KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > izforge > izpack > installer > IzPanel


1 /*
2  * $Id: IzPanel.java 1715 2007-01-17 07:29:00Z jponge $
3  * IzPack - Copyright 2001-2007 Julien Ponge, All Rights Reserved.
4  *
5  * http://www.izforge.com/izpack/
6  * http://developer.berlios.de/projects/izpack/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */

20 package com.izforge.izpack.installer;
21
22 import com.izforge.izpack.Panel;
23 import com.izforge.izpack.gui.LabelFactory;
24 import com.izforge.izpack.gui.LayoutConstants;
25 import com.izforge.izpack.util.AbstractUIHandler;
26 import com.izforge.izpack.util.Debug;
27 import com.izforge.izpack.util.MultiLineLabel;
28 import com.izforge.izpack.util.VariableSubstitutor;
29 import net.n3.nanoxml.XMLElement;
30
31 import javax.swing.*;
32 import javax.swing.plaf.metal.MetalLookAndFeel JavaDoc;
33 import java.awt.*;
34
35 /**
36  * Defines the base class for the IzPack panels. Any panel should be a subclass of it and should
37  * belong to the <code>com.izforge.izpack.panels</code> package.
38  * Since IzPack version 3.9 the layout handling will be delegated to the class
39  * LayoutHelper which can be accessed by <code>getLayoutHelper</code>.
40  * There are some layout helper methods in this class which will be exist some time longer,
41  * but they are deprecated. At a redesign or new panel use the layout helper.
42  * There is a special layout manager for IzPanels. This layout manager will be supported
43  * by the layout helper. There are some points which should be observed at layouting.
44  * One point e.g. is the anchor. All IzPanels have to be able to use different anchors, as
45  * minimum CENTER and NORTHWEST.
46  * To use a consistent appearance use this special layout manger and not others.
47  *
48  * @author Julien Ponge
49  * @author Klaus Bartz
50  */

