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