@Override
  protected Control createContents(Composite p) {
    Composite parent = (Composite) super.createContents(p);

    Label scriptLabel = new Label(parent, SWT.NONE);
    String headerMessages = getHeaderMessages();
    scriptLabel.setText(headerMessages);
    // FIXME, If the message can't be displayed complectly. try to set the tool tip
    if (headerMessages.length() > 50) { // simply first, just set the length greater than 50
      scriptLabel.setToolTipText(headerMessages);
    }

    int style = SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL;
    if (isReadonly()) {
      style |= SWT.READ_ONLY;
    }
    scriptTxt = new StyledText(parent, style);
    GridData layoutData = new GridData(GridData.FILL_BOTH);
    layoutData.heightHint = 280;
    layoutData.minimumHeight = 280;
    layoutData.widthHint = 500;
    layoutData.minimumWidth = 500;
    scriptTxt.setLayoutData(layoutData);
    scriptTxt.setText(getScriptContent());

    return parent;
  }
Ejemplo n.º 2
0
  /**
   * Create the composite.
   *
   * @param parent
   * @param style
   */
  public FeatureOffset(Composite parent, int style) {
    super(parent, style);
    setLayout(new GridLayout(3, true));

    stylerange = new StyleRange();
    stylerange.background = AndrospyMain.shell.getDisplay().getSystemColor(SWT.COLOR_YELLOW);

    txtSrch = new Text(this, SWT.BORDER);
    txtSrch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    Button btnSearch = new Button(this, SWT.NONE);
    btnSearch.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            String srch = txtSrch.getText();
            String fulltext = text.getText();
            if (srch != "" && fulltext != "") {
              find(srch, fulltext);
            }
          }
        });
    GridData gd_btnSearch = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_btnSearch.widthHint = 104;
    btnSearch.setLayoutData(gd_btnSearch);
    btnSearch.setText("lk.score.androphsy.main.Search");

    text = new StyledText(this, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    GridData gd_text = new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1);
    gd_text.heightHint = 230;
    text.setLayoutData(gd_text);

    lblOffset = new Label(this, SWT.NONE);
    lblOffset.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblOffset.setText("Offset:");

    txtOffset = new Text(this, SWT.BORDER);
    txtOffset.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    btnHexView = new Button(this, SWT.NONE);
    btnHexView.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            if (txtOffset.getText().equals("")) {
              MessageBox msbox = new MessageBox(getShell(), SWT.ICON_ERROR);
              msbox.setMessage("ERROR - Hex View");
              msbox.setText("Offset value cannot be null");
              msbox.open();
              return;
            }
            hv.getHexdump(txtOffset.getText());
          }
        });
    btnHexView.setText("Hex View");

    hv = new HexViewer(this, SWT.NONE);
    hv.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
  }
Ejemplo n.º 3
0
 @Override
 public StyledText makeView(Composite shell, PmAttrString pm) {
   StyledText textArea = new StyledText(shell, swtStyle);
   // FIXME olaf: that does not really work... should be done by the calling code.
   textArea.setLayoutData(
       new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
   return textArea;
 }
Ejemplo n.º 4
0
 /** Create the description */
 private void createDescription() {
   final StyledText labelDescription = new StyledText(this, SWT.WRAP | SWT.READ_ONLY);
   labelDescription.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
   labelDescription.setEnabled(false);
   labelDescription.setFont(getFont());
   labelDescription.setForeground(getForeground());
   labelDescription.setText(this.description);
   SWTGraphicUtil.applyHTMLFormating(labelDescription);
 }
Ejemplo n.º 5
0
 /**
  * Creates a new styled text widget
  *
  * @param parent the parent composite to add this styled text widget to
  * @param style the style bits for the styled text widget
  * @param hspan the horizontal span to take up on the parent composite
  * @param width the desired width of the styled text widget
  * @param height the desired height of the styled text widget
  * @param fill the fill style for the widget
  * @return the new styled text widget
  * @since 3.9
  */
 public static StyledText createStyledText(
     Composite parent, int style, int hspan, int width, int height, int fill) {
   StyledText t = new StyledText(parent, style);
   t.setFont(parent.getFont());
   GridData gd = new GridData(fill);
   gd.horizontalSpan = hspan;
   gd.widthHint = width;
   gd.heightHint = height;
   t.setLayoutData(gd);
   return t;
 }
Ejemplo n.º 6
0
  /** This method initializes compositeIntro */
  private void createCompositeIntro() {
    compositeIntro = new Composite(content, SWT.NONE);
    compositeIntro.setBackground(white);
    compositeIntro.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
    compositeIntro.setLayout(new GridLayout(1, false));

    Label label = new Label(compositeIntro, SWT.NONE);
    label.setFont(FontService.getHeaderFont());
    label.setBackground(white);
    label.setText(Messages.getString("ECView.Title")); // $NON-NLS-1$

    stDescription = new StyledText(compositeIntro, SWT.READ_ONLY);
    stDescription.setText(Messages.getString("ECView.Description")); // $NON-NLS-1$
    stDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
  }
Ejemplo n.º 7
0
 void createStyledText() {
   text =
       new org.eclipse.swt.custom.StyledText(
           shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
   org.eclipse.swt.layout.GridData spec = new org.eclipse.swt.layout.GridData();
   spec.horizontalAlignment = GridData.FILL;
   spec.grabExcessHorizontalSpace = true;
   spec.verticalAlignment = GridData.FILL;
   spec.grabExcessVerticalSpace = true;
   text.setLayoutData(spec);
   text.addLineStyleListener(lineStyler);
   text.setEditable(false);
   org.eclipse.swt.graphics.Color bg = Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
   text.setBackground(bg);
 }
  public DescriptionSingleComposite(Composite parent, int style) {
    super(parent, style);
    centerDescription = new StyledText(this, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP);
    this.setLayout(new FormLayout());
    formFill = new FormData();
    formFill.top = new FormAttachment(0, 0);
    formFill.left = new FormAttachment(0, 0);
    formFill.right = new FormAttachment(100, 0);
    formFill.bottom = new FormAttachment(100, 0);
    centerDescription.setLayoutData(formFill);
    centerDescription.setBackground(getBackground());
    setEnabled(false);

    // initialize description string format
    descriptionStringFormat = "%s: %s\r\n";
    // create object for colorize text in description composite
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createContents(org.eclipse.swt.widgets.Composite)
   */
  @Override
  protected Control createContents(Composite p) {
    Composite parent = (Composite) super.createContents(p);

    Label scriptLabel = new Label(parent, SWT.NONE);
    scriptLabel.setText(getHeadTitle());

    scriptTxt = new StyledText(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    GridData layoutData = new GridData(GridData.FILL_BOTH);
    layoutData.heightHint = 450;
    layoutData.minimumHeight = 450;
    layoutData.widthHint = 550;
    layoutData.minimumWidth = 550;
    scriptTxt.setLayoutData(layoutData);
    scriptTxt.setText(getPreferenceStore().getString(getPreferenceKey()));

    return parent;
  }
  /** ftang Comment method "handleErrorOutput". */
  protected void handleErrorOutput(
      Composite outputComposite, CTabFolder tabFolder, CTabItem outputTabItem, Exception... e) {

    // Dispose all existing controls.
    if (!outputComposite.isDisposed()) {
      Control[] children = outputComposite.getChildren();
      for (Control control : children) {
        if (!control.isDisposed()) {
          control.dispose();
        }
      }
    }

    Font font = new Font(Display.getDefault(), "courier", 8, SWT.NONE); // $NON-NLS-1$

    StyledText text =
        new StyledText(outputComposite, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    text.setLayoutData(gridData);
    outputComposite.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));

    Exception exception = getException();
    if (e != null && e.length == 1) {
      exception = e[0];
    }

    String errorInfo = exception.getMessage() + "\n"; // $NON-NLS-1$
    errorInfo =
        errorInfo
            + Messages.getString("FileStep2.previewFailure")
            + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
    StackTraceElement[] stackTrace = exception.getStackTrace();
    for (StackTraceElement stackTraceElement : stackTrace) {
      errorInfo = errorInfo + stackTraceElement.toString() + "\n"; // $NON-NLS-1$
    }
    text.setText(errorInfo);
    text.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
    text.setFont(font);

    tabFolder.setSelection(outputTabItem);
    outputComposite.layout(true);
  }
Ejemplo n.º 11
0
 public void show(String title, final String message, List<StyleRange> srList) {
   final Shell dialog = new Shell(Display.getDefault(), SWT.DIALOG_TRIM | SWT.RESIZE);
   UIUtil.setDialogDefaultFunctions(dialog);
   dialog.setText(title);
   dialog.setLayout(new GridLayout(1, true));
   final StyledText text =
       new StyledText(dialog, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
   GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
   gd.widthHint = 400;
   gd.heightHint = 300;
   text.setLayoutData(gd);
   text.setText(message);
   text.addKeyListener(
       new KeyAdapter() {
         public void keyPressed(KeyEvent e) {
           if (e.stateMask == SWT.CTRL) {
             if (e.keyCode == 'a' || e.keyCode == 'A') {
               text.selectAll();
             }
           }
         }
       });
   if (srList != null && srList.size() > 0) {
     text.setStyleRanges(srList.toArray(new StyleRange[srList.size()]));
   }
   Button btn = new Button(dialog, SWT.PUSH);
   gd = new GridData(SWT.RIGHT, SWT.FILL, false, false);
   gd.widthHint = 100;
   btn.setLayoutData(gd);
   btn.setText("&Close");
   btn.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           dialog.close();
         }
       });
   dialog.pack();
   dialog.open();
 }
  @Override
  protected Control createDialogArea(Composite parent) {
    setTitle((templatePersistenceData == null ? "Create a new" : "Modify the") + " Code Clip");
    Composite parentComposite = (Composite) super.createDialogArea(parent);

    GridLayout gridLayout = (GridLayout) parentComposite.getLayout();
    gridLayout.numColumns = 2; // 3;
    gridLayout.makeColumnsEqualWidth = false;

    GridData layoutData = (GridData) parentComposite.getChildren()[0].getLayoutData();
    layoutData.horizontalSpan = 2; // 3;

    gridLayout.marginWidth = 10;
    gridLayout.marginHeight = 10;
    gridLayout.horizontalSpacing = 5;
    gridLayout.verticalSpacing = 5;

    Label abbrevLabel = new Label(parentComposite, SWT.NONE);
    abbrevLabel.setText("Abbreviation:        ");
    GridData abbrevLabelGridData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    abbrevLabel.setLayoutData(abbrevLabelGridData);

    Label descriptionLabel = new Label(parentComposite, SWT.NONE);
    descriptionLabel.setText("Description:");
    GridData descriptionLabelGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    descriptionLabel.setLayoutData(descriptionLabelGridData);

    //		Label contentTypeLabel = new Label(parentComposite, SWT.NONE);
    //        contentTypeLabel.setText("Content Type:");
    //		GridData contentTypeLabelGridData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    //		contentTypeLabel.setLayoutData(contentTypeLabelGridData);

    abbrevText = new Text(parentComposite, SWT.SINGLE | SWT.BORDER);
    abbrevText.setText(abbrev);
    abbrevText.setEditable(templatePersistenceData == null);
    GridData abbrevTextGridData = new GridData(SWT.FILL, SWT.CENTER, false, false);
    abbrevText.setLayoutData(abbrevTextGridData);

    abbrevText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            validateAbbrev();
          }
        });

    descriptionText = new Text(parentComposite, SWT.SINGLE | SWT.BORDER);
    descriptionText.setText(description);
    GridData descriptionTextGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    descriptionText.setLayoutData(descriptionTextGridData);

    //		contentTypeText = new Text(parentComposite, SWT.SINGLE | SWT.BORDER);
    //      contentTypeText.setText(contentType);
    //      contentTypeText.setEditable(false);
    //		GridData contentTypeTextGridData = new GridData(SWT.FILL, SWT.CENTER, false, false);
    //		contentTypeText.setLayoutData(contentTypeTextGridData);

    Label expansionLabel = new Label(parentComposite, SWT.NONE);
    expansionLabel.setText("Expansion:");
    GridData expansionLabelGridData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    expansionLabelGridData.horizontalSpan = 2; // 3;
    expansionLabel.setLayoutData(expansionLabelGridData);

    expansionText =
        new StyledText(parentComposite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    expansionText.setText(expansion);
    expansionText.setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
    GridData styledTextGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    styledTextGridData.heightHint = expansionText.getLineHeight() * 8;
    styledTextGridData.horizontalSpan = 2; // 3;
    expansionText.setLayoutData(styledTextGridData);

    if (templatePersistenceData == null) {
      abbrevText.setFocus();
    } else {
      descriptionText.setFocus();
    }
    return parentComposite;
  }
