Package lcmc.cluster.ui.widget

Examples of lcmc.cluster.ui.widget.Widget


            public void check(final Value value) {
                if (fieldCheckLatch.getCount() > 0) {
                    return;
                }
                for (final String option : OPTIONS) {
                    final Widget w = optionsWidgets.get(option);
                    if (w != null) {
                        if (checkRegexp(w.getRegexp(), w.getStringValue())) {
                            w.setBackground(null, null, true);
                        } else {
                            w.wrongValue();
                        }
                    }
                }
                guiData.setAccessible(makeConfigButton, AccessMode.ADMIN);
            }
View Full Code Here


            final FilesystemData filesystemData = filesystems.get(getName());
            if (filesystemData != null) {
                for (final String param : getParametersFromXML()) {
                    final Value oldValue = getParamSaved(param);
                    Value value = getParamSaved(param);
                    final Widget wi = getWidget(param, null);
                    for (final Host h
                            : getVMSVirtualDomainInfo().getDefinedOnHosts()) {
                        final VmsXml vmsXml = getBrowser().getVmsXml(h);
                        if (vmsXml != null) {
                            final Value savedValue =
                                               filesystemData.getValue(param);
                            if (savedValue != null) {
                                value = savedValue;
                            }
                        }
                    }
                    if (!Tools.areEqual(value, oldValue)) {
                        getResource().setValue(param, value);
                        if (wi != null) {
                            /* only if it is not changed by user. */
                            wi.setValue(value);
                        }
                    }
                }
            }
        }
View Full Code Here

        if (FilesystemData.SOURCE_DIR.equals(param)) {
            final Value sourceDir = getParamSaved(FilesystemData.SOURCE_DIR);
            final MyButton fileChooserBtn = widgetFactory.createButton("Browse...");
            application.makeMiniButton(fileChooserBtn);
            final String regexp = ".*[^/]?$";
            final Widget paramWi = widgetFactory.createInstance(
                                     getFieldType(param),
                                     sourceDir,
                                     getParamPossibleChoices(param),
                                     regexp,
                                     width,
                                     Widget.NO_ABBRV,
                                     new AccessMode(getAccessType(param), AccessMode.NORMAL),
                                     fileChooserBtn);
            paramWi.setAlwaysEditable(true);
            if (prefix == null) {
                sourceDirWi.put("", paramWi);
            } else {
                sourceDirWi.put(prefix, paramWi);
            }
            if (Tools.isWindows()) {
                paramWi.setTFButtonEnabled(false);
            }
            fileChooserBtn.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(final ActionEvent e) {
                    final Thread t = new Thread(new Runnable() {
                        @Override
                        public void run() {
                            final String file;
                            final String oldFile = paramWi.getStringValue();
                            if (oldFile == null || oldFile.isEmpty()) {
                                file = LXC_SOURCE_DIR;
                            } else {
                                file = oldFile;
                            }
                            startFileChooser(paramWi,
                                             file,
                                             FILECHOOSER_DIR_ONLY);
                        }
                    });
                    t.start();
                }
            });
            widgetAdd(param, prefix, paramWi);
            return paramWi;
        } else if (FilesystemData.SOURCE_NAME.equals(param)) {
            final Value sourceName = getParamSaved(FilesystemData.SOURCE_NAME);
            final Widget paramWi = widgetFactory.createInstance(
                                    getFieldType(param),
                                    sourceName,
                                    getParamPossibleChoices(param),
                                    Widget.NO_REGEXP,
                                    width,
                                    Widget.NO_ABBRV,
                                    new AccessMode(getAccessType(param), AccessMode.NORMAL),
                                    Widget.NO_BUTTON);
            paramWi.setAlwaysEditable(true);
            if (prefix == null) {
                sourceNameWi.put("", paramWi);
            } else {
                sourceNameWi.put(prefix, paramWi);
            }
            widgetAdd(param, prefix, paramWi);
            return paramWi;
        } else {
            final Widget paramWi = super.createWidget(param, prefix, width);

            if (FilesystemData.SOURCE_DIR.equals(param)
                || FilesystemData.TARGET_DIR.equals(param)) {
                paramWi.setAlwaysEditable(true);
            }
            return paramWi;
        }
    }
