use of org.eclipse.jface.action.MenuManager in project tdi-studio-se by Talend.
the class JobHierarchyViewPart method createPartControl.
@Override
public void createPartControl(Composite container) {
fParent = container;
addResizeListener(fParent);
fPagebook = new PageBook(container, SWT.NONE);
// page 1 of page book (no hierarchy label)
fNoHierarchyShownLabel = new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP);
fNoHierarchyShownLabel.setText(showEmptyLabel);
// page 2 of page book (viewers)
fTypeMethodsSplitter = new SashForm(fPagebook, SWT.VERTICAL);
fTypeMethodsSplitter.setVisible(false);
fTypeViewerViewForm = new ViewForm(fTypeMethodsSplitter, SWT.NONE);
Control typeViewerControl = createTypeViewerControl(fTypeViewerViewForm);
fTypeViewerViewForm.setContent(typeViewerControl);
dependencyViewerViewForm = new ViewForm(fTypeMethodsSplitter, SWT.NONE);
fTypeMethodsSplitter.setWeights(new int[] { 65, 35 });
Control dependencyViewerPart = createMethodViewerControl(dependencyViewerViewForm);
dependencyViewerViewForm.setContent(dependencyViewerPart);
dependencyViewerPaneLabel = new CLabel(dependencyViewerViewForm, SWT.NONE);
dependencyViewerViewForm.setTopLeft(dependencyViewerPaneLabel);
ToolBar methodViewerToolBar = new ToolBar(dependencyViewerViewForm, SWT.FLAT | SWT.WRAP);
dependencyViewerViewForm.setTopCenter(methodViewerToolBar);
initDragAndDrop();
MenuManager menu = new MenuManager();
menu.add(focusOnTypeAction);
fNoHierarchyShownLabel.setMenu(menu.createContextMenu(fNoHierarchyShownLabel));
fPagebook.showPage(fNoHierarchyShownLabel);
int layout;
try {
layout = fDialogSettings.getInt(DIALOGSTORE_VIEWLAYOUT);
if (layout < 0 || layout > 3) {
layout = VIEW_LAYOUT_AUTOMATIC;
}
} catch (NumberFormatException e) {
layout = VIEW_LAYOUT_AUTOMATIC;
}
// force the update
fCurrentLayout = -1;
// will fill the main tool bar
setViewLayout(layout);
// set the filter menu items
IActionBars actionBars = getViewSite().getActionBars();
IMenuManager viewMenu = actionBars.getMenuManager();
// for (int i = 0; i < fViewActions.length; i++) {
// ToggleViewAction action = fViewActions[i];
// viewMenu.add(action);
// action.setEnabled(false);
// }
// viewMenu.add(new Separator());
// IMenuManager layoutSubMenu = new MenuManager(TypeHierarchyMessages.TypeHierarchyViewPart_layout_submenu);
//$NON-NLS-1$
IMenuManager layoutSubMenu = new MenuManager(Messages.getString("FocusOnJobAction.TypeHierarchyViewPart_layout_submenu"));
viewMenu.add(layoutSubMenu);
for (int i = 0; i < fToggleOrientationActions.length; i++) {
layoutSubMenu.add(fToggleOrientationActions[i]);
}
viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
// selection provider
int nHierarchyViewers = fAllViewers.length;
StructuredViewer[] trackedViewers = new StructuredViewer[nHierarchyViewers + 1];
for (int i = 0; i < nHierarchyViewers; i++) {
trackedViewers[i] = fAllViewers[i];
}
trackedViewers[nHierarchyViewers] = dependencyViewer;
fSelectionProviderMediator = new SelectionProviderMediator(trackedViewers, getCurrentViewer());
getSite().setSelectionProvider(fSelectionProviderMediator);
ActionGroup[] actionGroups = new ActionGroup[] { new JobActionGroup() };
fActionGroups = new CompositeActionGroup(actionGroups);
fActionGroups.fillActionBars(actionBars);
}
use of org.eclipse.jface.action.MenuManager in project tdi-studio-se by Talend.
the class JSONFileOutputStep2Form method addJSONFileViewer.
private void addJSONFileViewer(final Composite mainComposite, final int width, final int height) {
final Group group = Form.createGroup(mainComposite, 1, "Linker Target", height);
GridData data = new GridData(GridData.FILL_BOTH);
Composite composite = new Composite(group, SWT.BORDER);
composite.setLayout(new GridLayout());
composite.setLayoutData(data);
JSONViewer = new TreeViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
data = new GridData(GridData.FILL_BOTH);
JSONViewer.getControl().setLayoutData(data);
JSONViewer.setUseHashlookup(true);
Tree tree = JSONViewer.getTree();
if (isReadOnly()) {
tree.setEnabled(false);
}
tree.setLinesVisible(true);
tree.setBackground(tree.getDisplay().getSystemColor(SWT.COLOR_WHITE));
TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
column1.setText("JSON Tree");
column1.setWidth(120);
TreeColumn column2 = new TreeColumn(tree, SWT.CENTER);
column2.setText("Related Column");
column2.setWidth(100);
TreeColumn column3 = new TreeColumn(tree, SWT.CENTER);
column3.setText("Node Status");
column3.setWidth(100);
TreeColumn column4 = new TreeColumn(tree, SWT.CENTER);
column4.setText("Default Value");
column4.setWidth(100);
tree.setHeaderVisible(true);
JSONFileTreeViewerProvider provider = new JSONFileTreeViewerProvider();
JSONViewer.setLabelProvider(provider);
JSONViewer.setCellModifier(new ICellModifier() {
public void modify(Object element, String property, Object value) {
TreeItem treeItem = (TreeItem) element;
FOXTreeNode node = (FOXTreeNode) treeItem.getData();
if (property.equals("C1")) {
node.setLabel((String) value);
}
if (property.equals("C4")) {
node.setDefaultValue((String) value);
}
JSONViewer.refresh(node);
}
public Object getValue(Object element, String property) {
FOXTreeNode node = (FOXTreeNode) element;
if (property.equals("C1")) {
//$NON-NLS-1$
return node.getLabel();
}
if (property.equals("C4")) {
//$NON-NLS-1$
return node.getDefaultValue();
}
return null;
}
public boolean canModify(Object element, String property) {
FOXTreeNode node = (FOXTreeNode) element;
if (property.equals("C1")) {
if (node.getLabel() != null && node.getLabel().length() > 0) {
return true;
}
}
if (property.equals("C4")) {
if (node.getDefaultValue() != null && node.getDefaultValue().length() > 0) {
return true;
}
}
return false;
}
});
JSONViewer.setColumnProperties(new String[] { "C1", "C2", "C3", "C4" });
CellEditor editor = new TextCellEditor(JSONViewer.getTree());
editor.addListener(new DialogErrorJSONLabelCellEditor(editor, "C1"));
CellEditor editorDefault = new TextCellEditor(JSONViewer.getTree());
editorDefault.addListener(new DialogErrorJSONLabelCellEditor(editorDefault, "C4"));
JSONViewer.setCellEditors(new CellEditor[] { editor, null, null, editorDefault });
JSONViewer.setContentProvider(provider);
// JSONViewer.setInput(treeData);
JSONViewer.expandAll();
createAction();
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
fillContextMenu(manager);
}
});
Menu menu = menuMgr.createContextMenu(JSONViewer.getControl());
JSONViewer.getControl().setMenu(menu);
JSONViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
}
});
initToolBar(composite);
}
use of org.eclipse.jface.action.MenuManager in project tdi-studio-se by Talend.
the class TalendEditorContextMenuProvider method buildContextMenu.
/**
* Called when the context menu is about to show. Actions, whose state is enabled, will appear in the context menu.
*
* @see org.eclipse.gef.ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager)
*/
@Override
public void buildContextMenu(final IMenuManager menu) {
if (!isEnableContextMenu()) {
return;
}
// Add standard action groups to the menu
menu.add(new Separator(GROUP_CONNECTIONS));
menu.add(new Separator(GEFActionConstants.GROUP_UNDO));
menu.add(new Separator(GEFActionConstants.GROUP_COPY));
menu.add(new Separator(GEFActionConstants.GROUP_EDIT));
menu.add(new Separator(GEFActionConstants.GROUP_REST));
menu.add(new Separator(GROUP_OTHER));
menu.add(new Separator(GEFActionConstants.GROUP_VIEW));
menu.add(new Separator(GROUP_BREAKPOINT));
IAction action;
// target group id
menu.appendToGroup(// target group id
GEFActionConstants.GROUP_UNDO, // action to add
getAction(ActionFactory.UNDO.getId()));
menu.appendToGroup(GEFActionConstants.GROUP_UNDO, getAction(ActionFactory.REDO.getId()));
if (part != null) {
// new GEFCopyAction(part);
action = getAction(ActionFactory.COPY.getId());
if (action instanceof GEFCopyAction) {
((GEFCopyAction) action).update();
}
menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
// new GEFPasteAction(part);
action = getAction(ActionFactory.PASTE.getId());
GEFPasteAction pasteAction = (GEFPasteAction) action;
Point p = Display.getCurrent().getCursorLocation();
p = this.getViewer().getControl().toControl(p);
// gcui see bug 7812:Copy/Paste component in Job designer.
LayerManager layerManager = (LayerManager) this.getViewer().getEditPartRegistry().get(LayerManager.ID);
IFigure contentLayer = layerManager.getLayer(LayerConstants.PRINTABLE_LAYERS);
// System.out.println("X:" + contentLayer.getSize().width + " Y:" + contentLayer.getSize().height);
org.eclipse.draw2d.geometry.Point p1 = new org.eclipse.draw2d.geometry.Point(p.x, p.y);
contentLayer.translateToAbsolute(p1);
// System.out.println("relative:" + p);
p.x = 2 * (p.x) - p1.x;
p.y = 2 * (p.y) - p1.y;
// System.out.println("absolute:" + p);
pasteAction.setCursorLocation(p);
menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(ActionFactory.DELETE.getId()));
menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(ActionFactory.SELECT_ALL.getId()));
action = new ActivateElementAction(part);
((ActivateElementAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
action = new ActivateSubjobAction(part);
((ActivateSubjobAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
action = new ActivateSubjobOneComponentAction(part);
((ActivateSubjobOneComponentAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
action = getAction(ConnectionSetAsMainRef.ID);
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
action = getAction(ModifyMergeOrderAction.ID);
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
action = getAction(ModifyOutputOrderAction.ID);
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
List<String> orderActionIDs = ModifyConnectionOrderAction.getOrderActionIDs();
for (String id : orderActionIDs) {
action = getAction(id);
if (action != null && action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
}
//$NON-NLS-1$
MenuManager subMenu = new MenuManager(Messages.getString("TalendEditorContextMenuProvider.Row"));
menu.appendToGroup(GROUP_CONNECTIONS, subMenu);
action = new ConnectionCreateAction(part, EConnectionType.FLOW_MAIN);
((ConnectionCreateAction) action).update();
List<INodeConnector> connectors = ((ConnectionCreateAction) action).getConnectors();
if (connectors.size() > 1) {
for (INodeConnector connector : connectors) {
if (connector.isMultiSchema()) {
action = new ConnectionCreateAction(part, connector);
((ConnectionCreateAction) action).update();
if (action.isEnabled() && connector.isShow()) {
List<String> menuList = ((ConnectionCreateAction) action).getMenuList();
for (int i = 0; i < menuList.size(); i++) {
action = new ConnectionCreateAction(part, connector);
((ConnectionCreateAction) action).update();
((ConnectionCreateAction) action).setText(menuList.get(i));
subMenu.add(action);
}
}
} else {
action = new ConnectionCreateAction(part, connector);
((ConnectionCreateAction) action).update();
if (action.isEnabled() && connector.isShow()) {
((ConnectionCreateAction) action).setText(connector.getMenuName());
subMenu.add(action);
}
}
}
} else {
if (connectors.size() == 1) {
action = new ConnectionCreateAction(part, connectors.get(0));
((ConnectionCreateAction) action).update();
if (action.isEnabled() && connectors.get(0).isShow()) {
List<String> menuList = ((ConnectionCreateAction) action).getMenuList();
for (int i = 0; i < menuList.size(); i++) {
action = new ConnectionCreateAction(part, connectors.get(0));
((ConnectionCreateAction) action).update();
((ConnectionCreateAction) action).setText(menuList.get(i));
subMenu.add(action);
}
}
}
}
retrieveConnectors(subMenu, EConnectionType.ITERATE);
retrieveConnectors(subMenu, EConnectionType.ROUTE);
retrieveConnectors(subMenu, EConnectionType.ROUTE_TRY);
retrieveConnectors(subMenu, EConnectionType.ROUTE_CATCH);
retrieveConnectors(subMenu, EConnectionType.ROUTE_FINALLY);
retrieveConnectors(subMenu, EConnectionType.ROUTE_ENDBLOCK);
//$NON-NLS-1$
subMenu = new MenuManager("Link");
menu.appendToGroup(GROUP_CONNECTIONS, subMenu);
action = new ConnectionCreateAction(part, EConnectionType.TABLE);
((ConnectionCreateAction) action).update();
if (action.isEnabled()) {
List<String> menuList = ((ConnectionCreateAction) action).getMenuList();
for (int i = 0; i < menuList.size(); i++) {
action = new ConnectionCreateAction(part, EConnectionType.TABLE);
((ConnectionCreateAction) action).update();
((ConnectionCreateAction) action).setText(menuList.get(i));
subMenu.add(action);
}
}
//$NON-NLS-1$
subMenu = new MenuManager("Move to joblet");
menu.appendToGroup(GROUP_OTHER, subMenu);
action = getMoveToJobletAction(part, null, null);
if (action != null) {
((AddToJobletAction) action).update();
List<Node> nodeList = ((AddToJobletAction) action).getJobletNodeList();
Map<INode, IConnection> nodeMap = ((AddToJobletAction) action).getJobletNodeMap();
if (nodeList != null) {
for (Node jobletNode : nodeList) {
action = getMoveToJobletAction(part, jobletNode, nodeMap);
if (action != null) {
((AddToJobletAction) action).update();
action.setText(jobletNode.getLabel());
subMenu.add(action);
}
}
}
}
action = getMoveToJobAction(part);
if (action != null) {
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
}
//$NON-NLS-1$
subMenu = new MenuManager(Messages.getString("TalendEditorContextMenuProvider.Trigger"));
menu.appendToGroup(GROUP_CONNECTIONS, subMenu);
/*
* action = new ConnectionCreateAction(part, EConnectionType.RUN_BEFORE); ((ConnectionCreateAction)
* action).update(); if (action.isEnabled()) { subMenu.add(action); }
*/
retrieveConnectors(subMenu, EConnectionType.ON_SUBJOB_OK);
retrieveConnectors(subMenu, EConnectionType.ON_SUBJOB_ERROR);
subMenu.add(new Separator());
retrieveConnectors(subMenu, EConnectionType.SYNCHRONIZE);
retrieveConnectors(subMenu, EConnectionType.PARALLELIZE);
subMenu.add(new Separator());
retrieveConnectors(subMenu, EConnectionType.RUN_IF);
retrieveConnectors(subMenu, EConnectionType.ROUTE_WHEN);
retrieveConnectors(subMenu, EConnectionType.ROUTE_OTHER);
retrieveConnectors(subMenu, EConnectionType.ON_COMPONENT_OK);
retrieveConnectors(subMenu, EConnectionType.ON_COMPONENT_ERROR);
retrieveConnectors(subMenu, EConnectionType.STARTS);
action = new NodeBreakpointAction(part);
((NodeBreakpointAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
action = new ShowComponentSettingViewerAction(part);
((ShowComponentSettingViewerAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
action = new DisplaySubjobAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
if (PluginChecker.isAutoParalelPluginLoaded()) {
action = new SetParallelizationAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
action = new DisableParallelizationAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
}
// see feature 5027
action = new ParallelExecutionAction(part);
((SelectionAction) action).update();
if (PluginChecker.isTeamEdition() && action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
action = new SearchComponentAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
action = new TraceEnableAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_BREAKPOINT, action);
}
action = new TraceDisableAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_BREAKPOINT, action);
}
action = new FilterTraceColumnAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_BREAKPOINT, action);
}
action = new ShowBreakpointAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_BREAKPOINT, action);
}
action = new OpenJobHierarchyAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
action = new OpentRunJobComponentAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action);
}
action = new BringForwardAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action);
}
action = new BringToFrontAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action);
}
action = new SendBackwardAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action);
}
action = new SendToBackAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action);
}
List<SelectionAction> instances = CustomExternalActions.getInstances(part);
for (SelectionAction selectionAction : instances) {
selectionAction.update();
if (selectionAction.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_VIEW, selectionAction);
}
}
}
}
use of org.eclipse.jface.action.MenuManager in project tdi-studio-se by Talend.
the class TalendFlyoutPaletteComposite method createActionMenu.
private Menu createActionMenu(Control parent) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
final MenuManager manager = new MenuManager();
MenuManager mgr = new MenuManager(PaletteMessages.DOCK_LABEL);
changeDockActionClass.getDeclaredConstructors();
// reflect the constructor of ChangeDockAction
Constructor changeDockActionConstructor = changeDockActionClass.getDeclaredConstructor(FlyoutPaletteComposite.class, String.class, int.class);
changeDockActionConstructor.setAccessible(true);
// instance of ChangeDockAction for left
Object changeDockActionInstance = changeDockActionConstructor.newInstance(this, PaletteMessages.LEFT_LABEL, PositionConstants.WEST);
if (changeDockActionInstance instanceof IAction) {
mgr.add((IAction) changeDockActionInstance);
}
// instance of ChangeDockAction for right
changeDockActionInstance = changeDockActionConstructor.newInstance(this, PaletteMessages.RIGHT_LABEL, PositionConstants.EAST);
if (changeDockActionInstance instanceof IAction) {
mgr.add((IAction) changeDockActionInstance);
}
// instance of ResizeAction
Constructor resizeActionConstructor = resizeActionClass.getDeclaredConstructor(FlyoutPaletteComposite.class);
resizeActionConstructor.setAccessible(true);
Object resizeActionInstance = resizeActionConstructor.newInstance(this);
if (resizeActionInstance instanceof IAction) {
mgr.add((IAction) resizeActionInstance);
}
manager.add(mgr);
mgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager menuMgr) {
IContributionItem[] items = menuMgr.getItems();
for (IContributionItem item : items) {
((ActionContributionItem) item).update();
}
}
});
//
// ShowStandardAction showStandardAction = ShowStandardAction.getInstance();
// ShowFavoriteAction showFavoriteAction = ShowFavoriteAction.getInstance();
// manager.add(showStandardAction);
// manager.add(showFavoriteAction);
// if (ShowFavoriteAction.state) {
// showStandardAction.doSetEnable();
// }
OpenPaletteFilterAction openPaletteFilterAction = OpenPaletteFilterAction.getInstance();
manager.add(openPaletteFilterAction);
manager.add(mgr);
addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
manager.dispose();
}
});
return manager.createContextMenu(this);
}
use of org.eclipse.jface.action.MenuManager in project tdi-studio-se by Talend.
the class AssignmentPropertySection method createPopupMenu.
private void createPopupMenu() {
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopUp");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
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()) {
mgr.add(action);
}
}
}
}
}
}
});
Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
tableViewer.getControl().setMenu(menu);
}
Aggregations