1 11 12 package org.eclipse.pde.internal.ui.wizards.feature; 13 14 import org.eclipse.jface.dialogs.Dialog; 15 import org.eclipse.jface.resource.*; 16 import org.eclipse.jface.viewers.*; 17 import org.eclipse.pde.internal.core.*; 18 import org.eclipse.pde.internal.core.ifeature.*; 19 import org.eclipse.pde.internal.ui.*; 20 import org.eclipse.pde.internal.ui.elements.*; 21 import org.eclipse.pde.internal.ui.wizards.*; 22 import org.eclipse.pde.internal.ui.wizards.feature.NewFeaturePatchWizard.*; 23 import org.eclipse.swt.*; 24 import org.eclipse.swt.layout.*; 25 import org.eclipse.swt.widgets.*; 26 import org.eclipse.ui.help.*; 27 28 31 public class PatchPluginListPage extends BasePluginListPage { 32 33 public static final String PAGE_TITLE = "PatchPlugins.title"; public static final String PAGE_DESC = "PatchPlugins.desc"; private IProjectProvider provider; 36 private CheckboxTableViewer pluginViewer; 37 38 41 public PatchPluginListPage(String pageName) { 42 super(pageName); 43 setTitle(PDEPlugin.getResourceString(PAGE_TITLE)); 44 setDescription(PDEPlugin.getResourceString(PAGE_DESC)); 45 } 46 47 50 public PatchPluginListPage(IProjectProvider provider) { 51 super("patchPluginList"); this.provider = provider; 53 setTitle(PDEPlugin.getResourceString(PAGE_TITLE)); 54 setDescription(PDEPlugin.getResourceString(PAGE_DESC)); 55 } 56 57 62 public PatchPluginListPage(String pageName, String title, 63 ImageDescriptor titleImage) { 64 super(pageName, title, titleImage); 65 } 66 67 class PluginContentProvider extends DefaultContentProvider 68 implements 69 IStructuredContentProvider { 70 71 public Object [] getElements(Object parent) { 72 return getPluginModels(); 73 } 74 } 75 76 public PatchPluginListPage() { 77 super("patchPluginListPage"); setTitle(PDEPlugin.getResourceString(PAGE_TITLE)); 79 setDescription(PDEPlugin.getResourceString(PAGE_DESC)); 80 } 81 82 public void createControl(Composite parent) { 83 Composite container = new Composite(parent, SWT.NULL); 84 GridLayout layout = new GridLayout(); 85 layout.numColumns = 2; 86 layout.verticalSpacing = 9; 87 container.setLayout(layout); 88 89 tablePart.createControl(container); 90 pluginViewer = tablePart.getTableViewer(); 91 pluginViewer.setContentProvider(new PluginContentProvider()); 92 pluginViewer 93 .setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); 94 pluginViewer.setSorter(ListUtil.PLUGIN_SORTER); 95 GridData gd = (GridData) tablePart.getControl().getLayoutData(); 96 gd.heightHint = 250; 97 pluginViewer.setInput(PDECore.getDefault().getWorkspaceModelManager()); 98 tablePart.setSelection(new Object [0]); 99 setControl(container); 100 Dialog.applyDialogFont(container); 101 WorkbenchHelp.setHelp(container, 102 IHelpContextIds.NEW_FEATURE_REFERENCED_PLUGINS); 103 } 104 105 private Object [] getPluginModels() { 106 IFeatureModel featureModel = ((FeaturePatchProvider)provider).getFeatureToPatch(); 107 if (featureModel== null) 108 return new Object [0]; 109 return featureModel.getFeature().getPlugins(); 110 } 111 112 public IFeaturePlugin[] getSelectedPlugins(){ 113 IFeatureModel featureModel = ((FeaturePatchProvider)provider).getFeatureToPatch(); 114 if (featureModel== null) 115 return new IFeaturePlugin[0]; 116 Object [] result = tablePart.getSelection(); 117 IFeaturePlugin[] plugins = new IFeaturePlugin[result.length]; 118 for (int i = 0 ;i<plugins.length; i++){ 119 plugins[i] = (IFeaturePlugin)result[i]; 120 } 121 return plugins; 122 } 123 124 127 public void setVisible(boolean visible) { 128 if (visible = true){ 129 pluginViewer.refresh(); 130 } 131 super.setVisible(visible); 132 } 133 } 134 | Popular Tags |