Package lcmc.common.ui.utils

Examples of lcmc.common.ui.utils.MyMenuItem


        final String vgName = blockDevInfo.getVGName();
        if (vgName != null) {
            name += vgName;
        }

        final MyMenuItem mi = menuFactory.createMenuItem(
                name,
                null,
                LV_CREATE_MENU_DESCRIPTION,
                new AccessMode(AccessMode.OP, AccessMode.NORMAL),
                new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                .visiblePredicate(new VisiblePredicate() {
                    @Override
                    public boolean check() {
                        final String vg = blockDevInfo.getVGName();
                        return vg != null && !"".equals(vg) && getHost().getVolumeGroupNames().contains(vg);
                    }
                })
                .enablePredicate(new EnablePredicate() {
                    @Override
                    public String check() {
                        return null;
                    }
                })
                .addAction(new MenuAction() {
                    @Override
                    public void run(final String text) {
                        final LVCreate lvCreate = lvCreateProvider.get();
                        lvCreate.init(getHost(), blockDevInfo.getVGName(), blockDevInfo.getBlockDevice());
                        while (true) {
                            lvCreate.showDialog();
                            if (lvCreate.isPressedCancelButton()) {
                                lvCreate.cancelDialog();
                                return;
                            } else if (lvCreate.isPressedFinishButton()) {
                                break;
                            }
                        }
                    }
                });
        mi.onUpdate(new Runnable() {
            @Override
            public void run() {
                mi.setText1(LV_CREATE_MENU_ITEM + blockDevInfo.getVGName());
            }
        });
        mi.setToolTipText(LV_CREATE_MENU_DESCRIPTION);
        return mi;
    }
