Пример #1
0
  private void initQueryResult(QueryResult queryResult, PaneState state) {
    IOQLQuery.Result subject = (IOQLQuery.Result) (queryResult).getSubject();
    queryViewer.getDocument().set(subject.getOQLQuery());

    AbstractEditorPane pane = EditorPaneRegistry.instance().createNewPane(subject, this.getClass());

    if (state == null) {
      for (PaneState child : getPaneState().getChildren()) {
        if (queryString.getText().equals(child.getIdentifier())) {
          state = child;
          break;
        }
      }

      if (state == null) {
        state =
            new PaneState(PaneType.COMPOSITE_CHILD, getPaneState(), queryString.getText(), true);
        state.setImage(getTitleImage());
      }
    }

    pane.setPaneState(state);

    createResultPane(pane, queryResult);
  }
  private void updateCellExpression() {

    if (styledText.getText() != null
        && currentEntry != null
        && !styledText.getText().equals(currentEntry.getExpression())) {
      mapperManager.changeEntryExpression(currentEntry, styledText.getText());
    }
  }
Пример #3
0
  /**
   * Inputs in the view the selected PO whose pretty code is recorded in the Goal class
   *
   * @throws IOException
   */
  public void inputPO() throws IOException {

    // we want to see a context, not the goal
    if (!POMode) {
      return;
    }

    if (ttext > 0) // if we've a title text
    setPartName(IConstants.PO_VIEW_TITLE + " : po " + ttext); // put it in the view
    else setPartName(IConstants.PO_VIEW_TITLE); // else, put the view title only

    // gets the PO pretty text
    String container = "";
    container = Goal.getGoal();

    // if the Goal is empty, we can return
    if (container.equals("")) {
      text.setText(container);
      return;
    }

    // get the style ranges
    Vector<StyleRange> range = Goal.getStyleRanges();
    int w = range.size() - 1;
    // keep the ranges which can be applied in the text area
    while (((StyleRange) range.get(w)).start >= container.length()) {
      w--;
    }

    // put the bar between the goal and the arrow result excerpted from this same goal
    container += "\n_______________________________________________\n\n";
    container += Goal.getResult();
    text.setText(container);

    // apply style ranges to the first part of the goal (before the bar)
    for (int e = 0; e <= w; e++) {
      text.setStyleRange((StyleRange) range.get(e));
    }

    // puts a style range to color the bar in black
    StyleRange srg = new StyleRange();
    srg.start += Goal.getGoal().length();
    srg.length = 50;
    srg.foreground = new Color(null, 0, 0, 0);
    text.setStyleRange(srg);

    // puts a style range to color the end of the goal in blue
    srg = new StyleRange();
    srg.start += Goal.getGoal().length() + 50;
    srg.length = Goal.getResult().length();
    srg.foreground = new Color(null, 0, 0, 255);
    text.setStyleRange(srg);

    // sets the cursor at the end of the code
    text.setSelection(text.getText().length(), text.getText().length());
  }
  private void configureHardWrap() {
    if (shouldHardWrap()) {
      if (hardWrapSegmentListener == null) {
        final StyledText textWidget = getTextWidget();
        hardWrapSegmentListener =
            new BidiSegmentListener() {
              @Override
              public void lineGetSegments(BidiSegmentEvent e) {
                int[] segments = calculateWrapOffsets(e.lineText, MAX_LINE_WIDTH);
                if (segments != null) {
                  char[] segmentsChars = new char[segments.length];
                  Arrays.fill(segmentsChars, '\n');
                  e.segments = segments;
                  e.segmentsChars = segmentsChars;
                }
              }
            };
        textWidget.addBidiSegmentListener(hardWrapSegmentListener);
        textWidget.setText(
            textWidget.getText()); // XXX: workaround for https://bugs.eclipse.org/384886

        if (brokenBidiPlatformTextWidth != -1) {
          Layout restrictedWidthLayout =
              new Layout() {
                @Override
                protected Point computeSize(
                    Composite composite, int wHint, int hHint, boolean flushCache) {
                  Point size = SpellcheckableMessageArea.this.getSize();
                  Rectangle trim = SpellcheckableMessageArea.this.computeTrim(0, 0, 0, 0);
                  size.x -= trim.width;
                  size.y -= trim.height;
                  if (size.x > brokenBidiPlatformTextWidth) size.x = brokenBidiPlatformTextWidth;
                  return size;
                }

                @Override
                protected void layout(Composite composite, boolean flushCache) {
                  Point size = computeSize(composite, SWT.DEFAULT, SWT.DEFAULT, flushCache);
                  textWidget.setBounds(0, 0, size.x, size.y);
                }
              };
          setLayout(restrictedWidthLayout);
        }
      }

    } else if (hardWrapSegmentListener != null) {
      StyledText textWidget = getTextWidget();
      textWidget.removeBidiSegmentListener(hardWrapSegmentListener);
      textWidget.setText(
          textWidget.getText()); // XXX: workaround for https://bugs.eclipse.org/384886
      hardWrapSegmentListener = null;

      if (brokenBidiPlatformTextWidth != -1) setLayout(new FillLayout());
    }
  }
 public void colorText(int length, Color foreground, Color background) {
   if (length > secondColumnSize) {
     styleRanges.add(
         new StyleRange(
             centerDescription.getText().length() - length - 2, length, foreground, background));
   } else {
     styleRanges.add(
         new StyleRange(
             centerDescription.getText().length() - secondColumnSize - 2,
             length,
             foreground,
             background));
   }
 }
