Package lcmc.cluster.ui.widget

Examples of lcmc.cluster.ui.widget.Widget


    private void storeHostLocations() {
        savedHostLocations.clear();
        for (final Host host : getBrowser().getClusterHosts()) {
            final HostInfo hi = host.getBrowser().getHostInfo();
            final Widget wi = scoreComboBoxHash.get(hi);
            final Value score = wi.getValue();
            final String op = getOpFromLabel(hi.getName(), wi.getLabel().getText());
            if (score == null || score.isNothingSelected()) {
                savedHostLocations.remove(hi);
            } else {
                savedHostLocations.put(hi, new HostLocation(score.getValueForConfig(), op, null, null));
            }
View Full Code Here


                if (ClusterBrowser.CRM_OPERATIONS_WITH_IGNORED_DEFAULT.contains(op)) {
                    defaultValue = NOTHING_SELECTED_VALUE;
                }
                mOperationsComboBoxHashReadLock.lock();

                final Widget wi;
                try {
                    wi = operationsComboBoxHash.get(op, param);
                } finally {
                    mOperationsComboBoxHashReadLock.unlock();
                }
                if (wi == null) {
                    continue;
                }
                if (CrmXml.PARAM_OCF_CHECK_LEVEL.equals(param)) {
                    final Value value = wi.getValue();
                    if (!Tools.areEqual(value, defaultValue)) {
                        allAreDefaultValues = false;
                    }
                    final Value savedOp = savedOperation.get(op, param);
                    if (savedOp == null) {
                        if (!Tools.areEqual(value, defaultValue)) {
                            changed.add(param + ": " + defaultValue + " \u2192 " + value);
                        }
                    } else if (!Tools.areEqual(value, savedOp)) {
                        changed.add(param + ": " + savedOp + " \u2192 " + value);
                    }
                    wi.setBackground(defaultValue, savedOp, false);
                } else {
                    final Value value = wi.getValue();
                    if (!Tools.areEqual(value, defaultValue)) {
                        allAreDefaultValues = false;
                    }
                    final Value savedOp = savedOperation.get(op, param);
                    if (!Tools.areEqual(value, savedOp)) {
                        changed.add(param + ": " + savedOp + " \u2192 " + value);
                    }
                    wi.setBackground(defaultValue, savedOp, false);
                }
            }
        }
        if (sameAsOperationsWi != null) {
            final Value info = sameAsOperationsWiValue();
View Full Code Here

        final List<String> changed = new ArrayList<String>();
        final List<String> incorrect = new ArrayList<String>();
        boolean hostLocationFound = false;
        for (final Host host : getBrowser().getClusterHosts()) {
            final HostInfo hi = host.getBrowser().getHostInfo();
            final Widget wi = scoreComboBoxHash.get(hi);
            final HostLocation hlSaved = savedHostLocations.get(hi);
            final Value hsSaved;
            String opSaved = null;
            if (hlSaved == null) {
                hsSaved = NOTHING_SELECTED_VALUE;
            } else {
                hsSaved = new StringValue(hlSaved.getScore());
                opSaved = hlSaved.getOperation();
            }
            final String opSavedLabel = getHostLocationLabel(host.getName(), opSaved);
            if (wi == null) {
                continue;
            }
            String labelText = null;
            final JLabel label = wi.getLabel();
            if (label != null) {
                labelText = label.getText();
                final String op = getOpFromLabel(hi.getName(), label.getText());
                if (wi.getValue() == null || "eq".equals(op)) {
                    hostLocationFound = true;
                }
            }
            if (!Tools.areEqual(hsSaved, wi.getValue())
                || (!Tools.areEqual(opSavedLabel, labelText)
                    && (hsSaved != null  && !hsSaved.isNothingSelected()))) {
                changed.add("host location");
            }
            wi.setBackground(getHostLocationLabel(host.getName(), "eq"), null, opSavedLabel, hsSaved, false);
        }
        if (!hostLocationFound) {
            incorrect.add("no host location found");
        }
        /* ping */
        final Widget pwi = pingComboBox;
        if (pwi != null) {
            if (!Tools.areEqual(savedPingOperation, pwi.getValue())) {
                changed.add("ping operation");
            }
            pwi.setBackground(null, savedPingOperation, false);
        }
        return new Check(incorrect, changed);
    }
View Full Code Here

        if (!ci.getService().isNew()) {
            ci.getWidget(GUI_ID, null).setEnabled(false);
        }
        for (final String param : params) {
            if (ci.isMetaAttr(param)) {
                final Widget wi = ci.getWidget(param, null);
                wi.setEnabled(savedMAIdRef == null);
            }
        }

        ci.addHostLocations(optionsPanel, application.getServiceLabelWidth(), application.getServiceFieldWidth());
    }
