1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.debug.core.logview;
13 import java.util.Comparator;
15 import net.sourceforge.phpdt.internal.debug.core.PHPDebugCorePlugin;
17 import org.eclipse.core.runtime.IAdaptable;
18 import org.eclipse.jface.util.Assert;
19 import org.eclipse.jface.viewers.ISelectionProvider;
20 import org.eclipse.swt.widgets.Shell;
21 import org.eclipse.ui.actions.SelectionProviderAction;
22 import org.eclipse.ui.internal.WorkbenchMessages;
25 public class EventDetailsDialogAction extends SelectionProviderAction{
28 * The shell in which to open the property dialog
31 private ISelectionProvider provider;
32 private EventDetailsDialog propertyDialog;
33 private Comparator comparator;
35 * Creates a new action for opening a property dialog
36 * on the elements from the given selection provider
37 * @param shell - the shell in which the dialog will open
38 * @param provider - the selection provider whose elements
39 * the property dialog will describe
41 public EventDetailsDialogAction(Shell shell, ISelectionProvider provider){
42 super(provider, WorkbenchMessages.getString("PropertyDialog.text")); //$NON-NLS-1$
43 Assert.isNotNull(shell);
45 this.provider = provider;
47 //WorkbenchHelp.setHelp
50 public boolean resetSelection(byte sortType, int sortOrder){
51 IAdaptable element = (IAdaptable) getStructuredSelection().getFirstElement();
54 if (propertyDialog != null && propertyDialog.isOpen()){
55 propertyDialog.resetSelection(element, sortType, sortOrder);
60 public void resetSelection(){
61 IAdaptable element = (IAdaptable) getStructuredSelection().getFirstElement();
64 if (propertyDialog != null && propertyDialog.isOpen())
65 propertyDialog.resetSelection(element);
68 public void resetDialogButtons(){
69 if (propertyDialog != null && propertyDialog.isOpen())
70 propertyDialog.resetButtons();
73 public void setComparator(Comparator comparator){
74 this.comparator = comparator;
77 if (propertyDialog != null && propertyDialog.isOpen()){
82 //get initial selection
83 IAdaptable element = (IAdaptable) getStructuredSelection().getFirstElement();
87 propertyDialog = new EventDetailsDialog(shell, element, provider);
88 propertyDialog.create();
89 propertyDialog.getShell().setText(PHPDebugCorePlugin.getResourceString("EventDetailsDialog.title")); //$NON-NLS-1$
90 propertyDialog.setComparator(comparator);
91 propertyDialog.open();