Source Code Cross Referenced for TargetNamePanel.java in  » IDE-Netbeans » cnd » org » netbeans » modules » cnd » makewizard » 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 » cnd » org.netbeans.modules.cnd.makewizard 
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:
042:        package org.netbeans.modules.cnd.makewizard;
043:
044:        import java.io.File;
045:        import java.util.ArrayList;
046:        import org.netbeans.modules.cnd.api.utils.IpeUtils;
047:
048:        /**
049:         *  Create a panel used for gathering the binary name and output directory for
050:         *  the simple application cases (all Makefile types other than complex).
051:         */
052:
053:        public class TargetNamePanel extends ItemChooser {
054:
055:            /** Current name for the target label */
056:            private String label;
057:
058:            /** Current mnemonic for the target label */
059:            private char mnemonic;
060:
061:            /** Default target name for the current type */
062:            private String tname;
063:
064:            /** Serial version number */
065:            static final long serialVersionUID = 6653452210904639697L;
066:
067:            private boolean initialized = false;
068:
069:            /**
070:             *  Constructor for the Makefile binary panel.
071:             */
072:            TargetNamePanel(MakefileWizard wd) {
073:                super (wd, true);
074:                String subtitle = getString("TITLE_TargetName"); // NOI18N
075:                setSubTitle(subtitle);
076:                this .getAccessibleContext().setAccessibleDescription(subtitle);
077:            }
078:
079:            /** Validate the binary name and output directory */
080:            public void validateData(ArrayList msgs, int key) {
081:                TargetData target = (TargetData) getMakefileData().getTarget(
082:                        key);
083:                String cwd = getMakefileData().getBaseDirectory(
084:                        MakefileData.EXPAND);
085:                File bindir = null;
086:                File outdir = null;
087:                File outpar = null;
088:                String bname = IpeUtils.expandPath(target.getName());
089:                String odir = IpeUtils.expandPath(target.getOutputDirectory());
090:
091:                if (bname.length() > 0) {
092:                    File btmp;
093:
094:                    if (bname.startsWith(File.separator)) {
095:                        btmp = new File(bname);
096:                    } else {
097:                        btmp = new File(cwd, bname);
098:                    }
099:                    bindir = btmp.getParentFile();
100:                }
101:                if (odir.length() > 0 && !odir.equals(cwd)
102:                        && !odir.equals(bname)) {
103:                    if (odir.startsWith(File.separator)) {
104:                        outdir = new File(odir);
105:                    } else {
106:                        outdir = new File(cwd, odir);
107:                    }
108:                    outpar = outdir.getParentFile();
109:                }
110:
111:                if (bindir != null && !bindir.getPath().equals(cwd)
112:                        && bindir.exists() && !bindir.canWrite()) {
113:                    warn(msgs, WARN_BINDIR_NOT_WRITABLE, bindir.getPath(),
114:                            bname);
115:                }
116:                if (outdir != null && !outdir.equals(bindir)) {
117:                    if (!outdir.exists()) {
118:                        if (outpar == null || !outpar.canWrite()) {
119:                            warn(msgs, WARN_CANNOT_CREATE_OUTPUT_DIR, outdir
120:                                    .getPath());
121:                        }
122:                    } else if (!outdir.canWrite()) {
123:                        warn(msgs, WARN_CANNOT_WRITE_TO_OUTPUT_DIR, outdir
124:                                .getPath());
125:                    }
126:                }
127:            }
128:
129:            /**
130:             *  Convert a target from one type to another. If we cannot convert the
131:             *  target we move all existing targets 1 up in the array and create a new
132:             *  target in the 0th position.
133:             *
134:             *  @param type	The desired target type
135:             *  @param tlist	The ArrayList of existing targets
136:             *  @return		The ``type'' target
137:             */
138:            private TargetData convertOrCreate(int type, ArrayList tlist) {
139:                TargetData target = (TargetData) tlist.get(0);
140:
141:                if (target.getTargetType() != type) {
142:                    for (int i = 0; i < tlist.size(); i++) {
143:                        target = (TargetData) tlist.get(i);
144:                        if (target.isConvertable(type)) {
145:                            // Convert target and move to 0th position
146:                            target.convert(type);
147:                            if (i > 0) {
148:                                while (i > 0) {
149:                                    tlist.set(i, tlist.get(i - 1));
150:                                    i--;
151:                                }
152:                                tlist.set(0, target);
153:                            }
154:                            setup(getMakefileData(), type, true);
155:                            return target;
156:                        }
157:                    }
158:
159:                    /*
160:                     * We didn't find a target we could convert to the desired type. 
161:                     * Move all targets up an index and create a new target at index 0.
162:                     */
163:                    tlist.add(1, tlist.get(0));
164:                    tlist.add(0, (target = createTarget(type)));
165:                }
166:
167:                return target;
168:            }
169:
170:            private void setup(MakefileData makefileData, int type,
171:                    boolean reinit) {
172:
173:                if (type == MakefileData.EXECUTABLE_MAKEFILE_TYPE) {
174:                    label = getString("LBL_ExecutableName"); // NOI18N
175:                    mnemonic = getString("MNEM_ExecutableName").charAt(0); // NOI18N
176:                    tname = getString("DFLT_ExecutableName"); // NOI18N
177:
178:                } else if (type == MakefileData.ARCHIVE_MAKEFILE_TYPE) {
179:                    label = getString("LBL_ArchiveName"); // NOI18N
180:                    mnemonic = getString("MNEM_ArchiveName").charAt(0); // NOI18N
181:                    tname = getString("DFLT_ArchiveName"); // NOI18N
182:
183:                } else if (type == MakefileData.SHAREDLIB_MAKEFILE_TYPE) {
184:                    String suffix;
185:                    if (makefileData.getMakefileOS() == MakefileData.WINDOWS_OS_TYPE)
186:                        suffix = ".dll"; // NOI18N
187:                    else if (makefileData.getMakefileOS() == MakefileData.MACOSX_OS_TYPE)
188:                        suffix = ".dylib"; // NOI18N
189:                    else
190:                        suffix = ".so"; // NOI18N
191:                    label = getString("LBL_ShobjName"); // NOI18N
192:                    mnemonic = getString("MNEM_ShobjName").charAt(0); // NOI18N
193:                    tname = getString("DFLT_ShobjName") + suffix; // NOI18N
194:
195:                } else {
196:                    throw (new IllegalStateException());
197:                }
198:
199:                if (reinit) {
200:                    getNameLabel().setText(label);
201:                    getNameLabel().setDisplayedMnemonic(mnemonic);
202:                }
203:            }
204:
205:            private TargetData createTarget(int type) {
206:                setup(getMakefileData(), type, true);
207:                String dir = getMakefileData().defaultOutputDirectory();
208:                return new TargetData(type, tname, dir, 0);
209:            }
210:
211:            /**
212:             *  Create or convert the target to the correct type. If it is the correct
213:             *  type then reuse it unchanged. Set initial values for the panel too.
214:             */
215:            public void addNotify() {
216:                int type = getMakefileData().getMakefileType();
217:                TargetData target;
218:
219:                if (!initialized) {
220:                    setup(getMakefileData(), type, false);
221:                    create(getString("LBL_TargetDirectory"), // NOI18N
222:                            getString("MNEM_TargetDirectory").charAt(0), // NOI18N
223:                            label, mnemonic);
224:                    target = createTarget(type);
225:                    target.setTargetName(tname);
226:                    getMakefileData().getTargetList().add(target);
227:
228:                    initialized = true;
229:                } else {
230:                    ArrayList tlist = getMakefileData().getTargetList();
231:
232:                    target = (TargetData) tlist.get(0);
233:                    if ((target.getTargetType() != type)) {
234:                        target = convertOrCreate(type, tlist);
235:                    }
236:                }
237:
238:                // init makefile directory and makefile name here. It used to be done in BaseDirectoryPanel, but
239:                // this panel is no longer part of the simple wizard
240:                MakefileWizard.getMakefileWizard().initDirPaths();
241:                MakefileWizard.getMakefileWizard().initMakefileName();
242:
243:                String dir = target.getOutputDirectory();
244:                int pos;
245:
246:                getText().setText(target.getTargetName());
247:                if ((pos = dir.lastIndexOf('/')) == -1) {
248:                    getDirText().setText(
249:                            getMakefileData().getBaseDirectory()
250:                                    + File.separator
251:                                    + target.getOutputDirectory());
252:                } else {
253:                    getDirText().setText(dir);
254:                }
255:
256:                super .addNotify();
257:            }
258:
259:            /** Get the data from the panel and update the target */
260:            public void removeNotify() {
261:                super .removeNotify();
262:
263:                MakefileData md = getMakefileData();
264:                TargetData target = (TargetData) md.getTargetList().get(0);
265:                String name = getText().getText();
266:                String dir = getDirText().getText();
267:                String base = md.getBaseDirectory();
268:
269:                try {
270:                    if (dir.startsWith(base)
271:                            && (dir.length() == base.length() || dir
272:                                    .charAt(base.length()) == '/')) {
273:                        if (!dir.substring(base.length() + 1).equals(
274:                                target.getOutputDirectory())) {
275:                            target.setOutputDirectory(dir.substring(base
276:                                    .length() + 1));
277:                        }
278:                    } else {
279:                        target.setOutputDirectory(dir);
280:                    }
281:                } catch (IndexOutOfBoundsException ex) {
282:                    target.setOutputDirectory(dir);
283:                }
284:
285:                if (!name.equals(target.getTargetName())) {
286:                    target.setTargetName(name);
287:                    target.setName(name);
288:                }
289:            }
290:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.