public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginHeight = 0; layout.marginWidth = 5; container.setLayout(layout); tablePart.createControl(container); pluginListViewer = tablePart.getTableViewer(); pluginListViewer.setContentProvider(new BuildpathContentProvider()); pluginListViewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); GridData gd = (GridData) tablePart.getControl().getLayoutData(); gd.heightHint = 300; gd.widthHint = 300; pluginListViewer.setInput(PDEPlugin.getDefault()); if (fSelected != null && fSelected.length > 0) { tablePart.setSelection(fSelected); } setControl(container); Dialog.applyDialogFont(container); PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IHelpContextIds.UPDATE_CLASSPATH); }
private void handleNewPlugin() { NewPluginProjectWizard wizard = new NewPluginProjectWizard(); wizard.init(PDEPlugin.getActiveWorkbenchWindow().getWorkbench(), null); WizardDialog dialog = new WizardDialog(PDEPlugin.getActiveWorkbenchShell(), wizard); dialog.create(); SWTUtil.setDialogSize(dialog, 400, 500); if (dialog.open() == Window.OK) { addPlugin(wizard.getPluginId(), wizard.getPluginVersion()); } }
/** * Gets a list of all the bundles that can be added as implicit dependencies * * @return list of possible dependencies */ protected BundleInfo[] getValidBundles() throws CoreException { NameVersionDescriptor[] current = getTargetDefinition().getImplicitDependencies(); Set<String> currentBundles = new HashSet<String>(); if (current != null) { for (int i = 0; i < current.length; i++) { if (!currentBundles.contains(current[i].getId())) { currentBundles.add(current[i].getId()); } } } List<BundleInfo> targetBundles = new ArrayList<BundleInfo>(); TargetBundle[] allTargetBundles = getTargetDefinition().getAllBundles(); if (allTargetBundles == null || allTargetBundles.length == 0) { throw new CoreException( new Status( IStatus.WARNING, PDEPlugin.getPluginId(), PDEUIMessages.ImplicitDependenciesSection_0)); } for (int i = 0; i < allTargetBundles.length; i++) { BundleInfo bundleInfo = allTargetBundles[i].getBundleInfo(); if (!currentBundles.contains(bundleInfo.getSymbolicName())) { currentBundles.add(bundleInfo.getSymbolicName()); // to avoid duplicate entries targetBundles.add(bundleInfo); } } return targetBundles.toArray(new BundleInfo[targetBundles.size()]); }
private void handleAdd() { ElementListSelectionDialog dialog = new ElementListSelectionDialog( PDEPlugin.getActiveWorkbenchShell(), PDEPlugin.getDefault().getLabelProvider()); dialog.setElements(getBundles()); dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title); dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message); dialog.setMultipleSelection(true); if (dialog.open() == Window.OK) { Object[] bundles = dialog.getResult(); for (int i = 0; i < bundles.length; i++) { BundleDescription desc = (BundleDescription) bundles[i]; addPlugin(desc.getSymbolicName(), "0.0.0"); // $NON-NLS-1$ // addPlugin(desc.getSymbolicName(), desc.getVersion().toString()); } } }
private void handleGoToPackage(ISelection selection) { IPackageFragment frag = getPackageFragment(selection); if (frag != null) try { IViewPart part = PDEPlugin.getActivePage().showView(JavaUI.ID_PACKAGES); ShowInPackageViewAction action = new ShowInPackageViewAction(part.getSite()); action.run(frag); } catch (PartInitException e) { } }
private void handleExistingProjects() { ArrayList<Object> result = new ArrayList<>(); for (int i = 0; i < fModels.length; i++) { String id = fModels[i].getPluginBase().getId(); IProject project = (IProject) PDEPlugin.getWorkspace().getRoot().findMember(id); if (project != null && project.isOpen() && WorkspaceModelManager.isPluginProject(project)) { result.add(fModels[i]); } } handleSetImportSelection(result); }
public NewLibraryPluginCreationUpdateRefPage( LibraryPluginFieldData data, Collection<?> initialJarPaths, Collection<?> selection) { super("UpdateReferences"); // $NON-NLS-1$ setTitle(PDEUIMessages.UpdateBuildpathWizard_title); setDescription(PDEUIMessages.UpdateBuildpathWizard_desc); computeUnmigrated(); computeSelected(selection); fData = data; tablePart = new TablePart(PDEUIMessages.UpdateBuildpathWizard_availablePlugins); PDEPlugin.getDefault().getLabelProvider().connect(this); }
private void handleProperties() { IStructuredSelection ssel = (IStructuredSelection) fPluginTable.getSelection(); if (ssel.size() == 1) { IProductPlugin plugin = (IProductPlugin) ssel.toArray()[0]; VersionDialog dialog = new VersionDialog(PDEPlugin.getActiveWorkbenchShell(), isEditable(), plugin.getVersion()); dialog.create(); SWTUtil.setDialogSize(dialog, 400, 200); if (dialog.open() == Window.OK) { plugin.setVersion(dialog.getVersion()); } } }
private void computeUnmigrated() { IPluginModelBase[] models = PluginRegistry.getWorkspaceModels(); ArrayList<IPluginModelBase> modelArray = new ArrayList<IPluginModelBase>(); try { for (int i = 0; i < models.length; i++) { if (models[i].getUnderlyingResource().getProject().hasNature(JavaCore.NATURE_ID)) modelArray.add(models[i]); } } catch (CoreException e) { PDEPlugin.logException(e); } fUnmigrated = modelArray.toArray(new IPluginModelBase[modelArray.size()]); }
private void createImpTable(Composite container) { fElementViewer = new TableViewer(container, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 250; fElementViewer.getControl().setLayoutData(gd); fElementViewer.getControl().setFont(container.getFont()); fElementViewer.setContentProvider( new DefaultTableProvider() { public Object[] getElements(Object inputElement) { ITargetDefinition target = getTargetDefinition(); if (target != null) { NameVersionDescriptor[] bundles = target.getImplicitDependencies(); if (bundles != null) { return bundles; } } return new NameVersionDescriptor[0]; } }); fElementViewer.setLabelProvider(new StyledBundleLabelProvider(false, false)); fElementViewer.setInput(PDEPlugin.getDefault()); fElementViewer.setComparator( new ViewerComparator() { public int compare(Viewer viewer, Object e1, Object e2) { NameVersionDescriptor bundle1 = (NameVersionDescriptor) e1; NameVersionDescriptor bundle2 = (NameVersionDescriptor) e2; return super.compare(viewer, bundle1.getId(), bundle2.getId()); } }); fElementViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateImpButtons(); } }); fElementViewer .getTable() .addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.character == SWT.DEL && e.stateMask == 0) { handleRemove(); } } }); }
/* (non-Javadoc) * @see org.eclipse.pde.internal.ui.editor.PDESection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit) */ protected void createClient(Section section, FormToolkit toolkit) { section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); GridData sectionData = new GridData(GridData.FILL_BOTH); sectionData.verticalSpan = 2; section.setLayoutData(sectionData); Composite container = createClientContainer(section, 2, toolkit); createViewerPartControl(container, SWT.MULTI, 2, toolkit); container.setLayoutData(new GridData(GridData.FILL_BOTH)); createOptionalDependenciesButton(container); TablePart tablePart = getTablePart(); fPluginTable = tablePart.getTableViewer(); fPluginTable.setContentProvider(new ContentProvider()); fPluginTable.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); fPluginTable.setComparator( new ViewerComparator() { public int compare(Viewer viewer, Object e1, Object e2) { IProductPlugin p1 = (IProductPlugin) e1; IProductPlugin p2 = (IProductPlugin) e2; return super.compare(viewer, p1.getId(), p2.getId()); } }); GridData data = (GridData) tablePart.getControl().getLayoutData(); data.minimumWidth = 200; fPluginTable.setInput(getProduct()); tablePart.setButtonEnabled(0, isEditable()); tablePart.setButtonEnabled(1, isEditable()); tablePart.setButtonEnabled(2, isEditable()); // remove buttons will be updated on refresh tablePart.setButtonEnabled(5, isEditable()); toolkit.paintBordersFor(container); section.setClient(container); section.setText(PDEUIMessages.Product_PluginSection_title); section.setDescription(PDEUIMessages.Product_PluginSection_desc); getModel().addModelChangedListener(this); createSectionToolbar(section, toolkit); }
@Override protected void createClient(Section section, FormToolkit toolkit) { section.setText(PDEUIMessages.ExportPackageSection_title); if (isFragment()) section.setDescription(PDEUIMessages.ExportPackageSection_descFragment); else section.setDescription(PDEUIMessages.ExportPackageSection_desc); Composite container = createClientContainer(section, 2, toolkit); createViewerPartControl(container, SWT.MULTI, 2, toolkit); TablePart tablePart = getTablePart(); fPackageViewer = tablePart.getTableViewer(); fPackageViewer.setContentProvider(new ExportPackageContentProvider()); fPackageViewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); fPackageViewer.setComparator( new ViewerComparator() { @Override public int compare(Viewer viewer, Object e1, Object e2) { String s1 = e1.toString(); String s2 = e2.toString(); if (s1.indexOf(" ") != -1) // $NON-NLS-1$ s1 = s1.substring(0, s1.indexOf(" ")); // $NON-NLS-1$ if (s2.indexOf(" ") != -1) // $NON-NLS-1$ s2 = s2.substring(0, s2.indexOf(" ")); // $NON-NLS-1$ return super.compare(viewer, s1, s2); } }); toolkit.paintBordersFor(container); section.setClient(container); GridData gd = new GridData(GridData.FILL_BOTH); if (((ManifestEditor) getPage().getEditor()).isEquinox()) { gd.verticalSpan = 2; gd.minimumWidth = 300; } section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); section.setLayoutData(gd); makeActions(); IBundleModel model = getBundleModel(); fPackageViewer.setInput(model); model.addModelChangedListener(this); updateButtons(); }
private void handleAddWorkingSet() { IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager(); IWorkingSetSelectionDialog dialog = manager.createWorkingSetSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), true); if (dialog.open() == Window.OK) { IWorkingSet[] workingSets = dialog.getSelection(); IProduct product = getProduct(); IProductModelFactory factory = product.getModel().getFactory(); ArrayList<IProductPlugin> pluginList = new ArrayList<IProductPlugin>(); for (int i = 0; i < workingSets.length; i++) { IAdaptable[] elements = workingSets[i].getElements(); for (int j = 0; j < elements.length; j++) { IPluginModelBase model = findModel(elements[j]); if (model != null) { IProductPlugin plugin = factory.createPlugin(); IPluginBase base = model.getPluginBase(); plugin.setId(base.getId()); pluginList.add(plugin); } } } product.addPlugins(pluginList.toArray(new IProductPlugin[pluginList.size()])); } }
private void handleAdd() { IPluginModelBase model = (IPluginModelBase) getPage().getModel(); final IProject project = model.getUnderlyingResource().getProject(); try { if (project.hasNature(JavaCore.NATURE_ID)) { ILabelProvider labelProvider = new JavaElementLabelProvider(); final ConditionalListSelectionDialog dialog = new ConditionalListSelectionDialog( PDEPlugin.getActiveWorkbenchShell(), labelProvider, PDEUIMessages.ExportPackageSection_dialogButtonLabel); final Collection<?> pckgs = fHeader == null ? new Vector<>() : fHeader.getPackageNames(); final boolean allowJava = "true".equals(getBundle().getHeader(ICoreConstants.ECLIPSE_JREBUNDLE)); // $NON-NLS-1$ Runnable runnable = new Runnable() { @Override public void run() { ArrayList<IPackageFragment> elements = new ArrayList<>(); ArrayList<IPackageFragment> conditional = new ArrayList<>(); IPackageFragment[] fragments = PDEJavaHelper.getPackageFragments(JavaCore.create(project), pckgs, allowJava); for (IPackageFragment fragment : fragments) { try { if (fragment.containsJavaResources()) { elements.add(fragment); } else { conditional.add(fragment); } } catch (JavaModelException e) { } } dialog.setElements(elements.toArray()); dialog.setConditionalElements(conditional.toArray()); dialog.setMultipleSelection(true); dialog.setMessage(PDEUIMessages.PackageSelectionDialog_label); dialog.setTitle(PDEUIMessages.ExportPackageSection_title); dialog.create(); PlatformUI.getWorkbench() .getHelpSystem() .setHelp(dialog.getShell(), IHelpContextIds.EXPORT_PACKAGES); SWTUtil.setDialogSize(dialog, 400, 500); } }; BusyIndicator.showWhile(Display.getCurrent(), runnable); if (dialog.open() == Window.OK) { Object[] selected = dialog.getResult(); if (fHeader != null) { for (Object selectedObject : selected) { IPackageFragment candidate = (IPackageFragment) selectedObject; fHeader.addPackage( new ExportPackageObject(fHeader, candidate, getVersionAttribute())); } } else { getBundle().setHeader(getExportedPackageHeader(), getValue(selected)); // the way events get triggered, updateButtons isn't called if (selected.length > 0) getTablePart().setButtonEnabled(CALCULATE_USE_INDEX, true); } } labelProvider.dispose(); } } catch (CoreException e) { } }