Skip to main content
summaryrefslogtreecommitdiffstats
blob: ff6a2c5223d98c88a9afb0904cd2b4937b40bb9d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*******************************************************************************
 * Copyright (c) 2001, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.wst.command.internal.env.context;

import java.util.Vector;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.wst.command.internal.env.preferences.ActionDialogPreferenceType;


public class ActionDialogPreferenceTypeRegistry
{
  private Vector preferences_;
  
  private static ActionDialogPreferenceTypeRegistry registry_;

  private ActionDialogPreferenceTypeRegistry()
  {
    preferences_ = new Vector();
    
    loadDialogsPreferences();  
  }
  
  static public ActionDialogPreferenceTypeRegistry getInstance()
  {
    if( registry_ == null )
    {
      registry_ = new ActionDialogPreferenceTypeRegistry();
    }
    
    return registry_;
  }
  
  //
  private void loadDialogsPreferences ()
  {
  	IExtensionRegistry reg = Platform.getExtensionRegistry();
    IConfigurationElement[] config = reg.getConfigurationElementsFor( "org.eclipse.wst.command.env",
                                                                      "actionDialogPreferenceType");
    
    for(int idx=0; idx<config.length; idx++) 
    {
      IConfigurationElement      elem   = config[idx];     
      ActionDialogPreferenceType dialog = new ActionDialogPreferenceType();
      
      dialog.setId( elem.getAttribute("id") );
      dialog.setName( elem.getAttribute("name") );
      dialog.setInfopop( elem.getAttribute("infopop") );
      dialog.setTooltip( elem.getAttribute("tooltip") );
      dialog.setCategory( elem.getAttribute("category") );
      
      String showCheckbox = elem.getAttribute( "showcheckbox" );
      String alwaysHide   = elem.getAttribute( "alwayshide" );
      
      dialog.setShowCheckbox( showCheckbox == null ? true : showCheckbox.equals( "true" ) );
      dialog.setAlwaysHide( alwaysHide == null ? false : alwaysHide.equals( "true" ) );
      
      preferences_.add(dialog);        
    }
  }

  /**
  * Returns all registered <code>WebServiceType</code> objects.
  * @return All registered <code>WebServiceType</code> objects.
  */
  public ActionDialogPreferenceType[] getActionDialogsPrefrences ()
  {
    return (ActionDialogPreferenceType[])preferences_.toArray( new ActionDialogPreferenceType[0]);
  }
  
  public ActionDialogPreferenceType getActionDialogsPrefrence( String id )
  {
    int                        length = preferences_.size();
    ActionDialogPreferenceType result = null;
    
    for( int index = 0; index < length; index++ )
    {
      ActionDialogPreferenceType preference = (ActionDialogPreferenceType)preferences_.elementAt( index );
      
      if( preference.getId().equals( id ) )
      {
        result = preference;
        break;
      }
    }
    
    return result;
  }
}

Back to the top