Search in sources :

Example 86 with MenuItem

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();
            }
        }
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) ArrayList(java.util.ArrayList) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Example 87 with MenuItem

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();
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Example 88 with MenuItem

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();
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IArchimateConcept(com.archimatetool.model.IArchimateConcept) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Example 89 with MenuItem

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) {
        }
    });
}
Also used : StopServiceAction(com.cubrid.cubridmanager.ui.common.action.StopServiceAction) DisConnectHostAction(com.cubrid.cubridmanager.ui.host.action.DisConnectHostAction) MenuListener(org.eclipse.swt.events.MenuListener) DeleteHostAction(com.cubrid.cubridmanager.ui.host.action.DeleteHostAction) MenuItem(org.eclipse.swt.widgets.MenuItem) ActionManager(com.cubrid.common.ui.spi.action.ActionManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ConnectHostAction(com.cubrid.cubridmanager.ui.host.action.ConnectHostAction) DisConnectHostAction(com.cubrid.cubridmanager.ui.host.action.DisConnectHostAction) StartServiceAction(com.cubrid.cubridmanager.ui.common.action.StartServiceAction) Menu(org.eclipse.swt.widgets.Menu) AddHostAction(com.cubrid.cubridmanager.ui.host.action.AddHostAction) EditHostAction(com.cubrid.cubridmanager.ui.host.action.EditHostAction) SelectionListener(org.eclipse.swt.events.SelectionListener) MenuEvent(org.eclipse.swt.events.MenuEvent)

Example 90 with MenuItem

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;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuAdapter(org.eclipse.swt.events.MenuAdapter) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) MenuEvent(org.eclipse.swt.events.MenuEvent)

Aggregations

MenuItem (org.eclipse.swt.widgets.MenuItem)386 Menu (org.eclipse.swt.widgets.Menu)259 SelectionEvent (org.eclipse.swt.events.SelectionEvent)247 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)208 Event (org.eclipse.swt.widgets.Event)58 ArrayList (java.util.ArrayList)55 Point (org.eclipse.swt.graphics.Point)52 GridData (org.eclipse.swt.layout.GridData)49 Listener (org.eclipse.swt.widgets.Listener)48 SelectionListener (org.eclipse.swt.events.SelectionListener)46 Composite (org.eclipse.swt.widgets.Composite)43 GridLayout (org.eclipse.swt.layout.GridLayout)42 Rectangle (org.eclipse.swt.graphics.Rectangle)35 Label (org.eclipse.swt.widgets.Label)34 Shell (org.eclipse.swt.widgets.Shell)34 Table (org.eclipse.swt.widgets.Table)33 MenuEvent (org.eclipse.swt.events.MenuEvent)32 Button (org.eclipse.swt.widgets.Button)32 List (java.util.List)31 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)29