use of org.eclipse.jface.action.IAction in project cubrid-manager by CUBRID.
the class CUBRIDTextEditor method updateActions.
/**
* Update actions' status.
*
*/
protected void updateActions() {
IAction iAction = actions.get(ActionFactory.UNDO.getId());
if (iAction != null) {
iAction.setEnabled(undoManager.undoable());
}
iAction = actions.get(ActionFactory.REDO.getId());
if (iAction != null) {
iAction.setEnabled(undoManager.redoable());
}
iAction = actions.get(ActionFactory.CUT.getId());
if (iAction != null) {
iAction.setEnabled(textViewer.canDoOperation(ITextOperationTarget.CUT));
}
iAction = actions.get(ActionFactory.COPY.getId());
if (iAction != null) {
iAction.setEnabled(textViewer.canDoOperation(ITextOperationTarget.COPY));
}
iAction = actions.get(ActionFactory.PASTE.getId());
if (iAction != null) {
iAction.setEnabled(textViewer.canDoOperation(ITextOperationTarget.PASTE));
}
}
use of org.eclipse.jface.action.IAction in project cubrid-manager by CUBRID.
the class ActionAdvisor method createItem.
/**
*
* Create action contribution item for action for show text and icon
*
* @param id
* action ID
* @return ActionContributionItem
*/
private ActionContributionItem createItem(String id) {
IAction action = ActionManager.getInstance().getAction(id + ProxyAction.POSTFIX_ID);
if (action == null) {
return null;
}
ActionContributionItem item = new ActionContributionItem(action);
item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
return item;
}
use of org.eclipse.jface.action.IAction in project cubrid-manager by CUBRID.
the class XMLEditor method createContextMenu.
/**
* Add format action.
*
* @param manager IMenuManager
*/
protected void createContextMenu(IMenuManager manager) {
super.createContextMenu(manager);
manager.add(new Separator());
IAction formatAction = actions.get(ActionConstants.ACTION_FORMAT);
if (formatAction != null) {
manager.add(formatAction);
}
}
use of org.eclipse.jface.action.IAction in project cubrid-manager by CUBRID.
the class ActionAdvisor method createItem.
/**
*
* Create action contribution item for action for show text and icon
*
* @param id
* action ID
* @return ActionContributionItem
*/
private ActionContributionItem createItem(String id) {
IAction action = ActionManager.getInstance().getAction(id);
if (action == null) {
return null;
}
ActionContributionItem item = new ActionContributionItem(action);
item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
return item;
}
use of org.eclipse.jface.action.IAction 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