use of org.eclipse.jface.viewers.DoubleClickEvent in project cubrid-manager by CUBRID.
the class TableContentProvider method createPartControl.
/**
* Create part controls
*
* @param parent of the controls
*
*/
public void createPartControl(Composite parent) {
Composite backPanel = new Composite(parent, SWT.NONE);
backPanel.setLayout(new GridLayout(1, false));
backPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
Composite progressPanel = new Composite(backPanel, SWT.NONE);
progressPanel.setLayout(new GridLayout(3, false));
progressPanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
progressIndicator = new ProgressIndicator(progressPanel, SWT.NONE);
progressIndicator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
btnStop = new Button(progressPanel, SWT.NONE);
btnStop.setText(Messages.btnStop);
btnStop.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_run_stop.png"));
btnStop.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
processStop();
}
});
openLogFolderButton = new Button(progressPanel, SWT.NONE);
openLogFolderButton.setText(Messages.runSQLOpenBtn);
openLogFolderButton.setEnabled(false);
openLogFolderButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
java.awt.Desktop.getDesktop().open(new File(importConfig.getErrorLogFolderPath()));
} catch (IOException e) {
e.printStackTrace();
}
}
});
progressTableViewer = new TableViewer(backPanel, SWT.BORDER | SWT.FULL_SELECTION);
progressTableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
progressTableViewer.getTable().setLinesVisible(true);
progressTableViewer.getTable().setHeaderVisible(true);
final TableViewerColumn tableName = new TableViewerColumn(progressTableViewer, SWT.NONE);
final TableViewerColumn totalCount = new TableViewerColumn(progressTableViewer, SWT.NONE);
final TableViewerColumn parseCount = new TableViewerColumn(progressTableViewer, SWT.NONE);
final TableViewerColumn failedCount = new TableViewerColumn(progressTableViewer, SWT.NONE);
final TableViewerColumn status = new TableViewerColumn(progressTableViewer, SWT.NONE);
final TableViewerColumn elapsedTime = new TableViewerColumn(progressTableViewer, SWT.NONE);
final TableViewerColumn buttonColumn = new TableViewerColumn(progressTableViewer, SWT.NONE);
tableName.getColumn().setWidth(250);
tableName.getColumn().setText(Messages.columnName);
totalCount.getColumn().setWidth(100);
totalCount.getColumn().setText(Messages.columnCount);
parseCount.getColumn().setWidth(100);
parseCount.getColumn().setText(Messages.columnFinished);
failedCount.getColumn().setWidth(100);
failedCount.getColumn().setText(Messages.columnFailed);
status.getColumn().setWidth(100);
status.getColumn().setText(Messages.columnStatus);
elapsedTime.getColumn().setWidth(130);
elapsedTime.getColumn().setText(Messages.columnTime);
buttonColumn.getColumn().setWidth(90);
progressTableViewer.setContentProvider(new TableContentProvider());
progressTableViewer.setLabelProvider(new TableLabelProvider());
progressTableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
ImportMonitor monitor = (ImportMonitor) selection.getFirstElement();
openViewDialog(monitor);
}
});
Composite historyComposite = new Composite(backPanel, SWT.NONE);
historyComposite.setLayout(new GridLayout(4, false));
historyComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
historyLabel = new Label(historyComposite, SWT.NONE);
historyLabel.setText(Messages.lblHistory);
historyText = new Text(historyComposite, SWT.BORDER);
historyText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
saveButton = new Button(historyComposite, SWT.NONE);
saveButton.setText(Messages.btnSaveAndClose);
saveButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (historyText.getText().trim().length() == 0) {
CommonUITool.openErrorBox(Messages.errHistoryEmpty);
return;
}
if (ImportConfigManager.getInstance().getConfig(historyText.getText()) != null) {
CommonUITool.openErrorBox(Messages.errHistoryExist);
return;
}
importConfig.setName(historyText.getText().trim());
ImportConfigManager.getInstance().addConfig(importConfig);
close();
}
});
closeButton = new Button(historyComposite, SWT.NONE);
closeButton.setText(Messages.btnClose);
closeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
close();
}
});
setHistroyWidgetStatus(false);
init();
}
use of org.eclipse.jface.viewers.DoubleClickEvent in project cubrid-manager by CUBRID.
the class TableEditorPart method createPartitionTabItem.
private void createPartitionTabItem(final TabFolder tabFolder) {
loadPartitionInfoList();
final TabItem partTabItem = new TabItem(tabFolder, SWT.NONE);
final Composite parentComp = new Composite(tabFolder, SWT.NONE);
{
GridLayout gd = new GridLayout();
parentComp.setLayout(gd);
}
partTabItem.setControl(parentComp);
partTabItem.setText(Messages.tabItemPartition);
partitionTableView = new TableViewer(parentComp, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
final Table partitionTable = partitionTableView.getTable();
{
partitionTable.setLayout(TableViewUtil.createTableViewLayout(new int[] { 20, 15, 10, 20, 25, 10 }));
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 350;
partitionTable.setLayoutData(gd);
}
partitionTable.setHeaderVisible(true);
partitionTable.setLinesVisible(true);
CommonUITool.hackForYosemite(partitionTable);
TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColTableName);
TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColPartitionName);
TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColType);
TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColExpr);
TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColExprValue);
TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColRows);
partitionTableView.setLabelProvider(new PartitionTableLabelProvider());
partitionTableView.setContentProvider(new PartitionContentProvider());
partitionTableView.setInput(partitionInfoList);
partitionTableView.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
editPartition();
}
});
tabFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
if (tabFolder.getSelection()[0].getText().equals(Messages.tabItemPartition)) {
partitionTableView.refresh();
}
}
});
createPartitionTabButtons(parentComp);
}
use of org.eclipse.jface.viewers.DoubleClickEvent 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.DoubleClickEvent 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.DoubleClickEvent 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