Ejemplo n.º 13
0
  void createControlTransfer(Composite parent) {
    Label l = new Label(parent, SWT.NONE);
    l.setText("Text:");
    Button b = new Button(parent, SWT.PUSH);
    b.setText("Cut");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            text.cut();
          }
        });
    b = new Button(parent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            text.copy();
          }
        });
    b = new Button(parent, SWT.PUSH);
    b.setText("Paste");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            text.paste();
          }
        });
    text = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    text.setLayoutData(data);

    l = new Label(parent, SWT.NONE);
    l.setText("Combo:");
    b = new Button(parent, SWT.PUSH);
    b.setText("Cut");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            combo.cut();
          }
        });
    b = new Button(parent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            combo.copy();
          }
        });
    b = new Button(parent, SWT.PUSH);
    b.setText("Paste");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            combo.paste();
          }
        });
    combo = new Combo(parent, SWT.NONE);
    combo.setItems(new String[] {"Item 1", "Item 2", "Item 3", "A longer Item"});

    l = new Label(parent, SWT.NONE);
    l.setText("StyledText:");
    l = new Label(parent, SWT.NONE);
    l.setVisible(false);
    b = new Button(parent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            styledText.copy();
          }
        });
    b = new Button(parent, SWT.PUSH);
    b.setText("Paste");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            styledText.paste();
          }
        });
    styledText = new StyledText(parent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    styledText.setLayoutData(data);
  }
Ejemplo n.º 14
0
  protected void initViLister() {

    this.setLayout(new FillLayout());
    fileImage = ResourceManager.getImage("file.png");
    folderImage = ResourceManager.getImage("folder.png");

    mainArea = new Composite(this, SWT.NONE);
    GridLayout layout = GuiDataFactory.createkGridLayout(1, 0, 0, 0, 0, true);
    mainArea.setLayout(layout);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    mainArea.setLayoutData(gridData);

    Composite headGroup = new Composite(mainArea, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    headGroup.setLayoutData(gridData);

    layout = GuiDataFactory.createkGridLayout(3, 0, 0, 0, 0, false);
    headGroup.setLayout(layout);

    btnUpDir = new Button(headGroup, SWT.PUSH);
    btnUpDir.setText(".."); // $NON-NLS-1$
    gridData = new GridData();
    btnUpDir.setLayoutData(gridData);

    btnTopDir = new Button(headGroup, SWT.PUSH);
    btnTopDir.setText("/"); // $NON-NLS-1$
    gridData = new GridData();
    btnTopDir.setLayoutData(gridData);

    textLocation = new StyledText(headGroup, SWT.SINGLE | SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    textLocation.setLayoutData(gridData);

    table = new Table(mainArea, SWT.MULTI);
    gridData = new GridData(GridData.FILL_BOTH);
    table.setLayoutData(gridData);

    table.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            currentRow = table.getSelectionIndex();
          }

          public void widgetDefaultSelected(SelectionEvent arg0) {
            enterPath();
          }
        });

    TableColumn columName = new TableColumn(table, SWT.BORDER);
    columName.setText("name");
    columName.setWidth(270);

    TableColumn columnSize = new TableColumn(table, SWT.BORDER);
    columnSize.setText("size");
    columnSize.setWidth(80);

    TableColumn columnDate = new TableColumn(table, SWT.BORDER);
    columnDate.setText("date");
    columnDate.setWidth(120);

    table.setHeaderVisible(true);
    table.setLinesVisible(false);
  }
Ejemplo n.º 15
0
 /**
  * When this view is resized, the StyledText SWT widget is resized accordingly. This method should
  * be called only as a response to the ControlListener.
  */
 public void controlResized(ControlEvent e) {
   Point parentSize = parentCompo.getSize();
   rowData.width = parentSize.x - 36;
   rowData.height = parentSize.y - 11;
   shellTextArea.setLayoutData(rowData);
 }
