001: package com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards;
002:
003: import org.eclipse.jface.wizard.WizardPage;
004: import org.eclipse.swt.SWT;
005: import org.eclipse.swt.events.ModifyEvent;
006: import org.eclipse.swt.events.ModifyListener;
007: import org.eclipse.swt.layout.GridData;
008: import org.eclipse.swt.layout.GridLayout;
009: import org.eclipse.swt.widgets.Composite;
010: import org.eclipse.swt.widgets.Label;
011: import org.eclipse.swt.widgets.Text;
012:
013: import com.bostechcorp.cbesb.common.i18n.I18N;
014: import com.bostechcorp.cbesb.common.i18n.Messages;
015: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.Comment;
016:
017: public class CommentPropertyWizardMainPage extends
018: DecorativePropertyWizardPage implements ModifyListener {
019: private Label labelName;
020:
021: private Text textDescription;
022:
023: private Label labelDescription;
024:
025: private Text textName;
026:
027: protected CommentPropertyWizardMainPage(String pageName) {
028: super (pageName);
029: setTitle(I18N.getString(Messages.COMMENT_PRO_WIZ));
030: setDescription(I18N.getString(Messages.PAGE_MAIN_DES));
031: }
032:
033: public void createControl(Composite parent) {
034: final Composite topLevel = new Composite(parent, SWT.NONE);
035: setControl(topLevel); // critical method call
036: try {
037: GridLayout this Layout = new GridLayout();
038: this Layout.numColumns = 2;
039: topLevel.setLayout(this Layout);
040: topLevel.setSize(258, 179);
041: {
042: labelName = new Label(topLevel, SWT.NONE);
043: GridData label1LData = new GridData();
044: label1LData.heightHint = 13;
045: label1LData.horizontalAlignment = GridData.FILL;
046: label1LData.verticalAlignment = GridData.BEGINNING;
047: labelName.setLayoutData(label1LData);
048: labelName.setText(I18N.getString(Messages.NAME_WIZ));
049: }
050: {
051: textName = new Text(topLevel, SWT.BORDER);
052: GridData text1LData = new GridData();
053: text1LData.grabExcessHorizontalSpace = true;
054: text1LData.verticalAlignment = GridData.BEGINNING;
055: text1LData.horizontalAlignment = GridData.FILL;
056: textName.setLayoutData(text1LData);
057: textName.addModifyListener(this );
058: }
059: {
060: labelDescription = new Label(topLevel, SWT.NONE);
061: GridData label2LData = new GridData();
062: label2LData.heightHint = 13;
063: label2LData.verticalAlignment = GridData.BEGINNING;
064: label2LData.horizontalAlignment = GridData.FILL;
065: labelDescription.setLayoutData(label2LData);
066: labelDescription.setText(I18N
067: .getString(Messages.DES_WIZ));
068: }
069: {
070: textDescription = new Text(topLevel, SWT.V_SCROLL
071: | SWT.MULTI | SWT.BORDER | SWT.WRAP);
072: GridData text2LData = new GridData();
073: text2LData.horizontalAlignment = GridData.FILL;
074: text2LData.verticalAlignment = GridData.FILL;
075: text2LData.grabExcessHorizontalSpace = true;
076: text2LData.grabExcessVerticalSpace = true;
077: textDescription.setLayoutData(text2LData);
078: textDescription.addModifyListener(this );
079: }
080: topLevel.layout();
081:
082: if (this .getWizard().isUpdateOperation()) {
083: modelsToControl();
084: }
085: } catch (Exception e) {
086: e.printStackTrace();
087: }
088: }
089:
090: @Override
091: public void controlToModels() {
092: CommentPropertyWizard commentWizard = (CommentPropertyWizard) this
093: .getWizard();
094: Comment models = commentWizard.getModels();
095: if (models == null) {
096: return;
097: }
098:
099: try {
100: if (textName.getText().equals("")) {
101: models.setName("Comment");
102: } else {
103: models.setName(textName.getText());
104: }
105:
106: if (textDescription.getText().equals("")) {
107: models.setDescription("Default Empty Description");
108: } else {
109: models.setDescription(textDescription.getText());
110: }
111:
112: } catch (Exception e) {
113: e.printStackTrace();
114: }
115:
116: }
117:
118: @Override
119: public void modelsToControl() {
120: CommentPropertyWizard commentWizard = (CommentPropertyWizard) this
121: .getWizard();
122: // if (commentWizard.getModels() == null) {return;}
123:
124: Comment models = commentWizard.getModels();
125: if (models.getName() != null) {
126: textName.setText(models.getName());
127: } else {
128: textName.setText("");
129: }
130:
131: if (models.getDescription() != null) {
132: textDescription.setText(models.getDescription());
133: } else {
134: textDescription.setText("");
135: }
136: }
137:
138: private void dialogChanged() {
139: if (WizardUtil.whetherUseValidation == false) {
140: setPageComplete(true);
141: return;
142: }
143: if (textName.getText().equals("")) {
144: setMessage(I18N.getString(Messages.NAME_REQ),
145: WizardPage.ERROR);
146: setPageComplete(false);
147: return;
148: } else if (textDescription.getText().equals("")) {
149: setMessage(I18N
150: .getString(Messages.COMMENT_DESCRIPTION_WARNING),
151: WizardPage.WARNING);
152: setPageComplete(true);
153: return;
154: }
155: setPageComplete(true);
156: setMessage(null);
157: }
158:
159: public void modifyText(ModifyEvent e) {
160: dialogChanged();
161: }
162: }
|