mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
06.48.2009 ad42fe808889ebd10ac8787ae5a36247d69ebe66
Add UI to allow the user the refreshing period using by the control panel to update its contents.
1 files added
13 files modified
349 ■■■■■ changed files
opends/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java 30 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteBaseDNAndBackendTask.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteIndexTask.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/RestartServerTask.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/StartStopTask.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/IndexPanel.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/MainMenuBar.java 56 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewIndexPanel.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/RefreshOptionsPanel.java 212 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java 4 ●●●● patch | view | raw | blame | history
opends/src/messages/messages/admin_tool.properties 11 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel;
@@ -89,7 +89,7 @@
  {
    info = ControlPanelInfo.getInstance();
    info.regenerateDescriptor();
    info.startPooling(ControlPanelInfo.DEFAULT_POOLING);
    info.startPooling();
  }
  /**
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.datamodel;
@@ -67,10 +67,7 @@
 */
public class ControlPanelInfo
{
  /**
   * The default pooling time in miliseconds.
   */
  public static final long DEFAULT_POOLING = 20000;
  private long poolingPeriod = 20000;
  private ServerDescriptor serverDesc;
  private Set<Task> tasks = new HashSet<Task>();
@@ -699,9 +696,8 @@
   * Starts pooling the server configuration.  The period of the pooling is
   * specified as a parameter.  This method is asynchronous and it will start
   * the pooling in another thread.
   * @param period the pooling in miliseconds of the pooling.
   */
  public synchronized void startPooling(final long period)
  public synchronized void startPooling()
  {
    if (poolingThread != null)
    {
@@ -719,7 +715,7 @@
          while (!stopPooling)
          {
            regenerateDescriptor();
            Thread.sleep(period);
            Thread.sleep(poolingPeriod);
          }
        }
        catch (Throwable t)
@@ -1056,4 +1052,22 @@
  {
    return iconPool;
  }
  /**
   * Returns the pooling period in miliseconds.
   * @return the pooling period in miliseconds.
   */
  public long getPoolingPeriod()
  {
    return poolingPeriod;
  }
  /**
   * Sets the pooling period in miliseconds.
   * @param poolingPeriod the pooling time in miliseconds.
   */
  public void setPoolingPeriod(long poolingPeriod)
  {
    this.poolingPeriod = poolingPeriod;
  }
}
opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteBaseDNAndBackendTask.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.task;
@@ -432,7 +432,7 @@
      {
        DirectoryServer.getInstance().initializeConfiguration(
            ConfigReader.configClassName, ConfigReader.configFile);
        getInfo().startPooling(ControlPanelInfo.DEFAULT_POOLING);
        getInfo().startPooling();
      }
    }
  }
opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteIndexTask.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.task;
@@ -256,7 +256,7 @@
      {
        DirectoryServer.getInstance().initializeConfiguration(
            ConfigReader.configClassName, ConfigReader.configFile);
        getInfo().startPooling(ControlPanelInfo.DEFAULT_POOLING);
        getInfo().startPooling();
      }
    }
  }