Ejemplo n.º 16
0
  /**
   * Creates a new <code>BZStyledText</code> for parentShell <code>parentShell</code>.
   *
   * @param parentShell parentShell of the new instance (cannot be null)
   */
  public BZStyledText(Shell parentShell) {
    this.parentShell = parentShell;

    //   version from jar manifest
    String version = getClass().getPackage().getImplementationVersion();

    //   version from build file
    if (version == null) version = System.getProperty("braillezephyr.version");

    //   no version
    if (version == null) {
      logWriter.println("WARNING:  unable to determine version, using 0.0");
      version = "0.0";
    }

    versionString = version;
    String[] versionStrings = versionString.split("\\.");
    versionMajor = Integer.parseInt(versionStrings[0]);
    if (versionStrings.length > 1) versionMinor = Integer.parseInt(versionStrings[1]);
    else versionMinor = 0;
    if (versionStrings.length > 2) versionPatch = Integer.parseInt(versionStrings[2]);
    else versionPatch = 0;

    color = parentShell.getDisplay().getSystemColor(SWT.COLOR_BLACK);

    composite = new Composite(parentShell, 0);
    composite.setLayout(new GridLayout(2, true));

    //   load fonts
    loadFont("BrailleZephyr_6.otf");
    loadFont("BrailleZephyr_6b.otf");
    loadFont("BrailleZephyr_6s.otf");
    loadFont("BrailleZephyr_6sb.otf");
    loadFont("BrailleZephyr_8.otf");
    loadFont("BrailleZephyr_8b.otf");
    loadFont("BrailleZephyr_8s.otf");
    loadFont("BrailleZephyr_8sb.otf");
    loadFont("BrailleZephyr_8w.otf");
    loadFont("BrailleZephyr_8wb.otf");
    loadFont("BrailleZephyr_8ws.otf");
    loadFont("BrailleZephyr_8wsb.otf");

    //   load line margin bell
    try {
      InputStream inputStreamBellMargin =
          new BufferedInputStream(getClass().getResourceAsStream("/sounds/line_margin_bell.wav"));
      AudioInputStream audioInputStreamMargin =
          AudioSystem.getAudioInputStream(inputStreamBellMargin);
      DataLine.Info dataLineInfoMargin =
          new DataLine.Info(Clip.class, audioInputStreamMargin.getFormat());
      lineMarginClip = (Clip) AudioSystem.getLine(dataLineInfoMargin);
      lineMarginClip.open(audioInputStreamMargin);
    } catch (IOException exception) {
      logWriter.println(
          "ERROR:  Unable to read default line margin bell file:  " + exception.getMessage());
      lineMarginClip = null;
    } catch (UnsupportedAudioFileException exception) {
      logWriter.println(
          "ERROR:  Sound file unsupported for default line margin bell:  "
              + exception.getMessage());
      lineMarginClip = null;
    } catch (LineUnavailableException exception) {
      logWriter.println(
          "ERROR:  Line unavailable for default line margin bell:  " + exception.getMessage());
      lineMarginClip = null;
    }

    //   load page margin bell
    try {
      InputStream inputStreamBellPage =
          new BufferedInputStream(getClass().getResourceAsStream("/sounds/page_margin_bell.wav"));
      AudioInputStream audioInputStreamPage = AudioSystem.getAudioInputStream(inputStreamBellPage);
      DataLine.Info dataLineInfoPage =
          new DataLine.Info(Clip.class, audioInputStreamPage.getFormat());
      pageMarginClip = (Clip) AudioSystem.getLine(dataLineInfoPage);
      pageMarginClip.open(audioInputStreamPage);
    } catch (IOException exception) {
      logWriter.println(
          "ERROR:  Unable to read default page margin bell file:  " + exception.getMessage());
      pageMarginClip = null;
    } catch (UnsupportedAudioFileException exception) {
      logWriter.println(
          "ERROR:  Sound file unsupported for default page margin bell:  "
              + exception.getMessage());
      pageMarginClip = null;
    } catch (LineUnavailableException exception) {
      logWriter.println(
          "ERROR:  Line unavailable for default page margin bell:  " + exception.getMessage());
      pageMarginClip = null;
    }

    //   load line end bell
    try {
      InputStream inputStreamBellPage =
          new BufferedInputStream(getClass().getResourceAsStream("/sounds/line_end_bell.wav"));
      AudioInputStream audioInputStreamPage = AudioSystem.getAudioInputStream(inputStreamBellPage);
      DataLine.Info dataLineInfoPage =
          new DataLine.Info(Clip.class, audioInputStreamPage.getFormat());
      lineEndClip = (Clip) AudioSystem.getLine(dataLineInfoPage);
      lineEndClip.open(audioInputStreamPage);
    } catch (IOException exception) {
      logWriter.println(
          "ERROR:  Unable to read default line end bell file:  " + exception.getMessage());
      lineEndClip = null;
    } catch (UnsupportedAudioFileException exception) {
      logWriter.println(
          "ERROR:  Sound file unsupported for default line end bell:  " + exception.getMessage());
      lineEndClip = null;
    } catch (LineUnavailableException exception) {
      logWriter.println(
          "ERROR:  Line unavailable for default line end bell:  " + exception.getMessage());
      lineEndClip = null;
    }

    brailleText = new StyledText(composite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    brailleText.setLayoutData(new GridData(GridData.FILL_BOTH));
    brailleText.setFont(new Font(parentShell.getDisplay(), "BrailleZephyr_6s", 18, SWT.NORMAL));
    brailleText.addFocusListener(new FocusHandler(brailleText));
    brailleText.addPaintListener(new PaintHandler(brailleText));
    BrailleKeyHandler brailleKeyHandler = new BrailleKeyHandler(true);
    brailleText.addKeyListener(brailleKeyHandler);
    brailleText.addVerifyKeyListener(brailleKeyHandler);
    brailleText.addExtendedModifyListener(new ExtendedModifyHandler(brailleText));

    content = brailleText.getContent();

    asciiText = new StyledText(composite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    asciiText.setContent(content);
    asciiText.setLayoutData(new GridData(GridData.FILL_BOTH));
    asciiText.setFont(new Font(parentShell.getDisplay(), "Monospace", 18, SWT.NORMAL));
    asciiText.addFocusListener(new FocusHandler(asciiText));
    asciiText.addPaintListener(new PaintHandler(asciiText));
    asciiText.addVerifyKeyListener(new BrailleKeyHandler(false));
    asciiText.addExtendedModifyListener(new ExtendedModifyHandler(asciiText));

    brailleText.addCaretListener(new CaretHandler(brailleText, asciiText));
    asciiText.addCaretListener(new CaretHandler(asciiText, brailleText));

    currentText = brailleText;
  }
Ejemplo n.º 17
0
  private static void createStyledText(final Group group) {
    group.setLayout(new GridLayout(2, false));
    group.setText("StyledText widget");

    final Label lbl0 = new Label(group, SWT.NONE);
    lbl0.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl0.setText("No prompt :");

    final StyledText txt0 = new StyledText(group, SWT.BORDER);
    txt0.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));

    final Label lbl1 = new Label(group, SWT.NONE);
    lbl1.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl1.setText("Simple text prompt :");

    final StyledText txt1 = new StyledText(group, SWT.BORDER);
    txt1.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    PromptSupport.setPrompt("Type anything you want", txt1);

    final Label lbl2 = new Label(group, SWT.NONE);
    lbl2.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl2.setText("Other style (bold) :");

    final StyledText txt2 = new StyledText(group, SWT.BORDER);
    txt2.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    PromptSupport.setPrompt("Type anything you want in bold", txt2);
    PromptSupport.setFontStyle(SWT.BOLD, txt2);

    final Label lbl3 = new Label(group, SWT.NONE);
    lbl3.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl3.setText("Behaviour highlight :");

    final StyledText txt3 = new StyledText(group, SWT.BORDER);
    txt3.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    PromptSupport.setPrompt("Type anything you want", txt3);
    PromptSupport.setFocusBehavior(FocusBehavior.HIGHLIGHT_PROMPT, txt3);

    final Label lbl4 = new Label(group, SWT.NONE);
    lbl4.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl4.setText("Change colors :");

    final StyledText txt4 = new StyledText(group, SWT.BORDER);
    txt4.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    PromptSupport.setPrompt("Type anything you want", txt4);
    PromptSupport.setForeground(txt4.getDisplay().getSystemColor(SWT.COLOR_YELLOW), txt4);
    PromptSupport.setBackground(txt4.getDisplay().getSystemColor(SWT.COLOR_BLACK), txt4);

    final Label lbl5 = new Label(group, SWT.NONE);
    lbl5.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl5.setText("Change when widget is initialized :");

    final StyledText txt5 = new StyledText(group, SWT.BORDER);
    txt5.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    txt5.setText("Remove what is typed...");
    txt5.setBackground(txt4.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    txt5.setForeground(txt4.getDisplay().getSystemColor(SWT.COLOR_YELLOW));

    PromptSupport.setPrompt("Type anything you want", txt5);
    PromptSupport.setForeground(txt4.getDisplay().getSystemColor(SWT.COLOR_DARK_BLUE), txt5);
    PromptSupport.setBackground(txt4.getDisplay().getSystemColor(SWT.COLOR_WHITE), txt5);
  }
Ejemplo n.º 18
0
  /* (non-Javadoc)
   * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
   */
  @Override
  public void createPartControl(final Composite parent) {
    parent.setLayout(new GridLayout(6, true));

    CLabel clRuns = new CLabel(parent, SWT.LEFT);
    clRuns.setText(UITexts.test_view_runs);

    tRuns = new Text(parent, SWT.NONE);
    tRuns.setText("0"); // $NON-NLS-1$
    tRuns.setEditable(false);

    CLabel clErrors = new CLabel(parent, SWT.LEFT);
    clErrors.setText(UITexts.test_view_errors);
    clErrors.setImage(HaskellUIImages.getImage(IImageNames.ERROR_OVERLAY));

    tErrors = new Text(parent, SWT.NONE);
    tErrors.setText("0"); // $NON-NLS-1$
    tErrors.setEditable(false);

    CLabel clFailures = new CLabel(parent, SWT.LEFT);
    clFailures.setText(UITexts.test_view_failures);
    clFailures.setImage(HaskellUIImages.getImage(IImageNames.FAILURE_OVERLAY));

    tFailures = new Text(parent, SWT.NONE);
    tFailures.setText("0"); // $NON-NLS-1$
    tFailures.setEditable(false);

    final Composite mainComposite = new Composite(parent, SWT.NONE);
    final GridData gd =
        new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
    gd.horizontalSpan = 6;
    mainComposite.setLayoutData(gd);
    FormLayout fl = new FormLayout();
    mainComposite.setLayout(fl);

    testTree = new TreeViewer(mainComposite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    final Sash sash = new Sash(mainComposite, SWT.HORIZONTAL);

    FormData fd = new FormData();
    fd.top = new FormAttachment(0);
    fd.left = new FormAttachment(0);
    fd.right = new FormAttachment(100);
    fd.bottom = new FormAttachment(sash, 0);
    testTree.getTree().setLayoutData(fd);
    testTree.setContentProvider(new TestResultCP());
    testTree.setLabelProvider(new TestResultLP());

    CLabel clOutput = new CLabel(mainComposite, SWT.LEFT);
    clOutput.setText(UITexts.test_view_text);

    final FormData sashData = new FormData();
    sashData.top = new FormAttachment(50, 0);
    sashData.left = new FormAttachment(0);
    sashData.right = new FormAttachment(100);
    sash.setLayoutData(sashData);

    fd = new FormData();
    fd.top = new FormAttachment(sash, 0);
    fd.left = new FormAttachment(0);
    fd.right = new FormAttachment(100);
    clOutput.setLayoutData(fd);

    testText = new StyledText(mainComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);

    fd = new FormData();
    fd.top = new FormAttachment(clOutput, 0);
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100);
    fd.bottom = new FormAttachment(100);
    testText.setLayoutData(fd);

    testTree.addSelectionChangedListener(
        new ISelectionChangedListener() {

          @Override
          public void selectionChanged(final SelectionChangedEvent paramSelectionChangedEvent) {
            Object o =
                ((IStructuredSelection) paramSelectionChangedEvent.getSelection())
                    .getFirstElement();
            if (o instanceof TestResult) {
              String txt = ((TestResult) o).getText();
              if (txt == null) {
                txt = ""; // $NON-NLS-1$
              }
              testText.setText(txt);
            }
          }
        });

    testTree.addDoubleClickListener(
        new IDoubleClickListener() {

          @Override
          public void doubleClick(final DoubleClickEvent paramDoubleClickEvent) {
            Object o =
                ((IStructuredSelection) paramDoubleClickEvent.getSelection()).getFirstElement();
            if (o instanceof TestResult) {
              TestResult tr = (TestResult) o;
              if (tr.getLocation() != null && tr.getProject() != null) {
                try {
                  OpenDefinitionHandler.openInEditor(tr.getLocation(), tr.getProject());
                } catch (Throwable t) {
                  HaskellCorePlugin.log(t);
                }
              }
            }
          }
        });

    sash.addListener(
        SWT.Selection,
        new Listener() {

          @Override
          public void handleEvent(final Event event) {
            Rectangle clientArea = mainComposite.getClientArea();
            Rectangle sashRect = sash.getBounds();
            int top = clientArea.height - 70; // bottom minimum
            event.y = Math.max(Math.min(event.y, top), 30); // top minimum
            if (event.y != sashRect.y) {
              sashData.top = new FormAttachment(0, event.y);
              mainComposite.layout();
            }
          }
        });

    IToolBarManager tmgr = getViewSite().getActionBars().getToolBarManager();
    HistoryAction act = new HistoryAction();

    tmgr.add(act);
  }
  /**
   * Creates a source viewer information control with the given shell as parent. The given shell
   * styles are applied to the created shell. The given styles are applied to the created styled
   * text widget. The text widget will be initialized with the given font. The status field will
   * contain the given text or be hidden.
   *
   * @param parent the parent shell
   * @param isResizable <code>true</code> if resizable
   * @param symbolicFontName the symbolic font name
   * @param statusFieldText the text to be used in the optional status field or <code>null</code> if
   *     the status field should be hidden
   */
  public SourceViewerInformationControl(
      Shell parent, boolean isResizable, String symbolicFontName, String statusFieldText) {
    GridLayout layout;
    GridData gd;

    int shellStyle = SWT.TOOL | SWT.ON_TOP | (isResizable ? SWT.RESIZE : 0);
    int textStyle = isResizable ? SWT.V_SCROLL | SWT.H_SCROLL : SWT.NONE;

    fShell = new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle);
    Display display = fShell.getDisplay();

    Composite composite = fShell;
    layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    composite.setLayoutData(gd);

    if (statusFieldText != null) {
      composite = new Composite(composite, SWT.NONE);
      layout = new GridLayout(1, false);
      layout.marginHeight = 0;
      layout.marginWidth = 0;
      composite.setLayout(layout);
      gd = new GridData(GridData.FILL_BOTH);
      composite.setLayoutData(gd);
      composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
      composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    }

    // Source viewer
    fViewer = new SourceViewer(composite, null, textStyle);
    fViewer.configure(new SourceViewerConfiguration());
    fViewer.setEditable(false);

    fText = fViewer.getTextWidget();
    gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
    fText.setLayoutData(gd);
    fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
    fText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    fSymbolicFontName = symbolicFontName;
    fTextFont = JFaceResources.getFont(symbolicFontName);
    fText.setFont(fTextFont);

    fText.addKeyListener(
        new KeyListener() {

          public void keyPressed(KeyEvent e) {
            if (e.character == 0x1B) // ESC
            fShell.dispose();
          }

          public void keyReleased(KeyEvent e) {}
        });

    // Status field
    if (statusFieldText != null) {

      // Horizontal separator line
      fSeparator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
      fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      // Status field label
      fStatusField = new Label(composite, SWT.RIGHT);
      fStatusField.setText(statusFieldText);
      Font font = fStatusField.getFont();
      FontData[] fontDatas = font.getFontData();
      for (int i = 0; i < fontDatas.length; i++)
        fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
      fStatusTextFont = new Font(fStatusField.getDisplay(), fontDatas);
      fStatusField.setFont(fStatusTextFont);
      GridData gd2 =
          new GridData(
              GridData.FILL_VERTICAL
                  | GridData.FILL_HORIZONTAL
                  | GridData.HORIZONTAL_ALIGN_BEGINNING
                  | GridData.VERTICAL_ALIGN_BEGINNING);
      fStatusField.setLayoutData(gd2);

      fStatusTextForegroundColor =
          new Color(
              fStatusField.getDisplay(),
              blend(
                  display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(),
                  display.getSystemColor(SWT.COLOR_INFO_FOREGROUND).getRGB(),
                  0.56f));
      fStatusField.setForeground(fStatusTextForegroundColor);

      fStatusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    }

    addDisposeListener(this);
  }
