@Override
  public void refresh() {
    initiatorText.removeFocusListener(listener);
    formKeyText.removeFocusListener(listener);
    PictogramElement pe = getSelectedPictogramElement();
    if (pe != null) {
      Object bo = getBusinessObject(pe);
      // the filter assured, that it is a EClass
      if (bo == null) return;

      StartEvent startEvent = ((StartEvent) bo);

      if (startEvent.getInitiator() != null) {
        initiatorText.setText(startEvent.getInitiator());
      } else {
        initiatorText.setText("");
      }

      if (startEvent.getFormKey() != null) {

        String condition = startEvent.getFormKey();
        formKeyText.setText(condition);
      } else {
        formKeyText.setText("");
      }
    }
    initiatorText.addFocusListener(listener);
    formKeyText.addFocusListener(listener);
  }
示例#2
0
  private void setContent() {
    CatFormInit init = new CatFormInit(cfg);

    Label lblName = init.lblName(this);
    txtName = init.txtName(this, lblName);
    Label lblAbbrev = init.lblAbbrev(this, lblName);
    txtAbbrev = init.txtAbbrev(this, lblAbbrev);
    virtCheck = init.virtCheck(this, txtAbbrev);
    Label lblRate = init.lblRate(this, lblAbbrev);

    Composite tableContainer = new Composite(this, SWT.SHADOW_ETCHED_IN);
    rateViewer = init.catRateViewer(tableContainer, getShell(), contentProvider);
    init.tableContainer(lblRate, tableContainer);
    tblRate = rateViewer.getTable();

    addBtn = init.addBtn(this, lblRate, tableContainer);
    delBtn = init.delBtn(this, lblRate, tableContainer);
    Label lblComment = init.lblComment(this, tableContainer);
    txtComment = init.txtComment(this, lblComment);

    txtName.addFocusListener(new RefreshFocusLsnr());
    txtAbbrev.addFocusListener(new RefreshFocusLsnr());
    txtComment.addFocusListener(new RefreshFocusLsnr());

    virtCheck.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            tblRate.setEnabled(!virtCheck.getSelection());
            addBtn.setEnabled(!virtCheck.getSelection());
            delBtn.setEnabled(!virtCheck.getSelection());
            refreshListener.refresh(); // освежим данные в дереве и в базе
          }
        });

    addBtn.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            contentProvider.append();
            rateViewer.refresh();
          }
        });

    delBtn.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            int selIdx = rateViewer.getTable().getSelectionIndex();
            if (selIdx >= 0) {
              contentProvider.deleteAt(selIdx);
            }
            rateViewer.refresh();
            Table table = rateViewer.getTable();
            int lastPos = table.getItemCount() - 1;
            table.setSelection(lastPos);
          }
        });
  }
  /**
   * 为Text控件增加灰色提醒,获得焦点时自动清除灰色提醒
   *
   * @param text Text控件
   * @param initTxt 灰色提醒字符串
   */
  private void setGray(final Text text, final String initTxt) {
    text.setForeground(gray);
    text.setText(initTxt);
    text.addFocusListener(
        new FocusListener() {
          public void focusLost(FocusEvent arg0) {
            if (text.getText().trim().equals("")) {
              if (!text.getForeground().equals(gray)) {
                text.setForeground(gray);
              }
              text.setText(initTxt);
            } else {
              if (!text.getForeground().equals(black)) {
                text.setForeground(black);
              }
            }
          }

          public void focusGained(FocusEvent arg0) {
            if (text.getText().trim().equals(initTxt)) {
              text.setText("");
              text.setForeground(black);
            } else {
              if (!text.getForeground().equals(black)) {
                text.setForeground(black);
              }
            }
          }
        });
  }
