JavaArgumentsDialog.java revision 6292beaede500c125091a84263ed7cda454ba299
/*
* 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 legal-notices/CDDLv1_0.txt
* 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 legal-notices/CDDLv1_0.txt.
* 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 2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
/**
* This class is a dialog that appears when the user wants to configure
* java parameters in the runtime settings panel.
*/
public class JavaArgumentsDialog extends JDialog
{
private static final long serialVersionUID = -7950773258109643264L;
private JLabel lInitialMemory;
private JLabel lMaxMemory;
private JLabel lOtherArguments;
private JTextField tfInitialMemory;
private JTextField tfMaxMemory;
private JTextField tfOtherArguments;
private JButton cancelButton;
private boolean isCanceled = true;
private LocalizableMessage message;
private JavaArguments javaArguments;
private JPanel inputContainer;
private boolean isCheckingVisible;
/**
* Constructor of the JavaArgumentsDialog.
* @param parent the parent frame for this dialog.
* @param javaArguments the java arguments used to populate this dialog.
* @param title the title of the dialog.
* @param message the message to be displayed in top.
* @throws IllegalArgumentException if options is null.
*/
throws IllegalArgumentException
{
super(parent);
if (javaArguments == null)
{
throw new IllegalArgumentException("javaArguments cannot be null.");
}
{
throw new IllegalArgumentException("title cannot be null.");
}
{
throw new IllegalArgumentException("message cannot be null.");
}
this.javaArguments = javaArguments;
pack();
minHeight));
{
public void windowClosing(WindowEvent e)
{
}
});
}
/**
* Returns <CODE>true</CODE> if the user clicked on cancel and
* <CODE>false</CODE> otherwise.
* @return <CODE>true</CODE> if the user clicked on cancel and
* <CODE>false</CODE> otherwise.
*/
public boolean isCanceled()
{
return isCanceled;
}
/**
* Returns the java arguments object representing the input of the user
* in this panel. The method assumes that the values in the panel are
* valid.
* @return the java arguments object representing the input of the user
* in this panel.
*/
public JavaArguments getJavaArguments()
{
{
}
{
}
{
}
return javaArguments;
}
private String[] getOtherArguments()
{
{
return new String[]{};
}
{
{
}
}
}
/**
* Creates and returns the panel of the dialog.
* @return the panel of the dialog.
*/
private JPanel createPanel()
{
JLabel l =
l.setOpaque(false);
instructionsPane.setOpaque(false);
instructionsPane.setEditable(false);
inputContainer.setOpaque(false);
new GridBagConstraints());
return contentPanel;
}
/**
* Creates and returns the input sub panel: the panel with all the widgets
* that are used to define the security options.
* @return the input sub panel.
*/
private Component createInputPanel()
{
inputPanel.setOpaque(false);
lInitialMemory.setOpaque(false);
lMaxMemory.setOpaque(false);
lOtherArguments.setOpaque(false);
return inputPanel;
}
/**
*/
private Component createButtonsPanel()
{
buttonsPanel.setOpaque(false);
okButton =
{
{
okClicked();
}
});
{
{
}
});
return buttonsPanel;
}
/**
* Method called when user clicks on cancel.
*
*/
private void cancelClicked()
{
isCanceled = true;
dispose();
}
/**
* Method called when user clicks on OK.
*
*/
private void okClicked()
{
{
{
setValidLater(lInitialMemory, true);
setValidLater(lMaxMemory, true);
setValidLater(lOtherArguments, true);
int initialMemory = -1;
int maxMemory = -1;
try
{
{
if (initialMemory <= 0)
{
initialMemory = -1;
setValidLater(lInitialMemory, false);
}
}
}
catch (Throwable t)
{
setValidLater(lInitialMemory, false);
}
try
{
{
if (maxMemory <= 0)
{
maxMemory = -1;
setValidLater(lMaxMemory, false);
}
}
}
catch (Throwable t)
{
setValidLater(lMaxMemory, false);
}
if (maxMemory != -1
&& initialMemory != -1
&& initialMemory > maxMemory)
{
setValidLater(lMaxMemory, false);
setValidLater(lInitialMemory, false);
}
{
// Try the options together, often there are interdependencies.
{
if (!memoryErrors.isEmpty())
{
if (!otherErrors.isEmpty())
{
}
}
else
{
if (!otherErrors.isEmpty())
{
}
else
{
setValidLater(lInitialMemory, false);
setValidLater(lMaxMemory, false);
setValidLater(lOtherArguments, false);
// It appears that the arguments are not compatible together.
}
}
}
}
return errorMsgs;
}
{
setCheckingVisible(false);
{
// Bug
INFO_ERROR_TITLE.get());
cancelButton.setEnabled(true);
okButton.setEnabled(true);
}
else
{
cancelButton.setEnabled(true);
okButton.setEnabled(true);
if (!returnValue.isEmpty())
{
INFO_ERROR_TITLE.get());
}
else
{
isCanceled = false;
dispose();
}
}
}
};
setCheckingVisible(true);
cancelButton.setEnabled(false);
okButton.setEnabled(false);
}
/**
* Displays an error message dialog.
*
* @param msg
* the error message.
* @param title
* the title for the dialog.
*/
{
toFront();
}
/**
* Displays a confirmation dialog and returns <CODE>true</CODE> if the user
* accepts the message displayed in the dialog and <CODE>false</CODE>
* otherwise.
*
* @param msg
* the error message.
* @param title
* the title for the dialog.
* @return <CODE>true</CODE> if the user accepts the message displayed in the
* dialog and <CODE>false</CODE> otherwise.
*/
{
toFront();
}
/**
* Updates the widgets on the dialog with the contents of the securityOptions
* object.
*
*/
private void updateContents()
{
{
}
else
{
}
{
}
else
{
}
{
{
{
}
}
}
else
{
}
}
/**
* Method that updates the text style of a provided component by calling
* SwingUtilities.invokeLater. This method is aimed to be called outside
* the event thread (calling it from the event thread will also work though).
* @param comp the component to be updated.
* @param valid whether to use a TextStyle to mark the component as valid
* or as invalid.
*/
{
{
public void run()
{
}
});
}
/**
* This method displays a working progress icon in the panel.
* @param visible whether the icon must be displayed or not.
*/
private void setCheckingVisible(boolean visible)
{
{
if (visible)
{
}
else
{
}
}
}
/**
* Method written for testing purposes.
* @param args the arguments to be passed to the test program.
*/
{
try
{
// UIFactory.initialize();
dlg.setVisible(true);
{
}
}
private static final String INSTALL_PATH =
{
}
private void checkOptions(
{
{
}
{
{
setValidLater(l, false);
}
}
}
{
// 2048 MB is acceptable max heap size on 32Bit OS
if (memValue < 2048)
{
return msg;
}
else
{
}
}
{
setValidLater(lInitialMemory, true);
setValidLater(lMaxMemory, true);
if (initialMemory != -1)
{
if (maxMemory != -1)
{
msg);
}
else
{
msg);
}
}
else if (maxMemory != -1)
{
msg);
}
}
{
setValidLater(lInitialMemory, true);
setValidLater(lMaxMemory, true);
setValidLater(lOtherArguments, true);
if (initialMemory != -1)
{
if (maxMemory != -1)
{
}
else
{
}
}
else if (maxMemory != -1)
{
}
{
{
{
}
}
}
{
}
}
{
setValidLater(lOtherArguments, true);
{
{
{
}
}
}
{
}
}
}