Java Code Examples for org.eclipse.swt.widgets.TableColumn#getText()

The following examples show how to use org.eclipse.swt.widgets.TableColumn#getText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SWTTable.java    From tuxguitar with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void adjustColumnWidth(TableColumn column) {
	int minimumWidth = 0;
	
	String headerText = column.getText();
	if( headerText != null && headerText.length() > 0 ) {
		GC gc = new GC(this.getControl());
		minimumWidth = (gc.stringExtent(headerText).x + (TABLE_COLUMN_MARGIN * 2));
		gc.dispose();
	}
	
	column.pack();
	if( column.getWidth() < minimumWidth ) {
		column.setWidth(minimumWidth);
	}
	
}
 
Example 2
Source File: TableView.java    From hop with Apache License 2.0 5 votes vote down vote up
private String getSelectedText() {
  String selection = "";

  for ( int c = 1; c < table.getColumnCount(); c++ ) {
    TableColumn tc = table.getColumn( c );
    if ( c > 1 ) {
      selection += CLIPBOARD_DELIMITER;
    }
    selection += tc.getText();
  }
  selection += Const.CR;

  TableItem[] items = table.getSelection();
  if ( items.length == 0 ) {
    return null;
  }

  for ( int r = 0; r < items.length; r++ ) {
    TableItem ti = items[ r ];
    for ( int c = 1; c < table.getColumnCount(); c++ ) {
      ColumnInfo ci = columns[c-1];
      if ( c > 1 ) {
        selection += CLIPBOARD_DELIMITER;
      }
      String value = ti.getText(c);
      if ( StringUtils.isNotEmpty(value)) {
        Color textColor = ti.getForeground( c );
        if (!nullTextColor.equals(  textColor  ) || !"<null>".equals(value )) {
            selection += ti.getText( c );
        }
      }
    }
    selection += Const.CR;
  }
  return selection;
}
 
Example 3
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private IAction createShowColumnAction(final TableColumn column) {
    final IAction columnMenuAction = new Action(column.getText(), IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            boolean isChecked = isChecked();
            int index = (int) column.getData(Key.INDEX);
            if (isChecked) {
                int width = (int) column.getData(Key.WIDTH);
                column.setResizable(true);
                if (width <= 0) {
                    fPacking = true;
                    column.pack();
                    fPacking = false;
                    column.setData(Key.WIDTH, SWT.DEFAULT);
                    fColumnSize[index] = SWT.DEFAULT;
                } else {
                    column.setWidth(width);
                }
            } else {
                column.setResizable(false);
                column.setWidth(0);
            }
            fColumnResizable[index] = isChecked;
            fTable.refresh();
        }
    };
    columnMenuAction.setChecked(column.getResizable());
    return columnMenuAction;
}
 
Example 4
Source File: TableClipboard.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private static void copyHeaders(Table table, StringBuilder text) {
	int cols = table.getColumnCount();
	for (int col = 0; col < cols; col++) {
		TableColumn column = table.getColumn(col);
		String s = column.getText();
		text.append(s == null ? "" : s);
		if (col != (cols - 1))
			text.append('\t');
	}
	text.append('\n');
}
 
Example 5
Source File: TableView.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private String getSelectedText() {
  String selection = "";

  for ( int c = 1; c < table.getColumnCount(); c++ ) {
    TableColumn tc = table.getColumn( c );
    if ( c > 1 ) {
      selection += CLIPBOARD_DELIMITER;
    }
    selection += tc.getText();
  }
  selection += Const.CR;

  TableItem[] items = table.getSelection();
  if ( items.length == 0 ) {
    return null;
  }

  for ( int r = 0; r < items.length; r++ ) {
    TableItem ti = items[r];
    for ( int c = 1; c < table.getColumnCount(); c++ ) {
      if ( c > 1 ) {
        selection += CLIPBOARD_DELIMITER;
      }
      selection += ti.getText( c );
    }
    selection += Const.CR;
  }
  return selection;
}
 
Example 6
Source File: PopulationInspectView.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
/**
 *
 */
public void saveAsCSV() {
	try {
		Files.newFolder(getScope(), exportFolder);
	} catch (final GamaRuntimeException e1) {
		e1.addContext("Impossible to create folder " + exportFolder);
		GAMA.reportError(getScope(), e1, false);
		e1.printStackTrace();
		return;
	}

	final String exportFileName = FileUtils.constructAbsoluteFilePath(getScope(),
			exportFolder + "/" + getSpeciesName() + "_population" + getScope().getClock().getCycle() + ".csv",
			false);
	final Table table = viewer.getTable();
	final TableColumn[] columns = table.getColumns();
	try (final CsvWriter writer = new CsvWriter(exportFileName);) {
		// AD 2/1/16 Replaces the comma by ';' to properly output points and
		// lists
		writer.setDelimiter(';');
		writer.setUseTextQualifier(false);

		final List<String[]> contents = new ArrayList<>();
		final String[] headers = new String[columns.length];
		int columnIndex = 0;
		for (final TableColumn column : columns) {
			headers[columnIndex++] = column.getText();
		}
		contents.add(headers);
		final TableItem[] items = table.getItems();
		for (final TableItem item : items) {
			final String[] row = new String[columns.length];
			for (int i = 0; i < columns.length; i++) {
				row[i] = item.getText(i);
			}
			contents.add(row);
		}
		try {
			for (final String[] ss : contents) {
				writer.writeRecord(ss);
			}

		} catch (final IOException e) {
			throw GamaRuntimeException.create(e, getScope());

		}
	}
}