Add JVM compiler support.
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common
8 * Development and Distribution License("CDDL") (collectively, the
9 * "License"). You may not use this file except in compliance with the
10 * License. You can obtain a copy of the License at
11 * http://www.netbeans.org/cddl-gplv2.html
12 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13 * specific language governing permissions and limitations under the
14 * License. When distributing the software, include this License Header
15 * Notice in each file and include the License file at
16 * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17 * particular file as subject to the "Classpath" exception as provided
18 * by Sun in the GPL Version 2 section of the License file that
19 * accompanied this code. If applicable, add the following below the
20 * License Header, with the fields enclosed by brackets [] replaced by
21 * your own identifying information:
22 * "Portions Copyrighted [year] [name of copyright owner]"
24 * If you wish your version of this file to be governed by only the CDDL
25 * or only the GPL Version 2, indicate your decision by adding
26 * "[Contributor] elects to include this software in this distribution
27 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28 * single choice of license, a recipient has the option to distribute
29 * your version of this file under either the CDDL, the GPL Version 2 or
30 * to extend the choice of license to its licensees as provided above.
31 * However, if you add GPL Version 2 code and therefore, elected the GPL
32 * Version 2 license, then the option applies only if the new code is
33 * made subject to such option by the copyright holder.
37 * Portions Copyrighted 2009 Sun Microsystems, Inc.
39 package org.netbeans.modules.ada.editor;
41 import java.awt.Image;
42 import java.text.DateFormat;
43 import org.openide.filesystems.FileAttributeEvent;
44 import org.openide.filesystems.FileChangeListener;
45 import org.openide.filesystems.FileEvent;
46 import org.openide.filesystems.FileRenameEvent;
47 import org.openide.loaders.DataNode;
48 import org.openide.loaders.DataObject;
49 import org.openide.nodes.FilterNode.Children;
50 import org.openide.util.ImageUtilities;
51 import org.openide.util.Lookup;
55 * @author Andrea Lucarelli
57 public class AdaDataNode extends DataNode implements FileChangeListener {
59 private static final String ADS_ICON = "/org/netbeans/modules/ada/editor/resources/icons/ads-16.png";
60 private static final String ADB_ICON = "/org/netbeans/modules/ada/editor/resources/icons/adb-16.png";
61 private static final String ADA_SPEC_ICON = "/org/netbeans/modules/ada/editor/resources/icons/ada-spec-16.png";
62 private static final String ADA_BODY_ICON = "/org/netbeans/modules/ada/editor/resources/icons/ada-body-16.png";
63 private AdaDataObject obj;
64 private String displayName;
65 private String tooltip;
68 public AdaDataNode(AdaDataObject obj) {
69 super(obj, Children.LEAF);
73 public AdaDataNode(DataObject obj, Lookup lookup) {
74 super(obj, Children.LEAF, lookup);
75 //Add file change listener to the FileObject:
76 //obj.getPrimaryFile().addFileChangeListener(this);
78 if (obj.getPrimaryFile().getExt().equalsIgnoreCase("ads")) {
79 setIconBaseWithExtension(ADS_ICON);
80 icon = ImageUtilities.loadImage(ADS_ICON);
81 } else if (obj.getPrimaryFile().getExt().equalsIgnoreCase("adb")) {
82 setIconBaseWithExtension(ADB_ICON);
83 icon = ImageUtilities.loadImage(ADB_ICON);
85 // TODO: manage the contents for set the icon
86 setIconBaseWithExtension(ADA_SPEC_ICON);
87 icon = ImageUtilities.loadImage(ADA_SPEC_ICON);
90 //Set default tooltip:
91 tooltip = obj.getPrimaryFile().getNameExt();
92 setShortDescription (tooltip);
96 public String getDisplayName() {
97 if (null != displayName) {
100 return super.getDisplayName();
104 public String getShortDescription() {
105 if (null != tooltip) {
108 return super.getShortDescription();
112 public Image getIcon(int arg0) {
116 return super.getIcon(arg0);
119 //When the file changes...
121 public void fileChanged(FileEvent arg0) {
123 //Get the milliseconds and format it:
124 long mills = System.currentTimeMillis();
125 DateFormat dateFormatter = DateFormat.getDateTimeInstance(
128 String formatted = dateFormatter.format(mills);
130 //Save the current display name:
131 String oldDisplayName = displayName;
133 //Save the current tooltip:
134 String oldShortDescription = tooltip;
136 //Set the new display name:
137 displayName = "Change (" + formatted + ")";
139 //Set the new tooltip:
142 //Fire change events on the node,
143 //which will immediately refresh it with the new values:
144 fireDisplayNameChange(oldDisplayName, displayName);
145 fireShortDescriptionChange(oldShortDescription, tooltip);
150 public void fileFolderCreated(FileEvent arg0) {
154 public void fileDataCreated(FileEvent arg0) {
158 public void fileDeleted(FileEvent arg0) {
162 public void fileRenamed(FileRenameEvent arg0) {
166 public void fileAttributeChanged(FileAttributeEvent arg0) {