1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/python.project2/src/org/netbeans/modules/python/project2/ImportantFilesChildren.java Sun Jan 10 15:02:08 2016 +0100
1.3 @@ -0,0 +1,62 @@
1.4 +/*
1.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1.6 + *
1.7 + * Copyright 2016 Oracle and/or its affiliates. All rights reserved.
1.8 + *
1.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
1.10 + * Other names may be trademarks of their respective owners.
1.11 + *
1.12 + * The contents of this file are subject to the terms of either the GNU
1.13 + * General Public License Version 2 only ("GPL") or the Common
1.14 + * Development and Distribution License("CDDL") (collectively, the
1.15 + * "License"). You may not use this file except in compliance with the
1.16 + * License. You can obtain a copy of the License at
1.17 + * http://www.netbeans.org/cddl-gplv2.html
1.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
1.19 + * specific language governing permissions and limitations under the
1.20 + * License. When distributing the software, include this License Header
1.21 + * Notice in each file and include the License file at
1.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
1.23 + * particular file as subject to the "Classpath" exception as provided
1.24 + * by Oracle in the GPL Version 2 section of the License file that
1.25 + * accompanied this code. If applicable, add the following below the
1.26 + * License Header, with the fields enclosed by brackets [] replaced by
1.27 + * your own identifying information:
1.28 + * "Portions Copyrighted [year] [name of copyright owner]"
1.29 + *
1.30 + * If you wish your version of this file to be governed by only the CDDL
1.31 + * or only the GPL Version 2, indicate your decision by adding
1.32 + * "[Contributor] elects to include this software in this distribution
1.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
1.34 + * single choice of license, a recipient has the option to distribute
1.35 + * your version of this file under either the CDDL, the GPL Version 2 or
1.36 + * to extend the choice of license to its licensees as provided above.
1.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
1.38 + * Version 2 license, then the option applies only if the new code is
1.39 + * made subject to such option by the copyright holder.
1.40 + *
1.41 + * Contributor(s):
1.42 + *
1.43 + * Portions Copyrighted 2016 Sun Microsystems, Inc.
1.44 + */
1.45 +package org.netbeans.modules.python.project2;
1.46 +
1.47 +import org.openide.nodes.Children;
1.48 +import org.openide.nodes.Node;
1.49 +
1.50 +/**
1.51 + *
1.52 + * @author jenselme
1.53 + */
1.54 +public class ImportantFilesChildren extends Children {
1.55 + @Override
1.56 + public boolean add(Node[] nodes) {
1.57 + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
1.58 + }
1.59 +
1.60 + @Override
1.61 + public boolean remove(Node[] nodes) {
1.62 + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
1.63 + }
1.64 +
1.65 +}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/python.project2/src/org/netbeans/modules/python/project2/ImportantFilesNode.java Sun Jan 10 15:02:08 2016 +0100
2.3 @@ -0,0 +1,87 @@
2.4 +/*
2.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2.6 + *
2.7 + * Copyright 2016 Oracle and/or its affiliates. All rights reserved.
2.8 + *
2.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
2.10 + * Other names may be trademarks of their respective owners.
2.11 + *
2.12 + * The contents of this file are subject to the terms of either the GNU
2.13 + * General Public License Version 2 only ("GPL") or the Common
2.14 + * Development and Distribution License("CDDL") (collectively, the
2.15 + * "License"). You may not use this file except in compliance with the
2.16 + * License. You can obtain a copy of the License at
2.17 + * http://www.netbeans.org/cddl-gplv2.html
2.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
2.19 + * specific language governing permissions and limitations under the
2.20 + * License. When distributing the software, include this License Header
2.21 + * Notice in each file and include the License file at
2.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
2.23 + * particular file as subject to the "Classpath" exception as provided
2.24 + * by Oracle in the GPL Version 2 section of the License file that
2.25 + * accompanied this code. If applicable, add the following below the
2.26 + * License Header, with the fields enclosed by brackets [] replaced by
2.27 + * your own identifying information:
2.28 + * "Portions Copyrighted [year] [name of copyright owner]"
2.29 + *
2.30 + * If you wish your version of this file to be governed by only the CDDL
2.31 + * or only the GPL Version 2, indicate your decision by adding
2.32 + * "[Contributor] elects to include this software in this distribution
2.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
2.34 + * single choice of license, a recipient has the option to distribute
2.35 + * your version of this file under either the CDDL, the GPL Version 2 or
2.36 + * to extend the choice of license to its licensees as provided above.
2.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
2.38 + * Version 2 license, then the option applies only if the new code is
2.39 + * made subject to such option by the copyright holder.
2.40 + *
2.41 + * Contributor(s):
2.42 + *
2.43 + * Portions Copyrighted 2016 Sun Microsystems, Inc.
2.44 + */
2.45 +package org.netbeans.modules.python.project2;
2.46 +
2.47 +import java.awt.Image;
2.48 +import org.netbeans.api.annotations.common.StaticResource;
2.49 +import org.netbeans.api.project.Project;
2.50 +import org.openide.filesystems.FileUtil;
2.51 +import org.openide.loaders.DataFolder;
2.52 +import org.openide.loaders.DataObject;
2.53 +import org.openide.loaders.DataObjectNotFoundException;
2.54 +import org.openide.nodes.FilterNode;
2.55 +import org.openide.util.ImageUtilities;
2.56 +
2.57 +/**
2.58 + *
2.59 + * @author jenselme
2.60 + */
2.61 +class ImportantFilesNode extends FilterNode {
2.62 + @StaticResource
2.63 + private static final String IMAGE = "org/netbeans/modules/"
2.64 + + "python/project2/resources/brokenProjectBadge.gif";
2.65 +
2.66 + public ImportantFilesNode(Project proj) throws DataObjectNotFoundException {
2.67 + super(DataObject.find(proj.getProjectDirectory()).getNodeDelegate(), new ImportantFilesChildren());
2.68 + proj.getProjectDirectory().getChildren(false);
2.69 + }
2.70 +
2.71 + @Override
2.72 + public String getDisplayName() {
2.73 + return "Important Files";
2.74 + }
2.75 +
2.76 + @Override
2.77 + public Image getIcon(int type) {
2.78 + DataFolder root = DataFolder.findFolder(FileUtil.getConfigRoot());
2.79 + Image original = root.getNodeDelegate().getIcon(type);
2.80 + return ImageUtilities.mergeImages(original,
2.81 + ImageUtilities.loadImage(IMAGE), 7, 7);
2.82 + }
2.83 + @Override
2.84 + public Image getOpenedIcon(int type) {
2.85 + DataFolder root = DataFolder.findFolder(FileUtil.getConfigRoot());
2.86 + Image original = root.getNodeDelegate().getIcon(type);
2.87 + return ImageUtilities.mergeImages(original,
2.88 + ImageUtilities.loadImage(IMAGE), 7, 7);
2.89 + }
2.90 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/python.project2/src/org/netbeans/modules/python/project2/PythonImportantFilesNodeFactory.java Sun Jan 10 15:02:08 2016 +0100
3.3 @@ -0,0 +1,74 @@
3.4 +/*
3.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3.6 + *
3.7 + * Copyright 2016 Oracle and/or its affiliates. All rights reserved.
3.8 + *
3.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
3.10 + * Other names may be trademarks of their respective owners.
3.11 + *
3.12 + * The contents of this file are subject to the terms of either the GNU
3.13 + * General Public License Version 2 only ("GPL") or the Common
3.14 + * Development and Distribution License("CDDL") (collectively, the
3.15 + * "License"). You may not use this file except in compliance with the
3.16 + * License. You can obtain a copy of the License at
3.17 + * http://www.netbeans.org/cddl-gplv2.html
3.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
3.19 + * specific language governing permissions and limitations under the
3.20 + * License. When distributing the software, include this License Header
3.21 + * Notice in each file and include the License file at
3.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
3.23 + * particular file as subject to the "Classpath" exception as provided
3.24 + * by Oracle in the GPL Version 2 section of the License file that
3.25 + * accompanied this code. If applicable, add the following below the
3.26 + * License Header, with the fields enclosed by brackets [] replaced by
3.27 + * your own identifying information:
3.28 + * "Portions Copyrighted [year] [name of copyright owner]"
3.29 + *
3.30 + * If you wish your version of this file to be governed by only the CDDL
3.31 + * or only the GPL Version 2, indicate your decision by adding
3.32 + * "[Contributor] elects to include this software in this distribution
3.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
3.34 + * single choice of license, a recipient has the option to distribute
3.35 + * your version of this file under either the CDDL, the GPL Version 2 or
3.36 + * to extend the choice of license to its licensees as provided above.
3.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
3.38 + * Version 2 license, then the option applies only if the new code is
3.39 + * made subject to such option by the copyright holder.
3.40 + *
3.41 + * Contributor(s):
3.42 + *
3.43 + * Portions Copyrighted 2016 Sun Microsystems, Inc.
3.44 + */
3.45 +package org.netbeans.modules.python.project2;
3.46 +
3.47 +import org.netbeans.api.project.Project;
3.48 +import org.netbeans.spi.project.ui.support.NodeFactory;
3.49 +import org.netbeans.spi.project.ui.support.NodeFactorySupport;
3.50 +import org.netbeans.spi.project.ui.support.NodeList;
3.51 +import org.openide.loaders.DataObjectNotFoundException;
3.52 +import org.openide.util.Exceptions;
3.53 +
3.54 +/**
3.55 + *
3.56 + * @author Julien Enselme <jenselme@netbeans.org>
3.57 + */
3.58 +@NodeFactory.Registration(projectType = "org-netbeans-modules-python-project2", position = 200)
3.59 +public class PythonImportantFilesNodeFactory implements NodeFactory {
3.60 + @Override
3.61 + public NodeList createNodes(Project project) {
3.62 + //Optionally, only return a new node
3.63 + //if some item is in the project's lookup:
3.64 + //MyCoolLookupItem item = project.getLookup().lookup(MyCoolLookupItem.class);
3.65 + //if (item != null) {
3.66 + try {
3.67 + ImportantFilesNode nd = new ImportantFilesNode(project);
3.68 + return NodeFactorySupport.fixedNodeList(nd);
3.69 + } catch (DataObjectNotFoundException ex) {
3.70 + Exceptions.printStackTrace(ex);
3.71 + }
3.72 + //If the above try/catch fails, e.g.,
3.73 + //our item isn't in the lookup,
3.74 + //then return an empty list of nodes:
3.75 + return NodeFactorySupport.fixedNodeList();
3.76 + }
3.77 +}