use of org.eclipse.swt.events.MenuEvent in project webtools.sourceediting by eclipse.
the class RefactorActionGroup method refactorMenuShown.
private void refactorMenuShown(final IMenuManager refactorSubmenu) {
// we know that we have an MenuManager since we created it in
// addRefactorSubmenu.
Menu menu = ((MenuManager) refactorSubmenu).getMenu();
menu.addMenuListener(new MenuAdapter() {
public void menuHidden(MenuEvent e) {
refactorMenuHidden(refactorSubmenu);
}
});
for (Iterator iter = fEditorActions.iterator(); iter.hasNext(); ) {
Action action = (Action) iter.next();
if (action instanceof SelectionDispatchAction) {
SelectionDispatchAction selectionAction = (SelectionDispatchAction) action;
selectionAction.update(selection);
}
}
refactorSubmenu.removeAll();
if (fillRefactorMenu(refactorSubmenu) == 0)
refactorSubmenu.add(fNoActionAvailable);
}
use of org.eclipse.swt.events.MenuEvent in project cogtool by cogtool.
the class MenuFactory method buildMenu.
// addWindowMenu
public static void buildMenu(MenuType[] neededMenus, Shell viewShell, final Listener selectionListener, ListenerIdentifierMap lIDMap, IWindowMenuData<?> menuData) {
int windowMenuIndex = -1;
int fileMenuIndex = -1;
MenuUtil.CascadingMenuItemDefinition[] defn = new MenuUtil.CascadingMenuItemDefinition[neededMenus.length];
for (int i = 0; i < neededMenus.length; i++) {
defn[i] = menuDefns[neededMenus[i].getOrdering()];
if (neededMenus[i] == MenuFactory.MenuType.FileMenu) {
fileMenuIndex = i;
} else if (neededMenus[i] == MenuFactory.MenuType.WindowMenu) {
windowMenuIndex = i;
defn[i].menuItems = menuData.getWindowMenuLeadItems();
}
}
Menu newMenuBar = MenuUtil.createMenu(viewShell, SWT.BAR | SWT.LEFT_TO_RIGHT, defn, ListenerIdentifierMap.NORMAL, selectionListener, lIDMap);
if (fileMenuIndex != -1) {
final Menu fileMenu = newMenuBar.getItem(fileMenuIndex).getMenu();
fileMenu.addMenuListener(new MenuAdapter() {
@Override
public void menuShown(MenuEvent evt) {
for (MenuItem item : fileMenu.getItems()) {
//This menu item corresponds to the Open Recent submenu
if (item.getData() == RECENT_FLAG) {
Menu cascade = item.getMenu();
for (MenuItem subItem : cascade.getItems()) {
subItem.dispose();
}
char recentIndex = '0';
for (String pathName : CogToolPref.getRecent()) {
if (!(MenuFactory.UNSET_FILE.equals(pathName))) {
if (recentIndex != 0) {
if (recentIndex != '9') {
recentIndex++;
} else {
recentIndex = ' ';
}
}
String safePathName = "&" + recentIndex + " " + pathName.replaceAll("&", "&&");
MenuItem mi = MenuUtil.addMenuItem(cascade, safePathName, SWT.PUSH);
CogToolLID lid = new CogToolLID.OpenRecentLID("OpenRecent", pathName);
mi.addListener(SWT.Selection, selectionListener);
mi.setData(lid);
}
}
boolean hasRecent = CogToolPref.hasRecent();
if (hasRecent) {
MenuUtil.addMenuItem(cascade, "", SWT.SEPARATOR);
}
MenuItem clearItem = MenuUtil.addMenuItem(cascade, L10N.get("MI.ClearItems", "Clear items"), SWT.PUSH);
clearItem.addListener(SWT.Selection, selectionListener);
clearItem.setData(CogToolLID.ClearRecent);
clearItem.setEnabled(hasRecent);
//break;
} else // TODO this is a mess and needs to be tidied up
if (item.getData() == IMPORT_OTHER_FLAG) {
Menu cascade = item.getMenu();
for (MenuItem subItem : cascade.getItems()) {
subItem.dispose();
}
File directory = null;
String directoryName = CogToolPref.CONVERTER_DIRECTORY.getString();
boolean researchMode = CogToolPref.RESEARCH.getBoolean();
if (directoryName != null && !directoryName.equals("")) {
directory = new File(directoryName);
URL[] urls = null;
try {
// TODO: fix this deprecated method
URL url = directory.toURL();
urls = new URL[] { url };
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (directory.exists()) {
URLClassLoader classLoader = new URLClassLoader(urls);
String[] children = directory.list();
boolean firstMenuItem = true;
for (String resource : children) {
System.out.println("Resource " + resource);
resource = (resource.lastIndexOf(".") == -1) ? resource : resource.substring(0, resource.lastIndexOf('.'));
try {
Class<ImportConverter> translatorClass = (Class<ImportConverter>) classLoader.loadClass(resource);
try {
Object converter = null;
try {
converter = translatorClass.newInstance();
Class[] nameMethodParameters = new Class[0];
Method method = translatorClass.getMethod("name", nameMethodParameters);
String name = (String) method.invoke(converter);
if (!name.endsWith("...")) {
name = name + "...";
}
if (firstMenuItem) {
MenuUtil.addMenuItem(cascade, "", SWT.SEPARATOR);
firstMenuItem = false;
}
String menuItemName = "Import Designs from " + name;
MenuItem mi = MenuUtil.addMenuItem(cascade, menuItemName, SWT.PUSH);
CogToolLID lid = new CogToolLID.ConverterFilesLID("NewDesignFromImport");
((ConverterFilesLID) lid).setClassAttribute(translatorClass);
mi.setData(lid);
mi.addListener(SWT.Selection, selectionListener);
} catch (Exception ex) {
throw new RcvrImportException("The file " + resource + " can not be loaded as a class.");
}//Interact with the user and display the message.
catch (Error er) {
System.out.println("Error was thrown!");
//TODO: How to throw this recoverable exception but move on?
//throw new RcvrImportException("The file " + resource + " can not be loaded as a class.");
}
} catch (Exception ex) {
throw new RcvrImportException("The file " + resource + " is not a valid converter file.");
} catch (Error er) {
System.out.println("Error was thrown2!");
//TODO: How to throw this recoverable exception but move on?
//throw new RcvrImportException("The file " + resource + " can not be loaded as a class.");
}
} catch (Exception ex) {
throw new RcvrImportException("The file " + resource + " cannot be loaded as a class.");
} catch (Error er) {
System.out.println("Error was thrown3!");
//TODO: How to throw this recoverable exception but move on?
//throw new RcvrImportException("The file " + resource + " can not be loaded as a class.");
}
}
break;
}
}
}
}
}
});
}
if (windowMenuIndex != -1) {
// reset!
defn[windowMenuIndex].menuItems = null;
addWindowMenu(newMenuBar.getItem(windowMenuIndex).getMenu(), menuData);
}
viewShell.setMenuBar(newMenuBar);
}
use of org.eclipse.swt.events.MenuEvent in project dbeaver by serge-rider.
the class NavigatorUtils method createContextMenu.
public static MenuManager createContextMenu(final IWorkbenchSite workbenchSite, final Viewer viewer, final IMenuListener menuListener) {
final Control control = viewer.getControl();
final MenuManager menuMgr = new MenuManager();
Menu menu = menuMgr.createContextMenu(control);
menu.addMenuListener(new MenuListener() {
@Override
public void menuHidden(MenuEvent e) {
}
@Override
public void menuShown(MenuEvent e) {
Menu m = (Menu) e.widget;
DBNNode node = getSelectedNode(viewer.getSelection());
if (node != null && !node.isLocked() && node.allowsOpen()) {
String commandID = NavigatorUtils.getNodeActionCommand(DBXTreeNodeHandler.Action.open, node, CoreCommands.CMD_OBJECT_OPEN);
// Get contribution item from menu item and check it's ID
for (MenuItem item : m.getItems()) {
Object itemData = item.getData();
if (itemData instanceof IContributionItem) {
String contribId = ((IContributionItem) itemData).getId();
if (contribId != null && contribId.equals(commandID)) {
m.setDefaultItem(item);
}
}
}
}
}
});
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(final IMenuManager manager) {
ViewerColumnController columnController = ViewerColumnController.getFromControl(control);
if (columnController != null && columnController.isClickOnHeader()) {
columnController.fillConfigMenu(manager);
manager.add(new Separator());
return;
}
manager.add(new GroupMarker(MB_NAVIGATOR_ADDITIONS));
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
final DBNNode selectedNode = getSelectedNode(viewer);
if (selectedNode != null && !selectedNode.isLocked() && workbenchSite != null) {
// Add "Set active object" menu
if (selectedNode.isPersisted() && selectedNode instanceof DBNDatabaseNode && !(selectedNode instanceof DBNDatabaseFolder) && ((DBNDatabaseNode) selectedNode).getObject() != null) {
final DBSObjectSelector activeContainer = DBUtils.getParentAdapter(DBSObjectSelector.class, ((DBNDatabaseNode) selectedNode).getObject());
if (activeContainer != null && activeContainer.supportsDefaultChange()) {
DBSObject activeChild;
activeChild = activeContainer.getDefaultObject();
if (activeChild != ((DBNDatabaseNode) selectedNode).getObject()) {
DBNDatabaseNode databaseNode = (DBNDatabaseNode) selectedNode;
if (databaseNode.getObject() != null && (activeChild == null || activeChild.getClass() == databaseNode.getObject().getClass())) {
// + databaseNode.getNodeType();
String text = "Set Active ";
// Fill context menu
IAction action = ActionUtils.makeAction(new NavigatorActionSetActiveObject(), workbenchSite, selection, text, null, null);
manager.add(action);
}
}
}
}
manager.add(new Separator());
manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
manager.add(new GroupMarker(IActionConstants.MB_ADDITIONS_END));
// Add properties button
if (PreferencesUtil.hasPropertiesContributors(selection.getFirstElement())) {
manager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.FILE_PROPERTIES));
}
if (selectedNode.isPersisted()) {
// Add refresh button
manager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.FILE_REFRESH));
}
}
manager.add(new GroupMarker(CoreCommands.GROUP_TOOLS));
if (menuListener != null) {
menuListener.menuAboutToShow(manager);
}
}
});
menuMgr.setRemoveAllWhenShown(true);
control.setMenu(menu);
control.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
menuMgr.dispose();
}
});
return menuMgr;
}
use of org.eclipse.swt.events.MenuEvent in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method registerCubridBrokerTableContextMenu.
/**
* register CubridConfTable context menu
*/
private void registerCubridBrokerTableContextMenu() {
brokerConfTabTableViewer.getTable().addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(brokerConfTabTableViewer.getTable());
}
});
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
Menu contextMenu = menuManager.createContextMenu(brokerConfTabTableViewer.getTable());
brokerConfTabTableViewer.getTable().setMenu(contextMenu);
Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
final MenuItem itemEditAnnotation = new MenuItem(menu, SWT.PUSH);
itemEditAnnotation.setText(Messages.confEditorTableMenuEditAnnotation);
itemEditAnnotation.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("all")
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 = cubridBrokerTableClickPoint;
int selectIndex = brokerConfTabTableViewer.getTable().getSelectionIndex();
final TableItem item = brokerConfTabTableViewer.getTable().getItem(selectIndex);
if (item == null) {
return;
}
for (int i = 0; i < brokerConfTabTableViewer.getTable().getColumnCount(); i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
if (i == 0) {
CommonUITool.openErrorBox(getSite().getShell(), Messages.annotationDialogOpenErrorMsg);
return;
}
IStructuredSelection selection = (IStructuredSelection) brokerConfTabTableViewer.getSelection();
HashMap<String, String> valueMap = (HashMap<String, String>) selection.getFirstElement();
String serverName = cubridBrokerConfListData.get(0).get(i + "");
String parentPropertyKey = valueMap.get("0");
String parentKey = " ";
Map<String, String> brokerMap = cubridBrokerConfListData.get(1);
String brokerName = "";
if (brokerMap != null) {
brokerName = brokerMap.get(i + "");
}
if (selectIndex == 0) {
parentKey += serverName;
} else {
if (selectIndex == 1) {
parentKey += serverName + "->" + brokerName;
} else {
parentKey += serverName + "->" + brokerName + "->" + parentPropertyKey;
}
}
String annotationKey = Integer.toString(i) + BrokerConfPersistUtil.ANNOTATION;
CubridBrokerConfEditAnnotationDialog dialog = new CubridBrokerConfEditAnnotationDialog(getSite().getShell(), parentKey, annotationKey, valueMap);
if (IDialogConstants.OK_ID == dialog.open()) {
setDirty(true);
}
}
}
}
});
final MenuItem itemAddBrokerConf = new MenuItem(menu, SWT.PUSH);
itemAddBrokerConf.setText(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorAddBrokerConfItemLabel);
itemAddBrokerConf.setImage(CommonUIPlugin.getImage("icons/action/column_insert.png"));
itemAddBrokerConf.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
progress.setCancelable(true);
progress.run(true, true, new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) throws InvocationTargetException {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
// int horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y -
// brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
// = brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
monitor.beginTask(Messages.unifyHostConfigEditorAddColumnMsg, 1);
addBrokerConfColumn();
monitor.worked(1);
// horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y - horizontalSelectionInt;
// brokerConfTabTableViewer.getTable().getHorizontalBar().setSelection(horizontalSelectionInt + 160);
}
});
}
});
} catch (Exception e) {
LOGGER.error("", e);
}
setDirty(true);
}
});
final MenuItem itemDeleteBrokerConf = new MenuItem(menu, SWT.PUSH);
itemDeleteBrokerConf.setText(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorDeleteBrokerConfItemLabel);
itemDeleteBrokerConf.setImage(CommonUIPlugin.getImage("icons/action/column_delete.png"));
itemDeleteBrokerConf.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
progress.setCancelable(true);
progress.run(true, true, new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) throws InvocationTargetException {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
// int horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y -
// brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
// = brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
monitor.beginTask(Messages.unifyHostConfigEditorDelColumnMsg, 1);
delBrokerConfColumn();
monitor.worked(1);
// horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y - horizontalSelectionInt;
// brokerConfTabTableViewer.getTable().getHorizontalBar().setSelection(horizontalSelectionInt + 160);
}
});
}
});
} catch (Exception e) {
LOGGER.error("", e);
}
setDirty(true);
}
});
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 = cubridBrokerTableClickPoint;
// click timing
if (System.currentTimeMillis() - cubridBrokerTableClickPointTiming > 300) {
itemEditAnnotation.setEnabled(false);
itemDeleteBrokerConf.setEnabled(false);
itemAddBrokerConf.setEnabled(false);
return;
}
int selectIndex = brokerConfTabTableViewer.getTable().getSelectionIndex();
if (selectIndex == -1) {
itemEditAnnotation.setEnabled(false);
itemDeleteBrokerConf.setEnabled(false);
itemAddBrokerConf.setEnabled(false);
return;
}
if (selectIndex == 0) {
itemEditAnnotation.setEnabled(false);
itemDeleteBrokerConf.setEnabled(false);
itemAddBrokerConf.setEnabled(true);
return;
}
final TableItem item = brokerConfTabTableViewer.getTable().getItem(selectIndex);
if (item == null) {
return;
}
for (int i = 0; i < brokerConfTabTableViewer.getTable().getColumnCount(); i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
if (i == 0) {
itemEditAnnotation.setEnabled(false);
itemDeleteBrokerConf.setEnabled(false);
} else {
itemEditAnnotation.setEnabled(true);
itemDeleteBrokerConf.setEnabled(true);
}
}
}
itemAddBrokerConf.setEnabled(true);
}
});
brokerConfTabTableViewer.getTable().setMenu(menu);
}
use of org.eclipse.swt.events.MenuEvent in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method registerCubridConfTableContextMenu.
/**
* register CubridConfTable context menu
*/
private void registerCubridConfTableContextMenu() {
cubridConfTabTableViewer.getTable().addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(cubridConfTabTableViewer.getTable());
}
});
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
Menu contextMenu = menuManager.createContextMenu(cubridConfTabTableViewer.getTable());
cubridConfTabTableViewer.getTable().setMenu(contextMenu);
Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
final MenuItem itemEditAnnotation = new MenuItem(menu, SWT.PUSH);
itemEditAnnotation.setText(Messages.confEditorTableMenuEditAnnotation);
itemEditAnnotation.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("all")
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 = cubridConfTableClickPoint;
int selectIndex = cubridConfTabTableViewer.getTable().getSelectionIndex();
final TableItem item = cubridConfTabTableViewer.getTable().getItem(selectIndex);
if (item == null) {
return;
}
for (int i = 0; i < cubridConfTabTableViewer.getTable().getColumnCount(); i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
if (i == 0) {
CommonUITool.openErrorBox(getSite().getShell(), Messages.annotationDialogOpenErrorMsg);
return;
}
IStructuredSelection selection = (IStructuredSelection) cubridConfTabTableViewer.getSelection();
HashMap<String, String> valueMap = (HashMap<String, String>) selection.getFirstElement();
String serverName = cubridConfConfigListData.get(0).get(i + "");
String parentPropertyKey = valueMap.get("0");
String parentKey = " ";
Map<String, String> cubridMap = cubridConfConfigListData.get(1);
String cubridName = "";
if (cubridMap != null) {
cubridName = cubridMap.get(i + "");
}
if (selectIndex == 0) {
parentKey += serverName;
} else {
if (selectIndex == 1) {
parentKey += serverName + "->" + cubridName;
} else {
parentKey += serverName + "->" + cubridName + "->" + parentPropertyKey;
}
}
String annotationKey = Integer.toString(i) + BrokerConfPersistUtil.ANNOTATION;
CubridBrokerConfEditAnnotationDialog dialog = new CubridBrokerConfEditAnnotationDialog(getSite().getShell(), parentKey, annotationKey, valueMap);
if (IDialogConstants.OK_ID == dialog.open()) {
setDirty(true);
}
}
}
}
});
final MenuItem itemAddCubridConf = new MenuItem(menu, SWT.PUSH);
itemAddCubridConf.setText(Messages.unifyHostConfigEditorAddCubridConfColumn);
itemAddCubridConf.setImage(CommonUIPlugin.getImage("icons/action/column_insert.png"));
itemAddCubridConf.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
progress.setCancelable(true);
progress.run(true, true, new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) throws InvocationTargetException {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
// int horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y -
// brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
// = brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
monitor.beginTask(Messages.unifyHostConfigEditorAddColumnMsg, 1);
addCubridConfColumn();
monitor.worked(1);
// horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y - horizontalSelectionInt;
// brokerConfTabTableViewer.getTable().getHorizontalBar().setSelection(horizontalSelectionInt + 160);
}
});
}
});
} catch (Exception e) {
LOGGER.error("", e);
}
setDirty(true);
}
});
final MenuItem itemDelCubridConf = new MenuItem(menu, SWT.PUSH);
itemDelCubridConf.setText(Messages.unifyHostConfigEditorDelCubridConfColumn);
itemDelCubridConf.setImage(CommonUIPlugin.getImage("icons/action/column_delete.png"));
itemDelCubridConf.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
progress.setCancelable(true);
progress.run(true, true, new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) throws InvocationTargetException {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
// int horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y -
// brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
// = brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
monitor.beginTask(Messages.unifyHostConfigEditorDelColumnMsg, 1);
delCubridConfColumn();
monitor.worked(1);
// horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y - horizontalSelectionInt;
// brokerConfTabTableViewer.getTable().getHorizontalBar().setSelection(horizontalSelectionInt + 160);
}
});
}
});
} catch (Exception e) {
LOGGER.error("", e);
}
}
});
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 = cubridConfTableClickPoint;
// click timing
if (System.currentTimeMillis() - cubridConfTableClickPointTiming > 300) {
itemEditAnnotation.setEnabled(false);
itemDelCubridConf.setEnabled(false);
itemAddCubridConf.setEnabled(false);
return;
}
int selectIndex = cubridConfTabTableViewer.getTable().getSelectionIndex();
if (selectIndex == -1) {
itemEditAnnotation.setEnabled(false);
itemDelCubridConf.setEnabled(false);
itemAddCubridConf.setEnabled(false);
return;
}
if (selectIndex == 0) {
itemEditAnnotation.setEnabled(false);
itemDelCubridConf.setEnabled(false);
itemAddCubridConf.setEnabled(true);
return;
}
final TableItem item = cubridConfTabTableViewer.getTable().getItem(selectIndex);
if (item == null) {
return;
}
for (int i = 0; i < cubridConfTabTableViewer.getTable().getColumnCount(); i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
if (i == 0) {
itemEditAnnotation.setEnabled(false);
itemDelCubridConf.setEnabled(false);
} else {
itemEditAnnotation.setEnabled(true);
itemDelCubridConf.setEnabled(true);
}
}
}
itemAddCubridConf.setEnabled(true);
}
});
cubridConfTabTableViewer.getTable().setMenu(menu);
}
Aggregations