@Override
  public void saveState(String prefix, Properties properties) {
    PositionCoordinate coord = freezeLayer.getTopLeftPosition();
    properties.setProperty(
        prefix + FreezeLayer.PERSISTENCE_TOP_LEFT_POSITION,
        coord.columnPosition + IPersistable.VALUE_SEPARATOR + coord.rowPosition);

    coord = freezeLayer.getBottomRightPosition();
    properties.setProperty(
        prefix + FreezeLayer.PERSISTENCE_BOTTOM_RIGHT_POSITION,
        coord.columnPosition + IPersistable.VALUE_SEPARATOR + coord.rowPosition);

    super.saveState(prefix, properties);
  }
  public Control createExampleControl(Composite parent) {
    // Setup the layer stack
    final MyDataProvider myDataProvider = new MyDataProvider();
    SelectionLayer selectionLayer = new SelectionLayer(new DataLayer(myDataProvider));
    ILayer columnHeaderLayer =
        new ColumnHeaderLayer(
            new DataLayer(new DummyColumnHeaderDataProvider(myDataProvider)),
            selectionLayer,
            selectionLayer);

    CompositeLayer compositeLayer = new CompositeLayer(1, 2);
    compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER, columnHeaderLayer, 0, 0);
    compositeLayer.setChildLayer(GridRegion.BODY, selectionLayer, 0, 1);

    NatTable natTable = new NatTable(parent, compositeLayer, false);

    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());

    // Add our custom painting configuration
    natTable.addConfiguration(new CustomPaintingConfig());

    natTable.configure();
    return natTable;
  }
  @Override
  public void loadState(String prefix, Properties properties) {
    String property = properties.getProperty(prefix + FreezeLayer.PERSISTENCE_TOP_LEFT_POSITION);
    PositionCoordinate topLeftPosition = null;
    if (property != null) {
      StringTokenizer tok = new StringTokenizer(property, IPersistable.VALUE_SEPARATOR);
      String columnPosition = tok.nextToken();
      String rowPosition = tok.nextToken();
      topLeftPosition =
          new PositionCoordinate(
              this.freezeLayer, Integer.valueOf(columnPosition), Integer.valueOf(rowPosition));
    }

    property = properties.getProperty(prefix + FreezeLayer.PERSISTENCE_BOTTOM_RIGHT_POSITION);
    PositionCoordinate bottomRightPosition = null;
    if (property != null) {
      StringTokenizer tok = new StringTokenizer(property, IPersistable.VALUE_SEPARATOR);
      String columnPosition = tok.nextToken();
      String rowPosition = tok.nextToken();
      bottomRightPosition =
          new PositionCoordinate(
              this.freezeLayer, Integer.valueOf(columnPosition), Integer.valueOf(rowPosition));
    }

    // only restore a freeze state if there is one persisted
    if (topLeftPosition != null && bottomRightPosition != null) {
      if (topLeftPosition.columnPosition == -1
          && topLeftPosition.rowPosition == -1
          && bottomRightPosition.columnPosition == -1
          && bottomRightPosition.rowPosition == -1) {
        FreezeHelper.unfreeze(this.freezeLayer, this.viewportLayer);
      } else {
        FreezeHelper.freeze(
            this.freezeLayer, this.viewportLayer, topLeftPosition, bottomRightPosition);
      }
    }

    super.loadState(prefix, properties);
  }