Ejemplo n.º 20
0
  @Override
  protected void createBundleContent(Composite parent) {

    mform = new ManagedForm(parent);
    setManagedForm(mform);
    sform = mform.getForm();
    FormToolkit toolkit = mform.getToolkit();
    sform.setText("Server Console");
    sform.setImage(ServerUICore.getLabelProvider().getImage(getServer()));
    sform.setExpandHorizontal(true);
    sform.setExpandVertical(true);
    toolkit.decorateFormHeading(sform.getForm());

    Composite body = sform.getBody();
    GridLayout layout = new GridLayout(1, false);
    layout.marginLeft = 6;
    layout.marginTop = 6;
    layout.marginRight = 6;
    body.setLayout(layout);

    Section manifestSection =
        toolkit.createSection(sform.getBody(), ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
    manifestSection.setText("Commands");
    manifestSection.setDescription("Execute commands on server.");
    layout = new GridLayout();
    manifestSection.setLayout(layout);
    manifestSection.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite manifestComposite = toolkit.createComposite(manifestSection);
    layout = new GridLayout();
    layout.marginLeft = 6;
    layout.marginTop = 6;
    layout.numColumns = 3;
    manifestComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    manifestComposite.setLayout(layout);
    manifestSection.setClient(manifestComposite);

    Label commandLabel = toolkit.createLabel(manifestComposite, "Command:");
    commandLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(commandLabel);
    commandText = toolkit.createText(manifestComposite, "", SWT.CANCEL | SWT.SEARCH);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(commandText);

    commandText.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.character == SWT.CR || e.character == SWT.LF) {
              history.add(commandText.getText());
              String cmdLine = commandText.getText();
              executeCommand(cmdLine);
            } else if (e.keyCode == SWT.ARROW_UP) {
              String command = history.back();
              commandText.setText(command);
              commandText.setSelection(command.length());
              e.doit = false;
            } else if (e.keyCode == SWT.ARROW_DOWN) {
              String command = history.forward();
              commandText.setText(command);
              commandText.setSelection(command.length());
              e.doit = false;
            }
          }
        });

    Button commandButton = toolkit.createButton(manifestComposite, "Execute", SWT.PUSH);
    commandButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            history.add(commandText.getText());
            String cmdLine = commandText.getText();
            executeCommand(cmdLine);
          }
        });
    Button clearButton = toolkit.createButton(manifestComposite, "Clear", SWT.PUSH);
    clearButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            manifestText.setText("");
          }
        });

    manifestText =
        new StyledText(manifestComposite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    manifestText.setWordWrap(false);
    manifestText.setFont(JFaceResources.getTextFont());
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 3;
    manifestText.setLayoutData(data);

    Label helpLabel =
        toolkit.createLabel(manifestComposite, "Type 'help' to get a list of supported commands.");
    GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(helpLabel);

    toolBarManager = sform.getToolBarManager();

    backAction =
        new Action("Back") {
          @Override
          public void run() {
            commandText.setText(history.back());
            String cmdLine = commandText.getText();
            executeCommand(cmdLine);
          }
        };
    backAction.setImageDescriptor(
        ImageResource.getImageDescriptor(
            org.eclipse.ui.internal.browser.ImageResource.IMG_ELCL_NAV_BACKWARD));
    backAction.setHoverImageDescriptor(
        ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_NAV_BACKWARD));
    backAction.setDisabledImageDescriptor(
        ImageResource.getImageDescriptor(ImageResource.IMG_DLCL_NAV_BACKWARD));
    backAction.setEnabled(false);
    toolBarManager.add(backAction);

    forwardAction =
        new Action("Forward") {
          @Override
          public void run() {
            commandText.setText(history.forward());
            String cmdLine = commandText.getText();
            executeCommand(cmdLine);
          }
        };
    forwardAction.setImageDescriptor(
        ImageResource.getImageDescriptor(ImageResource.IMG_ELCL_NAV_FORWARD));
    forwardAction.setHoverImageDescriptor(
        ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_NAV_FORWARD));
    forwardAction.setDisabledImageDescriptor(
        ImageResource.getImageDescriptor(ImageResource.IMG_DLCL_NAV_FORWARD));
    forwardAction.setEnabled(false);
    toolBarManager.add(forwardAction);

    refreshAction =
        new Action(
            "Refresh from server",
            ImageResource.getImageDescriptor(ImageResource.IMG_ELCL_NAV_REFRESH)) {

          @Override
          public void run() {
            String cmdLine = history.current();
            if (cmdLine != null) {
              executeCommand(cmdLine);
            }
          }
        };
    toolBarManager.add(refreshAction);
    sform.updateToolBar();
  }
