use of org.eclipse.jface.action.MenuManager 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.jface.action.MenuManager in project cubrid-manager by CUBRID.
the class CUBRIDTextEditor method createPartControl.
/**
* Create Part Controls.
*
* @param parent composite.
*/
public void createPartControl(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout());
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
initTextViewer(composite);
undoManager.connect(textViewer);
createActions();
updateActions();
//create context menu
MenuManager contextMenuManager = new MenuManager("#PopupMenu", "CUBRIDTExtEditorContextMenu");
contextMenuManager.setRemoveAllWhenShown(true);
contextMenuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
createContextMenu(manager);
}
});
Menu contextMenu = contextMenuManager.createContextMenu(textViewer.getTextWidget());
textViewer.getTextWidget().setMenu(contextMenu);
IWorkbenchPartSite site = getSite();
site.registerContextMenu(contextMenuManager, textViewer);
site.setSelectionProvider(textViewer);
textViewer.getTextWidget().addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
hookRetargetActions();
}
public void focusLost(FocusEvent event) {
unHookRetargetActions();
}
});
}
use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.
the class ActionAdvisor method showToolbar.
public void showToolbar(ICoolBarManager coolBarManager) {
IToolBarManager newToolbarManager = getToolbarManaeger(coolBarManager);
ActionManager manager = ActionManager.getInstance();
String insertPoint = getToolbarInsertPoint(coolBarManager);
newToolbarManager.insertBefore(insertPoint, createItem(NewQueryConnAction.ID));
newToolbarManager.insertBefore(insertPoint, (createItem(QueryNewAction.ID)));
newToolbarManager.insertBefore(insertPoint, (new Separator()));
newToolbarManager.insertBefore(insertPoint, (createItem(RefreshAction.ID)));
newToolbarManager.insertBefore(insertPoint, (new Separator()));
newToolbarManager.insertBefore(insertPoint, (createItem(NewTableAction.ID)));
newToolbarManager.insertBefore(insertPoint, (createItem(CreateViewAction.ID)));
newToolbarManager.insertBefore(insertPoint, (new Separator()));
newToolbarManager.insertBefore(insertPoint, (createItem(ImportWizardAction.ID)));
newToolbarManager.insertBefore(insertPoint, (createItem(ExportWizardAction.ID)));
newToolbarManager.insertBefore(insertPoint, (new Separator()));
DropDownAction toolsDropAction = new DropDownAction(com.cubrid.common.ui.spi.Messages.toolsActionName, IAction.AS_DROP_DOWN_MENU, Activator.getImageDescriptor("icons/toolbar/qb_tools_on.png"));
toolsDropAction.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/toolbar/qb_tools_off.png"));
MenuManager toolsActionManager = toolsDropAction.getMenuManager();
toolsActionManager.add(manager.getAction(SchemaCompareWizardAction.ID));
toolsActionManager.add(manager.getAction(DataCompareWizardAction.ID));
toolsActionManager.add(new Separator());
toolsActionManager.add(manager.getAction(OpenSchemaEditorAction.ID));
toolsActionManager.add(new Separator());
toolsActionManager.add(manager.getAction(ExportERwinAction.ID));
toolsActionManager.add(manager.getAction(ImportERwinAction.ID));
toolsActionManager.add(new Separator());
toolsActionManager.add(manager.getAction(QueryTunerAction.ID));
ActionContributionItem toolsItem = new ActionContributionItem(toolsDropAction);
toolsItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);
newToolbarManager.insertBefore(insertPoint, toolsItem);
newToolbarManager.insertBefore(insertPoint, new Separator());
newToolbarManager.update(true);
coolBarManager.update(true);
}
use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.
the class ActionAdvisor method showToolbar.
public void showToolbar(ICoolBarManager coolBarManager) {
IToolBarManager newToolbarManager = getToolbarManaeger(coolBarManager);
ActionManager manager = ActionManager.getInstance();
String insertPoint = getToolbarInsertPoint(coolBarManager);
// Add host action
newToolbarManager.insertBefore(insertPoint, createItem(AddHostAction.ID_BIG));
newToolbarManager.insertBefore(insertPoint, new Separator());
// Start action
newToolbarManager.insertBefore(insertPoint, createItem(StartRetargetAction.ID_BIG));
newToolbarManager.insertBefore(insertPoint, new Separator());
// Open queryEditor
newToolbarManager.insertBefore(insertPoint, createItem(DatabaseQueryNewAction.ID_BIG));
// Schema actions
newToolbarManager.insertBefore(insertPoint, new Separator());
DropDownAction schemaDropAction = new DropDownAction(Messages.schemaActionNameBig, IAction.AS_DROP_DOWN_MENU, Activator.getImageDescriptor("icons/toolbar/schema_big.png"));
schemaDropAction.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/toolbar/schema_big.png"));
MenuManager schemaActionManager = schemaDropAction.getMenuManager();
schemaActionManager.add(manager.getAction(NewTableAction.ID));
schemaActionManager.add(manager.getAction(CreateViewAction.ID));
schemaActionManager.add(manager.getAction(CreateSerialAction.ID));
schemaActionManager.add(manager.getAction(NewTriggerAction.ID));
ActionContributionItem schemaItems = new ActionContributionItem(schemaDropAction);
schemaItems.setMode(ActionContributionItem.MODE_FORCE_TEXT);
newToolbarManager.insertBefore(insertPoint, schemaItems);
newToolbarManager.insertBefore(insertPoint, new Separator());
// Import and export
DropDownAction dataDropAction = new DropDownAction(Messages.dataActionNameBig, IAction.AS_DROP_DOWN_MENU, Activator.getImageDescriptor("icons/toolbar/data_big.png"));
dataDropAction.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/toolbar/data_big.png"));
MenuManager dataActionManager = dataDropAction.getMenuManager();
dataActionManager.add(manager.getAction(ExportWizardAction.ID));
dataActionManager.add(manager.getAction(ImportWizardAction.ID));
ActionContributionItem dataItems = new ActionContributionItem(dataDropAction);
dataItems.setMode(ActionContributionItem.MODE_FORCE_TEXT);
newToolbarManager.insertBefore(insertPoint, dataItems);
newToolbarManager.insertBefore(insertPoint, new Separator());
DropDownAction toolsDropAction = new DropDownAction(com.cubrid.common.ui.spi.Messages.toolsActionName, IAction.AS_DROP_DOWN_MENU, Activator.getImageDescriptor("icons/toolbar/qb_tools_on.png"));
toolsDropAction.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/toolbar/qb_tools_off.png"));
MenuManager toolsActionManager = toolsDropAction.getMenuManager();
toolsActionManager.add(ActionManager.getInstance().getAction(SchemaCompareWizardAction.ID));
toolsActionManager.add(ActionManager.getInstance().getAction(DataCompareWizardAction.ID));
toolsActionManager.add(new Separator());
toolsActionManager.add(manager.getAction(OpenSchemaEditorAction.ID));
toolsActionManager.add(new Separator());
toolsActionManager.add(ActionManager.getInstance().getAction(ExportERwinAction.ID));
toolsActionManager.add(ActionManager.getInstance().getAction(ImportERwinAction.ID));
toolsActionManager.add(new Separator());
// toolsActionManager.add(ActionManager.getInstance().getAction(RunSQLFileAction.ID));
toolsActionManager.add(ActionManager.getInstance().getAction(UnifyHostConfigAction.ID));
toolsActionManager.add(ActionManager.getInstance().getAction(QueryTunerAction.ID));
toolsActionManager.add(new Separator());
// toolsActionManager.add(ActionManager.getInstance().getAction(
// LaunchBrowserAction.ID));
// Action for CM service analysis
// toolsActionManager.add(ActionManager.getInstance().getAction(CMServiceAnalysisAction.ID));
ActionContributionItem toolsItem = new ActionContributionItem(toolsDropAction);
toolsItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);
newToolbarManager.insertBefore(insertPoint, toolsItem);
newToolbarManager.insertBefore(insertPoint, new Separator());
// User Management
DropDownAction usersDropAction = new DropDownAction(Messages.userActionNameBig, IAction.AS_DROP_DOWN_MENU, Activator.getImageDescriptor("icons/toolbar/user_big.png"));
usersDropAction.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/toolbar/user_big.png"));
MenuManager userActionManager = usersDropAction.getMenuManager();
userActionManager.add(manager.getAction(UserManagementAction.ID));
userActionManager.add(manager.getAction(ChangeManagerPasswordAction.ID));
userActionManager.add(new Separator());
userActionManager.add(manager.getAction(AddUserAction.ID));
userActionManager.add(manager.getAction(EditUserAction.ID));
userActionManager.add(manager.getAction(DeleteUserAction.ID));
ActionContributionItem usersItems = new ActionContributionItem(usersDropAction);
usersItems.setMode(ActionContributionItem.MODE_FORCE_TEXT);
newToolbarManager.insertBefore(insertPoint, usersItems);
// Management actions
DropDownAction manageAction = new DropDownAction(Messages.manageActionNameBig, IAction.AS_DROP_DOWN_MENU, Activator.getImageDescriptor("icons/toolbar/db_management_big.png"));
manageAction.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/toolbar/db_management_big.png"));
MenuManager manageActionManager = manageAction.getMenuManager();
manageActionManager.add(manager.getAction(UnloadDatabaseAction.ID));
manageActionManager.add(manager.getAction(LoadDatabaseAction.ID));
manageActionManager.add(manager.getAction(BackupDatabaseAction.ID));
manageActionManager.add(manager.getAction(RestoreDatabaseAction.ID));
manageActionManager.add(manager.getAction(OptimizeAction.ID));
manageActionManager.add(manager.getAction(CheckDatabaseAction.ID));
manageActionManager.add(new Separator());
manageActionManager.add(manager.getAction(TransactionInfoAction.ID));
manageActionManager.add(manager.getAction(LockInfoAction.ID));
ActionContributionItem manageItems = new ActionContributionItem(manageAction);
manageItems.setMode(ActionContributionItem.MODE_FORCE_TEXT);
newToolbarManager.insertBefore(insertPoint, manageItems);
newToolbarManager.insertBefore(insertPoint, new Separator());
newToolbarManager.update(true);
coolBarManager.update(true);
}
use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.
the class MonitorDashboardEditor method configureGraphicalViewer.
/**
* @see org.eclipse.gef.ui.parts.GraphicalEditor.configureGraphicalViewer
*/
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
GraphicalViewer viewer = getGraphicalViewer();
ScalableFreeformRootEditPart rootEditPart = new ScalableFreeformRootEditPart();
viewer.setRootEditPart(rootEditPart);
viewer.setEditPartFactory(new MonitorEditPartFacotry());
ZoomManager manager = rootEditPart.getZoomManager();
double[] zoomLevels = new double[] { 1.0, 1.2, 1.4, 1.6, 1.8, 2.0 };
manager.setZoomLevels(zoomLevels);
getActionRegistry().registerAction(new ZoomInAction(manager));
getActionRegistry().registerAction(new ZoomOutAction(manager));
KeyHandler keyHandler = new GefViewerKeyHandler(viewer);
keyHandler.put(KeyStroke.getReleased('', 97, SWT.CONTROL), getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
keyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));
keyHandler.put(KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT));
viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.CTRL), MouseWheelZoomHandler.SINGLETON);
viewer.setKeyHandler(keyHandler);
//initialize context menu
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
menuManager.addMenuListener(new IMenuListener() {
/**
* get menus to show.
*
* @param manager IMenuManager
*/
public void menuAboutToShow(IMenuManager manager) {
IStructuredSelection selection = (IStructuredSelection) getGraphicalViewer().getSelection();
String[] ids = new String[] {};
if (null == selection || selection.isEmpty() || selection.getFirstElement() instanceof DashboardPart) {
manager.add(getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
ids = new String[] { AddHostMonitorAction.ID, SEPARATOR, DashboardRefreshAction.ID };
} else if (selection.getFirstElement() instanceof HostMonitorPart) {
ids = new String[] { MonitorDetailAction.ID, DeleteHostMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, //HARoleChangeAction.ID, SEPARATOR,
HostDashboardHistoryAction.ID, AddDatabaseMonitorAction.ID, AddBrokerMonitorAction.ID, SEPARATOR, HideHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
} else if (selection.getFirstElement() instanceof DatabaseMonitorPart) {
ids = new String[] { MonitorDetailAction.ID, DeleteDatabaseMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, DbDashboardHistoryAction.ID, OpenApplyLogDBLogAction.ID, OpenCopyLogDBLogAction.ID, OpenDatabaseLogAction.ID, SEPARATOR, ShowHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
} else if (selection.getFirstElement() instanceof BrokerMonitorPart) {
ids = new String[] { MonitorDetailAction.ID, DeleteBrokerMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, ShowBrokerClientAction.ID, ShowBrokerDabaseAction.ID, SEPARATOR, ShowHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
} else if (selection.getFirstElement() instanceof ClientMonitorPart) {
ids = new String[] { EditAliasNameAction.ID };
} else if (selection.getFirstElement() instanceof BrokerDBListMonitorPart) {
ids = new String[] { EditAliasNameAction.ID };
}
for (String id : ids) {
if (id.equals(SEPARATOR)) {
manager.add(new Separator());
} else {
IAction action = ActionManager.getInstance().getAction(id);
((ISelectionAction) action).setSelectionProvider(getGraphicalViewer());
ActionManager.addActionToManager(manager, action);
}
}
manager.update(true);
}
});
viewer.setContextMenu(menuManager);
}
Aggregations