1 19 20 package org.netbeans.modules.project.ui; 21 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 import java.beans.PropertyChangeSupport ; 25 import org.netbeans.api.project.Project; 26 import org.netbeans.api.project.ui.OpenProjects; 27 import org.netbeans.modules.project.uiapi.OpenProjectsTrampoline; 28 29 33 public final class OpenProjectsTrampolineImpl implements OpenProjectsTrampoline, PropertyChangeListener { 34 35 36 private PropertyChangeSupport pchSupport; 37 38 private boolean listenersRegistered; 39 40 public OpenProjectsTrampolineImpl() { 41 pchSupport = new PropertyChangeSupport ( this ); 42 } 43 44 public Project[] getOpenProjectsAPI() { 45 return OpenProjectList.getDefault().getOpenProjects(); 46 } 47 48 public void openAPI (Project[] projects, boolean openRequiredProjects) { 49 OpenProjectList.getDefault().open (projects, openRequiredProjects); 50 } 51 52 public void closeAPI(Project[] projects) { 53 OpenProjectList.getDefault().close(projects, false); 54 } 55 56 public void addPropertyChangeListenerAPI( PropertyChangeListener listener ) { 57 boolean shouldRegisterListener; 58 59 synchronized (this) { 60 if (shouldRegisterListener = !listenersRegistered) { 61 listenersRegistered = true; 62 } 63 } 64 65 if (shouldRegisterListener) { 66 OpenProjectList.getDefault().addPropertyChangeListener( this ); 69 } 70 71 pchSupport.addPropertyChangeListener( listener ); 72 } 73 74 public void removePropertyChangeListenerAPI( PropertyChangeListener listener ) { 75 pchSupport.removePropertyChangeListener( listener ); 76 } 77 78 public void propertyChange( PropertyChangeEvent e ) { 79 80 if ( e.getPropertyName().equals( OpenProjectList.PROPERTY_OPEN_PROJECTS ) ) { 81 pchSupport.firePropertyChange( OpenProjects.PROPERTY_OPEN_PROJECTS, e.getOldValue(), e.getNewValue() ); 82 } 83 if ( e.getPropertyName().equals( OpenProjectList.PROPERTY_MAIN_PROJECT ) ) { 84 pchSupport.firePropertyChange( OpenProjects.PROPERTY_MAIN_PROJECT, e.getOldValue(), e.getNewValue() ); 85 } 86 } 87 88 public Project getMainProject() { 89 return OpenProjectList.getDefault().getMainProject(); 90 } 91 92 public void setMainProject(Project project) { 93 OpenProjectList.getDefault().setMainProject(project); 94 } 95 96 } 97 | Popular Tags |