Ejemplo n.º 21
0
  /**
   * Simply calls super and adds some listeners.
   *
   * @param parent
   * @param style
   */
  public TextWrapper(Composite parent, int style) {

    super(parent, SWT.NONE);
    //		GridLayoutFactory.fillDefaults().applyTo(this);
    setLayout(new GridLayout(1, false));

    this.text = new StyledText(this, style);
    //		GridDataFactory.fillDefaults().applyTo(text);
    text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    mainControl = text;

    this.modifyListener =
        new ModifyListener() {
          private JexlEngine jexl;

          @Override
          public void modifyText(ModifyEvent e) {

            final Object newValue = getValue();

            if (textType == TEXT_TYPE.EXPRESSION) {
              if (jexl == null) {
                jexl = new JexlEngine();
              }
              try {
                String expression = newValue.toString().trim();
                jexl.createExpression(expression);
                text.setForeground(BLUE);
              } catch (Throwable ne) {
                text.setForeground(RED);
              }
            } else if (textType == TEXT_TYPE.FILENAME) {
              String testString = newValue.toString().trim();
              if (testString.contains(" ")
                  || testString.startsWith("-")
                  || testString.contains(";")
                  || testString.contains("<")
                  || testString.contains("\t")
                  || testString.contains("'")
                  || testString.contains("\"")
                  || testString.contains("\\")
                  || testString.contains("\n")
                  || testString.contains("..")) {
                if (!RED.isDisposed()) {
                  text.setForeground(RED);
                }
                text.setToolTipText("Expression has invalid syntax");

              } else {
                text.setToolTipText(
                    "Enter a valid filename. Do NOT use spaces, commas, backslash etc.");
                if (!BLACK.isDisposed()) {
                  text.setForeground(BLACK);
                }
              }
            }

            final ValueEvent evt = new ValueEvent(text, getFieldName());
            evt.setValue(newValue);
            eventDelegate.notifyValueListeners(evt);
          }
        };
    text.addModifyListener(modifyListener);
  }
