コード例 #1
0
  private void createFilePreviewOptionsGroup(Composite parent) {
    Group theGroup =
        WidgetFactory.createGroup(
            parent, getString("filePreviewOptionsGroup"), SWT.NONE, 1, 5); // $NON-NLS-1$
    theGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label numberLinesInFileLabel = new Label(theGroup, SWT.NONE);
    numberLinesInFileLabel.setText(getString("numberOfLinesLabel")); // $NON-NLS-1$

    numberLinesInFileText = WidgetFactory.createTextField(theGroup, SWT.NONE);
    numberLinesInFileText.setEditable(false);
    numberLinesInFileText.setBackground(
        Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
    GridData gd = new GridData();
    gd.minimumWidth = 50;

    Label spacer = new Label(theGroup, SWT.NONE);
    spacer.setText("                    "); // $NON-NLS-1$

    Label prefixLabel = new Label(theGroup, SWT.NONE);
    prefixLabel.setText(getString("numberOfPreviewLines")); // $NON-NLS-1$
    prefixLabel.setLayoutData(new GridData()); // new GridData(GridData.FILL_HORIZONTAL));

    this.numberPreviewLinesText = WidgetFactory.createTextField(theGroup, SWT.NONE);
    gd = new GridData();
    gd.minimumWidth = 50;

    this.numberPreviewLinesText.setLayoutData(gd);
    this.numberPreviewLinesText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(final ModifyEvent event) {
            if (!synchronizing) {
              if (!numberPreviewLinesText.getText().isEmpty()) {
                try {
                  int nLines = Integer.parseInt(numberPreviewLinesText.getText());
                  if (nLines == 0) {
                    setErrorMessage(getString("numberOfLinesCannotBeNullOrZero")); // $NON-NLS-1$
                    return;
                  }
                  if (nLines != dataFileInfo.getNumberOfCachedFileLines()) {
                    dataFileInfo.setNumberOfCachedFileLines(nLines);
                    handleInfoChanged(true);
                  }
                  setErrorMessage(null);
                } catch (NumberFormatException ex) {
                  setErrorMessage(
                      getString(
                          "numberOfLinesMustBeInteger",
                          numberPreviewLinesText.getText())); // $NON-NLS-1$
                  return;
                }
              } else {
                setErrorMessage(getString("numberOfLinesCannotBeNullOrZero")); // $NON-NLS-1$
                return;
              }
            }
          }
        });
  }
コード例 #2
0
  /**
   * Create the controls for creating a new relationships Model.
   *
   * @param parent the parent composite
   * @return the created composite
   */
  private Composite createModelCreationComposite(Composite parent) {

    // Set up Composite
    Composite nameComposite = new Composite(parent, SWT.NONE);
    GridLayout nameCompositeLayout = new GridLayout();
    nameComposite.setLayout(nameCompositeLayout);
    nameCompositeLayout.numColumns = 3;
    nameCompositeLayout.marginWidth = 0;
    GridData nameCompositeGridData = new GridData(GridData.FILL_HORIZONTAL);
    nameCompositeGridData.horizontalIndent = 20;
    nameComposite.setLayoutData(nameCompositeGridData);

    // Enter Model name label - col 1 Model Name Label
    lbModelName = new Label(nameComposite, SWT.NONE);
    lbModelName.setText(MODEL_NAME_LABEL);
    lbModelName.getAlignment();

    // Model name entry field - col 2
    txtModelName = WidgetFactory.createTextField(nameComposite, GridData.HORIZONTAL_ALIGN_FILL);
    GridData modelNameTextGridData = new GridData();
    modelNameTextGridData.widthHint = MODEL_NAME_TEXT_WIDTH;
    txtModelName.setLayoutData(modelNameTextGridData);

    // listener for typing changes
    txtModelName.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(final ModifyEvent event) {
            handleSetModelName();
          }
        });

    // This initializes the status label
    handleSetModelName();

    setCreateControlsEnabled(false);

    return nameComposite;
  }
