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
9 * IBM - Initial API and implementation
10 **********************************************************************/
11 package net.sourceforge.phpdt.monitor.core.internal;
13 import net.sourceforge.phpdt.monitor.core.IMonitor;
14 import net.sourceforge.phpdt.monitor.core.IMonitorWorkingCopy;
15 import net.sourceforge.phpdt.monitor.core.IProtocolAdapter;
19 public class Monitor implements IMonitor {
20 private static final String MEMENTO_ID = "id";
21 private static final String MEMENTO_LOCAL_PORT = "local-port";
22 private static final String MEMENTO_REMOTE_HOST = "remote-host";
23 private static final String MEMENTO_REMOTE_PORT = "remote-port";
24 private static final String MEMENTO_TYPE_ID = "type-id";
27 protected String remoteHost;
28 protected int remotePort = 80;
29 protected int localPort = 80;
30 protected IProtocolAdapter type;
33 type = MonitorPlugin.getInstance().getDefaultType();
37 * @see org.eclipse.monitor.internal.IMonitor#getId()
39 public String getId() {
44 * @see org.eclipse.monitor.internal.IMonitor#getRemoteHost()
46 public String getRemoteHost() {
51 * @see org.eclipse.monitor.internal.IMonitor#getRemotePort()
53 public int getRemotePort() {
58 * @see org.eclipse.monitor.internal.IMonitor#getLocalPort()
60 public int getLocalPort() {
65 * @see org.eclipse.monitor.internal.IMonitor#isHTTPEnabled()
67 public IProtocolAdapter getProtocolAdapter() {
72 * @see org.eclipse.monitor.internal.IMonitor#isRunning()
74 public boolean isRunning() {
75 return MonitorManager.getInstance().isRunning(this);
78 public void delete() {
79 MonitorManager.getInstance().removeMonitor(this);
82 public boolean isWorkingCopy() {
86 public IMonitorWorkingCopy getWorkingCopy() {
87 return new MonitorWorkingCopy(this);
90 protected void setInternal(IMonitor monitor) {
92 remoteHost = monitor.getRemoteHost();
93 remotePort = monitor.getRemotePort();
94 localPort = monitor.getLocalPort();
95 type = monitor.getProtocolAdapter();
98 protected void save(IMemento memento) {
99 memento.putString(MEMENTO_ID, id);
100 memento.putString(MEMENTO_TYPE_ID, type.getId());
101 memento.putInteger(MEMENTO_LOCAL_PORT, localPort);
102 memento.putString(MEMENTO_REMOTE_HOST, remoteHost);
103 memento.putInteger(MEMENTO_REMOTE_PORT, remotePort);
106 protected void load(IMemento memento) {
107 id = memento.getString(MEMENTO_ID);
108 type = MonitorPlugin.getInstance().getProtocolAdapter(memento.getString(MEMENTO_TYPE_ID));
109 Integer temp = memento.getInteger(MEMENTO_LOCAL_PORT);
111 localPort = temp.intValue();
112 remoteHost = memento.getString(MEMENTO_REMOTE_HOST);
113 temp = memento.getInteger(MEMENTO_REMOTE_PORT);
115 remotePort = temp.intValue();