51 public class IzPanel extends JPanel implements AbstractUIHandler, LayoutConstants
52 {
53
54     private static final long serialVersionUID = 3256442495255786038L;
55
56     /** The helper object which handles layout */
57     protected LayoutHelper layoutHelper;
58     
59     /** The component which should get the focus at activation */
60     protected Component initialFocus = null;
61
62     /**
63      * The installer internal data (actually a melting-pot class with all-public fields.
64      */

65     protected InstallData idata;
66
67     /** The parent IzPack installer frame. */
68     protected InstallerFrame parent;
69     
70     /** i.e. "com.izforge.izpack.panels.HelloPanel" */
71     protected String JavaDoc myFullClassname;
72
73     /** myClassname=i.e "FinishPanel" */
74     protected String JavaDoc myClassname;
75
76     /** i.e. "FinishPanel." useFull for getString() */
77     protected String JavaDoc myPrefix;
78
79     /** internal headline string */
80     protected String JavaDoc headline;
81     
82     /** internal headline Label */
83     protected JLabel headLineLabel;
84     
85     /** Is this panel general hidden or not */
86     protected boolean hidden;
87     
88     /** HEADLINE = "headline" */
89     public final static String JavaDoc HEADLINE = "headline";
90     
91     /** X_ORIGIN = 0 */
92     public final static int X_ORIGIN = 0;
93
94     /** Y_ORIGIN = 0 */
95     public final static int Y_ORIGIN = 0;
96     /** D = "." ( dot ) */
97     public final static String JavaDoc D = ".";
98
99     /** d = D */
100     public final static String JavaDoc d = D;
101     
102     /** COLS_1 = 1 */
103     public final static int COLS_1 = 1;
104
105     /** ROWS_1 = 1 */
106     public final static int ROWS_1 = 1;
107
108     /**
109      * Information about the panel
110      */

111     public Panel metadata;
112
113     /**
114      * The constructor.
115      *
116      * @param parent The parent IzPack installer frame.
117      * @param idata The installer internal data.
118      */

119     public IzPanel(InstallerFrame parent, InstallData idata)
120     {
121       this( parent, idata, (LayoutManager2) null);
122     }
123     
124     /**
125      * Creates a new IzPanel object with the given layout manager. Valid layout manager are the
126      * IzPanelLayout and the GridBagLayout. New panels should be use the IzPanelLaout.
127      * If lm is null, no layout manager will be created or initialized.
128      * @param parent The parent IzPack installer frame.
129      * @param idata The installer internal data.
130      * @param lm layout manager to be used with this IzPanel
131      */

132     public IzPanel(InstallerFrame parent, InstallData idata, LayoutManager2 lm)
133     {
134       super();
135       init( parent, idata );
136       if( lm != null )
137           getLayoutHelper().startLayout(lm);
138     }
139     
140     /**
141      * Creates a new IzPanel object.
142      *
143      * @param parent the Parent Frame
144      * @param idata Installers Runtime Data Set
145      * @param iconName The Headline IconName
146      */

147     public IzPanel( InstallerFrame parent, InstallData idata, String JavaDoc iconName )
148     {
149       this( parent, idata, iconName, -1 );
150     }
151     
152     /**
153      * The constructor with Icon.
154      *
155      * @param parent The parent IzPack installer frame.
156      * @param idata The installer internal data.
157      * @param iconName A iconname to show as left oriented headline-leading Icon.
158      * @param instance An instance counter
159      */

160     public IzPanel( InstallerFrame parent, InstallData idata, String JavaDoc iconName, int instance )
161     {
162       this(parent, idata);
163       buildHeadline( iconName, instance );
164     }
165     
166     /**
167      * Build the IzPanel internal Headline. If an external headline#
168      * is used, this method returns immediately with false.
169      * Allows also to display a leading Icon for the PanelHeadline.
170      * This Icon can also be different if the panel has more than one Instances.
171      * The UserInputPanel is one of these Candidates.
172      *
173      * by marc.eppelmann&#064;gmx.de
174      *
175      * @param imageIconName an Iconname
176      * @param instanceNumber an panel instance
177      *
178      * @return true if successful build
179      */

180     protected boolean buildHeadline( String JavaDoc imageIconName, int instanceNumber )
181     {
182       boolean result = false;
183       if( parent.isHeading(this))
184           return(false);
185
186       // TODO: proteced instancenumber
187
// TODO: is to be validated
188
// TODO:
189
// TODO: first Test if a Resource for your protected Instance exists.
190
String JavaDoc headline;
191       String JavaDoc headlineSearchBaseKey = myClassname + d + "headline"; // Results for example in "ShortcutPanel.headline" :
192

193       if( instanceNumber > -1 ) // Search for Results for example in "ShortcutPanel.headline.1, 2, 3 etc." :
194
{
195         String JavaDoc instanceSearchKey = headlineSearchBaseKey + d +
196                                    Integer.toString( instanceNumber );
197
198         String JavaDoc instanceHeadline = getString( instanceSearchKey );
199
200         if( Debug.isLOG() )
201         {
202           System.out.println( "found headline: " + instanceHeadline + d + " for instance # " + instanceNumber );
203         }
204         if( ! instanceSearchKey.equals( instanceHeadline ) )
205         {
206           headline = instanceHeadline;
207         }
208         else
209         {
210           headline = getString( headlineSearchBaseKey );
211         }
212       }
213       else
214       {
215         headline = getString( headlineSearchBaseKey );
216       }
217
218       if( headline != null )
219       {
220         if( ( imageIconName != null ) && ! "".equals( imageIconName ) )
221         {
222           headLineLabel = new JLabel( headline, getImageIcon( imageIconName ),
223                                       SwingConstants.LEADING );
224         }
225         else
226         {
227           headLineLabel = new JLabel( headline );
228         }
229
230         Font font = headLineLabel.getFont( );
231         float size = font.getSize( );
232         int style = 0;
233         font = font.deriveFont( style, ( size * 1.5f ) );
234         headLineLabel.setFont( font );
235
236         GridBagConstraints gbc = new GridBagConstraints( );
237
238         gbc.gridx = 0;
239         gbc.gridy = 0;
240         gbc.gridwidth = 1;
241         gbc.gridheight = 1;
242
243         gbc.fill = GridBagConstraints.HORIZONTAL;
244         gbc.anchor = GridBagConstraints.WEST;
245         gbc.insets = new Insets( 0, 0, 0, 0 );
246         headLineLabel.setName( HEADLINE );
247         ((GridBagLayout) getLayout()).addLayoutComponent( headLineLabel, gbc );
248
249         add( headLineLabel );
250       }
251
252       return result;
253     }
254     
255     /**
256      * Gets a language Resource String from the parent, which holds these global resource.
257      *
258      * @param key The Search key
259      *
260      * @return The Languageresource or the key if not found.
261      */

262     public String JavaDoc getString( String JavaDoc key )
263     {
264       return parent.langpack.getString( key );
265     }
266     
267     /**
268      * Gets a named image icon
269      *
270      * @param iconName a valid image icon
271      *
272      * @return the icon
273      */

274     public ImageIcon getImageIcon( String JavaDoc iconName )
275     {
276       return parent.icons.getImageIcon( iconName );
277     }
278
279
280     
281     /**
282      * Inits and sets the internal layout helper object.
283      */

284     protected void initLayoutHelper()
285     {
286         layoutHelper = new LayoutHelper(this);
287     }
288     
289
290     /**
291      * Gets and fills the classname fields
292      */

293     protected void getClassName( )
294     {
295       myFullClassname = getClass( ).getName( );
296       myClassname = myFullClassname.substring( myFullClassname.lastIndexOf( "." ) + 1 );
297       myPrefix = myClassname + ".";
298     }
299     
300     /**
301      * Internal init method
302      *
303      * @param parent the parent frame
304      * @param idata installers runtime dataset
305      */

306     protected void init( InstallerFrame parent, InstallData idata )
307     {
308       getClassName( );
309       
310       this.idata = idata;
311       this.parent = parent;
312       // To get the Panel object via idata is a hack because InstallData will
313
// be hold global data, not panel specific data. But the Panel object will
314
// be needed in the constructor of some derived classes. And to expand the
315
// constructor is also not a good way because all derived classes have to
316
// change then the signature. Also the custem IzPanels elswhere. Therefore
317
// this hack...
318
// Problems with this hack will be exist if more than one threads calls the
319
// constructors of derived clases. This is not the case.
320
this.metadata = idata.currentPanel;
321       idata.currentPanel = null;
322       initLayoutHelper( );
323
324     }
325
326     /**
327      * Indicates wether the panel has been validated or not. The installer won't let the user go
328      * further through the installation process until the panel is validated. Default behaviour is
329      * to return <code>true</code>.
330      *
331      * @return A boolean stating wether the panel has been validated or not.
332      */

333     public boolean isValidated()
334     {
335         return true;
336     }
337
338     /**
339      * This method is called when the panel becomes active. Default is to do nothing : feel free to
340      * implement what you need in your subclasses. A panel becomes active when the user reaches it
341      * during the installation process.
342      */

343     public void panelActivate()
344     {
345     }
346
347     /**
348      * This method is called when the panel gets desactivated, when the user switches to the next
349      * panel. By default it doesn't do anything.
350      */

351     public void panelDeactivate()
352     {
353     }
354
355     /**
356      * Asks the panel to set its own XML data that can be brought back for an automated installation
357      * process. Use it as a blackbox if your panel needs to do something even in automated mode.
358      *
359      * @param panelRoot The XML root element of the panels blackbox tree.
360      */

361     public void makeXMLData(XMLElement panelRoot)
362     {
363     }
364
365     /**
366      * Ask the user a question.
367      *
368      * @param title Message title.
369      * @param question The question.
370      * @param choices The set of choices to present.
371      *
372      * @return The user's choice.
373      *
374      * @see AbstractUIHandler#askQuestion(String, String, int)
375      */

376     public int askQuestion(String JavaDoc title, String JavaDoc question, int choices)
377     {
378         return askQuestion(title, question, choices, -1);
379     }
380
381     /**
382      * Ask the user a question.
383      *
384      * @param title Message title.
385      * @param question The question.
386      * @param choices The set of choices to present.
387      * @param default_choice The default choice. (-1 = no default choice)
388      *
389      * @return The user's choice.
390      * @see AbstractUIHandler#askQuestion(String, String, int, int)
391      */

392     public int askQuestion(String JavaDoc title, String JavaDoc question, int choices, int default_choice)
393     {
394         int jo_choices = 0;
395
396         if (choices == AbstractUIHandler.CHOICES_YES_NO)
397             jo_choices = JOptionPane.YES_NO_OPTION;
398         else if (choices == AbstractUIHandler.CHOICES_YES_NO_CANCEL)
399             jo_choices = JOptionPane.YES_NO_CANCEL_OPTION;
400
401         int user_choice = JOptionPane.showConfirmDialog(this, (Object JavaDoc) question, title, jo_choices,
402                 JOptionPane.QUESTION_MESSAGE);
403
404         if (user_choice == JOptionPane.CANCEL_OPTION) return AbstractUIHandler.ANSWER_CANCEL;
405
406         if (user_choice == JOptionPane.YES_OPTION) return AbstractUIHandler.ANSWER_YES;
407
408         if (user_choice == JOptionPane.CLOSED_OPTION) return AbstractUIHandler.ANSWER_NO;
409
410         if (user_choice == JOptionPane.NO_OPTION) return AbstractUIHandler.ANSWER_NO;
411
412         return default_choice;
413     }
414
415     public boolean emitNotificationFeedback(String JavaDoc message)
416     {
417        return (JOptionPane.showConfirmDialog(this, message, idata.langpack.getString("installer.Message"), JOptionPane.WARNING_MESSAGE,
418              JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION);
419     }
420
421     /**
422      * Notify the user about something.
423      *
424      * @param message The notification.
425      */

426     public void emitNotification(String JavaDoc message)
427     {
428         JOptionPane.showMessageDialog(this, message);
429     }
430
431     /**
432      * Warn the user about something.
433      *
434      * @param message The warning message.
435      */

436     public boolean emitWarning(String JavaDoc title, String JavaDoc message)
437     {
438         return (JOptionPane.showConfirmDialog(this, message, title, JOptionPane.WARNING_MESSAGE,
439                 JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION);
440
441     }
442
443     /**
444      * Notify the user of some error.
445      *
446      * @param message The error message.
447      */

448     public void emitError(String JavaDoc title, String JavaDoc message)
449     {
450         JOptionPane.showMessageDialog(this, message, title, JOptionPane.ERROR_MESSAGE);
451     }
452
453     /**
454      * Returns the component which should be get the focus at activation of this panel.
455      *
456      * @return the component which should be get the focus at activation of this panel
457      */

458     public Component getInitialFocus()
459     {
460         return initialFocus;
461     }
462
463     /**
464      * Sets the component which should be get the focus at activation of this panel.
465      *
466      * @param component which should be get the focus at activation of this panel
467      */

468     public void setInitialFocus(Component component)
469     {
470         initialFocus = component;
471     }
472
473     /**
474      * Calls the langpack of parent InstallerFrame for the String <tt>RuntimeClassName.subkey</tt>.
475      * Do not add a point infront of subkey, it is always added in this method.
476      * If <tt>RuntimeClassName.subkey</tt> is not found, the super class name will be used
477      * until it is <tt>IzPanel</tt>. If no key will be found, null returns.
478      *
479      * @param subkey the subkey for the string which should be returned
480      * @return the founded string
481      */

482     public String JavaDoc getI18nStringForClass(String JavaDoc subkey)
483     {
484         String JavaDoc retval = null;
485         Class JavaDoc clazz = this.getClass();
486         while (retval == null && !clazz.getName().endsWith(".IzPanel"))
487         {
488             retval = getI18nStringForClass(clazz.getName(), subkey, null);
489             clazz = clazz.getSuperclass();
490         }
491         return (retval);
492     }
493
494     /**
495      * Calls the langpack of parent InstallerFrame for the String <tt>RuntimeClassName.subkey</tt>.
496      * Do not add a point infront of subkey, it is always added in this method.
497      * If no key will be found the key or - if alternate class is null - null returns.
498      *
499      * @param subkey the subkey for the string which should be returned
500      * @param alternateClass the short name of the class which should be used if no string is
501      * present with the runtime class name
502      * @return the founded string
503      */

504     public String JavaDoc getI18nStringForClass(String JavaDoc subkey, String JavaDoc alternateClass)
505     {
506         return( getI18nStringForClass(getClass().getName(), subkey, alternateClass));
507
508     }
509
510     private String JavaDoc getI18nStringForClass(String JavaDoc curClassName, String JavaDoc subkey, String JavaDoc alternateClass)
511     {
512
513         int nameStart = curClassName.lastIndexOf('.') + 1;
514         curClassName = curClassName.substring(nameStart, curClassName.length());
515         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
516         buf.append(curClassName).append(".").append(subkey);
517         String JavaDoc fullkey = buf.toString();
518         String JavaDoc panelid = null;
519         if( getMetadata() != null )
520         {
521             panelid = getMetadata().getPanelid();
522         }
523         String JavaDoc retval = null;
524         if (panelid != null)
525         {
526             buf.append(".");
527             buf.append(panelid);
528             retval = parent.langpack.getString(buf.toString());
529         }
530         if (retval == null || retval.startsWith(fullkey))
531             retval = parent.langpack.getString(fullkey);
532         if (retval == null || retval.startsWith(fullkey))
533         {
534             if (alternateClass == null) return (null);
535             buf.delete(0, buf.length());
536             buf.append(alternateClass).append(".").append(subkey);
537             retval = parent.langpack.getString(buf.toString());
538         }
539         if (retval != null && retval.indexOf('$') > -1)
540         {
541             VariableSubstitutor substitutor = new VariableSubstitutor(idata.getVariables());
542             retval = substitutor.substitute(retval, null);
543         }
544         return (retval);
545     }
546     
547         
548     /**
549      * Returns the parent of this IzPanel (which is a InstallerFrame).
550      *
551      * @return the parent of this IzPanel
552      */

553     public InstallerFrame getInstallerFrame()
554     {
555         return (parent);
556     }
557
558     // ------------- Helper for common used components ----- START ---
559

560     /**
561      * Creates a label via LabelFactory using iconId, pos and method getI18nStringForClass for
562      * resolving the text to be used. If the icon id is null, the label will be created also.
563      *
564      * @param subkey the subkey which should be used for resolving the text
565      * @param alternateClass the short name of the class which should be used if no string is
566      * present with the runtime class name
567      * @param iconId id string for the icon
568      * @param pos horizontal alignment
569      * @return the newly created label
570      */

571     public JLabel createLabel(String JavaDoc subkey, String JavaDoc alternateClass, String JavaDoc iconId, int pos)
572     {
573         ImageIcon ii = (iconId != null) ? parent.icons.getImageIcon(iconId) : null;
574         String JavaDoc msg = getI18nStringForClass(subkey, alternateClass);
575         JLabel label = LabelFactory.create(msg, ii, pos);
576         if (label != null) label.setFont(getControlTextFont());
577         return (label);
578
579     }
580
581     /**
582      * Creates a label via LabelFactory using iconId, pos and method getI18nStringForClass for
583      * resolving the text to be used. If the icon id is null, the label will be created also. If
584      * isFullLine true a LabelFactory.FullLineLabel will be created instead of a JLabel. The
585      * difference between both classes are a different layout handling.
586      *
587      * @param subkey the subkey which should be used for resolving the text
588      * @param alternateClass the short name of the class which should be used if no string is
589      * present with the runtime class name
590      * @param iconId id string for the icon
591      * @param pos horizontal alignment
592      * @param isFullLine determines whether a FullLineLabel or a JLabel should be created
593      * @return the newly created label
594      */

595     public JLabel createLabel(String JavaDoc subkey, String JavaDoc alternateClass, String JavaDoc iconId, int pos,
596             boolean isFullLine)
597     {
598         ImageIcon ii = (iconId != null) ? parent.icons.getImageIcon(iconId) : null;
599         String JavaDoc msg = getI18nStringForClass(subkey, alternateClass);
600         JLabel label = LabelFactory.create(msg, ii, pos, isFullLine);
601         if (label != null) label.setFont(getControlTextFont());
602         return (label);
603
604     }
605
606     /**
607      * Creates a label via LabelFactory with the given ids and the given horizontal alignment. If
608      * the icon id is null, the label will be created also. The strings are the ids for the text in
609      * langpack and the icon in icons of the installer frame.
610      *
611      * @param textId id string for the text
612      * @param iconId id string for the icon
613      * @param pos horizontal alignment
614      * @return the newly created label
615      */

616     public JLabel createLabel(String JavaDoc textId, String JavaDoc iconId, int pos)
617     {
618         return (createLabel(textId, iconId, pos, false));
619     }
620
621     /**
622      * Creates a label via LabelFactory with the given ids and the given horizontal alignment. If
623      * the icon id is null, the label will be created also. The strings are the ids for the text in
624      * langpack and the icon in icons of the installer frame. If isFullLine true a
625      * LabelFactory.FullLineLabel will be created instead of a JLabel. The difference between both
626      * classes are a different layout handling.
627      *
628      * @param textId id string for the text
629      * @param iconId id string for the icon
630      * @param pos horizontal alignment
631      * @param isFullLine determines whether a FullLineLabel or a JLabel should be created
632      * @return the newly created label
633      */

634     public JLabel createLabel(String JavaDoc textId, String JavaDoc iconId, int pos, boolean isFullLine)
635     {
636         ImageIcon ii = (iconId != null) ? parent.icons.getImageIcon(iconId) : null;
637         JLabel label = LabelFactory.create(parent.langpack.getString(textId), ii, pos, isFullLine);
638         if (label != null) label.setFont(getControlTextFont());
639         return (label);
640
641     }
642
643     /**
644      * Creates a multi line label with the language dependent text given by the text id. The strings
645      * is the id for the text in langpack of the installer frame. The horizontal alignment will be
646      * LEFT.
647      *
648      * @param textId id string for the text
649      * @return the newly created multi line label
650      */

651     public MultiLineLabel createMultiLineLabelLang(String JavaDoc textId)
652     {
653         return (createMultiLineLabel(parent.langpack.getString(textId)));
654     }
655
656     /**
657      * Creates a multi line label with the given text. The horizontal alignment will be LEFT.
658      *
659      * @param text text to be used in the label
660      * @return the newly created multi line label
661      */

662     public MultiLineLabel createMultiLineLabel(String JavaDoc text)
663     {
664         return (createMultiLineLabel(text, null, SwingConstants.LEFT));
665     }
666
667     /**
668      * Creates a label via LabelFactory with the given text, the given icon id and the given
669      * horizontal alignment. If the icon id is null, the label will be created also. The strings are
670      * the ids for the text in langpack and the icon in icons of the installer frame.
671      *
672      * @param text text to be used in the label
673      * @param iconId id string for the icon
674      * @param pos horizontal alignment
675      * @return the created multi line label
676      */

677     public MultiLineLabel createMultiLineLabel(String JavaDoc text, String JavaDoc iconId, int pos)
678     {
679         MultiLineLabel mll = null;
680         mll = new MultiLineLabel(text, 0, 0);
681         if (mll != null) mll.setFont(getControlTextFont());
682         return (mll);
683     }
684
685     /**
686      * The Font of Labels in many cases
687      */

688     public Font getControlTextFont()
689     {
690         return (getLAF() != null ? MetalLookAndFeel.getControlTextFont() : getFont());
691     }
692
693     protected static MetalLookAndFeel JavaDoc getLAF()
694     {
695         LookAndFeel JavaDoc laf = UIManager.getLookAndFeel();
696         if (laf instanceof MetalLookAndFeel JavaDoc) return ((MetalLookAndFeel JavaDoc) laf);
697         return (null);
698     }
699
700     // ------------- Helper for common used components ----- END ---
701
// ------------------- Layout stuff -------------------- START ---
702
/**
703      * Returns the default GridBagConstraints of this panel.
704      *
705      * @return the default GridBagConstraints of this panel
706      * @deprecated use <code>getLayoutHelper().getDefaulConstraints</code> instead
707      */

708     public GridBagConstraints getDefaultGridBagConstraints()
709     {
710         return(GridBagConstraints) ( layoutHelper.getDefaultConstraints());
711     }
712
713     /**
714      * Sets the default GridBagConstraints of this panel to the given object.
715      *
716      * @param constraints which should be set as default for this object
717      * @deprecated use <code>getLayoutHelper().setDefaultConstraints</code> instead
718      */

719     public void setDefaultGridBagConstraints(GridBagConstraints constraints)
720     {
721         layoutHelper.setDefaultConstraints(constraints);
722     }
723
724     /**
725      * Resets the grid counters which are used at getNextXGridBagConstraints and
726      * getNextYGridBagConstraints.
727      * @deprecated use <code>getLayoutHelper().resetGridCounter</code> instead
728      */

729     public void resetGridCounter()
730     {
731         layoutHelper.resetGridCounter();
732     }
733
734     /**
735      * Returns a newly created GridBagConstraints with the given values and the values from the
736      * defaultGridBagConstraints for the other parameters.
737      *
738      * @param gridx value to be used for the new constraint
739      * @param gridy value to be used for the new constraint
740      * @return newly created GridBagConstraints with the given values and the values from the
741      * defaultGridBagConstraints for the other parameters
742      * @deprecated use <code>getLayoutHelper().getNewConstraints</code> instead
743      */

744     public GridBagConstraints getNewGridBagConstraints(int gridx, int gridy)
745     {
746         return(GridBagConstraints) ( layoutHelper.getNewConstraints(gridx, gridy));
747     }
748
749     /**
750      * Returns a newly created GridBagConstraints with the given values and the values from the
751      * defaultGridBagConstraints for the other parameters.
752      *
753      * @param gridx value to be used for the new constraint
754      * @param gridy value to be used for the new constraint
755      * @param gridwidth value to be used for the new constraint
756      * @param gridheight value to be used for the new constraint
757      * @return newly created GridBagConstraints with the given values and the values from the
758      * defaultGridBagConstraints for the other parameters
759      * @deprecated use <code>getLayoutHelper().getNewConstraints</code> instead
760      */

761     public GridBagConstraints getNewGridBagConstraints(int gridx, int gridy, int gridwidth,
762             int gridheight)
763     {
764         return(GridBagConstraints) (layoutHelper.getNewConstraints(gridx, gridy, gridwidth, gridheight));
765     }
766
767     /**
768      * Returns a newly created GridBagConstraints for the next column of the current layout row.
769      *
770      * @return a newly created GridBagConstraints for the next column of the current layout row
771      *
772      * @deprecated use <code>getLayoutHelper().getNextXConstraints</code> instead
773      */

774     public GridBagConstraints getNextXGridBagConstraints()
775     {
776         return(GridBagConstraints) (layoutHelper.getNextXConstraints());
777     }
778
779     /**
780      * Returns a newly created GridBagConstraints with column 0 for the next row.
781      *
782      * @return a newly created GridBagConstraints with column 0 for the next row
783      *
784      * @deprecated use <code>getLayoutHelper().getNextYConstraints</code> instead
785      */

786     public GridBagConstraints getNextYGridBagConstraints()
787     {
788         return(GridBagConstraints) (layoutHelper.getNextYConstraints());
789     }
790
791     /**
792      * Returns a newly created GridBagConstraints with column 0 for the next row using the given
793      * parameters.
794      *
795      * @param gridwidth width for this constraint
796      * @param gridheight height for this constraint
797      * @return a newly created GridBagConstraints with column 0 for the next row using the given
798      * parameters
799      * @deprecated use <code>getLayoutHelper().getNextYConstraints</code> instead
800      */

801     public GridBagConstraints getNextYGridBagConstraints(int gridwidth, int gridheight)
802     {
803         return(GridBagConstraints) (layoutHelper.getNextYConstraints(gridwidth, gridheight));
804     }
805
806     /**
807      * Start layout determining. If it is needed, a dummy component will be created as first row.
808      * This will be done, if the IzPack guiprefs modifier with the key "layoutAnchor" has the value
809      * "SOUTH" or "SOUTHWEST". The earlier used value "BOTTOM" and the declaration via the IzPack
810      * variable <code>IzPanel.LayoutType</code> are also supported.
811      * @deprecated use <code>getLayoutHelper().startLayout</code> instead
812      */

813     public void startGridBagLayout()
814     {
815         layoutHelper.startLayout(new GridBagLayout());
816     }
817
818     /**
819      * Complete layout determining. If it is needed, a dummy component will be created as last row.
820      * This will be done, if the IzPack guiprefs modifier with the key "layoutAnchor" has the value
821      * "NORTH" or "NORTHWEST". The earlier used value "TOP" and the declaration via the IzPack
822      * variable <code>IzPanel.LayoutType</code> are also supported.
823      * @deprecated use <code>getLayoutHelper().completeLayout</code> instead
824      */

825     public void completeGridBagLayout()
826     {
827         layoutHelper.completeLayout();
828     }
829
830     // ------------------- Layout stuff -------------------- END ---
831

832     // ------------------- Summary stuff -------------------- START ---
833
/**
834      * This method will be called from the SummaryPanel to get the summary of this class which
835      * should be placed in the SummaryPanel. The returned text should not contain a caption of this
836      * item. The caption will be requested from the method getCaption. If <code>null</code>
837      * returns, no summary for this panel will be generated. Default behaviour is to return
838      * <code>null</code>.
839      *
840      * @return the summary for this class
841      */

842     public String JavaDoc getSummaryBody()
843     {
844         return null;
845     }
846
847     /**
848      * This method will be called from the SummaryPanel to get the caption for this class which
849      * should be placed in the SummaryPanel. If <code>null</code> returns, no summary for this
850      * panel will be generated. Default behaviour is to return the string given by langpack for the
851      * key <code>&lt;current class name>.summaryCaption&gt;</code> if exist, else the string
852      * &quot;summaryCaption.&lt;ClassName&gt;&quot;.
853      *
854      * @return the caption for this class
855      */

856     public String JavaDoc getSummaryCaption()
857     {
858         String JavaDoc caption;
859         if (parent.isHeading(this)
860                 && idata.guiPrefs.modifier.containsKey("useHeadingForSummary")
861                 && ((String JavaDoc) idata.guiPrefs.modifier.get("useHeadingForSummary"))
862                         .equalsIgnoreCase("yes"))
863         {
864             caption = getI18nStringForClass("headline", this.getClass().getName());
865         }
866         else
867             caption = getI18nStringForClass("summaryCaption", this.getClass().getName());
868
869         return (caption);
870     }
871
872     // ------------------- Summary stuff -------------------- END ---
873

874     // ------------------- Inner classes ------------------- START ---
875
public static class Filler extends JComponent
876     {
877
878         private static final long serialVersionUID = 3258416144414095153L;
879
880     }
881     // ------------------- Inner classes ------------------- END ---
882

883     
884     /**
885      * Returns whether this panel will be hidden general or not.
886      * A hidden panel will be not counted in the step counter and
887      * for panel icons.
888      * @return whether this panel will be hidden general or not
889      */

890     public boolean isHidden()
891     {
892         return hidden;
893     }
894
895     
896     /**
897      * Set whether this panel should be hidden or not.
898      * A hidden panel will be not counted in the step counter and
899      * for panel icons.
900      * @param hidden flag to be set
901      */

902     public void setHidden(boolean hidden)
903     {
904         this.hidden = hidden;
905     }
906
907     
908     /**
909      * Returns the used layout helper. Can be used in a derived class
910      * to create custom layout.
911      * @return the used layout helper
912      */

913     public LayoutHelper getLayoutHelper()
914     {
915         return layoutHelper;
916     }
917
918     /**
919      * @return the metadata
920      */

921     public Panel getMetadata() {
922       return this.metadata;
923     }
924
925     /**
926      * @param p the metadata to set
927      */

928     public void setMetadata(Panel p) {
929       this.metadata = p;
930     }
931 }
932
Popular Tags