visualweb.project.jsfloader/test/unit/src/org/netbeans/modules/visualweb/project/jsfloader/test/MockOpenProjectsTrampoline.java
Really making tests compilable.
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
6 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7 * Other names may be trademarks of their respective owners.
9 * The contents of this file are subject to the terms of either the GNU
10 * General Public License Version 2 only ("GPL") or the Common
11 * Development and Distribution License("CDDL") (collectively, the
12 * "License"). You may not use this file except in compliance with the
13 * License. You can obtain a copy of the License at
14 * http://www.netbeans.org/cddl-gplv2.html
15 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16 * specific language governing permissions and limitations under the
17 * License. When distributing the software, include this License Header
18 * Notice in each file and include the License file at
19 * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
20 * particular file as subject to the "Classpath" exception as provided
21 * by Oracle in the GPL Version 2 section of the License file that
22 * accompanied this code. If applicable, add the following below the
23 * License Header, with the fields enclosed by brackets [] replaced by
24 * your own identifying information:
25 * "Portions Copyrighted [year] [name of copyright owner]"
29 * Portions Copyrighted 2007 Sun Microsystems, Inc.
31 package org.netbeans.modules.visualweb.project.jsfloader.test;
33 import java.beans.PropertyChangeListener;
34 import java.beans.PropertyChangeSupport;
35 import java.util.ArrayList;
36 import java.util.Collection;
37 import java.util.concurrent.Future;
38 import org.netbeans.api.project.Project;
39 import org.netbeans.api.project.ProjectUtils;
40 import org.netbeans.api.project.ui.OpenProjects;
41 import org.netbeans.modules.project.uiapi.OpenProjectsTrampoline;
47 @org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.project.uiapi.OpenProjectsTrampoline.class)
48 public class MockOpenProjectsTrampoline implements OpenProjectsTrampoline {
49 /** Property change listeners registered through API */
50 private PropertyChangeSupport pchSupport;
52 private final Collection<Project> openProjects = new ArrayList<Project>();
54 public MockOpenProjectsTrampoline() {
58 public Project[] getOpenProjectsAPI() {
59 Project[] projects = new Project[openProjects.size()];
60 openProjects.toArray(projects);
64 public void openAPI(Project[] projects, boolean openRequiredProjects) {
65 Project[] oldProjects = getOpenProjectsAPI();
66 for (Project project : projects) {
67 openProjects.add(project);
68 mainProject = project;
70 Project[] newProjects = getOpenProjectsAPI();
71 if (pchSupport != null) {
72 pchSupport.firePropertyChange(OpenProjects.PROPERTY_OPEN_PROJECTS, oldProjects, newProjects);
76 public void closeAPI(Project[] projects) {
77 Project[] oldProjects = getOpenProjectsAPI();
78 for (Project project : projects) {
79 openProjects.remove(project);
81 Project[] newProjects = getOpenProjectsAPI();
82 if (pchSupport != null) {
83 pchSupport.firePropertyChange(OpenProjects.PROPERTY_OPEN_PROJECTS, oldProjects, newProjects);
87 public void addPropertyChangeListenerAPI(PropertyChangeListener listener, Object source) {
88 if (pchSupport == null) {
89 pchSupport = new PropertyChangeSupport(this);
91 pchSupport.addPropertyChangeListener(listener);
94 public void removePropertyChangeListenerAPI(PropertyChangeListener listener) {
95 if (pchSupport == null) {
96 pchSupport = new PropertyChangeSupport(this);
98 pchSupport.removePropertyChangeListener(listener);
101 private Project mainProject;
103 public Project getMainProject() {
107 public void setMainProject(Project project) {
108 if (project != null && !openProjects.contains(project)) {
109 throw new IllegalArgumentException("Project " + ProjectUtils.getInformation(project).getDisplayName() + " is not open and cannot be set as main.");
111 this.mainProject = project;
114 public Future<Project[]> openProjectsAPI() {
118 public void openAPI(Project[] prjcts, boolean bln, boolean bln1) {
119 throw new UnsupportedOperationException("Not supported yet.");