ada.project/src/org/netbeans/modules/ada/project/ui/properties/CompositePanelProviderImpl.java
author Andrea Lucarelli <raster@netbeans.org>
Sun, 22 Aug 2010 23:37:11 +0200
branchrelease68
changeset 16367 d2820c029d3a
parent 15779 367c7fdb5d23
permissions -rw-r--r--
Add JVM compiler support.
raster@14182
     1
/*
raster@14182
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
raster@14182
     3
 *
raster@14182
     4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
raster@14182
     5
 *
raster@14182
     6
 * The contents of this file are subject to the terms of either the GNU
raster@14182
     7
 * General Public License Version 2 only ("GPL") or the Common
raster@14182
     8
 * Development and Distribution License("CDDL") (collectively, the
raster@14182
     9
 * "License"). You may not use this file except in compliance with the
raster@14182
    10
 * License. You can obtain a copy of the License at
raster@14182
    11
 * http://www.netbeans.org/cddl-gplv2.html
raster@14182
    12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
raster@14182
    13
 * specific language governing permissions and limitations under the
raster@14182
    14
 * License.  When distributing the software, include this License Header
raster@14182
    15
 * Notice in each file and include the License file at
raster@14182
    16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
raster@14182
    17
 * particular file as subject to the "Classpath" exception as provided
raster@14182
    18
 * by Sun in the GPL Version 2 section of the License file that
raster@14182
    19
 * accompanied this code. If applicable, add the following below the
raster@14182
    20
 * License Header, with the fields enclosed by brackets [] replaced by
raster@14182
    21
 * your own identifying information:
raster@14182
    22
 * "Portions Copyrighted [year] [name of copyright owner]"
raster@14182
    23
 *
raster@14182
    24
 * If you wish your version of this file to be governed by only the CDDL
raster@14182
    25
 * or only the GPL Version 2, indicate your decision by adding
raster@14182
    26
 * "[Contributor] elects to include this software in this distribution
raster@14182
    27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
raster@14182
    28
 * single choice of license, a recipient has the option to distribute
raster@14182
    29
 * your version of this file under either the CDDL, the GPL Version 2 or
raster@14182
    30
 * to extend the choice of license to its licensees as provided above.
raster@14182
    31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
raster@14182
    32
 * Version 2 license, then the option applies only if the new code is
raster@14182
    33
 * made subject to such option by the copyright holder.
raster@14182
    34
 *
raster@14182
    35
 * Contributor(s):
raster@14182
    36
 *
raster@14182
    37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
raster@14182
    38
 */
raster@14182
    39
package org.netbeans.modules.ada.project.ui.properties;
raster@14182
    40
raster@14182
    41
import javax.swing.JComponent;
raster@14182
    42
import javax.swing.JPanel;
raster@16367
    43
import org.netbeans.modules.ada.project.options.ui.AdaGeneralOptionsPanel;
raster@14182
    44
import org.netbeans.spi.project.ui.support.ProjectCustomizer;
raster@14182
    45
import org.netbeans.spi.project.ui.support.ProjectCustomizer.CompositeCategoryProvider;
raster@14182
    46
import org.openide.util.Lookup;
raster@14182
    47
import org.openide.util.NbBundle;
raster@14182
    48
raster@14182
    49
/**
raster@14182
    50
 *
raster@14182
    51
 * @author Andrea Lucarelli
raster@14182
    52
 */
raster@14182
    53