View Full Code Here

        final MultiKeyMap<String, JPanel> panelPartsMap = new MultiKeyMap<String, JPanel>();
        final Collection<PanelPart> panelPartsList = new ArrayList<PanelPart>();
        final MultiKeyMap<String, Integer> panelPartRowsMap = new MultiKeyMap<String, Integer>();
       
        for (final String param : params) {
            final Widget paramWi = createWidget(param, prefix, rightWidth);
            /* sub panel */
            final String section = getSection(param);
            final JPanel panel;
            final AccessMode.Type accessType = getAccessType(param);
            final String accessTypeString = accessType.toString();
            final Boolean advanced = isAdvanced(param);
            final String advancedString = advanced.toString();
            if (panelPartsMap.containsKey(section, accessTypeString, advancedString)) {
                panel = panelPartsMap.get(section, accessTypeString, advancedString);
                panelPartRowsMap.put(section,
                                     accessTypeString,
                                     advancedString,
                                     panelPartRowsMap.get(section, accessTypeString, advancedString) + 1);
            } else {
                panel = new JPanel(new SpringLayout());

                panel.setBackground(getSectionColor(section));
                if (advanced) {
                    advancedPanelList.add(panel);
                    panel.setVisible(application.isAdvancedMode());
                }
                panelPartsMap.put(section, accessTypeString, advancedString, panel);
                panelPartsList.add(new PanelPart(section, accessType, advanced));
                panelPartRowsMap.put(section, accessTypeString, advancedString, 1);
            }

            /* label */
            final JLabel label = new JLabel(getParamShortDesc(param));
            final String longDesc = getParamLongDesc(param);
            paramWi.setLabel(label, longDesc);

            /* tool tip */
            paramWi.setToolTipText(getToolTipText(param, paramWi));
            label.setToolTipText(longDesc + additionalToolTip(param));
            int height = 0;
            if (paramWi instanceof Label) {
                height = application.getDefaultSize("Browser.LabelFieldHeight");
            }
            addField(panel, label, paramWi.getComponent(), leftWidth, rightWidth, height);
        }
        final boolean wizard = Widget.WIZARD_PREFIX.equals(prefix);
        for (final String param : params) {
            final Widget paramWi = getWidget(param, prefix);
            if (wizard) {
                final Widget rpwi = getWidget(param, null);
                if (rpwi == null) {
                    LOG.error("addParams: unknown param: " + param);
                    continue;
                }
                if (paramWi.getValue() == null
                    || paramWi.getValue().isNothingSelected()) {
                    rpwi.setValueAndWait(null);
                } else {
                    final Value value = paramWi.getValue();
                    rpwi.setValueAndWait(value);
                }
            }
        }
        for (final String param : params) {
            final Widget paramWi = getWidget(param, prefix);
            Widget rpwi = null;
            if (wizard) {
                rpwi = getWidget(param, null);
            }
            final Widget realParamWi = rpwi;
            paramWi.addListeners(new WidgetListener() {
                @Override
                public void check(final Value value) {
                    checkParameterFields(paramWi, realParamWi, param, getParametersFromXML(), thisApplyButton);
                }
            });
        }

        /* add sub panels to the option panel */
        final Map<String, JPanel> sectionMap = new HashMap<String, JPanel>();
        final Collection<JPanel> notAdvancedSections = new HashSet<JPanel>();
        final Collection<JPanel> advancedSections = new HashSet<JPanel>();
        for (final PanelPart panelPart : panelPartsList) {
            final String section = panelPart.getSection();
            final AccessMode.Type accessType = panelPart.getType();
            final String accessTypeString = accessType.toString();
            final Boolean advanced = panelPart.isAdvanced();
            final String advancedString = advanced.toString();

            final JPanel panel = panelPartsMap.get(section, accessTypeString, advancedString);
            final int rows = panelPartRowsMap.get(section, accessTypeString, advancedString);
            final int columns = 2;
            SpringUtilities.makeCompactGrid(panel, rows, columns,
                                                         1, 1// initX, initY
                                                         1, 1); // xPad, yPad
            final JPanel sectionPanel;
            if (sectionMap.containsKey(section)) {
                sectionPanel = sectionMap.get(section);
            } else {
                sectionPanel = getParamPanel(getSectionDisplayName(section), getSectionColor(section));
                sectionMap.put(section, sectionPanel);
                addSectionPanel(section, wizard, sectionPanel);
                optionsPanel.add(sectionPanel);
                if (sameAsFields != null) {
                    final Widget sameAsCombo = sameAsFields.get(section);
                    if (sameAsCombo != null) {
                        final JPanel saPanel = new JPanel(new SpringLayout());
                        saPanel.setBackground(Browser.BUTTON_PANEL_BACKGROUND);
                        final JLabel label = new JLabel(Tools.getString("ClusterBrowser.SameAs"));
                        sameAsCombo.setLabel(label, "");
                        addField(saPanel, label, sameAsCombo.getComponent(), leftWidth, rightWidth, 0);
                        SpringUtilities.makeCompactGrid(saPanel, 1, 2,
                                                                 1, 1// initX, initY
                                                                 1, 1); // xPad, yPad
                        sectionPanel.add(saPanel);
                    }
View Full Code Here

        thread.start();
    }

    /** Get stored value in the combo box. */
    public final Value getComboBoxValue(final String param) {
        final Widget wi = getWidget(param, null);
        if (wi == null) {
            return null;
        }
        return wi.getValue();
    }
View Full Code Here

             final SerialData serialData = serials.get(getName());
             if (serialData != null) {
                 for (final String param : getParametersFromXML()) {
                     final Value oldValue = getParamSaved(param);
                     Value value = getParamSaved(param);
                     final Widget wi = getWidget(param, null);
                     for (final Host h
                         : getVMSVirtualDomainInfo().getDefinedOnHosts()) {
                         final VmsXml vmsXml = getBrowser().getVmsXml(h);
                         if (vmsXml != null) {
                             final Value savedValue =
                                 serialData.getValue(param);
                             if (savedValue != null) {
                                 value = savedValue;
                             }
                         }
                     }
                     if (!Tools.areEqual(value, oldValue)) {
                         getResource().setValue(param, value);
                         if (wi != null) {
                             /* only if it is not changed by user. */
                             wi.setValue(value);
                         }
                     }
                 }
             }
         }
View Full Code Here

    /** Stores values in the combo boxes in the component c. */
    public void storeComboBoxValues(final String[] params) {
        for (final String param : params) {
            final Value value = getComboBoxValue(param);
            getResource().setValue(param, value);
            final Widget wi = getWidget(param, null);
            if (wi != null) {
                wi.setToolTipText(getToolTipText(param, wi));
            }
        }
    }
View Full Code Here

            type = Widget.Type.TEXTFIELDWITHUNIT;
            units = getTimeUnits();
        } else if (isLabel(param)) {
            type = Widget.Type.LABELFIELD;
        }
        final Widget paramWi = widgetFactory.createInstance(
                                      type,
                                      initValue,
                                      getPossibleChoices(param),
                                      units,
                                      regexp,
                                      width,
                                      abbreviations,
                                      new AccessMode(getAccessType(param), isEnabledOnlyInAdvancedMode(param)),
                                      null);
        widgetAdd(param, prefix, paramWi);
        paramWi.setEditable(true);
        return paramWi;
    }
