Esempio n. 1
0
 /**
  * ************************************************************************* Copy selected source
  * rows ************************************************************************
  */
 public void copySelected() {
   GridItem[] selection = getGrid().getSelection();
   Clipboard clipboard = new Clipboard(Display.getCurrent());
   String data = "";
   for (GridItem item : selection) {
     if (!data.isEmpty()) data += "\n";
     String line = item.getText(CodeViewerColumn.CODE.ordinal());
     if (line != null) {
       line = line.trim();
     } else {
       line = "";
     }
     data += line;
   }
   clipboard.setContents(new Object[] {data}, new Transfer[] {TextTransfer.getInstance()});
   clipboard.dispose();
 }
Esempio n. 2
0
 public void resetColumnWidths() {
   int totalWidth = 0;
   for (CodeViewerColumn colModel : CodeViewerColumn.values()) {
     if (colModel.equals(CodeViewerColumn.CODE)) continue;
     GridColumn column = getGrid().getColumn(colModel.ordinal());
     int width = colModel.getInitialWidth();
     totalWidth += width;
     column.setWidth(width);
   }
   int gridWidth = getGrid().getBounds().width;
   if (getGrid().getVerticalBar().isVisible()) {
     gridWidth -= getGrid().getVerticalBar().getSize().x;
   }
   if (totalWidth < gridWidth) {
     int widthForCode = gridWidth - totalWidth - 4;
     getGrid().getColumn(CodeViewerColumn.CODE.ordinal()).setWidth(widthForCode);
   }
 }
Esempio n. 3
0
  /**
   * ************************************************************************* Constructor.
   *
   * @param procId The procedure identifier
   * @param parent The parent composite
   *     ************************************************************************
   */
  public CodeViewer(Composite parent, IProcedure model) {
    super(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);

    if (s_cfg == null) {
      s_cfg = (IConfigurationManager) ServiceManager.get(IConfigurationManager.class);
    }

    m_procedure = model;

    m_autoScroll = true;
    getGrid().setHeaderVisible(true);
    getGrid().setLinesVisible(false);

    createColumns();

    final CodeViewer theViewer = this;
    getGrid()
        .addKeyListener(
            new KeyAdapter() {
              public void keyPressed(KeyEvent e) {
                if ((e.stateMask & SWT.CONTROL) > 0) {
                  if (e.keyCode == 99) // C
                  {
                    copySelected();
                    getGrid().deselectAll();
                  } else if (e.keyCode == 102) // F
                  {
                    getGrid().deselectAll();
                    SearchDialog dialog = new SearchDialog(getGrid().getShell(), theViewer);
                    dialog.open();
                  }
                }
              }
            });

    getGrid()
        .getColumn(CodeViewerColumn.BREAKPOINT.ordinal())
        .addControlListener(new ColumnSizer(getGrid(), CodeViewerColumn.RESULT));
    getGrid()
        .getColumn(CodeViewerColumn.LINE_NO.ordinal())
        .addControlListener(new ColumnSizer(getGrid(), CodeViewerColumn.RESULT));
    getGrid()
        .getColumn(CodeViewerColumn.CODE.ordinal())
        .addControlListener(new ColumnSizer(getGrid(), CodeViewerColumn.RESULT));
    getGrid()
        .getColumn(CodeViewerColumn.DATA.ordinal())
        .addControlListener(new ColumnSizer(getGrid(), CodeViewerColumn.RESULT));
    getGrid().addControlListener(new ColumnSizer(getGrid(), CodeViewerColumn.CODE));

    /*
     * Popup menu manager
     */
    new CodeViewerMenuManager(this, m_procedure);

    m_search = new CodeSearch(this);

    s_cfg.addPropertyChangeListener(this);

    getGrid()
        .addDisposeListener(
            new DisposeListener() {
              @Override
              public void widgetDisposed(DisposeEvent e) {
                dispose();
              }
            });
  }