Ejemplo n.º 22
0
  /**
   * @param glURL
   * @param glParameter
   */
  private void createURLComposite(Composite parent) {
    GridLayout gl = (GridLayout) parent.getLayout();
    gl.numColumns = 2;

    Label lblTarget = new Label(parent, SWT.NONE);
    GridData gdLBLTarget = new GridData();
    gdLBLTarget.horizontalIndent = 2;
    lblTarget.setLayoutData(gdLBLTarget);
    lblTarget.setText(Messages.getString("HyperlinkEditorDialog.Text.MenuLabel")); // $NON-NLS-1$

    fTxtHyperlinkLabel = new Text(parent, SWT.BORDER);
    GridData gdTXTTarget = new GridData(GridData.FILL_HORIZONTAL);
    gdTXTTarget.widthHint = 80;
    fTxtHyperlinkLabel.setLayoutData(gdTXTTarget);

    AssistField af =
        new TextAssistField(fTxtHyperlinkLabel, null) {

          private boolean fIsDuplicate = false;

          /* (non-Javadoc)
           * @see org.eclipse.birt.chart.ui.swt.fieldassist.TextAssistField#isValid()
           */
          public boolean isValid() {
            fIsDuplicate = false;
            String text = fTxtHyperlinkLabel.getText();
            if (text == null || "".equals(text.trim())) { // $NON-NLS-1$
              return false;
            }

            if (fExistingLabels != null && fExistingLabels.contains(fTxtHyperlinkLabel.getText())) {
              fIsDuplicate = true;
              return false;
            }

            return true;
          }

          /* (non-Javadoc)
           * @see org.eclipse.birt.chart.ui.swt.fieldassist.AssistField#isRequiredField()
           */
          public boolean isRequiredField() {
            return true;
          }

          public String getErrorMessage() {
            if (fIsDuplicate) {
              return Messages.getString(
                  "HyperlinkEditorDialog.ErrorMessage.ExistingText"); //$NON-NLS-1$
            }
            return Messages.getString("HyperlinkEditorDialog.ErrorMessage.NullText"); // $NON-NLS-1$
          }
        };
    FieldAssistHelper.getInstance().addRequiredFieldIndicator(af, lblTarget);

    Label lblBaseURL = new Label(parent, SWT.NONE);
    GridData gdLBLBaseURL = new GridData();
    gdLBLBaseURL.horizontalIndent = 2;
    lblBaseURL.setLayoutData(gdLBLBaseURL);
    lblBaseURL.setText(Messages.getString("TriggerDataComposite.Lbl.BaseURL")); // $NON-NLS-1$

    fBtnBaseURL = new Button(parent, SWT.NONE);
    {
      GridData gd = new GridData();
      fBtnBaseURL.setLayoutData(gd);
      fBtnBaseURL.setText(
          Messages.getString("TriggerDataComposite.Text.EditBaseURL")); // $NON-NLS-1$
      fBtnBaseURL.setToolTipText(
          Messages.getString("TriggerDataComposite.Tooltip.InvokeURLBuilder")); // $NON-NLS-1$
      fBtnBaseURL.addSelectionListener(this);
      fBtnBaseURL.setEnabled(fContext.getUIServiceProvider().isInvokingSupported());
    }

    Label lblDefine = new Label(parent, SWT.WRAP);
    {
      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalIndent = 2;
      gd.horizontalSpan = 3;
      gd.widthHint = 200;
      lblDefine.setLayoutData(gd);
      lblDefine.setText(
          Messages.getString("TriggerDataComposite.Label.Description")); // $NON-NLS-1$
    }

    fBtnAdvanced = new Button(parent, SWT.NONE);
    {
      GridData gd = new GridData();
      gd.horizontalSpan = 2;
      fBtnAdvanced.setLayoutData(gd);
      fBtnAdvanced.setText(getAdvancedButtonText(bAdvanced));
      fBtnAdvanced.setToolTipText(
          Messages.getString("TriggerDataComposite.Tooltip.Advanced")); // $NON-NLS-1$
      fBtnAdvanced.addSelectionListener(this);
      fBtnAdvanced.setEnabled(fbEnableURLParameters);
    }

    fGrpParameters = new Group(parent, SWT.NONE);
    GridData gdGRPParameters = new GridData(GridData.FILL_HORIZONTAL);
    gdGRPParameters.horizontalSpan = 3;
    fGrpParameters.setLayoutData(gdGRPParameters);

    GridLayout glParameter = new GridLayout();
    glParameter.marginWidth = 2;
    glParameter.marginHeight = 6;
    glParameter.horizontalSpacing = 6;
    glParameter.numColumns = 3;

    fGrpParameters.setLayout(glParameter);
    fGrpParameters.setText(
        Messages.getString("TriggerDataComposite.Lbl.ParameterNames")); // $NON-NLS-1$
    fGrpParameters.setVisible(bAdvanced);

    StyledText stParameters = new StyledText(fGrpParameters, SWT.WRAP | SWT.READ_ONLY);
    {
      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalIndent = 2;
      gd.horizontalSpan = 3;
      gd.widthHint = 200;
      stParameters.setLayoutData(gd);
      stParameters.setText(
          Messages.getString("TriggerDataComposite.Label.OptionalURLParameters")); // $NON-NLS-1$
      stParameters.setBackground(parent.getBackground());
    }

    Label lblBaseParm = new Label(fGrpParameters, SWT.NONE);
    {
      GridData gdLBLBaseParm = new GridData();
      gdLBLBaseParm.horizontalIndent = 2;
      lblBaseParm.setLayoutData(gdLBLBaseParm);
      lblBaseParm.setText(
          Messages.getString("TriggerDataComposite.Lbl.CategorySeries")); // $NON-NLS-1$
      lblBaseParm.setToolTipText(
          Messages.getString("TriggerDataComposite.Tooltip.ParameterCategory")); // $NON-NLS-1$
    }

    fTxtBaseParm = new Text(fGrpParameters, SWT.BORDER);
    GridData gdTXTBaseParm = new GridData(GridData.FILL_HORIZONTAL);
    gdTXTBaseParm.horizontalSpan = 2;
    fTxtBaseParm.setLayoutData(gdTXTBaseParm);
    fTxtBaseParm.setToolTipText(
        Messages.getString("TriggerDataComposite.Tooltip.ParameterCategory")); // $NON-NLS-1$
    fTxtBaseParm.setEnabled(
        fbEnableURLParameters
            && ((fOptionalStyle & TriggerDataComposite.DISABLE_CATEGORY_SERIES)
                != TriggerDataComposite.DISABLE_CATEGORY_SERIES));
    Label lblValueParm = new Label(fGrpParameters, SWT.NONE);
    {
      GridData gdLBLValueParm = new GridData();
      gdLBLValueParm.horizontalIndent = 2;
      lblValueParm.setLayoutData(gdLBLValueParm);
      lblValueParm.setText(
          Messages.getString("TriggerDataComposite.Lbl.ValueSeries")); // $NON-NLS-1$
      lblValueParm.setToolTipText(
          Messages.getString("TriggerDataComposite.Tooltip.ParameterValue")); // $NON-NLS-1$
    }

    fTxtValueParm = new Text(fGrpParameters, SWT.BORDER);
    GridData gdTXTValueParm = new GridData(GridData.FILL_HORIZONTAL);
    gdTXTValueParm.horizontalSpan = 2;
    fTxtValueParm.setLayoutData(gdTXTValueParm);
    fTxtValueParm.setToolTipText(
        Messages.getString("TriggerDataComposite.Tooltip.ParameterValue")); // $NON-NLS-1$
    fTxtValueParm.setEnabled(
        fbEnableURLParameters
            && ((fOptionalStyle & TriggerDataComposite.DISABLE_VALUE_SERIES)
                != TriggerDataComposite.DISABLE_VALUE_SERIES));

    Label lblSeriesParm = new Label(fGrpParameters, SWT.NONE);
    {
      GridData gdLBLSeriesParm = new GridData();
      gdLBLSeriesParm.horizontalIndent = 2;
      lblSeriesParm.setLayoutData(gdLBLSeriesParm);
      lblSeriesParm.setText(
          Messages.getString("TriggerDataComposite.Lbl.ValueSeriesName")); // $NON-NLS-1$
      lblSeriesParm.setToolTipText(
          Messages.getString("TriggerDataComposite.Tooltip.ParameterSeries")); // $NON-NLS-1$
    }

    fTxtSeriesParm = new Text(fGrpParameters, SWT.BORDER);
    GridData gdTXTSeriesParm = new GridData(GridData.FILL_HORIZONTAL);
    gdTXTSeriesParm.horizontalSpan = 2;
    fTxtSeriesParm.setLayoutData(gdTXTSeriesParm);
    fTxtSeriesParm.setToolTipText(
        Messages.getString("TriggerDataComposite.Tooltip.ParameterSeries")); // $NON-NLS-1$
    fTxtSeriesParm.setEnabled(
        fbEnableURLParameters
            && ((fOptionalStyle & TriggerDataComposite.DISABLE_VALUE_SERIES_NAME)
                != TriggerDataComposite.DISABLE_VALUE_SERIES_NAME));
  }
