use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.
the class SchemaInfoEditorPart method createContextMenu.
/**
*
* Create the context menu
*
* @param control Control
*/
private void createContextMenu(final Control control) {
MenuManager contextMenuManager = new MenuManager();
contextMenuManager.setRemoveAllWhenShown(true);
contextMenuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
ISelectionProvider provider = ActionManager.getInstance().getSelectionProvider();
if (!(provider instanceof TreeViewer)) {
return;
}
TreeViewer viewer = (TreeViewer) provider;
viewer.setSelection(new StructuredSelection(schemaNode), true);
viewer.getTree().setFocus();
MenuProvider menuProvider = new MenuProvider();
String type = schemaNode.getType();
if (NodeType.SYSTEM_TABLE.equals(type)) {
menuProvider.buildSystemTableMenu(manager);
} else if (NodeType.SYSTEM_VIEW.equals(type)) {
menuProvider.buildSystemViewMenu(manager);
} else if (NodeType.USER_PARTITIONED_TABLE_FOLDER.equals(type)) {
menuProvider.buildUserTableMenu(manager, schemaNode);
} else if (NodeType.USER_PARTITIONED_TABLE.equals(type)) {
menuProvider.buildPartitionedTableMenu(manager);
} else if (NodeType.USER_TABLE.equals(type)) {
menuProvider.buildUserTableMenu(manager, schemaNode);
} else if (NodeType.USER_VIEW.equals(type)) {
menuProvider.buildUserViewMenu(manager);
}
manager.remove(ShowSchemaEditorAction.ID);
}
});
Menu contextMenu = contextMenuManager.createContextMenu(control);
control.setMenu(contextMenu);
}
use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.
the class QueryPlanCompositeWithHistory method setupContextMenu.
private void setupContextMenu(final Tree tree) {
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
menuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
// IAction showSchemaAction = ActionManager.getInstance().getAction(ShowSchemaAction.ID);
// if (showSchemaAction != null) {
// manager.add(showSchemaAction);
//
// showSchemaAction.setEnabled(false);
// if (DatabaseNavigatorMenu.SELF_DATABASE_ID.equals(editor.getSelectedDatabase().getId())) {
// return;
// }
//
// if (editor.getSelectedDatabase().getDatabaseInfo() == null) {
// return;
// }
//
// if (tree.getSelection() != null && tree.getSelection().length > 0) {
// String tname = tree.getSelection()[0].getText(1);
// if (tname == null || tname.length() == 0) {
// return;
// }
//
// int ep = tname.indexOf(' ');
// if (ep != -1) {
// tname = tname.substring(0, ep);
// }
// editor.setCurrentSchemaName(tname);
// if (tname != null) {
// showSchemaAction.setEnabled(true);
// }
// }
// }
}
});
Menu contextMenu = menuManager.createContextMenu(tree);
tree.setMenu(contextMenu);
}
use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.
the class MenuProvider method buildUserTableMenu.
/**
* Construct user table related actions
*
* @param manager the parent IMenuManager
* @param node The ICubridNode object
*/
public void buildUserTableMenu(IMenuManager manager, ICubridNode node) {
DatabaseInfo dbInfo = ((ISchemaNode) node).getDatabase().getDatabaseInfo();
// SELECT GROUP
IMenuManager selectSqlMenu = new MenuManager(Messages.lblMakeSelectQueryGrp);
manager.add(selectSqlMenu);
// SELECT
addActionToManager(selectSqlMenu, getAction(MakeSelectQueryAction.ID));
// Parameterized SELECT
addActionToManager(selectSqlMenu, getAction(MakeSelectPstmtQueryAction.ID));
// Parameterized INSERT
addActionToManager(manager, getAction(MakeInsertQueryAction.ID));
// Parameterized UPDATE
addActionToManager(manager, getAction(MakeUpdateQueryAction.ID));
// Parameterized DELETE
addActionToManager(manager, getAction(MakeDeleteQueryAction.ID));
// CREATE GROUP
IMenuManager createSqlMenu = new MenuManager(Messages.lblMakeCreateQueryGrp);
manager.add(createSqlMenu);
addActionToManager(createSqlMenu, getAction(MakeCreateQueryAction.ID));
addActionToManager(createSqlMenu, getAction(MakeCloneQueryAction.ID));
manager.add(new Separator());
// Schema to Code Actions
addActionToManager(manager, getAction(TableToJavaCodeAction.ID));
addActionToManager(manager, getAction(TableToPhpCodeAction.ID));
addActionToManager(manager, getAction(ExportTableDefinitionAction.ID));
manager.add(new Separator());
// Install Schema Comment
addActionToManager(manager, getAction(SchemaCommentInstallAction.ID));
manager.add(new Separator());
// View data
IMenuManager viewDataMenu = new MenuManager(Messages.viewDataMenuName);
manager.add(viewDataMenu);
addActionToManager(viewDataMenu, getAction(TableSelectAllAction.ID));
addActionToManager(viewDataMenu, getAction(SelectByOnePstmtDataAction.ID));
addActionToManager(viewDataMenu, getAction(SelectByMultiPstmtDataAction.ID));
viewDataMenu.add(new Separator());
addActionToManager(viewDataMenu, getAction(TableSelectCountAction.ID));
// Input data
IMenuManager inputDataMenu = new MenuManager(Messages.inputDataMenuName);
manager.add(inputDataMenu);
addActionToManager(inputDataMenu, getAction(InsertOneByPstmtAction.ID));
addActionToManager(inputDataMenu, getAction(ImportDataFromFileAction.ID));
// addActionToManager(manager, getAction(RunSQLFileAction.ID));
manager.add(new Separator());
// Export & Import Actions
addActionToManager(manager, getAction(ExportWizardAction.ID));
addActionToManager(manager, getAction(ImportWizardAction.ID));
manager.add(new Separator());
// Manage table
addActionToManager(manager, getAction(EditTableAction.ID));
IAction renameTableAction = getAction(RenameTableAction.ID);
renameTableAction.setText(com.cubrid.common.ui.spi.Messages.tableRenameActionName);
renameTableAction.setImageDescriptor(CommonUIPlugin.getImageDescriptor("icons/action/table_rename.png"));
addActionToManager(manager, renameTableAction);
IMenuManager moreMenu = new MenuManager(Messages.tableMoreName);
addActionToManager(moreMenu, getAction(DeleteTableAction.ID));
IAction action = getAction(DeleteTableAction.ID);
if (CompatibleUtil.isSupportTruncateTable(dbInfo)) {
if (action != null) {
action.setText(Messages.deleteAllRecordsActionName);
}
addActionToManager(moreMenu, getAction(TruncateTableAction.ID));
} else {
if (action != null) {
action.setText(Messages.tableDeleteAllActionName);
}
}
IAction tableDropAction = getAction(DropTableAction.ID);
addActionToManager(moreMenu, tableDropAction);
moreMenu.add(new Separator());
if (CompatibleUtil.isSupportCreateTableLike(dbInfo)) {
addActionToManager(moreMenu, getAction(CreateLikeTableAction.ID));
}
manager.add(moreMenu);
}
use of org.eclipse.jface.action.MenuManager in project translationstudio8 by heartsome.
the class TermDbManagerDialog method initTreePopMenu.
/**
* 初始化树右键菜单 ;
*/
private void initTreePopMenu() {
MenuManager menuManager = new MenuManager("");
menuManager.add(new Action(Messages.getString("dialog.TermDbManagerDialog.deleteAction")) {
@Override
public void run() {
ISelection selection = getTreeViewer().getSelection();
if (selection.isEmpty()) {
return;
}
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object obj = structuredSelection.getFirstElement();
if (obj instanceof DatabaseModelBean) {
List<DatabaseModelBean> currDbTypeServers = treeInputMap.get(currDbType);
configer.deleteServerById(((DatabaseModelBean) obj).getId());
int i = currDbTypeServers.indexOf(obj);
currDbTypeServers.remove(i);
getTreeViewer().refresh();
if (currDbTypeServers.size() != 0) {
if (i > currDbTypeServers.size() - 1) {
setLastSelectedServer(currDbTypeServers.get(i - 1).getId());
} else {
setLastSelectedServer(currDbTypeServers.get(i).getId());
}
initUI(false);
} else {
setLastSelectedServer(null);
initUI(true);
}
selectSaveItem();
}
}
});
Tree tree = treeViewer.getTree();
this.treePopMenu = menuManager.createContextMenu(tree);
}
use of org.eclipse.jface.action.MenuManager in project translationstudio8 by heartsome.
the class TableHierarchicalExample method createControls.
/**
* Create the controls that compose the console test.
*
*/
protected void createControls(IHierarchicalJaretTableModel hierarchicalModel) {
GridLayout gl = new GridLayout();
gl.numColumns = 1;
_shell.setLayout(gl);
GridData gd = new GridData(GridData.FILL_BOTH);
_jt = new JaretTable(_shell, SWT.V_SCROLL | SWT.H_SCROLL);
_jt.setLayoutData(gd);
IHierarchicalJaretTableModel hmodel = hierarchicalModel;
if (hierarchicalModel == null) {
ITableNode root = new DummyTableNode("tn1", "tn1", "Root", "This the root node");
ITableNode r1 = new DummyTableNode("tn11", "tn12", "1", "Child 1 of the root");
ITableNode r2 = new DummyTableNode("tn12", "tn12", "2", "Child 2 of the root");
ITableNode r3 = new DummyTableNode("tn13", "tn13", "3", "Child 3 of the root");
root.addNode(r1);
root.addNode(r2);
root.addNode(r3);
r1.addNode(new DummyTableNode("tn111", "tn111", "1", "A second level child"));
r1.addNode(new DummyTableNode("tn112", "tn112", "2", "Another second level child"));
ITableNode n1 = new DummyTableNode("tn131", "tn131", "1", "A second level child");
r3.addNode(n1);
ITableNode n2 = new DummyTableNode("tn132", "tn132", "2", "Another second level child");
r3.addNode(n2);
n1.addNode(new DummyTableNode("tn1311", "tn1311", "1", "A third level child"));
n1.addNode(new DummyTableNode("tn1312", "tn1312", "2", "Another third level child"));
DefaultHierarchicalTableModel dhmodel = new DefaultHierarchicalTableModel(root);
hmodel = dhmodel;
if (SUPPORT_DND) {
// init the simple drag and drop handling
initDND(_jt, _shell);
}
}
_jt.setTableModel(hmodel);
StdHierarchicalTableModel model = (StdHierarchicalTableModel) _jt.getTableModel();
IColumn hcol = new HierarchyColumn();
// create and setup hierarchy renderer
final TableHierarchyRenderer hierarchyRenderer = new TableHierarchyRenderer();
hierarchyRenderer.setLabelProvider(new LabelProvider());
hierarchyRenderer.setDrawIcons(true);
hierarchyRenderer.setDrawLabels(true);
_jt.registerCellRenderer(hcol, hierarchyRenderer);
model.addColumn(hcol);
model.addColumn(new PropCol("b1", "column 1", "B1"));
model.addColumn(new PropCol("t1", "column 2", "T1"));
model.addColumn(new PropCol("t2", "column 3", "T2"));
model.addColumn(new PropCol("t3", "column 4", "T3"));
JaretTableActionFactory af = new JaretTableActionFactory();
MenuManager mm = new MenuManager();
mm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_CONFIGURECOLUMNS));
_jt.setHeaderContextMenu(mm.createContextMenu(_jt));
MenuManager rm = new MenuManager();
rm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_OPTROWHEIGHT));
rm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_OPTALLROWHEIGHTS));
_jt.setRowContextMenu(rm.createContextMenu(_jt));
TableControlPanel ctrlPanel = new TableControlPanel(_shell, SWT.NULL, _jt);
Label l = new Label(_shell, SWT.NONE);
l.setText("Level width:");
final Scale levelWidthScale = new Scale(_shell, SWT.HORIZONTAL);
levelWidthScale.setMaximum(40);
levelWidthScale.setMinimum(0);
levelWidthScale.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent ev) {
int val = levelWidthScale.getSelection();
hierarchyRenderer.setLevelWidth(val);
_jt.redraw();
}
});
}
Aggregations