1 11 package org.eclipse.pde.internal.runtime.logview; 12 13 import java.util.Comparator ; 14 15 import org.eclipse.core.runtime.Assert; 16 import org.eclipse.core.runtime.IAdaptable; 17 import org.eclipse.jface.viewers.ISelectionProvider; 18 import org.eclipse.pde.internal.runtime.PDERuntimeMessages; 19 import org.eclipse.swt.widgets.Shell; 20 import org.eclipse.ui.actions.SelectionProviderAction; 21 22 23 public class EventDetailsDialogAction extends SelectionProviderAction{ 24 25 28 private Shell shell; 29 private ISelectionProvider provider; 30 private EventDetailsDialog propertyDialog; 31 private Comparator comparator; 32 39 public EventDetailsDialogAction(Shell shell, ISelectionProvider provider){ 40 super(provider, PDERuntimeMessages.EventDetailsDialog_title); 41 Assert.isNotNull(shell); 42 this.shell = shell; 43 this.provider = provider; 44 } 47 48 public boolean resetSelection(byte sortType, int sortOrder){ 49 IAdaptable element = (IAdaptable) getStructuredSelection().getFirstElement(); 50 if (element == null) 51 return false; 52 if (propertyDialog != null && propertyDialog.isOpen()){ 53 propertyDialog.resetSelection(element, sortType, sortOrder); 54 return true; 55 } 56 return false; 57 } 58 public void resetSelection(){ 59 IAdaptable element = (IAdaptable) getStructuredSelection().getFirstElement(); 60 if (element == null) 61 return; 62 if (propertyDialog != null && propertyDialog.isOpen()) 63 propertyDialog.resetSelection(element); 64 } 65 66 public void resetDialogButtons(){ 67 if (propertyDialog != null && propertyDialog.isOpen()) 68 propertyDialog.resetButtons(); 69 } 70 71 public void setComparator(Comparator comparator){ 72 this.comparator = comparator; 73 if (propertyDialog != null && propertyDialog.isOpen()) 74 propertyDialog.setComparator(comparator); 75 } 76 77 public void run(){ 78 if (propertyDialog != null && propertyDialog.isOpen()){ 79 resetSelection(); 80 return; 81 } 82 83 IAdaptable element = (IAdaptable) getStructuredSelection().getFirstElement(); 85 if (element == null) 86 return; 87 88 propertyDialog = new EventDetailsDialog(shell, element, provider, comparator); 89 propertyDialog.create(); 90 propertyDialog.getShell().setText(PDERuntimeMessages.EventDetailsDialog_title); 91 propertyDialog.open(); 92 } 93 } 94 | Popular Tags |