コード例 #1
0
 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);
 }
コード例 #2
0
 protected void enableMinMax(boolean enable) {
   fMinOccurSpinner.setEnabled(enable);
   fMaxOccurSpinner.setEnabled(!fUnboundSelect.getSelection() && enable);
   fUnboundSelect.setEnabled(enable);
   fMinLabel.setEnabled(enable);
   fMaxLabel.setEnabled(enable);
 }
コード例 #3
0
 protected int getMaxOccur() {
   if (fMaxOccurSpinner != null) {
     if (fMaxOccurSpinner.isEnabled()) return fMaxOccurSpinner.getSelection();
     return Integer.MAX_VALUE;
   }
   return 1;
 }
コード例 #4
0
  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;
  }
コード例 #5
0
 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);
         }
       });
 }
コード例 #6
0
 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);
         }
       });
 }
コード例 #7
0
 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;
 }
コード例 #8
0
 protected void updateMinOccur(int min) {
   if (fMinOccurSpinner != null) fMinOccurSpinner.setSelection(min);
 }
コード例 #9
0
 protected int getMinOccur() {
   if (fMinOccurSpinner != null) return fMinOccurSpinner.getSelection();
   return 0;
 }