2011/08/05 - Jakarta Cactus has been retired.

For more information, please explore the Attic.

View Javadoc

1   /* 
2    * ========================================================================
3    * 
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * the License.  You may obtain a copy of the License at
10   * 
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * 
19   * ========================================================================
20   */
21  package org.apache.cactus.eclipse.runner.ui;
22  
23  import org.eclipse.jface.preference.BooleanFieldEditor;
24  import org.eclipse.jface.preference.DirectoryFieldEditor;
25  import org.eclipse.jface.preference.FieldEditorPreferencePage;
26  import org.eclipse.jface.preference.StringFieldEditor;
27  import org.eclipse.swt.widgets.Composite;
28  import org.eclipse.ui.IWorkbench;
29  import org.eclipse.ui.IWorkbenchPreferencePage;
30  
31  /**
32   * This class represents a preference page for the containers
33   * that is contributed to the Cactus Preferences dialog.
34   * <p>
35   *   By subclassing <samp>FieldEditorPreferencePage</samp>, we can use the
36   *   field support built into JFace that allows us to create a page that is 
37   *   small and knows how to save, restore and apply itself.
38   * </p>
39   * <p>
40   *   This page is used to modify preferences only. They are stored in the
41   *   preference store that belongs to the main plug-in class. That way,
42   *   preferences can be accessed directly via the preference store.
43   * </p>
44   * 
45   * @version $Id: ContainersPreferencePage.java 238816 2004-02-29 16:36:46Z vmassol $
46   */
47  public class ContainersPreferencePage
48      extends FieldEditorPreferencePage
49      implements IWorkbenchPreferencePage
50  {
51      /**
52       * Array of container identifiers.
53       */
54      private String[] containerIds;
55      /**
56       * Sets default plugin container preferences.
57       */
58      public ContainersPreferencePage()
59      {
60          super(GRID);
61          setPreferenceStore(CactusPlugin.getDefault().getPreferenceStore());
62          setDescription(
63              CactusMessages.getString("ContainersPreferencePage.description"));
64      }
65      /**
66       * Creates the field editors. Field editors are abstractions of
67       * the common GUI blocks needed to manipulate various types
68       * of preferences. Each field editor knows how to save and
69       * restore itself.
70       */
71      public void createFieldEditors()
72      {
73          Composite parent = getFieldEditorParent();
74          for (int i = 0; i < containerIds.length; i++)
75          {
76              DirectoryFieldEditor dirEditor =
77                  new DirectoryFieldEditor(
78                      containerIds[i],
79                      containerIds[i],
80                      parent);
81              dirEditor.getTextControl(parent).setToolTipText(
82                  CactusMessages.getString(
83                      "ContainersPreferencePage.label.container"));
84              addField(dirEditor);
85          }
86          BooleanFieldEditor jetty =
87              new BooleanFieldEditor(
88                  CactusPreferences.JETTY,
89                  CactusMessages.getString(
90                      "ContainersPreferencePage.label.jetty"),
91                  BooleanFieldEditor.SEPARATE_LABEL,
92                  parent);
93          jetty.getLabelControl(parent).setToolTipText(
94              CactusMessages.getString(
95                  "ContainersPreferencePage.label.jetty.tooltip"));
96          addField(jetty);
97          StringFieldEditor jettyXML =
98              new StringFieldEditor(
99                  CactusPreferences.JETTY_XML,
100                 CactusMessages.getString(
101                     "ContainersPreferencePage.label.jettyxml"),
102                 parent);
103         jettyXML.getTextControl(parent).setToolTipText(
104             CactusMessages.getString(
105                 "ContainersPreferencePage.label.jettyxml.tooltip"));
106         addField(jettyXML);
107     }
108 
109     /**
110      * @see org.eclipse.ui.IWorkbenchPreferencePage#init(IWorkbench)
111      */
112     public void init(IWorkbench theWorkbench)
113     {
114         containerIds = CactusPlugin.getContainerIds();
115 
116     }
117 
118 }