示例#4
0
  /**
   * Returns this field editor's text control.
   *
   * <p>The control is created if it does not yet exist
   *
   * @param parent the parent
   * @return the text control
   */
  public Text getTextControl(Composite parent) {
    if (textField == null) {
      textField = new Text(parent, SWT.SINGLE | SWT.BORDER);

      textField.setEchoChar('*');

      textField.setFont(parent.getFont());
      switch (validateStrategy) {
        case VALIDATE_ON_KEY_STROKE:
          textField.addKeyListener(
              new KeyAdapter() {

                /** {@inheritDoc} */
                @Override
                public void keyReleased(KeyEvent e) {
                  valueChanged();
                }
              });

          break;
        case VALIDATE_ON_FOCUS_LOST:
          textField.addKeyListener(
              new KeyAdapter() {
                @Override
                public void keyPressed(KeyEvent e) {
                  clearErrorMessage();
                }
              });
          textField.addFocusListener(
              new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                  refreshValidState();
                }

                @Override
                public void focusLost(FocusEvent e) {
                  valueChanged();
                  clearErrorMessage();
                }
              });
          break;
        default:
          Assert.isTrue(false, "Unknown validate strategy"); // $NON-NLS-1$
      }
      textField.addDisposeListener(
          new DisposeListener() {
            @Override
            public void widgetDisposed(DisposeEvent event) {
              textField = null;
            }
          });
      if (textLimit > 0) { // Only set limits above 0 - see SWT spec
        textField.setTextLimit(textLimit);
      }
    } else {
      checkParent(textField, parent);
    }
    return textField;
  }
  public void create(Composite parent) {
    text.addFocusListener(
        new FocusAdapter() {

          public void focusLost(FocusEvent e) {
            selectionBeforeFocusLost = text.getSelection();
            if (contentProposalAdapter != null && contentProposalAdapter.isProposalOpened()) {
              new AsynchronousThreading(
                      50,
                      false,
                      text.getDisplay(),
                      new Runnable() {

                        public void run() {
                          if (contentProposalAdapter != null
                              && contentProposalAdapter.isProposalOpened()
                              && contentProposalAdapter.hasFocus()) {
                            activateCellEditorAsynch(selectionBeforeFocusLost, false);
                          } else {
                            contentProposalAdapter.close();
                          }
                        }
                      })
                  .start();
            }
          }
        });

    initProposal();
  }
 protected Composite createValueText(FormToolkit widgetFactory, Composite parent) {
   FormUtils.createPartLabel(
       widgetFactory,
       parent,
       DroidMessages.BooleanVDPropertiesEditionPart_ValueLabel,
       propertiesEditionComponent.isRequired(
           DroidViewsRepository.BooleanVD.Properties.value, DroidViewsRepository.FORM_KIND));
   value = widgetFactory.createText(parent, ""); // $NON-NLS-1$
   value.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
   widgetFactory.paintBordersFor(parent);
   GridData valueData = new GridData(GridData.FILL_HORIZONTAL);
   value.setLayoutData(valueData);
   value.addFocusListener(
       new FocusAdapter() {
         /**
          * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
          */
         @Override
         @SuppressWarnings("synthetic-access")
         public void focusLost(FocusEvent e) {
           if (propertiesEditionComponent != null)
             propertiesEditionComponent.firePropertiesChanged(
                 new PropertiesEditionEvent(
                     BooleanVDPropertiesEditionPartForm.this,
                     DroidViewsRepository.BooleanVD.Properties.value,
                     PropertiesEditionEvent.COMMIT,
                     PropertiesEditionEvent.SET,
                     null,
                     value.getText()));
         }
       });
   value.addKeyListener(
       new KeyAdapter() {
         /** @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent) */
         @Override
         @SuppressWarnings("synthetic-access")
         public void keyPressed(KeyEvent e) {
           if (e.character == SWT.CR) {
             if (propertiesEditionComponent != null)
               propertiesEditionComponent.firePropertiesChanged(
                   new PropertiesEditionEvent(
                       BooleanVDPropertiesEditionPartForm.this,
                       DroidViewsRepository.BooleanVD.Properties.value,
                       PropertiesEditionEvent.COMMIT,
                       PropertiesEditionEvent.SET,
                       null,
                       value.getText()));
           }
         }
       });
   EditingUtils.setID(value, DroidViewsRepository.BooleanVD.Properties.value);
   EditingUtils.setEEFtype(value, "eef::Text"); // $NON-NLS-1$
   FormUtils.createHelpButton(
       widgetFactory,
       parent,
       propertiesEditionComponent.getHelpContent(
           DroidViewsRepository.BooleanVD.Properties.value, DroidViewsRepository.FORM_KIND),
       null); //$NON-NLS-1$
   return parent;
 }
 protected Composite createDescriptionText(FormToolkit widgetFactory, Composite parent) {
   createDescription(
       parent,
       InteractionViewsRepository.InteractionUse.Properties.description,
       InteractionMessages.InteractionUsePropertiesEditionPart_DescriptionLabel);
   description = widgetFactory.createText(parent, ""); // $NON-NLS-1$
   description.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
   widgetFactory.paintBordersFor(parent);
   GridData descriptionData = new GridData(GridData.FILL_HORIZONTAL);
   description.setLayoutData(descriptionData);
   description.addFocusListener(
       new FocusAdapter() {
         /**
          * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
          */
         @Override
         @SuppressWarnings("synthetic-access")
         public void focusLost(FocusEvent e) {
           if (propertiesEditionComponent != null)
             propertiesEditionComponent.firePropertiesChanged(
                 new PropertiesEditionEvent(
                     InteractionUsePropertiesEditionPartForm.this,
                     InteractionViewsRepository.InteractionUse.Properties.description,
                     PropertiesEditionEvent.COMMIT,
                     PropertiesEditionEvent.SET,
                     null,
                     description.getText()));
         }
       });
   description.addKeyListener(
       new KeyAdapter() {
         /** @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent) */
         @Override
         @SuppressWarnings("synthetic-access")
         public void keyPressed(KeyEvent e) {
           if (e.character == SWT.CR) {
             if (propertiesEditionComponent != null)
               propertiesEditionComponent.firePropertiesChanged(
                   new PropertiesEditionEvent(
                       InteractionUsePropertiesEditionPartForm.this,
                       InteractionViewsRepository.InteractionUse.Properties.description,
                       PropertiesEditionEvent.COMMIT,
                       PropertiesEditionEvent.SET,
                       null,
                       description.getText()));
           }
         }
       });
   EditingUtils.setID(
       description, InteractionViewsRepository.InteractionUse.Properties.description);
   EditingUtils.setEEFtype(description, "eef::Text"); // $NON-NLS-1$
   FormUtils.createHelpButton(
       widgetFactory,
       parent,
       propertiesEditionComponent.getHelpContent(
           InteractionViewsRepository.InteractionUse.Properties.description,
           InteractionViewsRepository.FORM_KIND),
       null); //$NON-NLS-1$
   return parent;
 }
  public static ContentProposalAdapter createPreferencesBacked(
      final Text text, String preferencesKey, String pluginId) {
    final ControlDecoration decoration = createContenProposalDecoration("History available", text);
    final StringsPreferenceValue preferencesValues =
        new StringsPreferenceValue(',', preferencesKey, pluginId);
    ContentProposalAdapter proposalAdapter = createContentProposal(text, preferencesValues.get());
    text.addFocusListener(
        new FocusAdapter() {

          @Override
          public void focusGained(FocusEvent e) {
            decoration.show();
          }

          @Override
          public void focusLost(FocusEvent e) {
            decoration.hide();
            String value = text.getText();
            if (value != null && value.length() > 0) {
              preferencesValues.add(text.getText());
            }
          }
        });
    return proposalAdapter;
  }
 /**
  * Set the edit mask string on the edit mask control.
  *
  * @param editMask The edit mask string
  */
 public void setMask(String editMask) {
   editMaskParser = new EditMaskParser(editMask);
   text.addVerifyListener(verifyListener);
   text.addFocusListener(focusListener);
   text.addDisposeListener(disposeListener);
   updateTextField.run();
   oldValidText = text.getText();
   oldValidRawText = editMaskParser.getRawResult();
 }
  /**
   * Returns this field editor's text control.
   *
   * <p>The control is created if it does not yet exist
   *
   * @param parent the parent
   * @return the text control
   */
  public Text getTextControl(Composite parent) {
    if (textField == null) {
      //            System.out.println("creating...");
      textField = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
      textField.setFont(parent.getFont());
      switch (validateStrategy) {
        case VALIDATE_ON_KEY_STROKE:
          textField.addKeyListener(
              new KeyAdapter() {

                /*
                 * (non-Javadoc)
                 *
                 * @see org.eclipse.swt.events.KeyAdapter#keyReleased(org.eclipse.swt.events.KeyEvent)
                 */
                public void keyReleased(KeyEvent e) {
                  valueChanged();
                }
              });

          break;
        case VALIDATE_ON_FOCUS_LOST:
          textField.addKeyListener(
              new KeyAdapter() {
                public void keyPressed(KeyEvent e) {
                  clearErrorMessage();
                }
              });
          textField.addFocusListener(
              new FocusAdapter() {
                public void focusGained(FocusEvent e) {
                  refreshValidState();
                }

                public void focusLost(FocusEvent e) {
                  valueChanged();
                  clearErrorMessage();
                }
              });
          break;
        default:
          Assert.isTrue(false, "Unknown validate strategy"); // $NON-NLS-1$
      }
      textField.addDisposeListener(
          new DisposeListener() {
            public void widgetDisposed(DisposeEvent event) {
              textField = null;
            }
          });
      if (textLimit > 0) { // Only set limits above 0 - see SWT spec
        textField.setTextLimit(textLimit);
      }
    } else {
      checkParent(textField, parent);
    }
    return textField;
  }
  /** @see IDialogPage#createControl(Composite) */
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 3;
    layout.verticalSpacing = 9;
    Label label = new Label(container, SWT.NULL);
    label.setText("&Container:");

    containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    containerText.setLayoutData(gd);
    containerText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            dialogChanged();
          }
        });

    Button button = new Button(container, SWT.PUSH);
    button.setText("Browse...");
    button.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            handleBrowse();
          }
        });
    label = new Label(container, SWT.NULL);
    label.setText("&File name:");

    fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    fileText.setLayoutData(gd);
    fileText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            dialogChanged();
          }
        });
    fileText.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            selectFileName();
          }
        });
    fileText.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            selectFileName();
          }
        });
    initialize();
    //		dialogChanged();
    setControl(container);
  }
