Exemplo n.º 1
0
  /**
   * set the given test suite as input
   *
   * @param ts the test suite
   * @param add add to history?
   */
  public void setInput(final TestSuite ts, final boolean add) {
    Object[] expanded = testTree.getExpandedElements();

    /** avoid flicker by only refreshing if we have the proper input already * */
    boolean needInput = true;
    if (!add) {
      Object i = testTree.getInput();
      if (i != null && i instanceof Collection<?>) {
        Collection<?> c = (Collection<?>) i;
        if (c.size() == 1 && ts.getRoot() == c.iterator().next()) {
          testTree.refresh();
          needInput = false;
        }
      }
    }
    if (needInput) {
      testTree.setInput(Collections.singleton(ts.getRoot()));
    }

    tRuns.setText(String.valueOf(ts.getRuns()));
    tErrors.setText(String.valueOf(ts.getErrors()));
    tFailures.setText(String.valueOf(ts.getFailures()));
    tRuns.getParent().layout(new Control[] {tRuns, tErrors, tFailures});
    if (add) {
      testText.setText(""); // $NON-NLS-1$
      history.add(ts);
      historyIndex = history.size() - 1;
      testTree.expandToLevel(2);
    } else {
      testTree.setExpandedElements(expanded);
    }
  }
  private void showHideTexts() {
    if (passwordText != null && !passwordText.isDisposed()) {
      boolean enablePasswordField = false;
      if (connection != null) {
        IRepositoryFactory factory =
            RepositoryFactoryProvider.getRepositoriyById(connection.getRepositoryId());
        if (factory != null && factory.isAuthenticationNeeded()) {
          enablePasswordField = true;
        }
      } else if (getRepository() != null
          && RepositoryConstants.REPOSITORY_REMOTE_ID.equals(getRepository().getId())) {
        enablePasswordField = true;
      }

      if (enablePasswordField) {
        passwordText.setBackground(LoginDialogV2.WHITE_COLOR);
      } else {
        passwordText.setText(""); // $NON-NLS-1$
        passwordText.setBackground(LoginDialogV2.GREY_COLOR);
      }
      passwordText.setEnabled(enablePasswordField);
      passwordText.setEditable(enablePasswordField);

      hideControl(passwordText, !enablePasswordField, false);
      hideControl(passwordLabel, !enablePasswordField, false);

      passwordText.getParent().layout();
    }
  }
Exemplo n.º 3
0
 public void clear() {
   testTree.setInput(Collections.emptySet());
   tRuns.setText(String.valueOf(0));
   tErrors.setText(String.valueOf(0));
   tFailures.setText(String.valueOf(0));
   tRuns.getParent().layout(new Control[] {tRuns, tErrors, tFailures});
 }
