use of org.eclipse.swt.events.KeyEvent in project tesb-studio-se by Talend.
the class WsdlFieldPart method createControl.
@Override
public Control createControl(Composite parent) {
wsdlField = new LabelledFileField(parent, "WSDL:", new String[] { "*.wsdl", "*.*" }, 1, SWT.BORDER) {
protected void setFileFieldValue(String result) {
if (result != null) {
setRawFieldValue(result);
}
}
};
wsdlField.getTextControl().addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
switch(event.keyCode) {
case SWT.CR:
case SWT.KEYPAD_CR:
refreshTriggered();
}
}
});
return wsdlField.getTextControl();
}
use of org.eclipse.swt.events.KeyEvent in project tdi-studio-se by Talend.
the class DB2ExplainPlanExecution method displayResults.
private void displayResults(final ExplainNode node) {
Display.getDefault().asyncExec(new Runnable() {
@Override
@SuppressWarnings("deprecation")
public void run() {
clearCanvas();
GridLayout gLayout = new GridLayout();
gLayout.numColumns = 2;
gLayout.marginLeft = 0;
gLayout.horizontalSpacing = 0;
gLayout.verticalSpacing = 0;
gLayout.marginWidth = 0;
gLayout.marginHeight = 0;
composite.setLayout(gLayout);
try {
//$NON-NLS-1$
composite.setData("parenttab", parentTab);
Composite pp = new Composite(composite, SWT.NULL);
pp.setLayout(new FillLayout());
pp.setLayoutData(new GridData(GridData.FILL_BOTH));
TreeViewer tv = new TreeViewer(pp, SWT.BORDER | SWT.FULL_SELECTION);
Tree tree = tv.getTree();
tree.setLinesVisible(true);
tree.setHeaderVisible(true);
TreeColumn tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText("");
tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText(Messages.getString("DB2ExplainPlanExecution.tableColumnText1"));
tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText(Messages.getString("DB2ExplainPlanExecution.tableColumnText2"));
TableLayout tableLayout = new TableLayout();
tableLayout.addColumnData(new ColumnWeightData(6, 150, true));
tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
tree.setLayout(tableLayout);
tv.setContentProvider(new ITreeContentProvider() {
@Override
public void dispose() {
}
@Override
public Object[] getChildren(Object parentElement) {
return ((ExplainNode) parentElement).getChildren();
}
@Override
public Object[] getElements(Object inputElement) {
ExplainNode nd = ((ExplainNode) inputElement);
return nd.getChildren();
}
@Override
public Object getParent(Object element) {
return ((ExplainNode) element).getParent();
}
@Override
public boolean hasChildren(Object element) {
if (((ExplainNode) element).getChildren().length > 0) {
return true;
}
return false;
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tv.setLabelProvider(new TreeLabelProvider() {
});
tv.setInput(node);
tv.refresh();
tv.expandAll();
// make columns full size
for (int i = 0; i < tree.getColumnCount(); i++) {
tree.getColumn(i).pack();
}
final Composite parent = composite;
tree.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
switch(e.keyCode) {
case SWT.F5:
// refresh SQL Results
try {
//$NON-NLS-1$
Object o = parent.getData("parenttab");
if (o != null) {
AbstractSQLExecution sqlExec = (AbstractSQLExecution) ((TabItem) o).getData();
if (sqlExec != null) {
sqlExec.startExecution();
}
}
} catch (Exception e1) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("DB2ExplainPlanExecution.logMessageError1"), e1);
}
break;
default:
return;
}
}
});
} catch (Exception e) {
// add message
String message = e.getMessage();
Label errorLabel = new Label(composite, SWT.FILL);
errorLabel.setText(message);
errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("DB2ExplainPlanExecution.logMessageError2"), e);
}
composite.layout();
composite.redraw();
}
;
});
}
use of org.eclipse.swt.events.KeyEvent in project tdi-studio-se by Talend.
the class OracleExplainPlanExecution method displayResults.
private void displayResults(final ExplainNode node) {
Display.getDefault().asyncExec(new Runnable() {
@Override
@SuppressWarnings("deprecation")
public void run() {
clearCanvas();
GridLayout gLayout = new GridLayout();
gLayout.numColumns = 2;
gLayout.marginLeft = 0;
gLayout.horizontalSpacing = 0;
gLayout.verticalSpacing = 0;
gLayout.marginWidth = 0;
gLayout.marginHeight = 0;
composite.setLayout(gLayout);
try {
//$NON-NLS-1$
composite.setData("parenttab", parentTab);
Composite pp = new Composite(composite, SWT.NULL);
pp.setLayout(new FillLayout());
pp.setLayoutData(new GridData(GridData.FILL_BOTH));
TreeViewer tv = new TreeViewer(pp, SWT.BORDER | SWT.FULL_SELECTION);
Tree tree = tv.getTree();
tree.setLinesVisible(true);
tree.setHeaderVisible(true);
TreeColumn tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText("");
tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText(Messages.getString("OracleExplainPlanExecution.tableColumnText1"));
tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText(Messages.getString("OracleExplainPlanExecution.tableColumnText2"));
TableLayout tableLayout = new TableLayout();
tableLayout.addColumnData(new ColumnWeightData(6, 150, true));
tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
tree.setLayout(tableLayout);
tv.setContentProvider(new ITreeContentProvider() {
@Override
public void dispose() {
}
@Override
public Object[] getChildren(Object parentElement) {
return ((ExplainNode) parentElement).getChildren();
}
@Override
public Object[] getElements(Object inputElement) {
ExplainNode nd = ((ExplainNode) inputElement);
return nd.getChildren();
}
@Override
public Object getParent(Object element) {
return ((ExplainNode) element).getParent();
}
@Override
public boolean hasChildren(Object element) {
if (((ExplainNode) element).getChildren().length > 0) {
return true;
}
return false;
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tv.setLabelProvider(new TreeLabelProvider() {
});
tv.setInput(node);
tv.refresh();
tv.expandAll();
// make columns full size
for (int i = 0; i < tree.getColumnCount(); i++) {
tree.getColumn(i).pack();
}
final Composite parent = composite;
tree.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
switch(e.keyCode) {
case SWT.F5:
// refresh SQL Results
try {
//$NON-NLS-1$
Object o = parent.getData("parenttab");
if (o != null) {
AbstractSQLExecution sqlExec = (AbstractSQLExecution) ((TabItem) o).getData();
if (sqlExec != null) {
sqlExec.startExecution();
}
}
} catch (Exception e1) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanExecution.logMessage1"), e1);
}
break;
default:
return;
}
}
});
} catch (Exception e) {
// add message
String message = e.getMessage();
Label errorLabel = new Label(composite, SWT.FILL);
errorLabel.setText(message);
errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanExecution.logMessage2"), e);
}
composite.layout();
composite.redraw();
}
;
});
}
use of org.eclipse.swt.events.KeyEvent in project cubrid-manager by CUBRID.
the class CubridNavigatorView method addListener.
/**
*
* Add listener
*
*/
protected void addListener() {
tv.getTree().addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent event) {
if (toolTip.isVisible()) {
toolTip.setVisible(false);
}
}
public void mouseUp(MouseEvent event) {
if (event.button == 1 && LayoutManager.getInstance().isUseClickOnce()) {
ISelection selection = tv.getSelection();
if (selection == null || selection.isEmpty()) {
return;
}
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (!(obj instanceof ICubridNode)) {
return;
}
ICubridNode cubridNode = (ICubridNode) obj;
LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(cubridNode);
}
}
});
tv.getTree().addMouseTrackListener(new MouseTrackAdapter() {
public void mouseHover(MouseEvent event) {
if (toolTip.isVisible()) {
toolTip.setVisible(false);
}
int x = event.x;
int y = event.y;
TreeItem item = tv.getTree().getItem(new Point(x, y));
if (item == null) {
return;
}
showToolTip(item);
}
});
tv.getTree().addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent event) {
widgetSelected(event);
}
public void widgetSelected(SelectionEvent event) {
if (toolTip.isVisible()) {
toolTip.setVisible(false);
}
TreeItem[] items = tv.getTree().getSelection();
if (items == null || items.length == 0) {
return;
}
showToolTip(items[0]);
if (items.length == 1) {
showSchemaInfo(items[0]);
} else {
showSchemaInfo(null);
}
}
});
addDragDropSupport(tv.getTree());
tv.getTree().addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
// prevent to make events by key press for a long time
if (e.character == ' ') {
TreeItem[] items = tv.getTree().getSelection();
if (items == null || items.length == 0) {
return;
}
if (items.length == 1) {
showSchemaInfo(items[0]);
} else {
showSchemaInfo(null);
}
}
lastKeyInputTimestamp = System.currentTimeMillis();
// by showing object information tab on the query editor.
if (e.keyCode == SWT.F2) {
TreeItem[] items = tv.getTree().getSelection();
if (items == null || items.length == 0) {
return;
}
for (TreeItem item : items) {
Object obj = item.getData();
if (obj instanceof ICubridNode) {
ICubridNode node = (ICubridNode) obj;
if (NodeType.USER_TABLE.equals(node.getType()) || NodeType.SYSTEM_TABLE.equals(node.getType()) || NodeType.USER_VIEW.equals(node.getType()) || NodeType.SYSTEM_VIEW.equals(node.getType())) {
DefaultSchemaNode table = (DefaultSchemaNode) obj;
OpenTargetAction action = new OpenTargetAction();
action.showObjectInfo(table);
} else if (NodeType.TABLE_FOLDER.equals(node.getType())) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(ID_CQB);
if (view == null) {
view = CubridNavigatorView.getNavigatorView(ID_CM);
}
if (view == null) {
return;
}
TreeViewer treeViewer = view.getViewer();
//if not expand ,expand the node and wait until all children be added
if (!treeViewer.getExpandedState(node)) {
treeViewer.expandToLevel(node, 1);
while (node.getChildren().size() == 0) {
try {
Thread.sleep(500);
} catch (Exception ignored) {
}
}
}
CubridDatabase database = (CubridDatabase) node.getParent();
OpenTargetAction action = new OpenTargetAction();
action.showTableDashboard(database);
}
}
}
}
}
});
}
use of org.eclipse.swt.events.KeyEvent 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());
}
});
}
Aggregations