001: package com.bostechcorp.cbesb.ui.ide.wizards;
002:
003: import org.eclipse.core.resources.IContainer;
004: import org.eclipse.core.resources.IResource;
005: import org.eclipse.jface.viewers.ISelection;
006: import org.eclipse.jface.viewers.IStructuredSelection;
007: import org.eclipse.jface.wizard.IWizardPage;
008: import org.eclipse.jface.wizard.WizardPage;
009: import org.eclipse.swt.SWT;
010: import org.eclipse.swt.events.ModifyEvent;
011: import org.eclipse.swt.events.ModifyListener;
012: import org.eclipse.swt.layout.GridData;
013: import org.eclipse.swt.layout.GridLayout;
014: import org.eclipse.swt.widgets.Combo;
015: import org.eclipse.swt.widgets.Composite;
016: import org.eclipse.swt.widgets.Label;
017: import org.eclipse.ui.IWorkbench;
018:
019: import com.bostechcorp.cbesb.common.i18n.I18N;
020: import com.bostechcorp.cbesb.common.i18n.Messages;
021: import com.bostechcorp.cbesb.common.util.custom.code.CustomCodeConstants;
022:
023: public class CustomCodeWizardMainPage extends WizardPage {
024:
025: private ISelection selection;
026:
027: private IWorkbench workbench;
028:
029: private Combo languageCombo;
030:
031: private Combo typeCombo;
032:
033: /**
034: * Constructor for TransformerFormatCreationWizardPage.
035: *
036: * @param workbench
037: * @param selection
038: */
039: public CustomCodeWizardMainPage(IWorkbench workbench,
040: ISelection selection) {
041: super ("MainPage");
042: this .selection = selection;
043: this .workbench = workbench;
044: setTitle(I18N.getString(Messages.CUSTOM_CODE_MAIN_PAGE));// "Choose
045: setDescription(I18N
046: .getString(Messages.CUSTOM_CODE_MAIN_PAGE_TIP));// "Choose
047:
048: }
049:
050: public void createControl(Composite parent) {
051:
052: final Composite composite = new Composite(parent, SWT.NONE);
053: final GridLayout gridLayout = new GridLayout();
054: gridLayout.marginTop = 5;
055: gridLayout.verticalSpacing = 10;
056: gridLayout.numColumns = 2;
057: composite.setLayout(gridLayout);
058:
059: final Label typeLabel = new Label(composite, SWT.NONE);
060: typeLabel.setText(I18N.getString(Messages.TYPE));
061:
062: typeCombo = new Combo(composite, SWT.READ_ONLY);
063: typeCombo.setItems(new String[] {
064: CustomCodeConstants.MAP_FILTER,
065: CustomCodeConstants.MAP_USER_OPERATION,
066: CustomCodeConstants.TRX_ID, CustomCodeConstants.UPOC,
067: CustomCodeConstants.SCRIPT_COMPONENT,
068: CustomCodeConstants.ETL_ERROR_HANDLER });
069:
070: typeCombo.setText(CustomCodeConstants.UPOC);
071: typeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
072: true, false));
073:
074: final Label languageLabel = new Label(composite, SWT.NONE);
075: languageLabel.setText(I18N.getString(Messages.LANGUAGE));
076:
077: languageCombo = new Combo(composite, SWT.READ_ONLY);
078: languageCombo.setItems(new String[] { "Java", "Groovy" });
079: languageCombo.setText("Java");
080: languageCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
081: true, false));
082: languageCombo.addModifyListener(new ModifyListener() {
083:
084: public void modifyText(ModifyEvent e) {
085:
086: if (languageCombo.getText().equalsIgnoreCase("java")) {
087: typeCombo.removeAll();
088: typeCombo.setItems(new String[] {
089: CustomCodeConstants.MAP_FILTER,
090: CustomCodeConstants.MAP_USER_OPERATION,
091: CustomCodeConstants.TRX_ID,
092: CustomCodeConstants.UPOC,
093: CustomCodeConstants.SCRIPT_COMPONENT,
094: CustomCodeConstants.ETL_ERROR_HANDLER });
095: typeCombo.setText(CustomCodeConstants.UPOC);
096: } else if (languageCombo.getText().equalsIgnoreCase(
097: "groovy")) {
098: typeCombo.removeAll();
099: typeCombo.setItems(new String[] {
100: CustomCodeConstants.TRX_ID,
101: CustomCodeConstants.UPOC,
102: CustomCodeConstants.SCRIPT_COMPONENT });
103: typeCombo.setText(CustomCodeConstants.UPOC);
104: }
105: }
106:
107: });
108:
109: initialize();
110: setControl(composite);
111: }
112:
113: @Override
114: public IWizardPage getNextPage() {
115:
116: if (languageCombo.getText().equalsIgnoreCase("Java")) {
117: CustomCodeWizardPojoPage javaPage = ((CustomCodeWizard) this
118: .getWizard()).getPojoPage();
119:
120: if (typeCombo.getText().equalsIgnoreCase(
121: CustomCodeConstants.MAP_FILTER)
122: || typeCombo.getText().equalsIgnoreCase(
123: CustomCodeConstants.UPOC)) {
124: if (javaPage.getMethod().equals("")) {
125: javaPage.setPageComplete(false);
126: if (javaPage.getName().equals(""))
127: javaPage.updateStatus(I18N
128: .getString(Messages.NAME_REQ));
129: else
130: javaPage.updateStatus(I18N
131: .getString(Messages.METHOD_REQUIRED));
132: }
133: javaPage.changeMethodVisable(true);
134: } else {
135: javaPage.changeMethodVisable(false);
136: if (!javaPage.getName().equals("")) {
137: javaPage.setPageComplete(true);
138: javaPage.updateStatus(null);
139: }
140: }
141: return javaPage;
142: } else if (languageCombo.getText().equalsIgnoreCase("Groovy")) {
143: CustomCodeWizardGroovyPage groovyPage = ((CustomCodeWizard) this
144: .getWizard()).getGroovyPage();
145: if (typeCombo.getText().equalsIgnoreCase(
146: CustomCodeConstants.MAP_FILTER)
147: || typeCombo.getText().equalsIgnoreCase(
148: CustomCodeConstants.UPOC)) {
149: if (groovyPage.getMethod().equals("")) {
150: groovyPage.setPageComplete(false);
151: if (groovyPage.getName().equals(""))
152: groovyPage.updateStatus(I18N
153: .getString(Messages.NAME_REQ));
154: else
155: groovyPage.updateStatus(I18N
156: .getString(Messages.METHOD_REQUIRED));
157: }
158:
159: groovyPage.changeMethodVisable(true);
160: } else {
161: groovyPage.changeMethodVisable(false);
162: if (!groovyPage.getName().equals("")) {
163: groovyPage.setPageComplete(true);
164: groovyPage.updateStatus(null);
165: }
166: }
167: return groovyPage;
168: }
169: return super .getNextPage();
170: }
171:
172: public boolean finish() {
173: return false;
174: }
175:
176: public Combo getTypeCombo() {
177: return typeCombo;
178: }
179:
180: public Combo getLanguageCombo() {
181: return languageCombo;
182: }
183:
184: private void initialize() {
185: if (selection != null && selection.isEmpty() == false
186: && selection instanceof IStructuredSelection) {
187: IStructuredSelection ssel = (IStructuredSelection) selection;
188: if (ssel.size() > 1)
189: return;
190: Object obj = ssel.getFirstElement();
191: if (obj instanceof IResource) {
192: IContainer container;
193: if (obj instanceof IContainer)
194: container = (IContainer) obj;
195: else
196: container = ((IResource) obj).getParent();
197: // targetfileNameText.setText(container.getFullPath().toString());
198: }
199: }
200: }
201:
202: }
|