001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2009 Sun Microsystems, Inc.
025 *      Portions Copyright 2014-2015 ForgeRock AS
026 */
027package org.opends.guitools.controlpanel.ui;
028
029import static org.opends.messages.AdminToolMessages.*;
030import static org.opends.server.util.StaticUtils.isOEMVersion;
031
032import java.awt.CardLayout;
033import java.awt.Component;
034import java.awt.GridBagConstraints;
035
036import javax.swing.JPanel;
037
038import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
039import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
040import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
041import org.opends.guitools.controlpanel.util.Utilities;
042import org.forgerock.i18n.LocalizableMessage;
043
044
045/**
046 * The panel on the right of the 'General Information' panel.
047 *
048 */
049public class GeneralMonitoringRightPanel extends StatusGenericPanel
050{
051  private static final long serialVersionUID = -4197460101279681042L;
052
053  /** The panel with a CardLayout that contains all the panels. */
054  protected JPanel mainPanel;
055
056  private RootMonitoringPanel rootPanel = new RootMonitoringPanel();
057  private WorkQueueMonitoringPanel workQueuePanel = new WorkQueueMonitoringPanel();
058  private EntryCachesMonitoringPanel entryCachesPanel = new EntryCachesMonitoringPanel();
059  private DatabaseMonitoringPanel jeMonitoringPanel = new DatabaseMonitoringPanel(BackendDescriptor.PluggableType.JE);
060  private DatabaseMonitoringPanel pdbMonitoringPanel = new DatabaseMonitoringPanel(BackendDescriptor.PluggableType.PDB);
061  private SystemInformationMonitoringPanel systemInformationPanel = new SystemInformationMonitoringPanel();
062  private JavaInformationMonitoringPanel javaInformationPanel = new JavaInformationMonitoringPanel();
063
064  private static final String rootPanelTitle = "RootMonitoringPanel";
065  private static final String workQueuePanelTitle = "WorkQueueMonitoringPanel";
066  private static final String entryCachesPanelTitle = "EntryCachesMonitoringPanel";
067  private static final String jeMonitoringPanelTitle = "JEDatabaseMonitoringPanel";
068  private static final String pdbMonitoringPanelTitle = "PDBDatabaseMonitoringPanel";
069  private static final String systemInformationPanelTitle = "SystemInformationMonitoringPanel";
070  private static final String javaInformationPanelTitle = "JavaInformationMonitoringPanel";
071
072  /** The panel used to update messages. */
073  protected NoItemSelectedPanel noEntryPanel = new NoItemSelectedPanel();
074  private static final String noEntryPanelTitle = "JavaInformationMonitoringPanel";
075
076  private final StatusGenericPanel[] panels =
077  {
078      rootPanel,
079      workQueuePanel,
080      entryCachesPanel,
081      jeMonitoringPanel,
082      pdbMonitoringPanel,
083      systemInformationPanel,
084      javaInformationPanel
085  };
086
087  /** Default constructor. */
088  public GeneralMonitoringRightPanel()
089  {
090    super();
091    createLayout();
092  }
093
094  /**
095   * Displays a panel containing a message.
096   * @param msg the message.
097   */
098  public void displayMessage(LocalizableMessage msg)
099  {
100    noEntryPanel.setMessage(msg);
101    ((CardLayout)mainPanel.getLayout()).show(mainPanel, noEntryPanelTitle);
102  }
103
104  /** {@inheritDoc} */
105  public void setInfo(ControlPanelInfo info)
106  {
107    super.setInfo(info);
108    for (StatusGenericPanel panel : panels)
109    {
110      panel.setInfo(info);
111    }
112  }
113
114  /** Creates the layout of the panel (but the contents are not populated here). */
115  protected void createLayout()
116  {
117    GridBagConstraints gbc = new GridBagConstraints();
118    CardLayout cardLayout = new CardLayout();
119    mainPanel = new JPanel(cardLayout);
120    mainPanel.setOpaque(false);
121    noEntryPanel.setMessage(INFO_CTRL_PANEL_GENERAL_MONITORING_NO_ITEM_SELECTED.get());
122    // panels with scroll
123    mainPanel.add(Utilities.createBorderLessScrollBar(noEntryPanel), noEntryPanelTitle);
124    mainPanel.add(Utilities.createBorderLessScrollBar(rootPanel), rootPanelTitle);
125    mainPanel.add(Utilities.createBorderLessScrollBar(workQueuePanel), workQueuePanelTitle);
126    mainPanel.add(Utilities.createBorderLessScrollBar(entryCachesPanel), entryCachesPanelTitle);
127    mainPanel.add(Utilities.createBorderLessScrollBar(systemInformationPanel), systemInformationPanelTitle);
128    mainPanel.add(Utilities.createBorderLessScrollBar(javaInformationPanel), javaInformationPanelTitle);
129    // panels with no scroll
130    if (!isOEMVersion())
131    {
132      mainPanel.add(jeMonitoringPanel, jeMonitoringPanelTitle);
133    }
134    mainPanel.add(pdbMonitoringPanel, pdbMonitoringPanelTitle);
135    cardLayout.show(mainPanel, noEntryPanelTitle);
136    gbc.gridx = 0;
137    gbc.gridy = 0;
138    gbc.weightx = 1.0;
139    gbc.weighty = 1.0;
140    gbc.fill = GridBagConstraints.BOTH;
141    add(mainPanel, gbc);
142  }
143
144  /** {@inheritDoc} */
145  public void okClicked()
146  {
147    // No ok button
148  }
149
150  /** {@inheritDoc} */
151  public GenericDialog.ButtonType getButtonType()
152  {
153    return GenericDialog.ButtonType.NO_BUTTON;
154  }
155
156  /** {@inheritDoc} */
157  public LocalizableMessage getTitle()
158  {
159    return LocalizableMessage.EMPTY;
160  }
161
162  /** {@inheritDoc} */
163  public Component getPreferredFocusComponent()
164  {
165    return null;
166  }
167
168  /** {@inheritDoc} */
169  public void configurationChanged(ConfigurationChangeEvent ev)
170  {
171  }
172
173  /** Updates the contents of the panel with the root monitoring information. */
174  public void updateRoot()
175  {
176    rootPanel.updateContents();
177    ((CardLayout)mainPanel.getLayout()).show(mainPanel, rootPanelTitle);
178  }
179
180  /** Updates the contents of the panel with the system information monitoring. */
181  public void updateSystemInformation()
182  {
183    systemInformationPanel.updateContents();
184    ((CardLayout)mainPanel.getLayout()).show(mainPanel, systemInformationPanelTitle);
185  }
186
187  /** Updates the contents of the panel with the work queue monitoring information. */
188  public void updateWorkQueue()
189  {
190    workQueuePanel.updateContents();
191    ((CardLayout)mainPanel.getLayout()).show(mainPanel, workQueuePanelTitle);
192  }
193
194  /** Updates the contents of the panel with the entry caches monitoring information. */
195  public void updateEntryCaches()
196  {
197    entryCachesPanel.updateContents();
198    ((CardLayout)mainPanel.getLayout()).show(mainPanel, entryCachesPanelTitle);
199  }
200
201  /** Updates the contents of the panel with the je database monitoring information. */
202  public void updateJEDatabaseInformation()
203  {
204    jeMonitoringPanel.updateContents();
205    ((CardLayout)mainPanel.getLayout()).show(mainPanel, jeMonitoringPanelTitle);
206  }
207
208  /** Updates the contents of the panel with the pdb database monitoring information. */
209  public void updatePDBDatbaseInformation()
210  {
211    pdbMonitoringPanel.updateContents();
212    ((CardLayout)mainPanel.getLayout()).show(mainPanel, pdbMonitoringPanelTitle);
213  }
214
215  /** Updates the contents of the panel with the JAVA information. */
216  public void updateJavaInformation()
217  {
218    javaInformationPanel.updateContents();
219    ((CardLayout)mainPanel.getLayout()).show(mainPanel, javaInformationPanelTitle);
220  }
221
222}