Exemplo n.º 4
0
  private void createContents() {
    TabFolder tabFolder = new TabFolder(this, SWT.NONE);
    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    CommonSelectorComposite commonCompositeRef =
        new CommonSelectorComposite(tabFolder, SWT.NONE, false, true);
    commonCompositeRef.getTreeViewer().getTree().setLinesVisible(false);
    commonCompositeRef.getTreeViewer().getTree().setHeaderVisible(false);
    commonCompositeRef.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    commonCompositeRef.setDataSet(this.dataset);
    commonCompositeRef.getTreeViewer().expandAll();
    TabItem tabItem1 = new TabItem(tabFolder, SWT.NONE);
    tabItem1.setText("Ref");
    tabItem1.setControl(commonCompositeRef);

    if (hasLabel) {
      CommonSelectorComposite commonCompositeLabel =
          new CommonSelectorComposite(tabFolder, SWT.NONE, false, true);
      commonCompositeLabel.getTreeViewer().getTree().setLinesVisible(false);
      commonCompositeLabel.getTreeViewer().getTree().setHeaderVisible(false);
      commonCompositeLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
      commonCompositeLabel.setDataSet(this.dataset);
      commonCompositeLabel.getTreeViewer().expandAll();
      TabItem tabItem2 = new TabItem(tabFolder, SWT.NONE);
      tabItem2.setText("Label");
      tabItem2.setControl(commonCompositeLabel);
    }

    tabFolder.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent event) {
            selectedRef = "Ref".equals(((TabItem) event.item).getText());
          }

          public void widgetSelected(SelectionEvent event) {
            selectedRef = "Ref".equals(((TabItem) event.item).getText());
          }
        });

    Composite composite = new Composite(this, SWT.NONE);
    GridData gd_composite = new GridData(SWT.FILL, SWT.FILL, true, false);

    composite.setLayoutData(gd_composite);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    composite.setLayout(gridLayout);

    Label label = new Label(composite, SWT.NONE);
    label.setText("属性值");
    displayText = new Text(composite, SWT.BORDER);
    displayText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    displayText.setEditable(false);
    displayText.setBackground(displayText.getParent().getBackground());

    displayText.setText(this.propertyItem.getValue());
  }
 /**
  * Sets the current error message or none if null
  *
  * @param errorMessage
  * @since 3.3
  */
 public void setErrorMessage(String errorMessage) {
   fErrorMessage = errorMessage;
   if (fErrorTextWidget != null && !fErrorTextWidget.isDisposed()) {
     fErrorTextWidget.setText(errorMessage == null ? "" : errorMessage); // $NON-NLS-1$
     fErrorTextWidget.getParent().update();
     // Access the ok button by id, in case clients have overridden button creation.
     // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643
     Control button = getButton(IDialogConstants.OK_ID);
     if (button != null) {
       button.setEnabled(errorMessage == null);
     }
   }
 }
 public void setErrorMessage(String errorMessage) {
   this.errorMessage = errorMessage;
   if (errorMessageText != null && !errorMessageText.isDisposed()) {
     errorMessageText.setText(errorMessage == null ? " \n " : errorMessage); // $NON-NLS-1$
     boolean hasError =
         errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
     errorMessageText.setEnabled(hasError);
     errorMessageText.setVisible(hasError);
     errorMessageText.getParent().update();
     Control button = getButton(IDialogConstants.OK_ID);
     if (button != null) {
       button.setEnabled(errorMessage == null);
     }
   }
 }
 public void keyPressed(KeyEvent event) {
   String value = consoleWidget.getText();
   String newValue = value;
   if (backSpacePressed(event)) {
     newValue = removeLastCommandCharacter(value);
   } else if (anyKeyPressed(event)) {
     newValue = appendLastCommandCharacter(event, value);
   }
   if (!enterPressed(event)) {
     event.doit = false;
   }
   consoleWidget.setText(newValue);
   consoleWidget.setSelection(consoleWidget.getText().length());
   consoleWidget.getParent().layout(true, true);
 }
Exemplo n.º 8
0
 /**
  * Sets or clears the error message. If not <code>null</code>, the OK button is disabled.
  *
  * @param errorMessage the error message, or <code>null</code> to clear
  */
 public void setErrorMessage(String errorMessage) {
   this.errorMessage = errorMessage;
   if (errorMessageText != null && !errorMessageText.isDisposed()) {
     errorMessageText.setText(errorMessage == null ? " \n " : errorMessage); // $NON-NLS-1$
     // Disable the error message text control if there is no error, or
     // no error text (empty or whitespace only). Hide it also to avoid color change.
     boolean hasError =
         errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
     errorMessageText.setEnabled(hasError);
     errorMessageText.setVisible(hasError);
     errorMessageText.getParent().update();
     // Access the ok button by id, in case clients have overridden button creation.
     Control button = getButton(IDialogConstants.OK_ID);
     if (button != null) {
       button.setEnabled(errorMessage == null);
     }
   }
 }
