01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.axis2.tool.codegen.eclipse.ui;
20:
21: import org.apache.axis2.tool.codegen.eclipse.CodeGenWizard;
22: import org.apache.axis2.tool.codegen.eclipse.plugin.CodegenWizardPlugin;
23: import org.apache.axis2.tool.codegen.eclipse.util.SettingsConstants;
24: import org.eclipse.jface.dialogs.IDialogSettings;
25: import org.eclipse.jface.wizard.WizardPage;
26:
27: public abstract class AbstractWizardPage extends WizardPage implements
28: SettingsConstants {
29:
30: protected IDialogSettings settings;
31: protected boolean restoredFromPreviousSettings = false;
32:
33: public AbstractWizardPage(String pageName) {
34: super (pageName + ".name");
35: init(pageName);
36: }
37:
38: protected void init(String pageName) {
39: setTitle(CodegenWizardPlugin.getResourceString(pageName
40: + ".title"));
41: setDescription(CodegenWizardPlugin.getResourceString(pageName
42: + ".desc"));
43: setImageDescriptor(CodegenWizardPlugin
44: .getWizardImageDescriptor());
45:
46: /*
47: * Get the settings for this page. If there is no section in the
48: * Plugin's settings for this OptionsPage, create a new section
49: */
50: IDialogSettings rootSettings = CodegenWizardPlugin.getDefault()
51: .getDialogSettings();
52: IDialogSettings section = rootSettings.getSection(this
53: .getClass().getName());
54: if (section == null) {
55: settings = rootSettings.addNewSection(this .getClass()
56: .getName());
57: restoredFromPreviousSettings = false;
58: initializeDefaultSettings();
59: } else {
60: restoredFromPreviousSettings = true;
61: settings = section;
62: }
63: }
64:
65: protected void updateStatus(String message) {
66: setErrorMessage(message);
67: setPageComplete(message == null);
68: }
69:
70: protected abstract void initializeDefaultSettings();
71:
72: public abstract int getPageType();
73:
74: /**
75: * a convenient method to get the wizard
76: * @return
77: */
78: public CodeGenWizard getCodegenWizard() {
79: return (CodeGenWizard) getWizard();
80: }
81: }
|