예제 #1
0
파일: Resource.java 프로젝트: evadmin/lcmc
 /** Applies the changes and returns next dialog (BlockDev). */
 @Override
 public WizardDialog nextDialog() {
   final DrbdResourceInfo dri = getDrbdVolumeInfo().getDrbdResourceInfo();
   final DrbdInfo drbdInfo = dri.getDrbdInfo();
   final boolean protocolInNetSection = drbdInfo.atLeastVersion("8.4");
   if (drbdInfo.getDrbdResources().size() <= 1) {
     for (final String commonP : COMMON_PARAMS) {
       if (!protocolInNetSection && PROTOCOL.equals(commonP)) {
         continue;
       }
       final String value = dri.getComboBoxValue(commonP);
       drbdInfo.getResource().setValue(commonP, value);
       drbdInfo.getWidget(commonP, null).setValue(value);
     }
   }
   Tools.waitForSwing();
   drbdInfo.apply(false);
   dri.apply(false);
   return new Volume(this, getDrbdVolumeInfo());
 }
예제 #2
0
파일: Resource.java 프로젝트: evadmin/lcmc
  /** Returns input pane where user can configure a drbd resource. */
  @Override
  protected JComponent getInputPane() {
    final DrbdResourceInfo dri = getDrbdVolumeInfo().getDrbdResourceInfo();
    final DrbdInfo drbdInfo = dri.getDrbdInfo();
    dri.getInfoPanel();
    dri.waitForInfoPanel();
    Tools.waitForSwing();
    final JPanel inputPane = new JPanel();
    inputPane.setLayout(new BoxLayout(inputPane, BoxLayout.X_AXIS));

    final JPanel optionsPanel = new JPanel();
    optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS));
    optionsPanel.setAlignmentY(Component.TOP_ALIGNMENT);
    /* common options */
    final Map<String, String> commonPreferredValue = new HashMap<String, String>();
    commonPreferredValue.put(PROTOCOL, "C");
    commonPreferredValue.put(DEGR_WFC_TIMEOUT_PARAM, "0");
    commonPreferredValue.put(CRAM_HMAC_ALG, "sha1");
    commonPreferredValue.put(SHARED_SECRET, getRandomSecret());
    commonPreferredValue.put(ON_IO_ERROR, "detach");
    if (drbdInfo.getDrbdResources().size() <= 1) {
      for (final String commonP : COMMON_PARAMS) {
        /* for the first resource set common options. */
        final String commonValue = drbdInfo.getResource().getValue(commonP);
        if (commonPreferredValue.containsKey(commonP)) {
          final String defaultValue = drbdInfo.getParamDefault(commonP);
          if ((defaultValue == null && "".equals(commonValue))
              || (defaultValue != null && defaultValue.equals(commonValue))) {
            drbdInfo.getWidget(commonP, null).setValue(commonPreferredValue.get(commonP));
            dri.getResource().setValue(commonP, commonPreferredValue.get(commonP));
          } else {
            dri.getResource().setValue(commonP, commonValue);
          }
        }
      }
    } else {
      /* resource options, if not defined in common section. */
      for (final String commonP : COMMON_PARAMS) {
        final String commonValue = drbdInfo.getResource().getValue(commonP);
        if ("".equals(commonValue) && commonPreferredValue.containsKey(commonP)) {
          dri.getResource().setValue(commonP, commonPreferredValue.get(commonP));
        }
      }
    }

    /* address combo boxes */
    dri.addHostAddresses(
        optionsPanel,
        ClusterBrowser.SERVICE_LABEL_WIDTH,
        ClusterBrowser.SERVICE_FIELD_WIDTH,
        true,
        buttonClass(nextButton()));
    dri.addWizardParams(
        optionsPanel,
        PARAMS,
        buttonClass(nextButton()),
        Tools.getDefaultSize("Dialog.DrbdConfig.Resource.LabelWidth"),
        Tools.getDefaultSize("Dialog.DrbdConfig.Resource.FieldWidth"),
        null);

    inputPane.add(optionsPanel);
    final JScrollPane sp = new JScrollPane(inputPane);
    sp.setMaximumSize(new Dimension(Short.MAX_VALUE, 200));
    sp.setPreferredSize(new Dimension(Short.MAX_VALUE, 200));
    return sp;
  }