Package lcmc.common.ui.utils

Examples of lcmc.common.ui.utils.MyMenuItem


                        //ptest, but this breaks group popup menu
                        //setMenuVisible(menu, false);
                        menu.setSelected(false);
                    }
                });
                final MyMenuItem item = dlm.getElementAt(index);
                item.actionThread();
            }
        });

        list.addMouseMotionListener(new MouseMotionAdapter() {
            @Override
            public void mouseMoved(final MouseEvent e) {
                final Thread thread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        int pIndex = list.locationToIndex(e.getPoint());
                        final Rectangle r = list.getCellBounds(pIndex, pIndex);
                        if (r == null) {
                            return;
                        }
                        if (!r.contains(e.getPoint())) {
                            pIndex = -1;
                        }
                        final int index = pIndex;
                        final int lastIndex = prevScrollingMenuIndex;
                        if (index == lastIndex) {
                            return;
                        }
                        prevScrollingMenuIndex = index;
                        application.invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                list.setSelectedIndex(index);
                            }
                        });
                        if (callbackHash != null) {
                            if (lastIndex >= 0) {
                                final MyMenuItem lastItem =
                                        dlm.getElementAt(lastIndex);
                                final ButtonCallback bc =
                                        callbackHash.get(lastItem);
                                if (bc != null) {
                                    bc.mouseOut(lastItem);
                                }
                            }
                            if (index >= 0) {
                                final MyMenuItem item = dlm.getElementAt(index);
                                final ButtonCallback bc =
                                        callbackHash.get(item);
                                if (bc != null) {
                                    bc.mouseOver(item);
                                }
                            }
                        }
                    }
                });
                thread.start();
            }
        });
        list.addKeyListener(new KeyListener() {
            @Override
            public void keyPressed(final KeyEvent e) {
                final int ch = e.getKeyCode();
                if (ch == KeyEvent.VK_UP && list.getSelectedIndex() == 0) {
                    application.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            typeToSearchField.requestFocus();
                        }
                    });
                } else if (ch == KeyEvent.VK_ESCAPE) {
                    application.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            for (final JDialog otherP : popups) {
                                otherP.dispose();
                            }
                        }
                    });
                    infoObject.hidePopup();
                } else if (ch == KeyEvent.VK_SPACE || ch == KeyEvent.VK_ENTER) {
                    final MyMenuItem item = list.getSelectedValue();
                    if (item != null) {
                        item.actionThread();
                    }
                }
            }
            @Override
            public void keyReleased(final KeyEvent e) {
            }
            @Override
            public void keyTyped(final KeyEvent e) {
            }
        });
        popup.addWindowFocusListener(new WindowFocusListener() {
            @Override
            public void windowGainedFocus(final WindowEvent e) {
            }
            @Override
            public void windowLostFocus(final WindowEvent e) {
                popup.dispose();
            }
        });

        typeToSearchField.addKeyListener(new KeyListener() {
            @Override
            public void keyPressed(final KeyEvent e) {
                final int ch = e.getKeyCode();
                final Thread thread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        if (ch == KeyEvent.VK_DOWN) {
                            application.invokeLater(new Runnable() {
                                @Override
                                public void run() {
                                    list.requestFocus();
                                    /* don't need to press down arrow twice */
                                    list.setSelectedIndex(0);
                                }
                            });
                        } else if (ch == KeyEvent.VK_ESCAPE) {
                            application.invokeLater(new Runnable() {
                                @Override
                                public void run() {
                                    for (final JDialog otherP : popups) {
                                        otherP.dispose();
                                    }
                                }
                            });
                            infoObject.hidePopup();
                        } else if (ch == KeyEvent.VK_SPACE || ch == KeyEvent.VK_ENTER) {
                            final MyMenuItem item = list.getModel().getElementAt(0);
                            if (item != null) {
                                item.actionThread();
                            }
                        }
                    }
                });
                thread.start();