View Full Code Here

            abbreviations.put("i", CrmXml.INFINITY_VALUE.getValueForConfig());
            abbreviations.put("+", CrmXml.PLUS_INFINITY_VALUE.getValueForConfig());
            abbreviations.put("I", CrmXml.INFINITY_VALUE.getValueForConfig());
            abbreviations.put("a", "ALWAYS");
            abbreviations.put("n", "NEVER");
            final Widget wi = widgetFactory.createInstance(
                                  Widget.Type.COMBOBOX,
                                  NOTHING_SELECTED_VALUE,
                                  new Value[]{NOTHING_SELECTED_VALUE,
                                              new StringValue("0"),
                                              new StringValue("2"),
                                              new StringValue("ALWAYS"),
                                              new StringValue("NEVER"),
                                              CrmXml.INFINITY_VALUE,
                                              CrmXml.MINUS_INFINITY_VALUE,
                                              CrmXml.INFINITY_VALUE},

                                  "^((-?\\d*|(-|\\+)?"
                                  + CrmXml.INFINITY_VALUE
                                  + "))|ALWAYS|NEVER|@NOTHING_SELECTED@$",

                                  rightWidth,
                                  abbreviations,
                                  new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                                  Widget.NO_BUTTON);
            wi.setEditable(true);
            final Widget prevWi = scoreComboBoxHash.get(hi);
            scoreComboBoxHash.put(hi, wi);

            /* set selected host scores in the combo box from
             * savedHostLocations */
            if (prevWi == null) {
                final HostLocation hl = savedHostLocations.get(hi);
                String hsSaved = null;
                if (hl != null) {
                    hsSaved = hl.getScore();
                }
                wi.setValue(new StringValue(hsSaved));
            } else {
                wi.setValue(prevWi.getValue());
            }
        }

        /* host score combo boxes */
        int rows = 0;
        for (final Host host : getBrowser().getClusterHosts()) {
            final HostInfo hi = host.getBrowser().getHostInfo();
            final Widget wi = scoreComboBoxHash.get(hi);
            String op = null;
            final HostLocation hl = savedHostLocations.get(hi);
            if (hl != null) {
                op = hl.getOperation();
            }
            final String text = getHostLocationLabel(hi.getName(), op);
            final JLabel label = new JLabel(text);
            final String onText = getHostLocationLabel(hi.getName(), "eq");
            final String notOnText = getHostLocationLabel(hi.getName(), "ne");
            label.addMouseListener(new MouseListener() {
                @Override
                public void mouseClicked(final MouseEvent e) {
                    /* do nothing */
                }
                @Override
                public void mouseEntered(final MouseEvent e) {
                    /* do nothing */
                }
                @Override
                public void mouseExited(final MouseEvent e) {
                    /* do nothing */
                }
                @Override
                public void mousePressed(final MouseEvent e) {
                    final String currentText = label.getText();
                    application.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            if (currentText.equals(onText)) {
                                label.setText(notOnText);
                            } else {
                                label.setText(onText);
                            }
                            final String[] params = getParametersFromXML();
                            setApplyButtons(CACHED_FIELD, params);
                        }
                    });
                }
                @Override
                public void mouseReleased(final MouseEvent e) {
                    /* do nothing */
                }
            });
            wi.setLabel(label, text);
            addField(panel, label, wi.getComponent(), leftWidth, rightWidth, 0);
            rows++;
        }
        rows += addPingField(panel, leftWidth, rightWidth);

        SpringUtilities.makeCompactGrid(panel, rows, 2, /* rows, cols */
 
View Full Code Here

    }

    private int addPingField(final JPanel panel, final int leftWidth, final int rightWidth) {
        final JLabel pingLabel = new JLabel("pingd");
        final Value savedPO;
        final Widget prevWi = pingComboBox;
        if (prevWi == null) {
            savedPO = savedPingOperation;
        } else {
            savedPO = prevWi.getValue();
        }
        final Widget pingWi = widgetFactory.createInstance(
                Widget.Type.COMBOBOX,
                savedPO,
                new Value[]{NOTHING_SELECTED_VALUE, PING_ATTRIBUTES.get("defined"), PING_ATTRIBUTES.get("eq0")},
                Widget.NO_REGEXP,
                rightWidth,
                Widget.NO_ABBRV,
                new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                Widget.NO_BUTTON);
        addField(panel, pingLabel, pingWi.getComponent(), leftWidth, rightWidth, 0);
        pingWi.setLabel(pingLabel, Tools.getString("ServiceInfo.PingdToolTip"));
        if (resourceAgent.isPingService()
            && (savedPingOperation == null || savedPingOperation.isNothingSelected())) {
            pingWi.setEnabled(false);
        }
        pingComboBox = pingWi;
        int rows = 0;
        rows++;
        return rows;
View Full Code Here

                }
                Value defaultValue = getParamPreferred(param);
                if (defaultValue == null || defaultValue.isNothingSelected()) {
                    defaultValue = getParamDefault(param);
                }
                final Widget wi = getWidget(param, null);
                if (wi == null) {
                    continue;
                }
                Value oldValue = wi.getValue();
                if (oldValue == null || oldValue.isNothingSelected()) {
                    oldValue = defaultValue;
                }
                wi.setEnabled(!sameAs || nothingSelected);
                if (!nothingSelected) {
                    if (sameAs) {
                        /* same as some other service */
                        defaultValue = ((EditableInfo) info).getParamSaved(param);
                    }
                    final Value newValue = defaultValue;
                    if (!Tools.areEqual(oldValue, newValue)) {
                        wi.setValueNoListeners(newValue);
                    }
                }
            }
        }
    }
