use of org.eclipse.swt.events.MouseEvent in project cubrid-manager by CUBRID.
the class QueryExecuter method bindEvents.
private void bindEvents() {
selectableSupport.getTableCursor().addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
}
public void mouseDown(MouseEvent e) {
}
public void mouseDoubleClick(MouseEvent e) {
performEdit();
}
});
selectableSupport.getTableCursor().addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
if (e.character == SWT.CR) {
performEdit();
}
}
});
selectableSupport.getTableCursor().addKeyListener(new org.eclipse.swt.events.KeyAdapter() {
public void keyReleased(KeyEvent event) {
if (isEditMode() && event.keyCode == SWT.DEL) {
deleteRecord(tblResult, null);
} else if (((event.stateMask & SWT.CTRL) != 0 || (event.stateMask & SWT.COMMAND) != 0) && (event.keyCode == 'c' || event.character == '')) {
// key press 'ctrl + c' is intercept by editor text so add
// here
copySelectedItems();
} else if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'a') {
selectableSupport.selectAll();
}
}
});
}
use of org.eclipse.swt.events.MouseEvent in project cubrid-manager by CUBRID.
the class SelectedLoactionComparator method redrawMoreButton.
public void redrawMoreButton() {
if (moreButton != null && !moreButton.isDisposed()) {
moreButton.dispose();
}
if (showMoreOperator != null) {
if (tableCursor != null && !tableCursor.isDisposed() && tableCursor.getRow() != null) {
final int rowIndex = table.indexOf(tableCursor.getRow());
final int columnIndex = tableCursor.getColumn();
if (showMoreOperator.isShowButton(rowIndex, columnIndex)) {
moreButton = new Button(tableCursor, SWT.None);
moreButton.setText("...");
Rectangle location = tableCursor.getBounds();
int x = location.width - detailButtonWidth;
if (x < 0) {
x = 0;
}
moreButton.setBounds(x, 0, detailButtonWidth, location.height);
moreButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
if (showMoreOperator != null) {
showMoreOperator.handleButtonEvent(rowIndex, columnIndex);
}
}
});
moreButton.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
handleMouseUp(e);
}
public void mouseDown(MouseEvent e) {
}
public void mouseDoubleClick(MouseEvent e) {
}
});
}
}
}
}
use of org.eclipse.swt.events.MouseEvent in project cubrid-manager by CUBRID.
the class BrokerEnvStatusView method createTable.
/**
* This method initializes table
*
*/
private void createTable() {
tableViewer = new TableViewer(composite, SWT.FULL_SELECTION);
tableViewer.getTable().setHeaderVisible(true);
tableViewer.getTable().setLinesVisible(true);
BrokerTblColumnSetHelp bcsh = BrokerTblColumnSetHelp.getInstance();
bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerEnvStatusColumn, BrokerEnvStatusColumn.values());
TableLayout tlayout = new TableLayout();
for (BrokerEnvStatusColumn column : BrokerEnvStatusColumn.values()) {
if (column.getValue() == -1) {
tlayout.addColumnData(new ColumnWeightData(0, 0, false));
} else {
tlayout.addColumnData(new ColumnWeightData(10, 40, true));
}
}
tableViewer.getTable().setLayout(tlayout);
tableViewer.getTable().addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent event) {
int index = -1;
if ((index = tableViewer.getTable().getSelectionIndex()) >= 0) {
TableItem tableItem = tableViewer.getTable().getItem(index);
String brokename = tableItem.getText(0).trim();
ICubridNode input = null;
for (ICubridNode node : cubridNode.getChildren()) {
if (node.getLabel().equalsIgnoreCase(brokename)) {
input = node;
break;
}
}
LayoutManager.getInstance().setCurrentSelectedNode(input);
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == window) {
return;
}
IWorkbenchPage activePage = window.getActivePage();
IViewPart viewPart = window.getActivePage().findView(BrokerStatusView.ID);
if (null != viewPart) {
activePage.hideView(viewPart);
}
try {
activePage.showView(BrokerStatusView.ID);
} catch (PartInitException e1) {
LOGGER.error(e1.getMessage(), e1);
}
}
}
});
makeTableColumn();
tableViewer.setContentProvider(new BrokersStatusContentProvider());
ServerInfo serverInfo = cubridNode.getServer().getServerInfo();
BrokersStatusLabelProvider brokersStatusLabelProvider = new BrokersStatusLabelProvider();
brokersStatusLabelProvider.setServerInfo(serverInfo);
tableViewer.setLabelProvider(brokersStatusLabelProvider);
}
use of org.eclipse.swt.events.MouseEvent 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.MouseEvent in project cubrid-manager by CUBRID.
the class QueryPlanCompositeWithHistory method initialize.
/**
* Initializing a Plan Tab
*/
private void initialize() {
createPlanToolbar();
//create the plan tab folder and history sash
plansHistorySash = new SashForm(this, SWT.HORIZONTAL);
plansHistorySash.setLayout(new GridLayout(2, true));
plansHistorySash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
//create left plan tab folder
plansTabFolder = new CTabFolder(plansHistorySash, SWT.BOTTOM | SWT.CLOSE);
plansTabFolder.setSimple(false);
plansTabFolder.setUnselectedImageVisible(true);
plansTabFolder.setUnselectedCloseVisible(true);
plansTabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
plansTabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
plansTabFolder.setLayout(new GridLayout(1, true));
plansTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
TabContextMenuManager tabContextMenuManager = new TabContextMenuManager(plansTabFolder);
tabContextMenuManager.createContextMenu();
//create the right plan history table
planHistoryTable = new Table(plansHistorySash, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
planHistoryTable.setLayout(new GridLayout(1, true));
planHistoryTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
planHistoryTable.setHeaderVisible(true);
planHistoryTable.setLinesVisible(true);
planHistoryTable.addMouseListener(new MouseListener() {
public void mouseDoubleClick(MouseEvent event) {
int selectionIndex = planHistoryTable.getSelectionIndex();
if (selectionIndex < 0) {
return;
}
TableItem tableItem = planHistoryTable.getItem(planHistoryTable.getSelectionIndex());
if (tableItem == null) {
return;
}
int uid = Integer.valueOf(tableItem.getText(0));
StructQueryPlan sq = planHistoryList.get(uid - 1);
PlanTabItem tabItem = findPlanTab(uid);
if (tabItem == null) {
tabItem = newPlanTab(uid);
}
plansTabFolder.setSelection(tabItem);
printPlan(tabItem, sq);
}
public void mouseDown(MouseEvent event) {
}
public void mouseUp(MouseEvent event) {
}
});
int i = 0;
planHistoryTblCols[i] = new TableColumn(planHistoryTable, SWT.RIGHT);
// No
planHistoryTblCols[i].setText(Messages.qedit_plan_history_col1);
planHistoryTblCols[i].setMoveable(true);
planHistoryTblCols[i].setWidth(20);
addNumberSorter(planHistoryTable, planHistoryTblCols[i]);
sortType.put(planHistoryTblCols[i], "NUMBER");
planHistoryTblCols[++i] = new TableColumn(planHistoryTable, SWT.LEFT);
// Date
planHistoryTblCols[i].setText(Messages.qedit_plan_history_col2);
planHistoryTblCols[i].setMoveable(true);
planHistoryTblCols[i].setWidth(100);
addStringSorter(planHistoryTable, planHistoryTblCols[i]);
sortType.put(planHistoryTblCols[i], "STRING");
planHistoryTblCols[++i] = new TableColumn(planHistoryTable, SWT.RIGHT);
// Cost
planHistoryTblCols[i].setText(Messages.qedit_plan_history_col4);
planHistoryTblCols[i].setMoveable(true);
planHistoryTblCols[i].setWidth(90);
addNumberSorter(planHistoryTable, planHistoryTblCols[i]);
sortType.put(planHistoryTblCols[i], "NUMBER");
planHistoryTblCols[++i] = new TableColumn(planHistoryTable, SWT.LEFT);
// Cost
planHistoryTblCols[i].setText(Messages.qedit_plan_history_col3);
planHistoryTblCols[i].setMoveable(false);
planHistoryTblCols[i].setWidth(90);
addStringSorter(planHistoryTable, planHistoryTblCols[i]);
sortType.put(planHistoryTblCols[i], "STRING");
sashPlanWeight = new int[] { 80, 20 };
plansHistorySash.setWeights(sashPlanWeight);
newPlanTab(1);
plansTabFolder.setSelection(0);
hideHistoryPane();
refreshToolbarStatus(QueryOptions.getQueryPlanDisplayType());
}
Aggregations