コード例 #3
0
  /**
   * @param parent
   * @return composite the page
   * @since 4.0
   */
  @SuppressWarnings({"unused", "unchecked"})
  Composite createPageControl(final Composite parent) {
    // Create page
    final Composite mainPanel = new Composite(parent, SWT.NONE);
    mainPanel.setLayout(new GridLayout(COLUMN_COUNT, false));
    // Add widgets to page
    WidgetFactory.createLabel(mainPanel, FOLDER_LABEL);
    final String name =
        (this.folder == null ? null : this.folder.getFullPath().makeRelative().toString());
    this.folderText =
        WidgetFactory.createTextField(mainPanel, GridData.FILL_HORIZONTAL, 1, name, SWT.READ_ONLY);
    this.folderText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(final ModifyEvent event) {
            folderModified();
          }
        });
    btnBrowse = WidgetFactory.createButton(mainPanel, BROWSE_BUTTON);
    btnBrowse.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            browseButtonSelected();
          }
        });
    WidgetFactory.createLabel(mainPanel, NAME_LABEL);
    this.nameText =
        WidgetFactory.createTextField(mainPanel, GridData.HORIZONTAL_ALIGN_FILL, COLUMN_COUNT - 1);
    this.nameText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(final ModifyEvent event) {
            nameModified();
          }
        });

    // set focus to browse button if no folder selected. otherwise set focus to text field
    if (folder == null) {
      btnBrowse.setFocus();
    } else {
      nameText.setFocus();
    }

    DESCRIPTION_GROUP:
    {
      final Group descGroup =
          WidgetFactory.createGroup(
              mainPanel, getString("description"), GridData.FILL_HORIZONTAL, 3); // $NON-NLS-1$
      descriptionTextEditor =
          new StyledTextEditor(
              descGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP | SWT.BORDER);
      final GridData descGridData = new GridData(GridData.FILL_BOTH);
      descGridData.horizontalSpan = 1;
      descGridData.heightHint = 50;
      descGridData.minimumHeight = 30;
      descGridData.grabExcessVerticalSpace = true;
      descriptionTextEditor.setLayoutData(descGridData);
      descriptionTextEditor.setText(""); // $NON-NLS-1$
    }

    MODELS_GROUP:
    {
      Group group =
          WidgetFactory.createGroup(
              mainPanel,
              getString("selectedModelsGroupTitle"),
              GridData.FILL_BOTH,
              COLUMN_COUNT,
              COLUMN_COUNT); //$NON-NLS-1$
      group.setLayout(new GridLayout(2, false));
      GridData gd = new GridData(GridData.FILL_BOTH);
      gd.heightHint = 200;
      gd.horizontalSpan = 3;
      group.setLayoutData(gd);

      Composite leftToolbarPanel = new Composite(group, SWT.NONE);
      leftToolbarPanel.setLayout(new GridLayout());
      GridData ltpGD = new GridData(GridData.FILL_VERTICAL);
      ltpGD.heightHint = 120;
      leftToolbarPanel.setLayoutData(ltpGD);

      addModelsButton = new Button(leftToolbarPanel, SWT.PUSH);
      addModelsButton.setText(getString("add")); // $NON-NLS-1$
      addModelsButton.setToolTipText(getString("addModelsTooltip")); // $NON-NLS-1$
      addModelsButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      addModelsButton.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              handleAddModelsSelected();
              if (!modelsViewer.getSelection().isEmpty()) {
                removeModelsButton.setEnabled(true);
              }
            }
          });

      removeModelsButton = new Button(leftToolbarPanel, SWT.PUSH);
      removeModelsButton.setText(getString("remove")); // $NON-NLS-1$
      removeModelsButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      removeModelsButton.setEnabled(false);
      removeModelsButton.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              Collection<IResource> models = new ArrayList<IResource>();

              IStructuredSelection selection = (IStructuredSelection) modelsViewer.getSelection();
              for (Object obj : selection.toArray()) {
                if (obj instanceof IResource) {
                  models.add((IResource) obj);
                }
              }
              removeModels(models);
              removeModelsButton.setEnabled(false);
            }
          });

      this.modelsViewer = new TableViewer(group);
      GridData gdv = new GridData(GridData.FILL_BOTH);
      // gdv.horizontalSpan = COLUMN_COUNT;
      modelsViewer.getControl().setLayoutData(gdv);
      modelsViewer.setContentProvider(new ListContentProvider());
      modelsViewer.setLabelProvider(new ModelExplorerLabelProvider());
      // Add Models from properties if available
      if (this.designerProperties != null && !this.designerProperties.isEmpty()) {
        IFile sourceMdl = DesignerPropertiesUtil.getSourceModel(this.designerProperties);
        IFile viewMdl = DesignerPropertiesUtil.getViewModel(this.designerProperties);
        if (sourceMdl != null) this.modelsForVdb.add(sourceMdl);
        if (viewMdl != null) this.modelsForVdb.add(viewMdl);
      } else {
        this.modelsForVdb.addAll(SelectionUtilities.getSelectedIResourceObjects(initialSelection));
      }
      modelsViewer.setInput(this.modelsForVdb);
      modelsViewer.addSelectionChangedListener(
          new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
              removeModelsButton.setEnabled(!event.getSelection().isEmpty());
            }
          });
    }

    updateForProperties();
    return mainPanel;
  }