示例#12
0
  protected void createFilterText(Composite parent) {
    filterText = doCreateFilterText(parent);

    filterText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(ModifyEvent e) {
            if (filterText.getText().length() > 0) {
              updateToolbar(true);
            } else {
              updateToolbar(false);
            }
          }
        });

    filterText.addFocusListener(
        new FocusAdapter() {
          public void focusGained(FocusEvent e) {}

          public void focusLost(FocusEvent e) {
            if (filterText.getText().equals(initialText)) {
              setFilterText(""); // $NON-NLS-1$
            }
          }
        });

    filterText.addMouseListener(
        new MouseAdapter() {
          public void mouseDown(MouseEvent e) {
            if (filterText.getText().equals(initialText)) {
              // We cannot call clearText() due to
              // [url]https://bugs.eclipse.org/bugs/show_bug.cgi?id=260664[/url]
              setFilterText(""); // $NON-NLS-1$
            }
          }
        });

    // if we're using a field with built in cancel we need to listen for
    // default selection changes (which tell us the cancel button has been
    // pressed)
    if ((filterText.getStyle() & SWT.ICON_CANCEL) != 0) {
      filterText.addSelectionListener(
          new SelectionAdapter() {
            public void widgetDefaultSelected(SelectionEvent e) {
              if (e.detail == SWT.ICON_CANCEL) clearText();
            }
          });
    }

    GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    // if the text widget supported cancel then it will have it's own
    // integrated button. We can take all of the space.
    if ((filterText.getStyle() & SWT.ICON_CANCEL) != 0) gridData.horizontalSpan = 2;
    filterText.setLayoutData(gridData);
  }