opends/src/guitools/org/opends/guitools/controlpanel/task/RestartServerTask.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.task;
@@ -189,6 +189,6 @@
      lastException = t;
      state = State.FINISHED_WITH_ERROR;
    }
    getInfo().startPooling(ControlPanelInfo.DEFAULT_POOLING);
    getInfo().startPooling();
  }
}
opends/src/guitools/org/opends/guitools/controlpanel/task/StartStopTask.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.task;
@@ -122,7 +122,7 @@
      lastException = t;
      state = State.FINISHED_WITH_ERROR;
    }
    getInfo().startPooling(ControlPanelInfo.DEFAULT_POOLING);
    getInfo().startPooling();
  }
  /**
opends/src/guitools/org/opends/guitools/controlpanel/ui/IndexPanel.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
@@ -687,7 +687,7 @@
        {
          DirectoryServer.getInstance().initializeConfiguration(
              ConfigReader.configClassName, ConfigReader.configFile);
          getInfo().startPooling(ControlPanelInfo.DEFAULT_POOLING);
          getInfo().startPooling();
        }
      }
    }
opends/src/guitools/org/opends/guitools/controlpanel/ui/MainMenuBar.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
@@ -54,6 +54,9 @@
{
  private static final long serialVersionUID = 6441273044772077947L;
  private GenericDialog dlg;
  private RefreshOptionsPanel panel;
  /**
   * Constructor.
   * @param info the control panel information.
@@ -99,6 +102,7 @@
      add(menu);
    }
    add(createViewMenuBar());
    add(createHelpMenuBar());
  }
@@ -134,6 +138,30 @@
    }
  }
  /**
   * Creates the View menu bar.
   * @return the View menu bar.
   */
  protected JMenu createViewMenuBar()
  {
    JMenu menu = Utilities.createMenu(INFO_CTRL_PANEL_VIEW_MENU.get(),
        INFO_CTRL_PANEL_HELP_VIEW_DESCRIPTION.get());
    menu.setMnemonic(KeyEvent.VK_V);
    JMenuItem menuItem = Utilities.createMenuItem(
        INFO_CTRL_PANEL_REFRESH_MENU.get());
    menuItem.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent ev)
      {
        refreshOptionsClicked();
      }
    });
    menu.add(menuItem);
    return menu;
  }
  /**
   * Specific method to be able to handle the Quit events sent from the COCOA
   * menu of Mac OS.
@@ -177,4 +205,30 @@
      t.printStackTrace();
    }
  }
  /**
   * The method called when the user clicks on 'Refresh Options'.
   *
   */
  protected void refreshOptionsClicked()
  {
    if (panel == null)
    {
      panel = new RefreshOptionsPanel();
      panel.setInfo(getInfo());
      dlg = new GenericDialog(
          Utilities.getFrame(MainMenuBar.this),
          panel);
      dlg.setModal(true);
      Utilities.centerGoldenMean(dlg,
          Utilities.getFrame(MainMenuBar.this));
    }
    dlg.setVisible(true);
    if (!panel.isCancelled())
    {
      getInfo().setPoolingPeriod(panel.getPoolingPeriod());
      getInfo().stopPooling();
      getInfo().startPooling();
    }
  }
}
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
@@ -940,7 +940,7 @@
        {
          DirectoryServer.getInstance().initializeConfiguration(
              ConfigReader.configClassName, ConfigReader.configFile);
          getInfo().startPooling(ControlPanelInfo.DEFAULT_POOLING);
          getInfo().startPooling();
        }
      }
    }
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewIndexPanel.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
@@ -552,7 +552,7 @@
        {
          DirectoryServer.getInstance().initializeConfiguration(
              ConfigReader.configClassName, ConfigReader.configFile);
          getInfo().startPooling(ControlPanelInfo.DEFAULT_POOLING);
          getInfo().startPooling();
        }
      }
    }
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
@@ -348,7 +348,7 @@
        {
          DirectoryServer.getInstance().initializeConfiguration(
              ConfigReader.configClassName, ConfigReader.configFile);
          getInfo().startPooling(ControlPanelInfo.DEFAULT_POOLING);
          getInfo().startPooling();
        }
      }
    }
opends/src/guitools/org/opends/guitools/controlpanel/ui/RefreshOptionsPanel.java
New file
@@ -0,0 +1,212 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
import static org.opends.messages.AdminToolMessages.*;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.util.LinkedHashSet;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JTextField;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.Message;
/**
 * The panel that displays the refresh options of the control panel.  Basically
 * it allows to set the refreshing period used by the control panel.
 *
 */
