use of org.eclipse.swt.widgets.MenuItem 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.swt.widgets.MenuItem 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.swt.widgets.MenuItem in project cubrid-manager by CUBRID.
the class EditVirtualTableDialog method buildColumnTableMenu.
private void buildColumnTableMenu() {
Menu menu = new Menu(columnsTable.getShell(), SWT.POP_UP);
columnsTable.setMenu(menu);
final MenuItem deleteItem = new MenuItem(menu, SWT.PUSH);
deleteItem.setText(Messages.itemDeleteColumn);
deleteItem.setImage(CommonUIPlugin.getImageDescriptor("icons/action/table_record_delete.png").createImage());
deleteItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
deleteColumn();
}
});
menu.addMenuListener(new MenuListener() {
public void menuShown(MenuEvent e) {
TableItem[] tblItems = columnsTable.getSelection();
if (tblItems.length > 0) {
DBAttribute attr = (DBAttribute) tblItems[0].getData();
List<DBAttribute> items = getNewSchemaInfo().getAttributes();
if (!items.contains(attr)) {
deleteItem.setEnabled(false);
} else {
deleteItem.setEnabled(true);
}
}
}
public void menuHidden(MenuEvent e) {
}
});
}
use of org.eclipse.swt.widgets.MenuItem 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.swt.widgets.MenuItem in project cubrid-manager by CUBRID.
the class ViewDashboardEditorPart method createTabFolder.
public void createTabFolder(Composite parent) {
tabFolder = new CTabFolder(parent, SWT.TOP);
tabFolder.setLayout(new FillLayout());
tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
tabFolder.setSimple(false);
tabFolder.setUnselectedImageVisible(true);
tabFolder.setUnselectedCloseVisible(true);
tabFolder.setBorderVisible(true);
tabFolder.setSelectionBackground(ResourceManager.getColor(136, 161, 227));
tabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
Menu menu = new Menu(tabFolder.getShell(), SWT.POP_UP);
tabFolder.setMenu(menu);
MenuItem closeItem = new MenuItem(menu, SWT.PUSH);
closeItem.setText(Messages.tablesDetailInfoPartCloseMenu);
closeItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
CTabItem item = tabFolder.getSelection();
item.dispose();
}
});
MenuItem closeOthersItem = new MenuItem(menu, SWT.PUSH);
closeOthersItem.setText(Messages.tablesDetailInfoPartCloseOthersMenu);
closeOthersItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
CTabItem[] items = tabFolder.getItems();
CTabItem selectedItem = tabFolder.getSelection();
for (CTabItem item : items) {
if (!item.equals(selectedItem)) {
item.dispose();
}
}
}
});
MenuItem closeAllItem = new MenuItem(menu, SWT.PUSH);
closeAllItem.setText(Messages.tablesDetailInfoPartCloseAllMenu);
closeAllItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
CTabItem[] items = tabFolder.getItems();
for (CTabItem item : items) {
item.dispose();
}
}
});
}
Aggregations