Ejemplo n.º 23
0
  /**
   * Create the composite.
   *
   * @param parent
   * @param style
   */
  public IOSNavBarComposite(Composite parent, BrowserSimImageList imageList) {
    super(parent, SWT.NONE);

    this.setLayout(new FormLayout());

    pageTitleStyledText = new IOSPageTitleStyledText(this, imageList);
    FormData formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.top = new FormAttachment(0, 0);
    formData.bottom = new FormAttachment(0, 26);
    formData.height = 27;
    pageTitleStyledText.setLayoutData(formData);

    urlText = new AdressBarText(this, SWT.SINGLE);
    formData = new FormData();
    formData.left = new FormAttachment(0, 12);
    formData.right = new FormAttachment(100, -58);
    formData.top = new FormAttachment(0, 33 - AdressBarText.adressBarUrlOffset);
    formData.height = 16;
    urlText.setLayoutData(formData);

    refreshButtonComposite =
        new ImageButtonComposite(
            this,
            imageList.getImage(BD + "refresh.png"),
            imageList.getImage(BD + "refresh.png"),
            imageList.getImage(BD + "refresh-selected.png"));
    formData = new FormData();
    Rectangle refreshImageBounds = imageList.getImage(BD + "refresh.png").getBounds();
    formData.right = new FormAttachment(100, -8);
    formData.bottom = new FormAttachment(100, -7);
    formData.width = refreshImageBounds.width;
    formData.height = refreshImageBounds.height;
    refreshButtonComposite.setLayoutData(formData);

    stopButtonComposite =
        new ImageButtonComposite(
            this,
            imageList.getImage(BD + "stop.png"),
            imageList.getImage(BD + "stop.png"),
            imageList.getImage(BD + "stop-selected.png"));
    formData = new FormData();
    Rectangle stopImageBounds = imageList.getImage(BD + "stop.png").getBounds();
    formData.right = new FormAttachment(100, -42);
    formData.bottom = new FormAttachment(100, -12);
    formData.width = stopImageBounds.width;
    formData.height = stopImageBounds.height;
    stopButtonComposite.setLayoutData(formData);

    progressBar = new ProgressBar(this, SWT.NONE);
    progressBar.setVisible(false);
    formData = new FormData();
    formData.left = new FormAttachment(0, 7);
    formData.right = new FormAttachment(100, -36);
    formData.bottom = new FormAttachment(100, -1);
    formData.height = 5;
    progressBar.setLayoutData(formData);

    Composite imagesComposite = new Composite(this, SWT.NONE);
    formData = new FormData();
    formData.left = new FormAttachment(0);
    formData.right = new FormAttachment(100);
    formData.top = new FormAttachment(0);
    formData.bottom = new FormAttachment(100);
    imagesComposite.setLayoutData(formData);

    GridLayout gridLayout = new GridLayout(5, false);
    gridLayout.verticalSpacing = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;

    imagesComposite.setLayout(gridLayout);

    for (ImageDescriptor descriptor : BODY_DESCRIPTOR) {
      descriptor.createWidget(imagesComposite, imageList);
    }
  }
Ejemplo n.º 24
0
  private void initialize(final Composite inContainer) {
    textWidget =
        new StyledText(
            inContainer,
            SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);

    content = new TextContent();
    textWidget.setContent(content);
    textWidget.setLayout(new GridLayout(1, true));
    textWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    textWidget.addExtendedModifyListener(
        new ExtendedModifyListener() {
          @Override
          public void modifyText(final ExtendedModifyEvent inEvent) {
            if (textWidget.getCharCount() == 0) return;
            final StyleRange lRange =
                textWidget.getStyleRangeAtOffset(Math.max(inEvent.start - 1, 0));
            if (lRange != null) {
              final StyleRange lNew =
                  new StyleRange(
                      lRange.start,
                      lRange.length + inEvent.length,
                      lRange.foreground,
                      lRange.background,
                      lRange.fontStyle);
              textWidget.replaceStyleRanges(lNew.start, lNew.length, new StyleRange[] {lNew});
            }
            final int lEndPos = inEvent.start + inEvent.length;
            if (lEndPos - textWidget.getOffsetAtLine(textWidget.getLineAtOffset(lEndPos)) == 0) {
              final int lLineIndex = textWidget.getLineAtOffset(inEvent.start);
              if (lLineIndex + 2 > textWidget.getLineCount()) return;
              // a new line has been entered, therefore, check whether we
              // have to continue a list
              final Bullet lBullet = textWidget.getLineBullet(lLineIndex);
              textWidget.setLineBullet(lLineIndex + 1, 1, lBullet);
            }
          }
        });
    textWidget.addPaintObjectListener(Styles.getPaintObjectListener(textWidget));
    textWidget.addVerifyKeyListener(
        new VerifyKeyListener() {
          @Override
          public void verifyKey(final VerifyEvent inEvent) {
            if (inEvent.keyCode == 9) { // TAB keyCode
              final StyledText lWidget = (StyledText) inEvent.getSource();
              if (consumeTabKey(lWidget)) {
                inEvent.doit = false;
                final TextStyler lStyler = new TextStyler(lWidget);
                if ((inEvent.stateMask & SWT.SHIFT) != 0) {
                  lStyler.dedentLines();
                  provider.notifyPositionChange(lWidget.getCaretOffset());
                } else {
                  lStyler.indentLines();
                }
              }
            }
          }
        });
    textWidget.addTraverseListener(
        new TraverseListener() {
          @Override
          public void keyTraversed(final TraverseEvent inEvent) {
            if (inEvent.detail == SWT.TRAVERSE_TAB_PREVIOUS
                && consumeTabKey((StyledText) inEvent.getSource())) {
              inEvent.doit = false;
            }
          }
        });
    textWidget.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDown(final MouseEvent inEvent) {
            provider.notifyPositionChange(textWidget.getCaretOffset());
          }
        });
    textWidget.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(final KeyEvent inEvent) {
            provider.notifyPositionChange(textWidget.getCaretOffset());
          }
        });
    provider = ContextInjectionFactory.make(TextStyleProvider.class, context);
    provider.setWidget(textWidget);

    // font handling
    if (fontSizeToUse != 0) {
      trackFontSize(fontSizeToUse);
    }

    disposed = false;
  }
  /* (non-Javadoc)
   * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(3, false));

    Group runtimeGrp = new Group(container, SWT.NONE);
    GridData runtimeGrpData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
    runtimeGrp.setLayout(new GridLayout(3, false));
    runtimeGrp.setLayoutData(runtimeGrpData);
    runtimeGrp.setText(Messages.newProjectWizardRuntimePageRuntimeGroupLabel);

    Label runtimeLabel = new Label(runtimeGrp, SWT.NONE);
    GridData runtimeLabelData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
    runtimeLabel.setLayoutData(runtimeLabelData);
    runtimeLabel.setText(Messages.newProjectWizardRuntimePageRuntimeLabel);

    runtimeComboViewer = new ComboViewer(runtimeGrp, SWT.NONE | SWT.READ_ONLY);
    runtimeComboViewer.setComparator(
        new ViewerComparator(
            new Comparator<String>() {

              @Override
              public int compare(String o1, String o2) {
                if (Messages.newProjectWizardRuntimePageNoRuntimeSelectedLabel.equals(o1)) {
                  return -1;
                }
                return o1.compareTo(o2);
              }
            }));

    GridData runtimeComboData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
    runtimeComboViewer.getCombo().setLayoutData(runtimeComboData);
    runtimeComboViewer
        .getCombo()
        .setToolTipText(Messages.newProjectWizardRuntimePageRuntimeDescription);
    runtimeComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    runtimeComboViewer
        .getCombo()
        .addModifyListener(
            new ModifyListener() {
              /*
               * (non-Javadoc)
               * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
               */
              @Override
              public void modifyText(ModifyEvent e) {
                lastSelectedRuntime = runtimeComboViewer.getSelection().toString();
                preselectCamelVersionForRuntime(determineRuntimeCamelVersion(getSelectedRuntime()));
                validate();
              }
            });

    try {
      configureRuntimeCombo();
    } catch (CoreException ex) {
      ProjectTemplatesActivator.pluginLog().logError(ex);
    }

    Button runtimeNewButton = new Button(runtimeGrp, SWT.NONE);
    GridData runtimeNewButtonData = new GridData(SWT.FILL, SWT.CENTER, false, false);
    runtimeNewButton.setLayoutData(runtimeNewButtonData);
    runtimeNewButton.setText(Messages.newProjectWizardRuntimePageRuntimeNewButtonLabel);
    runtimeNewButton.setToolTipText(
        Messages.newProjectWizardRuntimePageRuntimeNewButtonDescription);
    runtimeNewButton.addSelectionListener(
        new SelectionAdapter() {
          /*
           * (non-Javadoc)
           * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */

          @Override
          public void widgetSelected(SelectionEvent e) {
            String[] oldRuntimes = runtimeComboViewer.getCombo().getItems();
            boolean created = ServerUIUtil.showNewRuntimeWizard(getShell(), null, null);
            if (created) {
              String[] newRuntimes = runtimeComboViewer.getCombo().getItems();
              String newRuntime = getNewRuntime(oldRuntimes, newRuntimes);
              if (newRuntime != null) {
                runtimeComboViewer.setSelection(new StructuredSelection(newRuntime));
              }
            }
          }
        });

    new Label(runtimeGrp, SWT.None);

    Group camelGrp = new Group(container, SWT.NONE);
    GridData camelGrpData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 20);
    camelGrp.setLayout(new GridLayout(3, false));
    camelGrp.setLayoutData(camelGrpData);
    camelGrp.setText(Messages.newProjectWizardRuntimePageCamelGroupLabel);

    Label camelVersionLabel = new Label(camelGrp, SWT.NONE);
    GridData camelLabelData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
    camelVersionLabel.setLayoutData(camelLabelData);
    camelVersionLabel.setText(Messages.newProjectWizardRuntimePageCamelLabel);

    camelVersionCombo = new Combo(camelGrp, SWT.RIGHT | SWT.READ_ONLY);
    GridData camelComboData = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
    camelVersionCombo.setLayoutData(camelComboData);
    camelVersionCombo.setItems(getSupportedCamelVersions());
    camelVersionCombo.select(Math.max(camelVersionCombo.getItemCount() - 1, 0));
    camelVersionCombo.setToolTipText(Messages.newProjectWizardRuntimePageCamelDescription);
    camelVersionCombo.addSelectionListener(
        new SelectionAdapter() {
          /* (non-Javadoc)
           * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */
          @Override
          public void widgetSelected(SelectionEvent e) {
            validate();
          }
        });
    // TODO: leaving that out until we decide to support other camel versions than the ones we ship
    //		camelVersionCombo.addFocusListener(new FocusAdapter() {
    //			/* (non-Javadoc)
    //			 * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
    //			 */
    //			@Override
    //			public void focusLost(FocusEvent e) {
    //				super.focusLost(e);
    //				validate();
    //			}
    //
    //			/* (non-Javadoc)
    //			 * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent)
    //			 */
    //			@Override
    //			public void focusGained(FocusEvent e) {
    //				super.focusGained(e);
    //				setPageComplete(false);
    //			}
    //		});

    new Label(camelGrp, SWT.None);

    warningIconLabel = new Label(camelGrp, SWT.None);
    GridData camelLblData = new GridData(SWT.FILL, SWT.TOP, false, true, 1, 20);
    camelLblData.verticalIndent = 20;
    warningIconLabel.setImage(getSWTImage(SWT.ICON_WARNING));
    warningIconLabel.setLayoutData(camelLblData);
    warningIconLabel.setVisible(false);

    camelInfoText = new StyledText(camelGrp, SWT.WRAP | SWT.MULTI);
    GridData camelInfoData = new GridData(SWT.FILL, SWT.TOP, true, true, 2, 20);
    camelInfoData.verticalIndent = 0;
    camelInfoData.heightHint = 150;
    camelInfoText.setLayoutData(camelInfoData);
    camelInfoText.setEnabled(false);
    camelInfoText.setEditable(false);
    camelInfoText.setBackground(container.getBackground());

    new Label(camelGrp, SWT.None);

    setControl(container);

    IRuntimeLifecycleListener listener =
        new IRuntimeLifecycleListener() {

          @Override
          public void runtimeRemoved(IRuntime runtime) {
            runInUIThread();
          }

          @Override
          public void runtimeChanged(IRuntime runtime) {
            runInUIThread();
          }

          @Override
          public void runtimeAdded(IRuntime runtime) {
            runInUIThread();
          }

          private void runInUIThread() {
            Display.getDefault()
                .asyncExec(
                    new Runnable() {

                      @Override
                      public void run() {
                        try {
                          configureRuntimeCombo();
                        } catch (CoreException ex) {
                          ProjectTemplatesActivator.pluginLog()
                              .logError("Unable to handle runtime change event", ex); // $NON-NLS-1$
                        }
                      }
                    });
          }
        };
    ServerCore.addRuntimeLifecycleListener(listener);
    validate();
  }
