Package lcmc.common.ui.utils

Examples of lcmc.common.ui.utils.ButtonCallback


            public void removeUpdate(final DocumentEvent e) {
                update();
            }
        });

        final ButtonCallback buttonCallback = new ButtonCallback() {
            private volatile boolean mouseStillOver = false;

            @Override
            public boolean isEnabled() {
                return !Tools.versionBeforePacemaker(host);
View Full Code Here


        if (infoPanel != null) {
            infoPanelDone();
            return infoPanel;
        }
        final BlockDevInfo thisClass = this;
        final ButtonCallback buttonCallback = new ButtonCallback() {
            private volatile boolean mouseStillOver = false;

            @Override
            public boolean isEnabled() {
                return true;
View Full Code Here

        newPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND);
        newPanel.setLayout(new BoxLayout(newPanel, BoxLayout.PAGE_AXIS));
        if (getBrowser().getCrmXml() == null || getBrowser().getClusterStatus() == null) {
            return newPanel;
        }
        final ButtonCallback buttonCallback = new ButtonCallback() {
            private volatile boolean mouseStillOver = false;

            /**
             * Whether the whole thing should be enabled.
             */
 
View Full Code Here

                        });
                        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);
                                }
                            }
                        }
                    }
                });
View Full Code Here

                                }
                            }
                        });
        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),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
                        .visiblePredicate(new VisiblePredicate() {
                            @Override
                            public boolean check() {
                                final Host h = hostInfo.getHost();
                                return !h.isPcmkStartedByCorosync()
                                        && !h.isPacemakerRunning()
                                        && (h.isCorosyncRunning() || h.isOpenaisRunning())
                                        && !h.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) {
                                hostInfo.getHost().setPacemakerStarting(true);
                                Corosync.startPacemaker(hostInfo.getHost());
                                updateClusterView(hostInfo.getHost(), hostInfo);
                            }
                        });
        if (cb != null) {
            final ButtonCallback startPcmkItemCallback = cb.new ClMenuItemCallback(hostInfo.getHost())
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host dcHost) {
                            //TODO
                        }
View Full Code Here

                                    } else {
                                        cloneInfo.migrateFromResource(cloneInfo.getBrowser().getDCHost(), hostName, runMode);
                                    }
                                }
                            });
            final ButtonCallback migrateItemCallback = cloneInfo.getBrowser().new ClMenuItemCallback(null)
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host host) {
                            if (cloneInfo.getService().isMaster()) {
                        /* without role=master */
 
View Full Code Here

                    @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. */
                    hbConnectionInfo.addColocation(null,
                            hbConnectionInfo.getLastServiceInfoParent(),
                            hbConnectionInfo.getLastServiceInfoChild());
                    getBrowser().getCrmGraph().addColocation(hbConnectionInfo, getBrowser().getDCHost(), runMode);
                }
            }
        });
        final ButtonCallback removeColocationCallback = getBrowser().new ClMenuItemCallback(null) {
            @Override
            public boolean isEnabled() {
                return super.isEnabled() && !hbConnectionInfo.isNew();
            }
        }
View Full Code Here

                        constraintPHInfo.hidePopup();
                        constraintPHInfo.removeMyself(Application.RunMode.LIVE);
                        constraintPHInfo.getBrowser().getCrmGraph().repaint();
                    }
                });
        final ButtonCallback removeItemCallback = constraintPHInfo.getBrowser().new ClMenuItemCallback(null) {
            @Override
            public boolean isEnabled() {
                return super.isEnabled() && !constraintPHInfo.getService().isNew();
            }
        }