View Full Code Here


    public List<UpdatableItem> getPulldownMenu(final Host host, final HostDrbdInfo hostDrbdInfo) {
        final List<UpdatableItem> items = new ArrayList<UpdatableItem>();

        /* host wizard */
        final MyMenuItem hostWizardItem =
                menuFactory.createMenuItem(Tools.getString("HostBrowser.HostWizard"),
                        HostBrowser.HOST_ICON_LARGE,
                        Tools.getString("HostBrowser.HostWizard"),
                        new AccessMode(AccessMode.RO, AccessMode.NORMAL),
                        new AccessMode(AccessMode.RO, AccessMode.NORMAL))
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                editHostDialog.showDialogs(host);
                            }
                        });
        items.add(hostWizardItem);
        guiData.registerAddHostButton(hostWizardItem);

        /* proxy host wizard */
        final MyMenuItem proxyHostWizardItem =
                menuFactory.createMenuItem(Tools.getString("HostBrowser.ProxyHostWizard"),
                        HostBrowser.HOST_ICON_LARGE,
                        Tools.getString("HostBrowser.ProxyHostWizard"),
                        new AccessMode(AccessMode.RO, AccessMode.NORMAL),
                        new AccessMode(AccessMode.RO, AccessMode.NORMAL))
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                proxyHostWizard.init(host, null);
                                proxyHostWizard.showDialogs();
                            }
                        });
        items.add(proxyHostWizardItem);
        guiData.registerAddHostButton(proxyHostWizardItem);
        final Application.RunMode runMode = Application.RunMode.LIVE;
        /* load drbd */
        final UpdatableItem loadItem =
                menuFactory.createMenuItem(Tools.getString("HostBrowser.Drbd.LoadDrbd"),
                        null,
                        Tools.getString("HostBrowser.Drbd.LoadDrbd"),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                if (host.isConnected()) {
                                    if (host.isDrbdLoaded()) {
                                        return "already loaded";
                                    } else {
                                        return null;
                                    }
                                } else {
                                    return Host.NOT_CONNECTED_MENU_TOOLTIP_TEXT;
                                }
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                DRBD.load(host, runMode);
                                hostDrbdInfo.getBrowser().getClusterBrowser().updateHWInfo(host, !Host.UPDATE_LVM);
                            }
                        });
        items.add(loadItem);

        /* proxy start/stop */
        final UpdatableItem proxyItem =
                menuFactory.createMenuItem(Tools.getString("HostDrbdInfo.Drbd.StopProxy"),
                        null,
                        hostDrbdInfo.getMenuToolTip("DRBD.stopProxy", ""),
                        Tools.getString("HostDrbdInfo.Drbd.StartProxy"),
                        null,
                        hostDrbdInfo.getMenuToolTip("DRBD.startProxy", ""),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .predicate(new Predicate() {
                            @Override
                            public boolean check() {
                                return host.isDrbdProxyRunning();
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                if (host.isDrbdProxyRunning()) {
                                    DRBD.stopProxy(host, runMode);
                                } else {
                                    DRBD.startProxy(host, runMode);
                                }
                                hostDrbdInfo.getBrowser().getClusterBrowser().updateHWInfo(host, !Host.UPDATE_LVM);
                            }
                        });
        items.add(proxyItem);

        /* all proxy connections up */
        final UpdatableItem allProxyUpItem =
                menuFactory.createMenuItem(Tools.getString("HostDrbdInfo.Drbd.AllProxyUp"),
                        null,
                        hostDrbdInfo.getMenuToolTip("DRBD.proxyUp", DRBD.ALL_DRBD_RESOURCES),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .visiblePredicate(new VisiblePredicate() {
                            @Override
                            public boolean check() {
                                return host.isConnected() && host.isDrbdProxyRunning();
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                DRBD.proxyUp(host, DRBD.ALL_DRBD_RESOURCES, null, runMode);
                                hostDrbdInfo.getBrowser().getClusterBrowser().updateHWInfo(host, !Host.UPDATE_LVM);
                            }
                        });
        items.add(allProxyUpItem);

        /* all proxy connections down */
        final UpdatableItem allProxyDownItem =
                menuFactory.createMenuItem(Tools.getString("HostDrbdInfo.Drbd.AllProxyDown"),
                        null,
                        hostDrbdInfo.getMenuToolTip("DRBD.proxyDown", DRBD.ALL_DRBD_RESOURCES),
                        new AccessMode(AccessMode.ADMIN, AccessMode.ADVANCED),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .visiblePredicate(new VisiblePredicate() {
                            @Override
                            public boolean check() {
                                return host.isConnected() && host.isDrbdProxyRunning();
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                DRBD.proxyDown(host, DRBD.ALL_DRBD_RESOURCES, null, runMode);
                                hostDrbdInfo.getBrowser().getClusterBrowser().updateHWInfo(host, !Host.UPDATE_LVM);
                            }
                        });
        items.add(allProxyDownItem);

        /* load DRBD config / adjust all */
        final MyMenuItem adjustAllItem =
                menuFactory.createMenuItem(Tools.getString("HostBrowser.Drbd.AdjustAllDrbd"),
                        null,
                        Tools.getString("HostBrowser.Drbd.AdjustAllDrbd.ToolTip"),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                if (host.isConnected()) {
                                    return null;
                                } else {
                                    return Host.NOT_CONNECTED_MENU_TOOLTIP_TEXT;
                                }
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                DRBD.adjust(host, DRBD.ALL_DRBD_RESOURCES, null, runMode);
                                hostDrbdInfo.getBrowser().getClusterBrowser().updateHWInfo(host, !Host.UPDATE_LVM);
                            }
                        });
        items.add(adjustAllItem);
        final ClusterBrowser cb = hostDrbdInfo.getBrowser().getClusterBrowser();
        if (cb != null) {
            final ButtonCallback adjustAllItemCallback = cb.new DRBDMenuItemCallback(host)
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host host) {
                            DRBD.adjust(host, DRBD.ALL_DRBD_RESOURCES, null, Application.RunMode.TEST);
                        }
                    });
            hostDrbdInfo.addMouseOverListener(adjustAllItem, adjustAllItemCallback);
        }

        /* start drbd */
        final MyMenuItem upAllItem =
                menuFactory.createMenuItem(Tools.getString("HostBrowser.Drbd.UpAll"),
                        null,
                        Tools.getString("HostBrowser.Drbd.UpAll"),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                if (!host.isDrbdStatusOk()) {
                                    return HostDrbdInfo.NO_DRBD_STATUS_TOOLTIP;
                                }
                                return null;
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                DRBD.up(host, DRBD.ALL_DRBD_RESOURCES, null, runMode);
                            }
                        });
        items.add(upAllItem);
        if (cb != null) {
            final ButtonCallback upAllItemCallback = cb.new DRBDMenuItemCallback(host)
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host host) {
                            DRBD.up(host, DRBD.ALL_DRBD_RESOURCES, null, Application.RunMode.TEST);
                        }
                    });
            hostDrbdInfo.addMouseOverListener(upAllItem, upAllItemCallback);
        }

        /* change host color */
        final UpdatableItem changeHostColorItem =
                menuFactory.createMenuItem(Tools.getString("HostBrowser.Drbd.ChangeHostColor"),
                        null,
                        Tools.getString("HostBrowser.Drbd.ChangeHostColor"),
                        new AccessMode(AccessMode.RO, AccessMode.NORMAL),
                        new AccessMode(AccessMode.RO, AccessMode.NORMAL))
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                final Color newColor = JColorChooser.showDialog(guiData.getMainFrame(),
                                        "Choose " + host.getName() + " color",
                                        host.getPmColors()[0]);
                                if (newColor != null) {
                                    host.setSavedHostColorInGraphs(newColor);
                                }
                            }
                        });
        items.add(changeHostColorItem);

        /* view logs */
        final UpdatableItem viewLogsItem =
                menuFactory.createMenuItem(Tools.getString("HostBrowser.Drbd.ViewLogs"),
                        Info.LOGFILE_ICON,
                        Tools.getString("HostBrowser.Drbd.ViewLogs"),
                        new AccessMode(AccessMode.RO, AccessMode.NORMAL),
                        new AccessMode(AccessMode.RO, 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 DrbdsLog drbdsLog = drbdsLogProvider.get();
                                drbdsLog.init(host);
                                drbdsLog.showDialog();
                            }
                        });
        items.add(viewLogsItem);

        /* connect all */
        final MyMenuItem connectAllItem =
                menuFactory.createMenuItem(Tools.getString("HostBrowser.Drbd.ConnectAll"),
                        null,
                        Tools.getString("HostBrowser.Drbd.ConnectAll"),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                if (host.isDrbdStatusOk()) {
                                    return null;
                                } else {
                                    return HostDrbdInfo.NO_DRBD_STATUS_TOOLTIP;
                                }
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                DRBD.connect(host, DRBD.ALL_DRBD_RESOURCES, null, Application.RunMode.TEST);
                            }
                        });
        items.add(connectAllItem);
        if (cb != null) {
            final ButtonCallback connectAllItemCallback = cb.new DRBDMenuItemCallback(host)
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host host) {
                            DRBD.connect(host, DRBD.ALL_DRBD_RESOURCES, null, Application.RunMode.TEST);
                        }
                    });
            hostDrbdInfo.addMouseOverListener(connectAllItem, connectAllItemCallback);
        }

        /* disconnect all */
        final MyMenuItem disconnectAllItem =
                menuFactory.createMenuItem(Tools.getString("HostBrowser.Drbd.DisconnectAll"),
                        null,
                        Tools.getString("HostBrowser.Drbd.DisconnectAll"),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                if (host.isDrbdStatusOk()) {
                                    return null;
                                } else {
                                    return HostDrbdInfo.NO_DRBD_STATUS_TOOLTIP;
                                }
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                DRBD.disconnect(host, DRBD.ALL_DRBD_RESOURCES, null, runMode);
                            }
                        });
        items.add(disconnectAllItem);
        if (cb != null) {
            final ButtonCallback disconnectAllItemCallback = cb.new DRBDMenuItemCallback(host)
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host host) {
                            DRBD.disconnect(host, DRBD.ALL_DRBD_RESOURCES, null, Application.RunMode.TEST);
                        }
                    });
            hostDrbdInfo.addMouseOverListener(disconnectAllItem, disconnectAllItemCallback);
        }

        /* attach dettached */
        final MyMenuItem attachAllItem =
                menuFactory.createMenuItem(Tools.getString("HostBrowser.Drbd.AttachAll"),
                        null,
                        Tools.getString("HostBrowser.Drbd.AttachAll"),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                if (host.isDrbdStatusOk()) {
                                    return null;
                                } else {
                                    return HostDrbdInfo.NO_DRBD_STATUS_TOOLTIP;
                                }
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                DRBD.attach(host, DRBD.ALL_DRBD_RESOURCES, null, runMode);
                            }
                        });
        items.add(attachAllItem);
        if (cb != null) {
            final ButtonCallback attachAllItemCallback = cb.new DRBDMenuItemCallback(host)
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host host) {
                            DRBD.attach(host, DRBD.ALL_DRBD_RESOURCES, null, Application.RunMode.TEST);
                        }
                    });
            hostDrbdInfo.addMouseOverListener(attachAllItem, attachAllItemCallback);
        }

        /* detach */
        final MyMenuItem detachAllItem =
                menuFactory.createMenuItem(Tools.getString("HostBrowser.Drbd.DetachAll"),
                        null,
                        Tools.getString("HostBrowser.Drbd.DetachAll"),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                if (host.isDrbdStatusOk()) {
                                    return null;
                                } else {
                                    return HostDrbdInfo.NO_DRBD_STATUS_TOOLTIP;
                                }
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                DRBD.detach(host, DRBD.ALL_DRBD_RESOURCES, null, runMode);
                            }
                        });
        items.add(detachAllItem);
        if (cb != null) {
            final ButtonCallback detachAllItemCallback = cb.new DRBDMenuItemCallback(host)
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host host) {
                            DRBD.detach(host, DRBD.ALL_DRBD_RESOURCES, null, Application.RunMode.TEST);
                        }
                    });
            hostDrbdInfo.addMouseOverListener(detachAllItem, detachAllItemCallback);
        }

        /* set all primary */
        final MyMenuItem setAllPrimaryItem =
                menuFactory.createMenuItem(Tools.getString("HostBrowser.Drbd.SetAllPrimary"),
                        null,
                        Tools.getString("HostBrowser.Drbd.SetAllPrimary"),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                if (host.isDrbdStatusOk()) {
                                    return null;
                                } else {
                                    return HostDrbdInfo.NO_DRBD_STATUS_TOOLTIP;
                                }
                            }
                        })
                        .addAction(new MenuAction() {
                            @Override
                            public void run(final String text) {
                                DRBD.setPrimary(host, DRBD.ALL_DRBD_RESOURCES, null, runMode);
                            }
                        });
        items.add(setAllPrimaryItem);
        if (cb != null) {
            final ButtonCallback setAllPrimaryItemCallback = cb.new DRBDMenuItemCallback(host)
                    .addAction(new CallbackAction() {
                        @Override
                        public void run(final Host host) {
                            DRBD.setPrimary(host, DRBD.ALL_DRBD_RESOURCES, null, Application.RunMode.TEST);
                        }
                    });
            hostDrbdInfo.addMouseOverListener(setAllPrimaryItem, setAllPrimaryItemCallback);
        }

        /* set all secondary */
        final MyMenuItem setAllSecondaryItem =
                menuFactory.createMenuItem(Tools.getString("HostBrowser.Drbd.SetAllSecondary"),
                        null,
                        Tools.getString("HostBrowser.Drbd.SetAllSecondary"),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL))
