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.*;
17 public class Monitor implements IMonitor {
18 private static final String MEMENTO_ID = "id";
19 private static final String MEMENTO_LOCAL_PORT = "local-port";
20 private static final String MEMENTO_REMOTE_HOST = "remote-host";
21 private static final String MEMENTO_REMOTE_PORT = "remote-port";
22 private static final String MEMENTO_TYPE_ID = "type-id";
25 protected String remoteHost;
26 protected int remotePort = 80;
27 protected int localPort = 80;
28 protected IProtocolAdapter type;
31 type = MonitorPlugin.getInstance().getDefaultType();
35 * @see org.eclipse.monitor.internal.IMonitor#getId()
37 public String getId() {
42 * @see org.eclipse.monitor.internal.IMonitor#getRemoteHost()
44 public String getRemoteHost() {
49 * @see org.eclipse.monitor.internal.IMonitor#getRemotePort()
51 public int getRemotePort() {
56 * @see org.eclipse.monitor.internal.IMonitor#getLocalPort()
58 public int getLocalPort() {
63 * @see org.eclipse.monitor.internal.IMonitor#isHTTPEnabled()
65 public IProtocolAdapter getProtocolAdapter() {
70 * @see org.eclipse.monitor.internal.IMonitor#isRunning()
72 public boolean isRunning() {
73 return MonitorManager.getInstance().isRunning(this);
76 public void delete() {
77 MonitorManager.getInstance().removeMonitor(this);
80 public boolean isWorkingCopy() {
84 public IMonitorWorkingCopy getWorkingCopy() {
85 return new MonitorWorkingCopy(this);
88 protected void setInternal(IMonitor monitor) {
90 remoteHost = monitor.getRemoteHost();
91 remotePort = monitor.getRemotePort();
92 localPort = monitor.getLocalPort();
93 type = monitor.getProtocolAdapter();
96 protected void save(IMemento memento) {
97 memento.putString(MEMENTO_ID, id);
98 memento.putString(MEMENTO_TYPE_ID, type.getId());
99 memento.putInteger(MEMENTO_LOCAL_PORT, localPort);
100 memento.putString(MEMENTO_REMOTE_HOST, remoteHost);
101 memento.putInteger(MEMENTO_REMOTE_PORT, remotePort);
104 protected void load(IMemento memento) {
105 id = memento.getString(MEMENTO_ID);
106 type = MonitorPlugin.getInstance().getProtocolAdapter(memento.getString(MEMENTO_TYPE_ID));
107 Integer temp = memento.getInteger(MEMENTO_LOCAL_PORT);
109 localPort = temp.intValue();
110 remoteHost = memento.getString(MEMENTO_REMOTE_HOST);
111 temp = memento.getInteger(MEMENTO_REMOTE_PORT);
113 remotePort = temp.intValue();