protected void enableMinMax(boolean enable) { fMinOccurSpinner.setEnabled(enable); fMaxOccurSpinner.setEnabled(!fUnboundSelect.getSelection() && enable); fUnboundSelect.setEnabled(enable); fMinLabel.setEnabled(enable); fMaxLabel.setEnabled(enable); }
protected Composite createMaxOccurComp(Composite parent, FormToolkit toolkit) { fMaxLabel = toolkit.createLabel(parent, PDEUIMessages.AbstractSchemaDetails_maxOccurLabel); fMaxLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); Composite comp = toolkit.createComposite(parent); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; GridLayout layout = new GridLayout(3, false); layout.marginHeight = layout.marginWidth = 0; comp.setLayout(layout); comp.setLayoutData(gd); fMaxOccurSpinner = new Spinner(comp, SWT.BORDER); fMaxOccurSpinner.setMinimum(1); fMaxOccurSpinner.setMaximum(999); fMaxOccurSpinner.setIncrement(1); fUnboundSelect = toolkit.createButton(comp, PDEUIMessages.AbstractSchemaDetails_unboundedButton, SWT.CHECK); gd = new GridData(); gd.horizontalIndent = 10; fUnboundSelect.setLayoutData(gd); fUnboundSelect.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (blockListeners()) return; fMaxOccurSpinner.setEnabled(!fUnboundSelect.getSelection() && isEditableElement()); } }); return comp; }
protected void updateMaxOccur(int max) { if (fMaxOccurSpinner == null) return; boolean isMax = max == Integer.MAX_VALUE; fUnboundSelect.setSelection(isMax); fMaxOccurSpinner.setEnabled(!isMax); if (!isMax) fMaxOccurSpinner.setSelection(max); }
protected int getMaxOccur() { if (fMaxOccurSpinner != null) { if (fMaxOccurSpinner.isEnabled()) return fMaxOccurSpinner.getSelection(); return Integer.MAX_VALUE; } return 1; }
private Spinner createSpinner(Composite parent, FormToolkit toolkit) { Spinner spinner = new Spinner(parent, SWT.BORDER); spinner.setMinimum(0); spinner.setMaximum(9999); toolkit.adapt(spinner, false, false); return spinner; }
private void createProgressMessageConfig(Composite parent) { fAddMessageButton = createButton(parent, fToolkit, PDEUIMessages.SplashSection_progressMessage); fAddMessageButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean enable = fAddMessageButton.getSelection(); getSplashInfo().addProgressMessage(enable, false); updateFieldEnablement(); } }); fAddMessageButton.setEnabled(false); Color foreground = fToolkit.getColors().getColor(IFormColors.TITLE); fMessageControls[0] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageX); fMessageControls[1] = fMessageSpinners[0] = createSpinner(parent, fToolkit); fMessageControls[2] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageY); fMessageControls[3] = fMessageSpinners[1] = createSpinner(parent, fToolkit); fMessageControls[4] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageWidth); fMessageControls[5] = fMessageSpinners[2] = createSpinner(parent, fToolkit); fMessageControls[6] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageHeight); fMessageControls[7] = fMessageSpinners[3] = createSpinner(parent, fToolkit); fMessageControls[8] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageColor); fColorSelector = new ColorSelector(parent); fColorSelector.addListener( new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { if (!event.getNewValue().equals(event.getOldValue())) applyColor(); } }); fToolkit.adapt(fColorSelector.getButton(), true, true); fMessageControls[9] = fColorSelector.getButton(); // Add tooltips to coordinate controls addOffsetTooltips(fMessageControls); for (Spinner spinner : fMessageSpinners) { spinner.setEnabled(isEditable()); spinner.addModifyListener( new ModifyListener() { @Override public void modifyText(ModifyEvent e) { applySpinners(false); } }); } }
@NotNull public static Spinner createLabelSpinner( @NotNull Composite parent, @NotNull String label, int value, int minimum, int maximum) { createControlLabel(parent, label); Spinner spinner = new Spinner(parent, SWT.BORDER); spinner.setMinimum(minimum); spinner.setMaximum(maximum); spinner.setSelection(value); return spinner; }
protected void hookMinOccur(SelectionAdapter adapter) { fMinOccurSpinner.addSelectionListener(adapter); fMinOccurSpinner.addModifyListener( new ModifyListener() { @Override public void modifyText(ModifyEvent e) { if (blockListeners()) return; int minOccur = fMinOccurSpinner.getSelection(); if (minOccur > getMaxOccur()) fMinOccurSpinner.setSelection(minOccur - 1); } }); }
protected void hookMaxOccur(SelectionAdapter adapter) { fUnboundSelect.addSelectionListener(adapter); fMaxOccurSpinner.addSelectionListener(adapter); fMaxOccurSpinner.addModifyListener( new ModifyListener() { @Override public void modifyText(ModifyEvent e) { if (blockListeners()) return; int maxValue = fMaxOccurSpinner.getSelection(); if (maxValue < getMinOccur()) fMaxOccurSpinner.setSelection(maxValue + 1); } }); }
private void createProgressBarConfig(Composite parent) { fAddBarButton = createButton(parent, fToolkit, PDEUIMessages.SplashSection_progressBar); fAddBarButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean enable = fAddBarButton.getSelection(); getSplashInfo().addProgressBar(enable, false); updateFieldEnablement(); } }); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.verticalIndent = 5; data.horizontalSpan = F_NUM_COLUMNS; fAddBarButton.setLayoutData(data); fAddBarButton.setEnabled(isEditable()); Color foreground = fToolkit.getColors().getColor(IFormColors.TITLE); fBarControls[0] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressX); fBarControls[1] = fBarSpinners[0] = createSpinner(parent, fToolkit); fBarControls[2] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressY); fBarControls[3] = fBarSpinners[1] = createSpinner(parent, fToolkit); fBarControls[4] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressWidth); fBarControls[5] = fBarSpinners[2] = createSpinner(parent, fToolkit); fBarControls[6] = createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressHeight); fBarControls[7] = fBarSpinners[3] = createSpinner(parent, fToolkit); // Add tooltips to coordinate controls addOffsetTooltips(fBarControls); for (Spinner spinner : fBarSpinners) { spinner.setEnabled(isEditable()); spinner.addModifyListener( new ModifyListener() { @Override public void modifyText(ModifyEvent e) { applySpinners(true); } }); } Composite filler = fToolkit.createComposite(parent); filler.setLayout(new GridLayout()); GridData gd = new GridData(); gd.horizontalSpan = 2; filler.setLayoutData(gd); }
protected Composite createMinOccurComp(Composite parent, FormToolkit toolkit) { fMinLabel = toolkit.createLabel(parent, PDEUIMessages.AbstractSchemaDetails_minOccurLabel); fMinLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); Composite comp = toolkit.createComposite(parent); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; GridLayout layout = new GridLayout(); layout.marginHeight = layout.marginWidth = 0; comp.setLayout(layout); comp.setLayoutData(gd); fMinOccurSpinner = new Spinner(comp, SWT.BORDER); fMinOccurSpinner.setMinimum(0); fMinOccurSpinner.setMaximum(999); return comp; }
protected void updateMinOccur(int min) { if (fMinOccurSpinner != null) fMinOccurSpinner.setSelection(min); }
protected int getMinOccur() { if (fMinOccurSpinner != null) return fMinOccurSpinner.getSelection(); return 0; }