use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.
the class FavoriteQueryNavigatorView method createContextMenu.
private void createContextMenu() {
final MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
final Menu contextMenu = menuManager.createContextMenu(tv.getTable());
tv.getTable().setMenu(contextMenu);
final Menu popupMenu = new Menu(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.POP_UP);
tv.getTable().setMenu(popupMenu);
final MenuItem openMenuItem = new MenuItem(popupMenu, SWT.PUSH);
openMenuItem.setText(com.cubrid.common.ui.query.Messages.lblOpenSqlFavorite);
openMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
ISelection selection = tv.getSelection();
openSelectedFile(selection);
}
});
final MenuItem runMenuItem = new MenuItem(popupMenu, SWT.PUSH);
runMenuItem.setText(com.cubrid.common.ui.query.Messages.lblRunSqlFavorite);
runMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
executeSql();
}
});
new MenuItem(popupMenu, SWT.SEPARATOR);
final MenuItem addMenuItem = new MenuItem(popupMenu, SWT.PUSH);
addMenuItem.setText(Messages.btnAdd);
addMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
addFile();
}
});
new MenuItem(popupMenu, SWT.SEPARATOR);
final MenuItem removeMenuItem = new MenuItem(popupMenu, SWT.PUSH);
removeMenuItem.setText(com.cubrid.common.ui.query.Messages.lblRemoveFromSqlFavorite);
removeMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (!CommonUITool.openConfirmBox(com.cubrid.common.ui.query.Messages.errBatchRunDel)) {
return;
}
removeFavorite();
}
});
final MenuItem delMenuItem = new MenuItem(popupMenu, SWT.PUSH);
delMenuItem.setText(com.cubrid.common.ui.query.Messages.lblDeleteFromSqlFavorite);
delMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (!CommonUITool.openConfirmBox(com.cubrid.common.ui.query.Messages.errBatchRunDelWithFile)) {
return;
}
removeFavoriteWithFileDeletion();
}
});
popupMenu.addMenuListener(new MenuListener() {
public void menuShown(MenuEvent e) {
if (tv.getTable().getSelection().length == 0) {
openMenuItem.setEnabled(false);
runMenuItem.setEnabled(false);
removeMenuItem.setEnabled(false);
delMenuItem.setEnabled(false);
} else {
openMenuItem.setEnabled(true);
runMenuItem.setEnabled(true);
removeMenuItem.setEnabled(true);
delMenuItem.setEnabled(true);
}
}
public void menuHidden(MenuEvent e) {
}
});
}
use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.
the class CubridColumnNavigatorView method createPartControl.
public void createPartControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
{
GridLayout gl = new GridLayout(1, false);
comp.setLayout(gl);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
comp.setLayoutData(gd);
}
lblSchemaName = new Label(comp, SWT.NONE);
lblSchemaName.setText(com.cubrid.common.ui.common.Messages.lblQuickViewColInfo);
{
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
lblSchemaName.setLayoutData(gd);
}
tableColTableViewer = new TableViewer(comp, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
{
GridData gd = new GridData(GridData.FILL_BOTH);
tableColTableViewer.getTable().setLayoutData(gd);
tableColTableViewer.getTable().setToolTipText(com.cubrid.common.ui.common.Messages.miniSchemaCopyColumnTooltip);
final MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
final Menu contextMenu = menuManager.createContextMenu(tableColTableViewer.getTable());
tableColTableViewer.getTable().setMenu(contextMenu);
final Menu copyMenu = new Menu(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.POP_UP);
tableColTableViewer.getTable().setMenu(copyMenu);
tableColTableViewer.getTable().addKeyListener(new org.eclipse.swt.events.KeyAdapter() {
public void keyPressed(org.eclipse.swt.events.KeyEvent event) {
if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0 && event.keyCode == 'c') {
copyColumnListToClipboard(",");
}
}
});
final MenuItem copyMenuItem = new MenuItem(copyMenu, SWT.PUSH);
copyMenuItem.setText(com.cubrid.common.ui.common.Messages.miniSchemaCopyColumnWithComma);
copyMenuItem.setAccelerator(SWT.CTRL + 'C');
copyMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
copyColumnListToClipboard(",");
}
});
final MenuItem copyMenuItem2 = new MenuItem(copyMenu, SWT.PUSH);
copyMenuItem2.setText(com.cubrid.common.ui.common.Messages.miniSchemaCopyColumnWithNewline);
copyMenuItem2.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
copyColumnListToClipboard(StringUtil.NEWLINE);
}
});
new MenuItem(copyMenu, SWT.SEPARATOR);
final MenuItem copyMenuItem3 = new MenuItem(copyMenu, SWT.PUSH);
copyMenuItem3.setText(com.cubrid.common.ui.common.Messages.miniSchemaCopySelectQuery);
copyMenuItem3.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
copySelectSQLToClipboard();
}
});
final MenuItem copyMenuItem4 = new MenuItem(copyMenu, SWT.PUSH);
copyMenuItem4.setText(com.cubrid.common.ui.common.Messages.miniSchemaCopyInsertQuery);
copyMenuItem4.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
copyInsertSQLToClipboard();
}
});
final MenuItem copyMenuItem5 = new MenuItem(copyMenu, SWT.PUSH);
copyMenuItem5.setText(com.cubrid.common.ui.common.Messages.miniSchemaCopyUpdateQuery);
copyMenuItem5.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
copyUpdateSQLToClipboard();
}
});
}
Table columnsTable = tableColTableViewer.getTable();
columnsTable.setLinesVisible(true);
columnsTable.setHeaderVisible(true);
final TableColumn pkColumn = new TableColumn(columnsTable, SWT.NONE);
pkColumn.setAlignment(SWT.CENTER);
pkColumn.setWidth(30);
pkColumn.setText(Messages.tblColumnPK);
final TableColumn nameColumn = new TableColumn(columnsTable, SWT.NONE);
nameColumn.setWidth(90);
nameColumn.setText(Messages.tblColumnName);
final TableColumn dataTypeColumn = new TableColumn(columnsTable, SWT.NONE);
dataTypeColumn.setWidth(120);
dataTypeColumn.setText(Messages.tblColumnDataType);
final TableColumn defaultColumn = new TableColumn(columnsTable, SWT.NONE);
defaultColumn.setWidth(98);
defaultColumn.setText(Messages.tblColumnDefault);
final TableColumn autoIncrTableColumn = new TableColumn(columnsTable, SWT.NONE);
autoIncrTableColumn.setAlignment(SWT.CENTER);
autoIncrTableColumn.setWidth(100);
autoIncrTableColumn.setText(Messages.tblColumnAutoIncr);
final TableColumn notNullColumn = new TableColumn(columnsTable, SWT.NONE);
notNullColumn.setWidth(70);
notNullColumn.setText(Messages.tblColumnNotNull);
notNullColumn.setAlignment(SWT.CENTER);
final TableColumn uniqueColumn = new TableColumn(columnsTable, SWT.NONE);
uniqueColumn.setWidth(70);
uniqueColumn.setText(Messages.tblColumnUnique);
uniqueColumn.setAlignment(SWT.CENTER);
final TableColumn sharedColumn = new TableColumn(columnsTable, SWT.NONE);
sharedColumn.setWidth(60);
sharedColumn.setResizable(false);
sharedColumn.setText(Messages.tblColumnShared);
sharedColumn.setAlignment(SWT.CENTER);
final TableColumn inheritColumn = new TableColumn(columnsTable, SWT.NONE);
inheritColumn.setAlignment(SWT.CENTER);
inheritColumn.setWidth(90);
inheritColumn.setResizable(false);
inheritColumn.setText(Messages.tblColumnInherit);
final TableColumn classColumn = new TableColumn(columnsTable, SWT.NONE);
classColumn.setWidth(90);
classColumn.setResizable(false);
classColumn.setText(Messages.tblColumnClass);
classColumn.setAlignment(SWT.CENTER);
}
use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method registerCubridCMConfTableContextMenu.
/**
* register CubridCMConfTable context menu
*/
private void registerCubridCMConfTableContextMenu() {
cubridCMConfTabTableViewer.getTable().addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(cubridCMConfTabTableViewer.getTable());
}
});
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
Menu contextMenu = menuManager.createContextMenu(cubridCMConfTabTableViewer.getTable());
cubridCMConfTabTableViewer.getTable().setMenu(contextMenu);
Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
final MenuItem itemEditAnnotation = new MenuItem(menu, SWT.PUSH);
itemEditAnnotation.setText(Messages.confEditorTableMenuEditAnnotation);
itemEditAnnotation.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("all")
public void widgetSelected(SelectionEvent event) {
//seems like MenuEvent can't get the mouse click Point
//so use the point which table MouseDown event marked
Point pt = cubridCMConfTableClickPoint;
int selectIndex = cubridCMConfTabTableViewer.getTable().getSelectionIndex();
final TableItem item = cubridCMConfTabTableViewer.getTable().getItem(selectIndex);
if (item == null) {
return;
}
for (int i = 0; i < cubridCMConfTabTableViewer.getTable().getColumnCount(); i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
if (i == 0) {
CommonUITool.openErrorBox(getSite().getShell(), Messages.annotationDialogOpenErrorMsg);
return;
}
IStructuredSelection selection = (IStructuredSelection) cubridCMConfTabTableViewer.getSelection();
HashMap<String, String> valueMap = (HashMap<String, String>) selection.getFirstElement();
String serverName = cubridConfCMConfigListData.get(0).get(i + "");
String parentPropertyKey = valueMap.get("0");
String parentKey = " ";
Map<String, String> cubridMap = cubridConfCMConfigListData.get(1);
String cubridName = "";
if (cubridMap != null) {
cubridName = cubridMap.get(i + "");
}
if (selectIndex == 0) {
parentKey += serverName;
} else {
if (selectIndex == 1) {
parentKey += serverName + "->" + cubridName;
} else {
parentKey += serverName + "->" + cubridName + "->" + parentPropertyKey;
}
}
String annotationKey = Integer.toString(i) + BrokerConfPersistUtil.ANNOTATION;
CubridBrokerConfEditAnnotationDialog dialog = new CubridBrokerConfEditAnnotationDialog(getSite().getShell(), parentKey, annotationKey, valueMap);
if (IDialogConstants.OK_ID == dialog.open()) {
setDirty(true);
}
}
}
}
});
menu.addMenuListener(new MenuAdapter() {
public void menuShown(MenuEvent event) {
//seems like MenuEvent can't get the mouse click Point
//so use the point which table MouseDown event marked
Point pt = cubridCMConfTableClickPoint;
// click timing
if (System.currentTimeMillis() - cubridCMConfTableClickPointTiming > 300) {
itemEditAnnotation.setEnabled(false);
return;
}
int selectIndex = cubridCMConfTabTableViewer.getTable().getSelectionIndex();
if (selectIndex == -1) {
itemEditAnnotation.setEnabled(false);
return;
}
if (selectIndex == 0) {
itemEditAnnotation.setEnabled(false);
return;
}
final TableItem item = cubridCMConfTabTableViewer.getTable().getItem(selectIndex);
if (item == null) {
return;
}
for (int i = 0; i < cubridCMConfTabTableViewer.getTable().getColumnCount(); i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
if (i == 0) {
itemEditAnnotation.setEnabled(false);
} else {
itemEditAnnotation.setEnabled(true);
}
}
}
}
});
cubridCMConfTabTableViewer.getTable().setMenu(menu);
}
use of org.eclipse.jface.action.MenuManager 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.action.MenuManager in project cubrid-manager by CUBRID.
the class UnifyHostConfigDialog method registerContextMenu.
/**
* register context menu
*/
private void registerContextMenu() {
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
Menu contextMenu = menuManager.createContextMenu(hostTableViewer.getTable());
hostTableViewer.getTable().setMenu(contextMenu);
Menu menu = new Menu(getShell(), SWT.POP_UP);
final MenuItem itemDelete = new MenuItem(menu, SWT.PUSH);
itemDelete.setText("delete");
itemDelete.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
List<CubridServer> deleteCubridServer = new ArrayList<CubridServer>();
for (int i = 0; i < hostTableViewer.getTable().getSelectionIndices().length; i++) {
int index = hostTableViewer.getTable().getSelectionIndices()[i];
deleteCubridServer.add(cubridServers[index]);
}
List<CubridServer> hostList = Arrays.asList(cubridServers);
ArrayList<CubridServer> newServerList = new ArrayList<CubridServer>();
for (CubridServer cubridServer : hostList) {
if (deleteCubridServer.contains(cubridServer)) {
continue;
}
newServerList.add(cubridServer);
}
cubridServers = newServerList.toArray(new CubridServer[newServerList.size()]);
setInput();
validate();
}
});
hostTableViewer.getTable().setMenu(menu);
dialogDNDController = new UnifyHostConfigDialogDNDController(this);
dialogDNDController.registerDropTarget();
}
Aggregations