Exemplo n.º 1
0
  /** Returns info panel. */
  @Override
  public final JComponent getInfoPanel() {
    if (infoPanel != null) {
      return infoPanel;
    }
    final boolean abExisted = getApplyButton() != null;
    /* main, button and options panels */
    final JPanel mainPanel = new JPanel();
    mainPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    final JTable headerTable = getTable(VMSVirtualDomainInfo.HEADER_TABLE);
    if (headerTable != null) {
      mainPanel.add(headerTable.getTableHeader());
      mainPanel.add(headerTable);
    }
    addHardwareTable(mainPanel);

    final JPanel buttonPanel = new JPanel(new BorderLayout());
    buttonPanel.setBackground(ClusterBrowser.BUTTON_PANEL_BACKGROUND);
    buttonPanel.setMinimumSize(new Dimension(0, 50));
    buttonPanel.setPreferredSize(new Dimension(0, 50));
    buttonPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 50));

    final JPanel optionsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 20));
    optionsPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND);

    final String[] params = getParametersFromXML();
    initApplyButton(null);
    /* add item listeners to the apply button. */
    if (!abExisted) {
      getApplyButton()
          .addActionListener(
              new ActionListener() {
                @Override
                public void actionPerformed(final ActionEvent e) {
                  final Thread thread =
                      new Thread(
                          new Runnable() {
                            @Override
                            public void run() {
                              getBrowser().clStatusLock();
                              apply(false);
                              getBrowser().clStatusUnlock();
                            }
                          });
                  thread.start();
                }
              });
      getRevertButton()
          .addActionListener(
              new ActionListener() {
                @Override
                public void actionPerformed(final ActionEvent e) {
                  final Thread thread =
                      new Thread(
                          new Runnable() {
                            @Override
                            public void run() {
                              getBrowser().clStatusLock();
                              revert();
                              getBrowser().clStatusUnlock();
                            }
                          });
                  thread.start();
                }
              });
    }
    final JPanel extraButtonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    extraButtonPanel.setBackground(Browser.BUTTON_PANEL_BACKGROUND);
    buttonPanel.add(extraButtonPanel);
    addApplyButton(buttonPanel);
    addRevertButton(extraButtonPanel);
    final MyButton overviewButton = new MyButton("VM Host Overview", BACK_ICON);
    overviewButton.miniButton();
    overviewButton.setPreferredSize(new Dimension(130, 50));
    // overviewButton.setPreferredSize(new Dimension(200, 50));
    overviewButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            vmsVirtualDomainInfo.selectMyself();
          }
        });
    extraButtonPanel.add(overviewButton);
    addParams(
        optionsPanel,
        params,
        ClusterBrowser.SERVICE_LABEL_WIDTH,
        ClusterBrowser.SERVICE_FIELD_WIDTH * 2,
        null);
    /* Actions */
    buttonPanel.add(getActionsButton(), BorderLayout.EAST);

    mainPanel.add(optionsPanel);
    final JPanel newPanel = new JPanel();
    newPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND);
    newPanel.setLayout(new BoxLayout(newPanel, BoxLayout.Y_AXIS));
    newPanel.add(buttonPanel);
    newPanel.add(
        getMoreOptionsPanel(
            ClusterBrowser.SERVICE_LABEL_WIDTH + ClusterBrowser.SERVICE_FIELD_WIDTH + 4));
    newPanel.add(new JScrollPane(mainPanel));
    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            getApplyButton().setVisible(!getVMSVirtualDomainInfo().getResource().isNew());
            setApplyButtons(null, params);
          }
        });
    infoPanel = newPanel;
    infoPanelDone();
    return infoPanel;
  }
Exemplo n.º 2
0
  /** Prepares a new <code>ClusterViewPanel</code> object. */
  EmptyViewPanel() {
    super();
    browser = new EmptyBrowser();
    Tools.getGUIData().setEmptyBrowser(browser);
    browser.setEmptyViewPanel(this);
    browser.initHosts();

    final JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.setMinimumSize(new Dimension(0, 110));
    buttonPanel.setPreferredSize(new Dimension(0, 110));
    buttonPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 110));
    buttonPanel.setBackground(STATUS_BACKGROUND);
    add(buttonPanel, BorderLayout.NORTH);
    final JPanel logoPanel = new JPanel(new CardLayout());
    logoPanel.setBackground(java.awt.Color.WHITE);
    final ImageIcon logoImage = Tools.createImageIcon("startpage_head.jpg");

    final JLabel logo = new JLabel(logoImage);
    final JPanel lPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    lPanel.setBackground(java.awt.Color.WHITE);
    lPanel.add(logo);
    logoPanel.add(lPanel, LOGO_PANEL_STRING);
    final JPanel smallButtonPanel = new JPanel();
    smallButtonPanel.setBackground(STATUS_BACKGROUND);
    smallButtonPanel.setLayout(new BoxLayout(smallButtonPanel, BoxLayout.Y_AXIS));
    buttonPanel.add(smallButtonPanel);
    /* check for upgrade field. */
    smallButtonPanel.add(Tools.getGUIData().getClustersPanel().registerUpgradeTextField());
    /* add new host button */
    final MyButton addHostButton =
        new MyButton(Tools.getString("ClusterTab.AddNewHost"), HOST_ICON);
    addHostButton.setBackgroundColor(Browser.STATUS_BACKGROUND);
    addHostButton.setPreferredSize(BIG_BUTTON_DIMENSION);
    addHostButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            final Thread thread =
                new Thread(
                    new Runnable() {
                      @Override
                      public void run() {
                        final AddHostDialog ahd = new AddHostDialog();
                        ahd.showDialogs();
                      }
                    });
            thread.start();
          }
        });
    Tools.getGUIData().registerAddHostButton(addHostButton);
    buttonPanel.add(addHostButton);
    createEmptyView();
    add(logoPanel, BorderLayout.SOUTH);
    Tools.getGUIData().registerAllHostsUpdate(this);
    Tools.getGUIData().allHostsUpdate();

    /* add new cluster button */
    final MyButton addClusterButton =
        new MyButton(Tools.getString("ClusterTab.AddNewCluster"), CLUSTER_ICON);
    addClusterButton.setBackgroundColor(Browser.STATUS_BACKGROUND);
    addClusterButton.setPreferredSize(BIG_BUTTON_DIMENSION);
    addClusterButton.setMinimumSize(BIG_BUTTON_DIMENSION);
    addClusterButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            final Thread thread =
                new Thread(
                    new Runnable() {
                      @Override
                      public void run() {
                        AddClusterDialog acd = new AddClusterDialog();
                        acd.showDialogs();
                      }
                    });
            thread.start();
          }
        });
    Tools.getGUIData().registerAddClusterButton(addClusterButton);
    Tools.getGUIData().checkAddClusterButtons();
    buttonPanel.add(addClusterButton);
    if (!Tools.getConfigData().getAutoHosts().isEmpty()) {
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              addHostButton.pressButton();
            }
          });
    }
  }