001: /*
002: * Copyright (C) 2001, 2002 Robert MacGrogan
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: *
019: * $Archive: SourceJammer$
020: * $FileName: ExampleProjectListenerPlugin.java$
021: * $FileID: 4751$
022: *
023: * Last change:
024: * $AuthorName: Rob MacGrogan$
025: * $Date: 7/24/03 8:21 PM$
026: * $Comment: Demo for how to create a project change listener.$
027: */
028: package examples;
029:
030: import java.util.Map;
031:
032: import org.sourcejammer.project.controller.ProjectDoesNotExistException;
033: import org.sourcejammer.project.model.FileAccessException;
034: import org.sourcejammer.server.plugin.MissingParamException;
035: import org.sourcejammer.server.plugin.ROProject;
036: import org.sourcejammer.server.plugin.SJServerProjectChangeAdapter;
037: import org.sourcejammer.server.plugin.SJServerProjectEvent;
038: import org.sourcejammer.server.security.SecurityException;
039:
040: /**
041: * Title: $FileName: ExampleProjectListenerPlugin.java$
042: * @version $VerNum: 1$
043: * @author $AuthorName: Rob MacGrogan$<br><br>
044: *
045: * $Description: Demo for how to create a project change listener.$<br>
046: * $KeyWordsOff: $<br>
047: */
048: public class ExampleProjectListenerPlugin extends
049: SJServerProjectChangeAdapter {
050:
051: public void initPlugin(Map params) throws MissingParamException {
052: super .initPlugin(params);
053: System.out
054: .println("The ExampleProjectListenerPlugin has been initialized!");
055: }
056:
057: /**
058: * @see org.sourcejammer.server.plugin.SJServerProjectChangeListener#projectAdded(SJServerProjectEvent)
059: */
060: public void projectAdded(SJServerProjectEvent ev) {
061: long l = ev.getProjectID();
062: try {
063: ROProject proj = ev.getArchiveContext().getProject(l);
064: ev.getLog().println(
065: "Added project: id=" + l + ", name="
066: + proj.getNodeName());
067: } catch (Exception ex) {
068: ex.printStackTrace();
069: }
070: }
071:
072: /**
073: * @see org.sourcejammer.server.plugin.SJServerProjectChangeListener#projectDeleted(SJServerProjectEvent)
074: */
075: public void projectDeleted(SJServerProjectEvent ev) {
076: long l = ev.getProjectID();
077: ROProject proj;
078: try {
079: proj = ev.getArchiveContext().getProject(l);
080: ev.getLog().println(
081: "Deleted project: id=" + l + ", name="
082: + proj.getNodeName());
083: } catch (Exception ex) {
084: ex.printStackTrace();
085: }
086: }
087:
088: /**
089: * @see org.sourcejammer.server.plugin.SJServerProjectChangeListener#projectMoved(SJServerProjectEvent)
090: */
091: public void projectMoved(SJServerProjectEvent ev) {
092: long l = ev.getProjectID();
093: ROProject proj;
094: try {
095: proj = ev.getArchiveContext().getProject(l);
096: ev.getLog().println(
097: "Moved project: id=" + l + ", name="
098: + proj.getNodeName());
099: } catch (Exception ex) {
100: ex.printStackTrace();
101: }
102: }
103:
104: /**
105: * @see org.sourcejammer.server.plugin.SJServerProjectChangeListener#projectRemoved(SJServerProjectEvent)
106: */
107: public void projectRemoved(SJServerProjectEvent ev) {
108: long l = ev.getProjectID();
109: ROProject proj;
110: try {
111: proj = ev.getArchiveContext().getProject(l);
112: ev.getLog().println(
113: "Removed project: id=" + l + ", name="
114: + proj.getNodeName());
115: } catch (Exception ex) {
116: ex.printStackTrace();
117: }
118: }
119:
120: /**
121: * @see org.sourcejammer.server.plugin.SJServerProjectChangeListener#projectRenamed(SJServerProjectEvent)
122: */
123: public void projectRenamed(SJServerProjectEvent ev) {
124: long l = ev.getProjectID();
125: try {
126: ROProject proj = ev.getArchiveContext().getProject(l);
127: ev.getLog().println(
128: "Renamed project: id=" + l + ", name="
129: + proj.getNodeName() + ", oldname="
130: + ev.getTarget());
131: } catch (Exception ex) {
132: ex.printStackTrace();
133: }
134: }
135:
136: /**
137: * @see org.sourcejammer.server.plugin.SJServerProjectChangeListener#projectRestored(SJServerProjectEvent)
138: */
139: public void projectRestored(SJServerProjectEvent ev) {
140: long l = ev.getProjectID();
141: try {
142: ROProject proj = ev.getArchiveContext().getProject(l);
143: ev.getLog().println(
144: "Restored project: id=" + l + ", name="
145: + proj.getNodeName());
146: } catch (Exception ex) {
147: ex.printStackTrace();
148: }
149: }
150:
151: }
|