Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1e677433c9d051d60f9367de5bc4a3685dd23ca6 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 * IBM Corporation - initial API and implementation
 * yyyymmdd bug      Email and other contact information
 * -------- -------- -----------------------------------------------------------
 * 20060202   119780 pmoogk@ca.ibm.com - Peter Moogk
 * 20060216   127138 pmoogk@ca.ibm.com - Peter Moogk
 * 20060227   124392 rsinha@ca.ibm.com - Rupam Kuehner
 *******************************************************************************/

package org.eclipse.jst.ws.internal.consumption.ui.preferences;

import org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin;
import org.eclipse.wst.command.internal.env.context.PersistentContext;
import com.ibm.icu.util.StringTokenizer;


public class PersistentProjectTopologyContext extends PersistentContext implements ProjectTopologyContext
{

  public PersistentProjectTopologyContext () 
  {
	  super( WebServiceConsumptionUIPlugin.getInstance());
  }
  
  public void load() 
  {
    //Load the service project types
    String[] serviceIds = ProjectTopologyDefaults.getServiceTypes();
    StringBuffer serviceSb = new StringBuffer();
    for (int i = 0; i < serviceIds.length; i++)
    {
      if (i != 0)
        serviceSb.append(" ");
      serviceSb.append(serviceIds[i]);
    }
    setDefaultStringIfNoDefault(PREFERENCE_SERVICE_TYPES, serviceSb.toString());
    
    //Load the client project types
    String[] ids = ProjectTopologyDefaults.getClientTypes();
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < ids.length; i++)
    {
      if (i != 0)
        sb.append(" ");
      sb.append(ids[i]);
    }
    setDefaultStringIfNoDefault(PREFERENCE_CLIENT_TYPES, sb.toString());
    setDefault(PREFERENCE_USE_TWO_EARS, ProjectTopologyDefaults.isUseTwoEARs());
 }

  public void setServiceTypes(String[] ids)
  {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < ids.length; i++)
    {
      if (i != 0)
        sb.append(" ");
      sb.append(ids[i]);
    }
    setValue(PREFERENCE_SERVICE_TYPES, sb.toString());
  }

  public String[] getServiceTypes()
  {
    StringTokenizer st = new StringTokenizer(getValueAsString(PREFERENCE_SERVICE_TYPES));
    String[] s = new String[st.countTokens()];
    for (int i = 0; i < s.length; i++)
      s[i] = st.nextToken();
    return s;
  }
  
  public String[] getDefaultServiceTypes()
  {
    StringTokenizer st = new StringTokenizer(getDefaultString(PREFERENCE_SERVICE_TYPES));
    String[] s = new String[st.countTokens()];
    for (int i = 0; i < s.length; i++)
      s[i] = st.nextToken();
    return s;        
  }
    
 public void setClientTypes(String[] ids)
 {
   StringBuffer sb = new StringBuffer();
   for (int i = 0; i < ids.length; i++)
   {
     if (i != 0)
       sb.append(" ");
     sb.append(ids[i]);
   }
   setValue(PREFERENCE_CLIENT_TYPES, sb.toString());
 }

 public String[] getClientTypes()
 {
   StringTokenizer st = new StringTokenizer(getValueAsString(PREFERENCE_CLIENT_TYPES));
   String[] s = new String[st.countTokens()];
   for (int i = 0; i < s.length; i++)
     s[i] = st.nextToken();
   return s;
 }
 
 public String[] getDefaultClientTypes()
 {
   StringTokenizer st = new StringTokenizer(getDefaultString(PREFERENCE_CLIENT_TYPES));
   String[] s = new String[st.countTokens()];
   for (int i = 0; i < s.length; i++)
     s[i] = st.nextToken();
   return s;        
 } 

 public void setUseTwoEARs(boolean use)
 {
   setValue(PREFERENCE_USE_TWO_EARS, use);
 }
 public boolean isUseTwoEARs()
 {
   return getValueAsBoolean(PREFERENCE_USE_TWO_EARS);
 }

 public ProjectTopologyContext copy() {
 	TransientProjectTopologyContext context = new TransientProjectTopologyContext();
    context.setServiceTypes(getServiceTypes());
    context.setDefaultServiceTypes(getDefaultServiceTypes());
	context.setClientTypes(getClientTypes());
    context.setDefaultClientTypes(getDefaultClientTypes());
	context.setUseTwoEARs(isUseTwoEARs());
	return context;
}

}

Back to the top