View Full Code Here


    public void addAdvancedMenu(final MyMenu submenu) {
        if (submenu.getItemCount() > 0) {
            return;
        }
        /* Command log */
        final MyMenuItem cmdLogMenuItem = menuFactory.createMenuItem(
                Tools.getString("HostBrowser.CmdLog"),
                Info.LOGFILE_ICON,
                "",
                new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))

                .enablePredicate(new EnablePredicate() {
                    @Override
                    public String check() {
                        if (!host.isConnected()) {
                            return Host.NOT_CONNECTED_MENU_TOOLTIP_TEXT;
                        }
                        return null;
                    }
                })

                .addAction(new MenuAction() {
                    @Override
                    public void run(final String text) {
                        final CmdLog cmdLog = cmdLogProvider.get();
                        cmdLog.init(host);
                        cmdLog.showDialog();
                    }
                });
        submenu.add(cmdLogMenuItem);

        /* panic */
        final MyMenuItem panicMenuItem = menuFactory.createMenuItem(
                Tools.getString("HostBrowser.MakeKernelPanic") + host.getName(),
                null,
                new AccessMode(AccessMode.GOD, AccessMode.NORMAL),
                new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
                .enablePredicate(new EnablePredicate() {
                    @Override
                    public String check() {
                        if (!host.isConnected()) {
                            return Host.NOT_CONNECTED_MENU_TOOLTIP_TEXT;
                        }
                        return null;
                    }
                })
                .addAction(new MenuAction() {
                    @Override
                    public void run(final String text) {
                        final String hostName = host.getName();
                        final String command = "MakeKernelPanic";
                        guiData.startProgressIndicator(hostName, host.getDistString(command));
                        host.execCommand(new ExecCommandConfig().commandString(command));
                        guiData.stopProgressIndicator(hostName, host.getDistString(command));
                    }
                });
        submenu.add(panicMenuItem);

        /* reboot */
        final MyMenuItem rebootMenuItem = menuFactory.createMenuItem(
                Tools.getString("HostBrowser.MakeKernelReboot") + host.getName(),
                null,
                new AccessMode(AccessMode.GOD, AccessMode.NORMAL),
                new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
                .enablePredicate(new EnablePredicate() {
View Full Code Here

    private Provider<HostLogs> hostLogsProvider;

    public List<UpdatableItem> getPulldownMenu(final HostInfo hostInfo) {
        final List<UpdatableItem> items = new ArrayList<UpdatableItem>();
        /* host wizard */
        final MyMenuItem hostWizardItem =
                menuFactory.createMenuItem(Tools.getString("HostBrowser.HostWizard"),
                        HostBrowser.HOST_ICON_LARGE,
                        "",
                        new AccessMode(AccessMode.RO, AccessMode.NORMAL),
                        new AccessMode(AccessMode.RO, AccessMode.NORMAL))
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                editHostDialog.showDialogs(hostInfo.getHost());
                            }
                        });
        items.add(hostWizardItem);
        guiData.registerAddHostButton(hostWizardItem);
        /* cluster manager standby on/off */
        final Application.RunMode runMode = Application.RunMode.LIVE;
        final MyMenuItem standbyItem =
                menuFactory.createMenuItem(Tools.getString("HostBrowser.CRM.StandByOn"),
                        HostInfo.HOST_STANDBY_ICON,
                        ClusterBrowser.STARTING_PTEST_TOOLTIP,

                        Tools.getString("HostBrowser.CRM.StandByOff"),
                        HostInfo.HOST_STANDBY_OFF_ICON,
                        ClusterBrowser.STARTING_PTEST_TOOLTIP,
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .predicate(new Predicate() {
                            @Override
                            public boolean check() {
                                return !hostInfo.isStandby(runMode);
                            }
                        })
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                if (!hostInfo.getHost().isCrmStatusOk()) {
                                    return HostInfo.NO_PCMK_STATUS_STRING;
                                }
                                return null;
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                final Host dcHost = hostInfo.getBrowser().getClusterBrowser().getDCHost();
                                if (hostInfo.isStandby(runMode)) {
                                    CRM.standByOff(dcHost, hostInfo.getHost(), runMode);
                                } else {
                                    CRM.standByOn(dcHost, hostInfo.getHost(), runMode);
                                }
                            }
                        });
        final ClusterBrowser cb = hostInfo.getBrowser().getClusterBrowser();
        if (cb != null) {
            final ButtonCallback standbyItemCallback = cb.new ClMenuItemCallback(hostInfo.getHost())
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host dcHost) {
                            if (hostInfo.isStandby(Application.RunMode.LIVE)) {
                                CRM.standByOff(dcHost, hostInfo.getHost(), Application.RunMode.TEST);
                            } else {
                                CRM.standByOn(dcHost, hostInfo.getHost(), Application.RunMode.TEST);
                            }
                        }
                    });
            hostInfo.addMouseOverListener(standbyItem, standbyItemCallback);
        }
        items.add(standbyItem);

        /* Migrate all services from this host. */
        final MyMenuItem allMigrateFromItem =
                menuFactory.createMenuItem(Tools.getString("HostInfo.CRM.AllMigrateFrom"),
                        HostInfo.HOST_STANDBY_ICON,
                        ClusterBrowser.STARTING_PTEST_TOOLTIP,
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                if (!hostInfo.getHost().isCrmStatusOk()) {
                                    return HostInfo.NO_PCMK_STATUS_STRING;
                                }
                                if (hostInfo.getBrowser().getClusterBrowser().getExistingServiceList(null).isEmpty()) {
                                    return "there are no services to migrate";
                                }
                                return null;
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                for (final ServiceInfo si : cb.getExistingServiceList(null)) {
                                    if (!si.isConstraintPlaceholder() && si.getGroupInfo() == null && si.getCloneInfo() == null) {
                                        final List<String> runningOnNodes = si.getRunningOnNodes(Application.RunMode.LIVE);
                                        if (runningOnNodes != null && runningOnNodes.contains(hostInfo.getHost().getName())) {
                                            final Host dcHost = hostInfo.getHost();
                                            si.migrateFromResource(dcHost, hostInfo.getHost().getName(), Application.RunMode.LIVE);
                                        }
                                    }
                                }
                            }
                        });
        if (cb != null) {
            final ButtonCallback allMigrateFromItemCallback = cb.new ClMenuItemCallback(hostInfo.getHost())
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host dcHost) {
                            for (final ServiceInfo si : cb.getExistingServiceList(null)) {
                                if (!si.isConstraintPlaceholder() && si.getGroupInfo() == null) {
                                    final List<String> runningOnNodes = si.getRunningOnNodes(Application.RunMode.LIVE);
                                    if (runningOnNodes != null && runningOnNodes.contains(hostInfo.getHost().getName())) {
                                        si.migrateFromResource(dcHost, hostInfo.getHost().getName(), Application.RunMode.TEST);
                                    }
                                }
                            }
                        }
                    });
            hostInfo.addMouseOverListener(allMigrateFromItem, allMigrateFromItemCallback);
        }
        items.add(allMigrateFromItem);
        /* Stop corosync/openais. */
        final MyMenuItem stopCorosyncItem =
                menuFactory.createMenuItem(Tools.getString("HostInfo.StopCorosync"),
                        HostInfo.HOST_STOP_COMM_LAYER_ICON,
                        ClusterBrowser.STARTING_PTEST_TOOLTIP,

                        Tools.getString("HostInfo.StopOpenais"),
                        HostInfo.HOST_STOP_COMM_LAYER_ICON,
                        ClusterBrowser.STARTING_PTEST_TOOLTIP,

                        new AccessMode(AccessMode.ADMIN, AccessMode.ADVANCED),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                final Host h = hostInfo.getHost();
                                if (!h.isInCluster()) {
                                    return NOT_IN_CLUSTER;
                                }
                                return null;
                            }
                        })
                        .predicate(new Predicate() {
                            @Override
                            public boolean check() {
                    /* when both are running it's openais. */
                                return hostInfo.getHost().isCorosyncRunning() && !hostInfo.getHost().isOpenaisRunning();
                            }
                        })
                        .visiblePredicate(new VisiblePredicate() {
                            @Override
                            public boolean check() {
                                return hostInfo.getHost().isCorosyncRunning() || hostInfo.getHost().isOpenaisRunning();
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                if (application.confirmDialog(Tools.getString("HostInfo.confirmCorosyncStop.Title"),
                                        Tools.getString("HostInfo.confirmCorosyncStop.Desc"),
                                        Tools.getString("HostInfo.confirmCorosyncStop.Yes"),
                                        Tools.getString("HostInfo.confirmCorosyncStop.No"))) {
                                    final Host thisHost = hostInfo.getHost();
                                    thisHost.setCommLayerStopping(true);
                                    if (!thisHost.isPcmkStartedByCorosync()
                                            && thisHost.hasPacemakerInitScript()
                                            && thisHost.isPacemakerRunning()) {
                                        if (hostInfo.getHost().isCorosyncRunning() && !hostInfo.getHost().isOpenaisRunning()) {
                                            Corosync.stopCorosyncWithPcmk(thisHost);
                                        } else {
                                            Openais.stopOpenaisWithPcmk(thisHost);
                                        }
                                    } else {
                                        if (hostInfo.getHost().isCorosyncRunning() && !hostInfo.getHost().isOpenaisRunning()) {
                                            Corosync.stopCorosync(thisHost);
                                        } else {
                                            Openais.stopOpenais(thisHost);
                                        }
                                    }
                                    updateClusterView(thisHost, hostInfo);
                                }
                            }
                        });
        if (cb != null) {
            final ButtonCallback stopCorosyncItemCallback = cb.new ClMenuItemCallback(hostInfo.getHost())
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host dcHost) {
                            if (!hostInfo.isStandby(Application.RunMode.LIVE)) {
                                CRM.standByOn(dcHost, hostInfo.getHost(), Application.RunMode.TEST);
                            }
                        }
                    });
            hostInfo.addMouseOverListener(stopCorosyncItem, stopCorosyncItemCallback);
        }
        items.add(stopCorosyncItem);
        /* Stop heartbeat. */
        final MyMenuItem stopHeartbeatItem =
                menuFactory.createMenuItem(Tools.getString("HostInfo.StopHeartbeat"),
                        HostInfo.HOST_STOP_COMM_LAYER_ICON,
                        ClusterBrowser.STARTING_PTEST_TOOLTIP,

                        new AccessMode(AccessMode.ADMIN, AccessMode.ADVANCED),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
                        .visiblePredicate(new VisiblePredicate() {
                            @Override
                            public boolean check() {
                                return hostInfo.getHost().isHeartbeatRunning();
                            }
                        })
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                final Host h = hostInfo.getHost();
                                if (!h.isInCluster()) {
                                    return NOT_IN_CLUSTER;
                                }
                                return null;
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                if (application.confirmDialog(Tools.getString("HostInfo.confirmHeartbeatStop.Title"),
                                        Tools.getString("HostInfo.confirmHeartbeatStop.Desc"),
                                        Tools.getString("HostInfo.confirmHeartbeatStop.Yes"),
                                        Tools.getString("HostInfo.confirmHeartbeatStop.No"))) {
                                    hostInfo.getHost().setCommLayerStopping(true);
                                    Heartbeat.stopHeartbeat(hostInfo.getHost());
                                    updateClusterView(hostInfo.getHost(), hostInfo);
                                }
                            }
                        });
        if (cb != null) {
            final ButtonCallback stopHeartbeatItemCallback = cb.new ClMenuItemCallback(hostInfo.getHost())
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host dcHost) {
                            if (!hostInfo.isStandby(Application.RunMode.LIVE)) {
                                CRM.standByOn(dcHost, hostInfo.getHost(), Application.RunMode.TEST);
                            }
                        }
                    });
            hostInfo.addMouseOverListener(stopHeartbeatItem, stopHeartbeatItemCallback);
        }
        items.add(stopHeartbeatItem);
        /* Start corosync. */
        final MyMenuItem startCorosyncItem =
                menuFactory.createMenuItem(Tools.getString("HostInfo.StartCorosync"),
                        HostInfo.HOST_START_COMM_LAYER_ICON,
                        ClusterBrowser.STARTING_PTEST_TOOLTIP,

                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
                        .visiblePredicate(new VisiblePredicate() {
                            @Override
                            public boolean check() {
                                final Host h = hostInfo.getHost();
                                return h.isCorosyncInstalled()
                                        && h.hasCorosyncInitScript()
                                        && h.corosyncOrOpenaisConfigExists()
                                        && !h.isCorosyncRunning()
                                        && !h.isOpenaisRunning()
                                        && !h.isHeartbeatRunning()
                                        && !h.isHeartbeatInRc();
                            }
                        })
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                final Host h = hostInfo.getHost();
                                if (!h.isInCluster()) {
                                    return NOT_IN_CLUSTER;
                                }
                                if (h.isOpenaisInRc() && !h.isCorosyncInRc()) {
                                    return "Openais is in rc.d";
                                }
                                return null;
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                hostInfo.getHost().setCommLayerStarting(true);
                                if (hostInfo.getHost().isPacemakerInRc()) {
                                    Corosync.startCorosyncWithPcmk(hostInfo.getHost());
                                } else {
                                    Corosync.startCorosync(hostInfo.getHost());
                                }
                                updateClusterView(hostInfo.getHost(), hostInfo);
                            }
                        });
        if (cb != null) {
            final ButtonCallback startCorosyncItemCallback = cb.new ClMenuItemCallback(hostInfo.getHost())
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host dcHost) {
                            //TODO
                        }
                    });
            hostInfo.addMouseOverListener(startCorosyncItem, startCorosyncItemCallback);
        }
        items.add(startCorosyncItem);
        /* Start openais. */
        final MyMenuItem startOpenaisItem =
                menuFactory.createMenuItem(Tools.getString("HostInfo.StartOpenais"),
                        HostInfo.HOST_START_COMM_LAYER_ICON,
                        ClusterBrowser.STARTING_PTEST_TOOLTIP,

                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
                        .visiblePredicate(new VisiblePredicate() {
                            @Override
                            public boolean check() {
                                final Host h = hostInfo.getHost();
                                return h.hasOpenaisInitScript()
                                        && h.corosyncOrOpenaisConfigExists()
                                        && !h.isCorosyncRunning()
                                        && !h.isOpenaisRunning()
                                        && !h.isHeartbeatRunning()
                                        && !h.isHeartbeatInRc();
                            }
                        })
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                final Host h = hostInfo.getHost();
                                if (!h.isInCluster()) {
                                    return NOT_IN_CLUSTER;
                                }
                                if (h.isCorosyncInRc() && !h.isOpenaisInRc()) {
                                    return "Corosync is in rc.d";
                                }
                                return null;
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                hostInfo.getHost().setCommLayerStarting(true);
                                Openais.startOpenais(hostInfo.getHost());
                                updateClusterView(hostInfo.getHost(), hostInfo);
                            }
                        });
        if (cb != null) {
            final ButtonCallback startOpenaisItemCallback = cb.new ClMenuItemCallback(hostInfo.getHost())
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host dcHost) {
                            //TODO
                        }
                    });
            hostInfo.addMouseOverListener(startOpenaisItem, startOpenaisItemCallback);
        }
        items.add(startOpenaisItem);
        /* Start heartbeat. */
        final MyMenuItem startHeartbeatItem =
                menuFactory.createMenuItem(Tools.getString("HostInfo.StartHeartbeat"),
                        HostInfo.HOST_START_COMM_LAYER_ICON,
                        ClusterBrowser.STARTING_PTEST_TOOLTIP,

                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
                        .visiblePredicate(new VisiblePredicate() {
                            @Override
                            public boolean check() {
                                final Host h = hostInfo.getHost();
                                return h.hasHeartbeatInitScript()
                                        && h.heartbeatConfigExists()
                                        && !h.isCorosyncRunning()
                                        && !h.isOpenaisRunning()
                                        && !h.isHeartbeatRunning();
                                //&& !h.isAisRc()
                                //&& !h.isCsRc(); TODO should check /etc/defaults/
                            }
                        })
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                final Host h = hostInfo.getHost();
                                if (!h.isInCluster()) {
                                    return NOT_IN_CLUSTER;
                                }
                                return null;
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                hostInfo.getHost().setCommLayerStarting(true);
                                Heartbeat.startHeartbeat(hostInfo.getHost());
                                updateClusterView(hostInfo.getHost(), hostInfo);
                            }
                        });
        if (cb != null) {
            final ButtonCallback startHeartbeatItemCallback = cb.new ClMenuItemCallback(hostInfo.getHost())
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host dcHost) {
                            //TODO
                        }
                    });
            hostInfo.addMouseOverListener(startHeartbeatItem, startHeartbeatItemCallback);
        }
        items.add(startHeartbeatItem);

        /* Start pacemaker. */
        final MyMenuItem startPcmkItem =
                menuFactory.createMenuItem(Tools.getString("HostInfo.StartPacemaker"),
                        HostInfo.HOST_START_COMM_LAYER_ICON,
                        ClusterBrowser.STARTING_PTEST_TOOLTIP,

                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
View Full Code Here

                                                        ClusterBrowser.CRM_CLASS_MENU.get(cl),
                                                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                                                        new AccessMode(AccessMode.OP, AccessMode.NORMAL));
                    final MyListModel<MyMenuItem> dlm = new MyListModel<MyMenuItem>();
                    for (final ResourceAgent ra : groupInfo.getAddGroupServiceList(cl)) {
                        final MyMenuItem mmi = menuFactory.createMenuItem(
                                        ra.getPullDownMenuName(),
                                        null,
                                        null,
                                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                                        new AccessMode(AccessMode.OP, AccessMode.NORMAL));
                        mmi.addAction(new MenuAction() {
                                @Override
                                public void run(final String text) {
                                    final CloneInfo ci = groupInfo.getCloneInfo();
                                    if (ci != null) {
                                        ci.hidePopup();
                                    }
                                    groupInfo.hidePopup();
                                    application.invokeLater(new Runnable() {
                                        @Override
                                        public void run() {
                                            for (final JDialog otherP : popups) {
                                                otherP.dispose();
                                            }
                                        }
                                    });
                                    if (ra.isLinbitDrbd() && !groupInfo.getBrowser().linbitDrbdConfirmDialog()) {
                                        return;
                                    }
                                    groupInfo.addGroupServicePanel(ra, true);
                                    mmi.repaint();
                                }
                            });
                        dlm.addElement(mmi);
                    }
                    final boolean ret = drbdGui.getScrollingMenu(
View Full Code Here

            return;
        }
        boolean separatorAdded = false;
        final Application.RunMode runMode = getRunMode();
        for (final ServiceInfo asi : getClusterBrowser().getExistingServiceList(si)) {
            final MyMenuItem mmi = menuFactory.createMenuItem(asi.toString(),
                                                  null,
                                                  null,
                                                  new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                                                  new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                .addAction(new MenuAction() {
                    @Override
                    public void run(final String text) {
                        si.addServicePanel(asi,
                                null,
                                false, /* TODO: colocation only */
                                false, /* order only */
                                true,
                                getClusterBrowser().getDCHost(),
                                runMode);
                        repaint();
                    }
                });
            if ("Filesystem".equals(asi.getInternalValue()) || "IPaddr2".equals(asi.getInternalValue())) {

                mmi.setSpecialFont();
                addServiceMenuItem.add(mmi);
            } else {
                if (!separatorAdded) {
                    addServiceMenuItem.addSeparator();
                    separatorAdded = true;
View Full Code Here

            return;
        }
        final Application.RunMode runMode = Application.RunMode.LIVE;
        for (final Host host : cloneInfo.getBrowser().getClusterHosts()) {
            final String hostName = host.getName();
            final MyMenuItem migrateFromMenuItem =
                    menuFactory.createMenuItem(
                            Tools.getString("ClusterBrowser.Hb.MigrateFromResource") + ' ' + hostName + " (stop)",
                            ServiceInfo.MIGRATE_ICON,
                            ClusterBrowser.STARTING_PTEST_TOOLTIP,
View Full Code Here

        this.hbConnectionInfo = hbConnectionInfo;
        final List<UpdatableItem> items = new ArrayList<UpdatableItem>();

        final Application.RunMode runMode = Application.RunMode.LIVE;

        final MyMenuItem removeEdgeItem = menuFactory.createMenuItem(
                Tools.getString("ClusterBrowser.Hb.RemoveEdge"),
                ClusterBrowser.REMOVE_ICON,
                Tools.getString("ClusterBrowser.Hb.RemoveEdge.ToolTip"),
                new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                .enablePredicate(new EnablePredicate() {
                    @Override
                    public String check() {
                        if (getBrowser().crmStatusFailed()) {
                            return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
                        }
                        return null;
                    }
                })
                .addAction(new MenuAction() {
                    @Override
                    public void run(final String text) {
                        getBrowser().getCrmGraph().removeConnection(hbConnectionInfo, getBrowser().getDCHost(), runMode);
                    }
                });
        final ButtonCallback removeEdgeCallback = getBrowser().new ClMenuItemCallback(null) {
            @Override
            public boolean isEnabled() {
                return super.isEnabled() && !hbConnectionInfo.isNew();
            }
        }
                .addAction(new CallbackAction() {
                    @Override
                    public void run(final Host dcHost) {
                        if (!hbConnectionInfo.isNew()) {
                            getBrowser().getCrmGraph().removeConnection(hbConnectionInfo, dcHost, Application.RunMode.TEST);
                        }
                    }
                });
        hbConnectionInfo.addMouseOverListener(removeEdgeItem, removeEdgeCallback);
        items.add(removeEdgeItem);

        /* remove/add order */
        final MyMenuItem removeOrderItem =
                menuFactory.createMenuItem(Tools.getString("ClusterBrowser.Hb.RemoveOrder"),
                        ClusterBrowser.REMOVE_ICON,
                        Tools.getString("ClusterBrowser.Hb.RemoveOrder.ToolTip"),

                        Tools.getString("ClusterBrowser.Hb.AddOrder"),
                        null,
                        Tools.getString("ClusterBrowser.Hb.AddOrder.ToolTip"),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .predicate(new Predicate() {
                            @Override
                            public boolean check() {
                                return getBrowser().getCrmGraph().isOrder(hbConnectionInfo);
                            }
                        })
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                if (getBrowser().crmStatusFailed()) {
                                    return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
                                }
                                return null;
                            }
                        });
        removeOrderItem.addAction(new MenuAction() {
            @Override
            public void run(final String text) {
                if (removeOrderItem.getText().equals(Tools.getString("ClusterBrowser.Hb.RemoveOrder"))) {
                    getBrowser().getCrmGraph().removeOrder(hbConnectionInfo, getBrowser().getDCHost(), runMode);
                } else {
                    /* there is colocation constraint so let's get the
                     * endpoints from it. */
                    hbConnectionInfo.addOrder(null,
                            hbConnectionInfo.getLastServiceInfoRsc(),
                            hbConnectionInfo.getLastServiceInfoWithRsc());
                    getBrowser().getCrmGraph().addOrder(hbConnectionInfo, getBrowser().getDCHost(), runMode);
                }
            }
        });

        final ButtonCallback removeOrderCallback = getBrowser().new ClMenuItemCallback(null) {
            @Override
            public boolean isEnabled() {
                return super.isEnabled() && !hbConnectionInfo.isNew();
            }
        }
                .addAction(new CallbackAction() {
                    @Override
                    public void run(final Host dcHost) {
                        if (!hbConnectionInfo.isNew()) {
                            if (getBrowser().getCrmGraph().isOrder(hbConnectionInfo)) {
                                getBrowser().getCrmGraph().removeOrder(hbConnectionInfo, dcHost, Application.RunMode.TEST);
                            } else {
                        /* there is colocation constraint so let's get the
                         * endpoints from it. */
                                hbConnectionInfo.addOrder(null,
                                        hbConnectionInfo.getLastServiceInfoRsc(),
                                        hbConnectionInfo.getLastServiceInfoWithRsc());
                                getBrowser().getCrmGraph().addOrder(hbConnectionInfo, dcHost, Application.RunMode.TEST);
                            }
                        }
                    }
                });
        hbConnectionInfo.addMouseOverListener(removeOrderItem, removeOrderCallback);
        items.add(removeOrderItem);

        /* remove/add colocation */
        final MyMenuItem removeColocationItem =
                menuFactory.createMenuItem(
                        Tools.getString("ClusterBrowser.Hb.RemoveColocation"),
                        ClusterBrowser.REMOVE_ICON,
                        Tools.getString("ClusterBrowser.Hb.RemoveColocation.ToolTip"),

                        Tools.getString("ClusterBrowser.Hb.AddColocation"),
                        null,
                        Tools.getString("ClusterBrowser.Hb.AddColocation.ToolTip"),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .predicate(new Predicate() {
                            @Override
                            public boolean check() {
                                return getBrowser().getCrmGraph().isColocation(hbConnectionInfo);
                            }
                        })
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                if (getBrowser().crmStatusFailed()) {
                                    return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
                                }
                                return null;
                            }
                        });
        removeColocationItem.addAction(new MenuAction() {
            @Override
            public void run(final String text) {
                if (removeColocationItem.getText().equals(Tools.getString("ClusterBrowser.Hb.RemoveColocation"))) {
                    getBrowser().getCrmGraph().removeColocation(hbConnectionInfo, getBrowser().getDCHost(), runMode);
                } else {
                    /* add colocation */
                    /* there is order constraint so let's get the endpoints
                     * from it. */
 
View Full Code Here

        this.constraintPHInfo = (ConstraintPHInfo) serviceInfo;
        final List<UpdatableItem> items = new ArrayList<UpdatableItem>();
        final Application.RunMode runMode = Application.RunMode.LIVE;
        addDependencyMenuItems(constraintPHInfo, items, true, runMode);
        /* remove the placeholder and all constraints associated with it. */
        final MyMenuItem removeMenuItem = menuFactory.createMenuItem(
                Tools.getString("ConstraintPHInfo.Remove"),
                ClusterBrowser.REMOVE_ICON,
                ClusterBrowser.STARTING_PTEST_TOOLTIP,
                new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                new AccessMode(AccessMode.OP, AccessMode.NORMAL))
View Full Code Here

    public List<UpdatableItem> getPulldownMenu(final ServicesInfo servicesInfo) {
        final List<UpdatableItem> items = new ArrayList<UpdatableItem>();
        final Application.RunMode runMode = Application.RunMode.LIVE;

        /* add group */
        final MyMenuItem addGroupMenuItem =
                menuFactory.createMenuItem(Tools.getString("ClusterBrowser.Hb.AddGroup"),
                        null,
                        null,
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                if (servicesInfo.getBrowser().crmStatusFailed()) {
                                    return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
                                }
                                return null;
                            }
                        });
        addGroupMenuItem.addAction(new MenuAction() {
            @Override
            public void run(final String text) {
                servicesInfo.hidePopup();
                servicesInfo.addServicePanel(
                        servicesInfo.getBrowser().getCrmXml().getGroupResourceAgent(),
                        addGroupMenuItem.getPos(),
                        true,
                        null,
                        null,
                        runMode);
                servicesInfo.getBrowser().getCrmGraph().repaint();
            }
        });
        items.add(addGroupMenuItem);

        /* add service */
        final MyMenu addServiceMenuItem = menuFactory.createMenu(
                Tools.getString("ClusterBrowser.Hb.AddService"),
                new AccessMode(AccessMode.OP, AccessMode.NORMAL),
                new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                .enablePredicate(new EnablePredicate() {
                    @Override
                    public String check() {
                        if (servicesInfo.getBrowser().getCrmXml() == null) {
                            return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
                        }
                        if (servicesInfo.getBrowser().crmStatusFailed()) {
                            return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
                        }
                        return null;
                    }
                });
        addServiceMenuItem.onUpdate(new Runnable() {
            @Override
            public void run() {
                application.isSwingThread();
                addServiceMenuItem.removeAll();
                final Point2D pos = addServiceMenuItem.getPos();
                final CrmXml crmXML = servicesInfo.getBrowser().getCrmXml();
                if (crmXML == null) {
                    return;
                }
                final ResourceAgent fsService = crmXML.getResourceAgent(
                        "Filesystem",
                        ResourceAgent.HEARTBEAT_PROVIDER,
                        ResourceAgent.OCF_CLASS_NAME);
                if (crmXML.isLinbitDrbdResourceAgentPresent()) { /* just skip it, if it is not */
                    final MyMenuItem ldMenuItem = menuFactory.createMenuItem(
                            Tools.getString("ClusterBrowser.linbitDrbdMenuName"),
                            null,
                            null,
                            new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                            new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                            .addAction(new MenuAction() {
                                @Override
                                public void run(final String text) {
                                    servicesInfo.hidePopup();
                                    if (!servicesInfo.getBrowser().linbitDrbdConfirmDialog()) {
                                        return;
                                    }

                                    final FilesystemRaInfo fsi = (FilesystemRaInfo) servicesInfo.addServicePanel(
                                                    fsService,
                                                    addServiceMenuItem.getPos(),
                                                    true,
                                                    null,
                                                    null,
                                                    runMode);
                                    fsi.setDrbddiskIsPreferred(false);
                                    servicesInfo.getBrowser().getCrmGraph().repaint();
                                }
                            });
                    if (servicesInfo.getBrowser().atLeastOneDrbddiskConfigured()
                            || !crmXML.isLinbitDrbdResourceAgentPresent()) {
                        ldMenuItem.setEnabled(false);
                    }
                    ldMenuItem.setPos(pos);
                    addServiceMenuItem.add(ldMenuItem);
                }
                final ResourceAgent ipService = crmXML.getResourceAgent(
                        "IPaddr2",
                        ResourceAgent.HEARTBEAT_PROVIDER,
                        ResourceAgent.OCF_CLASS_NAME);
                if (ipService != null) { /* just skip it, if it is not*/
                    final MyMenuItem ipMenuItem =
                            menuFactory.createMenuItem(ipService.getPullDownMenuName(),
                                    null,
                                    null,
                                    new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                                    new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                                    .addAction(new MenuAction() {
                                        @Override
                                        public void run(final String text) {
                                            servicesInfo.hidePopup();
                                            servicesInfo.addServicePanel(ipService,
                                                    addServiceMenuItem.getPos(),
                                                    true,
                                                    null,
                                                    null,
                                                    runMode);
                                            servicesInfo.getBrowser().getCrmGraph().repaint();
                                        }
                                    });
                    ipMenuItem.setPos(pos);
                    addServiceMenuItem.add(ipMenuItem);
                }
                if (crmXML.isDrbddiskResourceAgentPresent()
                        && (servicesInfo.getBrowser().isDrbddiskRAPreferred()
                        || servicesInfo.getBrowser().atLeastOneDrbddiskConfigured()
                        || !crmXML.isLinbitDrbdResourceAgentPresent())) {
                    final MyMenuItem ddMenuItem = menuFactory.createMenuItem(
                            Tools.getString("ClusterBrowser.DrbddiskMenuName"),
                            null,
                            null,
                            new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                            new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                            .addAction(new MenuAction() {
                                @Override
                                public void run(final String text) {
                                    servicesInfo.hidePopup();
                                    final FilesystemRaInfo fsi = (FilesystemRaInfo) servicesInfo.addServicePanel(
                                            fsService,
                                            addServiceMenuItem.getPos(),
                                            true,
                                            null,
                                            null,
                                            runMode);
                                    fsi.setDrbddiskIsPreferred(true);
                                    servicesInfo.getBrowser().getCrmGraph().repaint();
                                }
                            });
                    if (servicesInfo.getBrowser().isOneLinbitDrbdRaConfigured()
                            || !crmXML.isDrbddiskResourceAgentPresent()) {
                        ddMenuItem.setEnabled(false);
                    }
                    ddMenuItem.setPos(pos);
                    addServiceMenuItem.add(ddMenuItem);
                }
                final Collection<JDialog> popups = new ArrayList<JDialog>();
                for (final String cl : ClusterBrowser.CRM_CLASSES) {
                    final List<ResourceAgent> services = servicesInfo.getAddServiceList(cl);
                    if (services.isEmpty()) {
                        /* no services, don't show */
                        continue;
                    }
                    AccessMode.Mode mode = AccessMode.NORMAL;
                    if (ResourceAgent.UPSTART_CLASS_NAME.equals(cl) || ResourceAgent.SYSTEMD_CLASS_NAME.equals(cl)) {
                        mode = AccessMode.ADVANCED;
                    }
                    if (ResourceAgent.LSB_CLASS_NAME.equals(cl)
                            && !servicesInfo.getAddServiceList(ResourceAgent.SERVICE_CLASS_NAME).isEmpty()) {
                        mode = AccessMode.ADVANCED;
                    }
                    final MyMenu classItem =
                            menuFactory.createMenu(ClusterBrowser.getClassMenuName(cl),
                                    new AccessMode(AccessMode.ADMIN, mode),
                                    new AccessMode(AccessMode.OP, mode));
                    final MyListModel<MyMenuItem> dlm = new MyListModel<MyMenuItem>();
                    for (final ResourceAgent ra : services) {
                        final MyMenuItem mmi = menuFactory.createMenuItem(
                                ra.getPullDownMenuName(),
                                null,
                                null,
                                new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                                new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                                .addAction(new MenuAction() {
                                    @Override
                                    public void run(final String text) {
                                        servicesInfo.hidePopup();
                                        application.invokeLater(new Runnable() {
                                            @Override
                                            public void run() {
                                                for (final JDialog otherP : popups) {
                                                    otherP.dispose();
                                                }
                                            }
                                        });
                                        if (ra.isLinbitDrbd() && !servicesInfo.getBrowser().linbitDrbdConfirmDialog()) {
                                            return;
                                        } else if (ra.isHbDrbd() && !servicesInfo.getBrowser().hbDrbdConfirmDialog()) {
                                            return;
                                        }
                                        servicesInfo.addServicePanel(ra,
                                                addServiceMenuItem.getPos(),
                                                true,
                                                null,
                                                null,
                                                runMode);
                                        servicesInfo.getBrowser().getCrmGraph().repaint();
                                    }
                                });
                        mmi.setPos(pos);
                        dlm.addElement(mmi);
                    }
                    final boolean ret = guiData.getScrollingMenu(
                            ClusterBrowser.getClassMenuName(cl),
                            null, /* options */
                            classItem,
                            dlm,
                            new MyList<MyMenuItem>(dlm, addServiceMenuItem.getBackground()),
                            servicesInfo,
                            popups,
                            null);
                    if (!ret) {
                        classItem.setEnabled(false);
                    }
                    addServiceMenuItem.add(classItem);
                }
                addServiceMenuItem.updateMenuComponents();
                addServiceMenuItem.processAccessMode();
            }
        });
        items.add(addServiceMenuItem);

        /* add constraint placeholder (and) */
        final MyMenuItem addConstraintPlaceholderAnd =
                menuFactory.createMenuItem(Tools.getString("ServicesInfo.AddConstraintPlaceholderAnd"),
                        null,
                        Tools.getString("ServicesInfo.AddConstraintPlaceholderAnd.ToolTip"),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                if (servicesInfo.getBrowser().crmStatusFailed()) {
                                    return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
                                }
                                return null;
                            }
                        });
        addConstraintPlaceholderAnd.addAction(new MenuAction() {
            @Override
            public void run(final String text) {
                servicesInfo.hidePopup();
                final CrmGraph hg = servicesInfo.getBrowser().getCrmGraph();
                final ConstraintPHInfo constraintPHInfo = constraintPHInfoProvider.get();
                constraintPHInfo.init(servicesInfo.getBrowser(), null, ConstraintPHInfo.Preference.AND);
                constraintPHInfo.getService().setNew(true);
                servicesInfo.getBrowser().addNameToServiceInfoHash(constraintPHInfo);
                hg.addConstraintPlaceholder(constraintPHInfo, addConstraintPlaceholderAnd.getPos(), runMode);
                final PcmkRscSetsInfo rscSetsInfo = rscSetsInfoProvider.get();
                rscSetsInfo.init(servicesInfo.getBrowser(), constraintPHInfo);
                constraintPHInfo.setPcmkRscSetsInfo(rscSetsInfo);
                application.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        hg.scale();
                    }
                });
            }
        });
        items.add(addConstraintPlaceholderAnd);

        /* add constraint placeholder (or) */
        final MyMenuItem addConstraintPlaceholderOr =
                menuFactory.createMenuItem(Tools.getString("ServicesInfo.AddConstraintPlaceholderOr"),
                        null,
                        Tools.getString("ServicesInfo.AddConstraintPlaceholderOr.ToolTip"),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                final String pmV = servicesInfo.getBrowser().getDCHost().getPacemakerVersion();
                                try {
                                    //TODO: get this from constraints-.rng files
                                    if (pmV == null || Tools.compareVersions(pmV, "1.1.7") <= 0) {
                                        return HbOrderInfo.NOT_AVAIL_FOR_PCMK_VERSION;
                                    }
                                } catch (final Exceptions.IllegalVersionException e) {
                                    LOG.appWarning("enablePredicate: unkonwn version: " + pmV);
                        /* enable it, if version check doesn't work */
                                }
                                if (servicesInfo.getBrowser().crmStatusFailed()) {
                                    return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
                                }
                                return null;
                            }
                        });
        addConstraintPlaceholderOr.addAction(new MenuAction() {
            @Override
            public void run(final String text) {
                servicesInfo.hidePopup();
                final CrmGraph hg = servicesInfo.getBrowser().getCrmGraph();
                final ConstraintPHInfo constraintPHInfo = constraintPHInfoProvider.get();
                constraintPHInfo.init(servicesInfo.getBrowser(), null, ConstraintPHInfo.Preference.OR);
                constraintPHInfo.getService().setNew(true);
                servicesInfo.getBrowser().addNameToServiceInfoHash(constraintPHInfo);
                hg.addConstraintPlaceholder(constraintPHInfo, addConstraintPlaceholderOr.getPos(), runMode);
                final PcmkRscSetsInfo rscSetsInfo = rscSetsInfoProvider.get();
                rscSetsInfo.init(servicesInfo.getBrowser(), constraintPHInfo);
                constraintPHInfo.setPcmkRscSetsInfo(rscSetsInfo);
                application.invokeLater(new Runnable() {
                    @Override
View Full Code Here

                        }
                    }});
        items.add(loadItem);

        /* load DRBD config / adjust all */
        final MyMenuItem adjustAllItem =
            menuFactory.createMenuItem(
                   Tools.getString("MultiSelectionInfo.AdjustAllDrbd"),
                   null,
                   Tools.getString("MultiSelectionInfo.AdjustAllDrbd"),
                           new AccessMode(AccessMode.OP, AccessMode.NORMAL),
                           new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                    .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                    for (final HostDrbdInfo hi : selectedHostInfos) {
                        if (!hi.getHost().isConnected()) {
                            return Host.NOT_CONNECTED_MENU_TOOLTIP_TEXT;
                        }
                    }
                    return null;
                }})
                .addAction(new MenuAction() {
                        @Override
                        public void run(final String text) {
                    for (final HostDrbdInfo hi : selectedHostInfos) {
                        DRBD.adjustApply(hi.getHost(), DRBD.ALL_DRBD_RESOURCES, null, Application.RunMode.LIVE);
                    }
                    for (final HostDrbdInfo hi : selectedHostInfos) {
                        getBrowser().updateHWInfo(hi.getHost(), !Host.UPDATE_LVM);
                    }
                }});
        items.add(adjustAllItem);
        final ButtonCallback adjustAllItemCallback =
               getBrowser().new DRBDMenuItemCallback(getBrowser().getDCHost())
                   .addAction(new CallbackAction() {
                           @Override
                           public void run(final Host host) {
                for (final HostDrbdInfo hi : selectedHostInfos) {
                    DRBD.adjustApply(hi.getHost(), DRBD.ALL_DRBD_RESOURCES, null, Application.RunMode.TEST);
                }
            }});
        multiSelectionInfo.addMouseOverListener(adjustAllItem, adjustAllItemCallback);

        /* start drbd */
        final MyMenuItem upAllItem =
            menuFactory.createMenuItem(Tools.getString("MultiSelectionInfo.UpAll"),
                           null,
                           Tools.getString("MultiSelectionInfo.UpAll"),
                           new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                           new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
View Full Code Here

TOP

Related Classes of lcmc.common.ui.utils.MyMenuItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.