示例#13
0
  private void addFocusListener(final Text text) {
    text.addFocusListener(
        new FocusListener() {
          @Override
          public void focusLost(final FocusEvent e) {
            prev = text; // remember so we can clear only when new focus
            // gained, not when lost
            // FIXME: Wrong layout of '&' in rap
            checkWordValidity(text);
          }

          private void checkWordValidity(final Text text) {
            String current = text.getText();
            Word word = (Word) text.getData(Word.class.toString());
            String reference = word.history().top().form();
            if (current.length() != reference.length()
                || (current.contains(" ")
                    && !reference.contains(" "))) { // $NON-NLS-1$ //$NON-NLS-2$
              text.setForeground(text.getDisplay().getSystemColor(DUBIOUS));
              setMessage(Messages.get().YourRecentEdit);
            } else {
              status.setText(""); // $NON-NLS-1$
            }
          }

          @Override
          public void focusGained(final FocusEvent e) {
            text.clearSelection(); // use only our persistent marking below
            Word word = (Word) text.getData(Word.class.toString());
            if (word.isLocked()) {
              setMessage(
                  String.format(
                      Messages.get().Entry + " '%s' " + Messages.get().IsLocked,
                      text.getText())); // $NON-NLS-1$
            }
            text.setEditable(!word.isLocked() && !page.done());
            DrcUiActivator.find(CheckView.class).setSelection(text);
            DrcUiActivator.find(SpecialCharacterView.class).setText(text);
            DrcUiActivator.find(WordView.class).selectedWord(word, text);
            DrcUiActivator.find(TagView.class).setWord(word);
            text.setToolTipText(word.formattedHistory());
            if (prev != null
                && !prev.isDisposed()
                && !prev.getForeground().equals(text.getDisplay().getSystemColor(DUBIOUS))) {
              prev.setForeground(text.getDisplay().getSystemColor(DEFAULT));
            }
            text.setForeground(text.getDisplay().getSystemColor(ACTIVE));
          }

          private void setMessage(String t) {
            status.setText(t);
            status.setForeground(status.getDisplay().getSystemColor(DUBIOUS));
          }
        });
  }
  @Override
  public void exportBarChartPng() {

    try {

      final ActionDialogForm actionDialog =
          new ActionDialogForm(chartTarget.getShell(), "Ok", null, "PNG file name");
      final Text exportPngFileName =
          new Text(actionDialog.getParent(), SWT.NONE | SWT.CENTER | SWT.BORDER);
      exportPngFileName.setText("Type in the png file name");
      exportPngFileName.addFocusListener(
          new FocusListener() {

            @Override
            public void focusLost(FocusEvent e) {}

            @Override
            public void focusGained(FocusEvent e) {
              if (exportPngFileName.getText().equals("Type in the png file name"))
                exportPngFileName.setText("");
            }
          });
      ActionDialogAction actionDialogAction =
          new ActionDialogAction() {
            @Override
            public void action(Control targetControl) {

              actionDialog.values[0] = exportPngFileName.getText();

              try {
                // Export
                String filePath = System.getProperty("installdir") + File.separator + "tmp";
                String fileName = filePath + File.separator + actionDialog.values[0] + ".png";
                if (new File(fileName).exists())
                  throw new InvalidParameterException("File " + fileName + " already exists!");
                chartTarget.getMainChartWraper().exportChart(fileName);
              } catch (InvalidParameterException e) {
                throw e;
              } catch (Exception e) {
                LOGGER.error(e, e);
              }
            }
          };
      actionDialog.setControl(exportPngFileName);
      actionDialog.setAction(actionDialogAction);
      actionDialog.open();

    } catch (InvalidParameterException e) {
      throw e;
    } catch (Exception e) {
      LOGGER.warn(e, e);
    }
  }
 /**
  * Create the Control that will be presented to the user before selecting the bill output target.
  * Here we simply chose a template to use for the bill. In fact we need two templates: a template
  * for the page with summary and giro and a template for the other pages
  */
 public Control createSettingsControl(final Composite parent) {
   Composite ret = new Composite(parent, SWT.NONE);
   ret.setLayout(new GridLayout());
   new Label(ret, SWT.NONE).setText("Formatvorlage für Rechnung (ESR-Seite)");
   final Text tVorlageESR = new Text(ret, SWT.BORDER);
   tVorlageESR.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
   tVorlageESR.setText(
       CoreHub.globalCfg.get(
           PreferenceConstants.cfgTemplateESR, PreferenceConstants.DEFAULT_TEMPLATE_ESR));
   tVorlageESR.addFocusListener(
       new FocusAdapter() {
         @Override
         public void focusLost(final FocusEvent ev) {
           templateESR = tVorlageESR.getText();
           CoreHub.globalCfg.set(PreferenceConstants.cfgTemplateESR, templateESR);
         }
       });
   new Label(ret, SWT.NONE).setText("Formatvorlage für Rechnung (Folgeseiten)");
   final Text tVorlageRn = new Text(ret, SWT.BORDER);
   tVorlageRn.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
   tVorlageRn.setText(
       CoreHub.globalCfg.get(
           PreferenceConstants.cfgTemplateBill, PreferenceConstants.DEFAULT_TEMPLATE_BILL));
   tVorlageRn.addFocusListener(
       new FocusAdapter() {
         @Override
         public void focusLost(final FocusEvent ev) {
           templateBill = tVorlageRn.getText();
           CoreHub.globalCfg.set(PreferenceConstants.cfgTemplateBill, templateBill);
         }
       });
   tVorlageESR.setText(
       CoreHub.globalCfg.get(
           PreferenceConstants.cfgTemplateESR, PreferenceConstants.DEFAULT_TEMPLATE_ESR));
   tVorlageRn.setText(
       CoreHub.globalCfg.get(
           PreferenceConstants.cfgTemplateBill, PreferenceConstants.DEFAULT_TEMPLATE_BILL));
   return ret;
 }
 private Text createText(Composite parent, TabbedPropertySheetWidgetFactory factory, Control top) {
   Text text = factory.createText(parent, ""); // $NON-NLS-1$
   FormData data = new FormData();
   data.left = new FormAttachment(0, 160);
   data.right = new FormAttachment(100, -HSPACE);
   if (top == null) {
     data.top = new FormAttachment(0, VSPACE);
   } else {
     data.top = new FormAttachment(top, VSPACE);
   }
   text.setLayoutData(data);
   text.addFocusListener(listener);
   return text;
 }
  protected Composite createDescriptionTextarea(Composite parent) {
    Label descriptionLabel =
        createDescription(
            parent,
            EnvironmentViewsRepository.BindingElement.Properties.description,
            EnvironmentMessages.BindingElementPropertiesEditionPart_DescriptionLabel);
    GridData descriptionLabelData = new GridData(GridData.FILL_HORIZONTAL);
    descriptionLabelData.horizontalSpan = 3;
    descriptionLabel.setLayoutData(descriptionLabelData);
    description =
        SWTUtils.createScrollableText(parent, SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.V_SCROLL);
    GridData descriptionData = new GridData(GridData.FILL_HORIZONTAL);
    descriptionData.horizontalSpan = 2;
    descriptionData.heightHint = 80;
    descriptionData.widthHint = 200;
    description.setLayoutData(descriptionData);
    description.addFocusListener(
        new FocusAdapter() {

          /**
           * {@inheritDoc}
           *
           * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
           */
          public void focusLost(FocusEvent e) {
            if (propertiesEditionComponent != null)
              propertiesEditionComponent.firePropertiesChanged(
                  new PropertiesEditionEvent(
                      BindingElementPropertiesEditionPartImpl.this,
                      EnvironmentViewsRepository.BindingElement.Properties.description,
                      PropertiesEditionEvent.COMMIT,
                      PropertiesEditionEvent.SET,
                      null,
                      description.getText()));
          }
        });
    EditingUtils.setID(
        description, EnvironmentViewsRepository.BindingElement.Properties.description);
    EditingUtils.setEEFtype(description, "eef::Textarea"); // $NON-NLS-1$
    SWTUtils.createHelpButton(
        parent,
        propertiesEditionComponent.getHelpContent(
            EnvironmentViewsRepository.BindingElement.Properties.description,
            EnvironmentViewsRepository.SWT_KIND),
        null); //$NON-NLS-1$
    // Start of user code for createDescriptionTextArea

    // End of user code
    return parent;
  }
  private void createSearchStringField(final Composite parent, final FormToolkit toolkit) {
    m_nameField = new Text(parent, SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
    m_nameField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    m_nameField.setMessage(Messages.getString("TextSearchFilterControl_0")); // $NON-NLS-1$
    m_nameField.addFocusListener(new SelectAllFocusListener());

    addResetListener(m_nameField);

    final ISWTObservableValue target =
        SWTObservables.observeText(m_nameField, new int[] {SWT.Modify, SWT.DefaultSelection});
    final IObservableValue model =
        PojoObservables.observeValue(m_filter, TimeseriesBrowserTextSearchFilter.PROPERTY_STRING);
    m_binding.bindValue(target, model);

    if (toolkit != null) toolkit.adapt(m_nameField, true, true);

    m_nameField.setBackground(m_yellow);
  }
示例#19
0
    /*
     * Create a text control for showing the info about a proposal.
     */
    protected Control createDialogArea(Composite parent) {
      text = new Text(parent, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.NO_FOCUS);

      // Use the compact margins employed by PopupDialog.
      GridData gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
      gd.horizontalIndent = PopupDialog.POPUP_HORIZONTALSPACING;
      gd.verticalIndent = PopupDialog.POPUP_VERTICALSPACING;
      text.setLayoutData(gd);
      text.setText(contents);

      // since SWT.NO_FOCUS is only a hint...
      text.addFocusListener(
          new FocusAdapter() {
            public void focusGained(FocusEvent event) {
              ContentProposalPopup.this.close();
            }
          });
      return text;
    }
  /**
   * Create contents of the dialog
   *
   * @param parent
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    container.setLayout(gridLayout);

    Label label = new Label(container, SWT.NONE);
    label.setText("\u7EB9\u7406\u7C7B\u578B\uFF1A");

    comboTextureType = new Combo(container, SWT.READ_ONLY);
    comboTextureType.setItems(
        new String[] {
          "PVRTC4",
          "\u5206\u79BB\u900F\u660E\u901A\u9053\u7684PVRTC4",
          "ETC1",
          "\u5206\u79BB\u900F\u660E\u901A\u9053\u7684ETC1"
        });
    comboTextureType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboTextureType.select(0);

    Label label_1 = new Label(container, SWT.NONE);
    label_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    label_1.setText("\u6700\u5927\u7EB9\u7406\u5927\u5C0F\uFF1A");

    comboTextureSize = new Combo(container, SWT.READ_ONLY);
    comboTextureSize.setItems(new String[] {"512", "1024", "2048"});
    comboTextureSize.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboTextureSize.select(1);

    final Label label_3 = new Label(container, SWT.NONE);
    label_3.setText("\u63CF\u8FB9\u5BBD\u5EA6\uFF1A");

    textBorderWidth = new Text(container, SWT.BORDER);
    textBorderWidth.setText("2");
    textBorderWidth.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    textBorderWidth.addFocusListener(AutoSelectAll.instance);

    return container;
  }
  /**
   * Creates a public port component consisting of label and text box. Also adds a focus listener to
   * the text box.
   *
   * @param container
   */
  private void createPublicPortComponent(Composite container) {
    lblPublicPort = new Label(container, SWT.LEFT);
    GridData gridData = new GridData();
    gridData.horizontalIndent = 10;
    lblPublicPort.setLayoutData(gridData);
    lblPublicPort.setText(Messages.adRolPubPort);

    txtPublicPort = new Text(container, SWT.SINGLE | SWT.BORDER);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.END;
    gridData.grabExcessHorizontalSpace = true;
    gridData.widthHint = 75;
    txtPublicPort.setLayoutData(gridData);

    final Combo comboTemp = comboType;
    txtPublicPort.addFocusListener(
        new FocusListener() {
          @Override
          public void focusLost(FocusEvent event) {
            if (!comboTemp.getText().equalsIgnoreCase(WindowsAzureEndpointType.Internal.toString())
                && (txtPrivatePort.getText().isEmpty() || isSamePort)) {
              if (txtPublicPort.getText().contains("-")) {
                txtPrivatePort.setText(txtPublicPort.getText().split("-")[0]);
              } else {
                txtPrivatePort.setText(txtPublicPort.getText());
              }
            }
          }

          @Override
          public void focusGained(FocusEvent event) {
            String oldPort = txtPublicPort.getText();
            isSamePort = false;
            if (txtPrivatePort.getText().equals(oldPort)) {
              isSamePort = true;
            }
          }
        });
  }
    protected void init(Composite parent) {
      label = new Label(parent, SWT.NONE);
      label.setText(getLabel());

      String expression = null;
      if (bindingElement != null) {
        expression = bindingElement.getBindingExpression();
      }

      text = new Text(parent, SWT.BORDER);
      text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
      if (alreadyBound == true) {
        if (expression != null) {
          text.setText(expression);
        }
        text.addFocusListener(
            new FocusListener() {
              public void focusLost(FocusEvent e) {

                UpdateMappingExpressionCommand updMappingCmd =
                    new UpdateMappingExpressionCommand(
                        editorManager.getEditingDomain(),
                        editorManager.getAccessor(),
                        bindingElement,
                        ((Text) e.widget).getText());
                editorManager.execute(updMappingCmd);
              }

              public void focusGained(FocusEvent e) {}
            });
      } else {
        text.setText(LBL_NOT_YET_BOUND_ELEMENT);
        text.setEnabled(false);
        text.setEditable(false);
      }
    }
  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);

    GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
    container.setLayoutData(gridData);
    container.setLayout(new GridLayout(3, false));

    Label nameLabel = new Label(container, SWT.NONE);
    nameLabel.setText(ProjectMessages.NewApplicationWizardPage_project_name_label);

    projectNameField = new Text(container, SWT.BORDER);
    projectNameField.setText(""); // $NON-NLS-1$
    projectNameField.setToolTipText(ProjectMessages.NewApplicationWizardPage_project_name_tooltip);
    projectNameField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    projectNameField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            projectNameField.selectAll();
          }
        });
    projectNameField.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            updateName();
          }
        });

    Label locationLabel = new Label(container, SWT.NONE);
    locationLabel.setText(ProjectMessages.NewApplicationWizardPage_directory_label);

    projectLocationField = new Text(container, SWT.BORDER);
    projectLocationField.setText(defaultLocation);
    projectLocationField.setToolTipText(ProjectMessages.NewApplicationWizardPage_directory_tooltip);
    projectLocationField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    projectLocationField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            projectLocationField.selectAll();
          }
        });
    projectLocationField.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            updateLocation();
          }
        });

    Button browseButton = new Button(container, SWT.NONE);
    browseButton.setText(ProjectMessages.NewApplicationWizardPage_browse_label);
    browseButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleBrowseButton(projectLocationField);
          }
        });

    projectNameField.setFocus();

    Group contentGroup = new Group(container, SWT.NONE);
    //    contentGroup.setText("Create sample content");
    GridDataFactory.fillDefaults().span(3, 1).grab(true, false).indent(0, 10).applyTo(contentGroup);
    GridLayoutFactory.fillDefaults().margins(8, 8).applyTo(contentGroup);

    webAppCheckboxButton = new Button(contentGroup, SWT.CHECK);
    webAppCheckboxButton.setText(
        ProjectMessages.NewApplicationWizardPage_webAppCheckbox_name_label);
    webAppCheckboxButton.setSelection(getWebAppCheckboxEnabled());
    webAppCheckboxButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IDialogSettings settings =
                DartToolsPlugin.getDefault().getDialogSettingsSection(NEW_APPPLICATION_SETTINGS);
            settings.put(WEB_APP_CHECKBOX_DISABLED, !webAppCheckboxButton.getSelection());
          }
        });

    pubSupportCheckboxButton = new Button(contentGroup, SWT.CHECK);
    pubSupportCheckboxButton.setText(
        ProjectMessages.NewApplicationCreationPage_pubSupportCheckbox_name_label);
    pubSupportCheckboxButton.setSelection(getPubSupportCheckboxEnabled());
    pubSupportCheckboxButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IDialogSettings settings =
                DartToolsPlugin.getDefault().getDialogSettingsSection(NEW_APPPLICATION_SETTINGS);
            settings.put(PUB_SUPPORT_CHECKBOX_DISABLED, !pubSupportCheckboxButton.getSelection());
          }
        });

    setPageComplete(false);
  }
  protected Composite createCommentsTextarea(FormToolkit widgetFactory, Composite parent) {
    Label commentsLabel =
        createDescription(
            parent,
            EntityrelationViewsRepository.Identifier.Properties.comments,
            EntityrelationMessages.IdentifierPropertiesEditionPart_CommentsLabel);
    GridData commentsLabelData = new GridData(GridData.FILL_HORIZONTAL);
    commentsLabelData.horizontalSpan = 3;
    commentsLabel.setLayoutData(commentsLabelData);
    comments =
        widgetFactory.createText(
            parent, "", SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.V_SCROLL); // $NON-NLS-1$
    GridData commentsData = new GridData(GridData.FILL_HORIZONTAL);
    commentsData.horizontalSpan = 2;
    commentsData.heightHint = 80;
    commentsData.widthHint = 200;
    comments.setLayoutData(commentsData);
    comments.addFocusListener(
        new FocusAdapter() {

          /**
           * {@inheritDoc}
           *
           * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
           */
          public void focusLost(FocusEvent e) {
            if (propertiesEditionComponent != null) {
              propertiesEditionComponent.firePropertiesChanged(
                  new PropertiesEditionEvent(
                      IdentifierPropertiesEditionPartForm.this,
                      EntityrelationViewsRepository.Identifier.Properties.comments,
                      PropertiesEditionEvent.COMMIT,
                      PropertiesEditionEvent.SET,
                      null,
                      comments.getText()));
              propertiesEditionComponent.firePropertiesChanged(
                  new PropertiesEditionEvent(
                      IdentifierPropertiesEditionPartForm.this,
                      EntityrelationViewsRepository.Identifier.Properties.comments,
                      PropertiesEditionEvent.FOCUS_CHANGED,
                      PropertiesEditionEvent.FOCUS_LOST,
                      null,
                      comments.getText()));
            }
          }

          /**
           * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent)
           */
          @Override
          public void focusGained(FocusEvent e) {
            if (propertiesEditionComponent != null) {
              propertiesEditionComponent.firePropertiesChanged(
                  new PropertiesEditionEvent(
                      IdentifierPropertiesEditionPartForm.this,
                      null,
                      PropertiesEditionEvent.FOCUS_CHANGED,
                      PropertiesEditionEvent.FOCUS_GAINED,
                      null,
                      null));
            }
          }
        });
    EditingUtils.setID(comments, EntityrelationViewsRepository.Identifier.Properties.comments);
    EditingUtils.setEEFtype(comments, "eef::Textarea"); // $NON-NLS-1$
    FormUtils.createHelpButton(
        widgetFactory,
        parent,
        propertiesEditionComponent.getHelpContent(
            EntityrelationViewsRepository.Identifier.Properties.comments,
            EntityrelationViewsRepository.FORM_KIND),
        null); //$NON-NLS-1$
    // Start of user code for createCommentsTextArea

    // End of user code
    return parent;
  }
  /**
   * Create a new SecurityPolicyComposite.
   *
   * @param container the container
   * @param parent the parent composite
   * @param style style bits
   */
  public CompositeMainComposite(ICompositeContainer container, Composite parent, int style) {
    super(org.eclipse.soa.sca.sca1_1.model.sca.Composite.class, container, parent, style);

    FormLayout layout = new FormLayout();
    layout.marginBottom = ITabbedPropertyConstants.VMARGIN;
    layout.marginTop = ITabbedPropertyConstants.VMARGIN;
    layout.marginLeft = ITabbedPropertyConstants.HMARGIN;
    layout.marginRight = ITabbedPropertyConstants.HMARGIN;
    setLayout(layout);

    FormToolkit factory = getWidgetFactory();

    _nameText = factory.createText(this, ""); // $NON-NLS-1$
    FormData data = new FormData();
    data.left = new FormAttachment(0, 85);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, 4);
    _nameText.setLayoutData(data);

    _nameText.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            // ignore
          }

          @Override
          public void focusLost(FocusEvent e) {
            if (_businessObject != null && !_inUpdate) {
              updateObjectName(_businessObject, _nameText.getText().trim());
            }
          }
        });

    //        if (getContainer() instanceof PropertyPage) {
    //            _nameText.addModifyListener(new ModifyListener() {
    //
    //                @Override
    //                public void modifyText(ModifyEvent arg0) {
    //                    if (!_inUpdate) {
    //                        updateObjectName(_businessObject, _nameText.getText().trim());
    //                    }
    //                }
    //
    //            });
    //        } else {
    //            _nameText.addKeyListener(new KeyListener() {
    //                @Override
    //                public void keyPressed(KeyEvent e) {
    //                    // ignore
    //                }
    //
    //                @Override
    //                public void keyReleased(KeyEvent e) {
    //                    if (e.keyCode == SWT.ESC) {
    //                        _inUpdate = true;
    //                        String name = ((org.eclipse.soa.sca.sca1_1.model.sca.Composite)
    // _businessObject).getName();
    //                        _nameText.setText(name == null ? "" : name); //$NON-NLS-1$
    //                        _inUpdate = false;
    //                    } else if (e.keyCode == SWT.CR) {
    //                        updateObjectName(_businessObject, _nameText.getText().trim());
    //                    }
    //                }
    //            });
    //        }

    Label valueLabel = factory.createLabel(this, "Name:"); // $NON-NLS-1$
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(_nameText, -5);
    data.top = new FormAttachment(_nameText, 0, SWT.CENTER);
    valueLabel.setLayoutData(data);

    _targetNamespaceText = factory.createText(this, ""); // $NON-NLS-1$
    data = new FormData();
    Integer widthTimes1Point5 = new Integer((int) (85 * 1.5));
    data.left = new FormAttachment(0, widthTimes1Point5.intValue());
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(_nameText, 4);
    _targetNamespaceText.setLayoutData(data);

    _targetNamespaceText.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            // ignore
          }

          @Override
          public void focusLost(FocusEvent e) {
            if (_businessObject != null && !_inUpdate) {
              updateTargetNamespace(_businessObject, _targetNamespaceText.getText().trim());
            }
          }
        });

    _targetNamespaceText.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {
            // ignore
          }

          @Override
          public void keyReleased(KeyEvent e) {
            if (e.keyCode == SWT.ESC) {
              _inUpdate = true;
              undo(_targetNamespaceText);
              _inUpdate = false;
            } else if (e.keyCode == SWT.CR || e.keyCode == SWT.TAB) {
              updateTargetNamespace(_businessObject, _targetNamespaceText.getText().trim());
            }
          }
        });

    _tnsLabel = factory.createLabel(this, Messages.label_targetNamespace);
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(_targetNamespaceText, -5);
    data.top = new FormAttachment(_targetNamespaceText, 0, SWT.CENTER);
    _tnsLabel.setLayoutData(data);

    //        addDomainListener();
  }
  protected Composite createNameText(Composite parent) {
    SWTUtils.createPartLabel(
        parent,
        UmaMessages.GuidancePackagePropertiesEditionPart_NameLabel,
        propertiesEditionComponent.isRequired(
            UmaViewsRepository.GuidancePackage.Properties.name, UmaViewsRepository.SWT_KIND));
    name = new Text(parent, SWT.BORDER);
    GridData nameData = new GridData(GridData.FILL_HORIZONTAL);
    name.setLayoutData(nameData);
    name.addFocusListener(
        new FocusAdapter() {

          /**
           * {@inheritDoc}
           *
           * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
           */
          @Override
          @SuppressWarnings("synthetic-access")
          public void focusLost(FocusEvent e) {
            if (propertiesEditionComponent != null)
              propertiesEditionComponent.firePropertiesChanged(
                  new PropertiesEditionEvent(
                      GuidancePackagePropertiesEditionPartImpl.this,
                      UmaViewsRepository.GuidancePackage.Properties.name,
                      PropertiesEditionEvent.COMMIT,
                      PropertiesEditionEvent.SET,
                      null,
                      name.getText()));
          }
        });
    name.addKeyListener(
        new KeyAdapter() {

          /**
           * {@inheritDoc}
           *
           * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
           */
          @Override
          @SuppressWarnings("synthetic-access")
          public void keyPressed(KeyEvent e) {
            if (e.character == SWT.CR) {
              if (propertiesEditionComponent != null)
                propertiesEditionComponent.firePropertiesChanged(
                    new PropertiesEditionEvent(
                        GuidancePackagePropertiesEditionPartImpl.this,
                        UmaViewsRepository.GuidancePackage.Properties.name,
                        PropertiesEditionEvent.COMMIT,
                        PropertiesEditionEvent.SET,
                        null,
                        name.getText()));
            }
          }
        });
    EditingUtils.setID(name, UmaViewsRepository.GuidancePackage.Properties.name);
    EditingUtils.setEEFtype(name, "eef::Text"); // $NON-NLS-1$
    SWTUtils.createHelpButton(
        parent,
        propertiesEditionComponent.getHelpContent(
            UmaViewsRepository.GuidancePackage.Properties.name, UmaViewsRepository.SWT_KIND),
        null); //$NON-NLS-1$
    return parent;
  }
