use of org.eclipse.swt.widgets.MenuItem in project archi by archimatetool.
the class MagicConnectionCreationTool method addConnectionActions.
/**
* Add Connection->Element Actions
*/
private void addConnectionActions(Menu menu, IDiagramModelArchimateComponent sourceDiagramModelComponent) {
for (EClass relationshipType : ArchimateModelUtils.getRelationsClasses()) {
if (ArchimateModelUtils.isValidRelationshipStart(sourceDiagramModelComponent.getArchimateConcept(), relationshipType)) {
MenuItem item = addConnectionAction(menu, relationshipType, false);
Menu subMenu = new Menu(item);
item.setMenu(subMenu);
addConnectionActions(subMenu, Messages.MagicConnectionCreationTool_7, sourceDiagramModelComponent, ArchimateModelUtils.getStrategyClasses(), relationshipType);
addConnectionActions(subMenu, Messages.MagicConnectionCreationTool_0, sourceDiagramModelComponent, ArchimateModelUtils.getBusinessClasses(), relationshipType);
addConnectionActions(subMenu, Messages.MagicConnectionCreationTool_1, sourceDiagramModelComponent, ArchimateModelUtils.getApplicationClasses(), relationshipType);
addConnectionActions(subMenu, Messages.MagicConnectionCreationTool_2, sourceDiagramModelComponent, ArchimateModelUtils.getTechnologyClasses(), relationshipType);
addConnectionActions(subMenu, Messages.MagicConnectionCreationTool_9, sourceDiagramModelComponent, ArchimateModelUtils.getPhysicalClasses(), relationshipType);
addConnectionActions(subMenu, Messages.MagicConnectionCreationTool_3, sourceDiagramModelComponent, ArchimateModelUtils.getMotivationClasses(), relationshipType);
addConnectionActions(subMenu, Messages.MagicConnectionCreationTool_4, sourceDiagramModelComponent, ArchimateModelUtils.getImplementationMigrationClasses(), relationshipType);
List<EClass> list = new ArrayList<EClass>();
list.addAll(Arrays.asList(ArchimateModelUtils.getOtherClasses()));
list.addAll(Arrays.asList(ArchimateModelUtils.getConnectorClasses()));
EClass[] arr = list.toArray(new EClass[] {});
addConnectionActions(subMenu, Messages.MagicConnectionCreationTool_8, sourceDiagramModelComponent, arr, relationshipType);
if (subMenu.getItemCount() == 0) {
// Nothing there
item.dispose();
}
}
}
}
use of org.eclipse.swt.widgets.MenuItem in project archi by archimatetool.
the class MagicConnectionCreationTool method addConnectionActions.
private void addConnectionActions(Menu menu, String menuText, IDiagramModelArchimateComponent sourceDiagramModelComponent, EClass[] list, EClass relationshipType) {
MenuItem item = new MenuItem(menu, SWT.CASCADE);
item.setText(menuText);
Menu subMenu = new Menu(item);
item.setMenu(subMenu);
for (EClass type : list) {
// Check if allowed by Viewpoint
if (!isAllowedTargetTypeInViewpoint(sourceDiagramModelComponent, type)) {
continue;
}
if (ArchimateModelUtils.isValidRelationship(sourceDiagramModelComponent.getArchimateConcept().eClass(), type, relationshipType)) {
addElementAction(subMenu, type);
}
}
if (subMenu.getItemCount() == 0) {
// Nothing there
item.dispose();
}
}
use of org.eclipse.swt.widgets.MenuItem in project archi by archimatetool.
the class MagicConnectionCreationTool method addElementActions.
private void addElementActions(Menu menu, String menuText, IDiagramModelArchimateComponent sourceDiagramModelComponent, EClass[] list) {
MenuItem item = new MenuItem(menu, SWT.CASCADE);
item.setText(menuText);
Menu subMenu = new Menu(item);
item.setMenu(subMenu);
IArchimateConcept sourceConcept = sourceDiagramModelComponent.getArchimateConcept();
for (EClass type : list) {
// Check if allowed by Viewpoint
if (!isAllowedTargetTypeInViewpoint(sourceDiagramModelComponent, type)) {
continue;
}
MenuItem subItem = addElementAction(subMenu, type);
Menu childSubMenu = new Menu(subItem);
subItem.setMenu(childSubMenu);
for (EClass typeRel : ArchimateModelUtils.getRelationsClasses()) {
if (ArchimateModelUtils.isValidRelationship(sourceConcept.eClass(), type, typeRel)) {
addConnectionAction(childSubMenu, typeRel, false);
}
}
if (childSubMenu.getItemCount() == 0) {
// Nothing there
subItem.dispose();
}
}
if (subMenu.getItemCount() == 0) {
// Nothing there
item.dispose();
}
}
use of org.eclipse.swt.widgets.MenuItem in project cubrid-manager by CUBRID.
the class ServiceDashboardEditor method initMenu.
private void initMenu(Tree tree) {
ActionManager manager = ActionManager.getInstance();
Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
tree.setMenu(menu);
refreshMenuItem = new MenuItem(menu, SWT.PUSH);
refreshMenuItem.setText(Messages.btnRefresh);
refreshMenuItem.setImage(CubridManagerUIPlugin.getImage("icons/action/refresh.png"));
refreshMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
loadAllData();
}
});
new MenuItem(menu, SWT.SEPARATOR);
final ConnectHostAction connectHostAction = (ConnectHostAction) manager.getAction(ConnectHostAction.ID);
connectMenuItem = new MenuItem(menu, SWT.PUSH);
connectMenuItem.setText(connectHostAction.getText());
connectMenuItem.setImage(connectHostAction.getImageDescriptor().createImage());
connectMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
connectHostAction.doRun(getSelectedServer());
loadAllData();
}
});
final DisConnectHostAction disConnectHostAction = (DisConnectHostAction) manager.getAction(DisConnectHostAction.ID);
disConnectMenuItem = new MenuItem(menu, SWT.PUSH);
disConnectMenuItem.setText(disConnectHostAction.getText());
disConnectMenuItem.setImage(disConnectHostAction.getImageDescriptor().createImage());
disConnectMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
disConnectHostAction.doRun(getSelectedServer());
loadAllData();
}
});
new MenuItem(menu, SWT.SEPARATOR);
final AddHostAction addHostAction = (AddHostAction) manager.getAction(AddHostAction.ID);
addHostMenuItem = new MenuItem(menu, SWT.PUSH);
addHostMenuItem.setText(addHostAction.getText());
addHostMenuItem.setImage(addHostAction.getImageDescriptor().createImage());
addHostMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
addHostAction.doRun(getSelectedServer());
loadAllData();
}
});
final EditHostAction editHostAction = (EditHostAction) manager.getAction(EditHostAction.ID);
editHostMenuItem = new MenuItem(menu, SWT.PUSH);
editHostMenuItem.setText(editHostAction.getText());
editHostMenuItem.setImage(editHostAction.getImageDescriptor().createImage());
editHostMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
editHostAction.doRun(getSelectedServer(), false);
loadAllData();
}
});
final DeleteHostAction deleteHostAction = (DeleteHostAction) manager.getAction(DeleteHostAction.ID);
deleteHostMenuItem = new MenuItem(menu, SWT.PUSH);
deleteHostMenuItem.setText(deleteHostAction.getText());
deleteHostMenuItem.setImage(deleteHostAction.getImageDescriptor().createImage());
deleteHostMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
deleteHostAction.doRun(getSelectedServer());
loadAllData();
}
});
new MenuItem(menu, SWT.SEPARATOR);
final StartServiceAction startServiceAction = (StartServiceAction) manager.getAction(StartServiceAction.ID);
startServiceMenuItem = new MenuItem(menu, SWT.PUSH);
startServiceMenuItem.setText(startServiceAction.getText());
startServiceMenuItem.setImage(startServiceAction.getImageDescriptor().createImage());
startServiceMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
startServiceAction.doRun(getSelectedServer());
loadAllData();
}
});
final StopServiceAction stopServiceAction = (StopServiceAction) manager.getAction(StopServiceAction.ID);
stopServiceMenuItem = new MenuItem(menu, SWT.PUSH);
stopServiceMenuItem.setText(stopServiceAction.getText());
stopServiceMenuItem.setImage(stopServiceAction.getImageDescriptor().createImage());
stopServiceMenuItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
stopServiceAction.doRun(getSelectedServer());
loadAllData();
}
});
menu.addMenuListener(new MenuListener() {
public void menuShown(MenuEvent e) {
updateMenuItems();
}
public void menuHidden(MenuEvent e) {
}
});
}
use of org.eclipse.swt.widgets.MenuItem in project cubrid-manager by CUBRID.
the class MultiDatabaseLoginFailedDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
getShell().setText(Messages.multiDatabaseLoginDialogTitle);
Composite parentComp = (Composite) super.createDialogArea(parent);
setTitle(Messages.multiDatabaseLoginDialogTitle);
setMessage(Messages.multiDatabaseLoginDialogMessages);
databaseTable = new TableViewer(parentComp, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
databaseTable.getTable().setLayoutData(gridData);
databaseTable.getTable().setHeaderVisible(true);
databaseTable.getTable().setLinesVisible(true);
final TableViewerColumn columnHost = new TableViewerColumn(databaseTable, SWT.CENTER);
columnHost.getColumn().setWidth(120);
columnHost.getColumn().setText(Messages.multiDatabaseLoginDialogColumnHostAddress);
final TableViewerColumn columnDatabase = new TableViewerColumn(databaseTable, SWT.CENTER);
columnDatabase.getColumn().setWidth(150);
columnDatabase.getColumn().setText(Messages.multiDatabaseLoginDialogColumnDbName);
final TableViewerColumn columnUser = new TableViewerColumn(databaseTable, SWT.CENTER);
columnUser.getColumn().setWidth(100);
columnUser.getColumn().setText(Messages.multiDatabaseLoginDialogColumnUser);
final TableViewerColumn columnErrMsg = new TableViewerColumn(databaseTable, SWT.CENTER);
columnErrMsg.getColumn().setWidth(200);
columnErrMsg.getColumn().setText(Messages.multiDatabaseLoginDialogColumnErrMsg);
final TableViewerColumn columnStatus = new TableViewerColumn(databaseTable, SWT.CENTER);
columnStatus.getColumn().setWidth(100);
columnStatus.getColumn().setText(Messages.multiDatabaseLoginDialogColumnStatus);
databaseTable.setContentProvider(new ServerListContentProvider());
databaseTable.setLabelProvider(new ServerListLabelProvider());
databaseTable.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo = (MultiDatabaseloginFailedInfo) selection.getFirstElement();
editHost(multiDatabaseloginFailedInfo);
//if all database login , close this dialog
if (checkAllDatabaseLogin()) {
close();
}
}
});
databaseTable.setInput(failedDatabaseList);
MenuManager menuManager = new MenuManager();
Menu contextMenu = menuManager.createContextMenu(databaseTable.getTable());
databaseTable.getTable().setMenu(contextMenu);
Menu menu = new Menu(getShell(), SWT.POP_UP);
final MenuItem itemEdit = new MenuItem(menu, SWT.PUSH);
itemEdit.setText(Messages.multiDatabaseLoginDialogEditLabel);
itemEdit.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
IStructuredSelection selection = (StructuredSelection) databaseTable.getSelection();
MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo = (MultiDatabaseloginFailedInfo) selection.getFirstElement();
editHost(multiDatabaseloginFailedInfo);
}
});
menu.addMenuListener(new MenuAdapter() {
public void menuShown(MenuEvent event) {
IStructuredSelection selection = (IStructuredSelection) databaseTable.getSelection();
MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo = (MultiDatabaseloginFailedInfo) selection.getFirstElement();
if (multiDatabaseloginFailedInfo.getCubridDatabase().isLogined()) {
itemEdit.setEnabled(false);
} else {
itemEdit.setEnabled(true);
}
}
});
databaseTable.getTable().setMenu(menu);
databaseTable.getTable().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (databaseTable.getTable().getSelectionIndices().length > 0) {
getButton(EDIT_ID).setEnabled(true);
} else {
getButton(EDIT_ID).setEnabled(false);
}
}
});
return parentComp;
}
Aggregations