Source Code Cross Referenced for ItemConfiguration.java in  » IDE-Netbeans » cnd » org » netbeans » modules » cnd » makeproject » api » configurations » 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.makeproject.api.configurations 
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.makeproject.api.configurations;
043:
044:        import java.beans.PropertyEditor;
045:        import java.beans.PropertyEditorSupport;
046:        import java.io.File;
047:        import java.text.DateFormat;
048:        import java.util.Date;
049:        import java.util.ResourceBundle;
050:        import org.netbeans.modules.cnd.makeproject.configurations.ItemXMLCodec;
051:        import org.netbeans.modules.cnd.makeproject.configurations.ui.BooleanNodeProp;
052:        import org.netbeans.modules.cnd.api.utils.IpeUtils;
053:        import org.netbeans.modules.cnd.api.xml.XMLDecoder;
054:        import org.netbeans.modules.cnd.api.xml.XMLEncoder;
055:        import org.netbeans.modules.cnd.api.compilers.CompilerSetManager;
056:        import org.netbeans.modules.cnd.api.compilers.CompilerSet;
057:        import org.netbeans.modules.cnd.api.compilers.Tool;
058:        import org.openide.nodes.Node;
059:        import org.openide.nodes.PropertySupport;
060:        import org.openide.nodes.Sheet;
061:        import org.openide.util.NbBundle;
062:
063:        public class ItemConfiguration implements  ConfigurationAuxObject {
064:            private boolean needSave = false;
065:
066:            private Configuration configuration;
067:            private Item item;
068:
069:            // General
070:            private BooleanConfiguration excluded;
071:            private int tool = -1;
072:
073:            // Tools
074:            private CustomToolConfiguration customToolConfiguration;
075:            private CCompilerConfiguration cCompilerConfiguration;
076:            private CCCompilerConfiguration ccCompilerConfiguration;
077:            private FortranCompilerConfiguration fortranCompilerConfiguration;
078:
079:            // cached id of item
080:            //    private String id;
081:
082:            public ItemConfiguration(Configuration configuration, Item item) {
083:                // General
084:                this .configuration = configuration;
085:                setItem(item);
086:                excluded = new BooleanConfiguration(null, false);
087:                // Compilers
088:                //customToolConfiguration = new CustomToolConfiguration();
089:                //cCompilerConfiguration = new CCompilerConfiguration(((MakeConfiguration)configuration).getBaseDir(), item.getFolder().getFolderConfiguration(configuration).getCCompilerConfiguration());
090:                //ccCompilerConfiguration = new CCCompilerConfiguration(((MakeConfiguration)configuration).getBaseDir(), item.getFolder().getFolderConfiguration(configuration).getCCCompilerConfiguration());
091:                //fortranCompilerConfiguration = new FortranCompilerConfiguration(((MakeConfiguration)configuration).getBaseDir(), ((MakeConfiguration)configuration).getFortranCompilerConfiguration());
092:
093:                // This is side effect of lazy configuration. We should init folder configuration
094:                // TODO: remove folder initialization. Folder should be responsible for it
095:                item.getFolder().getFolderConfiguration(configuration);
096:
097:                clearChanged();
098:            }
099:
100:            public boolean isCompilerToolConfiguration() {
101:                return getTool() == Tool.CCompiler
102:                        || getTool() == Tool.CCCompiler
103:                        || getTool() == Tool.FortranCompiler;
104:            }
105:
106:            public BasicCompilerConfiguration getCompilerConfiguration() {
107:                if (getTool() == Tool.CCompiler) {
108:                    return getCCompilerConfiguration();
109:                } else if (getTool() == Tool.CCCompiler) {
110:                    return getCCCompilerConfiguration();
111:                } else if (getTool() == Tool.FortranCompiler) {
112:                    return getFortranCompilerConfiguration();
113:                } else {
114:                    assert false;
115:                }
116:                return null;
117:            }
118:
119:            public Configuration getConfiguration() {
120:                return configuration;
121:            }
122:
123:            public void setConfiguration(Configuration configuration) {
124:                this .configuration = configuration;
125:            }
126:
127:            public Item getItem() {
128:                return item;
129:            }
130:
131:            private void setItem(Item item) {
132:                if (this .item != item) {
133:                    this .item = item;
134:                    this .needSave = true;
135:                    //            this.id = null;
136:                    //this.tool = item.getDefaultTool();
137:                }
138:            }
139:
140:            // General
141:            public BooleanConfiguration getExcluded() {
142:                return excluded;
143:            }
144:
145:            public void setExcluded(BooleanConfiguration excluded) {
146:                this .excluded = excluded;
147:                needSave = true;
148:            }
149:
150:            // Tool
151:            public void setTool(String name) {
152:                //        if (genericName != null) {
153:                //            CompilerSet set = CompilerSetManager.getDefault().getCompilerSet(((MakeConfiguration)configuration).getCompilerSet().getValue());
154:                //            tool = set.getToolKind(genericName);
155:                //        }
156:                setTool(Tool.getTool(name));
157:            }
158:
159:            public void setTool(int tool) {
160:                this .tool = tool;
161:            }
162:
163:            public int getTool() {
164:                if (tool == -1) {
165:                    tool = item.getDefaultTool();
166:                }
167:                return tool;
168:            }
169:
170:            //    protected String getToolName() {
171:            //        CompilerSet set = CompilerSetManager.getDefault().getCompilerSet(((MakeConfiguration)configuration).getCompilerSet().getValue());
172:            //        return set.getTool(getTool()).getName();
173:            //    }
174:            protected String[] getToolNames() {
175:                //        CompilerSet set = CompilerSetManager.getDefault().getCompilerSet(((MakeConfiguration)configuration).getCompilerSet().getValue());
176:                //        return set.getToolGenericNames();
177:                return Tool.getCompilerToolNames();
178:            }
179:
180:            // Custom Tool
181:            public void setCustomToolConfiguration(
182:                    CustomToolConfiguration customToolConfiguration) {
183:                this .customToolConfiguration = customToolConfiguration;
184:            }
185:
186:            public synchronized CustomToolConfiguration getCustomToolConfiguration() {
187:                if (customToolConfiguration == null) {
188:                    customToolConfiguration = new CustomToolConfiguration();
189:                }
190:                return customToolConfiguration;
191:            }
192:
193:            // C Compiler
194:            public void setCCompilerConfiguration(
195:                    CCompilerConfiguration cCompilerConfiguration) {
196:                this .cCompilerConfiguration = cCompilerConfiguration;
197:            }
198:
199:            public synchronized CCompilerConfiguration getCCompilerConfiguration() {
200:                if (cCompilerConfiguration == null) {
201:                    cCompilerConfiguration = new CCompilerConfiguration(
202:                            ((MakeConfiguration) configuration).getBaseDir(),
203:                            item.getFolder().getFolderConfiguration(
204:                                    configuration).getCCompilerConfiguration());
205:                }
206:                return cCompilerConfiguration;
207:            }
208:
209:            // CC Compiler
210:            public void setCCCompilerConfiguration(
211:                    CCCompilerConfiguration ccCompilerConfiguration) {
212:                this .ccCompilerConfiguration = ccCompilerConfiguration;
213:            }
214:
215:            public synchronized CCCompilerConfiguration getCCCompilerConfiguration() {
216:                if (ccCompilerConfiguration == null) {
217:                    ccCompilerConfiguration = new CCCompilerConfiguration(
218:                            ((MakeConfiguration) configuration).getBaseDir(),
219:                            item.getFolder().getFolderConfiguration(
220:                                    configuration).getCCCompilerConfiguration());
221:                }
222:                return ccCompilerConfiguration;
223:            }
224:
225:            // Fortran Compiler
226:            public void setFortranCompilerConfiguration(
227:                    FortranCompilerConfiguration fortranCompilerConfiguration) {
228:                this .fortranCompilerConfiguration = fortranCompilerConfiguration;
229:            }
230:
231:            public synchronized FortranCompilerConfiguration getFortranCompilerConfiguration() {
232:                if (fortranCompilerConfiguration == null) {
233:                    fortranCompilerConfiguration = new FortranCompilerConfiguration(
234:                            ((MakeConfiguration) configuration).getBaseDir(),
235:                            ((MakeConfiguration) configuration)
236:                                    .getFortranCompilerConfiguration());
237:                }
238:                return fortranCompilerConfiguration;
239:            }
240:
241:            // interface ConfigurationAuxObject
242:            public boolean shared() {
243:                return true;
244:            }
245:
246:            // interface ConfigurationAuxObject
247:            public boolean hasChanged() {
248:                return needSave;
249:            }
250:
251:            // interface ProfileAuxObject
252:            public void clearChanged() {
253:                needSave = false;
254:            }
255:
256:            /**
257:             * Returns an unique id (String) used to retrive this object from the
258:             * pool of aux objects
259:             */
260:            //    public String getId() {
261:            //        if (this.id == null) {
262:            //            this.id = getId(getItem().getPath());
263:            //        }
264:            //        assert this.id != null;
265:            //        return this.id;
266:            //    }
267:            //    
268:            //    static public String getId(String path) {
269:            //        return "item-" + path; // NOI18N
270:            //    }
271:            public String getId() {
272:                return item.getId();
273:            }
274:
275:            public void assign(ConfigurationAuxObject profileAuxObject) {
276:                if (!(profileAuxObject instanceof  ItemConfiguration)) {
277:                    // FIXUP: exception ????
278:                    System.err
279:                            .println("Item - assign: Profile object type expected - got "
280:                                    + profileAuxObject); // NOI18N
281:                    return;
282:                }
283:                ItemConfiguration i = (ItemConfiguration) profileAuxObject;
284:                if (!getId().equals(i.getItem().getId())) {
285:                    System.err.println("Item - assign: Item ID " + getId()
286:                            + " expected - got " + i.getItem().getId()); // NOI18N
287:                    return;
288:                }
289:                setConfiguration(i.getConfiguration());
290:                setItem(i.getItem());
291:                getExcluded().assign(i.getExcluded());
292:                setTool(i.getTool());
293:
294:                getCustomToolConfiguration().assign(
295:                        i.getCustomToolConfiguration());
296:                getCCompilerConfiguration().assign(
297:                        i.getCCompilerConfiguration());
298:                getCCCompilerConfiguration().assign(
299:                        i.getCCCompilerConfiguration());
300:                getFortranCompilerConfiguration().assign(
301:                        i.getFortranCompilerConfiguration());
302:            }
303:
304:            public void assignValues(ConfigurationAuxObject profileAuxObject) {
305:                if (!(profileAuxObject instanceof  ItemConfiguration)) {
306:                    // FIXUP: exception ????
307:                    System.err
308:                            .println("Item - assign: Profile object type expected - got "
309:                                    + profileAuxObject); // NOI18N
310:                    return;
311:                }
312:                ItemConfiguration i = (ItemConfiguration) profileAuxObject;
313:                getExcluded().assign(i.getExcluded());
314:                setTool(i.getTool());
315:
316:                getCustomToolConfiguration().assign(
317:                        i.getCustomToolConfiguration());
318:                getCCompilerConfiguration().assign(
319:                        i.getCCompilerConfiguration());
320:                getCCCompilerConfiguration().assign(
321:                        i.getCCCompilerConfiguration());
322:                getFortranCompilerConfiguration().assign(
323:                        i.getFortranCompilerConfiguration());
324:            }
325:
326:            public ItemConfiguration copy(MakeConfiguration makeConfiguration) {
327:                ItemConfiguration copy = new ItemConfiguration(
328:                        makeConfiguration, getItem());
329:                // safe using
330:                copy.assign(this );
331:                return copy;
332:            }
333:
334:            @Override
335:            public Object clone() {
336:                ItemConfiguration i = new ItemConfiguration(getConfiguration(),
337:                        getItem());
338:
339:                i.setExcluded((BooleanConfiguration) getExcluded().clone());
340:                i.setTool(getTool());
341:
342:                i
343:                        .setCustomToolConfiguration((CustomToolConfiguration) getCustomToolConfiguration()
344:                                .clone());
345:                i
346:                        .setCCompilerConfiguration((CCompilerConfiguration) getCCompilerConfiguration()
347:                                .clone());
348:                i
349:                        .setCCCompilerConfiguration((CCCompilerConfiguration) getCCCompilerConfiguration()
350:                                .clone());
351:                i
352:                        .setFortranCompilerConfiguration((FortranCompilerConfiguration) getFortranCompilerConfiguration()
353:                                .clone());
354:                return i;
355:            }
356:
357:            //
358:            // XML codec support
359:            public XMLDecoder getXMLDecoder() {
360:                return new ItemXMLCodec(this );
361:            }
362:
363:            public XMLEncoder getXMLEncoder() {
364:                return new ItemXMLCodec(this );
365:            }
366:
367:            public void initialize() {
368:                // FIXUP: this doesn't make sense...
369:            }
370:
371:            public Sheet getGeneralSheet() {
372:                Sheet sheet = new Sheet();
373:
374:                Sheet.Set set = new Sheet.Set();
375:                set.setName("Item"); // NOI18N
376:                set.setDisplayName(getString("ItemTxt"));
377:                set.setShortDescription(getString("ItemHint"));
378:                set.put(new StringRONodeProp(getString("NameTxt"), IpeUtils
379:                        .getBaseName(item.getPath())));
380:                set.put(new StringRONodeProp(getString("FilePathTxt"), item
381:                        .getPath()));
382:                String fullPath = IpeUtils.toAbsolutePath(
383:                        ((MakeConfiguration) configuration).getBaseDir(), item
384:                                .getPath());
385:                String mdate = ""; // NOI18N
386:                File itemFile = new File(fullPath);
387:                if (itemFile.exists()) {
388:                    mdate = DateFormat.getDateInstance().format(
389:                            new Date(itemFile.lastModified()));
390:                    mdate += " "
391:                            + DateFormat.getTimeInstance().format(
392:                                    new Date(itemFile.lastModified())); // NOI18N
393:                }
394:                set.put(new StringRONodeProp(getString("FullFilePathTxt"),
395:                        fullPath));
396:                set.put(new StringRONodeProp(getString("LastModifiedTxt"),
397:                        mdate));
398:                sheet.put(set);
399:
400:                set = new Sheet.Set();
401:                set.setName("ItemConfiguration"); // NOI18N
402:                set.setDisplayName(getString("ItemConfigurationTxt"));
403:                set.setShortDescription(getString("ItemConfigurationHint"));
404:                if ((getConfiguration() instanceof  MakeConfiguration)
405:                        && ((MakeConfiguration) getConfiguration())
406:                                .isMakefileConfiguration()) {
407:                    set.put(new BooleanNodeProp(getExcluded(), true,
408:                            "ExcludedFromBuild",
409:                            getString("ExcludedFromCodeAssistanceTxt"),
410:                            getString("ExcludedFromCodeAssistanceHint"))); // NOI18N
411:                } else {
412:                    set.put(new BooleanNodeProp(getExcluded(), true,
413:                            "ExcludedFromBuild",
414:                            getString("ExcludedFromBuildTxt"),
415:                            getString("ExcludedFromBuildHint"))); // NOI18N
416:                }
417:                set.put(new ToolNodeProp());
418:                sheet.put(set);
419:
420:                return sheet;
421:            }
422:
423:            private class ToolNodeProp extends Node.Property {
424:                public ToolNodeProp() {
425:                    super (Integer.class);
426:                }
427:
428:                @Override
429:                public String getName() {
430:                    return getString("ToolTxt1");
431:                }
432:
433:                public Object getValue() {
434:                    return new Integer(getTool());
435:                }
436:
437:                public void setValue(Object v) {
438:                    String newTool = (String) v;
439:                    setTool(newTool);
440:                }
441:
442:                public boolean canWrite() {
443:                    return true;
444:                }
445:
446:                public boolean canRead() {
447:                    return true;
448:                }
449:
450:                @Override
451:                public PropertyEditor getPropertyEditor() {
452:                    return new ToolEditor();
453:                }
454:            }
455:
456:            private class ToolEditor extends PropertyEditorSupport {
457:
458:                @Override
459:                public String getJavaInitializationString() {
460:                    return getAsText();
461:                }
462:
463:                @Override
464:                public String getAsText() {
465:                    int val = ((Integer) getValue()).intValue();
466:                    return Tool.getName(val);
467:                    //            CompilerSet set = CompilerSetManager.getDefault().getCompilerSet(((MakeConfiguration)configuration).getCompilerSet().getValue());
468:                    //            return set.getTool(val).getGenericName();
469:                }
470:
471:                @Override
472:                public void setAsText(String text)
473:                        throws java.lang.IllegalArgumentException {
474:                    setValue(text);
475:                }
476:
477:                @Override
478:                public String[] getTags() {
479:                    return getToolNames();
480:                }
481:            }
482:
483:            private class StringRONodeProp extends PropertySupport {
484:                String value;
485:
486:                public StringRONodeProp(String name, String value) {
487:                    super (name, String.class, name, name, true, false);
488:                    this .value = value;
489:                }
490:
491:                public Object getValue() {
492:                    return value;
493:                }
494:
495:                public void setValue(Object v) {
496:                }
497:            }
498:
499:            @Override
500:            public String toString() {
501:                return getItem().getPath();
502:            }
503:
504:            private static ResourceBundle bundle = null;
505:
506:            private static String getString(String s) {
507:                if (bundle == null) {
508:                    bundle = NbBundle.getBundle(ItemConfiguration.class);
509:                }
510:                return bundle.getString(s);
511:            }
512:        }
w__w___w__.j__ava__2__s_.__c_o___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.