| | |
| | | import javax.swing.table.TableCellRenderer; |
| | | import javax.swing.table.TableColumn; |
| | | |
| | | import org.opends.guitools.i18n.ResourceProvider; |
| | | import org.opends.guitools.statuspanel.BaseDNDescriptor; |
| | | import org.opends.guitools.statuspanel.DatabaseDescriptor; |
| | | import org.opends.guitools.statuspanel.ServerStatusDescriptor; |
| | |
| | | import org.opends.quicksetup.util.HtmlProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.Utils; |
| | | |
| | | import org.opends.messages.Message; |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | |
| | | /** |
| | | * This panel is used to display basic information about the server status. |
| | |
| | | |
| | | private InstantaneousToolTipManager toolTipManager; |
| | | |
| | | private final String NOT_AVAILABLE = getMsg("not-available-label"); |
| | | private final Message NOT_AVAILABLE = INFO_NOT_AVAILABLE_LABEL.get(); |
| | | |
| | | /** |
| | | * ProgressDialog constructor. |
| | |
| | | public StatusPanelDialog() |
| | | { |
| | | super(); |
| | | setTitle(getMsg("statuspanel-dialog-title")); |
| | | setTitle(INFO_STATUSPANEL_DIALOG_TITLE.get().toString()); |
| | | createLayout(); |
| | | |
| | | addWindowListener(new WindowAdapter() |
| | |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | |
| | | gbc.insets.bottom = UIFactory.BOTTOM_INSET_PROGRESS_BAR; |
| | | lError = UIFactory.makeHtmlPane("", UIFactory.PROGRESS_FONT); |
| | | lError = UIFactory.makeHtmlPane(Message.EMPTY, UIFactory.PROGRESS_FONT); |
| | | lError.setOpaque(false); |
| | | lError.setEditable(false); |
| | | inputPanel.add(lError, gbc); |
| | |
| | | buttonsPanel.add(Box.createHorizontalGlue(), gbc); |
| | | |
| | | authenticateButton = |
| | | UIFactory.makeJButton(getMsg("authenticate-button-label"), |
| | | getMsg("authenticate-status-panel-button-tooltip")); |
| | | UIFactory.makeJButton(INFO_AUTHENTICATE_BUTTON_LABEL.get(), |
| | | INFO_AUTHENTICATE_STATUS_PANEL_BUTTON_TOOLTIP.get()); |
| | | gbc.fill = GridBagConstraints.NONE; |
| | | gbc.weightx = 0.0; |
| | | gbc.gridwidth = GridBagConstraints.RELATIVE; |
| | |
| | | }); |
| | | |
| | | quitButton = |
| | | UIFactory.makeJButton(getMsg("quit-button-label"), |
| | | getMsg("quit-status-panel-button-tooltip")); |
| | | UIFactory.makeJButton(INFO_QUIT_BUTTON_LABEL.get(), |
| | | INFO_QUIT_STATUS_PANEL_BUTTON_TOOLTIP.get()); |
| | | gbc.fill = GridBagConstraints.NONE; |
| | | gbc.weightx = 0.0; |
| | | gbc.gridwidth = GridBagConstraints.REMAINDER; |
| | |
| | | * surrounding the text. |
| | | * @param title the title of the subsection. |
| | | */ |
| | | private JPanel createSubsectionTitle(String title) |
| | | private JPanel createSubsectionTitle(Message title) |
| | | { |
| | | JPanel p = new JPanel(new GridBagLayout()); |
| | | p.setOpaque(false); |
| | |
| | | gbc.weightx = 1.0; |
| | | gbc.insets = UIFactory.getEmptyInsets(); |
| | | |
| | | p.add(createSubsectionTitle(getMsg("server-status-title")), gbc); |
| | | p.add(createSubsectionTitle(INFO_SERVER_STATUS_TITLE.get()), gbc); |
| | | |
| | | JPanel auxPanel = new JPanel(new GridBagLayout()); |
| | | auxPanel.setOpaque(false); |
| | | gbc.anchor = GridBagConstraints.WEST; |
| | | gbc.gridwidth = GridBagConstraints.RELATIVE; |
| | | auxPanel.add(UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, |
| | | getMsg("server-status-label"), UIFactory.TextStyle.PRIMARY_FIELD_VALID), |
| | | INFO_SERVER_STATUS_LABEL.get(), |
| | | UIFactory.TextStyle.PRIMARY_FIELD_VALID), |
| | | gbc); |
| | | |
| | | JPanel statusPanel = new JPanel(new GridBagLayout()); |
| | |
| | | toolTipManager.registerComponent(lServerStatus); |
| | | gbc.gridwidth--; |
| | | |
| | | stopButton = UIFactory.makeJButton(getMsg("stop-button-label"), |
| | | getMsg("stop-button-tooltip")); |
| | | stopButton = UIFactory.makeJButton(INFO_STOP_BUTTON_LABEL.get(), |
| | | INFO_STOP_BUTTON_TOOLTIP.get()); |
| | | stopButton.addActionListener(new ActionListener() |
| | | { |
| | | public void actionPerformed(ActionEvent ev) |
| | |
| | | |
| | | gbc.gridwidth--; |
| | | gbc.insets.left = UIFactory.HORIZONTAL_INSET_BETWEEN_BUTTONS; |
| | | startButton = UIFactory.makeJButton(getMsg("start-button-label"), |
| | | getMsg("start-button-tooltip")); |
| | | startButton = UIFactory.makeJButton(INFO_START_BUTTON_LABEL.get(), |
| | | INFO_START_BUTTON_TOOLTIP.get()); |
| | | statusPanel.add(startButton, gbc); |
| | | startButton.addActionListener(new ActionListener() |
| | | { |
| | |
| | | }); |
| | | |
| | | gbc.gridwidth--; |
| | | restartButton = UIFactory.makeJButton(getMsg("restart-button-label"), |
| | | getMsg("restart-button-tooltip")); |
| | | restartButton = UIFactory.makeJButton(INFO_RESTART_BUTTON_LABEL.get(), |
| | | INFO_RESTART_BUTTON_TOOLTIP.get()); |
| | | restartButton.addActionListener(new ActionListener() |
| | | { |
| | | public void actionPerformed(ActionEvent ev) |
| | |
| | | gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; |
| | | gbc.gridwidth = GridBagConstraints.RELATIVE; |
| | | auxPanel.add(UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, |
| | | getMsg("connections-label"), UIFactory.TextStyle.PRIMARY_FIELD_VALID), |
| | | INFO_CONNECTIONS_LABEL.get(), UIFactory.TextStyle.PRIMARY_FIELD_VALID), |
| | | gbc); |
| | | lCurrentConnections = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, |
| | | NOT_AVAILABLE, UIFactory.TextStyle.READ_ONLY); |
| | |
| | | gbc.gridwidth = GridBagConstraints.REMAINDER; |
| | | gbc.weightx = 1.0; |
| | | |
| | | p.add(createSubsectionTitle(getMsg("server-details-title")), gbc); |
| | | p.add(createSubsectionTitle(INFO_SERVER_DETAILS_TITLE.get()), gbc); |
| | | |
| | | JPanel auxPanel = new JPanel(new GridBagLayout()); |
| | | auxPanel.setOpaque(false); |
| | |
| | | JLabel[] leftLabels = |
| | | { |
| | | UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, |
| | | getMsg("administrative-users-label"), |
| | | INFO_ADMINISTRATIVE_USERS_LABEL.get(), |
| | | UIFactory.TextStyle.PRIMARY_FIELD_VALID), |
| | | UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, |
| | | getMsg("installation-path-label"), |
| | | INFO_INSTALLATION_PATH_LABEL.get(), |
| | | UIFactory.TextStyle.PRIMARY_FIELD_VALID), |
| | | UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, |
| | | getMsg("opends-version-label"), |
| | | INFO_OPENDS_VERSION_LABEL.get(), |
| | | UIFactory.TextStyle.PRIMARY_FIELD_VALID), |
| | | UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, |
| | | getMsg("java-version-label"), |
| | | INFO_JAVA_VERSION_LABEL.get(), |
| | | UIFactory.TextStyle.PRIMARY_FIELD_VALID) |
| | | }; |
| | | |
| | |
| | | gbc.weightx = 1.0; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | |
| | | p.add(createSubsectionTitle(getMsg("listeners-title")), gbc); |
| | | p.add(createSubsectionTitle(INFO_LISTENERS_TITLE.get()), gbc); |
| | | |
| | | listenersTableModel = new ListenersTableModel(); |
| | | listenersTable = UIFactory.makeSortableTable(listenersTableModel, |
| | |
| | | gbc.insets.top = 0; |
| | | p.add(listenersTable, gbc); |
| | | |
| | | lListenersTableEmpty = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, "", |
| | | lListenersTableEmpty = UIFactory.makeJLabel( |
| | | UIFactory.IconType.NO_ICON, Message.EMPTY, |
| | | UIFactory.TextStyle.PRIMARY_FIELD_VALID); |
| | | gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; |
| | | p.add(lListenersTableEmpty, gbc); |
| | |
| | | gbc.weightx = 1.0; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | |
| | | p.add(createSubsectionTitle(getMsg("databases-title")), gbc); |
| | | p.add(createSubsectionTitle(INFO_DATABASES_TITLE.get()), gbc); |
| | | |
| | | dbTableModelWithReplication = new DatabasesTableModel(true); |
| | | dbTableModelWithoutReplication = new DatabasesTableModel(false); |
| | |
| | | dbTableWithoutReplication.setVisible(false); |
| | | |
| | | gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; |
| | | lDbTableEmpty = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, "", |
| | | UIFactory.TextStyle.PRIMARY_FIELD_VALID); |
| | | lDbTableEmpty = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, |
| | | Message.EMPTY, UIFactory.TextStyle.PRIMARY_FIELD_VALID); |
| | | p.add(lDbTableEmpty, gbc); |
| | | lDbTableEmpty.setVisible(false); |
| | | toolTipManager.registerComponent(lDbTableEmpty); |
| | |
| | | */ |
| | | private void setNotAvailableBecauseServerIsDown(JLabel l) |
| | | { |
| | | l.setText(NOT_AVAILABLE); |
| | | l.setText(NOT_AVAILABLE.toString()); |
| | | l.setIcon(UIFactory.getImageIcon(UIFactory.IconType.HELP_SMALL)); |
| | | l.setToolTipText(getMsg("not-available-server-down-tooltip")); |
| | | l.setToolTipText(INFO_NOT_AVAILABLE_SERVER_DOWN_TOOLTIP.get().toString()); |
| | | l.setHorizontalTextPosition(SwingConstants.LEFT); |
| | | } |
| | | |
| | |
| | | */ |
| | | private void setNotAvailableBecauseAuthenticationIsRequired(JLabel l) |
| | | { |
| | | l.setText(NOT_AVAILABLE); |
| | | l.setText(NOT_AVAILABLE.toString()); |
| | | l.setIcon(UIFactory.getImageIcon(UIFactory.IconType.HELP_SMALL)); |
| | | l.setToolTipText(getMsg("not-available-authentication-required-tooltip")); |
| | | l.setToolTipText( |
| | | INFO_NOT_AVAILABLE_AUTHENTICATION_REQUIRED_TOOLTIP.get() |
| | | .toString()); |
| | | l.setHorizontalTextPosition(SwingConstants.LEFT); |
| | | } |
| | | |
| | |
| | | */ |
| | | private void setNotAvailable(JLabel l) |
| | | { |
| | | l.setText(NOT_AVAILABLE); |
| | | l.setText(NOT_AVAILABLE.toString()); |
| | | l.setIcon(null); |
| | | l.setToolTipText(null); |
| | | } |
| | |
| | | */ |
| | | private void updateStatusContents(ServerStatusDescriptor desc) |
| | | { |
| | | String status; |
| | | Message status; |
| | | switch (desc.getStatus()) |
| | | { |
| | | case STARTED: |
| | | status = getMsg("server-started-label"); |
| | | status = INFO_SERVER_STARTED_LABEL.get(); |
| | | startButton.setVisible(false); |
| | | restartButton.setVisible(true); |
| | | stopButton.setVisible(true); |
| | | break; |
| | | |
| | | case STOPPED: |
| | | status = getMsg("server-stopped-label"); |
| | | status = INFO_SERVER_STOPPED_LABEL.get(); |
| | | startButton.setVisible(true); |
| | | restartButton.setVisible(false); |
| | | stopButton.setVisible(false); |
| | | break; |
| | | |
| | | case STARTING: |
| | | status = getMsg("server-starting-label"); |
| | | status = INFO_SERVER_STARTING_LABEL.get(); |
| | | startButton.setVisible(false); |
| | | restartButton.setVisible(false); |
| | | stopButton.setVisible(false); |
| | | break; |
| | | |
| | | case STOPPING: |
| | | status = getMsg("server-stopping-label"); |
| | | status = INFO_SERVER_STOPPING_LABEL.get(); |
| | | startButton.setVisible(false); |
| | | restartButton.setVisible(false); |
| | | stopButton.setVisible(false); |
| | | break; |
| | | |
| | | case UNKNOWN: |
| | | status = getMsg("server-unknown-status-label"); |
| | | status = INFO_SERVER_UNKNOWN_STATUS_LABEL.get(); |
| | | startButton.setVisible(false); |
| | | restartButton.setVisible(true); |
| | | stopButton.setVisible(true); |
| | |
| | | default: |
| | | throw new IllegalStateException("Unknown status: "+desc.getStatus()); |
| | | } |
| | | lServerStatus.setText(status); |
| | | lServerStatus.setText(status.toString()); |
| | | |
| | | /* Enable authenticate button only if the server is started AND we have |
| | | * no authentication (or the authentication we have does not seem to work |
| | |
| | | Set<String> administrators = desc.getAdministrativeUsers(); |
| | | if (administrators.size() > 0) |
| | | { |
| | | TreeSet<String> ordered = new TreeSet<String>(); |
| | | TreeSet<Message> ordered = new TreeSet<Message>(); |
| | | for (String name: administrators) |
| | | { |
| | | ordered.add(formatter.getFormattedText(name)); |
| | | ordered.add(formatter.getFormattedText(Message.raw(name))); |
| | | } |
| | | |
| | | setTextValue(lAdministrativeUsers,"<html>"+ |
| | | UIFactory.applyFontToHtml( |
| | | Utils.getStringFromCollection(ordered, "<br>"), |
| | | Utils.getMessageFromCollection(ordered, "<br>").toString(), |
| | | UIFactory.READ_ONLY_FONT)); |
| | | } |
| | | else |
| | |
| | | } |
| | | else |
| | | { |
| | | setTextValue(lListenersTableEmpty, getMsg("no-listeners-found")); |
| | | setTextValue(lListenersTableEmpty, |
| | | INFO_NO_LISTENERS_FOUND.get().toString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | setTextValue(lListenersTableEmpty, getMsg("no-listeners-found")); |
| | | setTextValue(lListenersTableEmpty, |
| | | INFO_NO_LISTENERS_FOUND.get().toString()); |
| | | } |
| | | } |
| | | else |
| | |
| | | } |
| | | else |
| | | { |
| | | setTextValue(lDbTableEmpty, getMsg("no-dbs-found")); |
| | | setTextValue(lDbTableEmpty, INFO_NO_DBS_FOUND.get().toString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | setTextValue(lDbTableEmpty, getMsg("no-dbs-found")); |
| | | setTextValue(lDbTableEmpty, INFO_NO_DBS_FOUND.get().toString()); |
| | | } |
| | | } |
| | | else |
| | |
| | | */ |
| | | private void updateErrorContents(ServerStatusDescriptor desc) |
| | | { |
| | | String errorMsg = desc.getErrorMessage(); |
| | | Message errorMsg = desc.getErrorMessage(); |
| | | if (errorMsg == null) |
| | | { |
| | | lError.setVisible(false); |
| | |
| | | { |
| | | |
| | | lError.setVisible(true); |
| | | lError.setText(formatter.getFormattedError(errorMsg, false)); |
| | | lError.setText(formatter.getFormattedError(errorMsg, false).toString()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * The following three methods are just commodity methods to get localized |
| | | * messages. |
| | | */ |
| | | private String getMsg(String key) |
| | | { |
| | | return getI18n().getMsg(key); |
| | | } |
| | | |
| | | private ResourceProvider getI18n() |
| | | { |
| | | return ResourceProvider.getInstance(); |
| | | } |
| | | |
| | | /** |
| | | * Updates the size of the table rows according to the size of the |
| | | * rendered component. |
| | | * @param table the table to handle. |