use of org.eclipse.swt.events.MenuEvent in project cubrid-manager by CUBRID.
the class ServiceDashboardEditor method initMenu.
private void initMenu(Tree tree) {
ActionManager manager = ActionManager.getInstance();
Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
tree.setMenu(menu);
refreshMenuItem = new MenuItem(menu, SWT.PUSH);
refreshMenuItem.setText(Messages.btnRefresh);
refreshMenuItem.setImage(CubridManagerUIPlugin.getImage("icons/action/refresh.png"));
refreshMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
loadAllData();
}
});
new MenuItem(menu, SWT.SEPARATOR);
final ConnectHostAction connectHostAction = (ConnectHostAction) manager.getAction(ConnectHostAction.ID);
connectMenuItem = new MenuItem(menu, SWT.PUSH);
connectMenuItem.setText(connectHostAction.getText());
connectMenuItem.setImage(connectHostAction.getImageDescriptor().createImage());
connectMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
connectHostAction.doRun(getSelectedServer());
loadAllData();
}
});
final DisConnectHostAction disConnectHostAction = (DisConnectHostAction) manager.getAction(DisConnectHostAction.ID);
disConnectMenuItem = new MenuItem(menu, SWT.PUSH);
disConnectMenuItem.setText(disConnectHostAction.getText());
disConnectMenuItem.setImage(disConnectHostAction.getImageDescriptor().createImage());
disConnectMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
disConnectHostAction.doRun(getSelectedServer());
loadAllData();
}
});
new MenuItem(menu, SWT.SEPARATOR);
final AddHostAction addHostAction = (AddHostAction) manager.getAction(AddHostAction.ID);
addHostMenuItem = new MenuItem(menu, SWT.PUSH);
addHostMenuItem.setText(addHostAction.getText());
addHostMenuItem.setImage(addHostAction.getImageDescriptor().createImage());
addHostMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
addHostAction.doRun(getSelectedServer());
loadAllData();
}
});
final EditHostAction editHostAction = (EditHostAction) manager.getAction(EditHostAction.ID);
editHostMenuItem = new MenuItem(menu, SWT.PUSH);
editHostMenuItem.setText(editHostAction.getText());
editHostMenuItem.setImage(editHostAction.getImageDescriptor().createImage());
editHostMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
editHostAction.doRun(getSelectedServer(), false);
loadAllData();
}
});
final DeleteHostAction deleteHostAction = (DeleteHostAction) manager.getAction(DeleteHostAction.ID);
deleteHostMenuItem = new MenuItem(menu, SWT.PUSH);
deleteHostMenuItem.setText(deleteHostAction.getText());
deleteHostMenuItem.setImage(deleteHostAction.getImageDescriptor().createImage());
deleteHostMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
deleteHostAction.doRun(getSelectedServer());
loadAllData();
}
});
new MenuItem(menu, SWT.SEPARATOR);
final StartServiceAction startServiceAction = (StartServiceAction) manager.getAction(StartServiceAction.ID);
startServiceMenuItem = new MenuItem(menu, SWT.PUSH);
startServiceMenuItem.setText(startServiceAction.getText());
startServiceMenuItem.setImage(startServiceAction.getImageDescriptor().createImage());
startServiceMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
startServiceAction.doRun(getSelectedServer());
loadAllData();
}
});
final StopServiceAction stopServiceAction = (StopServiceAction) manager.getAction(StopServiceAction.ID);
stopServiceMenuItem = new MenuItem(menu, SWT.PUSH);
stopServiceMenuItem.setText(stopServiceAction.getText());
stopServiceMenuItem.setImage(stopServiceAction.getImageDescriptor().createImage());
stopServiceMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
stopServiceAction.doRun(getSelectedServer());
loadAllData();
}
});
menu.addMenuListener(new MenuListener() {
public void menuShown(MenuEvent e) {
updateMenuItems();
}
public void menuHidden(MenuEvent e) {
}
});
}
use of org.eclipse.swt.events.MenuEvent 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;
}
use of org.eclipse.swt.events.MenuEvent in project dbeaver by dbeaver.
the class ToolsContextMenuHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
final Shell activeShell = HandlerUtil.getActiveShell(event);
if (part == null || activeShell == null) {
return null;
}
final Control focusControl = activeShell.getDisplay().getFocusControl();
if (focusControl == null) {
return null;
}
Point location = getLocationFromControl(activeShell, focusControl);
if (menuManager != null) {
menuManager.dispose();
}
menuManager = new MenuManager();
menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_CONNECT));
menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_DISCONNECT));
menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_INVALIDATE));
if (part instanceof IEditorPart) {
menuManager.add(new Separator());
menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_COMMIT));
menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_ROLLBACK));
{
final MenuManager txnMenu = new MenuManager(DBeaverActivator.getPluginResourceBundle().getString("command.org.jkiss.dbeaver.core.transaction_mode.name"));
txnMenu.add(new DataSourceTransactionModeContributor());
menuManager.add(txnMenu);
}
}
menuManager.add(new Separator());
{
menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_SQL_EDITOR_OPEN));
/*
final MenuManager toolsMenu = new MenuManager(
DBeaverActivator.getPluginResourceBundle().getString("menu.database.tools"));
toolsMenu.add(new DataSourceToolsContributor());
menuManager.add(toolsMenu);
*/
}
if (part instanceof IEditorPart) {
menuManager.add(ActionUtils.makeCommandContribution(part.getSite(), CoreCommands.CMD_LINK_EDITOR, "Find in navigator", null));
}
final Menu contextMenu = menuManager.createContextMenu(focusControl);
if (location != null) {
contextMenu.setLocation(location);
}
contextMenu.setVisible(true);
contextMenu.addMenuListener(new MenuAdapter() {
@Override
public void menuShown(MenuEvent e) {
int keyIndex = 1;
for (MenuItem item : contextMenu.getItems()) {
if (/*item.getMenu() == null && */
!CommonUtils.isEmpty(item.getText())) {
item.setText(String.valueOf(keyIndex) + ". " + item.getText());
keyIndex++;
if (keyIndex >= 10) {
break;
}
}
}
}
});
return null;
}
use of org.eclipse.swt.events.MenuEvent in project core by jcryptool.
the class HexEditorControl method createPopupMenu.
/**
* Creates all items located in the popup menu and associates
* all the menu items with their appropriate functions.
*
* @return Menu The created popup menu.
*/
private Menu createPopupMenu() {
Menu popUpMenu = new Menu(parent.getShell(), SWT.POP_UP);
/**
* Adds a listener to handle enabling and disabling
* some items in the Edit submenu.
*/
popUpMenu.addMenuListener(new MenuAdapter() {
public void menuShown(MenuEvent e) {
Menu menu = (Menu) e.widget;
MenuItem[] items = menu.getItems();
int rowIndex = table.getSelectionIndex();
int columnIndex = cursor.getColumn();
int tableSize = table.getBufferSize();
HexTablePointer p1 = new HexTablePointer(rowIndex, columnIndex - 1);
boolean isOffsetColumn = columnIndex == 0;
boolean isCharacterColumn = columnIndex == EHEP.TABLE_NUM_COLUMNS - 1;
boolean endOfBuffer = p1.getOffset() >= tableSize;
boolean readonly = hexEditor.isReadOnly();
boolean enableInsert = !isOffsetColumn && !isCharacterColumn && !endOfBuffer && !readonly;
boolean enableDelete = !isOffsetColumn && !isCharacterColumn && !endOfBuffer && !readonly;
boolean enableAppend = !readonly;
// insert
items[0].setEnabled(enableInsert);
// append
items[1].setEnabled(enableAppend);
// --- separator ---
items[3].setEnabled(canUndo());
items[4].setEnabled(canRedo());
// --- separator ---
// paste
items[8].setEnabled(canPaste());
// delete
items[9].setEnabled(enableDelete);
// --- separator ---
// goto
items[11].setEnabled(true);
// --- separator ---
// about
items[13].setEnabled(true);
}
});
//
// "Insert" menu item
//
MenuItem item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(Messages.HexEditorControl_37);
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
popupMenuInsertData(table.getSelectionIndex(), cursor.getColumn());
}
});
//
// "Append" menu item
//
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(Messages.HexEditorControl_38);
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
popupMenuAppendData();
}
});
//
// Separator
//
new MenuItem(popUpMenu, SWT.SEPARATOR);
//
// "Undo" and "Redo" menu item
//
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(Messages.HexEditorControl_39);
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
hexEditor.undo();
}
});
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(Messages.HexEditorControl_40);
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
hexEditor.redo();
}
});
//
// Separator
//
new MenuItem(popUpMenu, SWT.SEPARATOR);
Listener copyPasteListener = new Listener() {
public void handleEvent(Event event) {
hexEditor.getEditorSite().getActionBars().getGlobalActionHandler((String) event.widget.getData()).run();
}
};
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(Messages.HexEditorControl_41);
item.setData(ActionFactory.CUT.getId());
item.addListener(SWT.Selection, copyPasteListener);
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(Messages.HexEditorControl_42);
item.setData(ActionFactory.COPY.getId());
item.addListener(SWT.Selection, copyPasteListener);
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(Messages.HexEditorControl_43);
item.setData(ActionFactory.PASTE.getId());
item.addListener(SWT.Selection, copyPasteListener);
//
// "Delete" menu item
//
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(Messages.HexEditorControl_44);
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
popupMenuDeleteData(table.getSelectionIndex(), cursor.getColumn());
}
});
//
// Separator
//
new MenuItem(popUpMenu, SWT.SEPARATOR);
//
// "Goto..." menu item
//
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(Messages.HexEditorControl_45);
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
popupMenuGoto();
}
});
//
// Separator
//
new MenuItem(popUpMenu, SWT.SEPARATOR);
//
// "About" menu item
//
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(Messages.HexEditorControl_46);
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
popupMenuAbout();
}
});
return popUpMenu;
}
use of org.eclipse.swt.events.MenuEvent in project nebula.widgets.nattable by eclipse.
the class FillHandleDragMode method openMenu.
/**
* Opens a menu that enables a user to select whether values should simply
* be copied or if a series should be filled.
*
* @param natTable
* The NatTable instance on which the operation is performed.
*/
protected void openMenu(final NatTable natTable) {
// lazily create the menu
if (this.menu == null || this.menu.isDisposed()) {
this.menu = new Menu(natTable);
MenuItem copyItem = new MenuItem(this.menu, SWT.PUSH);
// $NON-NLS-1$
copyItem.setText(Messages.getLocalizedMessage("%FillHandleDragMode.menu.item.copy"));
copyItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.COPY, FillHandleDragMode.this.direction, natTable.getConfigRegistry()));
}
});
MenuItem seriesItem = new MenuItem(this.menu, SWT.PUSH);
// $NON-NLS-1$
seriesItem.setText(Messages.getLocalizedMessage("%FillHandleDragMode.menu.item.series"));
seriesItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.SERIES, FillHandleDragMode.this.direction, natTable.getConfigRegistry()));
}
});
// add a menu listener to reset the fill state when the menu is
// closed
this.menu.addMenuListener(new MenuAdapter() {
@Override
public void menuHidden(MenuEvent e) {
// perform the reset operation asynchronously because on
// several OS the hide event is processed BEFORE the
// selection event
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
reset(natTable);
}
});
}
});
// add the dispose listener for disposing the menu
natTable.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
FillHandleDragMode.this.menu.dispose();
}
});
}
this.menu.setVisible(true);
}
Aggregations