public class RefreshOptionsPanel extends StatusGenericPanel
{
  private static final long serialVersionUID = 641533296295459469L;
  private JTextField period;
  private JLabel lPeriod;
  private boolean isCancelled = true;
  private int MAX_VALUE = 5000;
  /**
   * Default constructor.
   *
   */
  public RefreshOptionsPanel()
  {
    super();
    createLayout();
  }
  /**
   * {@inheritDoc}
   */
  public Message getTitle()
  {
    return INFO_CTRL_PANEL_REFRESH_PANEL_TITLE.get();
  }
  /**
   * Creates the layout of the panel (but the contents are not populated here).
   */
  private void createLayout()
  {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.weightx = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 2;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    String text = INFO_CTRL_PANEL_REFRESH_OPTIONS_PANEL_TEXT.get().toString();
    JEditorPane pane = Utilities.makeHtmlPane(text,
        ColorAndFontConstants.defaultFont);
    Utilities.updatePreferredSize(pane, 60, text,
        ColorAndFontConstants.defaultFont, false);
    gbc.weighty = 0.0;
    add(pane, gbc);
    gbc.gridy = 1;
    gbc.gridwidth = 1;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    lPeriod =Utilities.createPrimaryLabel(
        INFO_CTRL_PANEL_REFRESH_OPTIONS_LABEL.get());
    gbc.insets.top = 10;
    add(lPeriod, gbc);
    period = Utilities.createShortTextField();
    gbc.insets.left = 10;
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    add(period, gbc);
    gbc.gridwidth = 2;
    addBottomGlue(gbc);
  }
  /**
   * {@inheritDoc}
   */
  public GenericDialog.ButtonType getButtonType()
  {
    return GenericDialog.ButtonType.OK_CANCEL;
  }
  /**
   * {@inheritDoc}
   */
  public Component getPreferredFocusComponent()
  {
    return period;
  }
  /**
   * {@inheritDoc}
   */
  public void configurationChanged(ConfigurationChangeEvent ev)
  {
  }
  /**
   * {@inheritDoc}
   */
  public void okClicked()
  {
    isCancelled = true;
    setPrimaryValid(lPeriod);
    LinkedHashSet<Message> errors = new LinkedHashSet<Message>();
    long t = -1;
    try
    {
      t = Long.parseLong(period.getText());
    }
    catch (Throwable th)
    {
    }
    if ((t <= 0) || (t > MAX_VALUE))
    {
      errors.add(INFO_CTRL_PANEL_INVALID_PERIOD_VALUE.get(MAX_VALUE));
    }
    if (errors.size() > 0)
    {
      displayErrorDialog(errors);
    }
    else
    {
      isCancelled = false;
      Utilities.getParentDialog(this).setVisible(false);
    }
  }
  /**
   * Returns whether this dialog has been cancelled or not.
   * @return whether this dialog has been cancelled or not.
   */
  public boolean isCancelled()
  {
    return isCancelled;
  }
  /**
   * {@inheritDoc}
   */
  public void toBeDisplayed(boolean visible)
  {
    if (visible)
    {
      isCancelled = true;
      long timeInSeconds = getInfo().getPoolingPeriod() / 1000;
      period.setText(String.valueOf(timeInSeconds));
    }
  }
  /**
   * Returns the time specified by the user in miliseconds.
   * @return the time specified by the user in miliseconds.
   */
  public long getPoolingPeriod()
  {
    long t = -1;
    try
    {
      t = 1000 * Long.parseLong(period.getText());
    }
    catch (Throwable th)
    {
    }
    return t;
  }
}
opends/src/guitools/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
@@ -764,7 +764,7 @@
        {
          DirectoryServer.getInstance().initializeConfiguration(
              ConfigReader.configClassName, ConfigReader.configFile);
          getInfo().startPooling(ControlPanelInfo.DEFAULT_POOLING);
          getInfo().startPooling();
        }
      }
    }
opends/src/messages/messages/admin_tool.properties
@@ -20,7 +20,7 @@
#
# CDDL HEADER END
#
#      Copyright 2006-2008 Sun Microsystems, Inc.
#      Copyright 2006-2009 Sun Microsystems, Inc.
@@ -2315,3 +2315,12 @@
INFO_CTRL_PANEL_VLV_INDEX_CELL=%s - VLV Index
INFO_CTRL_PANEL_DISPLAY_ALL_COMMAND_LINES=Display All Command-lines
INFO_CTRL_PANEL_HELP_VIEW_DESCRIPTION=Global view options.
INFO_CTRL_PANEL_REFRESH_MENU=Refresh options...
INFO_CTRL_PANEL_REFRESH_PANEL_TITLE=Refresh Options
INFO_CTRL_PANEL_REFRESH_OPTIONS_PANEL_TEXT=Select the period (in seconds) \
 used to refresh the monitoring and configuration information displayed.
INFO_CTRL_PANEL_REFRESH_OPTIONS_LABEL=Refresh Period (sec):
INFO_CTRL_PANEL_INVALID_PERIOD_VALUE=The period time must be an integer \
 positive value smaller than %d seconds.