示例#27
0
  @Override
  protected void createControl(Composite parent) {
    isComputeField = field.isComputeField();
    String fieldType = field.getType();

    // 类型检查 并且根据数据类型设置文本的对齐方式
    int style;
    if (isComputeField) {
      style = SWT.NONE;
    } else {
      style = SWT.BORDER;
    }

    if (field.isPassword()) {
      style = style | SWT.PASSWORD;
    }

    if ((IFieldTypeConstants.FIELD_INTEGER.equals(fieldType))
        || (IFieldTypeConstants.FIELD_DOUBLE.equals(fieldType))) {
      style = style | SWT.RIGHT;
    } else if (IFieldTypeConstants.FIELD_STRING.equals(fieldType)) {

    } else {
      Assert.isLegal(false, TYPE_MISMATCH + field.getId());
    }

    control = new Text(parent, style);
    GridData td = getControlLayoutData();
    control.setLayoutData(td);

    if (!isComputeField) {
      // 设置字数限制
      int textLimit = field.getTextLimit();
      if (textLimit != 0) {
        control.setTextLimit(textLimit);
      }
      // 设置如何设置值
      control.addFocusListener(
          new FocusListener() {

            @Override
            public void focusLost(FocusEvent event) {
              // 如果只读,不做任何变化
              if (isEditable) {
                updateDataValueAndPresent();
              }
            }

            @Override
            public void focusGained(FocusEvent event) {
              if (isEditable && isValuePresented()) {
                String editableValue = getValue() == null ? "" : getValue().toString();
                control.setText(editableValue);
              }
            }
          });

      // 设置字数控制提示
      if ((textLimit != 0)
          && (field.isEditable())
          && (!isValuePresented())
          && (field.getType().equals(IFieldTypeConstants.FIELD_STRING))) {
        new TextLimitToolTipsControl(this);
      }

      // 设置编辑提示
      String textMessage = field.getTextMessage();
      if (!Util.isNullOrEmptyString(textMessage)) {
        control.setMessage(textMessage);
      }
    }
    super.createControl(parent);
  }
  protected Composite createNameText(Composite parent) {
    createDescription(
        parent,
        EntityrelationViewsRepository.Entity.Properties.name,
        EntityrelationMessages.EntityPropertiesEditionPart_NameLabel);
    name = SWTUtils.createScrollableText(parent, SWT.BORDER);
    GridData nameData = new GridData(GridData.FILL_HORIZONTAL);
    name.setLayoutData(nameData);
    name.addFocusListener(
        new FocusAdapter() {

          /**
           * {@inheritDoc}
           *
           * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
           */
          @Override
          @SuppressWarnings("synthetic-access")
          public void focusLost(FocusEvent e) {
            if (propertiesEditionComponent != null)
              propertiesEditionComponent.firePropertiesChanged(
                  new PropertiesEditionEvent(
                      EntityPropertiesEditionPartImpl.this,
                      EntityrelationViewsRepository.Entity.Properties.name,
                      PropertiesEditionEvent.COMMIT,
                      PropertiesEditionEvent.SET,
                      null,
                      name.getText()));
          }
        });
    name.addKeyListener(
        new KeyAdapter() {

          /**
           * {@inheritDoc}
           *
           * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
           */
          @Override
          @SuppressWarnings("synthetic-access")
          public void keyPressed(KeyEvent e) {
            if (e.character == SWT.CR) {
              if (propertiesEditionComponent != null)
                propertiesEditionComponent.firePropertiesChanged(
                    new PropertiesEditionEvent(
                        EntityPropertiesEditionPartImpl.this,
                        EntityrelationViewsRepository.Entity.Properties.name,
                        PropertiesEditionEvent.COMMIT,
                        PropertiesEditionEvent.SET,
                        null,
                        name.getText()));
            }
          }
        });
    EditingUtils.setID(name, EntityrelationViewsRepository.Entity.Properties.name);
    EditingUtils.setEEFtype(name, "eef::Text"); // $NON-NLS-1$
    SWTUtils.createHelpButton(
        parent,
        propertiesEditionComponent.getHelpContent(
            EntityrelationViewsRepository.Entity.Properties.name,
            EntityrelationViewsRepository.SWT_KIND),
        null); //$NON-NLS-1$
    // Start of user code for createNameText

    // End of user code
    return parent;
  }
  protected Composite createCommentText(FormToolkit widgetFactory, Composite parent) {
    createDescription(
        parent,
        ChecklistViewsRepository.Item.Properties.comment,
        ChecklistMessages.ItemPropertiesEditionPart_CommentLabel);
    comment = widgetFactory.createText(parent, ""); // $NON-NLS-1$
    comment.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
    widgetFactory.paintBordersFor(parent);
    GridData commentData = new GridData(GridData.FILL_HORIZONTAL);
    comment.setLayoutData(commentData);
    comment.addFocusListener(
        new FocusAdapter() {
          /**
           * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
           */
          @Override
          @SuppressWarnings("synthetic-access")
          public void focusLost(FocusEvent e) {
            if (propertiesEditionComponent != null) {
              propertiesEditionComponent.firePropertiesChanged(
                  new PropertiesEditionEvent(
                      ItemPropertiesEditionPartForm.this,
                      ChecklistViewsRepository.Item.Properties.comment,
                      PropertiesEditionEvent.COMMIT,
                      PropertiesEditionEvent.SET,
                      null,
                      comment.getText()));
              propertiesEditionComponent.firePropertiesChanged(
                  new PropertiesEditionEvent(
                      ItemPropertiesEditionPartForm.this,
                      ChecklistViewsRepository.Item.Properties.comment,
                      PropertiesEditionEvent.FOCUS_CHANGED,
                      PropertiesEditionEvent.FOCUS_LOST,
                      null,
                      comment.getText()));
            }
          }

          /**
           * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent)
           */
          @Override
          public void focusGained(FocusEvent e) {
            if (propertiesEditionComponent != null) {
              propertiesEditionComponent.firePropertiesChanged(
                  new PropertiesEditionEvent(
                      ItemPropertiesEditionPartForm.this,
                      null,
                      PropertiesEditionEvent.FOCUS_CHANGED,
                      PropertiesEditionEvent.FOCUS_GAINED,
                      null,
                      null));
            }
          }
        });
    comment.addKeyListener(
        new KeyAdapter() {
          /** @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent) */
          @Override
          @SuppressWarnings("synthetic-access")
          public void keyPressed(KeyEvent e) {
            if (e.character == SWT.CR) {
              if (propertiesEditionComponent != null)
                propertiesEditionComponent.firePropertiesChanged(
                    new PropertiesEditionEvent(
                        ItemPropertiesEditionPartForm.this,
                        ChecklistViewsRepository.Item.Properties.comment,
                        PropertiesEditionEvent.COMMIT,
                        PropertiesEditionEvent.SET,
                        null,
                        comment.getText()));
            }
          }
        });
    EditingUtils.setID(comment, ChecklistViewsRepository.Item.Properties.comment);
    EditingUtils.setEEFtype(comment, "eef::Text"); // $NON-NLS-1$
    FormUtils.createHelpButton(
        widgetFactory,
        parent,
        propertiesEditionComponent.getHelpContent(
            ChecklistViewsRepository.Item.Properties.comment, ChecklistViewsRepository.FORM_KIND),
        null); //$NON-NLS-1$
    // Start of user code for createCommentText

    // End of user code
    return parent;
  }
