1 11 package org.eclipse.pde.internal.ui.launcher; 12 13 import java.util.Map ; 14 15 import org.eclipse.jface.dialogs.Dialog; 16 import org.eclipse.jface.dialogs.IDialogConstants; 17 import org.eclipse.jface.dialogs.TrayDialog; 18 import org.eclipse.jface.viewers.ITreeContentProvider; 19 import org.eclipse.jface.viewers.TreeViewer; 20 import org.eclipse.jface.viewers.ViewerComparator; 21 import org.eclipse.osgi.service.resolver.BundleDescription; 22 import org.eclipse.pde.internal.ui.PDEPlugin; 23 import org.eclipse.pde.internal.ui.PDEUIMessages; 24 import org.eclipse.pde.internal.ui.elements.DefaultContentProvider; 25 import org.eclipse.swt.SWT; 26 import org.eclipse.swt.layout.GridData; 27 import org.eclipse.swt.widgets.Composite; 28 import org.eclipse.swt.widgets.Control; 29 import org.eclipse.swt.widgets.Label; 30 import org.eclipse.swt.widgets.Shell; 31 32 33 public class PluginStatusDialog extends TrayDialog { 34 35 class ContentProvider extends DefaultContentProvider implements ITreeContentProvider { 36 37 public Object [] getChildren(Object parentElement) { 38 return (Object [])fInput.get(parentElement); 39 } 40 41 public Object getParent(Object element) { 42 return null; 43 } 44 45 public boolean hasChildren(Object element) { 46 return fInput.containsKey(element) && element instanceof BundleDescription; 47 } 48 49 public Object [] getElements(Object inputElement) { 50 return ((Map )inputElement).keySet().toArray(); 51 } 52 53 } 54 55 private boolean fShowCancelButton; 56 private Map fInput; 57 private TreeViewer treeViewer; 58 59 public PluginStatusDialog(Shell parentShell, int style) { 60 super(parentShell); 61 setShellStyle(style); 62 PDEPlugin.getDefault().getLabelProvider().connect(this); 63 } 64 65 public PluginStatusDialog(Shell parentShell) { 66 super(parentShell); 67 setShellStyle(getShellStyle()|SWT.RESIZE); 68 PDEPlugin.getDefault().getLabelProvider().connect(this); 69 } 70 71 public void showCancelButton(boolean showCancel) { 72 fShowCancelButton = showCancel; 73 } 74 75 public void setInput(Map input) { 76 fInput = input; 77 } 78 79 82 protected void createButtonsForButtonBar(Composite parent) { 83 createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); 84 if (fShowCancelButton) 85 createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true); 86 } 87 88 protected Control createDialogArea(Composite parent) { 89 Composite container = (Composite) super.createDialogArea(parent); 90 GridData gd = new GridData(GridData.FILL_BOTH); 91 gd.widthHint = 400; 92 gd.heightHint = 300; 93 container.setLayoutData(gd); 94 95 Label label = new Label(container, SWT.NONE); 96 label.setText(PDEUIMessages.PluginStatusDialog_label); 97 98 treeViewer = new TreeViewer(container); 99 treeViewer.setContentProvider(new ContentProvider()); 100 treeViewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); 101 treeViewer.setComparator(new ViewerComparator()); 102 treeViewer.setInput(fInput); 103 treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); 104 105 getShell().setText(PDEUIMessages.PluginStatusDialog_pluginValidation); 106 Dialog.applyDialogFont(container); 107 return container; 108 } 109 110 public boolean close() { 111 PDEPlugin.getDefault().getLabelProvider().disconnect(this); 112 return super.close(); 113 } 114 115 public void refresh(Map input) { 116 fInput = input; 117 treeViewer.setInput(input); 118 treeViewer.refresh(); 119 } 120 121 } 122 | Popular Tags |