Exemplo n.º 9
0
  private void bindControls() {

    // Bind source file path widget to UI model
    IObservableValue widgetValue = WidgetProperties.text(SWT.Modify).observe(_javaClassText);
    IObservableValue modelValue = null;
    if (isSourcePage()) {
      modelValue = BeanProperties.value(Model.class, "sourceFilePath").observe(model);
    } else {
      modelValue = BeanProperties.value(Model.class, "targetFilePath").observe(model);
    }
    UpdateValueStrategy strategy = new UpdateValueStrategy();
    strategy.setBeforeSetValidator(
        new IValidator() {

          @Override
          public IStatus validate(final Object value) {
            final String path = value == null ? null : value.toString().trim();
            if (path == null || path.isEmpty()) {
              return ValidationStatus.error(
                  "A source file path must be supplied for the transformation.");
            }
            NewTransformationWizard wizard = (NewTransformationWizard) getWizard();
            try {
              Class<?> tempClass = wizard.getLoader().loadClass(path);
              if (tempClass == null) {
                return ValidationStatus.error(
                    "Unable to find a source file with the supplied path");
              }
            } catch (ClassNotFoundException e) {
              return ValidationStatus.error("Unable to find a source file with the supplied path");
            }
            return ValidationStatus.ok();
          }
        });
    _binding = context.bindValue(widgetValue, modelValue, strategy, null);
    ControlDecorationSupport.create(
        _binding,
        decoratorPosition,
        _javaClassText.getParent(),
        new WizardControlDecorationUpdater());

    listenForValidationChanges();
  }
  private void showHideDynamicsControls() {
    // PTODO SML Optimize
    // 1. Hide all controls:
    for (IRepositoryFactory f : dynamicControls.keySet()) {
      for (LabelText control : dynamicControls.get(f).values()) {
        // control.setVisible(false);
        hideControl(control.getLabelControl(), true, false);
        hideControl(control.getTextControl(), true, false);
      }

      for (Button control : dynamicButtons.get(f).values()) {
        // control.setVisible(false);
        hideControl(control, true, false);
      }

      for (LabelledCombo control : dynamicChoices.get(f).values()) {
        // control.setVisible(false);
        hideControl(control.getCombo(), true, false);
      }
    }

    // 2. Show active repository controls:
    if (getRepository() != null) {
      for (LabelText control : dynamicControls.get(getRepository()).values()) {
        // control.setVisible(true);
        hideControl(control.getLabelControl(), false, false);
        hideControl(control.getTextControl(), false, false);
      }

      for (Button control : dynamicButtons.get(getRepository()).values()) {
        // control.setVisible(true);
        hideControl(control, false, false);
      }

      for (LabelledCombo control : dynamicChoices.get(getRepository()).values()) {
        // control.setVisible(true);
        hideControl(control.getCombo(), false, false);
      }
    }
    nameText.getParent().layout();
  }
Exemplo n.º 11
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
   * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
   */
  @Override
  public int estimateRowSize(Composite subComposite, IElementParameter param) {
    if (!estimateInitialized) {
      DecoratedField dField =
          new DecoratedField(
              subComposite,
              SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP,
              new TextControlCreator());
      Text text = (Text) dField.getControl();
      FormData d = (FormData) text.getLayoutData();
      d.height = text.getLineHeight();
      text.getParent().setSize(subComposite.getSize().x, text.getLineHeight());
      Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
      rowSizeByLine = text.getLineHeight();
      dField.getLayoutControl().dispose();
      rowSizeFixed = ITabbedPropertyConstants.VSPACE + (initialSize.y - rowSizeByLine);
      estimateInitialized = true;
    }

    return rowSizeFixed + (rowSizeByLine * param.getNbLines());
  }
