Пример #1
0
 @Override
 protected IDialogSettings getDialogBoundsSettings() {
   final IDialogSettings root = Q7UIPlugin.getDefault().getDialogSettings();
   IDialogSettings section = root.getSection(SETTINGS_KEY);
   if (section == null) {
     section = root.addNewSection(SETTINGS_KEY);
   }
   return section;
 }
Пример #2
0
  public void run() {

    TextViewer viewer = getTextViewer();
    if (viewer == null) return;

    IDocument document = viewer.getDocument();
    if (document == null) return;

    try {
      fLastLine = document.getLineOfOffset(document.getLength()) + 1;
    } catch (BadLocationException ex) {
      IStatus status =
          new Status(
              IStatus.ERROR,
              Q7UIPlugin.PLUGIN_ID,
              IStatus.OK,
              "Go to Line failed",
              ex); //$NON-NLS-1$
      Q7UIPlugin.getDefault().getLog().log(status);
      return;
    }

    String title = DIALOG_TITLE;
    String message = MessageFormat.format(DIALOG_MESSAGE, new Integer(fLastLine));

    String currentLineStr = ""; // $NON-NLS-1$
    StyledText textWidget = viewer.getTextWidget();
    int currentLine = textWidget.getLineAtOffset(textWidget.getCaretOffset());
    if (currentLine > -1) currentLineStr = Integer.toString(currentLine + 1);

    InputDialog d =
        new InputDialog(
            viewer.getTextWidget().getShell(),
            title,
            message,
            currentLineStr,
            new NumberValidator());
    if (d.open() == Window.OK) {
      try {
        int line = Integer.parseInt(d.getValue());
        gotoLine(line - 1);
      } catch (NumberFormatException x) {
      }
    }
  }
Пример #3
0
 private boolean hasDialogBoundsSettings() {
   final IDialogSettings root = Q7UIPlugin.getDefault().getDialogSettings();
   return root.getSection(SETTINGS_KEY) != null;
 }