use of org.eclipse.jface.action.IMenuManager in project tdi-studio-se by Talend.
the class MultiPageEditorContributor method contributeToMenu.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.EditorActionBarContributor#contributeToMenu(org.eclipse.jface.action.IMenuManager)
*/
@Override
public void contributeToMenu(final IMenuManager menubar) {
super.contributeToMenu(menubar);
//$NON-NLS-1$
MenuManager viewMenu = new MenuManager(Messages.getString("MultiPageEditorContributor.View"));
viewMenu.add(getAction(GEFActionConstants.ZOOM_IN));
viewMenu.add(getAction(GEFActionConstants.ZOOM_OUT));
viewMenu.add(new Separator());
viewMenu.add(getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY));
viewMenu.add(getAction(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY));
menubar.insertAfter(IWorkbenchActionConstants.M_EDIT, viewMenu);
}
use of org.eclipse.jface.action.IMenuManager in project tdi-studio-se by Talend.
the class HL7OutputUI method addXMLViewer.
/**
* create xml viewer.
*
* @param mainComposite
* @param form
* @param width
* @param height
*/
private void addXMLViewer(final Composite mainComposite, final int width, final int height) {
// Group Schema Viewer
Group group = Form.createGroup(mainComposite, 1, "Linker Target", height);
// group.setBackgroundMode(SWT.INHERIT_FORCE);
xmlViewer = new TreeViewer(group, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
GridData gridData = new GridData(GridData.FILL_BOTH);
xmlViewer.getControl().setLayoutData(gridData);
xmlViewer.setUseHashlookup(true);
Tree tree = xmlViewer.getTree();
if (canModify || isRespo) {
tree.setEnabled(false);
}
tree.setLinesVisible(true);
tree.setBackground(tree.getDisplay().getSystemColor(SWT.COLOR_WHITE));
TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
column1.setText("HL7 Structure");
column1.setWidth(170);
// Related Column
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(90);
TreeColumn column4 = new TreeColumn(tree, SWT.CENTER);
column4.setText("Default Value");
column4.setWidth(90);
tree.setHeaderVisible(true);
// tree.setBackgroundMode(SWT.INHERIT_NONE);
HL7TargetTreeViewerProvider provider = new HL7TargetTreeViewerProvider();
xmlViewer.setLabelProvider(provider);
xmlViewer.setCellModifier(new ICellModifier() {
@Override
public boolean canModify(Object element, String property) {
HL7TreeNode node = (HL7TreeNode) 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;
}
@Override
public Object getValue(Object element, String property) {
HL7TreeNode node = (HL7TreeNode) element;
if (property.equals("C1")) {
return node.getLabel();
}
if (property.equals("C4")) {
return node.getDefaultValue();
}
return null;
}
@Override
public void modify(Object element, String property, Object value) {
TreeItem treeItem = (TreeItem) element;
HL7TreeNode node = (HL7TreeNode) treeItem.getData();
if (property.equals("C1")) {
if (value != null && value.toString().length() == 0) {
value = node.getLabel();
}
node.setLabel((String) value);
}
if (property.equals("C4")) {
node.setDefaultValue((String) value);
}
xmlViewer.refresh(node);
}
});
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
xmlViewer.setColumnProperties(new String[] { "C1", "C2", "C3", "C4" });
CellEditor editor = new TextCellEditor(xmlViewer.getTree());
editor.addListener(new DialogErrorXMLLabelCellEditor(editor, "C1"));
// add by wzhang for bug 8572. set Default value column to be edit.
CellEditor editorDefault = new TextCellEditor(xmlViewer.getTree());
editorDefault.addListener(new DialogErrorXMLLabelCellEditor(editorDefault, "C4"));
xmlViewer.setCellEditors(new CellEditor[] { editor, null, null, editorDefault });
xmlViewer.setContentProvider(provider);
xmlViewer.setInput(this.hl7Manager.getTreeData());
xmlViewer.expandAll();
createAction();
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
HL7OutputUI.this.fillContextMenu(manager);
}
});
Menu menu = menuMgr.createContextMenu(xmlViewer.getControl());
xmlViewer.getControl().setMenu(menu);
xmlViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
// TODO Auto-generated method stub
}
});
refreshXMLViewer(null);
}
use of org.eclipse.jface.action.IMenuManager in project tdi-studio-se by Talend.
the class JvmTreeViewer method createContextMenu.
/**
* Creates the context menu.
*
* @param actionBars The action bars
*/
private void createContextMenu(IActionBars actionBars) {
startMonitoringAction = new StartMonitorJobAction();
stopMonitoringAction = new StopMonitoringAction(this);
openSnapshotAction = new OpenSnapshotAction();
copyAction = CopyAction.createCopyAction(actionBars);
deleteAction = new DeleteAction(this, actionBars);
renameAction = new RenameAction(this, actionBars);
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
configureMenus(manager);
}
});
Menu menu = menuMgr.createContextMenu(getControl());
getControl().setMenu(menu);
}
use of org.eclipse.jface.action.IMenuManager in project tdi-studio-se by Talend.
the class DataSetTableActionGroup method fillContextMenu.
/**
* Fill the context menu with all the correct actions.
* @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
*/
public void fillContextMenu(IMenuManager menu) {
IExtensionRegistry registry = Platform.getExtensionRegistry();
//$NON-NLS-1$ //$NON-NLS-2$
IExtensionPoint point = registry.getExtensionPoint("net.sourceforge.sqlexplorer", "dataSetTableContextAction");
IExtension[] extensions = point.getExtensions();
for (int i = 0; i < extensions.length; i++) {
IExtension e = extensions[i];
IConfigurationElement[] ces = e.getConfigurationElements();
for (int j = 0; j < ces.length; j++) {
try {
//$NON-NLS-1$
String group = ces[j].getAttribute("group");
if (group == null || !group.equalsIgnoreCase("export")) {
//$NON-NLS-1$
// check if the action thinks it is suitable..
AbstractDataSetTableContextAction action = (AbstractDataSetTableContextAction) ces[j].createExecutableExtension(//$NON-NLS-1$
"class");
action.setTable(ptable);
action.setTableCursor(pcursor);
if (action.isAvailable()) {
menu.add(action);
}
}
} catch (Throwable ex) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("DataSetTableActionGroup.logMessage1"), ex);
}
}
}
menu.add(new Separator());
// add export options
//$NON-NLS-1$
MenuManager subMenu = new MenuManager(Messages.getString("DataSetTable.Actions.ExportSubMenu"));
for (int i = 0; i < extensions.length; i++) {
IExtension e = extensions[i];
IConfigurationElement[] ces = e.getConfigurationElements();
for (int j = 0; j < ces.length; j++) {
try {
//$NON-NLS-1$
String group = ces[j].getAttribute("group");
if (group != null && group.equalsIgnoreCase("export")) {
//$NON-NLS-1$
// check if the action thinks it is suitable..
AbstractDataSetTableContextAction action = (AbstractDataSetTableContextAction) ces[j].createExecutableExtension(//$NON-NLS-1$
"class");
action.setTable(ptable);
action.setTableCursor(pcursor);
if (action.isAvailable()) {
subMenu.add(action);
}
}
} catch (Throwable ex) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("DataSetTableActionGroup.logMessage1"), ex);
}
}
}
menu.add(subMenu);
menu.add(new Separator());
menu.add(pcopyTableAction);
}
use of org.eclipse.jface.action.IMenuManager in project tdi-studio-se by Talend.
the class ThreadFilteredTree method createContextMenu.
/**
* Creates the context menu.
*
* @param actionBars The action bars
*/
private void createContextMenu(IActionBars actionBars) {
configureColumnsAction = new ConfigureColumnsAction(this);
final CopyAction copyAction = CopyAction.createCopyAction(actionBars);
getViewer().addSelectionChangedListener(copyAction);
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
manager.add(copyAction);
manager.add(new Separator());
manager.add(configureColumnsAction);
}
});
Menu menu = menuMgr.createContextMenu(getViewer().getControl());
getViewer().getControl().setMenu(menu);
}
Aggregations