3853N/A/*
3853N/A * CDDL HEADER START
3853N/A *
3853N/A * The contents of this file are subject to the terms of the
3853N/A * Common Development and Distribution License, Version 1.0 only
3853N/A * (the "License"). You may not use this file except in compliance
3853N/A * with the License.
3853N/A *
3853N/A * You can obtain a copy of the license at
3853N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE
3853N/A * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
3853N/A * See the License for the specific language governing permissions
3853N/A * and limitations under the License.
3853N/A *
3853N/A * When distributing Covered Code, include this CDDL HEADER in each
3853N/A * file and include the License file at
3853N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
3853N/A * add the following below this CDDL HEADER, with the fields enclosed
3853N/A * by brackets "[]" replaced with your own identifying information:
3853N/A * Portions Copyright [yyyy] [name of copyright owner]
3853N/A *
3853N/A * CDDL HEADER END
3853N/A *
3853N/A *
5067N/A * Copyright 2008-2010 Sun Microsystems, Inc.
3853N/A */
3853N/A
3853N/Apackage org.opends.guitools.controlpanel.ui;
3853N/A
3853N/Aimport static org.opends.messages.AdminToolMessages.*;
3853N/A
3853N/Aimport java.awt.Component;
3853N/Aimport java.awt.GridBagConstraints;
3853N/Aimport java.awt.GridBagLayout;
3853N/Aimport java.awt.Insets;
3853N/Aimport java.awt.event.ActionEvent;
3853N/Aimport java.awt.event.ActionListener;
3853N/Aimport java.util.ArrayList;
3853N/Aimport java.util.Collection;
3853N/Aimport java.util.HashSet;
3853N/Aimport java.util.Set;
3853N/Aimport java.util.SortedSet;
3853N/Aimport java.util.TreeSet;
3853N/A
3853N/Aimport javax.swing.Box;
3853N/Aimport javax.swing.JButton;
3853N/Aimport javax.swing.JComponent;
5067N/Aimport javax.swing.JEditorPane;
3853N/Aimport javax.swing.JLabel;
3853N/Aimport javax.swing.JPanel;
4131N/Aimport javax.swing.JScrollPane;
3853N/Aimport javax.swing.JTable;
3853N/Aimport javax.swing.SwingUtilities;
3853N/A
3853N/Aimport org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
3853N/Aimport org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
3853N/Aimport org.opends.guitools.controlpanel.datamodel.BaseDNTableModel;
3853N/Aimport org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor;
3853N/Aimport org.opends.guitools.controlpanel.datamodel.ConnectionHandlerTableModel;
3853N/Aimport org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
3853N/Aimport org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
4180N/Aimport org.opends.guitools.controlpanel.event.ScrollPaneBorderListener;
5067N/Aimport org.opends.guitools.controlpanel.ui.components.
5067N/A SelectableLabelWithHelpIcon;
3853N/Aimport org.opends.guitools.controlpanel.ui.renderer.BaseDNCellRenderer;
3853N/Aimport org.opends.guitools.controlpanel.ui.renderer.CustomCellRenderer;
3853N/Aimport org.opends.guitools.controlpanel.util.Utilities;
4131N/Aimport org.opends.guitools.controlpanel.util.ViewPositions;
3853N/Aimport org.opends.messages.Message;
3853N/Aimport org.opends.messages.MessageBuilder;
3853N/Aimport org.opends.server.types.DN;
3853N/Aimport org.opends.server.types.OpenDsException;
3853N/A
3853N/A/**
3853N/A * The panel displaying the general status of the server (started/stopped),
3853N/A * basic configuration (base DNs, connection listeners) and that allows to start
3853N/A * and stop the server.
3853N/A *
3853N/A */
3853N/Aclass StatusPanel extends StatusGenericPanel
3853N/A{
3853N/A private static final long serialVersionUID = -6493442314639004717L;
5067N/A // The place holder where we display errors.
5067N/A private JEditorPane serverStatus;
5067N/A private SelectableLabelWithHelpIcon currentConnections;
5067N/A private JEditorPane hostName;
5067N/A private JEditorPane administrativeUsers;
5067N/A private JEditorPane installPath;
5067N/A private JEditorPane instancePath;
5067N/A private JEditorPane opendsVersion;
5067N/A private SelectableLabelWithHelpIcon javaVersion;
5067N/A private JEditorPane adminConnector;
5067N/A private JEditorPane dbTableEmpty;
5067N/A private JEditorPane connectionHandlerTableEmpty;
4060N/A private JLabel lInstancePath;
3853N/A private JButton stopButton;
3853N/A private JButton startButton;
3853N/A private JButton restartButton;
3853N/A private BaseDNTableModel dbTableModelWithReplication;
3853N/A private BaseDNTableModel dbTableModelWithoutReplication;
3853N/A private JTable noReplicatedBaseDNsTable;
3853N/A private JTable replicationBaseDNsTable;
3853N/A
3853N/A private ConnectionHandlerTableModel connectionHandlerTableModel;
3853N/A private JTable connectionHandlersTable;
3853N/A
3853N/A /**
3853N/A * Default constructor.
3853N/A *
3853N/A */
3853N/A public StatusPanel()
3853N/A {
3853N/A super();
3853N/A GridBagConstraints gbc = new GridBagConstraints();
3853N/A gbc.gridx = 0;
3853N/A gbc.gridy = 0;
3853N/A gbc.gridwidth = 1;
4180N/A createErrorPane();
4180N/A gbc.insets = new Insets(20, 20, 10, 20);
4180N/A gbc.fill = GridBagConstraints.BOTH;
4180N/A gbc.weightx = 1.0;
4180N/A add(errorPane, gbc);
4180N/A JPanel inScrollPanel = new JPanel(new GridBagLayout());
4180N/A inScrollPanel.setOpaque(false);
3853N/A gbc.gridy ++;
4180N/A gbc.weighty = 1.0;
4180N/A JScrollPane scroll = Utilities.createBorderLessScrollBar(inScrollPanel);
3853N/A gbc.insets = new Insets(0, 0, 0, 0);
4180N/A add(scroll, gbc);
4180N/A ScrollPaneBorderListener.createFullBorderListener(scroll);
3853N/A
4180N/A gbc.gridy = 0;
4180N/A gbc.gridx = 0;
4180N/A gbc.fill = GridBagConstraints.HORIZONTAL;
4180N/A gbc.weightx = 1.0;
4180N/A gbc.insets = new Insets(15, 10, 0, 10);
4180N/A gbc.weighty = 0.0;
4180N/A inScrollPanel.add(createServerStatusPanel(), gbc);
3853N/A
3853N/A gbc.gridy ++;
4180N/A inScrollPanel.add(createServerDetailsPanel(), gbc);
3853N/A
4180N/A// To compensate titled border.
4180N/A gbc.insets.left += 3;
4180N/A gbc.insets.right += 3;
4180N/A gbc.gridy ++;
4180N/A inScrollPanel.add(createListenersPanel(), gbc);
3853N/A
3853N/A gbc.gridy ++;
4180N/A gbc.insets.bottom = 20;
4180N/A inScrollPanel.add(createBackendsPanel(), gbc);
4180N/A
4180N/A gbc.gridy ++;
4180N/A gbc.weighty = 1.0;
4180N/A gbc.insets = new Insets(0, 0, 0, 0);
4180N/A gbc.fill = GridBagConstraints.VERTICAL;
4180N/A inScrollPanel.add(Box.createVerticalGlue(), gbc);
3853N/A }
3853N/A
3853N/A /**
3853N/A * {@inheritDoc}
3853N/A */
3853N/A public Component getPreferredFocusComponent()
3853N/A {
4180N/A if (startButton.isVisible())
3853N/A {
3853N/A return startButton;
3853N/A }
3853N/A else
3853N/A {
3853N/A return stopButton;
3853N/A }
3853N/A }
3853N/A
4180N/A
4180N/A /**
4180N/A * {@inheritDoc}
4180N/A */
4180N/A public boolean requiresBorder()
4180N/A {
4180N/A return false;
4180N/A }
4180N/A
3853N/A private void recalculateSizes()
3853N/A {
3853N/A Utilities.updateTableSizes(replicationBaseDNsTable);
3853N/A Utilities.updateTableSizes(noReplicatedBaseDNsTable);
3853N/A Utilities.updateTableSizes(connectionHandlersTable);
3853N/A }
3853N/A
3853N/A /**
3853N/A * {@inheritDoc}
3853N/A */
3853N/A public Message getTitle()
3853N/A {
3853N/A return INFO_CTRL_PANEL_STATUS_PANEL_TITLE.get();
3853N/A }
3853N/A
3853N/A /**
3853N/A * {@inheritDoc}
3853N/A */
3853N/A public void configurationChanged(final ConfigurationChangeEvent ev)
3853N/A {
3853N/A if (SwingUtilities.isEventDispatchThread())
3853N/A {
3853N/A updateContents(ev.getNewDescriptor());
3853N/A }
3853N/A else
3853N/A {
3853N/A SwingUtilities.invokeLater(new Runnable()
3853N/A {
3853N/A /**
3853N/A * {@inheritDoc}
3853N/A */
3853N/A public void run()
3853N/A {
3853N/A updateContents(ev.getNewDescriptor());
3853N/A }
3853N/A });
3853N/A }
3853N/A }
3853N/A
3853N/A /**
3853N/A * {@inheritDoc}
3853N/A */
3853N/A public void okClicked()
3853N/A {
3853N/A }
3853N/A
3853N/A /**
3853N/A * Updates the contents of the panel with the provided ServerDescriptor.
3853N/A * @param desc the ServerDescriptor.
3853N/A */
3853N/A public void updateContents(ServerDescriptor desc)
3853N/A {
4131N/A JScrollPane scroll = Utilities.getContainingScroll(this);
4131N/A ViewPositions pos;
4131N/A if (scroll != null)
4131N/A {
4131N/A pos = Utilities.getViewPositions(scroll);
4131N/A }
4131N/A else
4131N/A {
4131N/A pos = Utilities.getViewPositions(this);
4131N/A }
4131N/A
3853N/A Collection<OpenDsException> exceptions = desc.getExceptions();
3853N/A if (exceptions.size() == 0)
3853N/A {
4180N/A boolean errorPaneVisible = false;
4180N/A if (desc.getStatus() == ServerDescriptor.ServerStatus.STARTED)
4180N/A {
4180N/A if (!desc.isAuthenticated())
4180N/A {
4180N/A errorPaneVisible = true;
4180N/A MessageBuilder mb = new MessageBuilder();
4180N/A mb.append(
4180N/A INFO_CTRL_PANEL_AUTH_REQUIRED_TO_BROWSE_MONITORING_SUMMARY.
4180N/A get());
4180N/A mb.append("<br><br>"+getAuthenticateHTML());
4180N/A Message title =
4180N/A INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_SUMMARY.get();
4180N/A updateErrorPane(errorPane, title,
4180N/A ColorAndFontConstants.errorTitleFont,
4180N/A mb.toMessage(), ColorAndFontConstants.defaultFont);
4180N/A }
4180N/A }
4500N/A else if (desc.getStatus() ==
4500N/A ServerDescriptor.ServerStatus.NOT_CONNECTED_TO_REMOTE)
4500N/A {
4500N/A errorPaneVisible = true;
4500N/A MessageBuilder mb = new MessageBuilder();
4500N/A mb.append(INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(
4500N/A desc.getHostname()));
4500N/A mb.append("<br><br>"+getAuthenticateHTML());
4500N/A Message title =
4500N/A INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_SUMMARY.get();
4500N/A updateErrorPane(errorPane, title,
4500N/A ColorAndFontConstants.errorTitleFont,
4500N/A mb.toMessage(), ColorAndFontConstants.defaultFont);
4500N/A }
4180N/A if (errorPane.isVisible() != errorPaneVisible)
4180N/A {
4180N/A errorPane.setVisible(errorPaneVisible);
4180N/A }
3853N/A }
3853N/A else
3853N/A {
3853N/A ArrayList<Message> msgs = new ArrayList<Message>();
3853N/A for (OpenDsException oe : exceptions)
3853N/A {
3853N/A msgs.add(oe.getMessageObject());
3853N/A }
3853N/A Message title = ERR_CTRL_PANEL_ERROR_READING_CONFIGURATION_SUMMARY.get();
3853N/A MessageBuilder mb = new MessageBuilder();
3853N/A for (Message error : msgs)
3853N/A {
3853N/A if (mb.length() > 0)
3853N/A {
3853N/A mb.append("<br>");
3853N/A }
3853N/A mb.append(error);
3853N/A }
4180N/A if (desc.getStatus() == ServerDescriptor.ServerStatus.STARTED)
4180N/A {
4180N/A if (!desc.isAuthenticated())
4180N/A {
4500N/A mb.append("<br>");
4180N/A mb.append(
4180N/A INFO_CTRL_PANEL_AUTH_REQUIRED_TO_BROWSE_MONITORING_SUMMARY.
4180N/A get());
4180N/A mb.append("<br><br>"+getAuthenticateHTML());
4180N/A }
4180N/A }
4613N/A else if (desc.getStatus() ==
4613N/A ServerDescriptor.ServerStatus.NOT_CONNECTED_TO_REMOTE)
4500N/A {
4500N/A mb.append("<br>");
4500N/A mb.append(INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(
4500N/A desc.getHostname()));
4500N/A mb.append("<br><br>"+getAuthenticateHTML());
4500N/A }
3853N/A updateErrorPane(errorPane, title, ColorAndFontConstants.errorTitleFont,
3853N/A mb.toMessage(), ColorAndFontConstants.defaultFont);
3853N/A
3853N/A if (!errorPane.isVisible())
3853N/A {
3853N/A errorPane.setVisible(true);
3853N/A }
3853N/A }
3853N/A
5067N/A setText(serverStatus, getStatusLabel(desc));
3853N/A
3853N/A boolean isRunning = desc.getStatus() ==
3853N/A ServerDescriptor.ServerStatus.STARTED;
3853N/A boolean isAuthenticated = desc.isAuthenticated();
4500N/A boolean isLocal = desc.isLocal();
3853N/A
3853N/A startButton.setVisible(desc.getStatus() ==
4500N/A ServerDescriptor.ServerStatus.STOPPED && isLocal);
4500N/A restartButton.setVisible(isRunning && isLocal);
4500N/A stopButton.setVisible(isRunning && isLocal);
3853N/A
3853N/A if (!isRunning)
3853N/A {
4500N/A if (isLocal)
4500N/A {
4500N/A Utilities.setNotAvailableBecauseServerIsDown(currentConnections);
4500N/A }
4500N/A else
4500N/A {
4500N/A Utilities.setTextValue(currentConnections,
4500N/A INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString());
4500N/A }
3853N/A }
3853N/A else if (!isAuthenticated)
3853N/A {
3853N/A Utilities.setNotAvailableBecauseAuthenticationIsRequired(
3853N/A currentConnections);
3853N/A }
3853N/A else
3853N/A {
3853N/A int nConnections = desc.getOpenConnections();
3853N/A if (nConnections >= 0)
3853N/A {
3853N/A Utilities.setTextValue(currentConnections,
3853N/A String.valueOf(nConnections));
3853N/A }
3853N/A else
3853N/A {
3853N/A Utilities.setNotAvailable(currentConnections);
3853N/A }
3853N/A }
3853N/A
5067N/A setText(hostName, desc.getHostname());
3853N/A
3853N/A Set<DN> rootUsers = desc.getAdministrativeUsers();
3853N/A
3853N/A SortedSet<String> sortedRootUsers = new TreeSet<String>();
3853N/A for (DN dn : rootUsers)
3853N/A {
3853N/A try
3853N/A {
3853N/A sortedRootUsers.add(Utilities.unescapeUtf8(dn.toString()));
3853N/A }
3853N/A catch (Throwable t)
3853N/A {
4676N/A throw new RuntimeException("Unexpected error: "+t, t);
3853N/A }
3853N/A }
3853N/A
4500N/A if (rootUsers.size() > 0)
4500N/A {
5067N/A setText(administrativeUsers,
5067N/A Utilities.getStringFromCollection(sortedRootUsers, "<br>"));
4500N/A }
4500N/A else
4500N/A {
5067N/A setText(administrativeUsers,
4500N/A INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString());
4500N/A }
4803N/A String install = desc.getInstallPath();
4500N/A if (install != null)
4500N/A {
5067N/A setText(installPath, install);
4500N/A }
4500N/A else
4500N/A {
5067N/A setText(installPath, INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString());
4500N/A }
4060N/A
4803N/A String instance = desc.getInstancePath();
4060N/A
4500N/A if (instance != null)
4500N/A {
5067N/A setText(instancePath, instance);
4500N/A }
4500N/A else
4500N/A {
5067N/A setText(instancePath, INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString());
4500N/A }
4060N/A
4803N/A instancePath.setVisible(!desc.sameInstallAndInstance());
4803N/A lInstancePath.setVisible(!desc.sameInstallAndInstance());
3853N/A
4500N/A if (desc.getOpenDSVersion() != null)
4500N/A {
5067N/A setText(opendsVersion, desc.getOpenDSVersion());
4500N/A }
4500N/A else
4500N/A {
5067N/A setText(opendsVersion, INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString());
4500N/A }
3853N/A
3853N/A if (!isRunning)
3853N/A {
4500N/A if (isLocal)
4500N/A {
4500N/A Utilities.setNotAvailableBecauseServerIsDown(javaVersion);
4500N/A }
4500N/A else
4500N/A {
4500N/A Utilities.setTextValue(javaVersion,
4500N/A INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString());
4500N/A }
3853N/A }
3853N/A else if (!isAuthenticated)
3853N/A {
3853N/A Utilities.setNotAvailableBecauseAuthenticationIsRequired(javaVersion);
3853N/A }
3853N/A else
3853N/A {
3853N/A String jVersion = desc.getJavaVersion();
3853N/A if (jVersion != null)
3853N/A {
3853N/A Utilities.setTextValue(javaVersion, jVersion);
3853N/A }
3853N/A else
3853N/A {
3853N/A Utilities.setNotAvailable(javaVersion);
3853N/A }
3853N/A }
3853N/A
5067N/A setText(adminConnector,
3853N/A getAdminConnectorStringValue(desc.getAdminConnector()));
3853N/A
3853N/A Set<BaseDNDescriptor> baseDNs = new HashSet<BaseDNDescriptor>();
3853N/A
3853N/A for (BackendDescriptor backend : desc.getBackends())
3853N/A {
3853N/A if (!backend.isConfigBackend())
3853N/A {
3853N/A baseDNs.addAll(backend.getBaseDns());
3853N/A }
3853N/A }
3853N/A
3853N/A boolean oneReplicated = false;
3853N/A for (BaseDNDescriptor baseDN : baseDNs)
3853N/A {
3853N/A if (baseDN.getType() == BaseDNDescriptor.Type.REPLICATED)
3853N/A {
3853N/A oneReplicated = true;
3853N/A break;
3853N/A }
3853N/A }
3853N/A
3853N/A boolean hasBaseDNs = baseDNs.size() > 0;
3853N/A
3853N/A replicationBaseDNsTable.setVisible(oneReplicated && hasBaseDNs);
3853N/A replicationBaseDNsTable.getTableHeader().setVisible(
3853N/A oneReplicated && hasBaseDNs);
3853N/A noReplicatedBaseDNsTable.setVisible(!oneReplicated && hasBaseDNs);
3853N/A noReplicatedBaseDNsTable.getTableHeader().setVisible(
3853N/A !oneReplicated && hasBaseDNs);
3853N/A dbTableEmpty.setVisible(!hasBaseDNs);
3853N/A
3853N/A dbTableModelWithReplication.setData(baseDNs, desc.getStatus(),
3853N/A desc.isAuthenticated());
3853N/A dbTableModelWithoutReplication.setData(baseDNs, desc.getStatus(),
3853N/A desc.isAuthenticated());
3853N/A
3853N/A Set<ConnectionHandlerDescriptor> connectionHandlers =
3853N/A desc.getConnectionHandlers();
3853N/A connectionHandlerTableModel.setData(connectionHandlers);
3853N/A
3853N/A boolean hasConnectionHandlers = connectionHandlers.size() > 0;
3853N/A connectionHandlersTable.setVisible(hasConnectionHandlers);
3853N/A connectionHandlersTable.getTableHeader().setVisible(hasConnectionHandlers);
3853N/A connectionHandlerTableEmpty.setVisible(!hasConnectionHandlers);
3853N/A
3853N/A recalculateSizes();
4131N/A
4131N/A Utilities.updateViewPositions(pos);
3853N/A }
3853N/A
5067N/A private void setText(JEditorPane pane, String htmlText)
5067N/A {
5067N/A pane.setText(Utilities.applyFont(htmlText,
5067N/A ColorAndFontConstants.defaultFont));
5067N/A }
5067N/A
3853N/A /**
3853N/A * Creates the server status subsection panel.
3853N/A * @return the server status subsection panel.
3853N/A */
3853N/A private JPanel createServerStatusPanel()
3853N/A {
3853N/A JPanel p = new JPanel(new GridBagLayout());
3853N/A p.setOpaque(false);
3853N/A GridBagConstraints gbc = new GridBagConstraints();
3853N/A gbc.gridwidth = GridBagConstraints.REMAINDER;
3853N/A gbc.weightx = 1.0;
3853N/A gbc.insets = new Insets(0, 0, 0, 0);
3853N/A
5067N/A setTitleBorder(p, INFO_CTRL_PANEL_SERVER_STATUS_TITLE_BORDER.get());
3853N/A JPanel auxPanel = new JPanel(new GridBagLayout());
3853N/A auxPanel.setOpaque(false);
3853N/A gbc.anchor = GridBagConstraints.WEST;
3853N/A gbc.gridwidth = GridBagConstraints.RELATIVE;
3853N/A JLabel l = Utilities.createPrimaryLabel(
3853N/A INFO_CTRL_PANEL_SERVER_STATUS_LABEL.get());
3853N/A auxPanel.add(l, gbc);
3853N/A
3853N/A JPanel statusPanel = new JPanel(new GridBagLayout());
3853N/A statusPanel.setOpaque(false);
3853N/A gbc.gridwidth = 6;
3853N/A gbc.weightx = 0.0;
5067N/A serverStatus = Utilities.makeHtmlPane("",
5067N/A ColorAndFontConstants.defaultFont);
3853N/A statusPanel.add(serverStatus, gbc);
5067N/A //l.setFocusable(true);
5067N/A l.setLabelFor(serverStatus);
3853N/A gbc.gridwidth--;
3853N/A
3853N/A stopButton = Utilities.createButton(INFO_STOP_BUTTON_LABEL.get());
3853N/A stopButton.setOpaque(false);
3853N/A stopButton.addActionListener(new ActionListener()
3853N/A {
3853N/A /**
3853N/A * {@inheritDoc}
3853N/A */
3853N/A public void actionPerformed(ActionEvent ev)
3853N/A {
3853N/A stopServer();
3853N/A }
3853N/A });
3853N/A gbc.insets.left = 10;
3853N/A statusPanel.add(stopButton, gbc);
3853N/A
3853N/A gbc.gridwidth--;
3853N/A gbc.insets.left = 10;
3853N/A startButton = Utilities.createButton(INFO_START_BUTTON_LABEL.get());
3853N/A startButton.setOpaque(false);
3853N/A statusPanel.add(startButton, gbc);
3853N/A startButton.addActionListener(new ActionListener()
3853N/A {
3853N/A /**
3853N/A * {@inheritDoc}
3853N/A */
3853N/A public void actionPerformed(ActionEvent ev)
3853N/A {
3853N/A startServer();
3853N/A }
3853N/A });
3853N/A
3853N/A gbc.gridwidth--;
3853N/A gbc.insets.left = 5;
3853N/A restartButton = Utilities.createButton(INFO_RESTART_BUTTON_LABEL.get());
3853N/A restartButton.setOpaque(false);
3853N/A restartButton.addActionListener(new ActionListener()
3853N/A {
3853N/A /**
3853N/A * {@inheritDoc}
3853N/A */
3853N/A public void actionPerformed(ActionEvent ev)
3853N/A {
3853N/A restartServer();
3853N/A }
3853N/A });
3853N/A statusPanel.add(restartButton, gbc);
3853N/A
3853N/A gbc.gridwidth = GridBagConstraints.RELATIVE;
3853N/A gbc.weightx = 1.0;
3853N/A gbc.insets.left = 0;
3853N/A statusPanel.add(Box.createHorizontalGlue(), gbc);
3853N/A
3853N/A int maxButtonHeight = 0;
3853N/A maxButtonHeight = Math.max(maxButtonHeight,
3853N/A (int)startButton.getPreferredSize().getHeight());
3853N/A maxButtonHeight = Math.max(maxButtonHeight,
3853N/A (int)restartButton.getPreferredSize().getHeight());
3853N/A maxButtonHeight = Math.max(maxButtonHeight,
3853N/A (int)stopButton.getPreferredSize().getHeight());
3853N/A
3853N/A gbc.gridwidth = GridBagConstraints.REMAINDER;
3853N/A gbc.weightx = 0.0;
3853N/A statusPanel.add(Box.createVerticalStrut(maxButtonHeight), gbc);
3853N/A
3853N/A gbc.weightx = 1.0;
3853N/A gbc.insets.left = 5;
3853N/A auxPanel.add(statusPanel, gbc);
3853N/A
3853N/A gbc.insets.left = 0;
3853N/A gbc.weightx = 0.0;
3853N/A gbc.insets.top = 5;
3853N/A gbc.gridwidth = GridBagConstraints.RELATIVE;
3853N/A l = Utilities.createPrimaryLabel(
3853N/A INFO_CTRL_PANEL_OPEN_CONNECTIONS_LABEL.get());
3853N/A auxPanel.add(l, gbc);
5067N/A currentConnections = new SelectableLabelWithHelpIcon(Message.EMPTY, null);
3853N/A
3853N/A gbc.gridwidth = GridBagConstraints.REMAINDER;
3853N/A gbc.insets.left = 5;
3853N/A auxPanel.add(currentConnections, gbc);
3853N/A
5067N/A l.setFocusable(true);
5067N/A l.setLabelFor(currentConnections);
5067N/A
3853N/A gbc.insets.top = 2;
3853N/A gbc.insets.right = 5;
3853N/A gbc.insets.left = 5;
3853N/A gbc.insets.bottom = 5;
3853N/A gbc.gridwidth = GridBagConstraints.REMAINDER;
3853N/A gbc.weightx = 1.0;
3853N/A p.add(auxPanel, gbc);
3853N/A
3853N/A restartButton.setVisible(false);
3853N/A stopButton.setVisible(false);
3853N/A return p;
3853N/A }
3853N/A
3853N/A
3853N/A /**
3853N/A * Creates the server details subsection panel.
3853N/A * @return the server details subsection panel.
3853N/A */
3853N/A private JPanel createServerDetailsPanel()
3853N/A {
3853N/A JPanel p = new JPanel(new GridBagLayout());
3853N/A p.setOpaque(false);
3853N/A GridBagConstraints gbc = new GridBagConstraints();
3853N/A gbc.insets = new Insets(0, 0, 0, 0);
3853N/A gbc.gridwidth = GridBagConstraints.REMAINDER;
3853N/A gbc.weightx = 1.0;
3853N/A
5067N/A setTitleBorder(p, INFO_CTRL_PANEL_SERVER_DETAILS_TITLE_BORDER.get());
3853N/A JPanel auxPanel = new JPanel(new GridBagLayout());
3853N/A auxPanel.setOpaque(false);
3853N/A gbc.anchor = GridBagConstraints.NORTHWEST;
3853N/A gbc.weightx = 0.0;
3853N/A JLabel[] leftLabels =
3853N/A {
3853N/A Utilities.createPrimaryLabel(
3853N/A INFO_CTRL_PANEL_HOST_NAME_LABEL.get()),
3853N/A Utilities.createPrimaryLabel(
3853N/A INFO_CTRL_PANEL_ADMINISTRATIVE_USERS_LABEL.get()),
3853N/A Utilities.createPrimaryLabel(
3853N/A INFO_CTRL_PANEL_INSTALLATION_PATH_LABEL.get()),
3853N/A Utilities.createPrimaryLabel(
4060N/A INFO_CTRL_PANEL_INSTANCE_PATH_LABEL.get()),
4060N/A Utilities.createPrimaryLabel(
3853N/A INFO_CTRL_PANEL_OPENDS_VERSION_LABEL.get()),
3853N/A Utilities.createPrimaryLabel(
3853N/A INFO_CTRL_PANEL_JAVA_VERSION_LABEL.get()),
3853N/A Utilities.createPrimaryLabel(
3853N/A INFO_CTRL_PANEL_ADMIN_CONNECTOR_LABEL.get())
3853N/A };
4060N/A lInstancePath = leftLabels[3];
3853N/A
5067N/A hostName = Utilities.makeHtmlPane("",
5067N/A ColorAndFontConstants.defaultFont);
5067N/A administrativeUsers = Utilities.makeHtmlPane("",
5067N/A ColorAndFontConstants.defaultFont);
5067N/A installPath = Utilities.makeHtmlPane("",
5067N/A ColorAndFontConstants.defaultFont);
5067N/A instancePath = Utilities.makeHtmlPane("",
5067N/A ColorAndFontConstants.defaultFont);
5067N/A opendsVersion = Utilities.makeHtmlPane("",
5067N/A ColorAndFontConstants.defaultFont);
5067N/A javaVersion = new SelectableLabelWithHelpIcon(Message.EMPTY, null);
5067N/A adminConnector = Utilities.makeHtmlPane("",
5067N/A ColorAndFontConstants.defaultFont);
3853N/A
3853N/A JComponent[] rightLabels =
3853N/A {
4060N/A hostName, administrativeUsers, installPath, instancePath, opendsVersion,
3853N/A javaVersion, adminConnector
3853N/A };
3853N/A
3853N/A
3853N/A for (int i=0; i<leftLabels.length; i++)
3853N/A {
3853N/A gbc.insets.left = 0;
3853N/A if (i != 0)
3853N/A {
4500N/A gbc.insets.top = 10;
3853N/A }
3853N/A gbc.gridwidth = GridBagConstraints.RELATIVE;
3853N/A auxPanel.add(leftLabels[i], gbc);
3853N/A
3853N/A gbc.gridwidth = GridBagConstraints.REMAINDER;
3853N/A gbc.insets.left = 5;
3853N/A auxPanel.add(rightLabels[i], gbc);
5067N/A
5067N/A leftLabels[i].setLabelFor(rightLabels[i]);
3853N/A }
3853N/A
3853N/A gbc.insets.top = 2;
3853N/A gbc.insets.right = 5;
3853N/A gbc.insets.left = 5;
3853N/A gbc.insets.bottom = 5;
3853N/A gbc.gridwidth = GridBagConstraints.REMAINDER;
3853N/A gbc.weightx = 1.0;
3853N/A p.add(auxPanel, gbc);
3853N/A
3853N/A return p;
3853N/A }
3853N/A
3853N/A /**
3853N/A * Creates the server listeners subsection panel.
3853N/A * @return the server listeners subsection panel.
3853N/A */
3853N/A private JPanel createListenersPanel()
3853N/A {
3853N/A JPanel p = new JPanel(new GridBagLayout());
3853N/A p.setOpaque(false);
3853N/A GridBagConstraints gbc = new GridBagConstraints();
3853N/A gbc.insets = new Insets(0, 0, 0, 0);
3853N/A gbc.gridwidth = GridBagConstraints.REMAINDER;
3853N/A gbc.weightx = 1.0;
3853N/A gbc.anchor = GridBagConstraints.WEST;
3853N/A gbc.fill = GridBagConstraints.HORIZONTAL;
3853N/A
3853N/A JLabel l = Utilities.createTitleLabel(
3853N/A INFO_CTRL_PANEL_CONNECTION_HANDLERS.get());
3853N/A p.add(l, gbc);
3853N/A
3853N/A connectionHandlerTableModel = new ConnectionHandlerTableModel();
3853N/A connectionHandlersTable =
3853N/A Utilities.createSortableTable(connectionHandlerTableModel,
3853N/A new CustomCellRenderer());
4612N/A connectionHandlersTable.setCellSelectionEnabled(false);
3853N/A
3853N/A gbc.insets.top = 5;
3853N/A p.add(connectionHandlersTable.getTableHeader(), gbc);
3853N/A gbc.insets.top = 0;
3853N/A p.add(connectionHandlersTable, gbc);
3853N/A
3853N/A connectionHandlerTableEmpty =
5067N/A Utilities.makeHtmlPane(
5067N/A INFO_CTRL_PANEL_NO_CONNECTION_HANDLER_FOUND.get().toString(),
5067N/A ColorAndFontConstants.primaryFont);
3853N/A gbc.insets.top = 5;
5067N/A gbc.anchor = GridBagConstraints.CENTER;
5067N/A gbc.fill = GridBagConstraints.NONE;
3853N/A p.add(connectionHandlerTableEmpty, gbc);
3853N/A connectionHandlerTableEmpty.setVisible(false);
3853N/A
5067N/A l.setLabelFor(connectionHandlersTable);
5067N/A
3853N/A return p;
3853N/A }
3853N/A
3853N/A /**
3853N/A * Creates the server backends subsection panel.
3853N/A * @return the server backends subsection panel.
3853N/A */
3853N/A private JPanel createBackendsPanel()
3853N/A {
3853N/A JPanel p = new JPanel(new GridBagLayout());
3853N/A p.setOpaque(false);
3853N/A GridBagConstraints gbc = new GridBagConstraints();
3853N/A gbc.insets = new Insets(0, 0, 0, 0);
3853N/A gbc.gridwidth = GridBagConstraints.REMAINDER;
3853N/A gbc.weightx = 1.0;
3853N/A gbc.anchor = GridBagConstraints.WEST;
3853N/A gbc.fill = GridBagConstraints.HORIZONTAL;
3853N/A
3853N/A JLabel l = Utilities.createTitleLabel(INFO_CTRL_PANEL_DATA_SOURCES.get());
3853N/A p.add(l, gbc);
3853N/A
3853N/A dbTableModelWithReplication = new BaseDNTableModel(true);
3853N/A dbTableModelWithoutReplication = new BaseDNTableModel(false);
4612N/A BaseDNCellRenderer renderer = new BaseDNCellRenderer();
3853N/A noReplicatedBaseDNsTable =
3853N/A Utilities.createSortableTable(dbTableModelWithoutReplication,
4612N/A renderer);
3853N/A noReplicatedBaseDNsTable.setVisible(false);
3853N/A noReplicatedBaseDNsTable.getTableHeader().setVisible(false);
5067N/A
3853N/A replicationBaseDNsTable =
3853N/A Utilities.createSortableTable(dbTableModelWithReplication,
4612N/A renderer);
4612N/A noReplicatedBaseDNsTable.setCellSelectionEnabled(false);
4612N/A replicationBaseDNsTable.setCellSelectionEnabled(false);
4612N/A Utilities.addClickTooltipListener(noReplicatedBaseDNsTable);
4612N/A Utilities.addClickTooltipListener(replicationBaseDNsTable);
3853N/A
5067N/A l.setLabelFor(replicationBaseDNsTable);
5067N/A
5067N/A noReplicatedBaseDNsTable.getAccessibleContext().setAccessibleName(
5067N/A l.getText());
5067N/A replicationBaseDNsTable.getAccessibleContext().setAccessibleName(
5067N/A l.getText());
5067N/A
3853N/A gbc.insets.top = 5;
3853N/A p.add(noReplicatedBaseDNsTable.getTableHeader(), gbc);
3853N/A gbc.insets.top = 0;
3853N/A p.add(noReplicatedBaseDNsTable, gbc);
3853N/A
3853N/A gbc.insets.top = 5;
3853N/A p.add(replicationBaseDNsTable.getTableHeader(), gbc);
3853N/A gbc.insets.top = 0;
3853N/A p.add(replicationBaseDNsTable, gbc);
3853N/A replicationBaseDNsTable.setVisible(true);
3853N/A replicationBaseDNsTable.getTableHeader().setVisible(true);
3853N/A
3853N/A gbc.insets.top = 5;
5067N/A dbTableEmpty = Utilities.makeHtmlPane(
5067N/A INFO_CTRL_PANEL_NO_DATA_SOURCES_FOUND.get().toString(),
5067N/A ColorAndFontConstants.primaryFont);
5067N/A gbc.fill = GridBagConstraints.NONE;
3853N/A gbc.anchor = GridBagConstraints.CENTER;
3853N/A p.add(dbTableEmpty, gbc);
3853N/A dbTableEmpty.setVisible(false);
3853N/A return p;
3853N/A }
3853N/A
3853N/A /**
3853N/A * Returns an string representation of the administration connector.
3853N/A * @param adminConnector the administration connector.
3853N/A * @return an string representation of the administration connector.
3853N/A */
3853N/A private static String getAdminConnectorStringValue(
3853N/A ConnectionHandlerDescriptor adminConnector)
3853N/A {
3853N/A if (adminConnector != null)
3853N/A {
3853N/A return INFO_CTRL_PANEL_ADMIN_CONNECTOR_DESCRIPTION.get(
3853N/A adminConnector.getPort()).toString();
3853N/A }
3853N/A else
3853N/A {
3853N/A return INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString();
3853N/A }
3853N/A }
4500N/A
4500N/A private String getStatusLabel(ServerDescriptor desc)
4500N/A {
4500N/A Message status;
4500N/A switch (desc.getStatus())
4500N/A {
4500N/A case STARTED:
4500N/A status = INFO_SERVER_STARTED_LABEL.get();
4500N/A break;
4500N/A
4500N/A case STOPPED:
4500N/A status = INFO_SERVER_STOPPED_LABEL.get();
4500N/A break;
4500N/A
4500N/A case STARTING:
4500N/A status = INFO_SERVER_STARTING_LABEL.get();
4500N/A break;
4500N/A
4500N/A case STOPPING:
4500N/A status = INFO_SERVER_STOPPING_LABEL.get();
4500N/A break;
4500N/A
4500N/A case NOT_CONNECTED_TO_REMOTE:
4500N/A status = INFO_SERVER_NOT_CONNECTED_TO_REMOTE_STATUS_LABEL.get();
4500N/A break;
4500N/A
4500N/A case UNKNOWN:
4500N/A status = INFO_SERVER_UNKNOWN_STATUS_LABEL.get();
4500N/A break;
4500N/A
4500N/A default:
4676N/A throw new RuntimeException("Unknown status: "+desc.getStatus());
4500N/A }
4500N/A return status.toString();
4500N/A }
5067N/A
5067N/A private void setTitleBorder(JPanel p, Message title)
5067N/A {
5067N/A p.setBorder(Utilities.makeTitledBorder(title));
5067N/A p.getAccessibleContext().setAccessibleName(title.toString());
5067N/A }
3853N/A}