001: package com.bostechcorp.cbesb.common.util.custcomponent;
002:
003: import java.util.Properties;
004: import java.util.Vector;
005:
006: public abstract class BaseCustComponent implements ICustComponent {
007:
008: Vector<IWizardPage> consumerWizards = new Vector<IWizardPage>();
009:
010: Vector<IWizardPage> providerWizards = new Vector<IWizardPage>();
011:
012: protected String bigIconResourceLocation = "";
013:
014: protected String smallIconResourceLocation = "";
015:
016: protected String name = "";
017:
018: protected String description = "";
019:
020: protected String componentName = "";
021:
022: protected String componentURI = "";
023:
024: protected String vendor = "";
025:
026: protected boolean useDefaultDeploy = true;
027:
028: protected boolean useDefaultWSDLGenerator = true;
029:
030: protected boolean useCCSL = true;
031:
032: protected String version = "";
033:
034: protected DefaultMEP consumerDefaultMep = DefaultMEP.IN_ONLY;
035:
036: protected DefaultMEP providerDefaultMep = DefaultMEP.IN_OUT;
037:
038: protected Role role = Role.BOTH;
039:
040: protected boolean scheduleableConsumer = false;
041:
042: public BaseCustComponent() {
043: super ();
044: }
045:
046: public DefaultMEP getDefaultMep(Role role) {
047: if (role.equals(Role.CONSUMER))
048: return this .consumerDefaultMep;
049: else
050: return this .providerDefaultMep;
051: }
052:
053: public void addWizardPage(IWizardPage wizardPage, Role role) {
054: if (role.equals(Role.CONSUMER))
055: this .consumerWizards.add(wizardPage);
056: else {
057: this .providerWizards.add(wizardPage);
058: }
059: }
060:
061: public IWizardPage[] getWizardPages(Role role) {
062: if (role.equals(Role.CONSUMER)) {
063:
064: return consumerWizards
065: .toArray(new IWizardPage[consumerWizards.size()]);
066: } else {
067:
068: return providerWizards
069: .toArray(new IWizardPage[providerWizards.size()]);
070:
071: }
072: }
073:
074: public String getBigIconResourceLocation() {
075: return this .bigIconResourceLocation;
076: }
077:
078: public DefaultMEP getConsumerDefaultMep() {
079: return this .consumerDefaultMep;
080: }
081:
082: public String getDescription() {
083: return this .description;
084: }
085:
086: public String getName() {
087: return this .name;
088: }
089:
090: public String getComponentName() {
091: return componentName;
092: }
093:
094: public DefaultMEP getProviderDefaultMep() {
095: return this .providerDefaultMep;
096: }
097:
098: public Role getRole() {
099: return this .role;
100: }
101:
102: public boolean getUseCCSL() {
103: return this .useCCSL;
104: }
105:
106: public String getVendor() {
107: return this .vendor;
108: }
109:
110: public String getVersion() {
111: return this .version;
112: }
113:
114: public boolean useDefaultDeployment() {
115: return this .useDefaultDeploy;
116: }
117:
118: public boolean useDefaultWSDLGenerator() {
119: return this .useDefaultWSDLGenerator;
120: }
121:
122: public String getSmallIconResourceLocation() {
123:
124: return this .smallIconResourceLocation;
125: }
126:
127: public void genDeploymentArtifacts(IServiceUnitContext context) {
128:
129: }
130:
131: public String getEndpointName(Role role, IServiceUnitContext context) {
132: return null;
133: }
134:
135: public String getServiceName(Role role, IServiceUnitContext context) {
136: return null;
137: }
138:
139: public void setComponentProperties(Properties properties) {
140:
141: }
142:
143: // Wrong implementation
144:
145: // public IProperty getPropertyByName(String propertyName,Role role)
146: // {
147: // IWizardPage[] pages=this.getWizardPages(role);
148: // for(int i=0;i<pages.length;i++){
149: // IProperty[] properties=pages[i].getProperties();
150: // if(properties[i].getName().equals(propertyName))
151: // {
152: // return properties[i];
153: // }
154: //
155: // }
156: // return null;
157: // }
158:
159: public IProperty getPropertyByName(String propertyName, Role role) {
160: IWizardPage[] pages = this .getWizardPages(role);
161: for (int i = 0; i < pages.length; i++) {
162: IProperty[] properties = pages[i].getProperties();
163: for (int j = 0; j < properties.length; j++) {
164: if (properties[j].getName().equals(propertyName)) {
165: return properties[j];
166: }
167: }
168: }
169: return null;
170: }
171:
172: public String getComponentURI() {
173: return componentURI;
174: }
175:
176: public class BaseCustWizard implements IWizardPage {
177:
178: protected String name = "";
179:
180: protected String description = "";
181:
182: Vector<IProperty> properies = new Vector<IProperty>();
183:
184: public BaseCustWizard(String name, String description) {
185: super ();
186: this .name = name;
187: this .description = description;
188: }
189:
190: public String getDescription() {
191:
192: return this .description;
193: }
194:
195: public String getName() {
196: return this .name;
197: }
198:
199: public void addProperty(IProperty property) {
200: this .properies.add(property);
201: }
202:
203: public IProperty[] getProperties() {
204:
205: return properies.toArray(new IProperty[properies.size()]);
206: }
207:
208: }
209:
210: public class BaseProperty implements IProperty {
211:
212: protected String name = "";
213:
214: protected boolean readOnly = false;
215:
216: protected boolean required = false;
217:
218: public BaseProperty(String name, boolean readOnly,
219: boolean required) {
220: super ();
221: this .name = name;
222: this .readOnly = readOnly;
223: this .required = required;
224: }
225:
226: public String getName() {
227: return this .name;
228: }
229:
230: public boolean isReadonly() {
231: return this .readOnly;
232: }
233:
234: public boolean isRequired() {
235: return this .required;
236: }
237:
238: }
239:
240: public class TextProperty extends BaseProperty implements
241: ITextProperty {
242:
243: public TextProperty(String name, boolean readOnly,
244: boolean required) {
245: super (name, readOnly, required);
246: }
247:
248: protected String defaultValue = "";
249:
250: protected boolean isPassword = false;
251:
252: public String getDefaultValue() {
253: return this .defaultValue;
254: }
255:
256: public TextProperty(String name, boolean readOnly,
257: boolean required, String defaultValue) {
258: super (name, readOnly, required);
259: this .defaultValue = defaultValue;
260: }
261:
262: public TextProperty(String name, boolean readOnly,
263: boolean required, String defaultValue,
264: boolean isPassword) {
265: this (name, readOnly, required, defaultValue);
266: setIsPassword(isPassword);
267:
268: }
269:
270: public boolean isPassword() {
271: return this .isPassword;
272: }
273:
274: public void setIsPassword(boolean isPassword) {
275: this .isPassword = isPassword;
276: }
277:
278: }
279:
280: public class EnumProperty extends BaseProperty implements
281: IEnumProperty {
282:
283: protected String defaultValue = "";
284:
285: protected String[] values;
286:
287: protected boolean editable = false;
288:
289: public EnumProperty(String name, boolean readOnly,
290: boolean required) {
291: super (name, readOnly, required);
292: }
293:
294: public EnumProperty(String name, boolean readOnly,
295: boolean required, String defaultValue, String[] values,
296: boolean editable) {
297: super (name, readOnly, required);
298: this .defaultValue = defaultValue;
299: this .values = values;
300: this .editable = editable;
301: }
302:
303: public String getDefaultValue() {
304: return this .defaultValue;
305: }
306:
307: public String[] getValues() {
308: return this .values;
309: }
310:
311: public void setValues(String[] values) {
312: this .values = values;
313: }
314:
315: public boolean isEditable() {
316: return this .editable;
317: }
318:
319: }
320:
321: public class BooleanProperty extends BaseProperty implements
322: IBooleanProperty {
323:
324: protected boolean defaultValue;
325:
326: public BooleanProperty(String name, boolean readOnly,
327: boolean required) {
328: super (name, readOnly, required);
329: }
330:
331: public BooleanProperty(String name, boolean readOnly,
332: boolean required, boolean defaultValue) {
333: super (name, readOnly, required);
334: this .defaultValue = defaultValue;
335: }
336:
337: public boolean getDefaultValue() {
338: return this .defaultValue;
339: }
340:
341: }
342:
343: public class FileProperty extends BaseProperty implements
344: IFileProperty {
345:
346: protected String baseFolderName;
347:
348: protected String fileName;
349:
350: protected boolean allowNewFile;
351:
352: protected FolderBrowseStyle folderBrowseStyle = FolderBrowseStyle.FILE_SYSTEM;
353:
354: public FileProperty(String name, boolean readOnly,
355: boolean required) {
356: super (name, readOnly, required);
357: }
358:
359: public FileProperty(String name, boolean readOnly,
360: boolean required, String baseFolderName,
361: String fileName, boolean allowNewFile,
362: FolderBrowseStyle folderBrowseStyle) {
363: super (name, readOnly, required);
364: this .baseFolderName = baseFolderName;
365: this .fileName = fileName;
366: this .allowNewFile = allowNewFile;
367: this .folderBrowseStyle = folderBrowseStyle;
368: }
369:
370: public boolean allowNewFile() {
371: return allowNewFile;
372: }
373:
374: public String getBaseFolderName() {
375: return baseFolderName;
376: }
377:
378: public String getFileName() {
379: return fileName;
380: }
381:
382: public FolderBrowseStyle getFolderBrowseStyle() {
383:
384: return this .folderBrowseStyle;
385: }
386:
387: }
388:
389: public class EndPointProperty extends BaseProperty implements
390: IEndpointProperty {
391:
392: public EndPointProperty(String name, boolean readOnly,
393: boolean required) {
394: super (name, readOnly, required);
395: }
396:
397: protected boolean editable = false;
398:
399: public EndPointProperty(String name, boolean readOnly,
400: boolean required, boolean editable) {
401: super (name, readOnly, required);
402: this .editable = editable;
403: }
404:
405: public boolean isEditable() {
406: return this .editable;
407: }
408:
409: }
410:
411: /* (non-Javadoc)
412: * @see com.bostechcorp.cbesb.common.util.custcomponent.ICustComponent#isConsumerScheduleable()
413: */
414: public boolean isConsumerScheduleable() {
415: return scheduleableConsumer;
416: }
417:
418: /**
419: * @param scheduleableConsumer tells either the consumer suports
420: * or not the schedule function
421: */
422: public void setConsumerScheduleable(boolean scheduleableConsumer) {
423: this.scheduleableConsumer = scheduleableConsumer;
424: }
425: }
|