コード例 #1
0
ファイル: HostInfo.java プロジェクト: xuzhikethinker/lcmc
 /** Returns a host icon for the menu. */
 @Override
 public ImageIcon getMenuIcon(final boolean testOnly) {
   final Cluster cl = host.getCluster();
   if (cl != null) {
     return HostBrowser.HOST_IN_CLUSTER_ICON_RIGHT_SMALL;
   }
   return HostBrowser.HOST_ICON;
 }
コード例 #2
0
ファイル: VGCreate.java プロジェクト: rdndnl/lcmc
  /** Returns the input pane. */
  @Override
  protected JComponent getInputPane() {
    createButton.setEnabled(false);
    final JPanel pane = new JPanel(new SpringLayout());
    /* vg name */
    final JPanel inputPane = new JPanel(new SpringLayout());
    inputPane.setBackground(Browser.BUTTON_PANEL_BACKGROUND);

    /* find next free group volume name */
    String defaultName;
    final Set<String> volumeGroups = host.getVolumeGroupNames();
    int i = 0;
    while (true) {
      defaultName = "vg" + String.format("%02d", i);
      if (volumeGroups == null || !volumeGroups.contains(defaultName)) {
        break;
      }
      i++;
    }
    vgNameWi =
        WidgetFactory.createInstance(
            Widget.Type.TEXTFIELD,
            defaultName,
            Widget.NO_ITEMS,
            Widget.NO_REGEXP,
            250,
            Widget.NO_ABBRV,
            new AccessMode(ConfigData.AccessType.OP, !AccessMode.ADVANCED),
            Widget.NO_BUTTON);
    inputPane.add(new JLabel("VG Name"));
    inputPane.add(vgNameWi);

    createButton.addActionListener(new CreateActionListener());
    inputPane.add(createButton);
    SpringUtilities.makeCompactGrid(
        inputPane, 1, 3, /* rows, cols */ 1, 1, /* initX, initY */ 1, 1); /* xPad, yPad */

    pane.add(inputPane);
    /* Volume groups. */
    final JPanel pvsPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    final Set<String> selectedPVs = new HashSet<String>();
    final Set<Host> selectedHosts = new HashSet<Host>();
    for (final BlockDevInfo sbdi : selectedBlockDevInfos) {
      if (sbdi.getBlockDevice().isDrbd()) {
        selectedPVs.add(sbdi.getBlockDevice().getDrbdBlockDevice().getName());
      } else {
        selectedPVs.add(sbdi.getName());
      }
      selectedHosts.add(sbdi.getHost());
    }
    pvCheckBoxes = getPVCheckBoxes(selectedPVs);
    pvsPane.add(new JLabel("Select physical volumes: "));
    for (final String pvName : pvCheckBoxes.keySet()) {
      pvCheckBoxes.get(pvName).addItemListener(new ItemChangeListener(true));
      pvsPane.add(pvCheckBoxes.get(pvName));
    }
    final JScrollPane pvSP = new JScrollPane(pvsPane);
    pvSP.setPreferredSize(new Dimension(0, 45));
    pane.add(pvSP);

    final JPanel hostsPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    final Cluster cluster = host.getCluster();
    hostCheckBoxes = Tools.getHostCheckBoxes(cluster);
    hostsPane.add(new JLabel("Select Hosts: "));
    for (final Host h : hostCheckBoxes.keySet()) {
      hostCheckBoxes.get(h).addItemListener(new ItemChangeListener(true));
      if (host == h) {
        hostCheckBoxes.get(h).setEnabled(false);
        hostCheckBoxes.get(h).setSelected(true);
      } else if (isOneDrbd(selectedBlockDevInfos)) {
        hostCheckBoxes.get(h).setEnabled(false);
        hostCheckBoxes.get(h).setSelected(false);
      } else if (hostHasPVS(h)) {
        hostCheckBoxes.get(h).setEnabled(true);
        hostCheckBoxes.get(h).setSelected(selectedHosts.contains(h));
      } else {
        hostCheckBoxes.get(h).setEnabled(false);
        hostCheckBoxes.get(h).setSelected(false);
      }
      hostsPane.add(hostCheckBoxes.get(h));
    }
    final JScrollPane sp = new JScrollPane(hostsPane);
    sp.setPreferredSize(new Dimension(0, 45));
    pane.add(sp);
    pane.add(getProgressBarPane(null));
    pane.add(getAnswerPane(""));
    SpringUtilities.makeCompactGrid(
        pane, 5, 1, /* rows, cols */ 0, 0, /* initX, initY */ 0, 0); /* xPad, yPad */
    checkButtons();
    return pane;
  }
