private void changeCurrentlyDisplayedExecutionRecord(ExecutionHistoryRecord newExecutionRecord) { if (newExecutionRecord.out.rows.isEmpty()) { // We do not want to erase the old content, but we want to give feedback that the command was // executed. return; } boolean needRefresh = currentlySelectedExecutionRecord == null; currentlySelectedExecutionRecord = newExecutionRecord; if (!needRefresh) { int percentage = 100 / (terminalDataLayer.getColumnCount() + 1); terminalDataLayer.setColumnWidthPercentageByPosition(0, percentage * 2); for (int i = 1; i < terminalDataLayer.getColumnCount(); i++) { terminalDataLayer.setColumnWidthPercentageByPosition(i, percentage); } } terminalGrid .refresh(); // FIXME: This somewhat works to display the columns the first time a command is // run. Especially if the output contains few rows and does not require a scroll // bar int selectedTab = 0; tabularErrorTable.clearAll(); int numberOfErrLines = 0; // if(currentlySelectedExecutionRecord.err!=null){ // numberOfErrLines=currentlySelectedExecutionRecord.err.rows.size(); // if(numberOfErrLines>0){ // selectedTab=1; // } // } TabFolder tabPane = (TabFolder) terminalGrid.getParent(); tabPane.getItem(1).setText("err " + numberOfErrLines + " lines"); tabularErrorTable.setItemCount(numberOfErrLines); tabularLogTable.clearAll(); int numberOfLogLines = 0; // if(currentlySelectedExecutionRecord.log!=null){ // numberOfLogLines=currentlySelectedExecutionRecord.log.rows.size(); // } tabPane.getItem(2).setText("log-" + numberOfLogLines); tabularLogTable.setItemCount(numberOfLogLines); tabPane.setSelection(selectedTab); commandLineTxt.setFocus(); }
/* (non-Javadoc) * @see org.eclipse.nebula.widgets.nattable.examples.INatExample#createExampleControl(org.eclipse.swt.widgets.Composite) */ public Control createExampleControl(Composite parent) { Composite panel = new Composite(parent, SWT.NONE); GridData layoutData = GridDataFactory.fillDefaults().grab(true, true).create(); GridLayout layout = new GridLayout(); layout.numColumns = 1; layout.marginWidth = 0; layout.marginHeight = 0; panel.setLayout(layout); panel.setLayoutData(layoutData); loadMessages(); ListDataProvider<LogRecord> dataProvider = new ListDataProvider<LogRecord>( logMessages, new ReflectiveColumnPropertyAccessor<LogRecord>( new String[] {"message"})); // $NON-NLS-1$ DataLayer dataLayer = new DataLayer(dataProvider); dataLayer.setColumnPercentageSizing(true); dataLayer.setColumnWidthPercentageByPosition(0, 100); dataLayer.setConfigLabelAccumulator(new ValidatorMessageLabelAccumulator()); ViewportLayer layer = new ViewportLayer(dataLayer); layer.setRegionName(GridRegion.BODY); NatTable natTable = new NatTable(panel, NatTable.DEFAULT_STYLE_OPTIONS | SWT.BORDER, layer, false); natTable.addConfiguration(new ValidationMessageTableStyleConfiguration()); natTable.configure(); GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable); return panel; }