Ejemplo n.º 26
0
 /**
  * Sets the layout data associated with the receiver to the argument.
  *
  * @param inLayoutData GridData the new layout data for the receiver.
  */
 public void setLayoutData(final GridData inLayoutData) {
   textWidget.setLayoutData(inLayoutData);
 }
Ejemplo n.º 27
0
  @Override
  protected void createContent(final Composite parent) {
    fContentComposite =
        new Composite(parent, SWT.NONE) {
          @Override
          public Point computeSize(final int width, final int height, final boolean changed) {
            return super.computeSize(width, height, changed || width != getSize().x);
          }
        };
    fContentComposite.setBackgroundMode(SWT.INHERIT_FORCE);

    final GridLayout gridLayout = LayoutUtil.applyCompositeDefaults(new GridLayout(), 2);
    gridLayout.horizontalSpacing = (int) ((gridLayout.horizontalSpacing) / 1.5);
    fContentComposite.setLayout(gridLayout);

    final int vIndent = Math.max(1, LayoutUtil.defaultVSpacing() / 4);
    final int hIndent = Math.max(2, LayoutUtil.defaultHSpacing() / 3);

    { // Title image
      fTitleImage = new Label(fContentComposite, SWT.NULL);
      final Image image = SharedUIResources.getImages().get(SharedUIResources.PLACEHOLDER_IMAGE_ID);
      fTitleImage.setImage(image);

      final GridData textGd = new GridData(SWT.FILL, SWT.TOP, false, false);
      fTitleText =
          new StyledText(fContentComposite, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP) {
            @Override
            public Point computeSize(int width, final int height, final boolean changed) {
              if (!fLayoutHint && width <= 0 && fContentComposite.getSize().x > 0) {
                width =
                    fContentComposite.getSize().x
                        - LayoutUtil.defaultHMargin()
                        - fTitleImage.getSize().x
                        - LayoutUtil.defaultHSpacing()
                        - 10;
              }

              final Point size = super.computeSize(width, -1, true);
              //					if (width >= 0) {
              //						size.x = Math.min(size.x, width);
              //					}
              return size;
            }
          };

      fTitleText.setFont(JFaceResources.getDialogFont());
      final GC gc = new GC(fTitleText);
      final FontMetrics fontMetrics = gc.getFontMetrics();
      final GridData imageGd = new GridData(SWT.FILL, SWT.TOP, false, false);
      imageGd.horizontalIndent = hIndent;
      final int textHeight = fontMetrics.getAscent() + fontMetrics.getLeading();
      final int imageHeight = image.getBounds().height;
      final int shift = Math.max(3, (int) ((fontMetrics.getDescent()) / 1.5));
      if (textHeight + shift < imageHeight) {
        imageGd.verticalIndent = vIndent + shift;
        textGd.verticalIndent = vIndent + (imageHeight - textHeight);
      } else {
        imageGd.verticalIndent = vIndent + (textHeight - imageHeight) + shift;
        textGd.verticalIndent = vIndent;
      }
      fTitleImage.setLayoutData(imageGd);
      fTitleText.setLayoutData(textGd);
      fLayoutWorkaround = true;

      gc.dispose();
    }

    fInfoText =
        new StyledText(
            fContentComposite,
            fMode == MODE_FOCUS
                ? (SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL)
                : (SWT.MULTI | SWT.READ_ONLY));
    fInfoText.setIndent(hIndent);
    fInfoText.setFont(JFaceResources.getFont(PREF_DETAIL_PANE_FONT));

    final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    //		gd.widthHint = LayoutUtil.hintWidth(fInfoText, INFO_FONT, 50);
    fInfoText.setLayoutData(gd);

    setBackgroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    setForegroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));

    updateInput();
  }
Ejemplo n.º 28
0
 private void createOutputText() {
   output = new StyledText(spyShell, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
   output.setLayoutData(
       new GridData(GridData.FILL_HORIZONTAL, GridData.FILL_VERTICAL, true, true));
   output.setFont(new Font(Display.getCurrent(), "Courier New", 10, SWT.NONE));
 }