private void createOptionalDependenciesButton(Composite container) { if (isEditable()) { fIncludeOptionalButton = new Button(container, SWT.CHECK); fIncludeOptionalButton.setText(PDEUIMessages.PluginSection_includeOptional); // initialize value IEditorInput input = getPage().getEditorInput(); if (input instanceof IFileEditorInput) { IFile file = ((IFileEditorInput) input).getFile(); try { fIncludeOptionalButton.setSelection( "true".equals(file.getPersistentProperty(OPTIONAL_PROPERTY))); // $NON-NLS-1$ } catch (CoreException e) { } } // create listener to save value when the checkbox is changed fIncludeOptionalButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { IEditorInput input = getPage().getEditorInput(); if (input instanceof IFileEditorInput) { IFile file = ((IFileEditorInput) input).getFile(); try { file.setPersistentProperty( OPTIONAL_PROPERTY, fIncludeOptionalButton.getSelection() ? "true" : null); // $NON-NLS-1$ } catch (CoreException e1) { } } } }); } }
/* (non-Javadoc) * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#buttonSelected(int) */ protected void buttonSelected(int index) { switch (index) { case 0: handleAdd(); break; case 1: handleAddWorkingSet(); break; case 2: handleAddRequired(getProduct().getPlugins(), fIncludeOptionalButton.getSelection()); break; case 3: handleDelete(); break; case 4: handleRemoveAll(); break; case 5: handleProperties(); break; } }
public boolean includeOptionalDependencies() { return fIncludeOptionalButton.getSelection(); }