View Full Code Here

    /** Checks whether this value matches the regexp of this field. */
    protected final boolean checkRegexp(final String param, final Value newValue) {
        String regexp = getParamRegexp(param);
        if (regexp == null) {
            final Widget wi = getWidget(param, null);
            if (wi != null) {
                regexp = wi.getRegexp();
            }
        }
        if (regexp != null) {
            final Pattern p = Pattern.compile(regexp);
            if (newValue == null || newValue.isNothingSelected()) {
View Full Code Here

        /* check if values are correct */
        final List<String> incorrect = new ArrayList<String>();
        final List<String> changed = new ArrayList<String>();
        if (params != null) {
            for (final String otherParam : params) {
                final Widget wi = getWidget(otherParam, null);
                if (wi == null) {
                    continue;
                }
                Value newValue = wi.getValue();

                /* check if value has changed */
                Value oldValue = getParamSaved(otherParam);
                if (oldValue == null) {
                    oldValue = getParamDefault(otherParam);
                }
                if (!Tools.areEqual(newValue, oldValue)) {
                    changed.add(otherParam + ": " + oldValue + " \u2192 " + newValue);
                }

                /* check correctness */
                final Boolean correctValueCache = (otherParam == null) ? null : paramCorrectValueMap.get(otherParam);
                if (param == null || param.equals(otherParam) || correctValueCache == null) {
                    final Widget wizardWi = getWidget(otherParam, Widget.WIZARD_PREFIX);
                    final String enable = isEnabled(otherParam);
                    if (wizardWi != null) {
                        wizardWi.setDisabledReason(enable);
                        wizardWi.setEnabled(enable == null);
                        newValue = wizardWi.getValue();
                    }
                    wi.setDisabledReason(enable);
                    wi.setEnabled(enable == null);
                    final boolean check = checkParam(otherParam, newValue) && checkRegexp(otherParam, newValue);
                    if (check) {
                        if (isTimeType(otherParam) || hasUnitPrefix(otherParam)) {
                            wi.setBackground(getParamDefault(otherParam),
                                             getParamSaved(otherParam),
                                             isRequired(otherParam));
                            if (wizardWi != null) {
                                wizardWi.setBackground(getParamDefault(otherParam),
                                                       getParamSaved(otherParam),
                                                       isRequired(otherParam));
                            }
                        } else {
                            wi.setBackground(getParamDefault(otherParam),
                                             getParamSaved(otherParam),
                                             isRequired(otherParam));
                            if (wizardWi != null) {
                                wizardWi.setBackground(getParamDefault(otherParam),
                                                       getParamSaved(otherParam),
                                                       isRequired(otherParam));
                            }
                        }
                    } else {
                        wi.wrongValue();
                        if (wizardWi != null) {
                            wizardWi.wrongValue();
                        }
                        incorrect.add(otherParam);
                    }
                    setCheckParamCache(otherParam, check);
                } else {
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.