コード例 #3
0
ファイル: TerminalPanel.java プロジェクト: npk/lcmc
  /** Starts action after cheat was entered. */
  private void startCheat(final String cheat) {
    if (!editEnabled) {
      addCommand(cheat);
    }
    if (!editEnabled && GOD_ON.equals(cheat)) {
      editEnabled = true;
      Tools.getGUIData().godModeChanged(editEnabled);
    } else if (editEnabled && GOD_OFF.equals(cheat)) {
      editEnabled = false;
      Tools.getGUIData().godModeChanged(editEnabled);
    } else if (CHEAT_LIST.equals(cheat)) {
      final StringBuilder list = new StringBuilder();
      for (final String ch : CHEATS_MAP.keySet()) {
        list.append(ch);
        list.append('\n');
      }
      addCommandOutput(list.toString());
    } else if (RUN_GC.equals(cheat)) {
      System.gc();
      Tools.info("run gc");
    } else if (ALLOCATE_10.equals(cheat)) {
      final Thread t =
          new Thread(
              new Runnable() {
                @Override
                public void run() {
                  Tools.info("allocate mem");
                  Byte[] b = new Byte[1024000];
                  Tools.info("allocate mem done.");

                  System.gc();
                  Tools.info("run gc");
                  Tools.sleep(60000);
                  Tools.info("free mem.");
                }
              });
      t.start();
    } else if (CLICKTEST_SHORT.equals(cheat)) {
      RoboTest.startClicker(1, false);
    } else if (CLICKTEST_LONG.equals(cheat)) {
      RoboTest.startClicker(8 * 60, false);
    } else if (CLICKTEST_LAZY_SHORT.equals(cheat)) {
      RoboTest.startClicker(1, true);
    } else if (CLICKTEST_LAZY_LONG.equals(cheat)) {
      RoboTest.startClicker(8 * 60, true); /* 8 hours */
    } else if (RIGHT_CLICKTEST_SHORT.equals(cheat)) {
      RoboTest.startRightClicker(1, false);
    } else if (RIGHT_CLICKTEST_LONG.equals(cheat)) {
      RoboTest.startRightClicker(8 * 60, false);
    } else if (RIGHT_CLICKTEST_LAZY_SHORT.equals(cheat)) {
      RoboTest.startRightClicker(1, true);
    } else if (RIGHT_CLICKTEST_LAZY_LONG.equals(cheat)) {
      RoboTest.startRightClicker(8 * 60, true); /* 8 hours */
    } else if (MOVETEST_SHORT.equals(cheat)) {
      RoboTest.startMover(1, false);
    } else if (MOVETEST_LONG.equals(cheat)) {
      RoboTest.startMover(8 * 60, false);
    } else if (MOVETEST_LAZY_SHORT.equals(cheat)) {
      RoboTest.startMover(1, true);
    } else if (MOVETEST_LAZY_LONG.equals(cheat)) {
      RoboTest.startMover(8 * 60, true);
    } else if (DEBUG_INC.equals(cheat)) {
      Tools.incrementDebugLevel();
    } else if (DEBUG_DEC.equals(cheat)) {
      Tools.decrementDebugLevel();
    } else if (TESTS.containsKey(cheat)) {
      RoboTest.startTest(TESTS.get(cheat), host.getCluster());
    } else if (REGISTER_MOVEMENT.equals(cheat)) {
      RoboTest.registerMovement();
    }
    nextCommand();
  }