use of org.eclipse.jface.action.IMenuListener in project cubrid-manager by CUBRID.
the class QueryExecuter method registerInputMethodContextMenu.
/**
*
* Register input method context menu for styled text
*
* @param text StyledText
* @param isEditable boolean
*/
public void registerInputMethodContextMenu(final StyledText text, final boolean isEditable, final String type, final TableItem item, final int column) {
text.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(text);
}
});
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
menuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
IAction copyAction = ActionManager.getInstance().getAction(CopyAction.ID);
if (copyAction instanceof CopyAction) {
manager.add(copyAction);
if (!copyAction.isEnabled()) {
FocusAction.changeActionStatus(copyAction, text);
}
}
if (!isEditable) {
return;
}
IAction pasteAction = ActionManager.getInstance().getAction(PasteAction.ID);
if (pasteAction instanceof PasteAction) {
manager.add(pasteAction);
if (!pasteAction.isEnabled()) {
FocusAction.changeActionStatus(pasteAction, text);
}
}
IAction inputAction = ActionManager.getInstance().getAction(InputMethodAction.ID);
if (inputAction instanceof InputMethodAction) {
manager.add(inputAction);
if (!inputAction.isEnabled()) {
FocusAction.changeActionStatus(inputAction, text);
} else {
((InputMethodAction) inputAction).setType(type);
((InputMethodAction) inputAction).setTableItem(item);
((InputMethodAction) inputAction).setColumn(column);
((InputMethodAction) inputAction).setQueryExecuter(executer);
}
if (isEditMode()) {
inputAction.setEnabled(true);
} else {
inputAction.setEnabled(false);
}
}
}
});
Menu contextMenu = menuManager.createContextMenu(text);
text.setMenu(contextMenu);
text.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
IAction copyAction = ActionManager.getInstance().getAction(CopyAction.ID);
if (!copyAction.isEnabled()) {
FocusAction.changeActionStatus(copyAction, text);
}
IAction pasteAction = ActionManager.getInstance().getAction(PasteAction.ID);
if (pasteAction != null && !pasteAction.isEnabled()) {
FocusAction.changeActionStatus(pasteAction, text);
}
IAction inputAction = ActionManager.getInstance().getAction(InputMethodAction.ID);
if (inputAction != null) {
FocusAction.changeActionStatus(inputAction, text);
}
}
});
}
use of org.eclipse.jface.action.IMenuListener in project azure-tools-for-java by Microsoft.
the class QueueFileEditor method createTablePopUp.
private void createTablePopUp(Composite parent) {
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
if (tableViewer.getSelection().isEmpty()) {
return;
}
if (tableViewer.getSelection() instanceof IStructuredSelection) {
manager.add(fileEditorVirtualNode.createPopupAction(OPEN));
Action action = fileEditorVirtualNode.createPopupAction(DEQUEUE);
if (queueTable.getSelectionIndex() != 0) {
action.setEnabled(false);
}
manager.add(action);
}
}
});
Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
tableViewer.getControl().setMenu(menu);
}
use of org.eclipse.jface.action.IMenuListener in project azure-tools-for-java by Microsoft.
the class ServiceExplorerView method hookContextMenu.
private void hookContextMenu() {
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
if (viewer.getSelection().isEmpty()) {
return;
}
if (viewer.getSelection() instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Node node = ((TreeNode) selection.getFirstElement()).node;
if (node.hasNodeActions()) {
for (final NodeAction nodeAction : node.getNodeActions()) {
ImageDescriptor imageDescriptor = nodeAction.getIconPath() != null ? Activator.getImageDescriptor("icons/" + nodeAction.getIconPath()) : null;
Action action = new Action(nodeAction.getName(), imageDescriptor) {
public void run() {
nodeAction.fireNodeActionEvent();
}
};
action.setEnabled(nodeAction.isEnabled());
manager.add(action);
}
}
}
}
});
Menu menu = menuMgr.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(menu);
}
use of org.eclipse.jface.action.IMenuListener in project cubrid-manager by CUBRID.
the class BrokerStatusView method createAsTable.
/**
* Create app server table
*
* @param comp the parent composite
*
*/
private void createAsTable(Composite comp) {
Composite asComposite = new Composite(comp, SWT.NONE);
GridData gdAs = new GridData(SWT.FILL, SWT.FILL, true, true);
asComposite.setLayoutData(gdAs);
asComposite.setLayout(new GridLayout());
asTableViewer = new TableViewer(asComposite, SWT.FULL_SELECTION | SWT.NO_SCROLL | SWT.V_SCROLL | SWT.BORDER);
Table asTable = asTableViewer.getTable();
asTable.setHeaderVisible(true);
asTable.setLinesVisible(true);
asTable.setLayoutData(gdAs);
TableLayout asLayout = new TableLayout();
setAsLayout(asLayout);
asTable.setLayout(asLayout);
TableColumn tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsId);
tblColumn.setToolTipText(Messages.tblAsId);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsProcess);
tblColumn.setToolTipText(Messages.tblAsProcess);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsQps);
tblColumn.setToolTipText(Messages.tblAsQps);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsLqs);
tblColumn.setToolTipText(Messages.tblAsLqs);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsPort);
tblColumn.setToolTipText(Messages.tblAsPort);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsSize);
tblColumn.setToolTipText(Messages.tblAsSize);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsStatus);
tblColumn.setToolTipText(Messages.tblAsStatus);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsDb);
tblColumn.setToolTipText(Messages.tblAsDb);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsHost);
tblColumn.setToolTipText(Messages.tblAsHost);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsLastAccess);
tblColumn.setToolTipText(Messages.tblAsLastAccess);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsLct);
tblColumn.setToolTipText(Messages.tblAsLct);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsClientIp);
tblColumn.setToolTipText(Messages.tblAsClientIp);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsCur);
tblColumn.setToolTipText(Messages.tblAsCur);
asTableViewer.setContentProvider(new ApplyServerContentProvider());
asTableViewer.setLabelProvider(new ApplyServerLabelProvider());
asTableViewer.setInput(asinfoLst);
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
menuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
IStructuredSelection selection = (IStructuredSelection) asTableViewer.getSelection();
ApplyServerInfo as = (ApplyServerInfo) (selection.toArray()[0]);
RestartAction restartAcion = new RestartAction(as.getAs_id());
manager.add(restartAcion);
}
});
Menu contextMenu = menuManager.createContextMenu(asTableViewer.getControl());
asTableViewer.getControl().setMenu(contextMenu);
}
use of org.eclipse.jface.action.IMenuListener in project tdi-studio-se by Talend.
the class BusinessAssignmentComposite method createPopupMenu.
private void createPopupMenu() {
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopUp");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager mgr) {
BusinessAssignment businessAssignment = getBusinessAssignment(tableViewer.getSelection());
if (businessAssignment != null) {
repositoryNode = createRepositoryNode(businessAssignment);
if (repositoryNode != null) {
List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
for (ITreeContextualAction action : contextualsActions) {
if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
action.init(null, new StructuredSelection(repositoryNode));
if (action.isVisible()) {
((AContextualAction) action).setAvoidUnloadResources(true);
mgr.add(action);
}
}
}
if (ProjectManager.getInstance().isInCurrentMainProject(repositoryNode)) {
CorePlugin.getDefault().getDiagramModelService().addDeleteAssignmentAction(mgr, tableViewer.getSelection());
}
}
}
}
});
Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
tableViewer.getControl().setMenu(menu);
}
Aggregations