View Full Code Here

            }
        }
    }

    private MyMenuItem getVGCreateItem(final Host host) {
        final MyMenuItem mi = menuFactory.createMenuItem(VG_CREATE_MENU_ITEM,
                null,
                VG_CREATE_MENU_DESCRIPTION,
                new AccessMode(AccessMode.OP, AccessMode.NORMAL),
                new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                .addAction(new MenuAction() {
                    @Override
                    public void run(final String text) {
                        final VGCreate vgCreate = vgCreateProvider.get();
                        vgCreate.init(host);
                        while (true) {
                            vgCreate.showDialog();
                            if (vgCreate.isPressedCancelButton()) {
                                vgCreate.cancelDialog();
                                return;
                            } else if (vgCreate.isPressedFinishButton()) {
                                break;
                            }
                        }
                    }
                });
        mi.setToolTipText(VG_CREATE_MENU_DESCRIPTION);
        return mi;
    }
View Full Code Here

    /**
     * Return create LV menu item.
     */
    private MyMenuItem getLVMCreateItem(final String volumeGroup, final BlockDevice blockDevice, final Host host) {
        final String name = LV_CREATE_MENU_ITEM + volumeGroup;
        final MyMenuItem mi = menuFactory.createMenuItem(name,
                null,
                LV_CREATE_MENU_DESCRIPTION,
                new AccessMode(AccessMode.OP, AccessMode.NORMAL),
                new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                .visiblePredicate(new VisiblePredicate() {
                    @Override
                    public boolean check() {
                        return volumeGroup != null
                                && !volumeGroup.isEmpty()
                                && host.getVolumeGroupNames().contains(volumeGroup);
                    }
                })
                .addAction(new MenuAction() {
                    @Override
                    public void run(final String text) {
                        final LVCreate lvCreate = lvCreateProvider.get();
                        lvCreate.init(host, volumeGroup, blockDevice);
                        while (true) {
                            lvCreate.showDialog();
                            if (lvCreate.isPressedCancelButton()) {
                                lvCreate.cancelDialog();
                                return;
                            } else if (lvCreate.isPressedFinishButton()) {
                                break;
                            }
                        }
                    }
                });
        mi.onUpdate(new Runnable() {
            @Override
            public void run() {
                mi.setText1(LV_CREATE_MENU_ITEM + volumeGroup);
            }
        });

        mi.setToolTipText(LV_CREATE_MENU_DESCRIPTION);
        return mi;
    }
View Full Code Here

    /**
     * Adds vm domain suspend menu item.
     */
    private void addSuspendMenu(final MyMenu advancedSubmenu, final Host host) {
        final MyMenuItem suspendMenuItem = menuFactory.createMenuItem(
                Tools.getString("DomainInfo.SuspendOn") + host.getName(),
                DomainInfo.PAUSE_ICON,
                Tools.getString("DomainInfo.SuspendOn") + host.getName(),
                new AccessMode(AccessMode.OP, AccessMode.NORMAL),
                new AccessMode(AccessMode.OP, AccessMode.NORMAL))
View Full Code Here

    /**
     * Adds vm domain resume menu item.
     */
    void addResumeAdvancedMenu(final MyMenu advancedSubmenu, final Host host) {
        final MyMenuItem resumeMenuItem = menuFactory.createMenuItem(
                Tools.getString("DomainInfo.ResumeOn") + host.getName(),
                RESUME_ICON,
                Tools.getString("DomainInfo.ResumeOn") + host.getName(),
                new AccessMode(AccessMode.OP, AccessMode.NORMAL),
                new AccessMode(AccessMode.OP, 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.