Пример #4
0
  public void createPartControl(Composite parent) {
    final Font monospaceFont =
        new Font(parent.getDisplay(), new FontData("Monospace", 12, SWT.NONE));
    final Color greenColor = parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GREEN);
    final Color redColor = parent.getDisplay().getSystemColor(SWT.COLOR_DARK_RED);
    final Color blackColor = parent.getDisplay().getSystemColor(SWT.COLOR_BLACK);
    final Color greyColor = parent.getDisplay().getSystemColor(SWT.COLOR_GRAY);

    FillLayout fillLayout = (FillLayout) parent.getLayout();
    fillLayout.type = SWT.VERTICAL;

    Composite terminalComposite = new Composite(parent, SWT.NONE);
    terminalComposite.setLayout(new FormLayout());
    terminalComposite.setBackground(blackColor);

    TabFolder terminalPane = new TabFolder(terminalComposite, SWT.BOTTOM);
    terminalPane.setBackground(blackColor);
    FormData terminalLayoutData = new FormData();
    terminalLayoutData.top = new FormAttachment(0);
    terminalLayoutData.left = new FormAttachment(0);
    terminalLayoutData.right = new FormAttachment(100);
    terminalPane.setLayoutData(terminalLayoutData);

    TabItem outTabItem = new TabItem(terminalPane, SWT.NONE);
    outTabItem.setText("out");
    //    terminalDataLayer = new DataLayer(currentlySelectedExecutionRecordDataProvider);

    SelectionLayer selectionLayer = new SelectionLayer(terminalDataLayer);
    ViewportLayer viewPortLayer = new ViewportLayer(selectionLayer);
    viewPortLayer.setRegionName(GridRegion.BODY);
    ColumnHeaderLayer columnHeaderLayer =
        new ColumnHeaderLayer(new DataLayer(columnDataProvider), viewPortLayer, selectionLayer);
    CompositeLayer compositeLayer = new CompositeLayer(1, 2);
    compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER, columnHeaderLayer, 0, 0);
    compositeLayer.setChildLayer(GridRegion.BODY, viewPortLayer, 0, 1);
    compositeLayer.setConfigLabelAccumulatorForRegion(GridRegion.BODY, configLabelAccumulator);
    terminalGrid = new NatTable(terminalPane, compositeLayer);
    terminalGrid.setTheme(new EarlGridTheme());
    terminalGrid.setBackground(blackColor);
    outTabItem.setControl(terminalGrid);

    TabItem errTabItem = new TabItem(terminalPane, SWT.NONE);
    errTabItem.setText("err");
    tabularErrorTable = new Table(terminalPane, SWT.VIRTUAL | SWT.HIDE_SELECTION);
    tabularErrorTable.setHeaderVisible(false);
    tabularErrorTable.setLinesVisible(true);
    //    tabularErrorTable.addListener(SWT.SetData, tabularErrorDataHandler);
    tabularErrorTable.setFont(monospaceFont);
    tabularErrorTable.setBackground(redColor);
    tabularErrorTable.setForeground(greyColor);
    errTabItem.setControl(tabularErrorTable);

    TabItem logTabItem = new TabItem(terminalPane, SWT.NONE);
    logTabItem.setText("log");
    tabularLogTable = new Table(terminalPane, SWT.VIRTUAL | SWT.HIDE_SELECTION);
    tabularLogTable.setHeaderVisible(false);
    tabularLogTable.setLinesVisible(true);
    //    tabularLogTable.addListener(SWT.SetData, tabularErrorDataHandler);
    tabularLogTable.setFont(monospaceFont);
    tabularLogTable.setBackground(greenColor);
    tabularLogTable.setForeground(greyColor);
    logTabItem.setControl(tabularLogTable);

    terminalPane.setSelection(0);

    commandLineTxt = new Text(terminalComposite, SWT.BORDER);
    FormData commandLineTxtLayoutData = new FormData();
    commandLineTxtLayoutData.left = new FormAttachment(terminalPane, 0, SWT.LEFT);
    commandLineTxtLayoutData.right = new FormAttachment(terminalPane, 0, SWT.RIGHT);
    commandLineTxtLayoutData.bottom = new FormAttachment(100);
    commandLineTxt.setLayoutData(commandLineTxtLayoutData);
    commandLineTxt.addFocusListener(commandLineFocusListener);
    commandLineTxt.addKeyListener(commandLineKeyListener);
    commandLineTxt.setFont(monospaceFont);
    commandLineTxt.setBackground(blackColor);
    commandLineTxt.setForeground(greyColor);
    commandLineTxt.addTraverseListener(preventTraversal);
    terminalLayoutData.bottom = new FormAttachment(commandLineTxt);

    monospaceFont.dispose();
  }