001: /**
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the
009: * Free Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: *
022: * $Id$
023: */package com.bostechcorp.cbesb.ui.ide.customcomponent.wizard;
024:
025: import java.util.ArrayList;
026: import java.util.List;
027:
028: import org.eclipse.jface.viewers.ICellEditorValidator;
029: import org.eclipse.jface.wizard.IWizardPage;
030: import org.eclipse.jface.wizard.WizardPage;
031: import org.eclipse.swt.SWT;
032: import org.eclipse.swt.widgets.Composite;
033:
034: import com.bostechcorp.cbesb.common.i18n.I18N;
035: import com.bostechcorp.cbesb.common.i18n.Messages;
036: import com.bostechcorp.cbesb.common.util.custcomponent.ICustComponent.Role;
037: import com.bostechcorp.cbesb.ui.ide.customcomponent.wizard.UIPagesPropertiesComposite.UIErrorsEnum;
038:
039: /**
040: * @author LPS
041: *
042: */
043: public class ConsumerEditorWizardPage extends WizardPage {
044: CBCCProjectCreationWizardPage mainPage;
045:
046: UIPagesPropertiesComposite composite = null;
047:
048: protected ConsumerEditorWizardPage(String pageName,
049: CBCCProjectCreationWizardPage mainPage) {
050: super (pageName);
051: this .mainPage = mainPage;
052:
053: setTitle(I18N.getString(Messages.CBCC_CONSUMER_PAGE_TITLE));
054: setDescription(I18N
055: .getString(Messages.CBCC_CONSUMER_PAGE_DESCRIPTION));
056: }
057:
058: /* (non-Javadoc)
059: * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
060: */
061: public void createControl(Composite parent) {
062: composite = new UIPagesPropertiesComposite(parent, SWT.NULL);
063: composite.setFont(parent.getFont());
064:
065: composite.getPropertyNameEditor().setValidator(
066: new ICellEditorValidator() {
067:
068: public String isValid(Object value) {
069: updatePageComplete();
070: return null;
071: }
072: });
073:
074: composite.getPageNameEditor().setValidator(
075: new ICellEditorValidator() {
076:
077: public String isValid(Object value) {
078: updatePageComplete();
079: return null;
080: }
081: });
082:
083: setPageComplete(true);
084: // Show description on opening
085: setMessage(null);
086: setControl(composite);
087: }
088:
089: protected void updatePageComplete() {
090: setPageComplete(isPageValid());
091:
092: }
093:
094: public List<PagesModelTableItem> getPages() {
095: List<PagesModelTableItem> pages = composite.getPages();
096: if (pages.isEmpty()) {
097: pages.add(new PagesModelTableItem("Consumer Page",
098: "Consumer Pages",
099: new ArrayList<PropertiesModelTableItem>()));
100: }
101: return pages;
102: }
103:
104: @Override
105: public IWizardPage getNextPage() {
106: if (mainPage.getRole().equals(Role.CONSUMER)) {
107: return getWizard().getPage(
108: "JavaCapabilityConfigurationPage");
109: }
110: return super .getNextPage();
111: }
112:
113: private boolean isPageValid() {
114: boolean valid = composite.isTableValid()
115: && composite.isTable1Valid();
116:
117: if (composite.ERROR == UIErrorsEnum.IDENTICAL_NAME_PAGE) {
118: setErrorMessage(I18N
119: .getString(Messages.CBCC_ERROR_IDENTICAL_PAGE_NAMES));
120: composite.ERROR = UIErrorsEnum.NO_ERROR;
121: //setPageComplete(valid);
122: return valid;
123: }
124: if (composite.ERROR == UIErrorsEnum.IDENTICAL_NAME_PROPERTY) {
125: setErrorMessage(I18N
126: .getString(Messages.CBCC_ERROR_IDENTICAL_PROPERTY_NAMES));
127: composite.ERROR = UIErrorsEnum.NO_ERROR;
128: //setPageComplete(valid);
129: return valid;
130: }
131: setErrorMessage(null);
132: composite.ERROR = UIErrorsEnum.NO_ERROR;
133: //setPageComplete(valid);
134: return valid;
135: }
136: }
|