use of org.eclipse.swt.events.MouseListener in project cubrid-manager by CUBRID.
the class SelectedLoactionComparator method bindListener.
/**
*
* Bind the linsteners
*/
private void bindListener() {
tableCursor.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent event) {
handleMouseUp(event);
}
public void mouseDown(MouseEvent event) {
handleMouseDown(event);
}
public void mouseDoubleClick(MouseEvent event) {
handleMouseDoubleClick(event);
}
});
tableCursor.addMouseMoveListener(new MouseMoveListener() {
public void mouseMove(MouseEvent event) {
handleMouseMove(event);
}
});
table.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent event) {
handleMouseUp(event);
}
public void mouseDown(MouseEvent event) {
handleMouseDown(event);
}
public void mouseDoubleClick(MouseEvent event) {
handleMouseDoubleClick(event);
}
});
table.addMouseTrackListener(new MouseTrackAdapter() {
public void mouseExit(MouseEvent e) {
Rectangle bound = table.getClientArea();
if (!bound.contains(e.x, e.y)) {
handleMouseExit(e);
}
}
});
table.addMouseMoveListener(new MouseMoveListener() {
public void mouseMove(MouseEvent event) {
handleMouseMove(event);
}
});
table.addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent event) {
handleKeyReleased(event);
}
public void keyPressed(KeyEvent event) {
handleKeyPressed(event);
}
});
tableCursor.addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent event) {
handleKeyReleased(event);
}
public void keyPressed(KeyEvent event) {
handleKeyPressed(event);
if (ctrlPressed) {
if (event.keyCode == SWT.ARROW_DOWN) {
int maxY = getMaxY();
int minX = getMinX();
int maxX = getMaxX();
int y = maxY + 1;
if (maxY > -1 && minX > -1 && maxX > -1 && y < table.getItemCount()) {
tableCursor.setSelection(y, maxX);
for (int x = minX; x <= maxX; x++) {
Point p = new Point(x, y);
addSelectPoint(p, true);
drawSelectedItem(p, true);
}
}
} else if (event.keyCode == SWT.ARROW_UP) {
int maxY = getMaxY();
int minX = getMinX();
int maxX = getMaxX();
int y = maxY;
if (maxY > -1 && minX > -1 && maxX > -1 && y > 0) {
tableCursor.setSelection(y - 1, maxX);
for (int x = minX; x <= maxX; x++) {
Point p = new Point(x, y);
removeSelectPoint(p, true);
drawUnselectedItem(p, true);
}
}
} else if (event.keyCode == SWT.ARROW_LEFT) {
int maxY = getMaxY();
int minY = getMinY();
int maxX = getMaxX();
if (maxY > -1 && minY > -1 && maxX > 0) {
tableCursor.setSelection(maxY, maxX - 1);
for (int y = minY; y <= maxY; y++) {
Point p = new Point(maxX, y);
removeSelectPoint(p, true);
drawUnselectedItem(p, true);
}
}
} else if (event.keyCode == SWT.ARROW_RIGHT) {
int maxY = getMaxY();
int minY = getMinY();
int maxX = getMaxX();
int columnCount = table.getColumnCount();
if (maxY > -1 && minY > -1 && maxX + 1 < columnCount) {
int x = maxX + 1;
tableCursor.setSelection(maxY, x);
for (int y = minY; y <= maxY; y++) {
Point p = new Point(x, y);
addSelectPoint(p, true);
drawSelectedItem(p, true);
}
}
}
} else if (!ctrlPressed && !shiftPressed) {
if (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_LEFT || event.keyCode == SWT.ARROW_RIGHT) {
selectedList.clear();
int y = table.indexOf(tableCursor.getRow());
int x = tableCursor.getColumn();
Point p = new Point(x, y);
addSelectPoint(p, true);
drawSelectedItems(true);
}
}
}
});
}
use of org.eclipse.swt.events.MouseListener in project GT by Tencent.
the class DevicesView method createTableView.
/**
* 初始化tableviewer
* 仅仅支持单选
* @param parent
*/
private void createTableView(Composite parent) {
sourcePkgTableViewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
// 设置表头内容
for (int i = 0; i < SOURCE_COLUMN_NAME.length; i++) {
new TableColumn(sourcePkgTableViewer.getTable(), SWT.LEFT).setText(SOURCE_COLUMN_NAME[i]);
}
sourcePkgTableViewer.getTable().getColumn(0).setWidth(200);
sourcePkgTableViewer.getTable().getColumn(1).setWidth(50);
// 设置表头和表格线可见
sourcePkgTableViewer.getTable().setHeaderVisible(true);
sourcePkgTableViewer.getTable().setLinesVisible(true);
sourcePkgTableViewer.setSorter(new APTTableSorter());
// 分别为表头的每一列注册事件
for (int i = 0; i < SOURCE_COLUMN_NAME.length; i++) {
final int j = i;
TableColumn column = sourcePkgTableViewer.getTable().getColumn(j);
column.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// // 单击时,重新设置排序对象属性
((APTTableSorter) sourcePkgTableViewer.getSorter()).doSort(j);
// 刷新表格数据
sourcePkgTableViewer.refresh();
}
});
}
sourcePkgTableViewer.setContentProvider(new ViewContentProvider());
sourcePkgTableViewer.setLabelProvider(new ViewLabelProvider());
sourcePkgTableViewer.getTable().addMouseListener(new MouseListener() {
@Override
public void mouseUp(MouseEvent e) {
}
@Override
public void mouseDown(MouseEvent e) {
}
@Override
public void mouseDoubleClick(MouseEvent e) {
if (isSupportAddOrDeleteOper) {
//APTConsoleFactory.getInstance().APTPrint("start ");
APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
//APTConsoleFactory.getInstance().APTPrint("1 ");
// 获取当前选择的进程
IStructuredSelection iss = (IStructuredSelection) sourcePkgTableViewer.getSelection();
//APTConsoleFactory.getInstance().APTPrint("2 ");
if (iss == null) {
//APTConsoleFactory.getInstance().APTPrint("iss == null");
return;
}
PkgInfo itemData = (PkgInfo) iss.getFirstElement();
//APTConsoleFactory.getInstance().APTPrint("3");
addDataItem(targetPkgTableViewer, itemData);
//APTConsoleFactory.getInstance().APTPrint("4");
APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
//APTConsoleFactory.getInstance().APTPrint("5");
} else {
APTConsoleFactory.getInstance().APTPrint("Operation forbid");
}
}
});
sourcePkgTableViewer.getTable().setToolTipText("双击或者右键菜单可添加指定进程到被测进程列表");
FormData tableViewFormData = new FormData();
tableViewFormData.left = new FormAttachment(0, 5);
tableViewFormData.right = new FormAttachment(100, -5);
tableViewFormData.top = new FormAttachment(targetPkgTableViewer.getTable(), 10);
tableViewFormData.bottom = new FormAttachment(100, -5);
Table table = sourcePkgTableViewer.getTable();
table.setLayoutData(tableViewFormData);
}
use of org.eclipse.swt.events.MouseListener in project cubrid-manager by CUBRID.
the class ServiceDashboardEditor method createPartControl.
public void createPartControl(Composite parent) {
Composite composite = new Composite(parent, SWT.None);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
composite.setLayout(layout);
Composite buttonComp = new Composite(composite, SWT.None);
buttonComp.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 24));
Composite dataComp = new Composite(composite, SWT.None);
dataComp.setLayout(new FillLayout());
dataComp.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
/*Create button*/
createButtonComposite(buttonComp);
serviceTreeViewer = new TreeViewer(dataComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
serviceTreeViewer.getTree().setHeaderVisible(true);
serviceTreeViewer.getTree().setLinesVisible(true);
ColumnViewerToolTipSupport.enableFor(serviceTreeViewer, ToolTip.NO_RECREATE);
final TreeColumn hostColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
hostColumn.setText(Messages.columnGroupOrHost);
hostColumn.setWidth(200);
serviceTreeViewer.setSorter(ServiceDashboardEditorSorter.Name_ASC);
setColumnSorter(hostColumn, ServiceDashboardEditorSorter.Name_ASC, ServiceDashboardEditorSorter.Name_DESC);
/*TreeColumn statusColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
statusColumn.setText(Messages.columnStatus);
statusColumn.setWidth(100);*/
final TreeColumn ipColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
ipColumn.setText(Messages.columnAddress);
ipColumn.setWidth(100);
setColumnSorter(ipColumn, ServiceDashboardEditorSorter.Address_ASC, ServiceDashboardEditorSorter.Address_DESC);
TreeColumn portColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
portColumn.setText(Messages.columnPort);
portColumn.pack();
setColumnSorter(portColumn, ServiceDashboardEditorSorter.Port_ASC, ServiceDashboardEditorSorter.Port_DESC);
TreeColumn userColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
userColumn.setText(Messages.columnUser);
userColumn.pack();
setColumnSorter(userColumn, ServiceDashboardEditorSorter.User_ASC, ServiceDashboardEditorSorter.User_DESC);
TreeViewerColumn volumnColumnData = new TreeViewerColumn(serviceTreeViewer, SWT.LEFT);
volumnColumnData.getColumn().setText(Messages.columnData);
volumnColumnData.getColumn().setToolTipText(Messages.columnDataTip);
volumnColumnData.getColumn().pack();
setColumnSorter(volumnColumnData.getColumn(), ServiceDashboardEditorSorter.Data_ASC, ServiceDashboardEditorSorter.Data_DESC);
TreeViewerColumn volumnColumnIndex = new TreeViewerColumn(serviceTreeViewer, SWT.LEFT);
volumnColumnIndex.getColumn().setText(Messages.columnIndex);
volumnColumnIndex.getColumn().setToolTipText(Messages.columnIndexTip);
volumnColumnIndex.getColumn().pack();
setColumnSorter(volumnColumnIndex.getColumn(), ServiceDashboardEditorSorter.Index_ASC, ServiceDashboardEditorSorter.Index_DESC);
TreeViewerColumn volumnColumnTemp = new TreeViewerColumn(serviceTreeViewer, SWT.LEFT);
volumnColumnTemp.getColumn().setText(Messages.columnTemp);
volumnColumnTemp.getColumn().setToolTipText(Messages.columnTempTip);
volumnColumnTemp.getColumn().pack();
setColumnSorter(volumnColumnTemp.getColumn(), ServiceDashboardEditorSorter.Temp_ASC, ServiceDashboardEditorSorter.Temp_DESC);
TreeViewerColumn volumnColumnGeneric = new TreeViewerColumn(serviceTreeViewer, SWT.LEFT);
volumnColumnGeneric.getColumn().setText(Messages.columnGeneric);
volumnColumnGeneric.getColumn().setToolTipText(Messages.columnGenericTip);
volumnColumnGeneric.getColumn().pack();
setColumnSorter(volumnColumnGeneric.getColumn(), ServiceDashboardEditorSorter.Generic_ASC, ServiceDashboardEditorSorter.Generic_DESC);
TreeColumn tpsColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
tpsColumn.setText(Messages.columnTps);
tpsColumn.setWidth(50);
setColumnSorter(tpsColumn, ServiceDashboardEditorSorter.Tps_ASC, ServiceDashboardEditorSorter.Tps_DESC);
TreeColumn qpsColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
qpsColumn.setText(Messages.columnQps);
qpsColumn.setWidth(50);
setColumnSorter(qpsColumn, ServiceDashboardEditorSorter.Qps_ASC, ServiceDashboardEditorSorter.Qps_DESC);
TreeColumn errorColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
errorColumn.setText(Messages.columnErrorQ);
errorColumn.setWidth(50);
setColumnSorter(errorColumn, ServiceDashboardEditorSorter.ErrorQ_ASC, ServiceDashboardEditorSorter.ErrorQ_DESC);
TreeColumn memColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
memColumn.setText(Messages.columnMemory);
memColumn.setWidth(100);
setColumnSorter(memColumn, ServiceDashboardEditorSorter.Memory_ASC, ServiceDashboardEditorSorter.Memory_DESC);
TreeColumn diskColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
diskColumn.setText(Messages.columnDisk);
diskColumn.setWidth(60);
setColumnSorter(diskColumn, ServiceDashboardEditorSorter.Disk_ASC, ServiceDashboardEditorSorter.Disk_DESC);
TreeColumn cpuColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
cpuColumn.setText(Messages.columnCpu);
cpuColumn.pack();
setColumnSorter(cpuColumn, ServiceDashboardEditorSorter.Cpu_ASC, ServiceDashboardEditorSorter.Cpu_DESC);
TreeColumn dbColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
dbColumn.setText(Messages.columnDbOnOff);
dbColumn.setWidth(80);
setColumnSorter(dbColumn, ServiceDashboardEditorSorter.DbStatus_ASC, ServiceDashboardEditorSorter.DbStatus_DESC);
TreeColumn verColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
verColumn.setText(Messages.columnVersion);
verColumn.setWidth(70);
setColumnSorter(verColumn, ServiceDashboardEditorSorter.Version_ASC, ServiceDashboardEditorSorter.Version_DESC);
TreeColumn brokerPortColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
brokerPortColumn.setText(Messages.columnBrokerPort);
brokerPortColumn.setWidth(120);
setColumnSorter(brokerPortColumn, ServiceDashboardEditorSorter.BrokerPort_ASC, ServiceDashboardEditorSorter.BrokerPort_DESC);
serviceTreeViewer.setContentProvider(new ServiceDashboardContentProvider());
serviceTreeViewer.setLabelProvider(new ServiceDashboardLabelProvider());
addCellTip(volumnColumnData, 1);
addCellTip(volumnColumnIndex, 2);
addCellTip(volumnColumnTemp, 3);
addCellTip(volumnColumnGeneric, 4);
serviceTreeViewer.getTree().addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
}
public void mouseDown(MouseEvent e) {
}
public void mouseDoubleClick(MouseEvent e) {
CubridServer[] servers = getSelectedServer();
if (servers.length == 1) {
if (!servers[0].isConnected()) {
ActionManager manager = ActionManager.getInstance();
final ConnectHostAction connectHostAction = (ConnectHostAction) manager.getAction(ConnectHostAction.ID);
connectHostAction.doRun(getSelectedServer());
loadAllData();
}
}
}
});
initMenu(serviceTreeViewer.getTree());
}
use of org.eclipse.swt.events.MouseListener in project cubrid-manager by CUBRID.
the class JdbcOptionComposite method createButtonComp.
/**
*
* Create button composite
*
* @param composite the composite
*/
private void createButtonComp(Composite composite) {
Composite buttonComposite = new Composite(composite, SWT.NONE);
{
GridLayout layout = new GridLayout();
layout.numColumns = 3;
buttonComposite.setLayout(layout);
buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
}
Hyperlink link = new Hyperlink(buttonComposite, SWT.None);
link.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
link.setText(Messages.titleJdbcAdvancedOptionView);
link.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
try {
IWebBrowser br = browserSupport.createBrowser(null);
br.openURL(new URL(Messages.msgCubridJdbcInfoUrl));
} catch (Exception ignored) {
}
}
public void mouseDown(MouseEvent e) {
}
public void mouseDoubleClick(MouseEvent e) {
}
});
addButton = new Button(buttonComposite, SWT.PUSH);
addButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
addButton.setText(Messages.btnAdd);
addButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
TableItem itemNew = new TableItem(jdbcInfoTv.getTable(), SWT.SINGLE);
int newIndex = jdbcInfoTv.getTable().getItemCount() - 1;
focusCell(itemNew, newIndex, 0);
}
});
Button delButton = new Button(buttonComposite, SWT.PUSH);
delButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
delButton.setText(Messages.btnDelete);
delButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
TableItem[] selection = jdbcInfoTv.getTable().getSelection();
if (selection == null || selection.length == 0) {
return;
}
jdbcInfoTv.getTable().setSelection(-1);
for (TableItem item : selection) {
item.dispose();
}
}
});
}
use of org.eclipse.swt.events.MouseListener in project tdi-studio-se by Talend.
the class TalendPaletteViewer method configListeners.
/**
* yzhang Comment method "configListeners".
*
* @param text
*/
private void configListeners(final Text text) {
text.addMouseListener(new MouseListener() {
@Override
public void mouseDoubleClick(MouseEvent e) {
}
@Override
public void mouseDown(MouseEvent e) {
if (text.getText().equals(SEARCH_COMPONENT)) {
//$NON-NLS-1$
text.setText("");
}
}
@Override
public void mouseUp(MouseEvent e) {
}
});
text.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// text.setText(""); //$NON-NLS-1$
}
@Override
public void focusLost(FocusEvent e) {
if (text.getText() == "") {
//$NON-NLS-1$
text.setText(SEARCH_COMPONENT);
}
}
});
text.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
startFiltering(text);
}
});
}
Aggregations