Пример #6
0
  /**
   * search next text
   *
   * @param widgetText text widget
   * @param widgetFind search text widget
   */
  private void findNext(StyledText widgetText, Text widgetFind) {
    if (!widgetText.isDisposed()) {
      String findText = widgetFind.getText().toLowerCase();
      if (!findText.isEmpty()) {
        // get cursor position
        int cursorIndex = widgetText.getCaretOffset();

        // search
        int offset = -1;
        if (cursorIndex >= 0) {
          String text = widgetText.getText();
          offset =
              (cursorIndex + 1 < text.length())
                  ? text.substring(cursorIndex + 1).toLowerCase().indexOf(findText)
                  : -1;
        }
        if (offset >= 0) {
          int index = cursorIndex + 1 + offset;

          widgetText.setCaretOffset(index);
          widgetText.setSelection(index);
          widgetText.redraw();

          int topIndex = widgetText.getTopIndex();

          widgetLineNumbers.setTopIndex(topIndex);
          widgetVerticalScrollBar.setSelection(topIndex);
        } else {
          Widgets.flash(widgetFind);
        }
      }
    }
  }
 @Override
 protected void okPressed() {
   //		contentType = contentTypeText.getText().trim();
   abbrev = abbrevText.getText().trim();
   description = descriptionText.getText().trim();
   expansion = expansionText.getText();
   super.okPressed();
 }
 private void resetXPathText(StyledText text, String changedValue) {
   String xpathString = text.getText().trim();
   String result =
       xpathString.substring(0, text.getSelection().x)
           + changedValue
           + xpathString.substring(text.getSelection().y);
   text.setText(result);
 }
Пример #9
0
 @Override
 public String getContents() {
   int charCount = commandLineText.getCharCount();
   if (charCount == contentsOffset) {
     // SWT doesn't like text ranges where start == end, handle empty contents explicitly
     return "";
   } else {
     return commandLineText.getText(contentsOffset, charCount - 1);
   }
 }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
  */
 @Override
 public boolean performOk() {
   boolean ok = super.performOk();
   if (scriptTxt != null && !scriptTxt.isDisposed()) {
     if (isDefaultPresentedForScriptTxt) {
       getPreferenceStore().setToDefault(getPreferenceKey());
     } else {
       getPreferenceStore().setValue(getPreferenceKey(), scriptTxt.getText());
     }
     isDefaultPresentedForScriptTxt = false;
   }
   return ok;
 }
 private void validateCamelVersion() {
   if (getSelectedCamelVersion() != null && !isCamelVersionValid(getSelectedCamelVersion())) {
     if (!Widgets.isDisposed(camelInfoText)) {
       camelInfoText.setText(
           NLS.bind(
               Messages.newProjectWizardRuntimePageCamelVersionInvalidWarning,
               getSelectedCamelVersion()));
       setPageComplete(false);
     }
   } else {
     if (!Widgets.isDisposed(camelInfoText)) {
       camelInfoText.setText(""); // $NON-NLS-1$
     }
   }
   if (!Widgets.isDisposed(warningIconLabel) && !Widgets.isDisposed(camelInfoText)) {
     warningIconLabel.setVisible(camelInfoText.getText().length() > 0);
   }
 }
 /**
  * 当一个文本段初次获取焦点时,实时进行拼写检查,<div style='color:red'>该方法与{@link tgtTextRealTimeSpellCheck} 类似</div>
  */
 private static void tgtTextFirstRealTimeSpellCheck(
     final String tgtLang, HsMultiCellEditor targetEditor) {
   final StyledTextCellEditor tgtEditor = targetEditor.getCellEditor();
   final StyledText text = tgtEditor.getSegmentViewer().getTextWidget();
   if (tgtLang == null) {
     return;
   }
   String tgtText = text.getText();
   if (tgtText == null || "".equals(tgtText.trim())) {
     return;
   }
   List<SingleWord> errorWordList = new LinkedList<SingleWord>();
   errorWordList = spellTrigger.getErrorWords(tgtText, tgtLang);
   if (errorWordList != null && errorWordList.size() > 0) {
     targetEditor.highLightedErrorWord(tgtText, errorWordList);
   } else {
     targetEditor.refreshErrorWordsStyle(null);
   }
 }
