use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.
the class PstmtSQLDialog method registerContextMenu.
private void registerContextMenu() {
parameterTable.getTable().addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(parameterTable.getTable());
}
});
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
Menu contextMenu = menuManager.createContextMenu(parameterTable.getTable());
parameterTable.getTable().setMenu(contextMenu);
Menu menu = new Menu(getShell(), SWT.POP_UP);
final MenuItem itemShowMuchValue = new MenuItem(menu, SWT.PUSH);
itemShowMuchValue.setText(Messages.pstmtSQLMuchItem);
itemShowMuchValue.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
//seems like MenuEvent can't get the mouse click Point
//so use the point which table MouseDown event marked
Point pt = clickPoint;
int selectIndex = parameterTable.getTable().getSelectionIndex();
final TableItem item = parameterTable.getTable().getItem(selectIndex);
if (item == null) {
return;
}
for (int i = 1; i < parameterTable.getTable().getColumnCount(); i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
String type = parameterTypeTable.getItem(0).getText(i);
SetPstmtValueDialog dialog = new SetPstmtValueDialog(getShell(), item, database, i, type);
if (IDialogConstants.OK_ID == dialog.open()) {
charSet = (String) item.getData(SetPstmtValueDialog.FILE_CHARSET);
valueList.get(selectIndex).getValue().set(i, item.getText(i));
packTable();
addTableItemToLast(selectIndex, item);
}
validate();
}
}
}
});
menu.addMenuListener(new MenuAdapter() {
public void menuShown(MenuEvent event) {
//seems like MenuEvent can't get the mouse click Point
//so use the point which table MouseDown event marked
Point pt = clickPoint;
int selectIndex = parameterTable.getTable().getSelectionIndex();
if (selectIndex < 0) {
itemShowMuchValue.setEnabled(false);
return;
}
final TableItem item = parameterTable.getTable().getItem(selectIndex);
if (item == null) {
itemShowMuchValue.setEnabled(false);
return;
}
for (int i = 1; i < parameterTable.getTable().getColumnCount(); i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
String type = parameterTypeTable.getItem(0).getText(i);
//if type is nut much value type ,set the menu disable
if (DBAttrTypeFormatter.isMuchValueType(type)) {
itemShowMuchValue.setEnabled(true);
} else {
itemShowMuchValue.setEnabled(false);
}
}
}
}
});
parameterTable.getTable().setMenu(menu);
}
use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.
the class DBAuthComparator method registerContextMenu.
/**
* register context menu
*/
private void registerContextMenu() {
userTableViewer.getTable().addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(userTableViewer.getTable());
}
});
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
Menu contextMenu = menuManager.createContextMenu(userTableViewer.getTable());
userTableViewer.getTable().setMenu(contextMenu);
Menu menu = new Menu(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.POP_UP);
final MenuItem editSerialItem = new MenuItem(menu, SWT.PUSH);
editSerialItem.setText(Messages.itemEditUser);
editSerialItem.setImage(CommonUIPlugin.getImage("icons/action/user_edit.png"));
editSerialItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
editUser();
}
});
final MenuItem dropSerialItem = new MenuItem(menu, SWT.PUSH);
dropSerialItem.setText(Messages.itemDropUser);
dropSerialItem.setImage(CommonUIPlugin.getImage("icons/action/user_delete.png"));
dropSerialItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
dropUser();
}
});
new MenuItem(menu, SWT.SEPARATOR);
final MenuItem addSerialItem = new MenuItem(menu, SWT.PUSH);
addSerialItem.setText(Messages.itemAddUser);
addSerialItem.setImage(CommonUIPlugin.getImage("icons/action/user_add.png"));
addSerialItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
addUser();
}
});
userTableViewer.getTable().setMenu(menu);
}
use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.
the class ViewDashboardEditorPart method registerContextMenu.
private void registerContextMenu() {
viewsDetailInfoTable.getTable().addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(viewsDetailInfoTable.getTable());
}
});
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
Menu contextMenu = menuManager.createContextMenu(viewsDetailInfoTable.getTable());
viewsDetailInfoTable.getTable().setMenu(contextMenu);
Menu menu = new Menu(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.POP_UP);
final MenuItem editViewItem = new MenuItem(menu, SWT.PUSH);
editViewItem.setText(Messages.viewDetailInfoPartTableEditViewBtn);
editViewItem.setImage(CommonUIPlugin.getImage("icons/action/schema_view_edit.png"));
editViewItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
editView();
}
});
final MenuItem dropViewItem = new MenuItem(menu, SWT.PUSH);
dropViewItem.setText(Messages.viewDetailInfoPartTableDropViewBtn);
dropViewItem.setImage(CommonUIPlugin.getImage("icons/action/schema_view_delete.png"));
dropViewItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
dropView();
}
});
new MenuItem(menu, SWT.SEPARATOR);
final MenuItem addViewItem = new MenuItem(menu, SWT.PUSH);
addViewItem.setText(Messages.viewDetailInfoPartTableCreateViewBtn);
addViewItem.setImage(CommonUIPlugin.getImage("icons/action/schema_view_add.png"));
addViewItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
addView();
}
});
viewsDetailInfoTable.getTable().setMenu(menu);
}
use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.
the class ApplicationActionBarAdvisor method fillCoolBar.
/**
* Fills the cool bar with the main toolbars for the window.
*
* @param coolBar the cool bar manager
*/
protected void fillCoolBar(ICoolBarManager coolBarManager) {
ActionManager manager = ActionManager.getInstance();
coolBarManager.setLockLayout(true);
IToolBarManager toolbarManager = new ToolBarManager(SWT.FLAT | SWT.WRAP | SWT.BOTTOM);
coolBarManager.add(new ToolBarContributionItem(toolbarManager, IActionConstants.TOOL_NEW1));
Bundle cqbBundle = Platform.getBundle(ApplicationUtil.CQB_PLUGIN_ID);
/* Active the CQB plugin */
if (cqbBundle != null) {
try {
cqbBundle.start();
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
}
Bundle cmBundle = Platform.getBundle(ApplicationUtil.CM_PLUGIN_ID);
/* Active the CM plugin */
if (cmBundle != null) {
try {
cmBundle.start();
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
}
// Change view actions
if (cqbBundle != null) {
DropDownAction viewAction = new DropDownAction(Messages.modeActionBig, IAction.AS_DROP_DOWN_MENU, CubridManagerAppPlugin.getImageDescriptor("icons/cubridmanager32.gif"));
viewAction.setDisabledImageDescriptor(CubridManagerAppPlugin.getImageDescriptor("icons/cubridmanager32.gif"));
MenuManager viewActionManager = viewAction.getMenuManager();
viewActionManager.add(manager.getAction(OpenCMPerspectiveAction.ID));
viewActionManager.add(manager.getAction(OpenCQBPerspectiveAction.ID));
ActionContributionItem viewItems = new ActionContributionItem(viewAction);
viewItems.setMode(ActionContributionItem.MODE_FORCE_TEXT);
viewItems.setId(IPerspectiveConstance.PERSPECTIVE_ACTION_CONTRIBUTION_ID);
toolbarManager.add(viewItems);
toolbarManager.add(new Separator());
}
/*TOOLS-3988 There still is the install option after installing cmt plugin.*/
Bundle bundle = Platform.getBundle(ApplicationUtil.CMT_PLUGIN_ID);
if (bundle == null) {
toolbarManager.add(new Separator());
IAction action = ActionManager.getInstance().getAction(InstallMigrationToolkitAction.ID);
if (action != null) {
ActionContributionItem item = new ActionContributionItem(action);
item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
toolbarManager.add(item);
item.setId(IPerspectiveConstance.MIGRATION_ACTION_CONTRIBUTION_ID);
}
} else {
/*Active the CMT plugin */
try {
bundle.start();
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
}
// Help
toolbarManager.add(new Separator());
DropDownAction helpDropAction = new DropDownAction(Messages.helpActionNameBig, IAction.AS_DROP_DOWN_MENU, CubridManagerUIPlugin.getImageDescriptor("icons/action/help_big.png"));
helpDropAction.setDisabledImageDescriptor(CubridManagerUIPlugin.getImageDescriptor("icons/action/help_big.png"));
MenuManager helpActionManager = helpDropAction.getMenuManager();
helpActionManager.add(manager.getAction(HelpDocumentAction.ID));
if ("ko".equals(Messages.language)) {
helpActionManager.add(newFeatureAction);
}
helpActionManager.add(new Separator());
helpActionManager.add(createItem(ReportBugAction.ID));
helpActionManager.add(new Separator());
helpActionManager.add(manager.getAction(ViewServerVersionAction.ID));
helpActionManager.add(clientVersionAction);
ActionContributionItem helpItems = new ActionContributionItem(helpDropAction);
helpItems.setMode(ActionContributionItem.MODE_FORCE_TEXT);
helpItems.setId(IPerspectiveConstance.HELP_ACTION_CONTRIBUTION_ID);
toolbarManager.add(helpItems);
ControlContribution searchContribution = new ControlContribution(SearchContributionComposite.class.getName()) {
protected Control createControl(Composite parent) {
return new SearchContributionComposite(parent, SWT.None);
}
};
searchContribution.setId(IPerspectiveConstance.SEARCH_ACTION_CONTRIBUTION_ID);
toolbarManager.add(new Separator());
toolbarManager.add(searchContribution);
}
use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.
the class RunSQLFileDialog method registerContextMenu.
/**
* register context menu
*/
private void registerContextMenu() {
sqlFileTableViewer.getTable().addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(sqlFileTableViewer.getTable());
}
});
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
Menu contextMenu = menuManager.createContextMenu(sqlFileTableViewer.getTable());
sqlFileTableViewer.getTable().setMenu(contextMenu);
Menu menu = new Menu(getShell(), SWT.POP_UP);
final MenuItem itemDelete = new MenuItem(menu, SWT.PUSH);
itemDelete.setText("delete");
itemDelete.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
List<String> deleteFiles = new ArrayList<String>();
for (int i = 0; i < sqlFileTableViewer.getTable().getSelectionIndices().length; i++) {
int index = sqlFileTableViewer.getTable().getSelectionIndices()[i];
deleteFiles.add(filesList.get(index));
}
filesList.removeAll(deleteFiles);
sqlFileTableViewer.setInput(filesList);
sqlFileTableViewer.refresh();
}
});
sqlFileTableViewer.getTable().setMenu(menu);
Menu dbTablecontextMenu = menuManager.createContextMenu(databaseTableViewer.getTable());
databaseTableViewer.getTable().setMenu(dbTablecontextMenu);
Menu dbTableMenu = new Menu(getShell(), SWT.POP_UP);
final MenuItem dbTableItemDelete = new MenuItem(dbTableMenu, SWT.PUSH);
dbTableItemDelete.setText("delete");
dbTableItemDelete.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
List<CubridDatabase> deleteCubridDatabase = new ArrayList<CubridDatabase>();
for (int i = 0; i < databaseTableViewer.getTable().getSelectionIndices().length; i++) {
int index = databaseTableViewer.getTable().getSelectionIndices()[i];
deleteCubridDatabase.add(cubridDatabases[index]);
}
List<CubridDatabase> dbList = Arrays.asList(cubridDatabases);
ArrayList<CubridDatabase> newDbList = new ArrayList<CubridDatabase>();
for (CubridDatabase cubridDatabase : dbList) {
if (deleteCubridDatabase.contains(cubridDatabase)) {
continue;
}
newDbList.add(cubridDatabase);
}
cubridDatabases = newDbList.toArray(new CubridDatabase[newDbList.size()]);
databaseTableViewer.setInput(cubridDatabases);
databaseTableViewer.refresh();
}
});
sqlFileTableViewer.getTable().setMenu(menu);
databaseTableViewer.getTable().setMenu(dbTableMenu);
runSQLFileDialogDNDController = new RunSQLFileDialogDNDController(this);
runSQLFileDialogDNDController.registerDropTarget();
}
Aggregations