/* (non-Javadoc) * @see org.eclipse.swt.widgets.Control#setEnabled(boolean) */ public void setEnabled(boolean enabled) { fTree.getControl().setEnabled(enabled); if (enabled) { updateButtons(); } else { fSelectButton.setEnabled(false); fSelectAllButton.setEnabled(false); fDeselectButton.setEnabled(false); fDeselectAllButton.setEnabled(false); fSelectRequiredButton.setEnabled(false); fCountLabel.setText(""); // $NON-NLS-1$ } fModeLabel.setEnabled(enabled); fPluginModeButton.setEnabled(enabled); fFeaureModeButton.setEnabled(enabled); fShowLabel.setEnabled(enabled); fShowPluginsButton.setEnabled(enabled); fShowSourceButton.setEnabled(enabled); boolean isPluginMode = !fFeaureModeButton.getSelection(); fGroupLabel.setEnabled(enabled && isPluginMode); if (fGroupCombo != null) { fGroupCombo.setEnabled(enabled && isPluginMode); } else { fGroupComboPart.setEnabled(enabled && isPluginMode); } }
/** * Creates a combo that controls whether a cursor is set on the registered controls. * * @return the created combo */ protected Combo createCursorCombo() { Composite group = new Composite(styleComp, SWT.NONE); group.setLayout(new GridLayout(2, false)); new Label(group, SWT.NONE).setText("Cursor"); final Combo combo = new Combo(group, SWT.READ_ONLY); combo.setItems(SWT_CURSORS); combo.select(0); combo.addSelectionListener( new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { String selection = null; int index = combo.getSelectionIndex(); if (index > 0) { selection = combo.getItem(index); } updateCursor(selection); } }); return combo; }
public ComboboxFigure(Composite parent, final IPropertySource propertySource) { super(); Combo cb = new Combo(parent, SWT.DROP_DOWN); cb.setVisible(false); cb.setBounds(-100, -100, 10, 10); Point p = cb.computeSize(SWT.DEFAULT, SWT.DEFAULT); cb.dispose(); mComboHeight = p.y; setLayoutManager(new XYLayout()); Rectangle[] bounds = calculateBounds( (Rectangle) propertySource.getPropertyValue(InstallOptionsWidget.PROPERTY_BOUNDS)); mComboFigure = new ComboFigure(parent, new CustomPropertySourceWrapper(propertySource, bounds[0])); mListFigure = new ListFigure( parent, new CustomPropertySourceWrapper(propertySource, bounds[1]), SWT.SINGLE); mListFigure.setBorder(new LineBorder(ColorManager.getColor(ColorManager.BLACK))); mListFigure.setVisible(mShowDropdown); add(mComboFigure); add(mListFigure); }
private void handleGroupChange() { int index; if (fGroupCombo != null) { index = fGroupCombo.getSelectionIndex(); } else { index = fGroupComboPart.getSelectionIndex(); } if (index != fGrouping) { // Refresh tree fGrouping = index; fTree.getControl().setRedraw(false); fTree.refresh(false); fTree.expandAll(); updateCheckState(); updateButtons(); fTree.getControl().setRedraw(true); } }
protected void updateJREWidgets() { fNamedJREsCombo.setEnabled(fNamedJREButton.getSelection()); fExecEnvsCombo.setEnabled(fExecEnvButton.getSelection()); }
private void createJREGroup(Composite container) { Group group = SWTFactory.createGroup( container, PDEUIMessages.EnvironmentBlock_jreTitle, 2, 1, GridData.FILL_HORIZONTAL); initializeJREValues(); SWTFactory.createWrapLabel(group, PDEUIMessages.JRESection_description, 2); fDefaultJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_defaultJRE, 2); fDefaultJREButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateJREWidgets(); getTargetDefinition().setJREContainer(JavaRuntime.newDefaultJREContainerPath()); } }); fNamedJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_JREName); fNamedJREButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateJREWidgets(); getTargetDefinition() .setJREContainer( JavaRuntime.newJREContainerPath( VMUtil.getVMInstall(fNamedJREsCombo.getText()))); } }); fNamedJREsCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, VMUtil.getVMInstallNames()); fNamedJREsCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition() .setJREContainer( JavaRuntime.newJREContainerPath( VMUtil.getVMInstall(fNamedJREsCombo.getText()))); } }); fExecEnvButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_ExecutionEnv); fExecEnvButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateJREWidgets(); getTargetDefinition() .setJREContainer( JavaRuntime.newJREContainerPath( VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText()))); } }); fExecEnvsCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, fExecEnvChoices.toArray(new String[fExecEnvChoices.size()])); fExecEnvsCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition() .setJREContainer( JavaRuntime.newJREContainerPath( VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText()))); } }); }
private void createTargetEnvironmentGroup(Composite container) { Group group = SWTFactory.createGroup( container, PDEUIMessages.EnvironmentBlock_targetEnv, 2, 1, GridData.FILL_HORIZONTAL); initializeChoices(); SWTFactory.createWrapLabel(group, PDEUIMessages.EnvironmentSection_description, 2); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_os, 1); fOSCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fOSChoices.toArray(new String[fOSChoices.size()])); fOSCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition().setOS(getModelValue(fOSCombo.getText())); } }); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_ws, 1); fWSCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fWSChoices.toArray(new String[fWSChoices.size()])); fWSCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition().setWS(getModelValue(fWSCombo.getText())); } }); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_arch, 1); fArchCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fArchChoices.toArray(new String[fArchChoices.size()])); fArchCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition().setArch(getModelValue(fArchCombo.getText())); } }); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_nl, 1); fNLCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fNLChoices.toArray(new String[fNLChoices.size()])); fNLCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { String value = fNLCombo.getText(); int index = value.indexOf("-"); // $NON-NLS-1$ if (index > 0) value = value.substring(0, index); getTargetDefinition().setNL(getModelValue(value)); } }); }
/* (non-Javadoc) * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged() */ protected void targetChanged(ITargetDefinition definition) { super.targetChanged(definition); if (definition != null) { // When If the page isn't open yet, try running a UI job so the dialog has time to finish // opening new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) { public IStatus runInUIThread(IProgressMonitor monitor) { ITargetDefinition definition = getTargetDefinition(); if (!definition.isResolved()) { try { getContainer() .run( true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { getTargetDefinition().resolve(new ResolutionProgressMonitor(monitor)); if (monitor.isCanceled()) { throw new InterruptedException(); } } }); } catch (InvocationTargetException e) { PDECore.log(e); } catch (InterruptedException e) { fContentTree.setCancelled(); return Status.CANCEL_STATUS; } } fContentTree.setInput(definition); fLocationTree.setInput(definition); if (definition.isResolved() && definition.getStatus().getSeverity() == IStatus.ERROR) { fLocationTab.setImage( PlatformUI.getWorkbench() .getSharedImages() .getImage(ISharedImages.IMG_OBJS_ERROR_TSK)); } else { fLocationTab.setImage(null); } return Status.OK_STATUS; } }.schedule(); String name = definition.getName(); if (name == null) { name = EMPTY_STRING; } if (name.trim().length() > 0) fNameText.setText(name); else setMessage(PDEUIMessages.TargetDefinitionContentPage_8); fLocationTree.setInput(definition); fContentTree.setInput(definition); String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS(); fOSCombo.setText(presetValue); presetValue = (definition.getWS() == null) ? EMPTY_STRING : definition.getWS(); fWSCombo.setText(presetValue); presetValue = (definition.getArch() == null) ? EMPTY_STRING : definition.getArch(); fArchCombo.setText(presetValue); presetValue = (definition.getNL() == null) ? EMPTY_STRING : LocaleUtil.expandLocaleName(definition.getNL()); fNLCombo.setText(presetValue); IPath jrePath = definition.getJREContainer(); if (jrePath == null || jrePath.equals(JavaRuntime.newDefaultJREContainerPath())) { fDefaultJREButton.setSelection(true); } else { String ee = JavaRuntime.getExecutionEnvironmentId(jrePath); if (ee != null) { fExecEnvButton.setSelection(true); fExecEnvsCombo.select(fExecEnvsCombo.indexOf(ee)); } else { String vm = JavaRuntime.getVMInstallName(jrePath); if (vm != null) { fNamedJREButton.setSelection(true); fNamedJREsCombo.select(fNamedJREsCombo.indexOf(vm)); } } } if (fExecEnvsCombo.getSelectionIndex() == -1) fExecEnvsCombo.setText(fExecEnvChoices.first().toString()); if (fNamedJREsCombo.getSelectionIndex() == -1) fNamedJREsCombo.setText(VMUtil.getDefaultVMInstallName()); updateJREWidgets(); presetValue = (definition.getProgramArguments() == null) ? EMPTY_STRING : definition.getProgramArguments(); fProgramArgs.setText(presetValue); presetValue = (definition.getVMArguments() == null) ? EMPTY_STRING : definition.getVMArguments(); fVMArgs.setText(presetValue); fElementViewer.refresh(); } }
/** * Creates the buttons in this group inside a new composite * * @param parent parent composite * @param toolkit toolkit to give form style or <code>null</code> for dialog style */ private void createButtons(Composite parent, FormToolkit toolkit) { if (toolkit != null) { Composite buttonComp = toolkit.createComposite(parent); GridLayout layout = new GridLayout(); layout.marginWidth = layout.marginHeight = 0; buttonComp.setLayout(layout); buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL)); fSelectButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_0, SWT.PUSH); fSelectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fDeselectButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_1, SWT.PUSH); fDeselectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Label emptySpace = new Label(buttonComp, SWT.NONE); GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectAllButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_2, SWT.PUSH); fSelectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fDeselectAllButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_3, SWT.PUSH); fDeselectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); emptySpace = new Label(buttonComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectRequiredButton = toolkit.createButton(buttonComp, Messages.TargetContentsGroup_4, SWT.PUSH); fSelectRequiredButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite filterComp = toolkit.createComposite(buttonComp); layout = new GridLayout(); layout.marginWidth = layout.marginHeight = 0; filterComp.setLayout(layout); filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true)); fModeLabel = toolkit.createLabel(filterComp, Messages.TargetContentsGroup_ManageUsing); fPluginModeButton = toolkit.createButton(filterComp, Messages.TargetContentsGroup_PluginMode, SWT.RADIO); fPluginModeButton.setSelection(true); fFeaureModeButton = toolkit.createButton(filterComp, Messages.TargetContentsGroup_FeatureMode, SWT.RADIO); fFeaureModeButton.setSelection(true); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fShowLabel = toolkit.createLabel(filterComp, Messages.BundleContainerTable_9); fShowPluginsButton = toolkit.createButton(filterComp, Messages.BundleContainerTable_14, SWT.CHECK); fShowPluginsButton.setSelection(true); fShowSourceButton = toolkit.createButton(filterComp, Messages.BundleContainerTable_15, SWT.CHECK); fShowSourceButton.setSelection(true); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fGroupLabel = toolkit.createLabel(filterComp, Messages.TargetContentsGroup_0); fGroupComboPart = new ComboPart(); fGroupComboPart.createControl(filterComp, toolkit, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalIndent = 10; fGroupComboPart.getControl().setLayoutData(gd); fGroupComboPart.setItems( new String[] { Messages.TargetContentsGroup_1, Messages.TargetContentsGroup_2, Messages.TargetContentsGroup_3 }); fGroupComboPart.setVisibleItemCount(30); fGroupComboPart.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handleGroupChange(); } }); fGroupComboPart.select(0); } else { Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0); fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null); fDeselectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null); Label emptySpace = new Label(buttonComp, SWT.NONE); GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null); fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null); emptySpace = new Label(buttonComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectRequiredButton = SWTFactory.createPushButton(buttonComp, Messages.TargetContentsGroup_4, null); Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0); filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true)); fModeLabel = SWTFactory.createLabel(filterComp, Messages.TargetContentsGroup_ManageUsing, 1); fPluginModeButton = SWTFactory.createRadioButton(filterComp, Messages.TargetContentsGroup_PluginMode); fFeaureModeButton = SWTFactory.createRadioButton(filterComp, Messages.TargetContentsGroup_FeatureMode); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1); fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1); fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fGroupLabel = SWTFactory.createLabel(filterComp, Messages.TargetContentsGroup_0, 1); fGroupCombo = SWTFactory.createCombo( filterComp, SWT.READ_ONLY, 1, new String[] { Messages.TargetContentsGroup_1, Messages.TargetContentsGroup_2, Messages.TargetContentsGroup_3 }); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalIndent = 10; fGroupCombo.setLayoutData(gd); fGroupCombo.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handleGroupChange(); } }); fGroupCombo.select(0); } fSelectButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fTree.getSelection().isEmpty()) { Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray(); for (int i = 0; i < selected.length; i++) { fTree.setChecked(selected[i], true); } saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } } }); fDeselectButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fTree.getSelection().isEmpty()) { Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray(); for (int i = 0; i < selected.length; i++) { fTree.setChecked(selected[i], false); } saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } } }); fSelectAllButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fTree.setAllChecked(true); saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } }); fDeselectAllButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fTree.setAllChecked(false); saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } }); fSelectRequiredButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Object[] allChecked = fTree.getCheckedLeafElements(); Object[] required = null; if (fFeaureModeButton.getSelection()) { required = getRequiredFeatures(fTargetDefinition.getAllFeatures(), allChecked); } else { required = getRequiredPlugins(fAllBundles, allChecked); } for (int i = 0; i < required.length; i++) { fTree.setChecked(required[i], true); } saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } }); fPluginModeButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // Moving from feature based filtering to plug-in based, need to update storage ((TargetDefinition) fTargetDefinition).setUIMode(TargetDefinition.MODE_PLUGIN); contentChanged(); fTargetDefinition.setIncluded(null); fGroupLabel.setEnabled(true); if (fGroupCombo != null) { fGroupCombo.setEnabled(true); } else { fGroupComboPart.getControl().setEnabled(true); } fTree.getControl().setRedraw(false); fTree.refresh(false); fTree.expandAll(); updateCheckState(); updateButtons(); fTree.getControl().setRedraw(true); } }); fPluginModeButton.setSelection(true); GridData gd = new GridData(); gd.horizontalIndent = 10; fPluginModeButton.setLayoutData(gd); fFeaureModeButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // Moving from plug-in based filtering to feature based, need to update storage ((TargetDefinition) fTargetDefinition).setUIMode(TargetDefinition.MODE_FEATURE); contentChanged(); fTargetDefinition.setIncluded(null); fGroupLabel.setEnabled(false); if (fGroupCombo != null) { fGroupCombo.setEnabled(false); } else { fGroupComboPart.getControl().setEnabled(false); } fTree.getControl().setRedraw(false); fTree.refresh(false); fTree.expandAll(); updateCheckState(); updateButtons(); fTree.getControl().setRedraw(true); } }); fFeaureModeButton.setSelection(false); gd = new GridData(); gd.horizontalIndent = 10; fFeaureModeButton.setLayoutData(gd); fShowPluginsButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fShowPluginsButton.getSelection()) { fTree.addFilter(fPluginFilter); } else { fTree.removeFilter(fPluginFilter); fTree.expandAll(); updateCheckState(); } updateButtons(); } }); fShowPluginsButton.setSelection(true); gd = new GridData(); gd.horizontalIndent = 10; fShowPluginsButton.setLayoutData(gd); fShowSourceButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fShowSourceButton.getSelection()) { fTree.addFilter(fSourceFilter); } else { fTree.removeFilter(fSourceFilter); fTree.expandAll(); updateCheckState(); } updateButtons(); } }); fShowSourceButton.setSelection(true); gd = new GridData(); gd.horizontalIndent = 10; fShowSourceButton.setLayoutData(gd); }