public class CompositePanelProviderImpl implements CompositeCategoryProvider {
raster@14182
    54
raster@14182
    55
    public static final String SOURCE_PACKAGES = "SourcePackages"; // NOI18N
raster@14182
    56
    public static final String LIBRARIES_PATH = "LibrariesPath"; //NOI18N
raster@15779
    57
    public static final String STANDARDS_AND_NAMING = "Naming"; //NOI18N
raster@14488
    58
    public static final String BUILD = "Build"; // NOI18N
raster@14182
    59
    public static final String RUN = "Run"; // NOI18N
raster@14182
    60
    private final String name;
raster@14182
    61
raster@14182
    62
    public CompositePanelProviderImpl(String name) {
raster@14182
    63
        this.name = name;
raster@14182
    64
    }
raster@14182
    65
raster@14182
    66
    public ProjectCustomizer.Category createCategory(Lookup context) {
raster@14182
    67
        ProjectCustomizer.Category toReturn = null;
raster@14182
    68
        final ProjectCustomizer.Category[] categories = null;
raster@14182
    69
raster@14182
    70
        if (SOURCE_PACKAGES.equals(name)) {
raster@14182
    71
            toReturn = ProjectCustomizer.Category.create(
raster@14182
    72
                    SOURCE_PACKAGES,
raster@14182
    73
                    NbBundle.getMessage(CompositePanelProviderImpl.class, "LBL_Config_Sources"),
raster@14182
    74
                    null,
raster@14182
    75
                    categories);
raster@14488
    76
        } else if (BUILD.equals(name)) {
raster@14488
    77
            toReturn = ProjectCustomizer.Category.create(
raster@14488
    78
                    BUILD,
raster@14488
    79
                    NbBundle.getMessage(CompositePanelProviderImpl.class, "LBL_Config_BuildConfig"),
raster@14488
    80
                    null,
raster@14488
    81
                    categories);
raster@14182
    82
        } else if (RUN.equals(name)) {
raster@14182
    83
            toReturn = ProjectCustomizer.Category.create(
raster@14182
    84
                    RUN,
raster@14182
    85
                    NbBundle.getMessage(CompositePanelProviderImpl.class, "LBL_Config_RunConfig"),
raster@14182
    86
                    null,
raster@14182
    87
                    categories);
raster@14182
    88
        } else if (LIBRARIES_PATH.equals(name)) {
raster@14182
    89
            toReturn = ProjectCustomizer.Category.create(
raster@14182
    90
                    LIBRARIES_PATH,
raster@14182
    91
                    NbBundle.getMessage(CompositePanelProviderImpl.class, "LBL_Config_LibrariesPath"),
raster@14182
    92
                    null,
raster@14182
    93
                    categories);
raster@15779
    94
        } else if (STANDARDS_AND_NAMING.equals(name)) {
raster@15779
    95
            toReturn = ProjectCustomizer.Category.create(
raster@15779
    96
                    STANDARDS_AND_NAMING,
raster@15779
    97
                    NbBundle.getMessage(CompositePanelProviderImpl.class, "LBL_Standards_Naming"),
raster@15779
    98
                    null,
raster@15779
    99
                    categories);
raster@14182
   100
        }
raster@16367
   101
raster@14182
   102
        assert toReturn != null : "No category for name: " + name;
raster@14182
   103
        return toReturn;
raster@14182
   104
    }
raster@14182
   105
raster@14182
   106
    public JComponent createComponent(ProjectCustomizer.Category category, Lookup context) {
raster@14182
   107
        String nm = category.getName();
raster@14182
   108
        AdaProjectProperties uiProps = context.lookup(AdaProjectProperties.class);
raster@14182
   109
raster@14182
   110
        if (SOURCE_PACKAGES.equals(nm)) {
raster@14182
   111
            return new CustomizerSources(uiProps);
raster@14488
   112
        } else if (BUILD.equals(nm)) {
raster@14488
   113
            return new CustomizerBuild(uiProps);
raster@14182
   114
        } else if (RUN.equals(nm)) {
raster@14182
   115
            return new CustomizerRun(uiProps);
raster@14182
   116
        } else if (LIBRARIES_PATH.equals(nm)) {
raster@14182
   117
            return new CustomizerLibrariesPath(uiProps);
raster@15779
   118
        } else if (STANDARDS_AND_NAMING.equals(nm)) {
raster@15779
   119
            return new AdaGeneralOptionsPanel(uiProps);
raster@14182
   120
        }
raster@16367
   121
raster@14182
   122
        return new JPanel();
raster@14182
   123
    }
raster@14182
   124
raster@14182
   125
    public static CompositePanelProviderImpl createSources() {
raster@14182
   126
        return new CompositePanelProviderImpl(SOURCE_PACKAGES);
raster@14182
   127
    }
raster@14182
   128
raster@14182
   129
    public static CompositePanelProviderImpl createRunConfig() {
raster@14182
   130
        return new CompositePanelProviderImpl(RUN);
raster@14182
   131
    }
raster@14182
   132
raster@14488
   133
    public static CompositePanelProviderImpl createBuildConfig() {
raster@14488
   134
        return new CompositePanelProviderImpl(BUILD);
raster@14488
   135
    }
raster@14488
   136
raster@14488
   137
    public static CompositePanelProviderImpl createLibrariesPath() {
raster@14182
   138
        return new CompositePanelProviderImpl(LIBRARIES_PATH);
raster@14182
   139
    }
raster@15779
   140
raster@15779
   141
    public static CompositePanelProviderImpl createNamingConfig() {
raster@15779
   142
        return new CompositePanelProviderImpl(STANDARDS_AND_NAMING);
raster@15779
   143
    }
raster@14182
   144
}