use of org.eclipse.jface.viewers.IDoubleClickListener in project cubrid-manager by CUBRID.
the class RecentlyUsedSQLComposite method createHistoryTable.
/**
* createHistoryTable
* @param bottomSash
*/
public void createHistoryTable(SashForm bottomSash) {
sqlHistoryTable = new TableViewer(bottomSash, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
sqlHistoryTable.getTable().setHeaderVisible(true);
sqlHistoryTable.getTable().setLinesVisible(true);
// final TableViewerColumn columnNO = new TableViewerColumn(
// sqlHistoryTable, SWT.CENTER);
// columnNO.getColumn().setWidth(40);
// columnNO.getColumn().setText("NO");
final TableViewerColumn columnRunTime = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
columnRunTime.getColumn().setWidth(155);
columnRunTime.getColumn().setText(Messages.recentlyUsedSQLColumnRunTime);
columnRunTime.getColumn().addSelectionListener(new SelectionAdapter() {
boolean asc = true;
@Override
public void widgetSelected(SelectionEvent e) {
sqlHistoryTable.setSorter(asc ? Sorter.EXECUTETIME_ASC : Sorter.EXECUTETIME_DESC);
sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
asc = !asc;
}
});
final TableViewerColumn columnSQL = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
columnSQL.getColumn().setWidth(250);
columnSQL.getColumn().setText(Messages.recentlyUsedSQLColumn);
columnSQL.getColumn().addSelectionListener(new SelectionAdapter() {
boolean asc = true;
@Override
public void widgetSelected(SelectionEvent e) {
sqlHistoryTable.setSorter(asc ? Sorter.SQL_ASC : Sorter.SQL_DEC);
sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
asc = !asc;
}
});
final TableViewerColumn columnElapseTime = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
columnElapseTime.getColumn().setWidth(100);
columnElapseTime.getColumn().setText(Messages.recentlyUsedSQLColumnElapseTime);
columnElapseTime.getColumn().addSelectionListener(new SelectionAdapter() {
boolean asc = true;
@Override
public void widgetSelected(SelectionEvent e) {
sqlHistoryTable.setSorter(asc ? Sorter.ELAPSETIME_ASC : Sorter.ELAPSETIME_DESC);
sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
asc = !asc;
}
});
final TableViewerColumn columnInfo = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
columnInfo.getColumn().setWidth(300);
columnInfo.getColumn().setText(Messages.recentlyUsedSQLColumnLOG);
columnInfo.getColumn().addSelectionListener(new SelectionAdapter() {
boolean asc = true;
@Override
public void widgetSelected(SelectionEvent e) {
sqlHistoryTable.setSorter(asc ? Sorter.LOG_ASC : Sorter.LOG_DESC);
sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
asc = !asc;
}
});
sqlHistoryTable.setContentProvider(new HistorySQLContentProvider());
provider = new HistorySQLLabelProvider();
sqlHistoryTable.setLabelProvider(provider);
sqlHistoryTable.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(final SelectionChangedEvent event) {
SQLHistoryDetail history = (SQLHistoryDetail) sqlHistoryTable.getElementAt(sqlHistoryTable.getTable().getSelectionIndex());
if (history != null) {
logMessageArea.setText(history.getExecuteInfo() + StringUtil.NEWLINE + history.getSql());
}
}
});
sqlHistoryTable.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
SQLHistoryDetail history = (SQLHistoryDetail) selection.getFirstElement();
logMessageArea.setText(history.getExecuteInfo() + StringUtil.NEWLINE + StringUtil.NEWLINE + history.getSql());
int start = editor.getAllQueries().length();
editor.setQuery(StringUtil.NEWLINE + history.getSql(), true, false, false);
int end = start + history.getSql().length();
// "/n" take a postion ,so both start and end should + 1
editor.setSelection(start + 1, end + 1);
}
});
}
use of org.eclipse.jface.viewers.IDoubleClickListener in project cubrid-manager by CUBRID.
the class NewMultiHostConnectionDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
getShell().setText(Messages.multiConnectServerDialogTitle);
Composite parentComp = (Composite) super.createDialogArea(parent);
setTitle(Messages.multiConnectServerDialogTitle);
setMessage(Messages.multiConnectServerDialogMessages);
serverTable = new TableViewer(parentComp, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
serverTable.getTable().setLayoutData(gridData);
serverTable.getTable().setHeaderVisible(true);
serverTable.getTable().setLinesVisible(true);
final TableViewerColumn columnHost = new TableViewerColumn(serverTable, SWT.CENTER);
columnHost.getColumn().setWidth(120);
columnHost.getColumn().setText(Messages.multiConnectServerDialogColumnHostAddress);
final TableViewerColumn columnUser = new TableViewerColumn(serverTable, SWT.CENTER);
columnUser.getColumn().setWidth(200);
columnUser.getColumn().setText(Messages.multiConnectServerDialogColumnUser);
final TableViewerColumn columnErrMsg = new TableViewerColumn(serverTable, SWT.CENTER);
columnErrMsg.getColumn().setWidth(200);
columnErrMsg.getColumn().setText(Messages.multiConnectServerDialogColumnErrMsg);
final TableViewerColumn columnStatus = new TableViewerColumn(serverTable, SWT.CENTER);
columnStatus.getColumn().setWidth(100);
columnStatus.getColumn().setText(Messages.multiConnectServerDialogColumnStatus);
serverTable.setContentProvider(new ServerListContentProvider());
serverTable.setLabelProvider(new ServerListLabelProvider());
serverTable.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
FailedHostServerInfo multiHostConnectionFailedServerInfo = (FailedHostServerInfo) selection.getFirstElement();
editHost(multiHostConnectionFailedServerInfo);
}
});
serverTable.setInput(failedServerList);
MenuManager menuManager = new MenuManager();
Menu contextMenu = menuManager.createContextMenu(serverTable.getTable());
serverTable.getTable().setMenu(contextMenu);
Menu menu = new Menu(getShell(), SWT.POP_UP);
final MenuItem itemEdit = new MenuItem(menu, SWT.PUSH);
itemEdit.setText(Messages.msgConnectHostDialog);
itemEdit.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
IStructuredSelection selection = (StructuredSelection) serverTable.getSelection();
FailedHostServerInfo multiHostConnectionFailedServerInfo = (FailedHostServerInfo) selection.getFirstElement();
editHost(multiHostConnectionFailedServerInfo);
}
});
menu.addMenuListener(new MenuAdapter() {
public void menuShown(MenuEvent event) {
IStructuredSelection selection = (IStructuredSelection) serverTable.getSelection();
FailedHostServerInfo multiHostConnectionFailedServerInfo = (FailedHostServerInfo) selection.getFirstElement();
if (multiHostConnectionFailedServerInfo.getCubridServer().isConnected()) {
itemEdit.setEnabled(false);
} else {
itemEdit.setEnabled(true);
}
}
});
serverTable.getTable().setMenu(menu);
return parentComp;
}
use of org.eclipse.jface.viewers.IDoubleClickListener in project cubrid-manager by CUBRID.
the class DatabaseLogListDialog method createTable.
/**
*
* Create table area
*
* @param parent the parent composite
*/
private void createTable(Composite parent) {
Label tipLabel = new Label(parent, SWT.LEFT | SWT.WRAP);
tipLabel.setText(Messages.lblDbLogListInfo);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
tipLabel.setLayoutData(gridData);
final String[] columnNameArr = new String[] { Messages.colDbLog };
dbLogTableViewer = CommonUITool.createCommonTableViewer(parent, new LogTableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, 200));
dbLogTable = dbLogTableViewer.getTable();
for (int i = 0; i < dbLogTable.getColumnCount(); i++) {
dbLogTable.getColumn(i).pack();
}
dbLogTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
getButton(IDialogConstants.OK_ID).setEnabled(dbLogTable.getSelectionCount() > 0);
}
});
dbLogTableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
openLogEditor();
}
});
dbLogTableViewer.setInput(dbLogList);
}
use of org.eclipse.jface.viewers.IDoubleClickListener in project cubrid-manager by CUBRID.
the class EditMultiHostStatisticItemDialog method createDialogArea.
/**
* Creates and returns the contents of the upper part of this dialog (above
* the button bar).
*
* @param parent The parent composite to contain the dialog area
* @return the dialog area control
*/
protected Control createDialogArea(Composite parent) {
final Composite parentComp = (Composite) super.createDialogArea(parent);
final int DEFAULT_WIDTH = 80;
Composite compHost = new Composite(parentComp, SWT.RESIZE);
compHost.setLayout(new FillLayout());
compHost.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
hostTableViewer = new TableViewer(compHost, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
hostTableViewer.getTable().setHeaderVisible(true);
hostTableViewer.getTable().setLinesVisible(true);
hostTableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
TableItem[] tableItems = hostTableViewer.getTable().getSelection();
StatisticChartHost hostItem = (StatisticChartHost) tableItems[0].getData();
openAddStatisticHostDialog(hostItem, hostList.size() == 1, false);
}
});
//Host Name
final TableViewerColumn nameColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
nameColumn.getColumn().setWidth(DEFAULT_WIDTH);
nameColumn.getColumn().setText(Messages.lblHostName);
//IP
final TableViewerColumn ipColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
ipColumn.getColumn().setWidth(DEFAULT_WIDTH);
ipColumn.getColumn().setText(Messages.lblIp);
//Port
final TableViewerColumn portColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
portColumn.getColumn().setWidth(50);
portColumn.getColumn().setText(Messages.lblPort);
//Data Type
final TableViewerColumn dataTypeColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
dataTypeColumn.getColumn().setWidth(DEFAULT_WIDTH);
dataTypeColumn.getColumn().setText(Messages.lblDataType);
//Time Type
final TableViewerColumn timeTypeColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
timeTypeColumn.getColumn().setWidth(DEFAULT_WIDTH);
timeTypeColumn.getColumn().setText(Messages.lblTimeType);
//Database Name
final TableViewerColumn dbNameColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
dbNameColumn.getColumn().setWidth(DEFAULT_WIDTH);
dbNameColumn.getColumn().setText(Messages.lblDbName);
//Database Volume Name
final TableViewerColumn volNameColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
volNameColumn.getColumn().setWidth(DEFAULT_WIDTH);
volNameColumn.getColumn().setText(Messages.lblVolName);
//Broker Name
final TableViewerColumn brokerColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
brokerColumn.getColumn().setWidth(DEFAULT_WIDTH);
brokerColumn.getColumn().setText(Messages.lblBrokerName);
//Metric
final TableViewerColumn metricColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
metricColumn.getColumn().setWidth(DEFAULT_WIDTH);
metricColumn.getColumn().setText(Messages.lblMetric);
hostTableViewer.setContentProvider(new HostTableViewerContentProvider());
hostTableViewer.setLabelProvider(new HostTableViewerLabelProvider());
hostTableViewer.getTable().addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(hostTableViewer.getTable());
}
});
hostTableViewer.getTable().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TableItem[] items = hostTableViewer.getTable().getSelection();
btnEditHost.setEnabled(items.length > 0);
btnDeleteHost.setEnabled(items.length > 0);
}
});
Composite compBtn = new Composite(parentComp, SWT.RESIZE);
GridLayout layoutCompBtn = new GridLayout(6, false);
layoutCompBtn.marginRight = 0;
// layoutCompBtn.numColumns = 6;
layoutCompBtn.marginWidth = 0;
compBtn.setLayout(layoutCompBtn);
compBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
btnAddHost = new Button(compBtn, SWT.NONE);
btnAddHost.setText(Messages.btnAddHost);
btnAddHost.addSelectionListener(new ButtonAddHostAdapter());
btnEditHost = new Button(compBtn, SWT.NONE);
btnEditHost.setText(Messages.btnEditHost);
btnEditHost.addSelectionListener(new ButtonEditHostAdapter());
btnEditHost.setEnabled(false);
btnDeleteHost = new Button(compBtn, SWT.NONE);
btnDeleteHost.setText(Messages.btnDelHost);
btnDeleteHost.addSelectionListener(new ButtonDeleteHostAdapter());
btnDeleteHost.setEnabled(false);
if (!isNew && statisticChartItem != null) {
MultiHostChartItem multiHostChartItem = (MultiHostChartItem) statisticChartItem;
type = multiHostChartItem.getType();
timeType = TimeType.getEnumByType(multiHostChartItem.getDType());
hostList = multiHostChartItem.getHostList();
hostTableViewer.setInput(hostList);
} else {
hostList = new ArrayList<StatisticChartHost>();
}
return parentComp;
}
use of org.eclipse.jface.viewers.IDoubleClickListener in project cubrid-manager by CUBRID.
the class MultiDatabaseLoginFailedDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
getShell().setText(Messages.multiDatabaseLoginDialogTitle);
Composite parentComp = (Composite) super.createDialogArea(parent);
setTitle(Messages.multiDatabaseLoginDialogTitle);
setMessage(Messages.multiDatabaseLoginDialogMessages);
databaseTable = new TableViewer(parentComp, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
databaseTable.getTable().setLayoutData(gridData);
databaseTable.getTable().setHeaderVisible(true);
databaseTable.getTable().setLinesVisible(true);
final TableViewerColumn columnHost = new TableViewerColumn(databaseTable, SWT.CENTER);
columnHost.getColumn().setWidth(120);
columnHost.getColumn().setText(Messages.multiDatabaseLoginDialogColumnHostAddress);
final TableViewerColumn columnDatabase = new TableViewerColumn(databaseTable, SWT.CENTER);
columnDatabase.getColumn().setWidth(150);
columnDatabase.getColumn().setText(Messages.multiDatabaseLoginDialogColumnDbName);
final TableViewerColumn columnUser = new TableViewerColumn(databaseTable, SWT.CENTER);
columnUser.getColumn().setWidth(100);
columnUser.getColumn().setText(Messages.multiDatabaseLoginDialogColumnUser);
final TableViewerColumn columnErrMsg = new TableViewerColumn(databaseTable, SWT.CENTER);
columnErrMsg.getColumn().setWidth(200);
columnErrMsg.getColumn().setText(Messages.multiDatabaseLoginDialogColumnErrMsg);
final TableViewerColumn columnStatus = new TableViewerColumn(databaseTable, SWT.CENTER);
columnStatus.getColumn().setWidth(100);
columnStatus.getColumn().setText(Messages.multiDatabaseLoginDialogColumnStatus);
databaseTable.setContentProvider(new ServerListContentProvider());
databaseTable.setLabelProvider(new ServerListLabelProvider());
databaseTable.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo = (MultiDatabaseloginFailedInfo) selection.getFirstElement();
editHost(multiDatabaseloginFailedInfo);
//if all database login , close this dialog
if (checkAllDatabaseLogin()) {
close();
}
}
});
databaseTable.setInput(failedDatabaseList);
MenuManager menuManager = new MenuManager();
Menu contextMenu = menuManager.createContextMenu(databaseTable.getTable());
databaseTable.getTable().setMenu(contextMenu);
Menu menu = new Menu(getShell(), SWT.POP_UP);
final MenuItem itemEdit = new MenuItem(menu, SWT.PUSH);
itemEdit.setText(Messages.multiDatabaseLoginDialogEditLabel);
itemEdit.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
IStructuredSelection selection = (StructuredSelection) databaseTable.getSelection();
MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo = (MultiDatabaseloginFailedInfo) selection.getFirstElement();
editHost(multiDatabaseloginFailedInfo);
}
});
menu.addMenuListener(new MenuAdapter() {
public void menuShown(MenuEvent event) {
IStructuredSelection selection = (IStructuredSelection) databaseTable.getSelection();
MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo = (MultiDatabaseloginFailedInfo) selection.getFirstElement();
if (multiDatabaseloginFailedInfo.getCubridDatabase().isLogined()) {
itemEdit.setEnabled(false);
} else {
itemEdit.setEnabled(true);
}
}
});
databaseTable.getTable().setMenu(menu);
databaseTable.getTable().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (databaseTable.getTable().getSelectionIndices().length > 0) {
getButton(EDIT_ID).setEnabled(true);
} else {
getButton(EDIT_ID).setEnabled(false);
}
}
});
return parentComp;
}
Aggregations