ecca3dcca5d81cba76245d8d970740b792e37270
[phpeclipse.git] /
1 /**********************************************************************
2  * Copyright (c) 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  *    IBM - Initial API and implementation
10  **********************************************************************/
11 package net.sourceforge.phpdt.monitor.core.internal;
12
13 import net.sourceforge.phpdt.monitor.core.*;
14 /**
15  * 
16  */
17 public class MonitorWorkingCopy extends Monitor implements IMonitorWorkingCopy {
18         protected Monitor monitor;
19         
20         // creation
21         public MonitorWorkingCopy() { }
22
23         // working copy
24         public MonitorWorkingCopy(Monitor monitor) {
25                 this.monitor = monitor;
26                 setInternal(monitor);
27         }
28         
29         /* (non-Javadoc)
30          * @see org.eclipse.monitor.internal.IMonitorWorkingCopy#setRemoteHost(java.lang.String)
31          */
32         public void setId(String newId) {
33                 id = newId;
34         }
35
36         /* (non-Javadoc)
37          * @see org.eclipse.monitor.internal.IMonitorWorkingCopy#setRemoteHost(java.lang.String)
38          */
39         public void setRemoteHost(String host) {
40                 remoteHost = host;
41         }
42
43         /* (non-Javadoc)
44          * @see org.eclipse.monitor.internal.IMonitorWorkingCopy#setRemotePort(int)
45          */
46         public void setRemotePort(int port) {
47                 remotePort = port;
48         }
49
50         /* (non-Javadoc)
51          * @see org.eclipse.monitor.internal.IMonitorWorkingCopy#setLocalPort(int)
52          */
53         public void setLocalPort(int port) {
54                 localPort = port;
55         }
56
57         /* (non-Javadoc)
58          * @see org.eclipse.monitor.internal.IMonitorWorkingCopy#setType(IType)
59          */
60         public void setProtocolAdapter(IProtocolAdapter t) {
61                 type = t;
62         }
63         
64         public boolean isWorkingCopy() {
65                 return true;
66         }
67         
68         public IMonitorWorkingCopy getWorkingCopy() {
69                 return this;
70         }
71         
72         public IMonitor save() {
73                 MonitorManager mm = MonitorManager.getInstance();
74                 if (monitor != null) {
75                         //boolean restart = false;
76                         if (monitor.isRunning()) {
77                                 //restart = true;
78                                 mm.stopMonitor(monitor);
79                         }
80                         monitor.setInternal(this);
81                         mm.monitorChanged(monitor);
82                         //if (restart)
83                         //      mm.startMonitor(monitor);
84                 } else {
85                         monitor = new Monitor();
86                         monitor.setInternal(this);
87                         mm.addMonitor(monitor);
88                 }
89                 return monitor;
90         }
91 }