validationfor file and task panels in first step.
1.1 --- a/enterprise/openesbaddons/workflow/editor/src/org/netbeans/modules/worklist/wizard/TaskPanel.java Fri Jun 22 01:40:36 2007 +0000
1.2 +++ b/enterprise/openesbaddons/workflow/editor/src/org/netbeans/modules/worklist/wizard/TaskPanel.java Fri Jun 22 02:36:53 2007 +0000
1.3 @@ -1,6 +1,9 @@
1.4 package org.netbeans.modules.worklist.wizard;
1.5
1.6 +import java.beans.PropertyChangeListener;
1.7 +import java.beans.PropertyChangeSupport;
1.8 import javax.swing.JPanel;
1.9 +import javax.swing.JTextField;
1.10 import javax.swing.event.DocumentEvent;
1.11 import javax.swing.event.DocumentListener;
1.12 import org.netbeans.modules.wlm.model.spi.OperationReference;
1.13 @@ -16,14 +19,17 @@
1.14
1.15 public final class TaskPanel extends JPanel {
1.16
1.17 + public static final String PROP_WSDL_OPERATION = "PROP_WSDL_OPERATION";
1.18 private DataObject dObj;
1.19
1.20 private Operation selectedOperation;
1.21
1.22 - private WorklistWizardPanel1 parent;
1.23 + private WorklistWizardBottomPanel1 parent;
1.24 +
1.25 + private PropertyChangeSupport pSupport = new PropertyChangeSupport(this);
1.26
1.27 /** Creates new form WorklistVisualPanel1 */
1.28 - public TaskPanel(WorklistWizardPanel1 parent, DataObject folder) {
1.29 + public TaskPanel(WorklistWizardBottomPanel1 parent, DataObject folder) {
1.30 this.dObj = folder;
1.31 this.parent = parent;
1.32 initComponents();
1.33 @@ -106,11 +112,13 @@
1.34 dDis.notify(dd);
1.35
1.36 if (dd.getValue() == DialogDescriptor.OK_OPTION ) {
1.37 + Operation oldOperation = this.selectedOperation;
1.38 this.selectedOperation = listener.getSelectedOperation();
1.39 if(this.selectedOperation != null) {
1.40 this.wsdlOperationTextField.setText(this.selectedOperation.getName());
1.41 }
1.42 - this.parent.fireChangeEvent();
1.43 +
1.44 + pSupport.firePropertyChange(PROP_WSDL_OPERATION, oldOperation, selectedOperation);
1.45 }
1.46 }//GEN-LAST:event_selectOperationButtonActionPerformed
1.47
1.48 @@ -126,27 +134,24 @@
1.49 return this.selectedOperation;
1.50 }
1.51
1.52 + public JTextField getTaskNameTextField() {
1.53 + return this.taskNameTextField;
1.54 + }
1.55 +
1.56 + public JTextField getTaskOperationTextField() {
1.57 + return this.wsdlOperationTextField;
1.58 + }
1.59 +
1.60 private void initGUI() {
1.61 - this.taskNameTextField.getDocument().addDocumentListener(new TaskNameDocumentListener());
1.62
1.63 }
1.64
1.65 + public void addPropertyChangeListener(PropertyChangeListener l) {
1.66 + pSupport.addPropertyChangeListener(l);
1.67 + }
1.68
1.69 - class TaskNameDocumentListener implements DocumentListener {
1.70 -
1.71 - public void insertUpdate(DocumentEvent e) {
1.72 - parent.fireChangeEvent();
1.73 - }
1.74 -
1.75 - public void removeUpdate(DocumentEvent e) {
1.76 - parent.fireChangeEvent();
1.77 - }
1.78 -
1.79 - public void changedUpdate(DocumentEvent e) {
1.80 -
1.81 - }
1.82 -
1.83 -
1.84 + public void removePropertyChangeListener(PropertyChangeListener l) {
1.85 + pSupport.removePropertyChangeListener(l);
1.86 }
1.87
1.88 // Variables declaration - do not modify//GEN-BEGIN:variables
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/enterprise/openesbaddons/workflow/editor/src/org/netbeans/modules/worklist/wizard/WorklistWizardBottomPanel1.java Fri Jun 22 02:36:53 2007 +0000
2.3 @@ -0,0 +1,247 @@
2.4 +package org.netbeans.modules.worklist.wizard;
2.5 +
2.6 +import java.awt.Component;
2.7 +import java.beans.PropertyChangeEvent;
2.8 +import java.beans.PropertyChangeListener;
2.9 +import java.util.HashSet;
2.10 +import java.util.Iterator;
2.11 +import java.util.Set;
2.12 +import javax.swing.JTextField;
2.13 +import javax.swing.event.ChangeEvent;
2.14 +import javax.swing.event.ChangeListener;
2.15 +import javax.swing.event.DocumentEvent;
2.16 +import javax.swing.event.DocumentListener;
2.17 +import javax.swing.text.Document;
2.18 +import org.netbeans.modules.xml.wsdl.model.Operation;
2.19 +import org.openide.WizardDescriptor;
2.20 +import org.openide.loaders.DataObject;
2.21 +import org.openide.loaders.TemplateWizard;
2.22 +import org.openide.util.HelpCtx;
2.23 +
2.24 +public class WorklistWizardBottomPanel1 implements WizardDescriptor.FinishablePanel {
2.25 +
2.26 + /**
2.27 + * The visual component that displays this panel. If you need to access the
2.28 + * component from this class, just use getComponent().
2.29 + */
2.30 + private TaskPanel component;
2.31 +
2.32 + private DataObject dObj;
2.33 +
2.34 + private JTextField fileNameTextField;
2.35 +
2.36 + private String mErrorMessage;
2.37 +
2.38 + private String oldFileName = "";
2.39 +
2.40 + private TemplateWizard templateWizard;
2.41 +
2.42 + private TextChangeListener mListener = new TextChangeListener();
2.43 +
2.44 +
2.45 + public WorklistWizardBottomPanel1(DataObject folder) {
2.46 + this.dObj = folder;
2.47 + }
2.48 +
2.49 + // Get the visual component for the panel. In this template, the component
2.50 + // is kept separate. This can be more efficient: if the wizard is created
2.51 + // but never displayed, or not all panels are displayed, it is better to
2.52 + // create only those which really need to be visible.
2.53 + public Component getComponent() {
2.54 + if (component == null) {
2.55 + component = new TaskPanel(this, this.dObj);
2.56 + component.getTaskNameTextField().getDocument().addDocumentListener(new TaskNameDocumentListener());
2.57 + component.addPropertyChangeListener(new WSDLOperationPropertyChangeListener() );
2.58 + }
2.59 + return component;
2.60 + }
2.61 +
2.62 + public HelpCtx getHelp() {
2.63 + // Show no Help button for this panel:
2.64 + return HelpCtx.DEFAULT_HELP;
2.65 + // If you have context help:
2.66 + // return new HelpCtx(SampleWizardPanel1.class);
2.67 + }
2.68 +
2.69 + public boolean isValid() {
2.70 +
2.71 + if(templateWizard != null) {
2.72 + templateWizard.putProperty ("WizardPanel_errorMessage", this.mErrorMessage); // NOI18N
2.73 + }
2.74 +
2.75 + return this.mErrorMessage == null;
2.76 +
2.77 +
2.78 +
2.79 + // If it is always OK to press Next or Finish, then:
2.80 +
2.81 + // If it depends on some condition (form filled out...), then:
2.82 + // return someCondition();
2.83 + // and when this condition changes (last form field filled in...) then:
2.84 + // fireChangeEvent();
2.85 + // and uncomment the complicated stuff below.
2.86 + }
2.87 +
2.88 + public boolean isFinishPanel() {
2.89 + return true;
2.90 + }
2.91 +
2.92 +
2.93 +// public final void addChangeListener(ChangeListener l) {}
2.94 +// public final void removeChangeListener(ChangeListener l) {}
2.95 +//
2.96 + private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(1); // or can use ChangeSupport in NB 6.0
2.97 + public final void addChangeListener(ChangeListener l) {
2.98 + synchronized (listeners) {
2.99 + listeners.add(l);
2.100 + }
2.101 + }
2.102 + public final void removeChangeListener(ChangeListener l) {
2.103 + synchronized (listeners) {
2.104 + listeners.remove(l);
2.105 + }
2.106 + }
2.107 + protected final void fireChangeEvent() {
2.108 + Iterator<ChangeListener> it;
2.109 + synchronized (listeners) {
2.110 + it = new HashSet<ChangeListener>(listeners).iterator();
2.111 + }
2.112 + ChangeEvent ev = new ChangeEvent(this);
2.113 + while (it.hasNext()) {
2.114 + it.next().stateChanged(ev);
2.115 + }
2.116 + }
2.117 +
2.118 +
2.119 + // You can use a settings object to keep track of state. Normally the
2.120 + // settings object will be the WizardDescriptor, so you can use
2.121 + // WizardDescriptor.getProperty & putProperty to store information entered
2.122 + // by the user.
2.123 + public void readSettings(Object settings) {
2.124 + templateWizard = (TemplateWizard)settings;
2.125 +
2.126 +
2.127 + }
2.128 +
2.129 + public void storeSettings(Object settings) {
2.130 + WizardDescriptor descriptor = (WizardDescriptor) settings;
2.131 + descriptor.putProperty(WizardConstants.TASK_NAME, component.getTaskName());
2.132 + descriptor.putProperty(WizardConstants.TASK_OPERATION, component.getSelectedOperation());
2.133 + }
2.134 +
2.135 + public void setNameTF(JTextField nameTF) {
2.136 + //gui.attachFileNameListener(nameTF);
2.137 + if(nameTF != null) {
2.138 + nameTF.getDocument().removeDocumentListener(mListener);//remove existing one
2.139 + nameTF.getDocument().addDocumentListener(mListener);
2.140 + fileNameTextField = nameTF;
2.141 + }
2.142 + }
2.143 +
2.144 +
2.145 +
2.146 + private boolean isValidName(Document doc) {
2.147 + try {
2.148 + String text = doc.getText(0, doc.getLength());
2.149 + boolean isValid = org.netbeans.modules.xml.xam.dom.Utils.isValidNCName(text);
2.150 + if(!isValid) {
2.151 + mErrorMessage = "Name \"" + text + "\" is not a valid NCName";
2.152 + } else {
2.153 + mErrorMessage = null;
2.154 + }
2.155 +
2.156 + } catch(Exception ex) {
2.157 + ex.printStackTrace();
2.158 + }
2.159 +
2.160 + return mErrorMessage == null;
2.161 + }
2.162 +
2.163 +
2.164 + void validateTask() {
2.165 + String taskName = component.getTaskName();
2.166 + if(taskName == null || taskName.equals("")) {
2.167 + this.mErrorMessage = "Provide a valid task name.";
2.168 + }
2.169 +
2.170 + validateOperation();
2.171 +
2.172 +
2.173 + }
2.174 +
2.175 + void validateOperation() {
2.176 +
2.177 + Operation operation = component.getSelectedOperation();
2.178 + if( operation == null) {
2.179 + this.mErrorMessage = "Select a valid request-reply wsdl operation.";
2.180 +
2.181 + } else {
2.182 + this.mErrorMessage = null;
2.183 + }
2.184 +
2.185 + fireChangeEvent();
2.186 + }
2.187 +
2.188 + private void validateFileName() {
2.189 + boolean validFileName = isValidName(this.fileNameTextField.getDocument());
2.190 + if(!validFileName) {
2.191 + fireChangeEvent();
2.192 + }
2.193 +
2.194 + String taskNamePrefix = "Task";
2.195 + String newTaskName = this.fileNameTextField.getText() + taskNamePrefix;
2.196 + String oldTaskName = oldFileName + taskNamePrefix;
2.197 +
2.198 + String taskName = component.getTaskName();
2.199 +
2.200 + if(taskName == null || taskName.trim().equals("") || taskName.equals(oldTaskName)) {
2.201 + component.setTaskName(newTaskName);
2.202 + }
2.203 +
2.204 + oldFileName = this.fileNameTextField.getText();
2.205 +
2.206 + }
2.207 +
2.208 + class TextChangeListener implements DocumentListener {
2.209 +
2.210 + public void changedUpdate(DocumentEvent e) {
2.211 + validateFileName();
2.212 + }
2.213 +
2.214 + public void insertUpdate(DocumentEvent e) {
2.215 + validateFileName();
2.216 + }
2.217 +
2.218 + public void removeUpdate(DocumentEvent e) {
2.219 + validateFileName();
2.220 + }
2.221 +
2.222 + }
2.223 +
2.224 + class TaskNameDocumentListener implements DocumentListener {
2.225 +
2.226 + public void insertUpdate(DocumentEvent e) {
2.227 + validateTask();
2.228 + }
2.229 +
2.230 + public void removeUpdate(DocumentEvent e) {
2.231 + validateTask();
2.232 + }
2.233 +
2.234 + public void changedUpdate(DocumentEvent e) {
2.235 +
2.236 + }
2.237 +
2.238 +
2.239 + }
2.240 +
2.241 + class WSDLOperationPropertyChangeListener implements PropertyChangeListener {
2.242 +
2.243 + public void propertyChange(PropertyChangeEvent evt) {
2.244 + validateOperation();
2.245 + }
2.246 +
2.247 + }
2.248 +
2.249 +}
2.250 +
3.1 --- a/enterprise/openesbaddons/workflow/editor/src/org/netbeans/modules/worklist/wizard/WorklistWizardIterator.java Fri Jun 22 01:40:36 2007 +0000
3.2 +++ b/enterprise/openesbaddons/workflow/editor/src/org/netbeans/modules/worklist/wizard/WorklistWizardIterator.java Fri Jun 22 02:36:53 2007 +0000
3.3 @@ -48,12 +48,12 @@
3.4 Project project = FileOwnerQuery.getOwner(folder.getPrimaryFile());
3.5 Sources sources = (Sources) project.getLookup().lookup(org.netbeans.api.project.Sources.class);
3.6 SourceGroup[] sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC);
3.7 - WorklistWizardPanel1 bottomPanel =new WorklistWizardPanel1(folder);
3.8 + WorklistWizardBottomPanel1 bottomPanel =new WorklistWizardBottomPanel1(folder);
3.9 // creates simple wizard panel with bottom panel
3.10 - WizardDescriptor.Panel firstPanel = new WizardNewWSDLStep(Templates.createSimpleTargetChooser(project,sourceGroups,bottomPanel));
3.11 + WizardDescriptor.Panel firstPanel = new WorklistWizardPanel1(Templates.createSimpleTargetChooser(project,sourceGroups,bottomPanel), bottomPanel);
3.12 JComponent comp = (JComponent)firstPanel.getComponent();
3.13 // the bottom panel should listen to changes on file name text field
3.14 - ((WorklistWizardPanel1)bottomPanel).setNameTF(findFileNameField(comp, Templates.getTargetName(this.wizard)));
3.15 + ((WorklistWizardBottomPanel1)bottomPanel).setNameTF(findFileNameField(comp, Templates.getTargetName(this.wizard)));
3.16
3.17 panels = new WizardDescriptor.Panel[] {
3.18 //new WorklistWizardPanel1(folder),
3.19 @@ -113,9 +113,11 @@
3.20
3.21 String taskName = (String) wiz.getProperty(WizardConstants.TASK_NAME);
3.22 Operation op = (Operation) wiz.getProperty(WizardConstants.TASK_OPERATION);
3.23 + String partnerLinkName = taskName + "PartnerLink";
3.24 TTask task = model.getFactory().createTask(model);
3.25 model.getTasks().addTask(task);
3.26 task.setName(taskName);
3.27 + task.setPartnerLink(partnerLinkName);
3.28 task.setOperation(task.createOperationReference(op));
3.29 model.endTransaction();
3.30
4.1 --- a/enterprise/openesbaddons/workflow/editor/src/org/netbeans/modules/worklist/wizard/WorklistWizardPanel1.java Fri Jun 22 01:40:36 2007 +0000
4.2 +++ b/enterprise/openesbaddons/workflow/editor/src/org/netbeans/modules/worklist/wizard/WorklistWizardPanel1.java Fri Jun 22 02:36:53 2007 +0000
4.3 @@ -1,187 +1,89 @@
4.4 +/*
4.5 + * The contents of this file are subject to the terms of the Common Development
4.6 + * and Distribution License (the License). You may not use this file except in
4.7 + * compliance with the License.
4.8 + *
4.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
4.10 + * or http://www.netbeans.org/cddl.txt.
4.11 + *
4.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
4.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
4.14 + * If applicable, add the following below the CDDL Header, with the fields
4.15 + * enclosed by brackets [] replaced by your own identifying information:
4.16 + * "Portions Copyrighted [year] [name of copyright owner]"
4.17 + *
4.18 + * The Original Software is NetBeans. The Initial Developer of the Original
4.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
4.20 + * Microsystems, Inc. All Rights Reserved.
4.21 + */
4.22 +
4.23 package org.netbeans.modules.worklist.wizard;
4.24
4.25 import java.awt.Component;
4.26 -import java.util.HashSet;
4.27 +import java.awt.Dimension;
4.28 +import java.util.ArrayList;
4.29 import java.util.Iterator;
4.30 -import java.util.Set;
4.31 -import javax.swing.JTextField;
4.32 +import java.util.List;
4.33 +
4.34 import javax.swing.event.ChangeEvent;
4.35 import javax.swing.event.ChangeListener;
4.36 import javax.swing.event.DocumentEvent;
4.37 import javax.swing.event.DocumentListener;
4.38 import javax.swing.text.Document;
4.39 -import org.netbeans.modules.xml.wsdl.model.Operation;
4.40 +
4.41 +import org.netbeans.api.project.Project;
4.42 import org.openide.WizardDescriptor;
4.43 -import org.openide.loaders.DataObject;
4.44 import org.openide.loaders.TemplateWizard;
4.45 import org.openide.util.HelpCtx;
4.46 +import org.openide.util.NbBundle;
4.47
4.48 +/**
4.49 + *
4.50 + * @author radval
4.51 + */
4.52 public class WorklistWizardPanel1 implements WizardDescriptor.FinishablePanel {
4.53 + private WizardDescriptor.Panel mPanel;
4.54 +
4.55 + private WorklistWizardBottomPanel1 bottomPanel;
4.56
4.57 - /**
4.58 - * The visual component that displays this panel. If you need to access the
4.59 - * component from this class, just use getComponent().
4.60 - */
4.61 - private TaskPanel component;
4.62 -
4.63 - private DataObject dObj;
4.64 -
4.65 - private JTextField fileNameTextField;
4.66 -
4.67 - private String mErrorMessage;
4.68 -
4.69 - private TemplateWizard templateWizard;
4.70 -
4.71 - private TextChangeListener mListener = new TextChangeListener();
4.72 -
4.73 -
4.74 - public WorklistWizardPanel1(DataObject folder) {
4.75 - this.dObj = folder;
4.76 + public WorklistWizardPanel1(WizardDescriptor.Panel panel, WorklistWizardBottomPanel1 bottomPanel) {
4.77 + this.mPanel = panel;
4.78 + this.bottomPanel = bottomPanel;
4.79 }
4.80
4.81 - // Get the visual component for the panel. In this template, the component
4.82 - // is kept separate. This can be more efficient: if the wizard is created
4.83 - // but never displayed, or not all panels are displayed, it is better to
4.84 - // create only those which really need to be visible.
4.85 - public Component getComponent() {
4.86 - if (component == null) {
4.87 - component = new TaskPanel(this, this.dObj);
4.88 - }
4.89 - return component;
4.90 - }
4.91 -
4.92 - public HelpCtx getHelp() {
4.93 - // Show no Help button for this panel:
4.94 - return HelpCtx.DEFAULT_HELP;
4.95 - // If you have context help:
4.96 - // return new HelpCtx(SampleWizardPanel1.class);
4.97 - }
4.98 -
4.99 - public boolean isValid() {
4.100 - String taskName = component.getTaskName();
4.101 - Operation operation = component.getSelectedOperation();
4.102 - if(taskName != null && !taskName.equals("") && operation != null) {
4.103 - return true;
4.104 - }
4.105 -
4.106 - if(templateWizard != null) {
4.107 - templateWizard.putProperty ("WizardPanel_errorMessage", this.mErrorMessage); // NOI18N
4.108 - }
4.109 - return this.mErrorMessage == null;
4.110 -
4.111 -
4.112 -
4.113 -
4.114 - // If it is always OK to press Next or Finish, then:
4.115 -
4.116 - // If it depends on some condition (form filled out...), then:
4.117 - // return someCondition();
4.118 - // and when this condition changes (last form field filled in...) then:
4.119 - // fireChangeEvent();
4.120 - // and uncomment the complicated stuff below.
4.121 - }
4.122 -
4.123 public boolean isFinishPanel() {
4.124 return true;
4.125 }
4.126 -
4.127 -
4.128 -// public final void addChangeListener(ChangeListener l) {}
4.129 -// public final void removeChangeListener(ChangeListener l) {}
4.130 -//
4.131 - private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(1); // or can use ChangeSupport in NB 6.0
4.132 - public final void addChangeListener(ChangeListener l) {
4.133 - synchronized (listeners) {
4.134 - listeners.add(l);
4.135 - }
4.136 +
4.137 + public Component getComponent() {
4.138 + return mPanel.getComponent();
4.139 }
4.140 - public final void removeChangeListener(ChangeListener l) {
4.141 - synchronized (listeners) {
4.142 - listeners.remove(l);
4.143 - }
4.144 +
4.145 + public HelpCtx getHelp() {
4.146 + return mPanel.getHelp();
4.147 }
4.148 - protected final void fireChangeEvent() {
4.149 - Iterator<ChangeListener> it;
4.150 - synchronized (listeners) {
4.151 - it = new HashSet<ChangeListener>(listeners).iterator();
4.152 - }
4.153 - ChangeEvent ev = new ChangeEvent(this);
4.154 - while (it.hasNext()) {
4.155 - it.next().stateChanged(ev);
4.156 - }
4.157 +
4.158 + public void readSettings(Object settings) {
4.159 + mPanel.readSettings(settings);
4.160 + }
4.161 +
4.162 + public void storeSettings(Object settings) {
4.163 + //hack calling mPanel.storeSettings null out the title
4.164 + String title = (String) ((WizardDescriptor)settings).getProperty ("NewFileWizard_Title"); // NOI18N
4.165 + mPanel.storeSettings(settings);
4.166 + ((WizardDescriptor)settings).putProperty ("NewFileWizard_Title", title); // NOI18N
4.167 + }
4.168 +
4.169 + public boolean isValid() {
4.170 + return mPanel.isValid() && bottomPanel.isValid();
4.171 + }
4.172 +
4.173 + public void addChangeListener(ChangeListener l) {
4.174 + mPanel.addChangeListener(l);
4.175 + }
4.176 +
4.177 + public void removeChangeListener(ChangeListener l) {
4.178 + mPanel.removeChangeListener(l);
4.179 }
4.180
4.181 -
4.182 - // You can use a settings object to keep track of state. Normally the
4.183 - // settings object will be the WizardDescriptor, so you can use
4.184 - // WizardDescriptor.getProperty & putProperty to store information entered
4.185 - // by the user.
4.186 - public void readSettings(Object settings) {
4.187 - templateWizard = (TemplateWizard)settings;
4.188 -
4.189 -
4.190 - }
4.191 -
4.192 - public void storeSettings(Object settings) {
4.193 - WizardDescriptor descriptor = (WizardDescriptor) settings;
4.194 - descriptor.putProperty(WizardConstants.TASK_NAME, component.getTaskName());
4.195 - descriptor.putProperty(WizardConstants.TASK_OPERATION, component.getSelectedOperation());
4.196 - }
4.197 -
4.198 - public void setNameTF(JTextField nameTF) {
4.199 - //gui.attachFileNameListener(nameTF);
4.200 - if(nameTF != null) {
4.201 - nameTF.getDocument().removeDocumentListener(mListener);//remove existing one
4.202 - nameTF.getDocument().addDocumentListener(mListener);
4.203 - fileNameTextField = nameTF;
4.204 - }
4.205 - }
4.206 -
4.207 - public void setTaskName(String taskName) {
4.208 - component.setTaskName(taskName);
4.209 - }
4.210 -
4.211 - private boolean isValidName(Document doc) {
4.212 - try {
4.213 - String text = doc.getText(0, doc.getLength());
4.214 - boolean isValid = org.netbeans.modules.xml.xam.dom.Utils.isValidNCName(text);
4.215 - if(!isValid) {
4.216 - mErrorMessage = "Name \"" + text + "\" is not a valid NCName";
4.217 - } else {
4.218 - mErrorMessage = null;
4.219 - }
4.220 -
4.221 - } catch(Exception ex) {
4.222 - ex.printStackTrace();
4.223 - }
4.224 -
4.225 - return mErrorMessage == null;
4.226 - }
4.227 -
4.228 -
4.229 -
4.230 - private void validateFileName() {
4.231 - boolean validFileName = isValidName(this.fileNameTextField.getDocument());
4.232 - if(!validFileName) {
4.233 - fireChangeEvent();
4.234 - return;
4.235 - }
4.236 - }
4.237 -
4.238 - class TextChangeListener implements DocumentListener {
4.239 -
4.240 - public void changedUpdate(DocumentEvent e) {
4.241 - validateFileName();
4.242 - }
4.243 -
4.244 - public void insertUpdate(DocumentEvent e) {
4.245 - validateFileName();
4.246 - }
4.247 -
4.248 - public void removeUpdate(DocumentEvent e) {
4.249 - validateFileName();
4.250 - }
4.251 -
4.252 - }
4.253 }
4.254 -