visualweb.navigation/test/unit/src/org/netbeans/modules/visualweb/navigation/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.navigation;
33 import java.beans.PropertyChangeListener;
34 import java.util.ArrayList;
35 import java.util.Collection;
36 import java.util.HashMap;
38 import java.util.Map.Entry;
40 import java.util.concurrent.Future;
41 import org.netbeans.api.project.Project;
42 import org.netbeans.api.project.ProjectUtils;
43 import org.netbeans.modules.project.uiapi.OpenProjectsTrampoline;
49 @org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.project.uiapi.OpenProjectsTrampoline.class)
50 public class MockOpenProjectsTrampoline implements OpenProjectsTrampoline {
52 private Collection<Project> openProjects = new ArrayList<Project>();
54 public MockOpenProjectsTrampoline() {
59 public Project[] getOpenProjectsAPI() {
60 Project[] projects = new Project[openProjects.size()];
61 openProjects.toArray(projects);
65 public void openAPI(Project[] projects, boolean openRequiredProjects) {
66 for (Project project : projects) {
67 openProjects.add(project);
68 mainProject = project;
72 public void closeAPI(Project[] projects) {
73 for (Project project : projects) {
74 openProjects.remove(project);
75 listeners.remove(project);
79 Map<Object, PropertyChangeListener> listeners = new HashMap<Object, PropertyChangeListener>();
81 public void addPropertyChangeListenerAPI(PropertyChangeListener listener, Object source) {
82 listeners.put(source, listener);
85 public void removePropertyChangeListenerAPI(PropertyChangeListener listener) {
86 if (listeners.containsValue(listener)) {
87 Set<Entry<Object, PropertyChangeListener>> entries = listeners.entrySet();
88 for (Entry<Object, PropertyChangeListener> entry : entries) {
89 if (entry.getValue().equals(listener)) {
90 Object object = entry.getKey();
91 listeners.remove(object);
97 private Project mainProject;
99 public Project getMainProject() {
103 public void setMainProject(Project project) {
104 if (project != null && !openProjects.contains(project)) {
105 throw new IllegalArgumentException("Project " + ProjectUtils.getInformation(mainProject).getDisplayName() + " is not open and cannot be set as main.");
107 this.mainProject = project;
110 public Future<Project[]> openProjectsAPI() {
114 public void openAPI(Project[] prjcts, boolean bln, boolean bln1) {
115 throw new UnsupportedOperationException("Not supported yet.");