View Full Code Here

                            }
                        }
                        servicesInfo.getBrowser().getCrmGraph().repaint();
                    }
                });
        final ButtonCallback stopAllItemCallback = servicesInfo.getBrowser().new ClMenuItemCallback(null)
                .addAction(new CallbackAction() {
                    @Override
                    public void run(final Host host) {
                        final Host thisDCHost = servicesInfo.getBrowser().getDCHost();
                        for (final ServiceInfo si : servicesInfo.getBrowser().getExistingServiceList(null)) {
                            if (si.getGroupInfo() == null
                                    && !si.isConstraintPlaceholder()
                                    && !si.isStopped(Application.RunMode.TEST)
                                    && !si.getService().isOrphaned()
                                    && !si.getService().isNew()) {
                                si.stopResource(thisDCHost, Application.RunMode.TEST);
                            }
                        }
                    }
                });
        servicesInfo.addMouseOverListener(stopAllMenuItem, stopAllItemCallback);
        items.add((UpdatableItem) stopAllMenuItem);

        /* unmigrate all services. */
        final ComponentWithTest unmigrateAllMenuItem = menuFactory.createMenuItem(
                Tools.getString("ClusterBrowser.Hb.UnmigrateAllServices"),
                ServiceInfo.UNMIGRATE_ICON,
                new AccessMode(AccessMode.OP, AccessMode.NORMAL),
                new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                .visiblePredicate(new VisiblePredicate() {
                    @Override
                    public boolean check() {
                        if (servicesInfo.getBrowser().crmStatusFailed()) {
                            return false;
                        }
                        if (servicesInfo.getBrowser().getExistingServiceList(null).isEmpty()) {
                            return false;
                        }
                        for (final ServiceInfo si : servicesInfo.getBrowser().getExistingServiceList(null)) {
                            if (si.getMigratedTo(runMode) != null || si.getMigratedFrom(runMode) != null) {
                                return true;
                            }
                        }
                        return false;
                    }
                })
                .addAction(new MenuAction() {
                    @Override
                    public void run(final String text) {
                        servicesInfo.hidePopup();
                        final Host dcHost = servicesInfo.getBrowser().getDCHost();
                        for (final ServiceInfo si : servicesInfo.getBrowser().getExistingServiceList(null)) {
                            if (si.getMigratedTo(runMode) != null || si.getMigratedFrom(runMode) != null) {
                                si.unmigrateResource(dcHost, Application.RunMode.LIVE);
                            }
                        }
                        servicesInfo.getBrowser().getCrmGraph().repaint();
                    }
                });
        final ButtonCallback unmigrateAllItemCallback =
                servicesInfo.getBrowser().new ClMenuItemCallback(null)
                        .addAction(new CallbackAction() {
                            @Override
                            public void run(final Host dcHost) {
                                for (final ServiceInfo si : servicesInfo.getBrowser().getExistingServiceList(null)) {
                                    if (si.getMigratedTo(runMode) != null || si.getMigratedFrom(runMode) != null) {
                                        si.unmigrateResource(dcHost, Application.RunMode.TEST);
                                    }
                                }
                            }
                        });
        servicesInfo.addMouseOverListener(unmigrateAllMenuItem, unmigrateAllItemCallback);
        items.add((UpdatableItem) unmigrateAllMenuItem);

        /* remove all services. */
        final ComponentWithTest removeMenuItem = menuFactory.createMenuItem(
                Tools.getString("ClusterBrowser.Hb.RemoveAllServices"),
                ClusterBrowser.REMOVE_ICON,
                new AccessMode(AccessMode.ADMIN, AccessMode.ADVANCED),
                new AccessMode(AccessMode.ADMIN, AccessMode.ADVANCED))
                .enablePredicate(new EnablePredicate() {
                    @Override
                    public String check() {
                        if (servicesInfo.getBrowser().crmStatusFailed()) {
                            return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
                        }
                        if (servicesInfo.getBrowser().getExistingServiceList(null).isEmpty()) {
                            return "there are no services";
                        }
                        for (final ServiceInfo si : servicesInfo.getBrowser().getExistingServiceList(null)) {
                            if (si.getGroupInfo() == null) {
                                if (si.isRunning(Application.RunMode.LIVE)) {
                                    return "there are running services";
                                }
                            }
                        }
                        return null;
                    }
                })
                .addAction(new MenuAction() {
                    @Override
                    public void run(final String text) {
                        servicesInfo.hidePopup();
                        if (application.confirmDialog(
                                Tools.getString("ClusterBrowser.confirmRemoveAllServices.Title"),
                                Tools.getString("ClusterBrowser.confirmRemoveAllServices.Description"),
                                Tools.getString("ClusterBrowser.confirmRemoveAllServices.Yes"),
                                Tools.getString("ClusterBrowser.confirmRemoveAllServices.No"))) {
                            final Thread t = new Thread() {
                                @Override
                                public void run() {
                                    final Host dcHost = servicesInfo.getBrowser().getDCHost();
                                    final List<ServiceInfo> services = servicesInfo.getBrowser().getExistingServiceList(null);
                                    for (final ServiceInfo si : services) {
                                        if (si.getGroupInfo() == null) {
                                            final ResourceAgent ra = si.getResourceAgent();
                                            if (ra != null && !ra.isClone()) {
                                                si.getService().setRemoved(true);
                                            }
                                        }
                                    }
                                    CRM.erase(dcHost, runMode);
                                    for (final ServiceInfo si : services) {
                                        if (si.getGroupInfo() == null) {
                                            final ResourceAgent ra = si.getResourceAgent();
                                            if (si.getService().isNew()) {
                                                si.removeMyself(runMode);
                                            } else if (ra != null && !ra.isClone()) {
                                                si.cleanupResource(dcHost, Application.RunMode.LIVE);
                                            }
                                        }
                                    }
                                    servicesInfo.getBrowser().getCrmGraph().repaint();
                                }
                            };
                            t.start();
                        }
                    }
                });
        final ButtonCallback removeItemCallback =
                servicesInfo.getBrowser().new ClMenuItemCallback(null)
                        .addAction(new CallbackAction() {
                            @Override
                            public void run(final Host dcHost) {
                                CRM.erase(dcHost, Application.RunMode.TEST);
View Full Code Here

                    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))
                    .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                    for (final HostDrbdInfo hi : selectedHostInfos) {
                        if (!hi.getHost().isDrbdStatusOk()) {
                            return HostDrbdInfo.NO_DRBD_STATUS_TOOLTIP;
                        }
                    }
                    return null;
                }})
                .addAction(new MenuAction() {
                        @Override
                        public void run(final String text) {
                    for (final HostDrbdInfo hi : selectedHostInfos) {
                        DRBD.up(hi.getHost(), DRBD.ALL_DRBD_RESOURCES, null, Application.RunMode.LIVE);
                    }
                }});
        items.add(upAllItem);
        final ButtonCallback upAllItemCallback =
             getBrowser().new DRBDMenuItemCallback(getBrowser().getDCHost())
                 .addAction(new CallbackAction() {
                         @Override
                         public void run(final Host host) {
                for (final HostDrbdInfo hi : selectedHostInfos) {
View Full Code Here

TOP

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

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.