use of org.eclipse.swt.widgets.Table in project ACS by ACS-Community.
the class TableViewBase method createPartControl.
@Override
public void createPartControl(Composite parent) {
tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
Table table = tableViewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
// Set the column
for (int t = 0; t < colNames.length; t++) {
int style = t == 0 ? SWT.LEFT : SWT.CENTER;
final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, style);
final TableColumn column = viewerColumn.getColumn();
column.setText(colNames[t]);
final int index = t;
// Setting the right sorter
column.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sorter.setColumn(index);
int dir = tableViewer.getTable().getSortDirection();
if (tableViewer.getTable().getSortColumn() == column) {
dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
} else {
dir = SWT.DOWN;
}
tableViewer.getTable().setSortDirection(dir);
tableViewer.getTable().setSortColumn(column);
tableViewer.refresh();
}
});
column.pack();
column.setWidth(colWidths[t]);
}
tableViewer.setContentProvider(new ViewContentProvider());
}
use of org.eclipse.swt.widgets.Table in project cubrid-manager by CUBRID.
the class PstmtSQLDialog method createEmptyTable.
/**
* Create the empty parameter table
*
* @param parent Composite
* @param isMulti boolean
*/
protected void createEmptyTable(Composite parent) {
Group typeGroup = new Group(parent, SWT.SHADOW_ETCHED_IN);
GridData groupGd = new GridData(GridData.FILL_HORIZONTAL);
groupGd.heightHint = 70;
typeGroup.setLayoutData(groupGd);
typeGroup.setLayout(new GridLayout());
typeGroup.setText(Messages.colParaType);
parameterTypeTable = new Table(typeGroup, SWT.BORDER | SWT.H_SCROLL);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 45;
parameterTypeTable.setLayoutData(gd);
parameterTypeTable.setHeaderVisible(true);
parameterTypeTable.setLinesVisible(false);
parameterTypeTable.setDragDetect(false);
TableColumn columnNO = new TableColumn(parameterTypeTable, SWT.CENTER);
columnNO.setWidth(40);
columnNO.setText("");
tableEditor = new TableEditor(parameterTypeTable);
tableEditor.horizontalAlignment = SWT.LEFT;
tableEditor.grabHorizontal = true;
parameterTypeTable.addListener(SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
if (event.button != 1) {
return;
}
if (isChanging) {
return;
}
Point pt = new Point(event.x, event.y);
final TableItem item = parameterTypeTable.getItem(0);
for (int i = 1; i < parameterTypeTable.getColumnCount(); i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
handleType(item, i);
}
}
}
});
Group parameterGroup = new Group(parent, SWT.SHADOW_IN);
parameterGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
parameterGroup.setLayout(new GridLayout(2, false));
parameterGroup.setText(Messages.colParaValue);
ToolBar toolBar = new ToolBar(parameterGroup, SWT.FLAT);
ToolItem addRecordItem = new ToolItem(toolBar, SWT.PUSH);
addRecordItem.setImage(CommonUIPlugin.getImage("icons/action/table_record_insert.png"));
addRecordItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
addData();
}
});
ToolItem delRecordItem = new ToolItem(toolBar, SWT.PUSH);
delRecordItem.setImage(CommonUIPlugin.getImage("icons/action/table_record_delete.png"));
delRecordItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (parameterTable.getTable().getSelectionIndices().length == 0) {
setErrorMessage(Messages.errDeleteMsg);
return;
}
List<Integer> deleteIndex = new ArrayList<Integer>();
for (int i = 0; i < parameterTable.getTable().getSelectionIndices().length; i++) {
deleteIndex.add(parameterTable.getTable().getSelectionIndices()[i]);
}
int lastSelectedIndex = 0;
for (int i = 0; i < deleteIndex.size(); i++) {
int seletectIndex = deleteIndex.get(i);
int newIndex = seletectIndex - i;
valueList.remove(newIndex);
lastSelectedIndex = newIndex;
}
//reset the index in data
for (int i = 0; i < valueList.size(); i++) {
ParamValueObject paramValueObject = valueList.get(i);
paramValueObject.getValue().set(0, String.valueOf(i + 1));
}
parameterTable.setInput(valueList);
parameterTable.refresh();
if (parameterTable.getTable().getItemCount() > 0) {
parameterTable.getTable().setSelection(lastSelectedIndex < 1 ? 0 : lastSelectedIndex - 1);
parameterTable.getTable().setFocus();
}
validate();
}
});
parameterTable = new TableViewer(parameterGroup, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
// press the tab key, it is moved next input area
TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(parameterTable, new FocusCellOwnerDrawHighlighter(parameterTable));
ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(parameterTable) {
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL || (event.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION && ((MouseEvent) event.sourceEvent).button == 1) || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR);
// || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
};
TableViewerEditor.create(parameterTable, focusCellManager, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
// new Table(parameterGroup, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
parameterTable.getTable().setLayoutData(gridData);
parameterTable.getTable().setHeaderVisible(true);
parameterTable.getTable().setLinesVisible(true);
parameterTable.setUseHashlookup(true);
final TableViewerColumn columnNO2 = new TableViewerColumn(parameterTable, SWT.CENTER);
columnNO2.getColumn().setWidth(40);
columnNO2.getColumn().setText("");
parameterTable.setContentProvider(new ParamValueContentProvider());
parameterTable.setLabelProvider(new ParamValueLabelProvider(parameterTable.getTable()));
parameterTable.getTable().addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'c') {
final Clipboard cb = new Clipboard(getShell().getDisplay());
StringBuffer clipboardDataString = new StringBuffer();
List<Integer> replaceIndex = new ArrayList<Integer>();
for (int i = 0; i < parameterTable.getTable().getSelectionIndices().length; i++) {
replaceIndex.add(parameterTable.getTable().getSelectionIndices()[i]);
}
for (int i = 0; i < replaceIndex.size(); i++) {
if (i != 0) {
clipboardDataString.append(EXCELDATASEPRATOR);
}
ParamValueObject paramValueObject = valueList.get(replaceIndex.get(i));
for (int j = 1; j < parameterTypeTable.getColumnCount(); j++) {
if (j != 1) {
clipboardDataString.append(EXCELCOLUMNSEPRATOR);
}
String value = paramValueObject.getValue().get(j);
clipboardDataString.append(value);
}
}
TextTransfer textTransfer = TextTransfer.getInstance();
Transfer[] transfers = new Transfer[] { textTransfer };
Object[] data = new Object[] { clipboardDataString.toString() };
cb.setContents(data, transfers);
cb.dispose();
} else if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'v') {
final Clipboard cb = new Clipboard(getShell().getDisplay());
// boolean supportFlag = false;
// TransferData[] transferDatas = cb.getAvailableTypes();
// for(int i=0; i<transferDatas.length; i++) {
// // Checks whether RTF format is available.
// if(RTFTransfer.getInstance().isSupportedType(transferDatas[i])) {
// supportFlag = true;
// break;
// }
// }
// if (!supportFlag) {
// setErrorMessage(Messages.pstmtSQLUnsupportPasteType);
// return;
// }
String plainText = (String) cb.getContents(TextTransfer.getInstance());
List<ParamValueObject> list = generateParamValueObjectListFromClipboardString(plainText);
if (list.size() == 0 || list.get(0).getValue().size() != parameterTypeTable.getColumnCount()) {
setErrorMessage(Messages.pstmtSQLUnsupportPasteType);
return;
}
// String rtfText = (String)cb.getContents(RTFTransfer.getInstance());
int startIndex = parameterTable.getTable().getSelectionIndex();
//if the copy line bigger than the value list, add new ParamValueObject to the end
if (parameterTable.getTable().getSelectionCount() <= 1) {
if (startIndex < 0 || startIndex > valueList.size()) {
for (ParamValueObject copyParamValueObject : list) {
valueList.add(copyParamValueObject);
}
} else {
for (ParamValueObject copyParamValueObject : list) {
if (startIndex > valueList.size() - 1) {
valueList.add(copyParamValueObject);
} else {
ParamValueObject paramValueObject = valueList.get(startIndex);
List<String> oldValue = paramValueObject.getValue();
for (int i = 1; i < oldValue.size(); i++) {
List<String> newValue = copyParamValueObject.getValue();
if (i > newValue.size() - 1) {
break;
}
oldValue.set(i, newValue.get(i));
}
}
startIndex++;
}
}
} else {
// replay the select line
List<Integer> replaceIndex = new ArrayList<Integer>();
for (int i = 0; i < parameterTable.getTable().getSelectionIndices().length; i++) {
replaceIndex.add(parameterTable.getTable().getSelectionIndices()[i]);
}
for (int i = 0; i < replaceIndex.size(); i++) {
ParamValueObject paramValueObject = valueList.get(replaceIndex.get(i));
List<String> oldValue = paramValueObject.getValue();
if (i > list.size()) {
break;
}
List<String> newValue = list.get(i).getValue();
for (int j = 1; j < oldValue.size(); j++) {
if (j > newValue.size()) {
break;
}
oldValue.set(j, newValue.get(j));
}
}
}
cb.dispose();
refreshValueListIndex();
parameterTable.refresh();
validate();
}
}
});
// use to mark click point, the right click menu use this point
parameterTable.getTable().addListener(SWT.MouseDown, new Listener() {
public void handleEvent(Event event) {
clickPoint = new Point(event.x, event.y);
}
});
registerContextMenu();
parameterTable.setInput(valueList);
}
use of org.eclipse.swt.widgets.Table in project cubrid-manager by CUBRID.
the class SetPhysicalLogicaMapDialog method createTableComposite.
private void createTableComposite(Composite composite, Group group, PhysicalLogicRelation.MapType type) {
group.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.numColumns = 1;
group.setLayout(layout);
ScrolledComposite scrolledComposite = new ScrolledComposite(group, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
final TableViewer tableViewer = new TableViewer(scrolledComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
columnDataTableView = tableViewer;
tableViewer.setColumnProperties(columnProperites);
final Table widgetTable = tableViewer.getTable();
scrolledComposite.setContent(widgetTable);
scrolledComposite.setMinSize(widgetTable.computeSize(SWT.DEFAULT, SWT.DEFAULT));
final GridData gdFkTable = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
widgetTable.setLayoutData(gdFkTable);
widgetTable.setLinesVisible(true);
widgetTable.setHeaderVisible(true);
//empty column
final TableColumn emptyColumn = new TableColumn(widgetTable, SWT.NONE);
emptyColumn.setWidth(0);
//flag column
final TableColumn flagColumn = new TableColumn(widgetTable, SWT.LEFT_TO_RIGHT);
flagColumn.setWidth(20);
//physical column
TableColumn tblCol = new TableColumn(widgetTable, SWT.NONE);
tblCol.setWidth(120);
tblCol.setText(Messages.tblcolumnPhysical);
//logical column
tblCol = new TableColumn(widgetTable, SWT.NONE);
tblCol.setWidth(120);
tblCol.setText(Messages.tblcolumnLogical);
attrContentProvider = new AttributeContentProvider();
attrLabelProvider = new RelationMapColumnLabelProvider(this);
tableViewer.setContentProvider(attrContentProvider);
tableViewer.setLabelProvider(attrLabelProvider);
CellEditor[] cellEditor = new CellEditor[columnProperites.length];
{
int index = 0;
//Empty
cellEditor[index++] = null;
//Flag
cellEditor[index++] = null;
//Physical
cellEditor[index++] = new TextCellEditor(widgetTable);
//Logical
cellEditor[index++] = new TextCellEditor(widgetTable);
}
tableViewer.setCellEditors(cellEditor);
tableViewer.setCellModifier(new ModelRelationCellModifier(this, type));
loadTableInput(type);
final Button delBtn = new Button(group, SWT.PUSH);
delBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
delBtn.setText(Messages.btnDelItem);
delBtn.setData(type);
delBtn.setEnabled(false);
delBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
deleteColumn(delBtn);
}
});
widgetTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
handleSelectionChangeInTable(widgetTable, delBtn);
}
});
}
use of org.eclipse.swt.widgets.Table in project cubrid-manager by CUBRID.
the class ObjectInfoComposite method initDataTabItem.
/**
* Initial demo data table setting
*
*/
private void initDataTabItem() {
CTabItem dataTabItem = new CTabItem(objInfoFolder, SWT.NONE);
dataTabItem.setText(Messages.titleData);
dataTabItem.setShowClose(false);
Composite composite = new Composite(objInfoFolder, SWT.None);
dataTabItem.setControl(composite);
objInfoFolder.setSelection(dataTabItem);
composite.setLayout(new FillLayout());
demoDataTable = new Table(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
demoDataTable.setHeaderVisible(true);
demoDataTable.setLinesVisible(true);
CommonUITool.hackForYosemite(demoDataTable);
}
use of org.eclipse.swt.widgets.Table in project cubrid-manager by CUBRID.
the class ObjectInfoComposite method initTableColumn.
/**
* Initial Table column setting
*
* @param composite
*/
private void initTableColumn(Composite composite) {
tableColTableViewer = new TableViewer(composite, SWT.FULL_SELECTION | SWT.BORDER);
Table columnsTable = tableColTableViewer.getTable();
columnsTable.setLinesVisible(true);
columnsTable.setHeaderVisible(true);
// PK
final TableColumn pkColumn = new TableColumn(columnsTable, SWT.NONE);
pkColumn.setAlignment(SWT.CENTER);
pkColumn.setWidth(30);
pkColumn.setText(Messages.tblColumnPK);
// NAME
final TableColumn nameColumn = new TableColumn(columnsTable, SWT.NONE);
nameColumn.setWidth(90);
nameColumn.setText(Messages.tblColumnName);
// DATATYPE
final TableColumn dataTypeColumn = new TableColumn(columnsTable, SWT.NONE);
dataTypeColumn.setWidth(120);
dataTypeColumn.setText(Messages.tblColumnDataType);
// DEFAULT
final TableColumn defaultColumn = new TableColumn(columnsTable, SWT.NONE);
defaultColumn.setWidth(98);
defaultColumn.setText(Messages.tblColumnDefault);
// AUTO INCREMENT
final TableColumn autoIncrTableColumn = new TableColumn(columnsTable, SWT.NONE);
autoIncrTableColumn.setAlignment(SWT.CENTER);
autoIncrTableColumn.setWidth(100);
autoIncrTableColumn.setText(Messages.tblColumnAutoIncr);
// NOT NULL
final TableColumn notNullColumn = new TableColumn(columnsTable, SWT.NONE);
notNullColumn.setWidth(70);
notNullColumn.setText(Messages.tblColumnNotNull);
notNullColumn.setAlignment(SWT.CENTER);
// UK
final TableColumn uniqueColumn = new TableColumn(columnsTable, SWT.NONE);
uniqueColumn.setWidth(70);
uniqueColumn.setText(Messages.tblColumnUnique);
uniqueColumn.setAlignment(SWT.CENTER);
// SHARED
final TableColumn sharedColumn = new TableColumn(columnsTable, SWT.NONE);
sharedColumn.setWidth(60);
sharedColumn.setResizable(false);
sharedColumn.setText(Messages.tblColumnShared);
sharedColumn.setAlignment(SWT.CENTER);
// INHERIT
final TableColumn inheritColumn = new TableColumn(columnsTable, SWT.NONE);
inheritColumn.setAlignment(SWT.CENTER);
inheritColumn.setWidth(90);
inheritColumn.setResizable(false);
inheritColumn.setText(Messages.tblColumnInherit);
// CLASS
final TableColumn classColumn = new TableColumn(columnsTable, SWT.NONE);
classColumn.setWidth(90);
classColumn.setResizable(false);
classColumn.setText(Messages.tblColumnClass);
classColumn.setAlignment(SWT.CENTER);
}
Aggregations