use of org.eclipse.swt.events.KeyAdapter in project cubrid-manager by CUBRID.
the class MultiDBQueryComposite method initialize.
/**
* Create the SQL history composite
*/
public void initialize() {
Composite toolBarComposite = new Composite(this, SWT.NONE);
GridLayout gridLayout = new GridLayout(2, false);
gridLayout.verticalSpacing = 0;
gridLayout.horizontalSpacing = 10;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
toolBarComposite.setLayout(gridLayout);
toolBarComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
ToolBar toolBar = new ToolBar(toolBarComposite, SWT.FLAT | SWT.RIGHT);
toolBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
ToolItem refreshToolItem = new ToolItem(toolBar, SWT.PUSH);
refreshToolItem.setText(Messages.lblItemRefreshMulti);
refreshToolItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_refresh.png"));
refreshToolItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_refresh.png"));
refreshToolItem.setToolTipText(Messages.refresh);
refreshToolItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
//refresh may set tree to group type or not
//so mark the select db then set it to checked after set input
// Object[] checkedObject = ctv.getCheckedElements();
setInput();
// for (Object o : checkedObject) {
// if (o instanceof CubridDatabase) {
// ctv.setChecked(o, true);
// }
// }
// refresh(editor.getSelectedDatabase());
}
});
runItem = new ToolItem(toolBar, SWT.PUSH);
runItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_run.png"));
runItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_run_disabled.png"));
runItem.setText(Messages.lblItemRunMulti);
runItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
editor.runMultiQuery();
}
});
Label lblNotice = new Label(toolBarComposite, SWT.None);
lblNotice.setText(Messages.qedit_multiDBQueryComp_noticeToolbarMsg);
lblNotice.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, true, false));
// create the query result tab folder
multiDBQueryCompTabFolder = new CTabFolder(this, SWT.BOTTOM);
multiDBQueryCompTabFolder.setSimple(false);
multiDBQueryCompTabFolder.setUnselectedImageVisible(true);
multiDBQueryCompTabFolder.setUnselectedCloseVisible(true);
multiDBQueryCompTabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
multiDBQueryCompTabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
multiDBQueryCompTabFolder.setLayout(new GridLayout(1, true));
multiDBQueryCompTabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
//TabContextMenuManager tabContextMenuManager = new TabContextMenuManager(multiDBQueryCompTabFolder);
//tabContextMenuManager.createContextMenu();
multiDBQueryCompTabItem = new CTabItem(resultTabFolder, SWT.NONE);
multiDBQueryCompTabItem.setText(Messages.qedit_multiDBQueryComp_folder);
multiDBQueryCompTabItem.setControl(this);
multiDBQueryCompTabItem.setShowClose(false);
SashForm bottomSash = new SashForm(multiDBQueryCompTabFolder, SWT.VERTICAL);
bottomSash.SASH_WIDTH = SASH_WIDTH;
bottomSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
SashForm tailSash = new SashForm(bottomSash, SWT.HORIZONTAL);
tailSash.SASH_WIDTH = SASH_WIDTH;
tailSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
Composite treeComp = new Composite(tailSash, SWT.NONE);
{
treeComp.setLayoutData(new GridData(GridData.FILL_BOTH));
treeComp.setLayout(new GridLayout());
}
ctv = new ContainerCheckedTreeViewer(treeComp, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
ctv.getControl().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
ctv.setContentProvider(new MultiDBQueryTreeContentProvider());
ctv.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
if (lastSelectedTime != 0 && lastSelectedTime > System.currentTimeMillis()) {
ctv.setChecked(event.getElement(), true);
return;
}
ctv.setChecked(event.getElement(), false);
lastSelectedTime = System.currentTimeMillis() + 100;
if (getQueryDatabaseList().size() > 0 && editor.getAllQueries().trim().length() != 0) {
editor.setMultiQueryRunItemStatus(true);
} else if (getQueryDatabaseList().size() == 0) {
editor.setMultiQueryRunItemStatus(false);
}
//if (!event.getChecked()) {
selectedNodes.remove(event.getElement());
if (event.getElement() instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) event.getElement();
if (database.getRunningType() == DbRunningType.STANDALONE || !database.isLogined()) {
//ctv.setChecked(event.getElement(), false);
selectedNodes.remove(database);
} else {
if (database.getData(INDEXKEY) == null) {
database.setData(INDEXKEY, String.valueOf(databaseIndex++));
}
}
} else if (event.getElement() instanceof CubridServer) {
CubridServer serverNode = (CubridServer) event.getElement();
for (ICubridNode dbFolderNode : serverNode.getChildren()) {
for (ICubridNode dbNode : dbFolderNode.getChildren()) {
if (dbNode instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) dbNode;
if (database.getRunningType() == DbRunningType.STANDALONE || !database.isLogined()) {
//ctv.setChecked(dbNode, false);
selectedNodes.remove(database);
} else if (ctv.getChecked(dbNode)) {
ctv.setChecked(dbNode, true);
if (dbNode.getData(INDEXKEY) == null) {
dbNode.setData(INDEXKEY, String.valueOf(databaseIndex++));
}
} else {
ctv.setChecked(dbNode, true);
}
}
}
//only has one db folder so first time break it
break;
}
} else if (event.getElement() instanceof ICubridNode) {
ICubridNode node = (ICubridNode) event.getElement();
if (node.getType().equals(NodeType.DATABASE_FOLDER)) {
for (ICubridNode dbNode : node.getChildren()) {
if (dbNode instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) dbNode;
if (database.getRunningType() == DbRunningType.STANDALONE || !database.isLogined()) {
ctv.setChecked(dbNode, false);
} else if (ctv.getChecked(dbNode)) {
ctv.setChecked(dbNode, true);
if (dbNode.getData(INDEXKEY) == null) {
dbNode.setData(INDEXKEY, String.valueOf(databaseIndex++));
}
} else {
ctv.setChecked(dbNode, false);
}
}
}
}
// else if (node.getType().equals(NodeType.GROUP)) {
// for (ICubridNode childNode : node.getChildren()) {
// //CQB tree
// if(childNode instanceof CubridDatabase) {
// CubridDatabase database = (CubridDatabase) childNode;
// if (database.getRunningType() == DbRunningType.STANDALONE
// || !database.isLogined()) {
// if (childNode.getData(INDEXKEY) == null) {
// childNode.setData(INDEXKEY, String.valueOf(databaseIndex++));
// }
// }
// continue;
// }
// //CM tree
// for (ICubridNode dbFolderNode : childNode.getChildren()) {
// for (ICubridNode dbNode : dbFolderNode.getChildren()) {
// if(dbNode instanceof CubridDatabase) {
// CubridDatabase database = (CubridDatabase) dbNode;
// if (database.getRunningType() == DbRunningType.STANDALONE
// || !database.isLogined()) {
// ctv.setChecked(dbNode, false);
// } else if (ctv.getChecked(dbNode)) {
// ctv.setChecked(dbNode, true);
// if (dbNode.getData(INDEXKEY) == null) {
// dbNode.setData(INDEXKEY, String.valueOf(databaseIndex++));
// }
// } else {
// ctv.setChecked(dbNode, false);
// }
// }
// }
// }
// //only has one db folder so first time break it
// break;
// }
// }
}
ctv.refresh();
}
});
ctv.getTree().addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent event) {
//mac can't drag and drop,so support copy and paste db node
if (((event.stateMask & SWT.CTRL) != 0) || ((event.stateMask & SWT.COMMAND) != 0) && event.keyCode == 'v') {
final Clipboard cb = new Clipboard(getShell().getDisplay());
String plainText = (String) cb.getContents(TextTransfer.getInstance());
String[] databaseNameArray = plainText.split(",");
selectedNodes.addAll(getDatabaseNode(databaseNameArray));
setInput();
}
}
});
// ctv.addDoubleClickListener(LayoutManager.getInstance());
// ctv.addTreeListener(new ITreeViewerListener() {
// public void treeCollapsed(TreeExpansionEvent event) {
// CommonTool.clearExpandedElements(ctv);
// }
//
// public void treeExpanded(TreeExpansionEvent event) {
// CommonTool.clearExpandedElements(ctv);
// }
// });
final Tree tableTree = ctv.getTree();
tableTree.setHeaderVisible(true);
tableTree.setLinesVisible(true);
final TreeViewerColumn dbCol = new TreeViewerColumn(ctv, SWT.NONE);
dbCol.setLabelProvider(new MultiDBQueryTreeColumnLabelProvider());
dbCol.getColumn().setWidth(250);
dbCol.getColumn().setText(Messages.qedit_multiDBQueryComp_tree_dbCol);
final TreeViewerColumn indexCol = new TreeViewerColumn(ctv, SWT.NONE);
indexCol.setLabelProvider(new MultiDBQueryTreeColumnLabelProvider());
indexCol.getColumn().setWidth(50);
indexCol.getColumn().setText(Messages.qedit_multiDBQueryComp_tree_indexCol);
indexCol.setEditingSupport(new EditingSupport(ctv) {
TextCellEditor textCellEditor;
protected boolean canEdit(Object element) {
if (element instanceof ICubridNode) {
ICubridNode node = (ICubridNode) element;
if (node.getType() == NodeType.DATABASE) {
CubridDatabase database = (CubridDatabase) element;
if ((database.getRunningType() == DbRunningType.CS && database.isLogined())) {
return true;
}
}
}
return false;
}
protected CellEditor getCellEditor(Object element) {
if (textCellEditor == null) {
textCellEditor = new TextCellEditor(ctv.getTree());
textCellEditor.setValidator(new IndexCellEditorValidator());
textCellEditor.addListener(new ICellEditorListener() {
public void applyEditorValue() {
}
public void cancelEditor() {
}
public void editorValueChanged(boolean oldValidState, boolean newValidState) {
}
});
}
return textCellEditor;
}
protected Object getValue(Object element) {
final ICubridNode node = (ICubridNode) element;
String index = (String) node.getData(INDEXKEY);
if (index == null) {
return "";
} else {
return index;
}
}
protected void setValue(Object element, Object value) {
if (value == null) {
return;
}
try {
Integer.valueOf((String) value);
} catch (Exception e) {
return;
}
final ICubridNode node = (ICubridNode) element;
node.setData(INDEXKEY, value);
// setAllParentExpandOrCollapse(node.getParent(), true);
ctv.refresh();
}
/**
* MyCellEditorValidator
*
* @author fulei
*
*/
class IndexCellEditorValidator implements ICellEditorValidator {
/**
* isValid
*
* @param value Object
* @return String
*/
public String isValid(Object value) {
try {
Integer.valueOf((String) value);
} catch (Exception e) {
CommonUITool.openErrorBox(Messages.qedit_multiDBQueryComp_tree_indexErr);
return Messages.qedit_multiDBQueryComp_tree_indexErr;
}
return null;
}
}
});
final TreeViewerColumn commentCol = new TreeViewerColumn(ctv, SWT.NONE);
commentCol.setLabelProvider(new MultiDBQueryTreeColumnLabelProvider());
commentCol.getColumn().setWidth(200);
commentCol.getColumn().setText(Messages.qedit_multiDBQueryComp_tree_commentCol);
CTabItem tabItem = new CTabItem(multiDBQueryCompTabFolder, SWT.NONE);
tabItem.setText(Messages.qedit_multiDBQueryComp_tabItem);
tabItem.setControl(bottomSash);
tabItem.setShowClose(false);
setInput();
// HostNodePersistManager.getInstance().getAllServer();
multiDBQueryCompTabFolder.setSelection(tabItem);
dragController = new MultiDBQueryDNDController(this, ctv);
dragController.registerDropTarget();
}
use of org.eclipse.swt.events.KeyAdapter in project cubrid-manager by CUBRID.
the class FilterResultContrItem method createControl.
/**
* Create the content
*
* @param parent Composite
* @return Control
*/
protected Control createControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
comp.setLayoutData(gridData);
final GridLayout gdLayout = new GridLayout(5, false);
gdLayout.marginHeight = 0;
gdLayout.marginWidth = 0;
gdLayout.horizontalSpacing = 0;
gdLayout.verticalSpacing = 0;
gdLayout.marginRight = 10;
comp.setLayout(gdLayout);
Label lbl = new Label(comp, SWT.NONE);
lbl.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
lbl.setText(" " + Messages.lblFilterSearch + " ");
text = new Text(comp, SWT.NONE | SWT.BORDER | SWT.LEFT);
text.setLayoutData(CommonUITool.createGridData(1, 1, 100, -1));
text.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
doFilter();
}
}
});
dropDownButton = new Button(comp, SWT.FLAT | SWT.DOWN);
dropDownButton.setText(Messages.lblFilterSearchOption);
dropDownButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
handleSelectionEvent();
}
});
Label lblLimit = new Label(comp, SWT.NONE);
lblLimit.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
lblLimit.setText(" " + Messages.lblSearchLimit + " ");
pageLimitCombo = new Combo(comp, SWT.READ_ONLY);
pageLimitCombo.setItems(new String[] { "1000", "5000", "10000" });
pageLimitCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
pageLimitCombo.setText("" + pageLimit);
pageLimitCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
int limit = StringUtil.intValue(pageLimitCombo.getText());
ServerInfo serverInfo = qe.getDatabase().getServer().getServerInfo();
QueryOptions.setSearchUnitCount(serverInfo, limit);
}
});
loadMenuItems();
return comp;
}
use of org.eclipse.swt.events.KeyAdapter in project cubrid-manager by CUBRID.
the class SqlmapNavigatorView method createCondView.
/**
* Create the main view.
*
* @param parent {@link Composite} the parent composite
*/
private void createCondView(Composite parent) {
String[] columnNames = { Messages.lblSqlmapUse, Messages.lblSqlmapCondition };
Label lblCondTitle = new Label(parent, SWT.NONE);
lblCondTitle.setText(Messages.lblSqlmapConditions);
condView = CommonUITool.createCommonTableViewer(parent, null, columnNames, CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 80));
condView.setColumnProperties(columnNames);
condView.setContentProvider(new TableContentProvider());
condView.setLabelProvider(new SqlmapLabelProvider(this));
condView.setCellModifier(new SqlmapCellModifier(this));
CellEditor[] cellEditor = new CellEditor[columnNames.length];
cellEditor[0] = new CheckboxCellEditor(condView.getTable());
condView.setCellEditors(cellEditor);
TableLayout tableLayout = new TableLayout();
tableLayout.addColumnData(new ColumnPixelData(30));
tableLayout.addColumnData(new ColumnPixelData(160));
condView.getTable().setLayout(tableLayout);
condView.getTable().addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.character == ' ') {
toggleUsedBySelectedCondition();
}
super.keyPressed(e);
}
});
}
use of org.eclipse.swt.events.KeyAdapter in project cubrid-manager by CUBRID.
the class DataCompareEditorPart method createContent.
private void createContent(Composite parent) {
compareTableViewer = new TableViewer(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
compareTableViewer.setUseHashlookup(true);
compareTableViewer.setColumnProperties(columnNames);
CommonUITool.createGridLayout(compareTableViewer.getTable(), 1, 0, 10, 0, 10, 0, 0, 0, 0);
compareTableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
compareTableViewer.getTable().setLinesVisible(true);
compareTableViewer.getTable().setHeaderVisible(true);
sorter = new DataCompareSchemaListViewSorter();
sorter.setSortType(DataCompareSchemaListViewSorter.SORT_TABLE);
compareTableViewer.setSorter(sorter);
makeContextMenu(compareTableViewer);
final TableViewerColumn firstCol = new TableViewerColumn(compareTableViewer, SWT.NONE);
firstCol.getColumn().setWidth(30);
firstCol.getColumn().setResizable(false);
firstCol.getColumn().setAlignment(SWT.CENTER);
firstCol.getColumn().setImage(CommonUIPlugin.getImage("icons/unchecked.gif"));
firstCol.getColumn().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TableItem[] items = compareTableViewer.getTable().getItems();
if (items == null) {
return;
}
for (TableItem item : items) {
DataCompare dataCompare = (DataCompare) item.getData();
dataCompare.setUse(isSelectAll);
}
compareTableViewer.refresh();
Image image = null;
if (isSelectAll) {
image = CommonUIPlugin.getImage("icons/checked.gif");
} else {
image = CommonUIPlugin.getImage("icons/unchecked.gif");
}
firstCol.getColumn().setImage(image);
isSelectAll = !isSelectAll;
}
});
TableViewerColumn col = new TableViewerColumn(compareTableViewer, SWT.NONE);
col.getColumn().setWidth(200);
col.getColumn().setText(Messages.lblDataCompareTable);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_TABLE);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordSource);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_SOURCE_RECORDS);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordTarget);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_TARGET_RECORDS);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordProgress);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_PROGRESS);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordMatch);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_MATCHES);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordNoMatch);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_NOT_MATCHES);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordNotExist);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_NOT_EXISTS);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(300);
col.getColumn().setText(Messages.lblDataCompareRecordError);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_ERROR);
CellEditor[] cellEditor = new CellEditor[1];
cellEditor[0] = new CheckboxCellEditor(compareTableViewer.getTable());
compareTableViewer.setCellEditors(cellEditor);
compareTableViewer.setCellModifier(new DataCompareCellModifier(this));
compareTableViewer.setContentProvider(new DataCompareSchemaListContentProvider());
compareTableViewer.setLabelProvider(new DataCompareSchemaListLabelProvider());
compareList = new ArrayList<DataCompare>();
compareTableViewer.setInput(compareList);
txtProgress = new StyledText(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
txtProgress.setEditable(false);
txtProgress.setWordWrap(true);
txtProgress.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 100));
txtProgress.setBackground(txtProgress.getDisplay().getSystemColor(SWT.COLOR_BLACK));
txtProgress.setForeground(txtProgress.getDisplay().getSystemColor(SWT.COLOR_GREEN));
compareTableViewer.getTable().setToolTipText(Messages.msgYouCanSeeDetailDblclick);
compareTableViewer.getTable().addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
if (e.character == ' ') {
TableItem[] items = compareTableViewer.getTable().getSelection();
if (items == null) {
return;
}
for (TableItem item : items) {
DataCompare dataCompare = (DataCompare) item.getData();
dataCompare.setUse(!dataCompare.isUse());
}
compareTableViewer.refresh();
}
}
});
compareTableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
if (!refreshedRecordCounts) {
CommonUITool.openWarningBox(Messages.msgClickRefreshToEsimateDiff);
return;
}
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
DataCompare model = (DataCompare) selection.getFirstElement();
if (!model.isSameSchema()) {
CommonUITool.openWarningBox(Messages.msgTheSchemaDiff);
return;
}
if (model.getRecordsTarget() == -1) {
CommonUITool.openWarningBox(Messages.msgTargetNotFound);
return;
}
if (model.getRecordsSource() == 0 && model.getRecordsTarget() > 0) {
CommonUITool.openWarningBox(Messages.msgTargetNoData);
return;
}
if (model.getRecordsSource() == 0) {
CommonUITool.openWarningBox(Messages.msgNoDataToCompare);
return;
}
if (model.getProgressPosition() == 0) {
CommonUITool.openWarningBox(Messages.msgNotYetCompared);
return;
}
if (model.getNotMatches() == 0 && model.getNotExists() == 0) {
CommonUITool.openWarningBox(Messages.msgSameData);
return;
}
showDataCompareDetailEditor(model.getSchemaInfo());
}
});
}
use of org.eclipse.swt.events.KeyAdapter in project MonjaDB by Kanatoko.
the class MActionView method init2.
//--------------------------------------------------------------------------------
public void init2() {
parent.setLayout(new FormLayout());
sashForm = new SashForm(parent, SWT.SMOOTH | SWT.VERTICAL);
FormData fd_sashForm1 = new FormData();
fd_sashForm1.top = new FormAttachment(0, 1);
fd_sashForm1.left = new FormAttachment(0, 1);
fd_sashForm1.right = new FormAttachment(100, -1);
fd_sashForm1.bottom = new FormAttachment(100, -1);
sashForm.setLayoutData(fd_sashForm1);
table = new Table(sashForm, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
table.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
onTableStateChange();
}
});
table.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.keyCode == 13) {
e.doit = false;
if (//Shift + Enter
(e.stateMask & SWT.SHIFT) != 0) {
repeatActionsOnTable();
} else {
editActions();
}
}
}
});
FormData fd_table = new FormData();
fd_table.top = new FormAttachment(0, 0);
fd_table.bottom = new FormAttachment(100, 0);
fd_table.left = new FormAttachment(0, 0);
fd_table.right = new FormAttachment(100, 0);
table.setLayoutData(fd_table);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn actionColumn = new TableColumn(table, SWT.NONE);
actionColumn.setWidth(100);
actionColumn.setText("Action");
TableColumn dateColumn = new TableColumn(table, SWT.NONE);
dateColumn.setWidth(100);
dateColumn.setText("Date");
editorComposite = new Composite(sashForm, SWT.BORDER);
editorComposite.setLayout(new FormLayout());
text = new Text(editorComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
onTextStateChange();
}
});
FormData fd_text = new FormData();
fd_text.bottom = new FormAttachment(100, -40);
fd_text.right = new FormAttachment(100);
fd_text.top = new FormAttachment(0);
fd_text.left = new FormAttachment(0);
text.setLayoutData(fd_text);
executeButton = new Button(editorComposite, SWT.NONE);
executeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
executeActionsOnText();
}
});
executeButton.setEnabled(false);
FormData fd_executeButton = new FormData();
fd_executeButton.top = new FormAttachment(text, 6);
fd_executeButton.left = new FormAttachment(text, -120, SWT.RIGHT);
fd_executeButton.right = new FormAttachment(100, -10);
executeButton.setLayoutData(fd_executeButton);
executeButton.setText("Execute");
editorComposite.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
onSashResize();
}
});
MSwtUtil.getTableColumnWidthFromProperties("actionListTable", table, prop, new int[] { 200, 100 });
MSwtUtil.addListenerToTableColumns2(table, this);
//table.addListener( SWT.KeyDown, this );
table.addListener(SWT.MouseDoubleClick, this);
menuManager = new MenuManager();
Menu contextMenu = menuManager.createContextMenu(table);
table.setMenu(contextMenu);
//executeTableAction
{
redoAction = new Action() {
public void run() {
//------------
repeatActionsOnTable();
}
};
//------------
redoAction.setToolTipText("Redo Selected Actions");
redoAction.setText("Redo\tShift+Enter");
initAction(redoAction, "table_go.png", menuManager);
redoAction.setEnabled(false);
}
//editAction
{
editAction = new Action() {
public void run() {
//------------
editActions();
}
};
//------------
editAction.setToolTipText("Edit Actions on The Text Editor");
editAction.setText("Edit\tEnter");
initAction(editAction, "pencil.png", menuManager);
editAction.setEnabled(false);
}
dropDownMenu.add(new Separator());
menuManager.add(new Separator());
//executeAction
{
executeAction = new Action() {
public void run() {
//------------
executeActionsOnText();
}
};
//------------
executeAction.setToolTipText("Execute Actions on the Textarea");
executeAction.setText("Execute");
setActionImage(executeAction, "bullet_go.png");
addActionToToolBar(executeAction);
executeAction.setEnabled(false);
dropDownMenu.add(executeAction);
}
dropDownMenu.add(new Separator());
menuManager.add(new Separator());
//copyAction
{
copyAction = new Action() {
public void run() {
//------------
copyActions();
}
};
//------------
copyAction.setToolTipText("Copy Actions to Clipboard");
copyAction.setText("Copy");
setActionImage(copyAction, "page_copy.png");
addActionToToolBar(copyAction);
copyAction.setEnabled(false);
dropDownMenu.add(copyAction);
menuManager.add(copyAction);
}
dropDownMenu.add(new Separator());
menuManager.add(new Separator());
//clearAction
{
clearAction = new Action() {
public void run() {
//------------
clearActions();
}
};
//------------
clearAction.setToolTipText("Clear All");
clearAction.setText("Clear All");
initAction(clearAction, "table_delete.png", menuManager);
clearAction.setEnabled(false);
}
//saveAction
{
saveAction = new Action() {
public void run() {
//------------
saveActions();
}
};
//------------
saveAction.setToolTipText("Save Action");
saveAction.setText("Save");
initAction(saveAction, "cog_add.png", menuManager);
saveAction.setEnabled(false);
}
//load actionLogList
if (prop.containsKey(ACTION_LOG_LIST)) {
String savedStr = prop.getProperty(ACTION_LOG_LIST);
actionLogList = (java.util.List) JSON.parse(savedStr);
for (int i = 0; i < actionLogList.size(); ++i) {
Map actionLog = (Map) actionLogList.get(i);
addActionToTable(actionLog);
}
} else {
actionLogList = new LinkedList();
}
if (prop.containsKey(ACTIONLOG_COMPOSITE_WEIGHT)) {
(new Thread() {
public void run() {
MSystemUtil.sleep(0);
shell.getDisplay().asyncExec(new Runnable() {
public void run() {
//----
sashForm.setWeights(prop.getIntArrayProperty(ACTIONLOG_COMPOSITE_WEIGHT));
}
});
//----
}
}).start();
} else {
sashForm.setWeights(new int[] { 70, 30 });
}
initializedTime = System.currentTimeMillis();
}
Aggregations