Source Code Cross Referenced for Panel.java in  » IDE-Netbeans » xml » org » netbeans » modules » xslt » project » wizard » element » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » xml » org.netbeans.modules.xslt.project.wizard.element 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.modules.xslt.project.wizard.element;
042:
043:        import java.awt.Component;
044:        import java.awt.GridBagConstraints;
045:        import java.awt.GridBagLayout;
046:        import java.awt.Insets;
047:        import java.awt.event.ActionEvent;
048:        import java.io.File;
049:        import java.util.Collection;
050:
051:        import javax.swing.DefaultListCellRenderer;
052:        import javax.swing.JButton;
053:        import javax.swing.JFileChooser;
054:        import javax.swing.JList;
055:        import javax.swing.JPanel;
056:        import javax.swing.JTextField;
057:        import javax.swing.event.ChangeListener;
058:        import javax.swing.filechooser.FileFilter;
059:        import javax.xml.namespace.QName;
060:
061:        import org.openide.WizardDescriptor;
062:        import org.openide.WizardValidationException;
063:        import org.openide.filesystems.FileUtil;
064:        import org.openide.filesystems.FileObject;
065:        import org.openide.util.ChangeSupport;
066:        import org.openide.util.HelpCtx;
067:
068:        import org.netbeans.api.project.Project;
069:        import org.netbeans.modules.xml.xam.dom.NamedComponentReference;
070:        import org.netbeans.modules.xml.wsdl.model.Message;
071:        import org.netbeans.modules.xml.wsdl.model.Operation;
072:        import org.netbeans.modules.xml.wsdl.model.OperationParameter;
073:        import org.netbeans.modules.xml.wsdl.model.Part;
074:        import org.netbeans.modules.xml.wsdl.model.PortType;
075:        import org.netbeans.modules.xml.wsdl.model.extensions.bpel.PartnerLinkType;
076:        import org.netbeans.modules.xml.wsdl.model.extensions.bpel.Role;
077:        import org.netbeans.modules.xml.xam.NamedReferenceable;
078:        import org.netbeans.modules.xslt.project.XsltproConstants;
079:        import org.netbeans.modules.xml.catalogsupport.util.ProjectUtilities;
080:        import org.netbeans.modules.xml.catalogsupport.util.ProjectWSDL;
081:        import static org.netbeans.modules.soa.ui.util.UI.*;
082:
083:        /**
084:         * @author Vladimir Yaroslavskiy
085:         * @author Vitaly Bychkov
086:         * @version 2007.08.31
087:         */
088:        abstract class Panel<T> implements  WizardDescriptor.ValidatingPanel<T> {
089:
090:            Panel(Project project, Panel<T> parent) {
091:                myProject = project;
092:                myFolder = ProjectUtilities.getSrcFolder(project);
093:                myParent = parent;
094:                myChangeSupport = new ChangeSupport(this );
095:            }
096:
097:            protected final Project getProject() {
098:                return myProject;
099:            }
100:
101:            protected final FileObject getFolder() {
102:                return myFolder;
103:            }
104:
105:            protected final Panel<T> getParent() {
106:                return myParent;
107:            }
108:
109:            protected abstract void createPanel(JPanel panel,
110:                    GridBagConstraints c);
111:
112:            protected void setEnabled(boolean enabled) {
113:            }
114:
115:            protected void update() {
116:            }
117:
118:            protected String getComponentName() {
119:                return null;
120:            }
121:
122:            protected Panel<T> getNext() {
123:                return null;
124:            }
125:
126:            protected Object getResult() {
127:                return null;
128:            }
129:
130:            protected final Panel<T> getPrevious() {
131:                return myParent;
132:            }
133:
134:            protected String getError() {
135:                return null;
136:            }
137:
138:            protected final String getError(String error1, String error2) {
139:                if (error1 != null) {
140:                    return error1;
141:                }
142:                return error2;
143:            }
144:
145:            public JPanel getComponent() {
146:                if (myComponent == null) {
147:                    myComponent = createMainPanel();
148:                    String name = getComponentName();
149:                    myComponent.setName(name);
150:
151:                    String[] steps = new String[] { NAME_TYPE, NAME_WSDL,
152:                            NAME_XSLT };
153:                    myComponent.putClientProperty("WizardPanel_contentData",
154:                            steps); // NOI18N
155:
156:                    for (int i = 0; i < steps.length; i++) {
157:                        if (name.equals(steps[i])) {
158:                            myComponent.putClientProperty(
159:                                    "WizardPanel_contentSelectedIndex",
160:                                    new Integer(i - 1)); // NOI18N
161:                        }
162:                    }
163:                }
164:                return myComponent;
165:            }
166:
167:            private JPanel createMainPanel() {
168:                JPanel panel = new JPanel(new GridBagLayout());
169:                GridBagConstraints c = new GridBagConstraints();
170:
171:                c.weightx = 1.0;
172:                c.weighty = 1.0;
173:                c.insets = new Insets(0, 0, 0, 0);
174:                c.anchor = GridBagConstraints.NORTHWEST;
175:                c.fill = GridBagConstraints.HORIZONTAL;
176:                createPanel(panel, c);
177:
178:                //  panel.setBorder(new javax.swing.border.LineBorder(java.awt.Color.red));
179:                return panel;
180:            }
181:
182:            public void validate() throws WizardValidationException {
183:                String error = getError();
184:
185:                if (error != null) {
186:                    throw new WizardValidationException(myComponent, error,
187:                            error);
188:                }
189:            }
190:
191:            protected final String i18n(String key) {
192:                return org.netbeans.modules.soa.ui.util.UI.i18n(Panel.class,
193:                        key);
194:            }
195:
196:            protected final String i18n(String key, String param) {
197:                return org.netbeans.modules.soa.ui.util.UI.i18n(Panel.class,
198:                        key, param);
199:            }
200:
201:            protected final String i18n(String key, String param1, String param2) {
202:                return org.netbeans.modules.soa.ui.util.UI.i18n(Panel.class,
203:                        key, param1, param2);
204:            }
205:
206:            public boolean isValid() {
207:                return true;
208:            }
209:
210:            public HelpCtx getHelp() {
211:                return new HelpCtx("xslt_project_addxsl"); // NOI18N
212:            }
213:
214:            public void storeSettings(Object object) {
215:            }
216:
217:            public void addChangeListener(ChangeListener listener) {
218:                myChangeSupport.addChangeListener(listener);
219:            }
220:
221:            public void removeChangeListener(ChangeListener listener) {
222:                myChangeSupport.removeChangeListener(listener);
223:            }
224:
225:            public void readSettings(Object object) {
226:            }
227:
228:            protected final int getXslFileNumber(int start) {
229:                int count = start;
230:
231:                while (true) {
232:                    if (getFolder().getFileObject(NAME + count, EXT) == null) {
233:                        return count;
234:                    }
235:                    count++;
236:                }
237:            }
238:
239:            protected final String getXslFileName(int number) {
240:                return NAME + number;
241:            }
242:
243:            protected final String getType(OperationParameter parameter) {
244:                if (parameter == null) {
245:                    //out("1");
246:                    return EMPTY;
247:                }
248:                NamedComponentReference<Message> reference = parameter
249:                        .getMessage();
250:
251:                if (reference == null) {
252:                    //out("2");
253:                    return EMPTY;
254:                }
255:                Message message = reference.get();
256:
257:                if (message == null) {
258:                    //out("3");
259:                    return EMPTY;
260:                }
261:                Collection<Part> parts = message.getParts();
262:
263:                if (parts == null) {
264:                    //out("4");
265:                    return EMPTY;
266:                }
267:                java.util.Iterator<Part> iterator = parts.iterator();
268:
269:                if (!iterator.hasNext()) {
270:                    //out("5");
271:                    return EMPTY;
272:                }
273:                return getType(iterator.next());
274:            }
275:
276:            private String getType(Part part) {
277:                NamedComponentReference<? extends NamedReferenceable> refTypeEl = part
278:                        .getType();
279:                refTypeEl = refTypeEl == null ? part.getElement() : refTypeEl;
280:
281:                if (refTypeEl != null) {
282:
283:                    QName qName = refTypeEl.getQName();
284:                    if (qName != null) {
285:                        return qName.getLocalPart();
286:                    }
287:                }
288:                return EMPTY;
289:            }
290:
291:            protected final String addExtension(String file) {
292:                file = File.separator.equals("\\") ? file.replace(
293:                        File.separatorChar, '/') : file;
294:
295:                if (file.endsWith(Panel.DOT + Panel.EXT)) {
296:                    return file;
297:                }
298:                return file + Panel.DOT + Panel.EXT;
299:            }
300:
301:            // -------------------------------------------------------
302:            protected class Renderer extends DefaultListCellRenderer {
303:
304:                public Component getListCellRendererComponent(JList list,
305:                        Object value, int index, boolean isSelected,
306:                        boolean hasFocus) {
307:                    super .getListCellRendererComponent(list, value, index,
308:                            isSelected, hasFocus);
309:
310:                    if (value instanceof  ProjectWSDL) {
311:                        setText(((ProjectWSDL) value).getName());
312:                    }
313:                    if (value instanceof  Operation) {
314:                        setText(((Operation) value).getName());
315:                    }
316:                    if (value instanceof  PartnerRolePort) {
317:                        setText(((PartnerRolePort) value).getName());
318:                    }
319:                    return this ;
320:                }
321:            }
322:
323:            // ----------------------------------
324:            public static class PartnerRolePort {
325:                public PartnerRolePort(PartnerLinkType partnerLinkType,
326:                        Role role, PortType portType) {
327:                    myPartnerLinkType = partnerLinkType;
328:                    myRole = role;
329:                    myPortType = portType;
330:                }
331:
332:                public PartnerLinkType getPartnerLinkType() {
333:                    return myPartnerLinkType;
334:                }
335:
336:                public Role getRole() {
337:                    return myRole;
338:                }
339:
340:                public PortType getPortType() {
341:                    return myPortType;
342:                }
343:
344:                public String getName() {
345:                    return myPortType.getName() + " (" + // NOI18N
346:                            myPartnerLinkType.getName() + "/" + // NOI18N
347:                            myRole.getName() + ")"; // NOI18N
348:                }
349:
350:                /**{@inheritDoc}*/
351:                @Override
352:                public boolean equals(Object object) {
353:                    if (!(object instanceof  PartnerRolePort)) {
354:                        return false;
355:                    }
356:                    PartnerRolePort partnerRolePort = (PartnerRolePort) object;
357:
358:                    return partnerRolePort.getPartnerLinkType().equals(
359:                            getPartnerLinkType())
360:                            && partnerRolePort.getRole().equals(getRole())
361:                            && partnerRolePort.getPortType().equals(
362:                                    getPortType());
363:                }
364:
365:                /**{@inheritDoc}*/
366:                @Override
367:                public int hashCode() {
368:                    return getPartnerLinkType().hashCode()
369:                            * getRole().hashCode() * getPortType().hashCode();
370:                }
371:
372:                private Role myRole;
373:                private PortType myPortType;
374:                private PartnerLinkType myPartnerLinkType;
375:            }
376:
377:            //-----------------------------------
378:            protected final JButton createBrowseButton(JTextField fileTextField) {
379:                return createBrowseButton(fileTextField, BROWSE_LABEL);
380:            }
381:
382:            protected final JButton createBrowseButton(
383:                    final JTextField fileTextField, String labelKey) {
384:                final JPanel panel = myComponent;
385:
386:                JButton browseButton = createButton(new ButtonAction(
387:                        i18n(labelKey), // NOI18N
388:                        i18n("TLT_Browse")) { // NOI18N
389:                    public void actionPerformed(ActionEvent event) {
390:
391:                        FileFilter xsltFileFilter = new FileFilter() {
392:
393:                            public boolean accept(File f) {
394:                                if (f.isDirectory()) {
395:                                    return true;
396:                                }
397:                                String extension = FileUtil.getExtension(f
398:                                        .getName());
399:                                if (XsltproConstants.XSLT_EXTENSION
400:                                        .equals(extension)
401:                                        || XsltproConstants.XSLT_EXTENSION2
402:                                                .equals(extension)) {
403:                                    return true;
404:                                }
405:                                return false;
406:                            }
407:
408:                            public String getDescription() {
409:                                return i18n("LBL_Transformation_Filter_Descr"); // NOI18N
410:                            }
411:                        };
412:
413:                        JFileChooser fileChooser = new JFileChooser(FileUtil
414:                                .toFile(getFolder()), new FileDialog(
415:                                getProject()));
416:                        fileChooser.setFileFilter(xsltFileFilter);
417:
418:                        int result = fileChooser.showOpenDialog(panel);
419:                        File selectedFile = fileChooser.getSelectedFile();
420:
421:                        if (result == JFileChooser.APPROVE_OPTION
422:                                && selectedFile != null) {
423:                            String relPath = "";
424:                            selectedFile = FileUtil.normalizeFile(selectedFile);
425:
426:                            if (!selectedFile.exists()) {
427:                                relPath = FileUtil.getRelativePath(getFolder(),
428:                                        FileUtil.toFileObject(selectedFile
429:                                                .getParentFile()));
430:                                relPath = (relPath == null
431:                                        || "".equals(relPath) ? "" : relPath
432:                                        + "/")
433:                                        + selectedFile.getName();
434:                            } else {
435:                                relPath = FileUtil.getRelativePath(getFolder(),
436:                                        FileUtil.toFileObject(selectedFile));
437:                            }
438:                            fileTextField.setText(relPath);
439:                        }
440:                    }
441:                });
442:                return browseButton;
443:            }
444:
445:            private ChangeSupport myChangeSupport;
446:            private Project myProject;
447:            private JPanel myComponent;
448:            private FileObject myFolder;
449:            private Panel<T> myParent;
450:
451:            private static final String DOT = "."; // NOI18N
452:            private static final String EXT = "xsl"; // NOI18N
453:            private static final String NAME = "newXSLFile"; // NOI18N
454:            private static final String BROWSE_LABEL = "LBL_Browse"; // NOI18N
455:            private static final String BROWSE_LABEL2 = "LBL_Browse2"; // NOI18N
456:
457:            protected static final String EMPTY = ""; // NOI18N
458:
459:            protected static final String NAME_TYPE = org.netbeans.modules.soa.ui.util.UI
460:                    .i18n(Panel.class, "LBL_Service_Type"); // NOI18N
461:
462:            protected static final String NAME_WSDL = org.netbeans.modules.soa.ui.util.UI
463:                    .i18n(Panel.class, "LBL_WSDL_File"); // NOI18N
464:
465:            protected static final String NAME_XSLT = org.netbeans.modules.soa.ui.util.UI
466:                    .i18n(Panel.class, "LBL_XSLT_Configuration"); // NOI18N
467:
468:            public static final String INPUT_FILE = "input.file"; // NOI18N
469:            public static final String INPUT_OPERATION = "input.operation"; // NOI18N
470:            public static final String INPUT_PARTNER_ROLE_PORT = "input.partner.role.port"; // NOI18N
471:
472:            public static final String OUTPUT_FILE = "output.file"; // NOI18N
473:            public static final String OUTPUT_OPERATION = "output.operation"; // NOI18N
474:            public static final String OUTPUT_PARTNER_ROLE_PORT = "output.partner.role.port"; // NOI18N
475:
476:            public static final String CHOICE = "choice"; // NOI18N
477:            public static final String CHOICE_REQUEST_REPLY = "choice.request.reply"; // NOI18N
478:            public static final String CHOICE_FILTER_ONE_WAY = "choice.filter.one.way"; // NOI18N
479:            public static final String CHOICE_FILTER_REQUEST_REPLY = "choice.filter.request.reply"; // NOI18N
480:        }
w__w__w_.__ja_v___a2___s_._c___om__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.