Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

IZPACK-363 : Imroved layout possibilities on UserInputPanel

- Added factory to create layout constraints
- Replaced new TwoColumnContraints() calls with factory calls

git-svn-id: http://svn.codehaus.org/izpack@2956 7d736ef5-cfd4-0310-9c9a-b52d5c14b761
  • Loading branch information...
commit 7a521ccd6ce0dd1a0664eaae12fd5bba5571d231 1 parent bfb8f38
fbuehlmann authored
View
69 izpack-src/trunk/src/doc-reST/user-input.txt
@@ -115,13 +115,22 @@ specify the details for one panel instance. The tag name for this is
The ``<panel>`` tag uses the following attributes:
-**order** ``- required``
+**order** ``- required / optional``
This is the order number of the user input panel for which this specification
should be used. Counting starts at 0 and increments by 1 for each instance of
the user input panel. So if a spec should be used for the second occurrence
-of the user input panel use ``order="1"``.
+of the user input panel use ``order="1"``. This attribute is required if no
+``id="unique.identifier"`` is set.
+
+
+**id** ``- optional / required``
+
+
+This is the id of the user input panel for which this specification
+should be used. This id links to the panel specification in the install.xml file.
+If no ``order`` attribute is specified the ``id`` attribute is required.
**layout** ``- optional``
@@ -133,6 +142,23 @@ want to experiment with this attribute and see which you like best. The
default is ``left``.
+**border** ``- optional``
+
+
+Normally the user input is shown with a small border. To prevent this border set this
+attribute to ``false``. The default is ``true``.
+
+
+**column_width** ``- optional``
+
+
+This can be used to set the column width of the two column layout. This value is in percent
+of the whole size.
+If it is set to ``0``, which is the default, the with will be set automatically.
+It it is set to ``50`` the gap between the left and right column is in the middle
+of the panel. This makes it possible to make a centered layout.
+
+
Concepts and XML Elements Common to All Fields
------------------------------------------------------------
@@ -157,6 +183,45 @@ right.
Each UI element is specified with a ``<field>`` tag. The ``type`` attribute
is used to specify what kind of field you want to place. Obviously, the
``type`` attribute is not optional.
+In addition there are multiple layout attributes for the field tag.
+``label_position``
+Can be used to change the default position of the label which is usually ``west``
+It takes the arguments ``west``, ``westonly``, ``both``, ``eastonly``, ``east``
+``label_align``
+Can be used to change the default alignment of the label which is usually ``left``
+It takes the argument ``left``, ``center``, ``right``
+``label_indent``
+Controls the indent of the label which is usually ``false``.
+It takes the arguments ``true``, ``false``
+
+``control_position``
+Can be used to change the default position of the control which is usually ``east``
+It takes the arguments ``west``, ``westonly``, ``both``, ``eastonly``, ``east``
+``control_align``
+Can be used to change the default alignment of the control which is usually ``left``
+It takes the argument ``left``, ``center``, ``right``
+``control_indent``
+Controls the indent of the control which is usually ``false``.
+It takes the arguments ``true``, ``false``
+
+**Examples**
+
+In the following example, the the label and the control will be shown on it's own row.
+
+::
+
+ <field type="text" variable="value1">
+ <spec txt="The label" id="" size="20" set="default value" label_both="both" control_position="both" />
+ </field>
+
+In the following example, the label is right aligned to the control.
+
+::
+
+ <field type="text" variable="value1">
+ <spec txt="The label" id="" size="20" set="default value" label_align="right" />
+ </field>
+
Each field that takes user input must also specify the variable that should
View
38 izpack-src/trunk/src/lib/com/izforge/izpack/gui/TwoColumnConstraints.java
@@ -1,22 +1,19 @@
/*
* IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
*
- * http://izpack.org/
- * http://izpack.codehaus.org/
+ * http://izpack.org/ http://izpack.codehaus.org/
*
* Copyright 2002 Elmar Grom
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package com.izforge.izpack.gui;
@@ -25,7 +22,7 @@
/**
* The constraints class to use with <code>TwoColumnLayout</code>.
- *
+ *
* @author Elmar Grom
* @version 0.0.1 / 11/15/02
* @see com.izforge.izpack.gui.TwoColumnLayout
@@ -55,18 +52,16 @@
/**
* Indicates where to place the associated component. <code>NORTH</code> will place the
- * component in the title margin. </code>WEST</code> will place the component in the left
- * column and <code>EAST</code> will place it in the right column. If <code>BOTH</code> is
- * used, the component will straddle both columns. <code>WESTONLY</code> and <code>EASTONLY</code>
- * will place the element accordingly but make sure that nothing is placed in the opposite
- * column.
+ * component in the title margin. </code>WEST</code> will place the component in the left column
+ * and <code>EAST</code> will place it in the right column. If <code>BOTH</code> is used, the
+ * component will straddle both columns. <code>WESTONLY</code> and <code>EASTONLY</code> will
+ * place the element accordingly but make sure that nothing is placed in the opposite column.
*/
public int position = WEST;
/**
* How to align the associated component, <code>LEFT</code>, <code>CENTER</code> or
- * <code>RIGHT</code>. Note that this setting only taks effect in the component is placed in
- * the title margin.
+ * <code>RIGHT</code>.
*/
public int align = LEFT;
@@ -88,9 +83,10 @@
/**
* Creates a copy of this two column constraint.
- *
+ *
* @return a copy of this <code>TwoColumnConstraints</code>
*/
+ @Override
public Object clone()
{
TwoColumnConstraints newObject = new TwoColumnConstraints();
View
188 izpack-src/trunk/src/lib/com/izforge/izpack/gui/TwoColumnConstraintsFactory.java
@@ -0,0 +1,188 @@
+/**
+ * File Name: TwoColumnConstraintsFactory.java
+ *
+ * Version: $Id: $
+ */
+
+package com.izforge.izpack.gui;
+
+import com.izforge.izpack.adaptator.IXMLElement;
+
+public class TwoColumnConstraintsFactory
+{
+
+ private static final String ALIGNMENT = "align";
+
+ private static final String LABEL_ALIGNMENT = "label_align";
+
+ private static final String CONTROL_ALIGNMENT = "control_align";
+
+ private static final String LABEL_POSITION = "label_position";
+
+ private static final String CONTROL_POSITION = "control_position";
+
+ private static final String LABEL_INDENT = "label_indent";
+
+ private static final String CONTROL_INDENT = "control_indent";
+
+ private static final String LEFT = "left";
+
+ private static final String CENTER = "center";
+
+ private static final String RIGHT = "right";
+
+ private static final String WEST = "west";
+
+ private static final String WESTONLY = "westonly";
+
+ private static final String EAST = "east";
+
+ private static final String EASTONLY = "eastonly";
+
+ private static final String BOTH = "both";
+
+ private static final String TRUE = "true";
+
+ private static final String FALSE = "false";
+
+ public static TwoColumnConstraints createTextConstraint(IXMLElement field)
+ {
+ return createTextConstraint(field, TwoColumnConstraints.BOTH, false, false);
+ }
+
+ public static TwoColumnConstraints createLabelConstraint(IXMLElement field)
+ {
+ return createLabelConstraint(field, TwoColumnConstraints.WEST, false, false);
+ }
+
+ public static TwoColumnConstraints createControlConstraint(IXMLElement field)
+ {
+ return createControlConstraint(field, TwoColumnConstraints.EAST, false, false);
+ }
+
+ public static TwoColumnConstraints createTextConstraint(IXMLElement field, int position, boolean indent,
+ boolean stretch)
+ {
+ TwoColumnConstraints constraint = new TwoColumnConstraints();
+ constraint.position = position;
+ constraint.indent = indent;
+ constraint.stretch = stretch;
+ constraint.align = TwoColumnConstraints.LEFT;
+ overrideTextDefaults(constraint, field);
+ return constraint;
+ }
+
+ public static TwoColumnConstraints createControlConstraint(IXMLElement field, int position, boolean indent,
+ boolean stretch)
+ {
+ TwoColumnConstraints constraint = new TwoColumnConstraints();
+ constraint.position = position;
+ constraint.indent = indent;
+ constraint.stretch = stretch;
+ constraint.align = TwoColumnConstraints.LEFT;
+ overrideControlDefaults(constraint, field);
+ return constraint;
+ }
+
+ public static TwoColumnConstraints createLabelConstraint(IXMLElement field, int position, boolean indent,
+ boolean stretch)
+ {
+ TwoColumnConstraints constraint = new TwoColumnConstraints();
+ constraint.position = position;
+ constraint.indent = indent;
+ constraint.stretch = stretch;
+ constraint.align = TwoColumnConstraints.LEFT;
+ overrideLabelDefaults(constraint, field);
+ return constraint;
+ }
+
+ private static void overrideTextDefaults(TwoColumnConstraints constraint, IXMLElement field)
+ {
+ if (field != null)
+ {
+ overrideAlignment(constraint, field.getAttribute(ALIGNMENT));
+ overrideAlignment(constraint, field.getAttribute(LABEL_ALIGNMENT));
+ }
+ }
+
+ private static void overrideLabelDefaults(TwoColumnConstraints constraint, IXMLElement field)
+ {
+ if (field != null)
+ {
+ overrideAlignment(constraint, field.getAttribute(LABEL_ALIGNMENT));
+ overridePosition(constraint, field.getAttribute(LABEL_POSITION));
+ overrideIndent(constraint, field.getAttribute(LABEL_INDENT));
+ }
+ }
+
+ private static void overrideControlDefaults(TwoColumnConstraints constraint, IXMLElement field)
+ {
+ if (field != null)
+ {
+ overrideAlignment(constraint, field.getAttribute(CONTROL_ALIGNMENT));
+ overridePosition(constraint, field.getAttribute(CONTROL_POSITION));
+ overrideIndent(constraint, field.getAttribute(CONTROL_INDENT));
+ }
+ }
+
+ private static void overrideAlignment(TwoColumnConstraints constraint, String value)
+ {
+ if (value != null)
+ {
+ if (value.equalsIgnoreCase(LEFT))
+ {
+ constraint.align = TwoColumnConstraints.LEFT;
+ }
+ else if (value.equalsIgnoreCase(CENTER))
+ {
+ constraint.align = TwoColumnConstraints.CENTER;
+ }
+ else if (value.equalsIgnoreCase(RIGHT))
+ {
+ constraint.align = TwoColumnConstraints.RIGHT;
+ }
+ }
+ }
+
+ private static void overridePosition(TwoColumnConstraints constraint, String value)
+ {
+ if (value != null)
+ {
+ if (value.equalsIgnoreCase(WEST))
+ {
+ constraint.position = TwoColumnConstraints.WEST;
+ }
+ else if (value.equalsIgnoreCase(EAST))
+ {
+ constraint.position = TwoColumnConstraints.EAST;
+ }
+ else if (value.equalsIgnoreCase(BOTH))
+ {
+ constraint.position = TwoColumnConstraints.BOTH;
+ }
+ else if (value.equalsIgnoreCase(WESTONLY))
+ {
+ constraint.position = TwoColumnConstraints.WESTONLY;
+ }
+ else if (value.equalsIgnoreCase(EASTONLY))
+ {
+ constraint.position = TwoColumnConstraints.EASTONLY;
+ }
+ }
+ }
+
+ private static void overrideIndent(TwoColumnConstraints constraint, String value)
+ {
+ if (value != null)
+ {
+ if (value.equalsIgnoreCase(TRUE))
+ {
+ constraint.indent = true;
+ }
+ else if (value.equalsIgnoreCase(FALSE))
+ {
+ constraint.indent = false;
+ }
+ }
+ }
+}
View
323 izpack-src/trunk/src/lib/com/izforge/izpack/gui/TwoColumnLayout.java
@@ -1,27 +1,31 @@
/*
* IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
*
- * http://izpack.org/
- * http://izpack.codehaus.org/
+ * http://izpack.org/ http://izpack.codehaus.org/
*
* Copyright 2002 Elmar Grom
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package com.izforge.izpack.gui;
-import java.awt.*;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.LayoutManager2;
+import java.awt.Stroke;
import java.util.Vector;
/**
@@ -73,19 +77,19 @@
* The location of the rules is determined based on the alignment strategy as follows:<br>
* <ul>
* <li>The right rule is always located at the edge of the right margin.
- * <li><b>Left Alignment:</b> The left rule is located the edge of the left margin. The center
- * rule is located far enough to the right to clear the widest component in the left column.
- * <li><b>Center Alignment:</b> The center rule is located at the center of the panel. The left
- * rule is located far enough to the left to make the widest component in the left column fit.
- * <li><b>Right Alignment</b> The center rule is located far enough to the left of the right rule
- * to make the widest component in the right column fit. The left rule is located far enough to the
+ * <li><b>Left Alignment:</b> The left rule is located the edge of the left margin. The center rule
+ * is located far enough to the right to clear the widest component in the left column.
+ * <li><b>Center Alignment:</b> The center rule is located at the center of the panel. The left rule
+ * is located far enough to the left to make the widest component in the left column fit.
+ * <li><b>Right Alignment</b> The center rule is located far enough to the left of the right rule to
+ * make the widest component in the right column fit. The left rule is located far enough to the
* left to make the widest component in the left column fit.
* </ul>
* All components clump together vertically and are positioned right beneath the title margin. This
* is of course not a very appealing presentation. By setting how the remaining vertical space is
* distributed above and below the cluster of components the cluster can be positioned more
* favorably (see the shaded area in the illustration).
- *
+ *
* @author Elmar Grom
* @version 0.0.1 / 11/14/02
* @see com.izforge.izpack.gui.TwoColumnConstraints
@@ -102,7 +106,9 @@
/**
* holds all the components and layout constraints.
*/
- private Vector[] components = {new Vector(), new Vector()};
+ @SuppressWarnings("unchecked")
+ private Vector<TwoColumnConstraints>[] components = new Vector[] { new Vector<TwoColumnConstraints>(),
+ new Vector<TwoColumnConstraints>() };
/**
* holds the component to be placed in the title region, including layout constraints.
@@ -129,6 +135,8 @@
*/
private int gap = 5;
+ private int colWidth;
+
private int alignment = LEFT;
private int leftRule;
@@ -142,20 +150,23 @@
/**
* Constructs a <code>TwoColumnLayout</code> layout manager. To add components use the
* container's <code>add(comp, constraints)</code> method with a TwoColumnConstraints object.
- *
- * @param margin the margin width to use on the left and right side in % of the total container
- * width. Values less than 0% and greater than 50% are not accepted.
- * @param gap the gap between the two columns.
- * @param indent the indent to use for components that have that constraint set. This is a value
- * in pixels.
+ *
+ * @param margin the margin width to use on the left and right side in % of the total container
+ * width. Values less than 0% and greater than 50% are not accepted.
+ * @param gap the gap between the two columns.
+ * @param indent the indent to use for components that have that constraint set. This is a value
+ * in pixels.
* @param topBuffer the percentage of left over vertical space to place on top of the component
- * cluster. Values between 0% and 100% are accepted.
+ * cluster. Values between 0% and 100% are accepted.
+ * @param colWidth with of the left column in percent of the whole panel. Set to 0 for automatic
+ * width.
* @param alignment how to align the overall layout. Legal values are LEFT, CENTER, RIGHT.
*/
- public TwoColumnLayout(int margin, int gap, int indent, int topBuffer, int alignment)
+ public TwoColumnLayout(int margin, int gap, int indent, int topBuffer, int colWidth, int alignment)
{
this.indent = indent;
this.gap = gap;
+ this.colWidth = colWidth;
if ((margin >= 0) && (margin <= 50))
{
@@ -172,10 +183,28 @@ public TwoColumnLayout(int margin, int gap, int indent, int topBuffer, int align
}
/**
- * Sets the constraints for the specified component in this layout. <code>null</code> is a
- * legal value for a component, but not for a constraints object.
- *
- * @param comp the component to be modified.
+ * Constructs a <code>TwoColumnLayout</code> layout manager. To add components use the
+ * container's <code>add(comp, constraints)</code> method with a TwoColumnConstraints object.
+ *
+ * @param margin the margin width to use on the left and right side in % of the total container
+ * width. Values less than 0% and greater than 50% are not accepted.
+ * @param gap the gap between the two columns.
+ * @param indent the indent to use for components that have that constraint set. This is a value
+ * in pixels.
+ * @param topBuffer the percentage of left over vertical space to place on top of the component
+ * cluster. Values between 0% and 100% are accepted.
+ * @param alignment how to align the overall layout. Legal values are LEFT, CENTER, RIGHT.
+ */
+ public TwoColumnLayout(int margin, int gap, int indent, int topBuffer, int alignment)
+ {
+ this(margin, gap, indent, topBuffer, 0, alignment);
+ }
+
+ /**
+ * Sets the constraints for the specified component in this layout. <code>null</code> is a legal
+ * value for a component, but not for a constraints object.
+ *
+ * @param comp the component to be modified.
* @param constraints the constraints to be applied.
*/
public void addLayoutComponent(Component comp, Object constraints)
@@ -310,7 +339,7 @@ else if (component.position == TwoColumnConstraints.EASTONLY)
/**
* Lays out the container in the specified panel.
- *
+ *
* @param parent the component which needs to be laid out.
*/
public void layoutContainer(Container parent)
@@ -327,7 +356,7 @@ public void layoutContainer(Container parent)
* <li><code>rightRule</code>
* <li><code>centerRule</code>
* </ul>
- *
+ *
* @param parent the component which needs to be laid out.
*/
private void positionRules(Container parent)
@@ -337,29 +366,41 @@ private void positionRules(Container parent)
if (alignment == LEFT)
{
leftRule = margin;
- centerRule = leftRule + minimumColumnWidth(LEFT, parent) + gap;
rightRule = parent.getWidth() - margin;
+ if (colWidth > 0)
+ {
+ centerRule = leftRule + (rightRule - leftRule) / 100 * colWidth + gap;
+ }
+ else
+ {
+ centerRule = leftRule + minimumColumnWidth(LEFT, parent) + gap;
+ }
}
-
else if (alignment == CENTER)
{
centerRule = (int) (parent.getMinimumSize().getWidth() / 2);
leftRule = centerRule - minimumColumnWidth(LEFT, parent) - gap;
rightRule = parent.getWidth() - margin;
}
-
else if (alignment == RIGHT)
{
rightRule = parent.getWidth() - margin;
- centerRule = rightRule - minimumColumnWidth(RIGHT, parent);
leftRule = centerRule - minimumColumnWidth(LEFT, parent) - gap;
+ if (colWidth > 0)
+ {
+ centerRule = rightRule - (rightRule - leftRule) / 100 * colWidth;
+ }
+ else
+ {
+ centerRule = rightRule - minimumColumnWidth(RIGHT, parent);
+ }
}
}
/**
* Positions the title component and sets the variable <code>titleHeight</code>. <b>Note:</b>
* this method depends on the fact that the rules are set to their correct layout position.
- *
+ *
* @param parent the component which needs to be laid out.
*/
private void positionTitle(Container parent)
@@ -400,7 +441,7 @@ else if (title.align == TwoColumnConstraints.RIGHT)
/**
* Positions all components in the container.
- *
+ *
* @param parent the component which needs to be laid out.
*/
private void positionComponents(Container parent)
@@ -451,12 +492,12 @@ else if (leftHeight < rightHeight)
}
/**
- * Positiones one component as instructed. Constraints for each component, such as
- * <code>stretch</code>, <code>BOTH</code> and <code>indent</code> are taken into
- * account. In addition, empty comonents are handled properly.
- *
- * @param y the y location within the continer, where the component should be positioned.
- * @param row the row of the component
+ * Positions one component as instructed. Constraints for each component, such as
+ * <code>stretch</code>, <code>BOTH</code> and <code>indent</code> are taken into account. In
+ * addition, empty components are handled properly.
+ *
+ * @param y the y location within the container, where the component should be positioned.
+ * @param row the row of the component
* @param column the column of the component
* @param parent the container which needs to be laid out.
*/
@@ -466,7 +507,7 @@ private void positionComponent(int y, int row, int column, Container parent)
try
{
- constraints = (TwoColumnConstraints) (components[column].elementAt(row));
+ constraints = components[column].elementAt(row);
}
catch (Throwable exception)
{
@@ -485,70 +526,94 @@ private void positionComponent(int y, int row, int column, Container parent)
// set x to the appropriate rule. The only need to
// modify this is for indent
// --------------------------------------------------
- if (column == LEFT)
+ boolean stretchBool = constraints.stretch;
+ boolean indentBool = constraints.indent;
+ int align = constraints.align;
+ if (constraints.position == TwoColumnConstraints.BOTH)
+ {
+ width = getWidth(leftRule, rightRule, stretchBool, indentBool, width);
+ if (width > (rightRule - leftRule))
+ {
+ stretchBool = true;
+ }
+ x = getPosition(leftRule, rightRule, stretchBool, indentBool, width, align);
+ }
+ else if (column == LEFT)
{
- x = leftRule;
+ width = getWidth(leftRule, centerRule, stretchBool, indentBool, width);
+ x = getPosition(leftRule, centerRule, stretchBool, indentBool, width, align);
}
else
{
- x = centerRule;
+ width = getWidth(centerRule, rightRule, stretchBool, indentBool, width);
+ x = getPosition(centerRule, rightRule, stretchBool, indentBool, width, align);
}
if (component != null)
{
- // --------------------------------------------------
- // set the width for stretch based on BOTH, LEFT and
- // RIGHT positionsing
- // --------------------------------------------------
- if ((constraints.stretch) && (constraints.position == TwoColumnConstraints.BOTH))
- {
- width = rightRule - leftRule;
- x = leftRule;
- }
- else if ((constraints.stretch) && (column == LEFT))
- {
- width = centerRule - leftRule;
- }
- else if ((constraints.stretch) && (column == RIGHT))
- {
- width = rightRule - centerRule;
- }
+ component.setBounds(x, y, width, height);
+ }
+ }
+ }
- // --------------------------------------------------
- // if we straddle both columns but are not stretching
- // use the preferred width as long as it is less then
- // the width of both columns combined. Also set the x
- // position to left, just to be sure.
- // --------------------------------------------------
- else if (constraints.position == TwoColumnConstraints.BOTH)
- {
- if (width > (rightRule - leftRule))
- {
- width = rightRule - leftRule;
- }
- x = leftRule;
- }
+ private int getWidth(int left, int right, boolean stretch, boolean indent, int componentWidth)
+ {
+ int width = componentWidth;
+ // --------------------------------------------------
+ // set the width for stretch based on BOTH, LEFT and
+ // RIGHT positioning
+ // --------------------------------------------------
+ if (stretch)
+ {
+ width = right - left;
+ }
- // --------------------------------------------------
- // correct for indent if this option is set
- // --------------------------------------------------
- if (constraints.indent)
- {
- width -= indent;
- x += indent;
- }
+ // --------------------------------------------------
+ // correct for indent if this option is set
+ // --------------------------------------------------
+ if (indent)
+ {
+ width -= this.indent;
+ }
+ return width;
+ }
- component.setBounds(x, y, width, height);
- }
+ private int getPosition(int left, int right, boolean stretch, boolean indent, int componentWidth, int align)
+ {
+ int position = left;
+
+ // --------------------------------------------------
+ // Correct position with alignment parameters
+ // --------------------------------------------------
+ if (align == TwoColumnConstraints.LEFT)
+ {
+ position = left;
}
+ else if (align == TwoColumnConstraints.CENTER)
+ {
+ position += (right - left) / 2 - componentWidth / 2 - this.gap / 2;
+ }
+ else if (align == TwoColumnConstraints.RIGHT)
+ {
+ position = right - componentWidth - this.gap;
+ }
+
+ // --------------------------------------------------
+ // correct for indent if this option is set
+ // --------------------------------------------------
+ if (indent)
+ {
+ position += this.indent;
+ }
+ return position;
}
/**
* Returns the minimum width of the column requested.
- *
+ *
* @param column the columns to measure (LEFT / RIGHT)
* @param parent the component which needs to be laid out.
- * @return the minimum width required to fis the components in this column
+ * @return the minimum width required to fits the components in this column
*/
private int minimumColumnWidth(int column, Container parent)
{
@@ -559,7 +624,7 @@ private int minimumColumnWidth(int column, Container parent)
for (int i = 0; i < components[column].size(); i++)
{
- constraints = (TwoColumnConstraints) components[column].elementAt(i);
+ constraints = components[column].elementAt(i);
if ((constraints != null) && (constraints.position != TwoColumnConstraints.BOTH))
{
@@ -584,7 +649,7 @@ private int minimumColumnWidth(int column, Container parent)
/**
* Retrunds the minimum width both columns together should have based on the minimum widths of
* all the components that straddle both columns and the minimum width of the title component.
- *
+ *
* @param parent the component which needs to be laid out.
* @return the minimum width required to fis the components in this column
*/
@@ -603,7 +668,7 @@ private int minimumBothColumnsWidth(Container parent)
for (int i = 0; i < components[LEFT].size(); i++)
{
- constraints = (TwoColumnConstraints) components[LEFT].elementAt(i);
+ constraints = components[LEFT].elementAt(i);
if ((constraints != null) && (constraints.position == TwoColumnConstraints.BOTH))
{
@@ -661,7 +726,7 @@ private int rows()
/**
* Measures and returns the minimum height required to render the components in the indicated
* row.
- *
+ *
* @param row the index of the row to measure
*/
private int rowHeight(int row)
@@ -688,10 +753,10 @@ private int rowHeight(int row)
/**
* Measures and returns the minimum height required to render the component in the indicated row
* and column.
- *
- * @param row the index of the row to measure
- * @param column the column of the component to measure (<code>LEFT</code> or
- * <code>RIGHT</code>)
+ *
+ * @param row the index of the row to measure
+ * @param column the column of the component to measure (<code>LEFT</code> or <code>RIGHT</code>
+ * )
*/
private int height(int row, int column)
{
@@ -702,7 +767,7 @@ private int height(int row, int column)
try
{
- constraints = (TwoColumnConstraints) components[column].elementAt(row);
+ constraints = components[column].elementAt(row);
if (constraints != null)
{
component = constraints.component;
@@ -749,7 +814,7 @@ else if (constraints.position == TwoColumnConstraints.BOTH)
/**
* Computes the margin value based on the container width and the margin setting.
- *
+ *
* @param parent the component which needs to be laid out.
*/
private int margin(Container parent)
@@ -761,10 +826,10 @@ private int margin(Container parent)
/**
* Computes the top buffer value based on the container width and the setting for the top buffer
- *
+ *
* @param usedHeight the amount of the parent component's height that is already in use (height
- * of the title and the combined height of all rows).
- * @param parent the component which needs to be laid out.
+ * of the title and the combined height of all rows).
+ * @param parent the component which needs to be laid out.
*/
private int topBuffer(int usedHeight, Container parent)
{
@@ -777,7 +842,7 @@ private int topBuffer(int usedHeight, Container parent)
/*--------------------------------------------------------------------------*/
/**
* Computes the indent value based on the container width and the indent setting.
- *
+ *
* @param parent the component which needs to be laid out.
*/
/*--------------------------------------------------------------------------*/
@@ -790,7 +855,7 @@ private int topBuffer(int usedHeight, Container parent)
/**
* Calculates the preferred size dimensions for the specified panel given the components in the
* specified parent container.
- *
+ *
* @param parent the component to be laid out
*/
public Dimension preferredLayoutSize(Container parent)
@@ -801,7 +866,7 @@ public Dimension preferredLayoutSize(Container parent)
/**
* Calculates the minimum size dimensions for the specified panel given the components in the
* specified parent container.
- *
+ *
* @param parent the component to be laid out
*/
public Dimension minimumLayoutSize(Container parent)
@@ -817,7 +882,7 @@ public Dimension minimumLayoutSize(Container parent)
/**
* Calculates the maximum size dimensions for the specified panel given the components in the
* specified parent container.
- *
+ *
* @param parent the component to be laid out
*/
public Dimension maximumLayoutSize(Container parent)
@@ -830,7 +895,7 @@ public Dimension maximumLayoutSize(Container parent)
* aligned relative to other components. The value should be a number between 0 and 1 where 0
* represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is
* centered, etc.
- *
+ *
* @param parent the component to be laid out
*/
public float getLayoutAlignmentX(Container parent)
@@ -843,7 +908,7 @@ public float getLayoutAlignmentX(Container parent)
* aligned relative to other components. The value should be a number between 0 and 1 where 0
* represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is
* centered, etc.
- *
+ *
* @param parent the component to be laid out
*/
public float getLayoutAlignmentY(Container parent)
@@ -854,7 +919,7 @@ public float getLayoutAlignmentY(Container parent)
/**
* Invalidates the layout, indicating that if the layout manager has cached information it
* should be discarded.
- *
+ *
* @param parent the component to be laid out
*/
public void invalidateLayout(Container parent)
@@ -868,7 +933,7 @@ public void invalidateLayout(Container parent)
/**
* Adds the specified component with the specified name to the layout. This version is not
* supported, use <code>addLayoutComponent</code> with layout contsraints.
- *
+ *
* @param name the component name
* @param comp the component to be added
*/
@@ -877,20 +942,19 @@ public void addLayoutComponent(String name, Component comp)
}
/**
- * This functionality removes the TwoColumnConstraints from Vectors
- * so that alignment of components on UserInputPanel doesn't get
- * dirty
- *
+ * This functionality removes the TwoColumnConstraints from Vectors so that alignment of
+ * components on UserInputPanel doesn't get dirty
+ *
* @param comp the component to be removed
*/
public void removeLayoutComponent(Component comp)
{
- Vector left = components[LEFT];
- Vector right = components[RIGHT];
+ Vector<TwoColumnConstraints> left = components[LEFT];
+ Vector<TwoColumnConstraints> right = components[RIGHT];
for (int i = 0; i < left.size(); i++)
{
- TwoColumnConstraints constraints = (TwoColumnConstraints) left.get(i);
+ TwoColumnConstraints constraints = left.get(i);
if (constraints == null)
{
continue;
@@ -898,7 +962,8 @@ public void removeLayoutComponent(Component comp)
Component ctemp = constraints.component;
if (ctemp != null && ctemp.equals(comp))
{
- if (constraints.position == TwoColumnConstraints.BOTH || constraints.position == TwoColumnConstraints.WESTONLY)
+ if (constraints.position == TwoColumnConstraints.BOTH
+ || constraints.position == TwoColumnConstraints.WESTONLY)
{
right.remove(i);
}
@@ -908,7 +973,7 @@ public void removeLayoutComponent(Component comp)
for (int j = 0; j < right.size(); j++)
{
- TwoColumnConstraints constraints = (TwoColumnConstraints) right.get(j);
+ TwoColumnConstraints constraints = right.get(j);
if (constraints == null)
{
continue;
@@ -916,7 +981,8 @@ public void removeLayoutComponent(Component comp)
Component ctemp = constraints.component;
if (ctemp != null && ctemp.equals(comp))
{
- if (constraints.position == TwoColumnConstraints.BOTH || constraints.position == TwoColumnConstraints.EASTONLY)
+ if (constraints.position == TwoColumnConstraints.BOTH
+ || constraints.position == TwoColumnConstraints.EASTONLY)
{
left.remove(j);
}
@@ -940,9 +1006,9 @@ public void removeLayoutComponent(Component comp)
* <b>Note:</b> cast the graphics object received in the <code>paint()</code> method to
* <code>Graphics2D</code> when making the call.<br>
* <br>
- *
+ *
* @param graphics the graphics context used for drawing.
- * @param color the color to use for rendering the layout grid
+ * @param color the color to use for rendering the layout grid
*/
public void showRules(Graphics2D graphics, Color color)
{
@@ -951,8 +1017,7 @@ public void showRules(Graphics2D graphics, Color color)
Stroke currentStroke = graphics.getStroke();
Color currentColor = graphics.getColor();
- Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.5f,
- new float[]{10, 5}, 5);
+ Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.5f, new float[] { 10, 5 }, 5);
graphics.setColor(color);
graphics.drawLine(leftRule, 0, leftRule, height);
View
62 izpack-src/trunk/src/lib/com/izforge/izpack/panels/FileInputField.java
@@ -21,18 +21,26 @@
package com.izforge.izpack.panels;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.util.List;
+
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
import com.izforge.izpack.gui.ButtonFactory;
import com.izforge.izpack.installer.InstallData;
import com.izforge.izpack.installer.InstallerFrame;
import com.izforge.izpack.installer.IzPanel;
import com.izforge.izpack.util.Debug;
-import javax.swing.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.File;
-import java.util.List;
-
public class FileInputField extends JPanel implements ActionListener
{
@@ -62,14 +70,14 @@
protected static final int INVALID = 0, EMPTY = 1;
- public FileInputField(IzPanel parent, InstallData data, boolean directory, String set,
- int size, List<ValidatorContainer> validatorConfig)
+ public FileInputField(IzPanel parent, InstallData data, boolean directory, String set, int size,
+ List<ValidatorContainer> validatorConfig)
{
this(parent, data, directory, set, size, validatorConfig, null, null);
}
- public FileInputField(IzPanel parent, InstallData data, boolean directory, String set,
- int size, List<ValidatorContainer> validatorConfig, String fileExt, String fileExtDesc)
+ public FileInputField(IzPanel parent, InstallData data, boolean directory, String set, int size,
+ List<ValidatorContainer> validatorConfig, String fileExt, String fileExtDesc)
{
this.parent = parent;
this.parentFrame = parent.getInstallerFrame();
@@ -87,12 +95,24 @@ private void initialize()
filetxt = new JTextField(set, size);
filetxt.setCaretPosition(0);
+ GridBagLayout layout = new GridBagLayout();
+ setLayout(layout);
+ GridBagConstraints fileTextConstraint = new GridBagConstraints();
+ GridBagConstraints fileButtonConstraint = new GridBagConstraints();
+ fileTextConstraint.gridx = 0;
+ fileTextConstraint.gridy = 0;
+ fileTextConstraint.anchor = GridBagConstraints.WEST;
+ fileTextConstraint.insets = new Insets(0, 0, 0, 5);
+ fileButtonConstraint.gridx = 1;
+ fileButtonConstraint.gridy = 0;
+ fileButtonConstraint.anchor = GridBagConstraints.WEST;
+
// TODO: use separate key for button text
- browseBtn = ButtonFactory.createButton(data.langpack
- .getString("UserInputPanel.search.browse"), data.buttonsHColor);
+ browseBtn = ButtonFactory.createButton(data.langpack.getString("UserInputPanel.search.browse"),
+ data.buttonsHColor);
browseBtn.addActionListener(this);
- this.add(filetxt);
- this.add(browseBtn);
+ this.add(filetxt, fileTextConstraint);
+ this.add(browseBtn, fileButtonConstraint);
}
public void setFile(String filename)
@@ -158,9 +178,9 @@ else if (k == EMPTY)
protected void showMessage(String messageType)
{
- JOptionPane.showMessageDialog(parentFrame, parentFrame.langpack.getString("UserInputPanel."
- + messageType + ".message"), parentFrame.langpack.getString("UserInputPanel."
- + messageType + ".caption"), JOptionPane.WARNING_MESSAGE);
+ JOptionPane.showMessageDialog(parentFrame, parentFrame.langpack.getString("UserInputPanel." + messageType
+ + ".message"), parentFrame.langpack.getString("UserInputPanel." + messageType + ".caption"),
+ JOptionPane.WARNING_MESSAGE);
}
public boolean validateField()
@@ -194,15 +214,13 @@ else if (input != null)
}
else
{
- StringInputProcessingClient processingClient = new StringInputProcessingClient(
- input, validators);
+ StringInputProcessingClient processingClient = new StringInputProcessingClient(input, validators);
boolean success = processingClient.validate();
if (!success)
{
JOptionPane
- .showMessageDialog(parentFrame,
- processingClient.getValidationMessage(), parentFrame.langpack
- .getString("UserInputPanel.error.caption"),
+ .showMessageDialog(parentFrame, processingClient.getValidationMessage(),
+ parentFrame.langpack.getString("UserInputPanel.error.caption"),
JOptionPane.WARNING_MESSAGE);
}
result = success;
View
467 izpack-src/trunk/src/lib/com/izforge/izpack/panels/UserInputPanel.java
@@ -20,6 +20,49 @@
package com.izforge.izpack.panels;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.io.File;
+import java.io.InputStream;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import javax.swing.BorderFactory;
+import javax.swing.ButtonGroup;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JPasswordField;
+import javax.swing.JRadioButton;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.border.Border;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.filechooser.FileFilter;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import javax.swing.text.JTextComponent;
+
import com.izforge.izpack.LocaleDatabase;
import com.izforge.izpack.Pack;
import com.izforge.izpack.Panel;
@@ -29,28 +72,19 @@
import com.izforge.izpack.gui.ButtonFactory;
import com.izforge.izpack.gui.LabelFactory;
import com.izforge.izpack.gui.TwoColumnConstraints;
+import com.izforge.izpack.gui.TwoColumnConstraintsFactory;
import com.izforge.izpack.gui.TwoColumnLayout;
-import com.izforge.izpack.installer.*;
+import com.izforge.izpack.installer.InstallData;
+import com.izforge.izpack.installer.InstallerFrame;
+import com.izforge.izpack.installer.IzPanel;
+import com.izforge.izpack.installer.ResourceManager;
+import com.izforge.izpack.installer.ResourceNotFoundException;
import com.izforge.izpack.rules.RulesEngine;
-import com.izforge.izpack.rules.VariableExistenceCondition;
-import com.izforge.izpack.util.*;
-
-import javax.swing.*;
-import javax.swing.border.Border;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.filechooser.FileFilter;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.Document;
-import javax.swing.text.JTextComponent;
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.event.*;
-import java.io.File;
-import java.io.InputStream;
-import java.text.MessageFormat;
-import java.util.*;
+import com.izforge.izpack.util.Debug;
+import com.izforge.izpack.util.HyperlinkHandler;
+import com.izforge.izpack.util.OsConstraint;
+import com.izforge.izpack.util.OsVersion;
+import com.izforge.izpack.util.VariableSubstitutor;
public class UserInputPanel extends IzPanel implements ActionListener, ItemListener, FocusListener
{
@@ -80,6 +114,8 @@
protected static final String PANEL_IDENTIFIER = "id";
+ protected static final String BORDER_IDENTIFIER = "border";
+
private static final String TYPE = "type";
private static final String DESCRIPTION = "description";
@@ -98,18 +134,14 @@
private static final String TOPBUFFER = "topBuffer";
+ private static final String COLUMN_WIDTH = "column_width";
+
private static final String TRUE = "true";
private static final String FALSE = "false";
private static final String ALIGNMENT = "align";
- private static final String LEFT = "left";
-
- private static final String CENTER = "center";
-
- private static final String RIGHT = "right";
-
private static final String TOP = "top";
private static final String ITALICS = "italic";
@@ -290,6 +322,8 @@
private JPanel panel;
+ private boolean showBorder = true;
+
/*--------------------------------------------------------------------------*/
// This method can be used to search for layout problems. If this class is
// compiled with this method uncommented, the layout guides will be shown
@@ -304,7 +338,7 @@
/*--------------------------------------------------------------------------*/
/**
* Constructs a <code>UserInputPanel</code>.
- *
+ *
* @param parent reference to the application frame
* @param installData shared information about the installation
*/
@@ -316,18 +350,6 @@ public UserInputPanel(InstallerFrame parent, InstallData installData)
this.parentFrame = parent;
}
- private void createBuiltInVariableConditions(String variable)
- {
- if (variable != null)
- {
- VariableExistenceCondition variableCondition = new VariableExistenceCondition();
- variableCondition.setId("izpack.input." + variable);
- variableCondition.setInstalldata(idata);
- variableCondition.setVariable(variable);
- parent.getRules().addCondition(variableCondition);
- }
- }
-
protected void init()
{
eventsActivated = false;
@@ -354,7 +376,6 @@ protected void init()
e.printStackTrace();
}
-
// ----------------------------------------------------
// read the specifications
// ----------------------------------------------------
@@ -375,6 +396,7 @@ protected void init()
// same panel)
// ----------------------------------------------------
int topbuff = 25;
+ int colWidth = 0;
try
{
topbuff = Integer.parseInt(spec.getAttribute(TOPBUFFER));
@@ -382,10 +404,15 @@ protected void init()
catch (Exception ex)
{
}
- finally
+ try
{
- layout = new TwoColumnLayout(10, 5, 30, topbuff, TwoColumnLayout.LEFT);
+ colWidth = Integer.parseInt(spec.getAttribute(COLUMN_WIDTH));
}
+ catch (Exception ex)
+ {
+ }
+
+ layout = new TwoColumnLayout(10, 5, 30, topbuff, colWidth, TwoColumnLayout.LEFT);
setLayout(new BorderLayout());
panel = new JPanel();
@@ -413,12 +440,6 @@ protected void init()
{
IXMLElement field = fields.elementAt(i);
String attribute = field.getAttribute(TYPE);
- String associatedVariable = field.getAttribute(VARIABLE);
- if (associatedVariable != null)
- {
- // create automatic existence condition
- createBuiltInVariableConditions(associatedVariable);
- }
String conditionid = field.getAttribute(ATTRIBUTE_CONDITIONID_NAME);
if (conditionid != null)
@@ -596,30 +617,29 @@ private void addDirectoryField(IXMLElement field)
size = 1;
}
- allowEmptyValue = Boolean
- .parseBoolean(element.getAttribute("allowEmptyValue", "false"));
+ allowEmptyValue = Boolean.parseBoolean(element.getAttribute("allowEmptyValue", "false"));
mustExist = Boolean.parseBoolean(element.getAttribute("mustExist", "true"));
create = Boolean.parseBoolean(element.getAttribute("create", "false"));
}
validatorConfig = analyzeValidator(field);
- TwoColumnConstraints constraints = new TwoColumnConstraints();
- constraints.position = TwoColumnConstraints.WEST;
+ if (label.getText() == null || label.getText().length() > 0)
+ {
+ TwoColumnConstraints constraints = TwoColumnConstraintsFactory.createLabelConstraint(field);
- UIElement labelUiElement = new UIElement();
- labelUiElement.setType(UIElementType.LABEL);
- labelUiElement.setConstraints(constraints);
- labelUiElement.setComponent(label);
- labelUiElement.setForPacks(forPacks);
- labelUiElement.setForOs(forOs);
- elements.add(labelUiElement);
+ UIElement labelUiElement = new UIElement();
+ labelUiElement.setType(UIElementType.LABEL);
+ labelUiElement.setConstraints(constraints);
+ labelUiElement.setComponent(label);
+ labelUiElement.setForPacks(forPacks);
+ labelUiElement.setForOs(forOs);
+ elements.add(labelUiElement);
+ }
- TwoColumnConstraints constraints2 = new TwoColumnConstraints();
- constraints2.position = TwoColumnConstraints.EAST;
+ TwoColumnConstraints constraints2 = TwoColumnConstraintsFactory.createControlConstraint(field);
- FileInputField fileInput = new DirInputField(this, idata, true, set, size,
- validatorConfig, mustExist, create);
+ FileInputField fileInput = new DirInputField(this, idata, true, set, size, validatorConfig, mustExist, create);
fileInput.setAllowEmptyInput(allowEmptyValue);
@@ -748,20 +768,17 @@ private void addMultipleFileField(IXMLElement field)
}
}
- createMultipleVariables = Boolean.parseBoolean(element.getAttribute(
- "multipleVariables", "false"));
- allowEmptyValue = Boolean
- .parseBoolean(element.getAttribute("allowEmptyValue", "false"));
+ createMultipleVariables = Boolean.parseBoolean(element.getAttribute("multipleVariables", "false"));
+ allowEmptyValue = Boolean.parseBoolean(element.getAttribute("allowEmptyValue", "false"));
}
List<ValidatorContainer> validatorConfig = analyzeValidator(field);
- TwoColumnConstraints constraints2 = new TwoColumnConstraints();
- constraints2.position = TwoColumnConstraints.EAST;
+ TwoColumnConstraints constraints2 = TwoColumnConstraintsFactory.createControlConstraint(field);
- MultipleFileInputField fileInputField = new MultipleFileInputField(parentFrame, idata,
- false, set, size, validatorConfig, filter, filterdesc, createMultipleVariables,
- visibleRows, preferredX, preferredY, labelText);
+ MultipleFileInputField fileInputField = new MultipleFileInputField(parentFrame, idata, false, set, size,
+ validatorConfig, filter, filterdesc, createMultipleVariables, visibleRows, preferredX, preferredY,
+ labelText);
fileInputField.setAllowEmptyInput(allowEmptyValue);
UIElement fileUiElement = new UIElement();
@@ -847,28 +864,27 @@ private void addFileField(IXMLElement field)
// internationalize it
filterdesc = idata.langpack.getString(filterdesc);
- allowEmptyValue = Boolean
- .parseBoolean(element.getAttribute("allowEmptyValue", "false"));
+ allowEmptyValue = Boolean.parseBoolean(element.getAttribute("allowEmptyValue", "false"));
}
List<ValidatorContainer> validatorConfig = analyzeValidator(field);
- TwoColumnConstraints constraints = new TwoColumnConstraints();
- constraints.position = TwoColumnConstraints.WEST;
-
- UIElement labelUiElement = new UIElement();
- labelUiElement.setType(UIElementType.LABEL);
- labelUiElement.setConstraints(constraints);
- labelUiElement.setComponent(label);
- labelUiElement.setForPacks(forPacks);
- labelUiElement.setForOs(forOs);
- elements.add(labelUiElement);
+ if (label.getText() == null || label.getText().length() > 0)
+ {
+ TwoColumnConstraints constraints = TwoColumnConstraintsFactory.createLabelConstraint(field);
- TwoColumnConstraints constraints2 = new TwoColumnConstraints();
- constraints2.position = TwoColumnConstraints.EAST;
+ UIElement labelUiElement = new UIElement();
+ labelUiElement.setType(UIElementType.LABEL);
+ labelUiElement.setConstraints(constraints);
+ labelUiElement.setComponent(label);
+ labelUiElement.setForPacks(forPacks);
+ labelUiElement.setForOs(forOs);
+ elements.add(labelUiElement);
+ }
- FileInputField fileInputField = new FileInputField(this, idata, false, set, size,
- validatorConfig, filter, filterdesc);
+ TwoColumnConstraints constraints2 = TwoColumnConstraintsFactory.createControlConstraint(field);
+ FileInputField fileInputField = new FileInputField(this, idata, false, set, size, validatorConfig, filter,
+ filterdesc);
fileInputField.setAllowEmptyInput(allowEmptyValue);
@@ -945,8 +961,7 @@ else if (element.getType() == UIElementType.RULE)
}
else if (element.getType() == UIElementType.MULTIPLE_FILE)
{
- MultipleFileInputField multifile = (MultipleFileInputField) element
- .getComponent();
+ MultipleFileInputField multifile = (MultipleFileInputField) element.getComponent();
if (value != null)
{
multifile.clearFiles();
@@ -1012,7 +1027,7 @@ else if (element.getType() == UIElementType.DIRECTORY)
* Indicates wether the panel has been validated or not. The installer won't let the user go
* further through the installation process until the panel is validated. Default behavior is to
* return true.
- *
+ *
* @return A boolean stating wether the panel has been validated or not.
*/
/*--------------------------------------------------------------------------*/
@@ -1043,8 +1058,7 @@ public void panelActivate()
Vector<IXMLElement> forUnselectedPacks = spec.getChildrenNamed(UNSELECTEDPACKS);
Vector<IXMLElement> forOs = spec.getChildrenNamed(OS);
- if (!itemRequiredFor(forPacks) || !itemRequiredForUnselected(forUnselectedPacks)
- || !itemRequiredForOs(forOs))
+ if (!itemRequiredFor(forPacks) || !itemRequiredForUnselected(forUnselectedPacks) || !itemRequiredForOs(forOs))
{
parentFrame.skipPanel();
return;
@@ -1120,6 +1134,10 @@ private void buildUI()
scroller.setViewportBorder(emptyBorder);
scroller.getVerticalScrollBar().setBorder(emptyBorder);
scroller.getHorizontalScrollBar().setBorder(emptyBorder);
+ if (!showBorder)
+ {
+ scroller.setBorder(emptyBorder);
+ }
add(scroller, BorderLayout.CENTER);
}
@@ -1198,10 +1216,9 @@ private boolean readDirectoryField(UIElement field)
result = panel.validateField();
if (result)
{
- idata.setVariable(field.getAssociatedVariable(), panel.getSelectedFile()
- .getAbsolutePath());
- entries.add(new TextValuePair(field.getAssociatedVariable(), panel
- .getSelectedFile().getAbsolutePath()));
+ idata.setVariable(field.getAssociatedVariable(), panel.getSelectedFile().getAbsolutePath());
+ entries
+ .add(new TextValuePair(field.getAssociatedVariable(), panel.getSelectedFile().getAbsolutePath()));
}
}
catch (Exception e)
@@ -1223,10 +1240,9 @@ private boolean readFileField(UIElement field)
result = input.validateField();
if (result)
{
- idata.setVariable(field.getAssociatedVariable(), input.getSelectedFile()
- .getAbsolutePath());
- entries.add(new TextValuePair(field.getAssociatedVariable(), input
- .getSelectedFile().getAbsolutePath()));
+ idata.setVariable(field.getAssociatedVariable(), input.getSelectedFile().getAbsolutePath());
+ entries
+ .add(new TextValuePair(field.getAssociatedVariable(), input.getSelectedFile().getAbsolutePath()));
}
}
catch (Exception e)
@@ -1342,10 +1358,18 @@ private void readSpec() throws Exception
data = specElements.elementAt(i);
attribute = data.getAttribute(INSTANCE_IDENTIFIER);
panelattribute = data.getAttribute(PANEL_IDENTIFIER);
+ String border = data.getAttribute(BORDER_IDENTIFIER);
+ if (border != null && border.equalsIgnoreCase("false"))
+ {
+ showBorder = false;
+ }
+ else
+ {
+ showBorder = true;
+ }
if (((attribute != null) && instance.equals(attribute))
- || ((panelattribute != null) && (panelid != null) && (panelid
- .equals(panelattribute))))
+ || ((panelattribute != null) && (panelid != null) && (panelid.equals(panelattribute))))
{
// use the current element as spec
spec = data;
@@ -1378,7 +1402,6 @@ private void addTitle(IXMLElement spec)
boolean italic = getBoolean(spec, ITALICS, false);
boolean bold = getBoolean(spec, BOLD, false);
float multiplier = getFloat(spec, SIZE, 2.0f);
- int justify = getAlignment(spec);
String icon = getIconName(spec);
@@ -1413,9 +1436,8 @@ private void addTitle(IXMLElement spec)
label.setFont(font);
label.setAlignmentX(0);
- TwoColumnConstraints constraints = new TwoColumnConstraints();
- constraints.align = justify;
- constraints.position = TwoColumnConstraints.NORTH;
+ TwoColumnConstraints constraints = TwoColumnConstraintsFactory.createTextConstraint(spec,
+ TwoColumnConstraints.NORTH, false, false);
panel.add(label, constraints);
}
@@ -1576,28 +1598,29 @@ else if (format.equals(RULE_ENCRYPTED))
// ----------------------------------------------------
if (hasParams)
{
- field = new RuleInputField(layout, set, separator, validator, validateParamMap,
- processor, resultFormat, getToolkit(), idata);
+ field = new RuleInputField(layout, set, separator, validator, validateParamMap, processor, resultFormat,
+ getToolkit(), idata);
}
else
{
- field = new RuleInputField(layout, set, separator, validator, processor, resultFormat,
- getToolkit(), idata);
+ field = new RuleInputField(layout, set, separator, validator, processor, resultFormat, getToolkit(), idata);
}
- TwoColumnConstraints constraints = new TwoColumnConstraints();
- constraints.position = TwoColumnConstraints.WEST;
- UIElement labelUiElement = new UIElement();
- labelUiElement.setType(UIElementType.LABEL);
- labelUiElement.setConstraints(constraints);
- labelUiElement.setComponent(label);
- labelUiElement.setForPacks(forPacks);
- labelUiElement.setForOs(forOs);
- elements.add(labelUiElement);
+ if (label.getText() == null || label.getText().length() > 0)
+ {
+ TwoColumnConstraints constraints = TwoColumnConstraintsFactory.createLabelConstraint(spec);
+
+ UIElement labelUiElement = new UIElement();
+ labelUiElement.setType(UIElementType.LABEL);
+ labelUiElement.setConstraints(constraints);
+ labelUiElement.setComponent(label);
+ labelUiElement.setForPacks(forPacks);
+ labelUiElement.setForOs(forOs);
+ elements.add(labelUiElement);
+ }
- TwoColumnConstraints constraints2 = new TwoColumnConstraints();
- constraints2.position = TwoColumnConstraints.EAST;
+ TwoColumnConstraints constraints2 = TwoColumnConstraintsFactory.createControlConstraint(spec);
UIElement ruleField = new UIElement();
ruleField.setType(UIElementType.RULE);
@@ -1779,22 +1802,24 @@ private void addTextField(IXMLElement spec)
inputField = new TextInputField(set, size, validator);
}
inputField.addFocusListener(this);
- TwoColumnConstraints constraints = new TwoColumnConstraints();
- constraints.position = TwoColumnConstraints.WEST;
- UIElement labelUiElement = new UIElement();
- labelUiElement.setType(UIElementType.LABEL);
- labelUiElement.setConstraints(constraints);
- labelUiElement.setComponent(label);
- labelUiElement.setForPacks(forPacks);
- labelUiElement.setForOs(forOs);
- elements.add(labelUiElement);
+ if (label.getText() == null || label.getText().length() > 0)
+ {
+ TwoColumnConstraints constraints = TwoColumnConstraintsFactory.createLabelConstraint(spec);
+
+ UIElement labelUiElement = new UIElement();
+ labelUiElement.setType(UIElementType.LABEL);
+ labelUiElement.setConstraints(constraints);
+ labelUiElement.setComponent(label);
+ labelUiElement.setForPacks(forPacks);
+ labelUiElement.setForOs(forOs);
+ elements.add(labelUiElement);
+ }
// uiElements
// .add(new Object[] { null, FIELD_LABEL, null, constraints, label, forPacks, forOs});
- TwoColumnConstraints constraints2 = new TwoColumnConstraints();
- constraints2.position = TwoColumnConstraints.EAST;
+ TwoColumnConstraints constraints2 = TwoColumnConstraintsFactory.createControlConstraint(spec);
UIElement textUiElement = new UIElement();
textUiElement.setType(UIElementType.TEXT);
@@ -1885,7 +1910,7 @@ private boolean readTextField(UIElement field)
* &lt;p/&gt;
* &lt;p/&gt;
* </pre>
- *
+ *
* @param spec a <code>IXMLElement</code> containing the specification for the combo box.
*/
/*--------------------------------------------------------------------------*/
@@ -1929,8 +1954,7 @@ private void addComboBox(IXMLElement spec)
String choiceValues = "";
try
{
- choiceValues = ((Processor) Class.forName(processorClass).newInstance())
- .process(null);
+ choiceValues = ((Processor) Class.forName(processorClass).newInstance()).process(null);
}
catch (Throwable t)
{
@@ -1969,8 +1993,7 @@ private void addComboBox(IXMLElement spec)
if (userinput)
{
// is the current value identical to the value associated with this element
- if ((value != null) && (value.length() > 0)
- && (currentvariablevalue.equals(value)))
+ if ((value != null) && (value.length() > 0) && (currentvariablevalue.equals(value)))
{
// select it
field.setSelectedIndex(i);
@@ -1985,8 +2008,7 @@ private void addComboBox(IXMLElement spec)
{
if (set != null && !"".equals(set))
{
- VariableSubstitutor vs = new VariableSubstitutor(idata
- .getVariables());
+ VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
set = vs.substitute(set, null);
}
if (set.equals(TRUE))
@@ -2015,22 +2037,23 @@ private void addComboBox(IXMLElement spec)
element = spec.getFirstChildNamed(DESCRIPTION);
addDescription(element, forPacks, forOs);
- TwoColumnConstraints constraints = new TwoColumnConstraints();
- constraints.position = TwoColumnConstraints.WEST;
+ if (label.getText() == null || label.getText().length() > 0)
+ {
+ TwoColumnConstraints constraints = TwoColumnConstraintsFactory.createLabelConstraint(spec);
- UIElement labelUiElement = new UIElement();
- labelUiElement.setType(UIElementType.LABEL);
- labelUiElement.setConstraints(constraints);
- labelUiElement.setComponent(label);
- labelUiElement.setForPacks(forPacks);
- labelUiElement.setForOs(forOs);
- elements.add(labelUiElement);
+ UIElement labelUiElement = new UIElement();
+ labelUiElement.setType(UIElementType.LABEL);
+ labelUiElement.setConstraints(constraints);
+ labelUiElement.setComponent(label);
+ labelUiElement.setForPacks(forPacks);
+ labelUiElement.setForOs(forOs);
+ elements.add(labelUiElement);
+ }
// uiElements
// .add(new Object[] { null, FIELD_LABEL, null, constraints, label, forPacks, forOs});
- TwoColumnConstraints constraints2 = new TwoColumnConstraints();
- constraints2.position = TwoColumnConstraints.EAST;
+ TwoColumnConstraints constraints2 = TwoColumnConstraintsFactory.createControlConstraint(spec);
UIElement comboUiElement = new UIElement();
comboUiElement.setType(UIElementType.COMBOBOX);
@@ -2104,7 +2127,7 @@ private boolean readComboBox(UIElement field)
* &lt;p/&gt;
* &lt;p/&gt;
* </pre>
- *
+ *
* @param spec a <code>IXMLElement</code> containing the specification for the radio button set.
*/
/*--------------------------------------------------------------------------*/
@@ -2118,10 +2141,8 @@ private void addRadioButton(IXMLElement spec)
IXMLElement element = null;
ButtonGroup group = new ButtonGroup();
- TwoColumnConstraints constraints = new TwoColumnConstraints();
- constraints.position = TwoColumnConstraints.BOTH;
- constraints.indent = true;
- constraints.stretch = true;
+ TwoColumnConstraints constraints = TwoColumnConstraintsFactory.createControlConstraint(spec,
+ TwoColumnConstraints.BOTH, true, true);
// ----------------------------------------------------
// get the description and add it to the list of UI
@@ -2360,22 +2381,23 @@ private void addPasswordField(IXMLElement spec)
JPasswordField field = new JPasswordField(set, size);
field.setCaretPosition(0);
- TwoColumnConstraints constraints = new TwoColumnConstraints();
- constraints.position = TwoColumnConstraints.WEST;
-
- UIElement labelUiElement = new UIElement();
- labelUiElement.setType(UIElementType.LABEL);
- labelUiElement.setConstraints(constraints);
- labelUiElement.setComponent(label);
- labelUiElement.setForPacks(forPacks);
- labelUiElement.setForOs(forOs);
- elements.add(labelUiElement);
+ if (label.getText() == null || label.getText().length() > 0)
+ {
+ TwoColumnConstraints constraints = TwoColumnConstraintsFactory.createLabelConstraint(spec);
+
+ UIElement labelUiElement = new UIElement();
+ labelUiElement.setType(UIElementType.LABEL);
+ labelUiElement.setConstraints(constraints);
+ labelUiElement.setComponent(label);
+ labelUiElement.setForPacks(forPacks);
+ labelUiElement.setForOs(forOs);
+ elements.add(labelUiElement);
+ }
// uiElements.add(new Object[] { null, FIELD_LABEL, null, constraints, label,
// forPacks, forOs});
- TwoColumnConstraints constraints2 = new TwoColumnConstraints();
- constraints2.position = TwoColumnConstraints.EAST;
+ TwoColumnConstraints constraints2 = TwoColumnConstraintsFactory.createControlConstraint(spec);
PasswordUIElement passwordUiElement = new PasswordUIElement();
passwordUiElement.setType(UIElementType.PASSWORD);
@@ -2447,9 +2469,8 @@ private boolean readPasswordField(UIElement field)
success = group.validateContents(i);
if (!success)
{
- JOptionPane.showMessageDialog(parentFrame, group.getValidatorMessage(i),
- parentFrame.langpack.getString("UserInputPanel.error.caption"),
- JOptionPane.WARNING_MESSAGE);
+ JOptionPane.showMessageDialog(parentFrame, group.getValidatorMessage(i), parentFrame.langpack
+ .getString("UserInputPanel.error.caption"), JOptionPane.WARNING_MESSAGE);
break;
}
}
@@ -2508,7 +2529,7 @@ private void addCheckBox(IXMLElement spec)
JCheckBox checkbox = new JCheckBox(label);
// What are we doing here anyway??? BDA 20090518
- //checkbox.addItemListener(this);
+ // checkbox.addItemListener(this);
if (causesValidataion != null && causesValidataion.equals("yes"))
{
@@ -2538,10 +2559,8 @@ private void addCheckBox(IXMLElement spec)
IXMLElement element = spec.getFirstChildNamed(DESCRIPTION);
addDescription(element, forPacks, forOs);
- TwoColumnConstraints constraints = new TwoColumnConstraints();
- constraints.position = TwoColumnConstraints.BOTH;
- constraints.stretch = true;
- constraints.indent = true;
+ TwoColumnConstraints constraints = TwoColumnConstraintsFactory.createControlConstraint(spec,
+ TwoColumnConstraints.BOTH, true, true);
UIElement checkboxUiElement = new UIElement();
checkboxUiElement.setType(UIElementType.CHECKBOX);
@@ -2762,30 +2781,30 @@ else if (result_type_str.equals(SEARCH_PARENTDIR))
element = spec.getFirstChildNamed(DESCRIPTION);
addDescription(element, forPacks, forOs);
- TwoColumnConstraints westconstraint1 = new TwoColumnConstraints();
- westconstraint1.position = TwoColumnConstraints.WEST;
+ if (label.getText() == null || label.getText().length() > 0)
+ {
+ TwoColumnConstraints westconstraint1 = TwoColumnConstraintsFactory.createLabelConstraint(spec);
- UIElement labelUiElement = new UIElement();
- labelUiElement.setType(UIElementType.LABEL);
- labelUiElement.setConstraints(westconstraint1);
- labelUiElement.setComponent(label);
- labelUiElement.setForPacks(forPacks);
- labelUiElement.setForOs(forOs);
- elements.add(labelUiElement);
+ UIElement labelUiElement = new UIElement();
+ labelUiElement.setType(UIElementType.LABEL);
+ labelUiElement.setConstraints(westconstraint1);
+ labelUiElement.setComponent(label);
+ labelUiElement.setForPacks(forPacks);
+ labelUiElement.setForOs(forOs);
+ elements.add(labelUiElement);
+ }
// uiElements.add(new Object[] { null, FIELD_LABEL, null, westconstraint1, label, forPacks,
// forOs});
- TwoColumnConstraints eastconstraint1 = new TwoColumnConstraints();
- eastconstraint1.position = TwoColumnConstraints.EAST;
+ TwoColumnConstraints eastconstraint1 = TwoColumnConstraintsFactory.createControlConstraint(spec);
StringBuffer tooltiptext = new StringBuffer();
if ((filename != null) && (filename.length() > 0))
{
- tooltiptext.append(MessageFormat.format(parentFrame.langpack
- .getString("UserInputPanel.search.location"),
- new Object[]{new String[]{filename}}));
+ tooltiptext.append(MessageFormat.format(parentFrame.langpack.getString("UserInputPanel.search.location"),
+ new Object[] { new String[] { filename } }));
}
boolean showAutodetect = (check_filename != null) && (check_filename.length() > 0);
@@ -2793,7 +2812,7 @@ else if (result_type_str.equals(SEARCH_PARENTDIR))
{
tooltiptext.append(MessageFormat.format(parentFrame.langpack
.getString("UserInputPanel.search.location.checkedfile"),
- new Object[]{new String[]{check_filename}}));
+ new Object[] { new String[] { check_filename } }));
}
if (tooltiptext.length() > 0)
@@ -2814,15 +2833,13 @@ else if (result_type_str.equals(SEARCH_PARENTDIR))
// forPacks, forOs});
JPanel buttonPanel = new JPanel();
- buttonPanel.setLayout(new com.izforge.izpack.gui.FlowLayout(
- com.izforge.izpack.gui.FlowLayout.LEADING));
+ buttonPanel.setLayout(new com.izforge.izpack.gui.FlowLayout(com.izforge.izpack.gui.FlowLayout.LEADING));
JButton autodetectButton = ButtonFactory.createButton(parentFrame.langpack
.getString("UserInputPanel.search.autodetect"), idata.buttonsHColor);
autodetectButton.setVisible(showAutodetect);
- autodetectButton.setToolTipText(parentFrame.langpack
- .getString("UserInputPanel.search.autodetect.tooltip"));
+ autodetectButton.setToolTipText(parentFrame.langpack.getString("UserInputPanel.search.autodetect.tooltip"));
buttonPanel.add(autodetectButton);
@@ -2831,7 +2848,8 @@ else if (result_type_str.equals(SEARCH_PARENTDIR))
buttonPanel.add(browseButton);
- TwoColumnConstraints eastonlyconstraint = new TwoColumnConstraints();
+ TwoColumnConstraints eastonlyconstraint = TwoColumnConstraintsFactory.createControlConstraint(spec,
+ TwoColumnConstraints.EASTONLY, false, false);
eastonlyconstraint.position = TwoColumnConstraints.EASTONLY;
UIElement searchbuttonUiElement = new UIElement();
@@ -2845,8 +2863,8 @@ else if (result_type_str.equals(SEARCH_PARENTDIR))
// uiElements.add(new Object[] { null, SEARCH_BUTTON_FIELD, null, eastonlyconstraint,
// buttonPanel, forPacks, forOs});
- searchFields.add(new SearchField(filename, check_filename, parentFrame, combobox,
- autodetectButton, browseButton, search_type, result_type));
+ searchFields.add(new SearchField(filename, check_filename, parentFrame, combobox, autodetectButton,
+ browseButton, search_type, result_type));
}
/*--------------------------------------------------------------------------*/
@@ -2922,9 +2940,8 @@ private void addSpace(IXMLElement spec)
Vector<IXMLElement> forOs = spec.getChildrenNamed(OS);
JPanel panel = new JPanel();
- TwoColumnConstraints constraints = new TwoColumnConstraints();
- constraints.position = TwoColumnConstraints.BOTH;
- constraints.stretch = true;
+ TwoColumnConstraints constraints = TwoColumnConstraintsFactory.createControlConstraint(spec,
+ TwoColumnConstraints.BOTH, false, true);
UIElement spaceUiElement = new UIElement();
spaceUiElement.setType(UIElementType.SPACE);
@@ -2968,9 +2985,8 @@ private void addDivider(IXMLElement spec)
panel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray));
}
- TwoColumnConstraints constraints = new TwoColumnConstraints();
- constraints.position = TwoColumnConstraints.BOTH;
- constraints.stretch = true;
+ TwoColumnConstraints constraints = TwoColumnConstraintsFactory.createControlConstraint(spec,
+ TwoColumnConstraints.BOTH, false, true);
UIElement dividerUiElement = new UIElement();
dividerUiElement.setType(UIElementType.DIVIDER);
@@ -2991,13 +3007,10 @@ private void addDivider(IXMLElement spec)
* @param spec a <code>IXMLElement</code> containing the specification for the description.
*/
/*--------------------------------------------------------------------------*/
- private void addDescription(IXMLElement spec, Vector<IXMLElement> forPacks,
- Vector<IXMLElement> forOs)
+ private void addDescription(IXMLElement spec, Vector<IXMLElement> forPacks, Vector<IXMLElement> forOs)
{
String description;
- TwoColumnConstraints constraints = new TwoColumnConstraints();
- constraints.position = TwoColumnConstraints.BOTH;
- constraints.stretch = true;
+ TwoColumnConstraints constraints = TwoColumnConstraintsFactory.createTextConstraint(spec);
if (spec != null)
{
@@ -3379,7 +3392,7 @@ private boolean itemRequiredFor(Vector<IXMLElement> packs)
/*--------------------------------------------------------------------------*/
/*
* $ @design
- *
+ *
* The information about the installed packs comes from InstallData.selectedPacks. This assumes
* that this panel is presented to the user AFTER the PacksPanel.
* --------------------------------------------------------------------------
@@ -3419,7 +3432,7 @@ private boolean itemRequiredForUnselected(Vector<IXMLElement> packs)
// ----------- Inheritance stuff -----------------------------------------
/**
* Returns the uiElements.
- *
+ *
* @return Returns the uiElements.
*/
// protected Vector<Object[]> getUiElements()
@@ -3459,7 +3472,7 @@ public TextValuePair(String text, String value)
/*--------------------------------------------------------------------------*/
/**
* Sets the text
- *
+ *
* @param text the text for this object
*/
/*--------------------------------------------------------------------------*/
@@ -3483,7 +3496,7 @@ public void setValue(String value)
/*--------------------------------------------------------------------------*/
/**
* This method returns the text that was set for the object
- *
+ *
* @return the object's text
*/
/*--------------------------------------------------------------------------*/
@@ -3495,7 +3508,7 @@ public String toString()
/*--------------------------------------------------------------------------*/
/**
* This method returns the value that was associated with this object
- *
+ *
* @return the object's value
*/
/*--------------------------------------------------------------------------*/
@@ -3577,9 +3590,8 @@ public String getValue()
* RESULT_PARENTDIR
*/
/*---------------------------------------------------------------------------*/
- public SearchField(String filename, String checkFilename, InstallerFrame parent,
- JComboBox combobox, JButton autobutton, JButton browsebutton, int search_type,
- int result_type)
+ public SearchField(String filename, String checkFilename, InstallerFrame parent, JComboBox combobox,
+ JButton autobutton, JButton browsebutton, int search_type, int result_type)
{
this.filename = filename;
this.checkFilename = checkFilename;
@@ -3596,8 +3608,8 @@ public SearchField(String filename, String checkFilename, InstallerFrame parent,
/*
* add DocumentListener to manage nextButton if user enters input
*/
- ((JTextField) this.pathComboBox.getEditor().getEditorComponent()).getDocument()
- .addDocumentListener(new DocumentListener()
+ ((JTextField) this.pathComboBox.getEditor().getEditorComponent()).getDocument().addDocumentListener(
+ new DocumentListener()
{
public void changedUpdate(DocumentEvent e)
@@ -3617,8 +3629,7 @@ public void removeUpdate(DocumentEvent e)
private void checkNextButtonState()
{
- Document doc = ((JTextField) pathComboBox.getEditor()
- .getEditorComponent()).getDocument();
+ Document doc = ((JTextField) pathComboBox.getEditor().getEditorComponent()).getDocument();
try
{
if (pathMatches(doc.getText(0, doc.getLength())))
@@ -3816,8 +3827,7 @@ public void actionPerformed(ActionEvent event)
if (!autodetect())
{
showMessageDialog(parent, "UserInputPanel.search.autodetect.failed.message",
- "UserInputPanel.search.autodetect.failed.caption",
- JOptionPane.WARNING_MESSAGE);
+ "UserInputPanel.search.autodetect.failed.caption", JOptionPane.WARNING_MESSAGE);
}
}
else if (event.getSource() == this.browseButton)
@@ -3841,8 +3851,7 @@ else if (event.getSource() == this.browseButton)
if (this.resultType != TYPE_FILE && !this.pathMatches(f.getAbsolutePath()))
{
showMessageDialog(parent, "UserInputPanel.search.wrongselection.message",
- "UserInputPanel.search.wrongselection.caption",
- JOptionPane.WARNING_MESSAGE);
+ "UserInputPanel.search.wrongselection.caption", JOptionPane.WARNING_MESSAGE);
}
}
@@ -3979,15 +3988,14 @@ public void actionPerformed(ActionEvent e)
/*--------------------------------------------------------------------------*/
/**
* Show localized message dialog basing on given parameters.
- *
+ *
* @param parentFrame The parent frame.
* @param message The message to print out in dialog box.
* @param caption The caption of dialog box.
* @param messageType The message type (JOptionPane.*_MESSAGE)
*/
/*--------------------------------------------------------------------------*/
- private void showMessageDialog(InstallerFrame parentFrame, String message, String caption,
- int messageType)
+ private void showMessageDialog(InstallerFrame parentFrame, String message, String caption, int messageType)
{
String localizedMessage = parentFrame.langpack.getString(message);
if ((localizedMessage == null) || (localizedMessage.trim().length() == 0))
@@ -4012,8 +4020,7 @@ private void showMessageDialog(InstallerFrame parentFrame, String message, Strin
/*--------------------------------------------------------------------------*/
private void showWarningMessageDialog(InstallerFrame parentFrame, String message)
{
- showMessageDialog(parentFrame, message, "UserInputPanel.error.caption",
- JOptionPane.WARNING_MESSAGE);
+ showMessageDialog(parentFrame, message, "UserInputPanel.error.caption", JOptionPane.WARNING_MESSAGE);
}
public void itemStateChanged(ItemEvent arg0)
Please sign in to comment.
Something went wrong with that request. Please try again.