示例#30
0
  /**
   * Creates and returns the content of the version area.
   *
   * @param composite The parent composite to contain the version area
   */
  private Composite createVersionArea(Composite composite) {
    Group group = new Group(composite, SWT.CENTER);
    group.setText("Version");
    GridLayout layout = new GridLayout(2, false);
    group.setLayout(layout);

    // old version label
    Label oldVersionLabel = new Label(group, SWT.LEFT);
    oldVersionLabel.setText("Previous Version");
    GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    oldVersionLabel.setLayoutData(gd);
    final Text oldVersionText = new Text(group, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    oldVersionText.setText(oldVersionValue.toString());
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    oldVersionText.setLayoutData(gd);

    // new version:
    // 1. Development version
    // 2. Release
    // 3. Major release
    // 4. Custom
    devVersionButton = new Button(group, SWT.CHECK);
    devVersionButton.setText("Development Version");
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    devVersionButton.setLayoutData(gd);
    devVersionButton.setSelection(true);
    devVersionButton.addSelectionListener(
        new SelectionListener() {

          public void widgetSelected(SelectionEvent e) {
            developmentVersionButtonPressed();
          }

          public void widgetDefaultSelected(SelectionEvent e) {}
        });
    final Text devVersionText = new Text(group, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    devVersionText.setText(devVersionValue.toString());
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    devVersionText.setLayoutData(gd);

    // RELEASE AREA
    releaseVersionButton = new Button(group, SWT.CHECK);
    releaseVersionButton.setText("Release Version");
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    releaseVersionButton.setLayoutData(gd);
    releaseVersionButton.addSelectionListener(
        new SelectionListener() {

          public void widgetSelected(SelectionEvent e) {
            releaseVersionButtonPressed();
          }

          public void widgetDefaultSelected(SelectionEvent e) {}
        });
    final Text releaseVersionText = new Text(group, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    releaseVersionText.setText(releaseVersionValue.toString());
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    releaseVersionText.setLayoutData(gd);

    // MAJOR RELEASE AREA
    majorReleaseVersionButton = new Button(group, SWT.CHECK);
    majorReleaseVersionButton.setText("Major Release");
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    majorReleaseVersionButton.setLayoutData(gd);
    majorReleaseVersionButton.addSelectionListener(
        new SelectionListener() {

          public void widgetSelected(SelectionEvent e) {
            majorReleaseVersionButtonPressed();
          }

          public void widgetDefaultSelected(SelectionEvent e) {}
        });
    final Text majorReleaseVersionText = new Text(group, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    majorReleaseVersionText.setText(majorReleaseVersionValue.toString());
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    majorReleaseVersionText.setLayoutData(gd);

    // CUSTOM VERSION AREA
    customVersionButton = new Button(group, SWT.CHECK);
    customVersionButton.setText("Custom");
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    customVersionButton.setLayoutData(gd);
    customVersionButton.addSelectionListener(
        new SelectionListener() {

          public void widgetSelected(SelectionEvent e) {
            customVersionButtonPressed();
          }

          public void widgetDefaultSelected(SelectionEvent e) {}
        });
    customVersionText = new Text(group, SWT.SINGLE | SWT.BORDER);
    customVersionText.setEditable(false); // by default
    customVersionText.setText(customReleaseVersionValue.toString());
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    customVersionText.setLayoutData(gd);
    customVersionText.addFocusListener(
        new FocusListener() {

          public void focusGained(FocusEvent e) {
            customVersionText.setText(customReleaseVersionValue.toString());
          }

          public void focusLost(FocusEvent e) {
            try {
              customReleaseVersionValue = Version.parseVersion(customVersionText.getText());
              newVersionValue = customReleaseVersionValue;
              setErrorMessage(null);
            } catch (IllegalArgumentException iae) {
              setErrorMessage(
                  "Custom version number format should be X.Y.Z, not "
                      + customVersionText.getText());
              customReleaseVersionValue = devVersionValue; // default value
              developmentVersionButtonPressed();
            }
          }
        });

    return group;
  }