|
From: <caw...@us...> - 2007-01-18 21:46:49
|
Revision: 1804
http://svn.sourceforge.net/rubyeclipse/?rev=1804&view=rev
Author: cawilliams
Date: 2007-01-18 13:46:46 -0800 (Thu, 18 Jan 2007)
Log Message:
-----------
moved to externally facing package
Added Paths:
-----------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/VMStandin.java
Added: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/VMStandin.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/VMStandin.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/VMStandin.java 2007-01-18 21:46:46 UTC (rev 1804)
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.launching;
+
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.rubypeople.rdt.internal.launching.IllegalCommandException;
+
+
+
+/**
+ * An implementation of IVMInstall that is used for manipulating VMs without necessarily
+ * committing changes.
+ * <p>
+ * Instances of this class act like wrappers. All other instances of IVMInstall represent
+ * 'real live' VMs that may be used for building or launching. Instances of this class
+ * behave like 'temporary' VMs that are not visible and not available for building or launching.
+ * </p>
+ * <p>
+ * Instances of this class may be constructed as a preliminary step to creating a 'live' VM
+ * or as a preliminary step to making changes to a 'real' VM.
+ * </p>
+ * When <code>convertToRealVM</code> is called, a corresponding 'real' VM is created
+ * if one did not previously exist, or the corresponding 'real' VM is updated.
+ * </p>
+ * <p>
+ * Clients may instantiate this class; it is not intended to be subclassed.
+ * </p>
+ *
+ * @since 0.9.0
+ */
+public class VMStandin extends AbstractVMInstall {
+
+ /**
+ * <code>java.version</code> system property, or <code>null</code>
+ * @since 0.9.0
+ */
+ private String fRubyVersion = null;
+
+ /*
+ * @see org.eclipse.jdt.launching.AbstractVMInstall#AbstractVMInstall(org.eclipse.jdt.launching.IVMInstallType, java.lang.String)
+ */
+ public VMStandin(IVMInstallType type, String id) {
+ super(type, id);
+ setNotify(false);
+ }
+
+ /**
+ * Constructs a copy of the specified VM with the given identifier.
+ *
+ * @param sourceVM
+ * @param id
+ * @since 3.2
+ */
+ public VMStandin(IVMInstall sourceVM, String id) {
+ super(sourceVM.getVMInstallType(), id);
+ setNotify(false);
+ init(sourceVM);
+ }
+
+ /**
+ * Construct a <code>VMStandin</code> instance based on the specified <code>IVMInstall</code>.
+ * Changes to this standin will not be reflected in the 'real' VM until <code>convertToRealVM</code>
+ * is called.
+ *
+ * @param realVM the 'real' VM from which to construct this standin VM
+ */
+ public VMStandin(IVMInstall realVM) {
+ this (realVM.getVMInstallType(), realVM.getId());
+ init(realVM);
+ }
+
+ /**
+ * Initializes the settings of this standin based on the settings in the given
+ * VM install.
+ *
+ * @param realVM VM to copy settings from
+ */
+ private void init(IVMInstall realVM) {
+ setName(realVM.getName());
+ setInstallLocation(realVM.getInstallLocation());
+ setLibraryLocations(realVM.getLibraryLocations());
+ if (realVM instanceof IVMInstall2) {
+ IVMInstall2 vm2 = (IVMInstall2) realVM;
+ setVMArgs(vm2.getVMArgs());
+ fRubyVersion = vm2.getRubyVersion();
+ } else {
+ setVMArguments(realVM.getVMArguments());
+ fRubyVersion = null;
+ }
+ }
+
+ /**
+ * If no corresponding 'real' VM exists, create one and populate it from this standin instance.
+ * If a corresponding VM exists, update its attributes from this standin instance.
+ *
+ * @return IVMInstall the 'real' corresponding to this standin VM
+ */
+ public IVMInstall convertToRealVM() {
+ IVMInstallType vmType= getVMInstallType();
+ IVMInstall realVM= vmType.findVMInstall(getId());
+ boolean notify = true;
+
+ if (realVM == null) {
+ realVM= vmType.createVMInstall(getId());
+ notify = false;
+ }
+ // do not notify of property changes on new VMs
+ if (realVM instanceof AbstractVMInstall) {
+ ((AbstractVMInstall)realVM).setNotify(notify);
+ }
+ realVM.setName(getName());
+ realVM.setInstallLocation(getInstallLocation());
+ realVM.setLibraryLocations(getLibraryLocations());
+ if (realVM instanceof IVMInstall2) {
+ IVMInstall2 vm2 = (IVMInstall2) realVM;
+ vm2.setVMArgs(getVMArgs());
+ } else {
+ realVM.setVMArguments(getVMArguments());
+ }
+
+ if (realVM instanceof AbstractVMInstall) {
+ ((AbstractVMInstall)realVM).setNotify(true);
+ }
+ if (!notify) {
+ RubyRuntime.fireVMAdded(realVM);
+ }
+ return realVM;
+ }
+
+ /* (non-Javadoc)
+ * @see org.rubypeople.rdt.launching.IVMInstall#getRubyVersion()
+ */
+ public String getRubyVersion() {
+ return fRubyVersion;
+ }
+
+ public Process exec(List commandLine, File workingDirectory)
+ throws CoreException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getCommand() throws IllegalCommandException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|