Пример #13
0
  /**
   * update view find text
   *
   * @param widgetText text widget
   * @param widgetFind search text widget
   */
  private void updateViewFindText(StyledText widgetText, Text widgetFind) {
    if (!widgetText.isDisposed()) {
      String findText = widgetFind.getText().toLowerCase();
      ;
      if (!findText.isEmpty()) {
        // get cursor position
        int cursorIndex = widgetText.getCaretOffset();

        // search
        int offset = widgetText.getText().toLowerCase().substring(cursorIndex).indexOf(findText);
        if (offset >= 0) {
          widgetText.redraw();
        } else {
          Widgets.flash(widgetFind);
        }
      } else {
        widgetText.redraw();
      }
    }
  }
  public String getChangeDescription() {

    return _text.getText();
  }
Пример #15
0
 public String getSQL() {
   return innerText.getText();
 }
  /** /!\ Public for test purpose */
  public void validate() {
    // if runtime is selected other than NO RUNTIME
    if (getSelectedRuntime() != null) {
      // determine the camel version of that runtime
      String runtimeCamelVersion = determineRuntimeCamelVersion(getSelectedRuntime());

      if (UNKNOWN_CAMEL_VERSION.equals(runtimeCamelVersion)) {
        if (!Widgets.isDisposed(camelVersionCombo)) {
          camelVersionCombo.setEnabled(true);
        }
        camelInfoText.setText(
            Messages
                .FuseIntegrationProjectWizardRuntimeAndCamelPage_WarningMessageWhenCamelVersionCannotBeDeterminedInRuntime);
      } else {
        // and compare if selected camel version fits that version
        if (!isCompatible(runtimeCamelVersion, getSelectedCamelVersion())) {
          // Display warning and suggest the correct version
          camelInfoText.setText(
              NLS.bind(
                  Messages.newProjectWizardRuntimePageCamelVersionsDontMatchWarning,
                  runtimeCamelVersion));
        } else {
          camelInfoText.setText(""); // $NON-NLS-1$
        }
        if (!Widgets.isDisposed(camelVersionCombo)) {
          camelVersionCombo.setEnabled(false);
        }
      }
    } else {
      if (!Widgets.isDisposed(camelVersionCombo)) {
        camelVersionCombo.setEnabled(true);
      }

      if (!Widgets.isDisposed(camelInfoText)) {
        camelInfoText.setText(""); // $NON-NLS-1$
      }
    }
    // TODO: leaving that out until we decide to support other camel versions than the ones we ship
    //		try {
    //			getWizard().getContainer().run(false, false, new IRunnableWithProgress() {
    //				@Override
    //				public void run(IProgressMonitor monitor) throws InvocationTargetException,
    // InterruptedException {
    //					monitor.beginTask(Messages.newProjectWizardRuntimePageResolveDependencyStatus,
    // IProgressMonitor.UNKNOWN);
    //					validateCamelVersion();
    //					monitor.done();
    //				}
    //			});
    //		} catch (Exception ex) {
    //			ProjectTemplatesActivator.pluginLog().logError(ex);
    //		}

    if (!Widgets.isDisposed(warningIconLabel) && !Widgets.isDisposed(camelInfoText)) {
      warningIconLabel.setVisible(!camelInfoText.getText().isEmpty());
    }

    if (!Widgets.isDisposed(runtimeComboViewer) && !Widgets.isDisposed(camelVersionCombo)) {
      setPageComplete(
          !Strings.isBlank(runtimeComboViewer.getSelection().toString())
              && !Strings.isBlank(camelVersionCombo.getText())
              && !warningIconLabel.isVisible());
    }
  }
Пример #17
0
 @Override
 public String getFullContents() {
   return commandLineText.getText();
 }
Пример #18
0
 /** @return text */
 public String getText() {
   if (text.isDisposed()) {
     return null;
   }
   return text.getText();
 }
 public String getText() {
   return fStyledText.getText();
 }
 public String getText() {
   return centerDescription.getText();
 }
Пример #21
0
 /**
  * Returns a copy of the widget content.
  *
  * @return String
  * @see StyledText#getText()
  */
 public String getText() {
   return textWidget.getText();
 }
 public void addText(Object[] object) {
   centerDescription.setText(
       centerDescription.getText() + String.format(descriptionStringFormat, object));
 }