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.phpeclipse.xdebug.ui.views.logview;
13 import java.util.Comparator;
16 import net.sourceforge.phpeclipse.xdebug.ui.XDebugUIPlugin;
18 import org.eclipse.core.runtime.IAdaptable;
19 import org.eclipse.jface.util.Assert;
20 import org.eclipse.jface.viewers.ISelectionProvider;
21 import org.eclipse.swt.widgets.Shell;
22 import org.eclipse.ui.actions.SelectionProviderAction;
26 public class EventDetailsDialogAction extends SelectionProviderAction{
29 * The shell in which to open the property dialog
32 private ISelectionProvider provider;
33 private EventDetailsDialog propertyDialog;
34 private Comparator comparator;
36 * Creates a new action for opening a property dialog
37 * on the elements from the given selection provider
38 * @param shell - the shell in which the dialog will open
39 * @param provider - the selection provider whose elements
40 * the property dialog will describe
42 public EventDetailsDialogAction(Shell shell, ISelectionProvider provider){
43 super(provider, "Test Text");
44 Assert.isNotNull(shell);
46 this.provider = provider;
48 //WorkbenchHelp.setHelp
51 public boolean resetSelection(byte sortType, int sortOrder){
52 IAdaptable element = (IAdaptable) getStructuredSelection().getFirstElement();
55 if (propertyDialog != null && propertyDialog.isOpen()){
56 propertyDialog.resetSelection(element, sortType, sortOrder);
61 public void resetSelection(){
62 IAdaptable element = (IAdaptable) getStructuredSelection().getFirstElement();
65 if (propertyDialog != null && propertyDialog.isOpen())
66 propertyDialog.resetSelection(element);
69 public void resetDialogButtons(){
70 if (propertyDialog != null && propertyDialog.isOpen())
71 propertyDialog.resetButtons();
74 public void setComparator(Comparator comparator){
75 this.comparator = comparator;
78 if (propertyDialog != null && propertyDialog.isOpen()){
83 //get initial selection
84 IAdaptable element = (IAdaptable) getStructuredSelection().getFirstElement();
88 propertyDialog = new EventDetailsDialog(shell, element, provider);
89 propertyDialog.create();
90 propertyDialog.getShell().setText(XDebugUIPlugin.getString("EventDetailsDialog.title")); //$NON-NLS-1$
91 propertyDialog.setComparator(comparator);
92 propertyDialog.open();