Exemplo n.º 12
0
  private void checkPage() {
    boolean createBranchSelected = createBranch.getSelection();
    branchText.setEnabled(createBranchSelected);
    branchText.setVisible(createBranchSelected);
    branchTextlabel.setVisible(createBranchSelected);
    GridData gd = (GridData) branchText.getLayoutData();
    gd.exclude = !createBranchSelected;
    gd = (GridData) branchTextlabel.getLayoutData();
    gd.exclude = !createBranchSelected;

    boolean createTagSelected = createTag.getSelection();
    tagText.setEnabled(createTagSelected);
    tagText.setVisible(createTagSelected);
    tagTextlabel.setVisible(createTagSelected);
    gd = (GridData) tagText.getLayoutData();
    gd.exclude = !createTagSelected;
    gd = (GridData) tagTextlabel.getLayoutData();
    gd.exclude = !createTagSelected;
    branchText.getParent().layout(true);

    boolean showActivateAdditionalRefs = false;
    showActivateAdditionalRefs =
        (checkout.getSelection() || dontCheckout.getSelection())
            && !Activator.getDefault()
                .getPreferenceStore()
                .getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_ADDITIONAL_REFS);

    gd = (GridData) warningAdditionalRefNotActive.getLayoutData();
    gd.exclude = !showActivateAdditionalRefs;
    warningAdditionalRefNotActive.setVisible(showActivateAdditionalRefs);
    warningAdditionalRefNotActive.getParent().layout(true);

    setErrorMessage(null);
    try {
      if (refText.getText().length() > 0) {
        Change change = Change.fromRef(refText.getText());
        if (change == null) {
          setErrorMessage(UIText.FetchGerritChangePage_MissingChangeMessage);
          return;
        }
      } else {
        setErrorMessage(UIText.FetchGerritChangePage_MissingChangeMessage);
        return;
      }

      boolean emptyRefName =
          (createBranchSelected && branchText.getText().length() == 0)
              || (createTagSelected && tagText.getText().length() == 0);
      if (emptyRefName) {
        setErrorMessage(UIText.FetchGerritChangePage_ProvideRefNameMessage);
        return;
      }

      boolean existingRefName =
          (createBranchSelected && repository.getRef(branchText.getText()) != null)
              || (createTagSelected && repository.getRef(tagText.getText()) != null);
      if (existingRefName) {
        setErrorMessage(
            NLS.bind(UIText.FetchGerritChangePage_ExistingRefMessage, branchText.getText()));
        return;
      }
    } catch (IOException e1) {
      // ignore here
    } finally {
      setPageComplete(getErrorMessage() == null);
    }
  }
 private void updateFileEnabled(ILaunchConfiguration configuration) throws CoreException {
   boolean enabled = configuration.getAttribute(SERVER_ENABLED, true);
   fFile.getParent().setVisible(enabled);
 }
 public void keyReleased(KeyEvent event) {
   if (enterPressed(event)) {
     inputProcessor.processCommand();
   }
   consoleWidget.getParent().layout(true, true);
 }
Exemplo n.º 15
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
   */
  @Override
  public Control createControl(
      final Composite subComposite,
      final IElementParameter param,
      final int numInRow,
      final int nbInRow,
      final int top,
      final Control lastControl) {
    this.curParameter = param;
    this.paramFieldType = param.getFieldType();
    int nbLines = param.getNbLines();

    DecoratedField dField =
        new DecoratedField(
            subComposite,
            SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP,
            new SelectAllTextControlCreator());
    if (param.isRequired()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    Control cLayout = dField.getLayoutControl();
    Text text = (Text) dField.getControl();

    editionControlHelper.register(param.getName(), text);

    FormData d = (FormData) text.getLayoutData();
    if (getAdditionalHeightSize() != 0) {
      nbLines += this.getAdditionalHeightSize() / text.getLineHeight();
    }
    d.height = text.getLineHeight() * nbLines;
    FormData data;
    text.getParent().setSize(subComposite.getSize().x, text.getLineHeight() * nbLines);
    cLayout.setBackground(subComposite.getBackground());
    // for bug 7580
    if (!(text instanceof Text)) {
      text.setEnabled(!param.isReadOnly());
    } else {
      text.setEditable(!param.isReadOnly());
    }
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
    FontData fontData = new FontData(fontType);
    Font font = new Font(null, fontData);
    addResourceDisposeListener(text, font);
    text.setFont(font);
    if (elem instanceof Node) {
      text.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    addDragAndDropTarget(text);

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    data = new FormData();
    if (lastControl != null) {
      data.left = new FormAttachment(lastControl, 0);
    } else {
      data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
      labelLabel.setAlignment(SWT.RIGHT);
    }
    // *********************
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();

    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
      currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
      if (lastControl != null) {
        data.left = new FormAttachment(lastControl, currentLabelWidth);
      } else {
        data.left = new FormAttachment(0, currentLabelWidth);
      }

    } else {
      data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    // **********************
    hashCurControls.put(param.getName(), text);

    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);

    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return null;
  }