From de55352efcbef4c90879a15831d19892e7af8145 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 21 Jan 2009 12:50:41 +0000
Subject: [PATCH] Fix for issue 3731 (status-panel command-lines should be removed)
---
/dev/null | 70 --------------
opends/src/messages/messages/admin_tool.properties | 1
opends/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java | 182 +++++++++++++++++++++++++++++++----
3 files changed, 159 insertions(+), 94 deletions(-)
diff --git a/opends/resource/bin/status-panel b/opends/resource/bin/status-panel
deleted file mode 100644
index 1c01f6a..0000000
--- a/opends/resource/bin/status-panel
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/sh
-#
-# 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 2008 Sun Microsystems, Inc.
-
-
-# This script may be used to display the control panel.
-OPENDS_INVOKE_CLASS="org.opends.guitools.controlpanel.ControlPanelLauncher"
-export OPENDS_INVOKE_CLASS
-
-SCRIPT_NAME="control-panel"
-export SCRIPT_NAME
-
-NO_CHECK=0
-export NO_CHECK
-
-SCRIPT_DIR=`dirname "${0}"`
-"${SCRIPT_DIR}/../lib/_client-script.sh" "${@}"
diff --git a/opends/resource/bin/status-panel.bat b/opends/resource/bin/status-panel.bat
deleted file mode 100644
index 3dc1b99..0000000
--- a/opends/resource/bin/status-panel.bat
+++ /dev/null
@@ -1,70 +0,0 @@
-
-@echo off
-rem CDDL HEADER START
-rem
-rem The contents of this file are subject to the terms of the
-rem Common Development and Distribution License, Version 1.0 only
-rem (the "License"). You may not use this file except in compliance
-rem with the License.
-rem
-rem You can obtain a copy of the license at
-rem trunk/opends/resource/legal-notices/OpenDS.LICENSE
-rem or https://OpenDS.dev.java.net/OpenDS.LICENSE.
-rem See the License for the specific language governing permissions
-rem and limitations under the License.
-rem
-rem When distributing Covered Code, include this CDDL HEADER in each
-rem file and include the License file at
-rem trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
-rem add the following below this CDDL HEADER, with the fields enclosed
-rem by brackets "[]" replaced with your own identifying information:
-rem Portions Copyright [yyyy] [name of copyright owner]
-rem
-rem CDDL HEADER END
-rem
-rem
-rem Copyright 2006-2008 Sun Microsystems, Inc.
-
-setlocal
-for %%i in (%~sf0) do set DIR_HOME=%%~dPsi..
-set INSTALL_ROOT=%DIR_HOME%
-
-set INSTANCE_DIR=
-for /f "delims=" %%a in (%DIR_HOME%\instance.loc) do (
- set INSTANCE_DIR=%%a
-)
-set CUR_DIR=%~dp0
-cd /d %INSTALL_ROOT%
-cd /d %INSTANCE_DIR%
-set INSTANCE_ROOT=%CD%
-cd /d %CUR_DIR%
-
-
-set SCRIPT_NAME=control-panel
-
-rem Set environment variables
-set SCRIPT_UTIL_CMD=set-full-environment
-call "%INSTALL_ROOT%\lib\_script-util.bat"
-if NOT %errorlevel% == 0 exit /B %errorlevel%
-
-if "%~1" == "" goto callLaunch
-goto callJava
-
-:callLaunch
-if exist "%INSTALL_ROOT%\lib\set-java-args.bat" DO call "%INSTALL_ROOT%\lib\set-java-args.bat"
-"%INSTALL_ROOT%\lib\winlauncher.exe" launch "%OPENDS_JAVA_BIN%" %OPENDS_JAVA_ARGS% %SCRIPT_NAME_ARG% org.opends.guitools.controlpanel.ControlPanelLauncher
-goto end
-
-:callJava
-if exist "%INSTALL_ROOT%\lib\set-java-args.bat" DO call "%INSTALL_ROOT%\lib\set-java-args.bat"
-"%OPENDS_JAVA_BIN%" %OPENDS_JAVA_ARGS% %SCRIPT_NAME_ARG% org.opends.guitools.controlpanel.ControlPanelLauncher %*
-
-rem return part
-if %errorlevel% == 50 goto version
-goto end
-
-:version
-rem version information was requested. Return code should be 0.
-exit /B 0
-
-:end
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java
index 4e67671..054a678 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java
@@ -32,6 +32,8 @@
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
@@ -48,6 +50,7 @@
import javax.swing.ButtonGroup;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
@@ -100,8 +103,53 @@
private JLabel lInitContents;
+ private JCheckBox showAll;
+
private Set<JavaArgumentsDescriptor> readJavaArguments =
new HashSet<JavaArgumentsDescriptor>();
+
+ private Set<JavaArgumentsDescriptor> currentJavaArguments =
+ new HashSet<JavaArgumentsDescriptor>();
+
+ private Set<String> allScriptNames =
+ new HashSet<String>();
+ {
+ String[] names =
+ {
+ "start-ds", "import-ldif.offline", "backup.online", "base64",
+ "create-rc-script", "dsconfig", "dsreplication", "dsframework",
+ "export-ldif.online", "import-ldif.online", "ldapcompare",
+ "ldapdelete", "ldapmodify", "ldappasswordmodify", "ldapsearch",
+ "list-backends", "manage-account", "manage-tasks", "restore.online",
+ "stop-ds", "status", "control-panel", "uninstall", "setup",
+ "backup.offline", "encode-password", "export-ldif.offline",
+ "ldif-diff", "ldifmodify", "ldifsearch", "make-ldif",
+ "rebuild-index", "restore.offline", "upgrade",
+ "verify-index", "dbtest"
+ };
+ for (String name : names)
+ {
+ allScriptNames.add(name);
+ }
+ }
+
+ private Set<String> relevantScriptNames =
+ new HashSet<String>();
+
+ {
+ String[] relevantNames =
+ {
+ "start-ds", "import-ldif.offline", "backup.offline",
+ "export-ldif.offline",
+ "ldif-diff", "make-ldif", "rebuild-index", "restore.offline",
+ "verify-index", "dbtest"
+ };
+ for (String name : relevantNames)
+ {
+ relevantScriptNames.add(name);
+ }
+ }
+
private String readJavaHome;
private boolean readUseOpenDSJavaHome;
private boolean readUseOpenDSJavaArgs;
@@ -316,6 +364,23 @@
gbc.weightx = 1.0;
gbc.anchor = GridBagConstraints.WEST;
+ showAll =
+ Utilities.createCheckBox(INFO_CTRL_PANEL_DISPLAY_ALL_COMMAND_LINES.get());
+ showAll.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ editor.stopCellEditing();
+ currentJavaArguments = getCurrentJavaArguments();
+ argumentsTableModel.setData(filterJavaArguments(currentJavaArguments));
+ Utilities.updateTableSizes(argumentsTable, 7);
+ }
+ });
+
+ gbc.gridy ++;
+ gbc.insets.top = 5;
+ p.add(showAll, gbc);
+
JLabel inlineHelp = Utilities.createInlineHelpLabel(
INFO_CTRL_PANEL_ONLINE_COMMAND_HELP.get());
gbc.insets.top = 3;
@@ -370,6 +435,30 @@
}
/**
+ * Returns the names of all the command-line that can be displayed by this
+ * panel.
+ * @return the names of all the command-line that can be displayed by this
+ * panel.
+ */
+ protected Set<String> getAllCommandLineNames()
+ {
+ return allScriptNames;
+ }
+
+ /**
+ * Returns the names of the most important command-line to be displayed by
+ * this panel.
+ * @return the names of the most important command-line to be displayed by
+ * this panel.
+ */
+ protected Set<String> getRelevantCommandLineNames()
+ {
+ return relevantScriptNames;
+ }
+
+
+
+ /**
* Returns <CODE>true</CODE> if the user updated the contents and
* <CODE>false</CODE> otherwise.
* @return <CODE>true</CODE> if the user updated the contents and
@@ -380,26 +469,81 @@
boolean updatedByUser = !javaHome.getText().equals(readJavaHome) ||
useOpenDSJavaHome.isSelected() != readUseOpenDSJavaHome ||
useOpenDSJavaArgs.isSelected() != readUseOpenDSJavaArgs ||
- !readJavaArguments.equals(getJavaArguments());
+ !readJavaArguments.equals(getCurrentJavaArguments());
return updatedByUser;
}
/**
- * Returns the java arguments specified in the table.
- * @return the java arguments specified in the table.
+ * Returns the java arguments specified by the user.
+ * @return the java arguments specified by the user.
*/
- private Set<JavaArgumentsDescriptor> getJavaArguments()
+ private Set<JavaArgumentsDescriptor> getCurrentJavaArguments()
{
HashSet<JavaArgumentsDescriptor> args =
+ new HashSet<JavaArgumentsDescriptor>(currentJavaArguments);
+
+ HashSet<JavaArgumentsDescriptor> tableArgs =
new HashSet<JavaArgumentsDescriptor>();
for (int i=0; i<argumentsTableModel.getRowCount(); i++)
{
- args.add(argumentsTableModel.getJavaArguments(i));
+ tableArgs.add(argumentsTableModel.getJavaArguments(i));
+ }
+ for (JavaArgumentsDescriptor arg : tableArgs)
+ {
+ JavaArgumentsDescriptor foundJavaArgument = null;
+ for (JavaArgumentsDescriptor arg1 : args)
+ {
+ if (arg1.getCommandName().equals(arg.getCommandName()))
+ {
+ foundJavaArgument = arg1;
+ break;
+ }
+ }
+ if (foundJavaArgument != null)
+ {
+ args.remove(foundJavaArgument);
+ }
+ args.add(arg);
}
return args;
}
+
+ /**
+ * Filters the provided list of java arguments depending on the showing
+ * options (basically whether the 'Show All Command-lines' is selected or
+ * not).
+ * @param args the list of java arguments.
+ * @return a list of filtered java arguments (the ones that must be displayed
+ * in the table).
+ */
+ private Set<JavaArgumentsDescriptor> filterJavaArguments(
+ Set<JavaArgumentsDescriptor> args)
+ {
+ if (showAll.isSelected())
+ {
+ return args;
+ }
+ else
+ {
+ Set<JavaArgumentsDescriptor> filteredArgs =
+ new HashSet<JavaArgumentsDescriptor>();
+ for (String relevantName : getRelevantCommandLineNames())
+ {
+ for (JavaArgumentsDescriptor arg : args)
+ {
+ if (arg.getCommandName().equals(relevantName))
+ {
+ filteredArgs.add(arg);
+ break;
+ }
+ }
+ }
+ return filteredArgs;
+ }
+ }
+
/**
* Inits the contents of the table in the background.
*
@@ -440,19 +584,6 @@
}
}
- String[] scripts =
- {
- "start-ds", "import-ldif.offline", "backup.online", "base64",
- "create-rc-script", "dsconfig", "dsreplication", "dsframework",
- "export-ldif.online", "import-ldif.online", "ldapcompare",
- "ldapdelete", "ldapmodify", "ldappasswordmodify", "ldapsearch",
- "list-backends", "manage-account", "manage-tasks", "restore.online",
- "stop-ds", "status", "status-panel", "uninstall", "setup",
- "backup.offline", "encode-password", "export-ldif.offline",
- "ldif-diff", "ldifmodify", "ldifsearch", "make-ldif",
- "rebuild-index", "restore.offline", "upgrade",
- "verify-index", "dbtest"
- };
String v = properties.getProperty("overwrite-env-java-home");
readUseOpenDSJavaHome =
(v == null) || ("false".equalsIgnoreCase(v.trim()));
@@ -463,7 +594,7 @@
readJavaHome = properties.getProperty("default.java-home");
if (readJavaHome == null)
{
- for (String script : scripts)
+ for (String script : getAllCommandLineNames())
{
readJavaHome = properties.getProperty(script+".java-home");
if (readJavaHome != null)
@@ -474,7 +605,7 @@
}
readJavaArguments.clear();
- for (String script : scripts)
+ for (String script : getAllCommandLineNames())
{
v = properties.getProperty(script+".java-args");
if (v != null)
@@ -502,7 +633,10 @@
useSpecifiedJavaHome.setSelected(!readUseOpenDSJavaHome);
useOpenDSJavaArgs.setSelected(readUseOpenDSJavaArgs);
useSpecifiedJavaArgs.setSelected(!readUseOpenDSJavaArgs);
- argumentsTableModel.setData(readJavaArguments);
+ currentJavaArguments.clear();
+ currentJavaArguments.addAll(readJavaArguments);
+ argumentsTableModel.setData(
+ filterJavaArguments(currentJavaArguments));
Utilities.updateTableSizes(argumentsTable, 7);
}
else
@@ -597,7 +731,7 @@
if (errors.size() == 0)
{
final Set<String> providedArguments = new HashSet<String>();
- for (JavaArgumentsDescriptor cmd : getJavaArguments())
+ for (JavaArgumentsDescriptor cmd : getCurrentJavaArguments())
{
String args = cmd.getJavaArguments().trim();
if (args.length() > 0)
@@ -749,7 +883,7 @@
readJavaHome = javaHome.getText();
readUseOpenDSJavaHome = useOpenDSJavaHome.isSelected();
readUseOpenDSJavaArgs = useOpenDSJavaArgs.isSelected();
- readJavaArguments = getJavaArguments();
+ readJavaArguments = getCurrentJavaArguments();
}
else
{
@@ -1108,7 +1242,7 @@
defaultJavaHome = javaHome.getText().trim();
overwriteOpenDSJavaHome = useSpecifiedJavaHome.isSelected();
overwriteOpenDSJavaArgs = useSpecifiedJavaArgs.isSelected();
- arguments = getJavaArguments();
+ arguments = getCurrentJavaArguments();
}
/**
diff --git a/opends/src/messages/messages/admin_tool.properties b/opends/src/messages/messages/admin_tool.properties
index e111e75..9eaa32e 100644
--- a/opends/src/messages/messages/admin_tool.properties
+++ b/opends/src/messages/messages/admin_tool.properties
@@ -2314,3 +2314,4 @@
INFO_CTRL_PANEL_PROGRESS_DONE=Done
INFO_CTRL_PANEL_VLV_INDEX_CELL=%s - VLV Index
+INFO_CTRL_PANEL_DISPLAY_ALL_COMMAND_LINES=Display All Command-lines
--
Gitblit v1.10.0