View Full Code Here

                    continue;
                }
                if (ClusterBrowser.CRM_OPERATIONS_WITH_IGNORED_DEFAULT.contains(op)) {
                    defaultValue = NOTHING_SELECTED_VALUE;
                }
                final Widget wi;
                mOperationsComboBoxHashReadLock.lock();
                try {
                    wi = operationsComboBoxHash.get(op, param);
                } finally {
                    mOperationsComboBoxHashReadLock.unlock();
                }
                final Value oldValue = wi.getValue();
                wi.setEnabled(!sameAs || nothingSelected);
                if (!nothingSelected) {
                    if (sameAs) {
                        /* same as some other service */
                        defaultValue = ((ServiceInfo) info).getSavedOperation().get(op, param);
                    }
                    final Value newValue = defaultValue;
                    if (!Tools.areEqual(oldValue, newValue)) {
                        wi.setValueNoListeners(newValue);
                    }
                }
            }
        }
        mSavedOperationsLock.unlock();
View Full Code Here

                    defaultValue = new StringValue("0");
                }
                mOperationsComboBoxHashWriteLock.lock();
                Value savedValue = null;
                try {
                    final Widget prevWi = operationsComboBoxHash.get(op, param);
                    if (prevWi != null) {
                        savedValue = prevWi.getValue();
                    }
                } finally {
                    mOperationsComboBoxHashWriteLock.unlock();
                }
                if (savedValue == null) {
                    savedValue = savedOperation.get(op, param);
                }
                if (!getService().isNew() && (savedValue == null || savedValue.isNothingSelected())) {
                    savedValue = getOpDefaultsDefault(param);
                    if (savedValue ==null) {
                        savedValue = new StringValue("");
                    }
                }
                if (!Tools.areEqual(defaultValue, savedValue)) {
                    allAreDefaultValues = false;
                }
                if (savedValue != null) {
                    defaultValue = savedValue;
                }
                final Widget wi;
                if (CrmXml.PARAM_OCF_CHECK_LEVEL.equals(param)) {
                    wi = widgetFactory.createInstance(Widget.Type.COMBOBOX,
                                                      defaultValue,
                                                      new Value[]{NOTHING_SELECTED_VALUE,
                                                                  new StringValue("10"),
                                                                  new StringValue("20")},
                                                      "^\\d*$",
                                                      rightWidth,
                                                      Widget.NO_ABBRV,
                                                      new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                                                      Widget.NO_BUTTON);
                } else {
                    final String regexp = "^-?\\d*$";
                    wi = widgetFactory.createInstance(
                                               Widget.Type.TEXTFIELDWITHUNIT,
                                               defaultValue,
                                               Widget.NO_ITEMS,
                                               getUnits(param),
                                               regexp,
                                               rightWidth,
                                               Widget.NO_ABBRV,
                                               new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                                               Widget.NO_BUTTON);
                }
                wi.setEnabled(savedOpIdRef == null);

                mOperationsComboBoxHashWriteLock.lock();
                try {
                    operationsComboBoxHash.put(op, param, wi);
                } finally {
                    mOperationsComboBoxHashWriteLock.unlock();
                }
                final String labelText = Tools.ucfirst(op) + " / " + Tools.ucfirst(param);
                final JLabel wiLabel = new JLabel(labelText);
                wi.setLabel(wiLabel, labelText);
                final JPanel panel;
                if (getBrowser().isCrmOperationAdvanced(op, param)) {
                    panel = advancedOpPanel;
                    advancedRows++;
                } else {
                    panel = normalOpPanel;
                    normalRows++;
                }
                addField(panel, wiLabel, wi.getComponent(), leftWidth, rightWidth, 0);
                application.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        wiLabel.setToolTipText(labelText);
                    }
View Full Code Here

        final CloneInfo cloneInfo = cloneInfoProvider.get();
        cloneInfo.init(crmXML.getCloneResourceAgent(), title, masterSlave, getBrowser());
        setCloneInfo(cloneInfo);
        cloneInfo.setContainedService(this);
        if (oldCI == null) {
            final Widget prevWi = getWidget(GUI_ID, null);
            if (prevWi != null) {
                cloneInfo.getService().setId(getName() + '_' + prevWi.getStringValue());
            }
            getBrowser().addNameToServiceInfoHash(cloneInfo);
            getBrowser().addToHeartbeatIdList(cloneInfo);
            getBrowser().getCrmGraph().exchangeObjectInTheVertex(cloneInfo, this);
            cloneInfo.setPingComboBox(pingComboBox);
View Full Code Here

TOP

Related Classes of lcmc.cluster.ui.widget.Widget

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.