This commit was manufactured by cvs2svn to create tag 'v20050223_1902'.
diff --git a/plugins/org.eclipse.jem.util/.classpath b/plugins/org.eclipse.jem.util/.classpath
deleted file mode 100644
index 76c372b..0000000
--- a/plugins/org.eclipse.jem.util/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="jemutil/"/>
- <classpathentry kind="src" path="property_files/"/>
- <classpathentry kind="src" path="jemutil-nonworkbnech/"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/plugins/org.eclipse.jem.util/.cvsignore b/plugins/org.eclipse.jem.util/.cvsignore
deleted file mode 100644
index ba077a4..0000000
--- a/plugins/org.eclipse.jem.util/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/plugins/org.eclipse.jem.util/.options b/plugins/org.eclipse.jem.util/.options
deleted file mode 100644
index 0565417..0000000
--- a/plugins/org.eclipse.jem.util/.options
+++ /dev/null
@@ -1,3 +0,0 @@
-org.eclipse.jem.util/debug/logtrace=false
-org.eclipse.jem.util/debug/logtracefile=false
-org.eclipse.jem.util/debug/loglevel=WARNING
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/.project b/plugins/org.eclipse.jem.util/.project
deleted file mode 100644
index e0e4120..0000000
--- a/plugins/org.eclipse.jem.util/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jem.util</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/plugins/org.eclipse.jem.util/README_for_PerformanceMonitorUtil_Compile_Errors.txt b/plugins/org.eclipse.jem.util/README_for_PerformanceMonitorUtil_Compile_Errors.txt
deleted file mode 100644
index e028980..0000000
--- a/plugins/org.eclipse.jem.util/README_for_PerformanceMonitorUtil_Compile_Errors.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-If you are getting compile errors in PerformanceMonitorUtil and PresentPerformanceMonitor classes it is because you
-don't have org.eclipse.perfmsr.core plugin installed. This is an optional plugin that is usually never needed
-except for performance testing.
-
-So to get around the compile errors we've created a stub plugin that you can use just for compiling. To use this
-go to CVS Repository view and check out as a project the org.eclipse.jem.util/org.eclipse.permsr.core.stub directory.
-This will create a plugin project with this as a stub for the performance monitor. You can then compile and run
-from the Run Runtime Workbench launches.
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/about.html b/plugins/org.eclipse.jem.util/about.html
deleted file mode 100644
index 419a5a1..0000000
--- a/plugins/org.eclipse.jem.util/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>20th June, 2002</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, "Program" will mean the Content.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the EPL, any Contributions, as defined in the EPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the EPL and can be made available to others under the terms of the EPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the EPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the EPL and such Modifications can be made available to others under the terms of
-the EPL.</p>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/build.properties b/plugins/org.eclipse.jem.util/build.properties
deleted file mode 100644
index 34a35dc..0000000
--- a/plugins/org.eclipse.jem.util/build.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 2004 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
-###############################################################################
-source.util.jar = jemutil/,\
- property_files/,\
- jemutil-nonworkbnech/
-output.util.jar = bin/
-bin.includes = plugin.xml,\
- util.jar,\
- .options,\
- about.html,\
- plugin.properties
-src.includes = schema/,\
- about.html
diff --git a/plugins/org.eclipse.jem.util/jemutil-nonworkbnech/org/eclipse/jem/util/logger/LogEntry.java b/plugins/org.eclipse.jem.util/jemutil-nonworkbnech/org/eclipse/jem/util/logger/LogEntry.java
deleted file mode 100644
index a585666..0000000
--- a/plugins/org.eclipse.jem.util/jemutil-nonworkbnech/org/eclipse/jem/util/logger/LogEntry.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $RCSfile: LogEntry.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:05:54 $
- */
-package org.eclipse.jem.util.logger;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintWriter;
-
-/**
- * This class should be used when logging information which should be grouped together. Instead of creating a new instance of this class every time it
- * is needed, for performance reasons, create an instance and reuse it.
- *
- *
- * @since 1.0.0
- */
-public class LogEntry {
-
- private int _executionMap = 0;
-
- private Throwable _caughtException = null;
-
- private String _propertiesFileName = null;
-
- private String localeOfOrigin = null;
-
- private String sourceIdentifier;
-
- private String elapsedTime;
-
- private String text;
-
- private String messageTypeIdentifier;
-
- /**
- * The file name parameter must be a name which can be used by ResourceBundle to load the string from the .properties file. The parameter must not
- * be null or the empty string.
- *
- * @param propertiesFileName
- *
- * @since 1.0.0
- */
- public LogEntry(String propertiesFileName) {
- setPropertiesFileName(propertiesFileName);
- }
-
- /**
- * Default Constructor
- */
- public LogEntry() {
- }
-
- /**
- * Get execution map
- *
- * @return execution map
- *
- * @since 1.0.0
- */
- public int getExecutionMap() {
- return _executionMap;
- }
-
- /**
- * Get the properties file name
- *
- * @return properties file name or <code>null</code> if not set.
- *
- * @since 1.0.0
- */
- public String getPropertiesFileName() {
- return _propertiesFileName;
- }
-
- /**
- * Get target exception
- *
- * @return target exception or <code>null</code> if not set.
- *
- * @since 1.0.0
- */
- public Throwable getTargetException() {
- return _caughtException;
- }
-
- /**
- * Get locale of origin
- *
- * @return locale of origin or <code>null</code> if not set.
- *
- * @since 1.0.0
- */
- public String getLocaleOfOrigin() {
- return localeOfOrigin;
- }
-
- /**
- * Get source identifier.
- *
- * @return source identifier or <code>null</code> if not set.
- *
- * @since 1.0.0
- */
- public String getSourceidentifier() {
- return sourceIdentifier;
- }
-
- /**
- * Get elapsed time
- *
- * @return elapsed time
- *
- * @since 1.0.0
- */
- public String getElapsedTime() {
- return elapsedTime;
- }
-
- /**
- * Get the message type identifier
- *
- * @return message type identifier or <code>null</code> if not set.
- *
- * @since 1.0.0
- */
- public String getMessageTypeIdentifier() {
- return messageTypeIdentifier;
- }
-
- /**
- * Set execution map
- *
- * @param map
- *
- * @since 1.0.0
- */
- public void setExecutionMap(int map) {
- _executionMap = map;
- }
-
- /**
- * Set properties file name
- *
- * @param fName
- *
- * @since 1.0.0
- */
- public void setPropertiesFileName(String fName) {
- _propertiesFileName = fName;
- }
-
- /**
- * Set target exception
- *
- * @param exc
- *
- * @since 1.0.0
- */
- public void setTargetException(Throwable exc) {
- _caughtException = exc;
- }
-
- /**
- * Append stacktrace of current stack (at the time of call to this method) to the text buffer.
- *
- *
- * @since 1.0.0
- */
- public void appendStackTrace() {
- // Grab the stack trace from the Thread ...
- ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
- PrintWriter printWriter = new PrintWriter(byteOutput);
- // Can't call Thread.dumpStack() because it doesn't take a writer as input.
- // Copy its mechanism instead.
- new Exception("Stack trace").printStackTrace(printWriter); //$NON-NLS-1$
- printWriter.flush();
-
- // and update the text to the LogEntry's text.
- StringBuffer buffer = new StringBuffer();
- buffer.append(getText());
- buffer.append("\n"); //$NON-NLS-1$
- buffer.append(byteOutput.toString());
- setText(buffer.toString());
- }
-
- /**
- * Get the text.
- *
- * @return text or or <code>null</code> if not set.
- *
- * @since 1.0.0
- */
- public String getText() {
- return text;
- }
-
- /**
- * Set the text
- *
- * @param string
- *
- * @since 1.0.0
- */
- public void setText(String string) {
- text = string;
- }
-
- /**
- * Set every entry to the default value except the properties file name.
- *
- *
- * @since 1.0.0
- */
- public void reset() {
- setExecutionMap(0);
- setTargetException(null);
- localeOfOrigin = null;
- sourceIdentifier = null;
- elapsedTime = null;
- setText(null);
- }
-
- /**
- * Set locale of origin.
- *
- * @param origin
- *
- * @since 1.0.0
- */
- public void setLocaleOfOrigin(String origin) {
- localeOfOrigin = origin;
- }
-
- /**
- * Set source id.
- *
- * @param id
- *
- * @since 1.0.0
- */
- public void setSourceID(String id) {
- sourceIdentifier = id;
- }
-
- /**
- * Set elapsed time.
- *
- * @param time
- *
- * @since 1.0.0
- */
- public void setElapsedTime(long time) {
- elapsedTime = String.valueOf(time);
- }
-
- /**
- * Set source identifier.
- *
- * @param string
- *
- * @since 1.0.0
- */
- public void setSourceIdentifier(String string) {
- setSourceID(string);
- }
-
- /**
- * Set message type identifier.
- *
- * @param string
- *
- * @since 1.0.0
- */
- public void setMessageTypeIdentifier(String string) {
- messageTypeIdentifier = string;
- }
-
- /**
- * Set message type id. Same as <code>setMessageTypeIdentifier.</code>
- * @param string
- *
- * @since 1.0.0
- */
- public void setMessageTypeID(String string) {
- setMessageTypeIdentifier(string);
- }
-
- /**
- * Set tokens. (Currently this is ignored).
- *
- * @param strings
- *
- * @since 1.0.0
- */
- public void setTokens(String[] strings) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer b = new StringBuffer();
- if (text != null)
- b.append(text);
- if (_caughtException != null)
- b.append(_caughtException.toString());
- return b.toString();
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil-nonworkbnech/org/eclipse/jem/util/logger/proxy/ILogRenderer.java b/plugins/org.eclipse.jem.util/jemutil-nonworkbnech/org/eclipse/jem/util/logger/proxy/ILogRenderer.java
deleted file mode 100644
index 3ba7c4d..0000000
--- a/plugins/org.eclipse.jem.util/jemutil-nonworkbnech/org/eclipse/jem/util/logger/proxy/ILogRenderer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $RCSfile: ILogRenderer.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:05:54 $
- */
-package org.eclipse.jem.util.logger.proxy;
-
-/**
- * Basic log renderer interface. It is replaced by the extension <code>ILogRenderer2.</code>
- *
- * @since 1.0.0
- */
-public interface ILogRenderer {
-
- /**
- * Logged to console.
- */
- final public static String CONSOLE_DESCRIPTION = "console"; //$NON-NLS-1$
-
- /**
- * Logged to workbench.
- */
- final public static String WORKBENCH_DESCRIPTION = "workbench log"; //$NON-NLS-1$
-
- /**
- * Not logged.
- */
- final public static String NOLOG_DESCRIPTION = ""; //$NON-NLS-1$
-
- /**
- * Log levels. These are deprecated, use <code>java.util.logging.Level</code> codes instead.
- */
- final public static int LOG_ERROR = 0;
-
- final public static int LOG_TRACE = 1;
-
- final public static int LOG_WARNING = 2;
-
- final public static int LOG_INFO = 3;
-
- final public static String DefaultPluginID = "org.eclipse.jem.util"; //$NON-NLS-1$
-
- /**
- * Log the string at the specified type.
- *
- * @param msg
- * @param type
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(String msg, int type);
-
- /**
- * Start or stop the tracing.
- *
- * @param Flag
- * <code>true</code> to start the tracing.
- *
- * @since 1.0.0
- */
- public void setTraceMode(boolean Flag);
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil-nonworkbnech/org/eclipse/jem/util/logger/proxy/ILogRenderer2.java b/plugins/org.eclipse.jem.util/jemutil-nonworkbnech/org/eclipse/jem/util/logger/proxy/ILogRenderer2.java
deleted file mode 100644
index fb87172..0000000
--- a/plugins/org.eclipse.jem.util/jemutil-nonworkbnech/org/eclipse/jem/util/logger/proxy/ILogRenderer2.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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
- *******************************************************************************/
-/*
- * $RCSfile: ILogRenderer2.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:05:54 $
- */
-package org.eclipse.jem.util.logger.proxy;
-
-import java.util.logging.Level;
-
-/**
- * Log renderer that provides more function. Basically it can handle
- * the logging of specific types in a different manner than the default
- * conversion to string supplied by Logger.
- *
- * It also uses the Level classes from java.util.logging as the logging levels.
- *
- * @since 1.0.0
- */
-public interface ILogRenderer2 extends ILogRenderer {
-
- /**
- * When Logger.setLevel(DEFAULT): restore to what the default level was.
- * When log(...,DEFAULT): Log at the default level for the type of object.
- */
- static final Level DEFAULT = new Logger.LocalLevel("DEFAULT", Integer.MAX_VALUE-1);
-
- /**
- * When log(...,TRACE) : Log only when in trace mode.
- * Don't use in Logger.setLevel(). Has no meaning in that case.
- */
- static final Level TRACE = new Logger.LocalLevel("TRACE", Integer.MAX_VALUE-2);
-
- /**
- * Log the throwable at the given level (if DEFAULT, use default level for a throwable).
- *
- * @param t
- * @param level
- * @return
- *
- * @since 1.0.0
- */
- String log(Throwable t, Level level);
-
- /**
- * Log the object at the given level (if DEFAULT, use default level for an object).
- *
- * @param o
- * @param level
- * @return
- *
- * @since 1.0.0
- */
- String log(Object o, Level level);
-
- /**
- * Log the boolean at the given level (if DEFAULT, use default level for a boolean).
- *
- * @param b
- * @param level
- * @return
- *
- * @since 1.0.0
- */
- String log(boolean b, Level level);
-
- /**
- * Log the char at the given level (if DEFAULT, use default level for a char).
- *
- * @param c
- * @param level
- * @return
- *
- * @since 1.0.0
- */
- String log(char c, Level level);
-
- /**
- * Log the byte at the given level (if DEFAULT, use default level for a byte).
- *
- * @param b
- * @param level
- * @return
- *
- * @since 1.0.0
- */
- String log(byte b, Level level);
-
- /**
- * Log the short at the given level (if DEFAULT, use default level for a short).
- *
- * @param s
- * @param level
- * @return
- *
- * @since 1.0.0
- */
- String log(short s, Level level);
-
- /**
- * Log the int at the given level (if DEFAULT, use default level for an int).
- *
- * @param i
- * @param level
- * @return
- *
- * @since 1.0.0
- */
- String log(int i, Level level);
-
- /**
- * Log the long at the given level (if DEFAULT, use default level for a long).
- *
- * @param l
- * @param level
- * @return
- *
- * @since 1.0.0
- */
- String log(long l, Level level);
-
- /**
- * Log the float at the given level (if DEFAULT, use default level for a float).
- *
- * @param f
- * @param level
- * @return
- *
- * @since 1.0.0
- */
- String log(float f, Level level);
-
- /**
- * Log the double at the given level (if DEFAULT, use default level for a double).
- *
- * @param d
- * @param level
- * @return
- *
- * @since 1.0.0
- */
- String log(double d, Level level);
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil-nonworkbnech/org/eclipse/jem/util/logger/proxy/JDKConsoleRenderer.java b/plugins/org.eclipse.jem.util/jemutil-nonworkbnech/org/eclipse/jem/util/logger/proxy/JDKConsoleRenderer.java
deleted file mode 100644
index 6dc9f8a..0000000
--- a/plugins/org.eclipse.jem.util/jemutil-nonworkbnech/org/eclipse/jem/util/logger/proxy/JDKConsoleRenderer.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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
- *******************************************************************************/
-/*
- * $RCSfile: JDKConsoleRenderer.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:05:54 $
- */
-package org.eclipse.jem.util.logger.proxy;
-
-import java.util.logging.Level;
-
-/**
- * Default log renderer to use when not running under Eclipse. It logs to sysout and syserr.
- *
- * @since 1.1.0
- */
-
-public class JDKConsoleRenderer implements ILogRenderer2 {
-
- private boolean fTraceMode = false; // will we actually punch trace messaged or not
-
- private boolean fSettingTrace = false;
-
- private Logger fMyLogger = null;
-
- /**
- * Constructer taking a logger.
- *
- * @param logger
- *
- * @since 1.1.0
- */
- public JDKConsoleRenderer(Logger logger) {
- super();
- fMyLogger = logger;
- fTraceMode = fMyLogger.getTraceMode();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer#log(java.lang.String, int)
- */
- public String log(String msg, int type) {
-
- if (type == ILogRenderer.LOG_TRACE && !fTraceMode)
- return null;
-
- if (type == ILogRenderer.LOG_ERROR)
- System.err.println(msg);
- else
- System.out.println(msg);
- return ILogRenderer.CONSOLE_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer#setTraceMode(boolean)
- */
- public void setTraceMode(boolean flag) {
-
- if (fSettingTrace)
- return;
- fSettingTrace = true;
- fTraceMode = flag;
- fMyLogger.setTraceMode(flag);
- fSettingTrace = false;
- }
-
- /**
- * Log the string at the given level.
- *
- * @param msg
- * @param level
- * @return <code>CONSOLE_DESCRIPTION</code>
- *
- * @since 1.1.0
- */
- protected String log(String msg, Level level) {
- if (level == Level.SEVERE)
- System.err.println(msg);
- else
- System.out.println(msg);
- return ILogRenderer.CONSOLE_DESCRIPTION;
- }
-
- /**
- * Answer if logging at the given level
- *
- * @param logLevel
- * @return <code>true</code> if logging at the given level.
- *
- * @since 1.1.0
- */
- protected boolean isLogging(Level logLevel) {
- return fTraceMode || fMyLogger.isLoggingLevel(logLevel);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(boolean, java.util.logging.Level)
- */
- public String log(boolean b, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return log(fMyLogger.getGenericMsg(String.valueOf(b), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(byte, java.util.logging.Level)
- */
- public String log(byte b, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return log(fMyLogger.getGenericMsg(String.valueOf(b), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(char, java.util.logging.Level)
- */
- public String log(char c, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return log(fMyLogger.getGenericMsg(String.valueOf(c), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(double, java.util.logging.Level)
- */
- public String log(double d, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return log(fMyLogger.getGenericMsg(String.valueOf(d), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(float, java.util.logging.Level)
- */
- public String log(float f, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return log(fMyLogger.getGenericMsg(String.valueOf(f), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(int, java.util.logging.Level)
- */
- public String log(int i, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return log(fMyLogger.getGenericMsg(String.valueOf(i), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(long, java.util.logging.Level)
- */
- public String log(long l, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return log(fMyLogger.getGenericMsg(String.valueOf(l), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(java.lang.Object, java.util.logging.Level)
- */
- public String log(Object o, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return log(fMyLogger.getGenericMsg(String.valueOf(o), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(short, java.util.logging.Level)
- */
- public String log(short s, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return log(fMyLogger.getGenericMsg(String.valueOf(s), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(java.lang.Throwable, java.util.logging.Level)
- */
- public String log(Throwable t, Level level) {
- if (level == DEFAULT)
- level = Level.SEVERE;
- if (isLogging(level))
- return log(fMyLogger.getGenericMsg(fMyLogger.exceptionToString(t), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil-nonworkbnech/org/eclipse/jem/util/logger/proxy/Logger.java b/plugins/org.eclipse.jem.util/jemutil-nonworkbnech/org/eclipse/jem/util/logger/proxy/Logger.java
deleted file mode 100644
index 465bfe4..0000000
--- a/plugins/org.eclipse.jem.util/jemutil-nonworkbnech/org/eclipse/jem/util/logger/proxy/Logger.java
+++ /dev/null
@@ -1,836 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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
- *******************************************************************************/
-/*
- * $RCSfile: Logger.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:05:54 $
- */
-package org.eclipse.jem.util.logger.proxy;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.*;
-import java.util.logging.Level;
-
-/**
- * This is a base, UI independent logger. It will
- * construct a consistent msg. body, and call an enfironment specific ILogRenderer.
- * By default, this logger will use a console based ILogRenderer,
- * and a J2EE Plugin identification.
- *
- * <p>
- * When running outside of Eclipse, the trace and logging level come from the system properties
- * <ul>
- * <li>"debug" (="true") - The default is <code>false</code>.
- * <li>"logLevel" (="level" where "level" is a level string, e.g. SEVERE, WARNING, etc. from the <code>java.util.logging.Level</code> class).
- * The default is "WARNING".
- * </ul>
- *
- *
- * @since 1.0.0
- */
-public class Logger {
-
- // This is used by ILogRenderer2 to define the default level.
- static class LocalLevel extends Level {
- public LocalLevel(String name, int level) {
- super(name, level);
- }
- }
-
- private boolean fTraceMode = false; // will we actually punch trace messaged or not
- private String fPluginID;
- private ILogRenderer fRenderer = null;
- private ILogRenderer2 renderer2 = null;
- public String fLineSeperator;
- private Level level;
- private Level defaultLevel = Level.SEVERE; // By default only severe or greater are logged.
- private String logFileName;
- private final static String DefaultLoggerPlugin = ILogRenderer.DefaultPluginID;
- static private Hashtable Loggers = new Hashtable(); // Keep track of all the Loggers
- final protected static String[] LogMark = { "*** ERROR *** ", //$NON-NLS-1$
- "[Trace] ", //$NON-NLS-1$
- "+++ Warning +++ ", //$NON-NLS-1$
- "Info " }; //$NON-NLS-1$
-
- final protected static String Filler = " "; // Use this to indent msg. body //$NON-NLS-1$
-
- protected Logger() {
- this(ILogRenderer.DefaultPluginID);
- }
-
- protected Logger(String pluginID) {
- fPluginID = pluginID;
- setRenderer(new JDKConsoleRenderer(this)); // Set up default to this. Someone can change it later.
- }
-
- /**
- * Return the stacktrace as a print formatted string.
- * @param e
- * @return the stacktrace as a string.
- *
- * @since 1.0.0
- */
- public String exceptionToString(Throwable e) {
- StringWriter stringWriter = new StringWriter();
- e.printStackTrace(new PrintWriter(stringWriter));
- return stringWriter.toString();
- }
-
- /**
- * Get the system default logger. This is used for clients that don't know if they
- * are running in Eclipse or outside of it. This way they have a common logger format
- * which switch correctly.
- * @return default logger.
- *
- * @since 1.0.0
- */
- static public Logger getLogger() {
- Logger defaultLogger = (Logger) Loggers.get(DefaultLoggerPlugin);
- if (defaultLogger == null) {
- defaultLogger = new Logger();
- defaultLogger.init();
- Loggers.put(DefaultLoggerPlugin, defaultLogger);
- }
- return defaultLogger;
- }
-
- /**
- * Get the logger for a specific plugin.
- * @param pluginId
- * @return logger for a specific pluggin.
- *
- * @since 1.0.0
- */
- static public Logger getLogger(String pluginId) {
- if (pluginId == null)
- return Logger.getLogger();
- Logger Logger = (Logger) Loggers.get(pluginId);
- if (Logger == null) {
- Logger = new Logger(pluginId);
- Logger.init();
- Loggers.put(pluginId, Logger);
- }
- return Logger;
- }
-
- /**
- * Used by subclass to get a logger if it exists, but not create one.
- * @param pluginId
- * @return logger.
- *
- * @since 1.0.0
- */
- static protected Logger getLoggerIfExists(String pluginId) {
- if (pluginId == null)
- return Logger.getLogger();
- else
- return (Logger) Loggers.get(pluginId);
- }
-
- /**
- * Get the plugin id for this logger.
- * @return pluginid
- *
- * @since 1.0.0
- */
- public String getPluginID() {
- return fPluginID;
- }
-
- /**
- * Get the trace mode for this logger
- * @return <code>true</code> if tracing is going on.
- *
- * @since 1.0.0
- */
- public boolean getTraceMode() {
- return fTraceMode;
- }
-
- /*
- * Indent the Msg. Body to make it easier to read the log
- */
- private void indentMsg(String msg, StringBuffer logMsg) {
- // Line seperator is different on different platform, unix = \n, windows \r\n and mac \r
- String sep = fLineSeperator;
- if (msg.indexOf("\r\n") != -1) //$NON-NLS-1$
- sep = "\r\n"; //$NON-NLS-1$
- else if (msg.indexOf("\n") != -1) //$NON-NLS-1$
- sep = "\n"; //$NON-NLS-1$
- else if (msg.indexOf("\r") != -1) //$NON-NLS-1$
- sep = "\r"; //$NON-NLS-1$
- StringTokenizer tokenizer = new StringTokenizer(msg, sep);
- boolean first = true;
- while (tokenizer.hasMoreTokens()) {
- if (first) {
- first = false;
- logMsg.append(Filler + tokenizer.nextToken());
- } else
- logMsg.append(fLineSeperator + Filler + tokenizer.nextToken());
- }
- }
- /*
- * If Eclipse is started with the -XDebug or -debug turn traces on for this Logger
- * Creation date: (8/23/2001 7:37:04 PM)
- */
- private void init() {
- if (System.getProperty("debug") != null) //$NON-NLS-1$
- fTraceMode = true;
- level = defaultLevel = Level.parse(System.getProperty("logLevel", Level.WARNING.getName()));
-
- try {
- fLineSeperator = System.getProperty("line.separator"); // Diff on Win/Unix/Mac //$NON-NLS-1$
- } catch (Throwable e) {
- fLineSeperator = "\n"; //$NON-NLS-1$
- }
- }
- /*
- * Generic log.
- * Creation date: (8/24/2001 1:55:34 PM)
- * @return java.lang.String
- * @param msg java.lang.String
- * @param type int
- */
- private String logAny(String msg, int type) {
- StringBuffer logMsg = new StringBuffer();
- logMsg.append(fLineSeperator);
- logMsg.append(LogMark[type]);
- return punchLog(logRest(msg, logMsg), type);
- }
-
- /**
- * This is to be used by renderers that want to put a msg out
- * in a generic format. This just returns the string that
- * should be logged. It puts things like headers on it.
- *
- * @param msg
- * @param aLevel
- * @return The generic message for the string and level.
- *
- * @since 1.0.0
- */
- public String getGenericMsg(String msg, Level aLevel) {
- StringBuffer genMsg = new StringBuffer(msg.length()+16);
- genMsg.append(fLineSeperator);
- genMsg.append(getLevelHeader(aLevel));
- genMsg.append(": ");
- genMsg.append(new Date());
- indentMsg(msg, genMsg);
- return genMsg.toString();
- }
-
- private static final Level[] LEVEL_SEARCH = new Level[] {
- Level.SEVERE,
- Level.WARNING,
- Level.INFO,
- ILogRenderer2.TRACE
- };
-
- private static final String[] LEVEL_MARK = new String[] {
- "*** ERROR ***",
- "+++ Warning +++",
- "Info",
- "[Trace]"
- };
-
- private String getLevelHeader(Level aLevel) {
- for (int i=0; i<LEVEL_SEARCH.length; i++)
- if (LEVEL_SEARCH[i] == aLevel)
- return LEVEL_MARK[i];
- return aLevel.getName(); // Not found, just use level string.
- }
-
- // The write's are here for history. Will implement using log(obj, Level) for all of the types.
-
-
- /**
- * deprecated use log(Level, Exception)
- * @param aLevel
- * @param ex
- * @return
- *
- * @since 1.0.0
- *
- */
- public String write(Level aLevel, Exception ex) {
- return log(aLevel, ex);
- }
-
- /**
- * deprecated use log(Throwable)
- * @param ex
- * @return
- *
- * @since 1.0.0
- *
- */
- public String write(Throwable ex) {
- return log(ex);
- }
-
- /**
- * deprecated use log(Object, Level)
- * @param aLevel
- * @param logEntry
- * @return
- *
- * @since 1.0.0
- */
- public String write(Level aLevel, Object logEntry) {
- return log(logEntry, aLevel);
- }
-
- /**
- * deprecated use log(String, Level)
- * @param aLevel
- * @param string
- * @return
- *
- * @since 1.0.0
- */
- public String write(Level aLevel, String string) {
- return log(string, aLevel);
- }
- /**
- * deprecated use log(Throwable, Level)
- * @param aLevel
- * @param ex
- * @return
- *
- * @since 1.0.0
- */
- public String write(Level aLevel, Throwable ex) {
- return log(ex, aLevel);
- }
- /**
- * deprecated use log(Throwable, Level)
- * @param aLevel
- * @param ex
- * @return
- *
- * @since 1.0.0
- */
- public String log(Level aLevel, Exception ex) {
- return log(ex, aLevel);
- }
- /**
- * deprecated use log(Throwable, Level)
- * @param aLevel
- * @param ex
- * @return
- *
- * @since 1.0.0
- */
- public String log(Level aLevel, Throwable ex) {
- return log(ex, aLevel);
- }
-
- /**
- * Get the logging level
- * @return logging level
- *
- * @since 1.0.0
- */
- public Level getLevel() {
- return level;
- }
-
- /**
- * Check if the requested level is being logged. (e.g. if current level is SEVERE, then FINE will not be logged).
- * @param requestlevel
- * @return <code>true</code> if the level will be logged.
- *
- * @since 1.0.0
- */
- public boolean isLoggingLevel(Level requestlevel) {
- if (requestlevel == ILogRenderer2.TRACE && !getTraceMode())
- return false; // We aren't tracing but requested trace.
-
- return !(requestlevel.intValue() < getLevel().intValue() || getLevel() == Level.OFF);
- }
-
- /**
- * Log an error string.
- * @param msg
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String logError(String msg) {
- return log(msg, Level.SEVERE);
- }
-
- /**
- * Log an error throwable
- * @param e
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String logError(Throwable e) {
- return log(e, Level.SEVERE);
- }
-
- /**
- * Log an info message.
- * @param msg
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String logInfo(String msg) {
- return log(msg, Level.INFO);
- }
-
-/**
- * Log a throwable as a warning.
- * @param e
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String logInfo(Throwable e) {
- return log(e, Level.INFO);
- }
-
- /**
- * Append the string to logMsg buffer passed in. Append the date and format the
- * string with nice indentation.
- *
- * @param msg
- * @param logMsg
- * @return the string from the logMsg after logging the rest.
- *
- * @since 1.0.0
- */
- protected String logRest(String msg, StringBuffer logMsg) {
- logMsg.append(new Date());
- indentMsg(msg, logMsg);
- return logMsg.toString();
- }
-
- /**
- * Log the msg as trace only.
- * @param msg
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String logTrace(String msg) {
- if (fTraceMode)
- return log(msg, ILogRenderer2.TRACE);
- else
- return ILogRenderer.NOLOG_DESCRIPTION;
- }
-
- /**
- * Log the throwable as trace only.
- * @param e
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String logTrace(Throwable e) {
- return log(e, ILogRenderer2.TRACE);
- }
-
- /**
- * Log the message as warning.
- * @param msg
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String logWarning(String msg) {
- return log(msg, Level.WARNING);
- }
- /**
- * Log the throwable as a warning.
- * @param e
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String logWarning(Throwable e) {
- return log(e, Level.WARNING);
- }
-
- /**
- * Ask the Renderer to punch the msg. in the log.. one
- * caller at the time
- * Creation date: (8/24/2001 9:19:17 AM)
- * @return java.lang.String
- * @param msg java.lang.String
- * @param type int
- */
- protected synchronized String punchLog(String msg, int type) {
- return fRenderer.log(msg, type);
- }
-
- /**
- * Set the renderer to use.
- * @param renderer
- *
- * @since 1.0.0
- */
- public void setRenderer(ILogRenderer renderer) {
- fRenderer = renderer;
- renderer2 = (renderer instanceof ILogRenderer2) ? (ILogRenderer2) renderer : null;
- renderer.setTraceMode(getTraceMode());
- }
-
- /**
- * Set the trace mode.
- * @param flag <code>true</code> to turn on tracing.
- *
- * @since 1.0.0
- */
- public void setTraceMode(boolean flag) {
- fTraceMode = flag;
- if (fRenderer != null)
- fRenderer.setTraceMode(flag);
- }
-
- /**
- * Set the level cutoff for logging. Anything below this level will not log.
- * Do not set level to <code>ILogRenderer2.TRACE</code>. It doesn't make sense.
- *
- * @param level (Use <code>ILogRenderer2.DEFAULT</code> to restore to default for this logger.
- *
- * @since 1.0.0
- */
- public void setLevel(Level level) {
- this.level = level != ILogRenderer2.DEFAULT ? level : defaultLevel;
- }
-
- /**
- * Set the default level for this logger. It won't touch the current level.
- *
- * @param level
- *
- * @since 1.0.0
- */
- public void setDefaultLevel(Level level) {
- this.defaultLevel = level;
- }
-
- /**
- * Get the log file name.
- * @return Returns the logFileName.
- */
- public String getLogFileName() {
- return logFileName;
- }
-
- /**
- * Set the log file name.
- * @param logFileName The logFileName to set.
- */
- public void setLogFileName(String logFileName) {
- this.logFileName = logFileName;
- }
-
- // Now all of the log() types that use a Level.
-
- /**
- * Log the throwable at the default level for a throwable.
- * @param e
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(Throwable e) {
- return log(e, ILogRenderer2.DEFAULT);
- }
-
- /**
- * Log the throwable at the given level.
- * @param e
- * @param logLevel
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(Throwable e, Level logLevel) {
- if (renderer2 != null) {
- return renderer2.log(e, logLevel);
- } else {
- // Do it the old way.
- String stackTrace = exceptionToString(e);
- return logAny(stackTrace, getOldType(logLevel != ILogRenderer2.DEFAULT ? level : Level.SEVERE));
- }
- }
-
- public String log(Object o) {
- return log(o, ILogRenderer2.DEFAULT);
- }
-
- /**
- * Log the object at the given level.
- * @param o
- * @param logLevel
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(Object o, Level logLevel) {
- if (renderer2 != null) {
- return renderer2.log(o, logLevel);
- } else {
- // Do it the old way.
- return logAny(String.valueOf(o), getOldType(logLevel != ILogRenderer2.DEFAULT ? level : Level.FINEST));
- }
- }
-
- // The following are added to match up with Hyades so that primitives can be logged too.
-
- /**
- * Log a boolean at the default level.
- * @param b
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(boolean b) {
- return log(b, ILogRenderer2.DEFAULT);
- }
-
- /**
- * Log a boolean at the given level.
- * @param b
- * @param logLevel
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(boolean b, Level logLevel) {
- if (renderer2 != null) {
- return renderer2.log(b, logLevel);
- } else {
- // Do it the old way.
- return logAny(String.valueOf(b), getOldType(logLevel != ILogRenderer2.DEFAULT ? level : Level.FINEST));
- }
- }
-
- /**
- * Log the character at the default level.
- * @param c
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(char c) {
- return log(c, ILogRenderer2.DEFAULT);
- }
-
- /**
- * Log the character at the given level.
- * @param c
- * @param logLevel
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(char c, Level logLevel) {
- if (renderer2 != null) {
- return renderer2.log(c, logLevel);
- } else {
- // Do it the old way.
- return logAny(String.valueOf(c), getOldType(logLevel != ILogRenderer2.DEFAULT ? level : Level.FINEST));
- }
- }
-
- /**
- * Log the byte at the default level.
- * @param b
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(byte b) {
- return log(b, ILogRenderer2.DEFAULT);
- }
-
- /**
- * Log the byte at the given level.
- * @param b
- * @param logLevel
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(byte b, Level logLevel) {
- if (renderer2 != null) {
- return renderer2.log(b, logLevel);
- } else {
- // Do it the old way.
- return logAny(String.valueOf(b), getOldType(logLevel != ILogRenderer2.DEFAULT ? level : Level.FINEST));
- }
- }
-
- /**
- * Log the short at the default level.
- * @param s
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(short s) {
- return log(s, ILogRenderer2.DEFAULT);
- }
-
- /**
- * Log the short at the given level.
- * @param s
- * @param logLevel
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(short s, Level logLevel) {
- if (renderer2 != null) {
- return renderer2.log(s, logLevel);
- } else {
- // Do it the old way.
- return logAny(String.valueOf(s), getOldType(logLevel != ILogRenderer2.DEFAULT ? level : Level.FINEST));
- }
- }
-
- /**
- * Log the int at the default level.
- * @param i
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(int i) {
- return log(i, ILogRenderer2.DEFAULT);
- }
-
- /**
- * Log the int at the default level.
- * @param i
- * @param logLevel
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(int i, Level logLevel) {
- if (renderer2 != null) {
- return renderer2.log(i, logLevel);
- } else {
- // Do it the old way.
- return logAny(String.valueOf(i), getOldType(logLevel != ILogRenderer2.DEFAULT ? level : Level.FINEST));
- }
- }
-
- /**
- * Log the long at the default level.
- * @param l
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(long l) {
- return log(l, ILogRenderer2.DEFAULT);
- }
-
- /**
- * Log the long at the given level.
- * @param l
- * @param logLevel
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(long l, Level logLevel) {
- if (renderer2 != null) {
- return renderer2.log(l, logLevel);
- } else {
- // Do it the old way.
- return logAny(String.valueOf(l), getOldType(logLevel != ILogRenderer2.DEFAULT ? level : Level.FINEST));
- }
- }
-
- /**
- * Log the float at the default level.
- * @param f
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(float f) {
- return log(f, ILogRenderer2.DEFAULT);
- }
-
- /**
- * Log the float at the given level.
- * @param f
- * @param logLevel
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(float f, Level logLevel) {
- if (renderer2 != null) {
- return renderer2.log(f, logLevel);
- } else {
- // Do it the old way.
- return logAny(String.valueOf(f), getOldType(logLevel != ILogRenderer2.DEFAULT ? level : Level.FINEST));
- }
- }
-
- /**
- * Log the double at the default level
- * @param d
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(double d) {
- return log(d, ILogRenderer2.DEFAULT);
- }
-
- /**
- * Log the double at the given level
- *
- * @param d
- * @param logLevel
- * @return how it was logged. See <code>CONSOLE_DESCRIPTION.</code>
- *
- * @since 1.0.0
- */
- public String log(double d, Level logLevel) {
- if (renderer2 != null) {
- return renderer2.log(d, logLevel);
- } else {
- // Do it the old way.
- return logAny(String.valueOf(d), getOldType(logLevel != ILogRenderer2.DEFAULT ? level : Level.FINEST));
- }
- }
-
- /*
- * Turn new type into old type. The defaultLevel is the
- * level to use if the incoming level is marked as default.
- */
- private int getOldType(Level aLevel) {
- if (aLevel == Level.SEVERE)
- return ILogRenderer.LOG_ERROR;
- else if (aLevel == Level.WARNING)
- return ILogRenderer.LOG_WARNING;
- else if (aLevel == Level.INFO)
- return ILogRenderer.LOG_INFO;
- else if (aLevel == ILogRenderer2.TRACE)
- return ILogRenderer.LOG_TRACE;
- else
- return ILogRenderer.LOG_INFO;
- }
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/EMFWorkbenchContextFactory.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/EMFWorkbenchContextFactory.java
deleted file mode 100644
index 450b46e..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/EMFWorkbenchContextFactory.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: EMFWorkbenchContextFactory.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.internal.util.emf.workbench;
-
-import java.util.*;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectNature;
-import org.eclipse.core.runtime.*;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-import org.eclipse.jem.internal.util.emf.workbench.nls.EMFWorkbenchResourceHandler;
-import org.eclipse.jem.util.RegistryReader;
-import org.eclipse.jem.util.emf.workbench.*;
-import org.eclipse.jem.util.emf.workbench.nature.EMFNature;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-
-public class EMFWorkbenchContextFactory {
- public static final EMFWorkbenchContextFactory INSTANCE;
-
- static {
- INSTANCE = createFactoryInstance();
- }
- private final Class CONTRIBUTOR_CLASS = IEMFContextContributor.class;
- protected Map emfContextCache = new WeakHashMap();
-
-
- private static EMFWorkbenchContextFactory createFactoryInstance() {
- EMFWorkbenchContextFactory factory = createFactoryInstanceFromExtension();
- if (factory == null)
- factory = new EMFWorkbenchContextFactory();
- return factory;
- }
-
- private static EMFWorkbenchContextFactory createFactoryInstanceFromExtension() {
- final EMFWorkbenchContextFactory[] factoryHolder = new EMFWorkbenchContextFactory[1];
- RegistryReader reader = new RegistryReader(JEMUtilPlugin.ID, "internalWorkbenchContextFactory") { //$NON-NLS-1$
- public boolean readElement(IConfigurationElement element) {
- if (element.getName().equals("factoryClass")) //$NON-NLS-1$
- try {
- factoryHolder[0] = (EMFWorkbenchContextFactory)element.createExecutableExtension("name"); //$NON-NLS-1$
- return true;
- } catch (CoreException e) {
- Logger.getLogger().logError(e);
- }
- return false;
- }
- };
- reader.readRegistry();
- return factoryHolder[0];
- }
-
- /**
- * Constructor for EMFNatureFactory.
- */
- protected EMFWorkbenchContextFactory() {
- super();
-
- }
-
-
- protected void cacheEMFContext(IProject aProject, EMFWorkbenchContextBase emfContext) {
- if (aProject != null && emfContext != null)
- emfContextCache.put(aProject, emfContext);
- }
-
- protected EMFWorkbenchContextBase getCachedEMFContext(IProject aProject) {
- if (aProject != null)
- return (EMFWorkbenchContextBase) emfContextCache.get(aProject);
- return null;
- }
-
- /**
- * <code>aProject</code> is either being closed or deleted so we need to cleanup our cache.
- */
- public void removeCachedProject(IProject aProject) {
- if (aProject != null)
- emfContextCache.remove(aProject);
-
- }
- /**
- * Return a new or existing EMFNature on <code>aProject</code>. Allow the <code>contributor</code>
- * to contribute to the new or existing nature prior to returning.
- */
- public EMFWorkbenchContextBase createEMFContext(IProject aProject, IEMFContextContributor contributor) {
- if (aProject == null)
- throw new IllegalStateException("[EMFWorkbenchContextBase]" + EMFWorkbenchResourceHandler.getString("EMFWorkbenchContextFactory_UI_0")); //$NON-NLS-1$ //$NON-NLS-2$
- if (!aProject.isAccessible())
- throw new IllegalStateException("[EMFWorkbenchContextBase]" + EMFWorkbenchResourceHandler.getString("EMFWorkbenchContextFactory_UI_1", new Object[]{aProject.getName()})); //$NON-NLS-1$ //$NON-NLS-2$
- EMFWorkbenchContextBase context = getCachedEMFContext(aProject);
- if (context == null) {
- context = primCreateEMFContext(aProject);
- cacheEMFContext(aProject, context);
- if (contributor == null)
- initializeEMFContextFromContributors(aProject, context);
- }
- if (contributor != null && context != null)
- contributor.primaryContributeToContext(context);
- return context;
- }
-
- protected void initializeEMFContextFromContributors(IProject aProject, EMFWorkbenchContextBase emfContext) {
- if (aProject == null || emfContext == null)
- return;
- List runtimes = EMFNature.getRegisteredRuntimes(aProject);
- for (int i = 0; i < runtimes.size(); i++) {
- IProjectNature nature = (IProjectNature) runtimes.get(i);
- if (nature != null && CONTRIBUTOR_CLASS.isInstance(nature))
- ((IEMFContextContributor) nature).primaryContributeToContext(emfContext);
- }
- }
-
- protected boolean isNatureEnabled(IProject aProject, String natureId) {
- try {
- return aProject.isNatureEnabled(natureId);
- } catch (CoreException e) {
- return false;
- }
- }
-
- protected String[] getNatureIds(IProject aProject) {
- try {
- if (aProject.isAccessible())
- return aProject.getDescription().getNatureIds();
- } catch (CoreException e) {
- }
- return null;
- }
-
- protected IProjectNature getNature(IProject aProject, String natureId) {
- try {
- return aProject.getNature(natureId);
- } catch (CoreException e) {
- return null;
- }
- }
-
- protected EMFWorkbenchContextBase primCreateEMFContext(IProject aProject) {
- return new EMFWorkbenchContextBase(aProject);
- }
- /**
- * Return an existing EMFNature on <code>aProject</code>.
- */
- public EMFWorkbenchContextBase getEMFContext(IProject aProject) {
- return getCachedEMFContext(aProject);
- }
-
- public ResourceSetWorkbenchSynchronizer createSynchronizer(ResourceSet aResourceSet, IProject aProject) {
- return new ResourceSetWorkbenchSynchronizer(aResourceSet, aProject);
- }
-
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/ProjectResourceSetImpl.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/ProjectResourceSetImpl.java
deleted file mode 100644
index 838f7e7..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/ProjectResourceSetImpl.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: ProjectResourceSetImpl.java,v $$
- * $$Revision: 1.7 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.internal.util.emf.workbench;
-
-import java.io.IOException;
-import java.util.*;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.NotificationImpl;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.Resource.Factory.Registry;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.resource.impl.URIConverterImpl;
-import org.eclipse.emf.ecore.xmi.XMLResource;
-
-import org.eclipse.jem.util.emf.workbench.*;
-import org.eclipse.jem.util.emf.workbench.nature.EMFNature;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-public class ProjectResourceSetImpl extends ResourceSetImpl implements ProjectResourceSet {
- private boolean isReleasing = false;
- private IProject project;
- protected List resourceHandlers = new ArrayList();
- protected ResourceSetWorkbenchSynchronizer synchronizer;
- protected ProjectResourceSetImpl() {
- setURIResourceMap(new HashMap(10)); // Tell it to cache uri->resource access.
- getLoadOptions().put(XMLResource.OPTION_USE_PARSER_POOL, EMFNature.SHARED_PARSER_POOL);
- }
- public ProjectResourceSetImpl(IProject aProject) {
- this();
- setProject(aProject);
- initializeSharedCacheListener();
- }
- protected void initializeSharedCacheListener() {
- JEMUtilPlugin.getSharedCache().beginListening(this);
- }
- protected boolean isReleasing() {
- return isReleasing;
- }
- /**
- * @see org.eclipse.emf.ecore.resource.impl.ResourceSetImpl#delegatedGetResource(URI, boolean)
- */
- protected Resource delegatedGetResource(URI uri, boolean loadOnDemand) {
- Resource res = super.delegatedGetResource(uri, loadOnDemand);
- if (res == null)
- res = getResourceFromHandlers(uri);
- return res;
- }
- public Resource createResource(URI uri) {
- if (isReleasing) return null;
- //Check the map first when creating the resource and do not
- //normalize if a value is found.
- boolean isMapped = !(((URIConverterImpl.URIMap)getURIConverter().getURIMap()).getURI(uri).equals(uri));
- URI converted = uri;
- if (!isMapped)
- converted = getURIConverter().normalize(uri);
- Resource result = createResourceFromHandlers(converted);
- if (result == null)
- result = super.createResource(converted);
-
- return result;
- }
- /**
- * @see org.eclipse.emf.ecore.resource.impl.ResourceSetImpl#demandLoad(Resource)
- */
- protected void demandLoad(Resource resource) throws IOException {
- if (!isReleasing)
- super.demandLoad(resource);
- }
-
- /**
- * See if any resource handlers from the WorkbenchContext
- * decide to create the Resource in another manner.
- */
- protected Resource createResourceFromHandlers(URI uri) {
- Resource resource = null;
- ResourceHandler handler = null;
- for (int i = 0; i < resourceHandlers.size(); i++) {
- handler = (ResourceHandler) resourceHandlers.get(i);
- resource = handler.createResource(this, uri);
- if (resource != null)
- return resource;
- }
- return null;
- }
- /**
- * See if any resource handlers from the WorkbenchContext
- * can return a Resource from a <code>uri</code>.
- */
- protected Resource getResourceFromHandlers(URI uri) {
- if (isReleasing) return null;
- for (int i = 0; i < resourceHandlers.size(); i++) {
- Resource resource = ((ResourceHandler) resourceHandlers.get(i)).getResource(this, uri);
- if (resource != null)
- return resource;
- }
- return null;
- }
-
- public void release() {
- // Send out notification of release.
- if (eNotificationRequired()) {
- eNotify(new NotificationImpl(SPECIAL_NOTIFICATION_TYPE, null, null, Notification.NO_INDEX, false) {
- /* (non-Javadoc)
- * @see org.eclipse.emf.common.notify.impl.NotificationImpl#getFeatureID(java.lang.Class)
- */
- public int getFeatureID(Class expectedClass) {
- return PROJECTRESOURCESET_ABOUT_TO_RELEASE_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.emf.common.notify.impl.NotificationImpl#getNotifier()
- */
- public Object getNotifier() {
- return ProjectResourceSetImpl.this;
- }
- });
- }
- setIsReleasing(true);
- if (synchronizer != null)
- synchronizer.dispose();
- synchronizer = null;
- removeAndUnloadAllResources();
- resourceHandlers = null;
- eAdapters().clear();
- setProject(null);
- JEMUtilPlugin.getSharedCache().stopListening(this);
- }
- protected void removeAndUnloadAllResources() {
- boolean caughtException = false;
- if (getResources().isEmpty()) return;
- List list = new ArrayList(getResources());
- getResources().clear();
- Resource res;
- int size = list.size();
- for (int i = 0; i < size; i++) {
- res = (Resource) list.get(i);
- try {
- res.unload();
- } catch (RuntimeException ex) {
- Logger.getLogger().logError(ex);
- caughtException = true;
- }
- }
- if (caughtException)
- throw new RuntimeException("Exception(s) unloading resources - check log files"); //$NON-NLS-1$
- }
- protected void setIsReleasing(boolean aBoolean) {
- isReleasing = aBoolean;
- }
- /**
- * Gets the project.
- * @return Returns a IProject
- */
- public IProject getProject() {
- return project;
- }
- /**
- * Sets the project.
- * @param project The project to set
- */
- protected void setProject(IProject project) {
- this.project = project;
- }
- /*
- * Javadoc copied from interface.
- */
- public EObject getEObject(URI uri, boolean loadOnDemand) {
- if (isReleasing) return null;
- Resource resource = getResource(uri.trimFragment(), loadOnDemand);
- EObject result = null;
- if (resource != null && resource.isLoaded())
- result = resource.getEObject(uri.fragment());
- if (result == null)
- result = getEObjectFromHandlers(uri, loadOnDemand);
- return result;
- }
- /**
- * See if any resource handlers from the WorkbenchContext
- * can return a EObject from a <code>uri</code> after
- * failing to find it using the normal mechanisms.
- */
- protected EObject getEObjectFromHandlers(URI uri, boolean loadOnDemand) {
- EObject obj = null;
- ResourceHandler handler = null;
- for (int i = 0; i < resourceHandlers.size(); i++) {
- handler = (ResourceHandler) resourceHandlers.get(i);
- obj = handler.getEObjectFailed(this, uri, loadOnDemand);
- if (obj != null)
- return obj;
- }
- return null;
- }
-
- public boolean add(ResourceHandler resourceHandler) {
- return resourceHandlers.add(resourceHandler);
- }
- public void addFirst(ResourceHandler resourceHandler) {
- resourceHandlers.add(0, resourceHandler);
- }
- public boolean remove(ResourceHandler resourceHandler) {
- return resourceHandlers.remove(resourceHandler);
- }
- /**
- * Returns the synchronizer.
- * @return ResourceSetWorkbenchSynchronizer
- */
- public ResourceSetWorkbenchSynchronizer getSynchronizer() {
- return synchronizer;
- }
- /**
- * Sets the synchronizer.
- * @param synchronizer The synchronizer to set
- */
- public void setSynchronizer(ResourceSetWorkbenchSynchronizer synchronizer) {
- this.synchronizer = synchronizer;
- }
- /**
- * @see org.eclipse.emf.ecore.resource.ResourceSet#setResourceFactoryRegistry(Registry)
- */
- public void setResourceFactoryRegistry(Resource.Factory.Registry factoryReg) {
- if (resourceFactoryRegistry != null && factoryReg != null) {
- preserveEntries(factoryReg.getExtensionToFactoryMap(), resourceFactoryRegistry.getExtensionToFactoryMap());
- preserveEntries(factoryReg.getProtocolToFactoryMap(), resourceFactoryRegistry.getProtocolToFactoryMap());
- }
- super.setResourceFactoryRegistry(factoryReg);
- }
- /*
- * Preserve the entries from map2 in map1 if no collision.
- */
- protected void preserveEntries(Map map1, Map map2) {
- if (map2.isEmpty())
- return;
- Iterator it = map2.entrySet().iterator();
- Map.Entry entry;
- while (it.hasNext()) {
- entry = (Map.Entry) it.next();
- if (!map1.containsKey(entry.getKey()))
- map1.put(entry.getKey(), entry.getValue());
- }
- }
- /*
- * Javadoc copied from interface.
- */
- public Resource getResource(URI uri, boolean loadOnDemand) {
- if (isReleasing) return null;
- return super.getResource(uri, loadOnDemand);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.util.emf.workbench.ProjectResourceSet#resetNormalizedURICache()
- */
- public void resetNormalizedURICache() {
- if (getURIResourceMap() != null)
- getURIResourceMap().clear();
- }
-
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/WorkspaceResourceHandler.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/WorkspaceResourceHandler.java
deleted file mode 100644
index 9234123..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/WorkspaceResourceHandler.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: WorkspaceResourceHandler.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.internal.util.emf.workbench;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.URIConverterImpl;
-
-import org.eclipse.jem.util.emf.workbench.ResourceHandler;
-import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-/**
- * The main purpose of this class is to redirect, if necessary, to another
- * ResourceSet. This class should be used in conjunction with the WorkbenchURIConverter
- * so that the URIs passed will use the platform protocol. Anything else will be considered
- * to be ambiguous and we will not be able to redirect.
- */
-public class WorkspaceResourceHandler implements ResourceHandler {
- /**
- * Constructor for WorkspaceResourceHandler.
- */
- public WorkspaceResourceHandler() {
- super();
- }
- /*
- * @see IResourceHandler#getResource(ResourceSet, URI)
- */
- public Resource getResource(ResourceSet originatingResourceSet, URI uri) {
- if (WorkbenchResourceHelperBase.isPlatformResourceURI(uri))
- return getResourceForPlatformProtocol(originatingResourceSet, uri);
- URI mappedURI = ((URIConverterImpl.URIMap)originatingResourceSet.getURIConverter().getURIMap()).getURI(uri);
- if (isGlobalPluginLoad(mappedURI))
- return getResourceForPlatformPluginProtocol(originatingResourceSet, uri);
- return null;
- }
- /**
- * Redirect to the correct project based on the project name in the <code>uri</code>.
- * The <code>uri</code> will be in the following format: platform:/resource/[project name].
- */
- protected Resource createResourceForPlatformProtocol(ResourceSet originatingResourceSet, URI uri) {
- String projectName = uri.segment(1);
- IProject project = getProject(projectName);
- if (project != null && project.isAccessible()) {
- ResourceSet set = WorkbenchResourceHelperBase.getResourceSet(project);
- if (originatingResourceSet != set)
- return createResource(uri, set);
- }
- return null;
- }
- /**
- * Redirect to the correct project based on the project name in the <code>uri</code>.
- * The <code>uri</code> will be in the following format: platform:/resource/[project name].
- */
- protected Resource createResourceForPlatformPluginProtocol(ResourceSet originatingResourceSet, URI uri) {
-
- ResourceSet set = JEMUtilPlugin.getPluginResourceSet();
- return createResource(uri, set);
- }
- protected Resource createResource(URI uri, ResourceSet redirectedResourceSet) {
- return redirectedResourceSet.createResource(uri);
- }
- /**
- * Redirect to the correct project based on the first segment in the file name.
- * This is for compatability purposes for people using the platform:/resource protocol.
- */
- protected Resource getResourceForPlatformProtocol(ResourceSet originatingResourceSet, URI uri) {
- String projectName = uri.segment(1);
- IProject project = getProject(projectName);
- if (project != null && project.isAccessible()) {
- ResourceSet set = WorkbenchResourceHelperBase.getResourceSet(project);
- if (originatingResourceSet != set)
- return getResource(uri, set);
- }
- return null;
- }
- /**
- * Redirect to the correct project based on the first segment in the file name.
- * This is for compatability purposes for people using the platform:/resource protocol.
- */
- protected Resource getResourceForPlatformPluginProtocol(ResourceSet originatingResourceSet, URI uri) {
-
- ResourceSet set = JEMUtilPlugin.getPluginResourceSet();
- return getResource(uri, set);
-
- }
- protected Resource getResource(URI uri, ResourceSet redirectedResourceSet) {
- return redirectedResourceSet.getResource(uri, false);
- }
-
- protected IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
- protected IProject getProject(String projectName) {
- IWorkspace ws = getWorkspace();
- if (ws == null)
- return null;
- return ws.getRoot().getProject(projectName);
- }
- protected IProject getProject(ResourceSet resourceSet) {
- return WorkbenchResourceHelperBase.getProject(resourceSet);
- }
- /**
- * @see org.eclipse.jem.util.ResourceHandler#createResource(ResourceSet, URI)
- */
- public Resource createResource(ResourceSet originatingResourceSet, URI uri) {
- if (WorkbenchResourceHelperBase.isPlatformResourceURI(uri))
- return createResourceForPlatformProtocol(originatingResourceSet, uri);
- URI mappedURI = ((URIConverterImpl.URIMap)originatingResourceSet.getURIConverter().getURIMap()).getURI(uri);
- if (isGlobalPluginLoad(mappedURI))
- return createResourceForPlatformPluginProtocol(originatingResourceSet, uri);
- return null;
- }
- /**
- * @see org.eclipse.jem.util.ResourceHandler#getEObjectFailed(ResourceSet, URI, boolean)
- * Subclasses may override.
- */
- public EObject getEObjectFailed(ResourceSet originatingResourceSet, URI uri, boolean loadOnDemand) {
- return null;
- }
-
- protected boolean isGlobalPluginLoad(URI aURI) {
- if (WorkbenchResourceHelperBase.isPlatformPluginResourceURI(aURI)) {
- String[] globalPlugins = JEMUtilPlugin.getGlobalLoadingPluginNames();
- for (int i=0;i<globalPlugins.length;i++) {
- if (aURI.segment(1).startsWith(globalPlugins[i]))
- return true;
- }
- }
- return false;
- }
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/WorkspaceResourceNotifier.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/WorkspaceResourceNotifier.java
deleted file mode 100644
index 6c10afe..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/WorkspaceResourceNotifier.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: WorkspaceResourceNotifier.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.internal.util.emf.workbench;
-
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.notify.impl.NotifierImpl;
-
-import org.eclipse.jem.util.emf.workbench.ProjectResourceSet;
-
-/**
- * This class is used to capture all ADD and REMOVE notifications from each ProjectResourceSet
- * and forward it on to any interrested listeners. This is to allow you to listen to one object
- * to gain all ADD and REMOVE notifications for each ResourceSet within the system.
- */
-public class WorkspaceResourceNotifier extends NotifierImpl {
- protected Adapter projectAdapter = new WorkspaceResourceCacheAdapter();
-
- class WorkspaceResourceCacheAdapter extends AdapterImpl {
- /**
- * Forward ADD and REMOVE notification.
- */
- public void notifyChanged(Notification msg) {
- switch (msg.getEventType()) {
- case Notification.ADD :
- case Notification.ADD_MANY :
- case Notification.REMOVE :
- case Notification.REMOVE_MANY :
- eNotify(msg);
- break;
- }
- }
- }
-
- /**
- * Constructor for WorkspaceResourceCache.
- */
- public WorkspaceResourceNotifier() {
- super();
- }
-
- /**
- * Begin listening to a ProjectResourceSet.
- */
- public void beginListening(ProjectResourceSet aResourceSet) {
- if (aResourceSet != null) {
- if (aResourceSet.eAdapters() == null ||
- !aResourceSet.eAdapters().contains(projectAdapter))
- aResourceSet.eAdapters().add(projectAdapter);
- }
- }
- /**
- * Stop listening to a ProjectResourceSet.
- */
- public void stopListening(ProjectResourceSet aResourceSet) {
- if (aResourceSet != null)
- aResourceSet.eAdapters().remove(projectAdapter);
- }
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/nature/EMFNatureRegistry.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/nature/EMFNatureRegistry.java
deleted file mode 100644
index f85f7b0..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/nature/EMFNatureRegistry.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: EMFNatureRegistry.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.internal.util.emf.workbench.nature;
-
-import java.util.HashSet;
-import java.util.Set;
-
-
-import org.eclipse.core.runtime.*;
-
-import org.eclipse.jem.internal.util.emf.workbench.nls.EMFWorkbenchResourceHandler;
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-public class EMFNatureRegistry {
-
- private static final String NATURE_REGISTRATION_POINT = "org.eclipse.jem.util.nature_registration"; //$NON-NLS-1$
- private static final String NATURE = "nature"; //$NON-NLS-1$
- private static final String STATIC_ID = "id"; //$NON-NLS-1$
-
- /**
- * Constructor
- */
- private EMFNatureRegistry() {
- super();
- readRegistry();
- }
-
- private static EMFNatureRegistry singleton;
-
- public final Set REGISTERED_NATURE_IDS = new HashSet();
-
- public static EMFNatureRegistry singleton() {
- if (singleton == null)
- singleton = new EMFNatureRegistry();
- return singleton;
- }
-
- protected void readRegistry() {
- // register Nature IDs for the J2EENatures
- IExtensionRegistry r = Platform.getExtensionRegistry();
- IConfigurationElement[] ce = r.getConfigurationElementsFor(NATURE_REGISTRATION_POINT);
- String natureId;
- for (int i=0; i<ce.length; i++) {
- if (ce[i].getName().equals(NATURE)) {
- natureId = ce[i].getAttribute(STATIC_ID);
- if (natureId != null)
- registerNatureID(natureId);
- }
- }
- }
-
- /**
- * @param natureId
- */
- private void registerNatureID(String natureId) {
- if (!REGISTERED_NATURE_IDS.contains(natureId))
- REGISTERED_NATURE_IDS.add(natureId);
- else
- Logger.getLogger().logError(EMFWorkbenchResourceHandler.getString("EMFNatureRegistry_ERROR_0", new Object[] {natureId})); //$NON-NLS-1$
- }
-
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/nls/EMFWorkbenchResourceHandler.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/nls/EMFWorkbenchResourceHandler.java
deleted file mode 100644
index 31a8e45..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/nls/EMFWorkbenchResourceHandler.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: EMFWorkbenchResourceHandler.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.internal.util.emf.workbench.nls;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class EMFWorkbenchResourceHandler {
-
- private static ResourceBundle fgResourceBundle;
-
- /**
- * Returns the resource bundle used by all classes in this Project
- */
- public static ResourceBundle getResourceBundle() {
- try {
- return ResourceBundle.getBundle("emfworkbench");//$NON-NLS-1$
- } catch (MissingResourceException e) {
- // does nothing - this method will return null and
- // getString(String, String) will return the key
- // it was called with
- }
- return null;
- }
- public static String getString(String key) {
- if (fgResourceBundle == null) {
- fgResourceBundle= getResourceBundle();
- }
-
- if (fgResourceBundle != null) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$
- }
- } else {
- return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$
- }
- }
-public static String getString(String key, Object[] args) {
-
- try {return MessageFormat.format(getString(key), args);}
- catch (IllegalArgumentException e) {return getString(key);}
-
-}
-public static String getString(String key, Object[] args, int x) {
-
- return getString(key);
- }
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/NotPresentPerformanceMonitor.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/NotPresentPerformanceMonitor.java
deleted file mode 100644
index 54af2bd..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/NotPresentPerformanceMonitor.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.eclipse.jem.util;
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: NotPresentPerformanceMonitor.java,v $$
- * $$Revision: 1.3 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-/**
- * This is the instantiation to use if the performance monitor plugin is not installed. It basically does nothing.
- *
- * <p>
- * This class is not intended to be instantiated by clients.
- * </p>
- *
- * @since 1.0.0
- */
-public class NotPresentPerformanceMonitor extends PerformanceMonitorUtil {
-
- /*
- * Only instantiated from this package.
- */
- NotPresentPerformanceMonitor() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#setVar(java.lang.String)
- */
- public void setVar(String var) {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#doSnapshot(int, int)
- */
- protected void doSnapshot(int step, int types) {
- }
-
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#doSnapshot(int)
- */
- protected void doSnapshot(int step) {
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/PerformanceMonitorUtil.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/PerformanceMonitorUtil.java
deleted file mode 100644
index c24fcee..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/PerformanceMonitorUtil.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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
- *******************************************************************************/
-/*
- * $RCSfile: PerformanceMonitorUtil.java,v $
- * $Revision: 1.4 $ $Date: 2005/02/15 23:04:14 $
- */
-package org.eclipse.jem.util;
-import java.util.EventObject;
-
-import org.eclipse.perfmsr.core.IPerformanceMonitor;
-
-/**
- * This is a simplified wrapper to the IPerformanceMonitor that hides it so that the actual plugin can be optional and not required.
- *
- * <p>
- * This class is not meant to be subclassed by clients.
- * </p>
- *
- * @since 1.0.0
- */
-public abstract class PerformanceMonitorUtil {
- /**
- * Event for PerformanceListener notification.
- *
- * @since 1.1.0
- */
- public static class PerformanceEvent extends EventObject {
-
- PerformanceEvent(Object source, int step) {
- super(source);
- snapshowWithTypes = false;
- this.step = step;
- this.types = 0; // Not set.
- }
-
- PerformanceEvent(Object source, int step, int types) {
- super(source);
- snapshowWithTypes = true;
- this.step = step;
- this.types = types;
- }
-
-
- /**
- * Snapshot with types if <code>true</code>.
- * @since 1.1.0
- */
- public final boolean snapshowWithTypes;
-
- /**
- * Step of snapshot
- * @since 1.1.0
- */
- public final int step;
-
- /**
- * types of snapshot.
- * @since 1.1.0
- */
- public final int types;
- }
-
- /**
- * Performance Listener interface
- *
- * @since 1.1.0
- */
- public interface PerformanceListener {
- /**
- * Snapshot was called.
- * @param event
- *
- * @since 1.1.0
- */
- public void snapshot(PerformanceEvent event);
- }
-
- private PerformanceListener[] listeners;
-
- public interface Types {
-
- /**
- * 1 - Write out the performance counters from the operating system. These include working set, peak working set, elapsed time, user time, and
- * kernel time.
- */
- int OperatingSystemCounters = IPerformanceMonitor.Types.OperatingSystemCounters;
-
- /**
- * 2 - Write out the global performance info. This includes things like the total committed memory for the entire system.
- *
- * This function depends on the GetPerformanceInfo() function being available in the Windows psapi.dll. This is available in XP but is usually
- * not available in Win/2000. If it is not available then this function throws an UnsupportedOperationException.
- */
- int GlobalSystemCounters = IPerformanceMonitor.Types.GlobalSystemCounters;
-
- /**
- * 4 - Write out the size of the Java Heap.
- */
- int JavaHeapSize = IPerformanceMonitor.Types.JavaHeapSize;
-
- /**
- * 8 - Write out how much of the Java heap is being used. This calls the garbage collector so it may skew timing results.
- */
- int JavaHeapUsed = IPerformanceMonitor.Types.JavaHeapUsed;
-
- /**
- * 16 - The plugin startup and size information.
- */
- int PluginInfo = IPerformanceMonitor.Types.PluginInfo;
-
- /** 0xffff - Everything. */
- int All = IPerformanceMonitor.Types.All;
- }
-
- private static PerformanceMonitorUtil sharedMonitor;
-
- public static PerformanceMonitorUtil getMonitor() {
- if (sharedMonitor == null) {
- try {
- Class.forName("org.eclipse.perfmsr.core.PerfMsrCorePlugin"); // This just tests if the performance plugin is available. Throws
- // exception otherwise.
- Class presentClass = Class.forName("org.eclipse.jem.util.PresentPerformanceMonitor"); // Get the class we use wrapper it.
- sharedMonitor = (PerformanceMonitorUtil) presentClass.newInstance();
- if (!sharedMonitor.isValid())
- sharedMonitor = null;
- } catch (RuntimeException e) {
- // If any runtime exception, just use the not present one.
- } catch (ClassNotFoundException e) {
- // If class not found, then plugin not available, so just use the not present one.
- } catch (InstantiationException e) {
- // Problem instantiating, so just use the not present one.
- } catch (IllegalAccessException e) {
- // Some illegal access, so just use the not present one.
- }
- if (sharedMonitor == null) {
- // Couldn't get the performance one for some reason. Use not present one instead.
- sharedMonitor = new NotPresentPerformanceMonitor();
- }
- }
- return sharedMonitor;
- }
-
- protected boolean isValid() {
- return true;
- }
-
- /**
- * Set the variations that are in effect.
- *
- * @param var
- * a comma delimited string of variation numbers
- */
- public abstract void setVar(String var);
-
- /**
- * Take a snapshot of some default performance measurements.
- *
- * @param step
- * this identifies the step that the snapshot is for
- */
- public final void snapshot(int step) {
- doSnapshot(step);
- if (listeners != null)
- notifySnapshot(new PerformanceEvent(this, step));
- }
-
- private void notifySnapshot(PerformanceEvent event) {
- PerformanceListener[] list = listeners;
- for (int i = 0; i < list.length; i++) {
- list[i].snapshot(event);
- }
- }
-
- /**
- * Do the actual snapshot
- * @param step
- *
- * @see #snapshot(int)
- * @since 1.1.0
- */
- protected abstract void doSnapshot(int step);
-
- /**
- * Take a snapshot of the selected performance measurements.
- *
- * @param step
- * this identifies the step that the snapshot is for
- *
- * @param types
- * This controls which measurements are selected. It is an or'd together list of the IPerformanceMonitor.Types constants.
- *
- * @see IPerformanceMonitor.Types
- */
- public void snapshot(int step, int types) {
- doSnapshot(step, types);
- if (listeners != null)
- notifySnapshot(new PerformanceEvent(this, step, types));
- }
-
- /**
- * Do the actual snapshot
- * @param step
- *
- * @see #snapshot(int, int)
- * @since 1.1.0
- */
- protected abstract void doSnapshot(int step, int types);
-
- /**
- * Add listener to list.
- * @param listener
- *
- * @since 1.1.0
- */
- public void addPerformanceListener(PerformanceListener listener) {
- if (findListener(listener) != -1)
- return;
- PerformanceListener[] newList = new PerformanceListener[listeners != null ? listeners.length+1 : 1];
- if (listeners != null)
- System.arraycopy(listeners, 0, newList, 0, listeners.length);
- newList[newList.length-1] = listener;
- listeners = newList;
- }
-
- private int findListener(PerformanceListener listener) {
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- if (listeners[i] == listener)
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Remove the listener from the list.
- * @param listener
- *
- * @since 1.1.0
- */
- public void removePerformanceListener(PerformanceListener listener) {
- int index = findListener(listener);
- if (index != -1) {
- if (listeners.length == 1) {
- listeners = null;
- return;
- }
- PerformanceListener[] newList = new PerformanceListener[listeners.length-1];
- System.arraycopy(listeners, 0, newList, 0, index);
- System.arraycopy(listeners, index+1, newList, index, newList.length-index);
- listeners = newList;
- }
- }
- /**
- * Upload the results to the server. This causes the file to be
- * closed, and the monitor to be placed into the finished state.
- *
- * This method can only be called if the uploadhost, uploadport and uploaduserid
- * have been configured before hand.
- *
- * @param description an optional description (it can be null)
- *
- */
- public boolean upload(String description){return false;}
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/PresentPerformanceMonitor.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/PresentPerformanceMonitor.java
deleted file mode 100644
index 4f48978..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/PresentPerformanceMonitor.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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
- *******************************************************************************/
-/*
- * $RCSfile: PresentPerformanceMonitor.java,v $
- * $Revision: 1.4 $ $Date: 2005/02/15 23:04:14 $
- */
-package org.eclipse.jem.util;
-import org.eclipse.perfmsr.core.IPerformanceMonitor;
-import org.eclipse.perfmsr.core.PerfMsrCorePlugin;
-
-/**
- * This is the version used when the performance plugin is available.
- *
- * <p>
- * This class is not meant to be instantiated by clients.
- * </p>
- *
- * @since 1.0.0
- */
-public class PresentPerformanceMonitor extends PerformanceMonitorUtil {
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#upload(java.lang.String)
- */
- public boolean upload(String description) {
- return monitor.upload(description).success;
- }
-
- private IPerformanceMonitor monitor;
-
- /*
- * So that only instantiated by this package.
- */
- PresentPerformanceMonitor() {
- monitor = PerfMsrCorePlugin.getPerformanceMonitor(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#isValid()
- */
- protected boolean isValid() {
- return monitor != null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#setVar(java.lang.String)
- */
- public void setVar(String var) {
- monitor.setVar(var);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#doSnapshot(int)
- */
- protected void doSnapshot(int step) {
- monitor.snapshot(step);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#doSnapshot(int, int)
- */
- protected void doSnapshot(int step, int types) {
- monitor.snapshot(step, types);
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/RegistryReader.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/RegistryReader.java
deleted file mode 100644
index 3f3cfbe..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/RegistryReader.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: RegistryReader.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util;
-import org.eclipse.core.runtime.*;
-import org.osgi.framework.Bundle;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-
-/**
- * Class to read a registry. It is meant to be subclassed to provide specific function.
- *
- * @since 1.0.0
- */
-public abstract class RegistryReader {
-
- String pluginId;
-
- String extensionPointId;
-
- private static Bundle systemBundle;
-
- /**
- * Utility method to get the plugin id of a configuation element
- *
- * @param configurationElement
- * @return plugin id of configuration element
- * @since 1.0.0
- */
- public static String getPluginId(IConfigurationElement configurationElement) {
- String pluginId = null;
-
- if (configurationElement != null) {
- IExtension extension = configurationElement.getDeclaringExtension();
-
- if (extension != null)
- pluginId = extension.getNamespace();
- }
-
- return pluginId;
- }
-
- /**
- * Constructor for RegistryReader taking a registry, plugin id, and extension point id.
- *
- * @param registry
- * @param pluginID
- * @param extensionPoint
- *
- * @deprecated Use RegistryReader(plugin, extensionPoint) instead. The registry passed in is ignored.
- * @since 1.0.0
- */
- public RegistryReader(IPluginRegistry registry, String pluginID, String extensionPoint) {
- this(pluginID, extensionPoint);
- }
-
- /**
- * Constructor for RegistryReader taking the plugin id and extension point id.
- *
- * @param pluginID
- * @param extensionPoint
- *
- * @since 1.0.0
- */
- public RegistryReader(String pluginID, String extensionPoint) {
- super();
- this.pluginId = pluginID;
- extensionPointId = extensionPoint;
- }
-
- private void internalReadElement(IConfigurationElement element) {
- boolean recognized = this.readElement(element);
- if (!recognized) {
- logError(element, "Error processing extension: " + element); //$NON-NLS-1$
- }
- }
-
- /*
- * Logs the error in the desktop log using the provided text and the information in the configuration element.
- */
- protected void logError(IConfigurationElement element, String text) {
- IExtension extension = element.getDeclaringExtension();
- StringBuffer buf = new StringBuffer();
- buf.append("Plugin " + extension.getNamespace() + ", extension " + extension.getExtensionPointUniqueIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append("\n" + text); //$NON-NLS-1$
- Logger.getLogger().logError(buf.toString());
- }
-
- /*
- * Logs a very common registry error when a required attribute is missing.
- */
- protected void logMissingAttribute(IConfigurationElement element, String attributeName) {
- logError(element, "Required attribute '" + attributeName + "' not defined"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /*
- * Implement this method to read element attributes. If this element has subelements, the reader will recursively cycle through them and call this
- * method so don't do it here.
- */
- public abstract boolean readElement(IConfigurationElement element);
-
- /**
- * Read the extension point and parse it.
- *
- * @since 1.0.0
- */
- public void readRegistry() {
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(pluginId, extensionPointId);
- if (point == null)
- return;
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- internalReadElement(elements[i]);
- }
- }
-
- /**
- * Tests to see if it is valid at this point in time to create an executable extension. A valid reason not to would be that the workspace is
- * shutting donw.
- *
- * @param element
- * @return <code>true</code> if it is valid point to create an executable extension.
- *
- * @since 1.0.0
- */
- public static boolean canCreateExecutableExtension(IConfigurationElement element) {
- if (Platform.isRunning() && getSystemBundle().getState() != Bundle.STOPPING)
- return true;
- return false;
- }
-
- /**
- * Get the system bundle
- *
- * @return system bundle.
- *
- * @since 1.0.0
- */
- protected static Bundle getSystemBundle() {
- if (systemBundle == null)
- systemBundle = Platform.getBundle("org.eclipse.osgi");
- return systemBundle;
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/TimerTests.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/TimerTests.java
deleted file mode 100644
index 453c5cf..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/TimerTests.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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
- *******************************************************************************/
-/*
- * $RCSfile: TimerTests.java,v $
- * $Revision: 1.3 $ $Date: 2005/02/15 23:04:14 $
- */
-package org.eclipse.jem.util;
-
-import java.text.NumberFormat;
-import java.util.*;
-
-/**
- *
- * @since 1.0.2
- */
-public class TimerTests {
-
- /**
- * Default TimerTests class to use when not using your own. It's a global.
- */
- public static TimerTests basicTest = new TimerTests();
-
- public static final String CURRENT_PARENT_ID = "current parent";
- protected String currentParentId = null;
-
-
- protected static class TimerStep {
- static final int START = 0;
- static final int STOP = 1;
- static final int START_CUMULATIVE = 2;
- static final int STOP_CUMULATIVE = 3;
- static final int START_ACCUMULATING = 4;
- static final int STOP_ACCUMULATING = 5;
- protected String id;
- protected int type;
- protected long currentTime;
- protected int threadId;
-}
-
- protected boolean testOn = false;
- protected List steps;
-
- public synchronized boolean startStep(String id) {
- if (!testOn)
- return true;
-
- TimerStep step = createTimerStep(id, TimerStep.START);
- return step != null;
- }
-
- protected TimerStep createTimerStep(String id, int stepType) {
- TimerStep newStep = new TimerStep();
- newStep.threadId = Thread.currentThread().hashCode();
- newStep.id = id;
- newStep.type = stepType;
- newStep.currentTime = System.currentTimeMillis();
- steps.add(newStep);
-
- return newStep;
- }
-
- public synchronized boolean stopStep(String id) {
- if (!testOn)
- return true;
- TimerStep step = createTimerStep(id, TimerStep.STOP);
- return step != null;
- }
-
- public synchronized boolean startAccumulating(String id) {
- if (!testOn)
- return true;
-
- return createTimerStep(id, TimerStep.START_ACCUMULATING) != null;
- }
-
- public synchronized boolean stopAccumulating(String id) {
- if (!testOn)
- return true;
-
- return createTimerStep(id, TimerStep.STOP_ACCUMULATING) != null;
- }
- public synchronized boolean startCumulativeStep(String id) {
- if (!testOn)
- return true;
-
- return createTimerStep(id, TimerStep.START_CUMULATIVE) != null;
- }
-
- public synchronized boolean stopCumulativeStep(String id) {
- if (!testOn)
- return true;
- return createTimerStep(id, TimerStep.STOP_CUMULATIVE) != null;
- }
-
- /**
- * Clear the tests so that you can restart and do some more tests.
- *
- *
- * @since 1.0.2
- */
- public synchronized void clearTests() {
- if (!testOn)
- return;
- steps.clear();
- currentParentId = null;
- }
-
- /**
- * Turn this test on. If not turned on then all calls will quickly return with no errors. This allows the code to stay in place even when not
- * debugging.
- * <p>
- * When turned off, it will clear the test.
- *
- * @param on
- *
- * @since 1.0.2
- */
- public synchronized void testState(boolean on) {
- if (on == testOn)
- return;
- if (on) {
- testOn = true;
- if (steps == null)
- steps = new ArrayList();
- } else {
- testOn = false;
- steps = null;
- }
- currentParentId = null;
- }
- private static class CumulativeInformation {
- public TimerStep currentCumulativeStep;
- public long cumTime;
- public int cumCount;
- public int cumCountNonZero;
- public long maxTime;
- public long minTime = Integer.MAX_VALUE;
- public long minTimeNonZero = Integer.MAX_VALUE;
- }
- public synchronized void printIt() {
- if (!testOn)
- return;
- if (steps == null)
- return;
- Map stepInfoByThreadId = new HashMap();
- Map indentsByThreadId = new HashMap();
- Map cumSteps;
- TimerStep prevStep = null;
- TimerStep startStep;
- NumberFormat percentFormatter = NumberFormat.getPercentInstance();
- double totalTime = 0;
- StringBuffer strb = new StringBuffer(150);
- if (steps.size() > 2){
- totalTime = ((TimerStep)steps.get(steps.size()-1)).currentTime - ((TimerStep)steps.get(0)).currentTime;
- }
- for (int i = 0; i < steps.size(); i++) {
- TimerStep step = (TimerStep) steps.get(i);
- Integer threadId = new Integer(step.threadId);
- switch (step.type) {
- case TimerStep.START:
- case TimerStep.STOP:
- Integer threadIndent = (Integer) indentsByThreadId.get(threadId);
- int indent = 0;
- if (step.type == TimerStep.START) {
- if (threadIndent != null)
- indent = threadIndent.intValue() + 1;
- indentsByThreadId.put(threadId, new Integer(indent));
- } else {
- if (threadIndent != null)
- indent = threadIndent.intValue();
- if (indent > 0)
- indentsByThreadId.put(threadId, new Integer(indent - 1));
- else {
- indentsByThreadId.remove(threadId);
- indent = 0;
- }
- }
- strb.setLength(0);
- strb.append(step.currentTime);
- strb.append("\t");
- for (int j = 0; j < indent; j++) {
- strb.append(" ");
- }
- switch (step.type) {
- case TimerStep.START:
- strb.append("Start");
- break;
-
- case TimerStep.STOP:
- strb.append("Stop ");
- break;
- default:
- break;
- }
- ;
- strb.append(" \"");
- strb.append(step.id);
- strb.append("\" id(");
- strb.append(step.threadId);
- strb.append(")");
- Map startSteps = (Map) stepInfoByThreadId.get(threadId);
- if (startSteps == null)
- stepInfoByThreadId.put(threadId, startSteps = new HashMap());
- if (step.type == TimerStep.START) {
- // Store the start step for later lookup when calulating the total time
- startSteps.put(step.id, step);
- } else {
- // This is the stop time for a step. We need to find
- // the corresponding start time and calculate the total time.
- Object item = startSteps.remove(step.id);
- if (item instanceof TimerStep) {
- startStep = (TimerStep) item;
- if (startStep != null) {
- int addchars = 100 - strb.length();
- for (int j = 0; j < addchars; j++) {
- strb.append(" ");
- }
- long delta = step.currentTime - startStep.currentTime;
- strb.append(" Total = " + delta + " ms");
- if (totalTime > 0)
- strb.append(" " + percentFormatter.format(delta/totalTime));
- }
- } else
- strb.append(" ---> Couldn't find Starting point for \"" + step.id + "\"");
- }
- if (i > 0 && (step.currentTime - prevStep.currentTime) > 0)
- System.out.println("-- " + (step.currentTime - prevStep.currentTime) + " ms --");
- prevStep = step;
- System.out.println(strb);
- break;
-
- case TimerStep.START_ACCUMULATING:
- cumSteps = (Map) stepInfoByThreadId.get(threadId);
- if (cumSteps == null)
- stepInfoByThreadId.put(threadId, cumSteps = new HashMap());
- cumSteps.put(step.id, new CumulativeInformation());
- threadIndent = (Integer) indentsByThreadId.get(threadId);
- indent = 0;
- if (threadIndent != null)
- indent = threadIndent.intValue();
- strb.setLength(0);
- strb.append(step.currentTime);
- strb.append("\t");
- for (int j = 0; j < indent; j++) {
- strb.append(" ");
- }
- strb.append("Start Accumulating");
- strb.append(" \"");
- strb.append(step.id);
- strb.append("\" id(");
- strb.append(step.threadId);
- strb.append(")");
- if (i > 0 && (step.currentTime - prevStep.currentTime) > 0)
- System.out.println("-- " + (step.currentTime - prevStep.currentTime) + " ms --");
- prevStep = step;
- System.out.println(strb);
- break;
-
- case TimerStep.START_CUMULATIVE:
- cumSteps = (Map) stepInfoByThreadId.get(threadId);
- if (cumSteps != null) {
- Object info = cumSteps.get(step.id);
- if (info instanceof CumulativeInformation)
- ((CumulativeInformation) info).currentCumulativeStep = step;
- }
- break;
-
- case TimerStep.STOP_CUMULATIVE:
- cumSteps = (Map) stepInfoByThreadId.get(threadId);
- if (cumSteps != null) {
- Object info = cumSteps.get(step.id);
- if (info instanceof CumulativeInformation) {
- CumulativeInformation cumInfo = (CumulativeInformation) info;
- if (cumInfo.currentCumulativeStep != null) {
- cumInfo.cumCount++;
- long delta = step.currentTime - cumInfo.currentCumulativeStep.currentTime;
- cumInfo.cumTime += delta;
- if (cumInfo.maxTime < delta)
- cumInfo.maxTime = delta;
- if (delta < cumInfo.minTime)
- cumInfo.minTime = delta;
- if (delta != 0) {
- cumInfo.cumCountNonZero++;
- if (delta < cumInfo.minTimeNonZero)
- cumInfo.minTimeNonZero = delta;
- }
- }
- }
- }
- break;
-
- case TimerStep.STOP_ACCUMULATING:
- threadIndent = (Integer) indentsByThreadId.get(threadId);
- indent = 0;
- if (threadIndent != null)
- indent = threadIndent.intValue();
- strb.setLength(0);
- strb.append(step.currentTime);
- strb.append("\t");
- for (int j = 0; j < indent; j++) {
- strb.append(" ");
- }
- strb.append("Stop Accumulating");
- strb.append(" \"");
- strb.append(step.id);
- strb.append("\" id(");
- strb.append(step.threadId);
- strb.append(")");
- cumSteps = (Map) stepInfoByThreadId.get(threadId);
- if (cumSteps != null) {
- Object info = cumSteps.get(step.id);
- if (info instanceof CumulativeInformation) {
- CumulativeInformation cumInfo = (CumulativeInformation) info;
- if (cumInfo.currentCumulativeStep != null) {
- strb.append(" cumulative time=");
- strb.append(cumInfo.cumTime);
- strb.append(" cumulative count=");
- strb.append(cumInfo.cumCount);
- strb.append(" max time=");
- strb.append(cumInfo.maxTime);
- strb.append(" min time=");
- strb.append(cumInfo.minTime);
- strb.append(" avg time=");
- strb.append(((double) cumInfo.cumTime)/cumInfo.cumCount);
- strb.append(" NonZero times: cumulative ~0 count=");
- strb.append(cumInfo.cumCountNonZero);
- if (cumInfo.cumCountNonZero != 0) {
- strb.append(" min ~0 time=");
- strb.append(cumInfo.minTimeNonZero);
- strb.append(" avg ~0 time=");
- strb.append(((double) cumInfo.cumTime) / cumInfo.cumCountNonZero);
- }
- }
- }
- }
- if (i > 0 && (step.currentTime - prevStep.currentTime) > 0)
- System.out.println("-- " + (step.currentTime - prevStep.currentTime) + " ms --");
- prevStep = step;
- System.out.println(strb);
- break;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/UIContextDetermination.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/UIContextDetermination.java
deleted file mode 100644
index 443df5a..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/UIContextDetermination.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: UIContextDetermination.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.*;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-/**
- * Static utility class for UIContext determination.
- *
- * @since 1.0.0
- */
-public class UIContextDetermination {
-
- private static final int UNKNOWN = 100;
-
- public static final String HEADLESS_CONTEXT_LITERAL = "Headless";
-
- public static final String UI_CONTEXT_LITERAL = "UI";
-
- public static final int HEADLESS_CONTEXT = 102;
-
- public static final int UI_CONTEXT = 100;
-
- private static Map cachedExtensions = null;
-
- private static int currentContext = UNKNOWN;
-
- private UIContextDetermination() {
- }
-
- /**
- * Returns an instance of a given class based on the UI or Headless context.
- *
- * @param key
- * @return new class instance for the given key.
- * @throws IllegalArgumentException
- * If the key is invalid (e.g. no extension is found for the key)
- */
- public static Object createInstance(String key) {
- Object result = null;
- if (cachedExtensions == null)
- initExtensions();
- IConfigurationElement contextSensitiveClass = (IConfigurationElement) cachedExtensions.get(key);
- try {
- if (contextSensitiveClass != null)
- result = contextSensitiveClass
- .createExecutableExtension(UIContextDeterminationRegistryReader.UI_CONTEXT_SENSTIVE_CLASS_CLASSNAME_ATTR);
- } catch (CoreException e) {
- Logger.getLogger().logError("Problem loading extension not found for key \"" + key + "\".");
- Logger.getLogger().logError(e);
- }
- if (result == null)
- Logger.getLogger().logError("Extension not found for key \"" + key + "\".");
- return result;
- }
-
- /**
- * Returns the current context -- determines the value if necessary.
- *
- * @return current context
- * @see #HEADLESS_CONTEXT
- * @see #UI_CONTEXT
- */
- public static int getCurrentContext() {
- if (currentContext == UNKNOWN) {
- currentContext = HEADLESS_CONTEXT;
- new UITesterRegistryReader().readRegistry();
- }
- return currentContext;
- }
-
- /*
- * Invokes the UIContextDeterminationRegistryReader to cache all of the extensions, if necessary.
- *
- */
- private static void initExtensions() {
- if (cachedExtensions == null) {
- cachedExtensions = new HashMap();
- new UIContextDeterminationRegistryReader().readRegistry();
- }
- }
-
- /*
- * Converts the input to one of UI_CONTEXT or HEADLESS_CONTEXT. Defaults to HEADLESS on invalid input
- *
- * @param literal @return
- */
- private static int convertLiteral(String literal) {
- return (UI_CONTEXT_LITERAL.equals(literal)) ? UI_CONTEXT : HEADLESS_CONTEXT;
- }
-
- /*
- * Reads the registration of UI Context-sensitive class extensions and initializes the cache of the UIContextDetermination object.
- *
- * @author mdelder
- */
- private static class UIContextDeterminationRegistryReader extends RegistryReader {
-
- public static final String UI_CONTEXT_SENSTIVE_CLASS_ELEMENT = "uiContextSensitiveClass";
-
- public static final String UI_CONTEXT_SENSTIVE_CLASS_KEY_ATTR = "key";
-
- public static final String UI_CONTEXT_SENSTIVE_CLASS_CLASSNAME_ATTR = "className";
-
- public static final String UI_CONTEXT_SENSTIVE_CLASS_CONTEXT_ATTR = "context";
-
- public UIContextDeterminationRegistryReader() {
- super(JEMUtilPlugin.PLUGIN_ID, JEMUtilPlugin.UI_CONTEXT_EXTENSION_POINT);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement)
- */
- public boolean readElement(IConfigurationElement element) {
- boolean result = false;
- if (element.getName().equals(UI_CONTEXT_SENSTIVE_CLASS_ELEMENT)) {
-
- String key = element.getAttribute(UI_CONTEXT_SENSTIVE_CLASS_KEY_ATTR);
- String context = element.getAttribute(UI_CONTEXT_SENSTIVE_CLASS_CONTEXT_ATTR);
-
- if (!cachedExtensions.containsKey(key) || getCurrentContext() == convertLiteral(context))
- cachedExtensions.put(key, element);
- result = true;
- }
- return result;
- }
- }
-
- /*
- * Reads the uiTester extension and instantiate the any of the UITester classes it finds.
- *
- * The implementation has the side effect that if multiple UITesters are registered, any of them can trip the currentContext into the UI_CONTEXT
- * state.
- *
- * @author mdelder
- */
- private static class UITesterRegistryReader extends RegistryReader {
-
- public static final String UI_TESTER_ELEMENT = "uiTester"; //$NON-NLS-1$
-
- public static final String UI_TESTER_CLASSNAME_ATTR = "className"; //$NON-NLS-1$
-
- public UITesterRegistryReader() {
- super(JEMUtilPlugin.PLUGIN_ID, JEMUtilPlugin.UI_TESTER_EXTENSION_POINT);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf.workbench.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement)
- */
- public boolean readElement(IConfigurationElement element) {
- boolean result = false;
- if (element.getName().equals(UI_TESTER_ELEMENT)) {
- result = true;
- try {
- if (canCreateExecutableExtension(element)) {
- UITester tester = (UITester) element.createExecutableExtension(UI_TESTER_CLASSNAME_ATTR);
- if (tester.isCurrentContextUI())
- currentContext = UI_CONTEXT;
- }
- } catch (Throwable t) {
- Logger.getLogger().log("UIContextDetermination is proceeding in HEADLESS mode"); //$NON-NLS-1$
- }
- }
- return result;
- }
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/UITester.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/UITester.java
deleted file mode 100644
index 54517e8..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/UITester.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.eclipse.jem.util;
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: UITester.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-/**
- * Interface for a UITester. The "classname" attribute on the "uiTester" extension point should implement this class.
- *
- * @since 1.0.0
- */
-public interface UITester {
-
- /**
- * Answer if the current context is an UI context.
- *
- * @return <code>true</code> if an UI context.
- *
- * @since 1.0.0
- */
- public boolean isCurrentContextUI();
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/EMFWorkbenchContextBase.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/EMFWorkbenchContextBase.java
deleted file mode 100644
index bedff60..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/EMFWorkbenchContextBase.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: EMFWorkbenchContextBase.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-
-import org.eclipse.jem.internal.util.emf.workbench.*;
-import org.eclipse.jem.internal.util.emf.workbench.nls.EMFWorkbenchResourceHandler;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-/**
- * ContextBase for EMFWorkbench.
- *
- * <p>
- * This is meant to be subclassed as needed for additional or override function. It will be instantiated by default.
- * </p>
- *
- * @since 1.0.0
- */
-public class EMFWorkbenchContextBase {
-
- protected IProject project;
-
- protected ProjectResourceSet resourceSet;
-
- /**
- * Construct with a project.
- *
- * @param aProject
- *
- * @since 1.0.0
- */
- public EMFWorkbenchContextBase(IProject aProject) {
- if (aProject == null)
- throw new IllegalArgumentException(EMFWorkbenchResourceHandler.getString("EMFWorkbenchContextBase_ERROR_1")); //$NON-NLS-1$
- project = aProject;
- }
-
- /**
- * Dispose of the context base.
- *
- *
- * @since 1.0.0
- */
- public void dispose() {
- if (resourceSet != null)
- resourceSet.release();
- resourceSet = null;
- project = null;
- }
-
- /**
- * Get the project this context is associated with.
- *
- * @return project
- *
- * @since 1.0.0
- */
- public IProject getProject() {
- return project;
- }
-
- /**
- * Return the resource set (creating if needed) for context.
- *
- * @return resource set
- *
- * @since 1.0.0
- */
- public ProjectResourceSet getResourceSet() {
- if (resourceSet == null) {
- resourceSet = createResourceSet();
- initializeResourceSet(resourceSet);
- }
- return resourceSet;
- }
-
- /**
- * Used for optimization; answer whether a resourceSet has been created
- *
- * @return <code>true</code> if a resource set has been created.
- *
- * @since 1.0.0
- */
- public boolean hasResourceSet() {
- return resourceSet != null;
- }
-
- /**
- * Initialize the resource set.
- *
- * @param aResourceSet
- *
- * @since 1.0.0
- */
- protected void initializeResourceSet(ProjectResourceSet aResourceSet) {
- createResourceSetSynchronizer(aResourceSet);
- aResourceSet.setURIConverter(createURIConverter(aResourceSet));
- aResourceSet.add(new WorkspaceResourceHandler());
- JEMUtilPlugin.getDefault().addExtendedResourceHandlers(aResourceSet);
-
- }
-
- /**
- * Create the resource set. By default it is a ProjectResourceSetImpl.
- *
- * @return project's new resource set.
- *
- * @since 1.0.0
- */
- protected ProjectResourceSet createResourceSet() {
- if (project == null)
- throw new IllegalStateException(EMFWorkbenchResourceHandler.getString("EMFWorkbenchContextBase_ERROR_2")); //$NON-NLS-1$
- return new ProjectResourceSetImpl(project);
- }
-
- /**
- * Create a URIConverter for the resource set.
- *
- * @param aResourceSet
- * @return a uri converter.
- *
- * @since 1.0.0
- */
- protected WorkbenchURIConverter createURIConverter(ProjectResourceSet aResourceSet) {
- return new WorkbenchURIConverterImpl(getProject(), aResourceSet.getSynchronizer());
- }
-
- /**
- * Create a resource set workbench synchronizer.
- *
- * @param aResourceSet
- * @return a resource set workbench synchronizer.
- *
- * @since 1.0.0
- */
- protected ResourceSetWorkbenchSynchronizer createResourceSetSynchronizer(ProjectResourceSet aResourceSet) {
- return EMFWorkbenchContextFactory.INSTANCE.createSynchronizer(aResourceSet, getProject());
- }
-
- /**
- * Delete the resource from the workspace.
- *
- * @param aResource
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public void deleteResource(Resource aResource) throws CoreException {
- if (aResource != null)
- deleteFile(aResource);
- }
-
- /**
- * Delete the file associated with the resource.
- *
- * @param resource
- *
- * @since 1.0.0
- */
- public void deleteFile(Resource resource) {
- throw new UnsupportedOperationException(EMFWorkbenchResourceHandler.getString("EMFWorkbenchContextBase_ERROR_0")); //$NON-NLS-1$
- }
-
- /**
- * Get resource (with the given URI) from the project resource set. Load it if not already loaded.
- *
- * @param uri
- * @return resource for the uri, or <code>null</code> if not found.
- *
- * @since 1.0.0
- */
- public Resource getResource(URI uri) {
- return this.resourceSet.getResource(uri, true);
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/IEMFContextContributor.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/IEMFContextContributor.java
deleted file mode 100644
index 465d7fa..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/IEMFContextContributor.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: IEMFContextContributor.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-
-package org.eclipse.jem.util.emf.workbench;
-
-/**
- * EMF Context Contributor interface. Implimenters are called to contribute to the context.
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase#createEMFContext(IProject, IEMFContextContributor)
- * @since 1.0.0
- */
-public interface IEMFContextContributor {
-
- /**
- * This is your opportunity to add a primary EMFNature. Typically you would add to the WorkbenchContext held by <code>aNature</code> in order to
- * change the container for the WorkbenchURIConverter or add adapter factories to the ResourceSet or anything else that is needed.
- *
- * @param aNature
- *
- * @since 1.0.0
- */
- void primaryContributeToContext(EMFWorkbenchContextBase aNature);
-
- /**
- * This is your opportunity to add a secondary EMFNature. Typically you would add to the WorkbenchContext held by <code>aNature</code> in order
- * to change the container for the WorkbenchURIConverter or add adapter factories to the ResourceSet or anything else that is needed.
- *
- * @param aNature
- *
- * @since 1.0.0
- */
- void secondaryContributeToContext(EMFWorkbenchContextBase aNature);
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ISynchronizerExtender.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ISynchronizerExtender.java
deleted file mode 100644
index f70dd1e..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ISynchronizerExtender.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: ISynchronizerExtender.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import org.eclipse.core.resources.IResourceDelta;
-
-/**
- * Implimenters allows clients, eg {@link org.eclipse.jem.util.emf.workbench.EMFNatureContributor}, to extend the behavior of the
- * ResourceSetWorkbenchSynchronizer.
- *
- * @see org.eclipse.jem.util.emf.workbench.ResourceSetWorkbenchSynchronizer#addExtender(ISynchronizerExtender)
- * @since 1.0.0
- */
-public interface ISynchronizerExtender {
-
- /**
- * Notification that project has changed.
- *
- * @param delta
- *
- * @since 1.0.0
- */
- void projectChanged(IResourceDelta delta);
-
- /**
- * Notification that project has been closed.
- *
- *
- * @since 1.0.0
- */
- void projectClosed();
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/JavaProjectUtilities.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/JavaProjectUtilities.java
deleted file mode 100644
index 73771d5..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/JavaProjectUtilities.java
+++ /dev/null
@@ -1,688 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $RCSfile: JavaProjectUtilities.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:04:14 $
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import java.net.URL;
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.internal.core.JavaModel;
-import org.eclipse.jdt.internal.core.JavaModelManager;
-
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-/**
- * Project utilities that are Java (JDT) specific. This class should be
- * referenced only if the JDT is installed, otherwise you will get
- * class definition not found errors. This is because JDT is optional
- * for thie org.eclipse.jem.util bundle.
- * @since 1.1.0
- */
-public class JavaProjectUtilities extends ProjectUtilities {
-
- public JavaProjectUtilities() {
- super();
- }
-
- /**
- * Get the java project nature for the given project.
- *
- * @param p
- * project
- * @return the java project nature for the project or <code>null</code> if not a java project.
- *
- * @since 1.0.0
- */
- public static IJavaProject getJavaProject(IProject p) {
- try {
- return (IJavaProject) p.getNature(JavaCore.NATURE_ID);
- } catch (CoreException ignore) {
- return null;
- }
- }
-
- /**
- * Touch classpath. It simply takes the classpath and sets it back in.
- *
- * @param javaProject
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static void updateClasspath(IJavaProject javaProject) throws JavaModelException {
- if (javaProject != null)
- javaProject.setRawClasspath(javaProject.getRawClasspath(), new NullProgressMonitor());
- }
-
- /**
- * Return the location of the binary output files for the JavaProject.
- *
- * @param p
- * project
- * @return path to binary output folder or <code>null</code> if not java project or other problem.
- *
- * @since 1.0.0
- */
- public static IPath getJavaProjectOutputLocation(IProject p) {
- try {
- IJavaProject javaProj = getJavaProject(p);
- if (javaProj == null)
- return null;
- if (!javaProj.isOpen())
- javaProj.open(null);
- return javaProj.getOutputLocation();
- } catch (JavaModelException e) {
- return null;
- }
- }
-
- /**
- * Get the project's binary output container.
- *
- * @param p
- * project
- * @return project's output container or <code>null</code> if not java project or some other error.
- *
- * @since 1.0.0
- */
- public static IContainer getJavaProjectOutputContainer(IProject p) {
- IPath path = getJavaProjectOutputLocation(p);
- if (path == null)
- return null;
- if (path.segmentCount() == 1)
- return p;
- return p.getFolder(path.removeFirstSegments(1));
- }
-
- /**
- * Get the binary output absolute (local file system) path.
- *
- * @param p
- * project
- * @return project's output path or <code>null</code> if not java project or some other error.
- *
- * @since 1.0.0
- */
- public static IPath getJavaProjectOutputAbsoluteLocation(IProject p) {
- IContainer container = getJavaProjectOutputContainer(p);
- if (container != null)
- return container.getLocation();
- return null;
- }
-
- /**
- * Get the JDT JavaModel.
- *
- * @return JDT's JavaModel
- *
- * @since 1.0.0
- */
- public static JavaModel getJavaModel() {
- return JavaModelManager.getJavaModelManager().getJavaModel();
- }
-
- /**
- * Get all source package fragment roots.
- *
- * @param javaProj
- * @return source package fragment roots
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static List getSourcePackageFragmentRoots(IJavaProject javaProj) throws JavaModelException {
- List result = new ArrayList();
- IPackageFragmentRoot[] roots = javaProj.getPackageFragmentRoots();
- for (int i = 0; i < roots.length; i++) {
- IPackageFragmentRoot root = roots[i];
- if (root.getKind() == IPackageFragmentRoot.K_SOURCE)
- result.add(result);
- }
- return result;
- }
-
- /**
- * Remove the resource from the classpath
- *
- * @param p
- * project
- * @param res
- * resource
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static void removeFromJavaClassPath(IProject p, IResource res) throws JavaModelException {
- IClasspathEntry entry = JavaCore.newLibraryEntry(res.getFullPath(), null, null);
- removeFromJavaClassPath(p, entry);
- }
-
- /**
- * Remove the path from the classpath
- *
- * @param p
- * project
- * @param path
- * path to remove
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static void removeFromJavaClassPath(IProject p, IPath path) throws JavaModelException {
- org.eclipse.core.resources.IFile f = p.getFile(path);
- removeFromJavaClassPath(p, f);
- }
-
- /**
- * Remove the classpath entry from the project's classpath.
- *
- * @param p
- * @param entry
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static void removeFromJavaClassPath(IProject p, IClasspathEntry entry) throws JavaModelException {
- IJavaProject javaProject = null;
- try {
- javaProject = (IJavaProject) p.getNature(JavaCore.NATURE_ID);
- } catch (CoreException ignore) {
- }
- if (javaProject != null) {
- IClasspathEntry[] classpath = javaProject.getRawClasspath();
- javaProject.setRawClasspath(primRemoveFromJavaClassPath(classpath, entry), new NullProgressMonitor());
- }
- }
-
- /**
- * Remove the list of entries from the classpath of the project.
- *
- * @param p
- * project
- * @param entries
- * list of IClassPathEntry's
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static void removeFromJavaClassPath(IProject p, List entries) throws JavaModelException {
- IJavaProject javaProject = null;
- try {
- javaProject = (IJavaProject) p.getNature(JavaCore.NATURE_ID);
- } catch (CoreException ignore) {
- }
- if (javaProject != null) {
- IClasspathEntry[] classpath = javaProject.getRawClasspath();
- javaProject.setRawClasspath(primRemoveFromJavaClassPath(classpath, entries), new NullProgressMonitor());
- }
- }
-
- protected static IClasspathEntry[] primRemoveFromJavaClassPath(IClasspathEntry[] classpath, IClasspathEntry entry) throws JavaModelException {
- List result = new ArrayList();
- boolean didRemove = false;
- for (int i = 0; i < classpath.length; i++) {
- IClasspathEntry cpEntry = classpath[i];
- if (!entry.getPath().equals(classpath[i].getPath()))
- result.add(cpEntry);
- else
- didRemove = true;
- }
- if (!didRemove)
- return classpath;
- return (IClasspathEntry[]) result.toArray(new IClasspathEntry[result.size()]);
- }
-
- protected static IClasspathEntry[] primRemoveFromJavaClassPath(IClasspathEntry[] classpath, List entries) throws JavaModelException {
- List arrayList = Arrays.asList(classpath);
- List removeable = new ArrayList(arrayList);
- IClasspathEntry entry;
- boolean didRemove = false;
- int size = entries.size();
- for (int i = 0; i < size; i++) {
- entry = (IClasspathEntry) entries.get(i);
- for (int j = 0; j < classpath.length; j++) {
- IClasspathEntry cpEntry = classpath[j];
- if (entry.getPath().equals(classpath[j].getPath())) {
- if (removeable.remove(cpEntry))
- didRemove = true;
- }
- }
- }
- if (!didRemove)
- return classpath;
- return (IClasspathEntry[]) removeable.toArray(new IClasspathEntry[removeable.size()]);
- }
-
- /**
- * Get the classpath as an array or URL's.
- *
- * @param javaProject
- * @return array of URL's or <code>null</code> if javaProject was <code>null</code>.
- *
- * @since 1.0.0
- */
- public static URL[] getClasspathAsURLArray(IJavaProject javaProject) {
- if (javaProject == null)
- return null;
- Set visited = new HashSet();
- List urls = new ArrayList(20);
- collectClasspathURLs(javaProject, urls, visited, true);
- URL[] result = new URL[urls.size()];
- urls.toArray(result);
- return result;
- }
-
- private static void collectClasspathURLs(IJavaProject javaProject, List urls, Set visited, boolean isFirstProject) {
- if (visited.contains(javaProject))
- return;
- visited.add(javaProject);
- IPath outPath = getJavaProjectOutputAbsoluteLocation(javaProject.getProject());
- outPath = outPath.addTrailingSeparator();
- URL out = ProjectUtilities.createFileURL(outPath);
- urls.add(out);
- IClasspathEntry[] entries = null;
- try {
- entries = javaProject.getResolvedClasspath(true);
- } catch (JavaModelException e) {
- return;
- }
- IClasspathEntry entry;
- for (int i = 0; i < entries.length; i++) {
- entry = entries[i];
- switch (entry.getEntryKind()) {
- case IClasspathEntry.CPE_LIBRARY:
- case IClasspathEntry.CPE_CONTAINER:
- case IClasspathEntry.CPE_VARIABLE:
- collectClasspathEntryURL(entry, urls);
- break;
- case IClasspathEntry.CPE_PROJECT: {
- if (isFirstProject || entry.isExported())
- collectClasspathURLs(getJavaProject(entry), urls, visited, false);
- break;
- }
- }
- }
- }
-
- private static void collectClasspathEntryURL(IClasspathEntry entry, List urls) {
- URL url = ProjectUtilities.createFileURL(entry.getPath());
- if (url != null)
- urls.add(url);
- }
-
- private static IJavaProject getJavaProject(IClasspathEntry entry) {
- IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(entry.getPath().segment(0));
- if (proj != null)
- return getJavaProject(proj);
- return null;
- }
-
- /**
- * Is this project a binary project.
- * <p>
- * Typically a Java project is considered binary if it does not have a source entry in the classpath.
- *
- * @param project
- * Project to test
- * @return <code>true</code> if project is a binary project.
- */
- public static boolean isBinaryProject(IProject aProject) {
-
- IJavaProject javaProj = getJavaProject(aProject);
- if (javaProj == null)
- return false;
- IClasspathEntry[] entries = null;
- try {
- entries = javaProj.getRawClasspath();
- } catch (JavaModelException jme) {
- return false;
- }
- for (int i = 0; i < entries.length; i++) {
- IClasspathEntry entry = entries[i];
- if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE)
- return false;
- }
- return true;
- }
-
- /**
- * Append to java class path.
- * <p>
- * Append a list of IClasspathEntry's to the build path of the passed project. Updated to remove existing occurrences of the passed entries before
- * appending.
- * </p>
- *
- * @param p
- * project
- * @param appendClasspathEntries
- * list of entries
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static void appendJavaClassPath(IProject p, List appendClasspathEntries) throws JavaModelException {
- IJavaProject javaProject = null;
- try {
- javaProject = (IJavaProject) p.getNature(JavaCore.NATURE_ID);
- } catch (CoreException ignore) {
- }
- if (javaProject != null) {
- IClasspathEntry[] classpath = javaProject.getRawClasspath();
- List newPathList = new ArrayList(classpath.length);
- for (int i = 0; i < classpath.length; i++) {
- IClasspathEntry entry = classpath[i];
- // Skip entries which are in the append list
- if (appendClasspathEntries.indexOf(entry) < 0)
- newPathList.add(entry);
- }
- newPathList.addAll(appendClasspathEntries);
- IClasspathEntry[] newClasspath = (IClasspathEntry[]) newPathList.toArray(new IClasspathEntry[newPathList.size()]);
- javaProject.setRawClasspath(newClasspath, new NullProgressMonitor());
- }
- }
-
- /**
- * Append classpath entry.
- * <p>
- * Append one IClasspathEntry to the build path of the passed project. If a classpath entry having the same path as the parameter already exists,
- * then does nothing.
- * </p>
- *
- * @param p
- * Project
- * @param newEntry
- * Entry
- * @throws JavaModelException
- *
- * @since 1.0.0
- */
- public static void appendJavaClassPath(IProject p, IClasspathEntry newEntry) throws JavaModelException {
- IJavaProject javaProject = getJavaProject(p);
- if (javaProject == null)
- return;
- IClasspathEntry[] classpath = javaProject.getRawClasspath();
- List newPathList = new ArrayList(classpath.length);
- for (int i = 0; i < classpath.length; i++) {
- IClasspathEntry entry = classpath[i];
- // fix dup class path entry for .JETEmitter project
- // Skip the entry to be added if it already exists
- if (Platform.getOS().equals(Platform.OS_WIN32)) {
- if (!entry.getPath().toString().equalsIgnoreCase(newEntry.getPath().toString()))
- newPathList.add(entry);
- else
- return;
- } else {
- if (!entry.getPath().equals(newEntry.getPath()))
- newPathList.add(entry);
- else
- return;
- }
- }
- newPathList.add(newEntry);
- IClasspathEntry[] newClasspath = (IClasspathEntry[]) newPathList.toArray(new IClasspathEntry[newPathList.size()]);
- javaProject.setRawClasspath(newClasspath, new NullProgressMonitor());
- }
-
- /**
- * Return the source path matching the parameter; if the parameter is null, or if the source folder is not on the classpath, return the first
- * source path on the classpath
- *
- * @param p
- * project
- * @param defaultSourceName
- * source folder to find if on classpath, or if <code>null</code> the first folder
- * @return path searched for or <code>null</code> if not java project or some other problem.
- *
- * @since 1.0.0
- */
- public static IPath getSourcePathOrFirst(IProject p, String defaultSourceName) {
- IJavaProject javaProj = getJavaProject(p);
- if (javaProj == null)
- return null;
- IClasspathEntry[] cp = null;
- try {
- cp = javaProj.getRawClasspath();
- } catch (JavaModelException ex) {
- JEMUtilPlugin.getLogger().logError(ex);
- return null;
- }
- IClasspathEntry firstSource = null;
- IPath defaultSourcePath = null;
- if (defaultSourceName != null)
- defaultSourcePath = ProjectUtilities.createPath(p, defaultSourceName);
- for (int i = 0; i < cp.length; i++) {
- if (cp[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) {
- if (firstSource == null) {
- firstSource = cp[i];
- if (defaultSourcePath == null)
- break;
- }
- if (cp[i].getPath().equals(defaultSourcePath))
- return defaultSourcePath.removeFirstSegments(1);
- }
- }
- if (firstSource == null)
- return null;
- if (firstSource.getPath().segment(0).equals(p.getName()))
- return firstSource.getPath().removeFirstSegments(1);
- return null;
- }
-
- protected static List getSourcePaths(IProject p) {
- IJavaProject javaProj = getJavaProject(p);
- if (javaProj == null)
- return null;
- IClasspathEntry[] cp = null;
- try {
- cp = javaProj.getRawClasspath();
- } catch (JavaModelException ex) {
- JEMUtilPlugin.getLogger().logError(ex);
- return null;
- }
- List sourcePaths = new ArrayList();
- for (int i = 0; i < cp.length; i++) {
- if (cp[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) {
- sourcePaths.add(cp[i].getPath().removeFirstSegments(1));
- }
- }
- return sourcePaths;
- }
-
- /**
- * Hack to force a reload of the .classpath file
- *
- * @param project
- * project to reload
- * @since 1.0.0
- */
- public static void forceClasspathReload(IProject project) throws JavaModelException {
- IJavaProject javaProj = getJavaProject(project);
- if (javaProj != null) {
- IClasspathEntry[] entries = javaProj.readRawClasspath();
- if (entries != null) {
- IPath output = javaProj.readOutputLocation();
- if (output != null)
- javaProj.setRawClasspath(entries, output, null);
- }
- }
- }
-
- /**
- * Get the paths of all of the local jars in the classpath for the project. It does not recurse into referenced projects.
- *
- * @param proj
- * project to search (should be a java project).
- * @return A list of IPath, where each entry is a project relative path to a JAR contained in the project.
- */
- public static List getLocalJARPathsFromClasspath(IProject proj) {
- IJavaProject javaProj = getJavaProject(proj);
- if (javaProj == null)
- return null;
- IPath projectPath = proj.getFullPath();
- List result = new ArrayList();
- try {
- IClasspathEntry[] entries = javaProj.getRawClasspath();
- for (int i = 0; i < entries.length; i++) {
- IClasspathEntry entry = entries[i];
- if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
- IPath path = entry.getPath();
- int segments = path.matchingFirstSegments(projectPath);
- if (segments > 0)
- result.add(path.removeFirstSegments(segments));
- }
- }
- } catch (JavaModelException e) {
- JEMUtilPlugin.getLogger().logError(e);
- }
- return result;
- }
-
- /*
- * return list of path that may contain classes
- */
- protected static List getlibraryPaths(IProject p) {
- IJavaProject javaProj = getJavaProject(p);
- if (javaProj == null)
- return null;
- IClasspathEntry[] cp = null;
- try {
- cp = javaProj.getRawClasspath();
- } catch (JavaModelException ex) {
- JEMUtilPlugin.getLogger().logError(ex);
- return null;
- }
- List libraryPaths = new ArrayList();
- for (int i = 0; i < cp.length; i++) {
- if (cp[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
- libraryPaths.add(cp[i].getPath().removeFirstSegments(1));
- }
- }
- return libraryPaths;
- }
-
- /**
- * Return the source folder matching the parameter; if the parameter is null, or if the source folder is not on the classpath, return the first
- * source folder on the classpath
- *
- * @param p
- * project
- * @param defaultSourceName
- * source folder to find if on classpath, or if <code>null</code> the first folder
- * @return container searched for or <code>null</code> if not java project or some other problem.
- *
- * @since 1.0.0
- */
- public static IContainer getSourceFolderOrFirst(IProject p, String defaultSourceName) {
- try {
- IPath sourcePath = getSourcePathOrFirst(p, defaultSourceName);
- if (sourcePath == null)
- return null;
- else if (sourcePath.isEmpty())
- return p;
- else
- return p.getFolder(sourcePath);
- } catch (IllegalArgumentException ex) {
- return null;
- }
- }
-
- /**
- * Returns a list of IFolder that represents each source folder in a java project
- *
- * @deprecated Use {@link #getSourceContainers(IProject)}because the project itself might be a source container
- *
- * @param p
- * project
- * @return
- *
- * @since 1.0.0
- */
- public static List getSourceFolders(IProject p) {
- try {
- List sourceFolders = new ArrayList();
- List sourcePaths = getSourcePaths(p);
- if (sourcePaths != null && !sourcePaths.isEmpty()) {
- for (int i = 0; i < sourcePaths.size(); i++) {
- IPath path = (IPath) sourcePaths.get(i);
- if (!path.isEmpty())
- sourceFolders.add(p.getFolder(path));
- }
- }
- return sourceFolders;
- } catch (IllegalArgumentException ex) {
- return Collections.EMPTY_LIST;
- }
- }
-
- /**
- * Get source containers for the project.
- *
- * @param p
- * project
- * @return list of source containers.
- *
- * @since 1.0.0
- */
- public static List getSourceContainers(IProject p) {
- try {
- List sourceContainers = new ArrayList();
- List sourcePaths = getSourcePaths(p);
- if (sourcePaths != null && !sourcePaths.isEmpty()) {
- for (int i = 0; i < sourcePaths.size(); i++) {
- IPath path = (IPath) sourcePaths.get(i);
- if (path.isEmpty())
- sourceContainers.add(p);
- else
- sourceContainers.add(p.getFolder(path));
- }
- }
- return sourceContainers;
- } catch (IllegalArgumentException ex) {
- return Collections.EMPTY_LIST;
- }
- }
-
- /**
- * Return list of IContainers that are Libraries in the classpath.
- *
- * @param p
- * project
- * @return list of library IContainers.
- *
- * @since 1.0.0
- */
- public static List getLibraryContainers(IProject p) {
- try {
- List libraryContainers = new ArrayList();
- List libraryPaths = getlibraryPaths(p);
- if (libraryPaths != null && !libraryPaths.isEmpty()) {
- for (int i = 0; i < libraryPaths.size(); i++) {
- IPath path = (IPath) libraryPaths.get(i);
- if (path.isEmpty())
- libraryContainers.add(p);
- else
- libraryContainers.add(p.getFolder(path));
- }
- }
- return libraryContainers;
- } catch (IllegalArgumentException ex) {
- return Collections.EMPTY_LIST;
- }
- }
-
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectResourceSet.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectResourceSet.java
deleted file mode 100644
index 68c9735..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectResourceSet.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: ProjectResourceSet.java,v $$
- * $$Revision: 1.3 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-/**
- * A ResourceSet for an entire project. It allows sharing of resources from multiple editors/viewers for a project.
- * <p>
- * An additional Notification type is sent out by ProjectResourceSet's of project resource set about to be released. A release is
- * called when projects are about to be closed. They release all of the resources and unload them. This notification can be used
- * to know that this is about to happen and to do something before the resources become invalid. It will be sent out just before the
- * resource set will be released.
- *
- * @see ProjectResourceSet#SPECIAL_NOTIFICATION_TYPE
- * @see ProjectResourceSet#PROJECTRESOURCESET_ABOUT_TO_RELEASE_ID
- * @since 1.0.0
- */
-
-public interface ProjectResourceSet extends ResourceSet {
-
- IProject getProject();
-
- /**
- * Notification type in notifications from the ProjectResourceSet for
- * special notifications, and not the standard ones from ResourceSet.
- *
- * @see org.eclipse.emf.common.notify.Notification#getEventType()
- * @since 1.1.0
- */
- static int SPECIAL_NOTIFICATION_TYPE = Notification.EVENT_TYPE_COUNT+4;
-
- /**
- * Notification Feature ID for resource set about to be released.
- * Use {@link org.eclipse.emf.common.notify.Notification#getFeatureID(java.lang.Class)} to
- * get this id. The getFeature() on notification will return null.
- *
- * @since 1.1.0
- */
- static int PROJECTRESOURCESET_ABOUT_TO_RELEASE_ID = 1000;
-
- /**
- * Call when the ResourceSet is no longer to be used.
- *
- *
- * @since 1.0.0
- */
- void release();
-
- /**
- * Add the <code>resourceHandler</code> to the end of the list of resourceHandlers.
- *
- * @param resourceHandler
- * IResourceHandler
- * @return boolean Return <code>true</code> if it was added.
- * @since 1.0.0
- */
- boolean add(ResourceHandler resourceHandler);
-
- /**
- * Add the <code>resourceHandler</code> to the front of the list of resourceHandlers.
- *
- * @param resourceHandler
- * IResourceHandler
- * @since 1.0.0
- */
- void addFirst(ResourceHandler resourceHandler);
-
- /**
- * Remove the <code>resourceHandler</code> from the list of resourceHandlers.
- *
- * @param resourceHandler
- * IResourceHandler
- * @return boolean Return true if it was removed.
- * @since 1.0.0
- */
- boolean remove(ResourceHandler resourceHandler);
-
- /**
- * Return the ResourceSet synchronizer that will synchronize the ResourceSet with changes from the Workbench.
- *
- * @return ResourceSetWorkbenchSynchronizer
- * @since 1.0.0
- */
- ResourceSetWorkbenchSynchronizer getSynchronizer();
-
- /**
- * Set the ResourceSet synchronizer that will synchronize the ResourceSet with changes from the Workbench.
- *
- * @param aSynchronizer
- * @return ResourceSetWorkbenchSynchronizer
- * @since 1.0.0
- */
- void setSynchronizer(ResourceSetWorkbenchSynchronizer aSynchronizer);
-
- /**
- * This should be called by clients whenever the structure of the project changes such that any cached URIs will be invalid. For example, if the
- * source folders within the URIConverter change.
- *
- * @since 1.0.0
- */
- void resetNormalizedURICache();
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectUtilities.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectUtilities.java
deleted file mode 100644
index 7ae9053..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectUtilities.java
+++ /dev/null
@@ -1,749 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: ProjectUtilities.java,v $$
- * $$Revision: 1.3 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-
-package org.eclipse.jem.util.emf.workbench;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.*;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-/**
- * EMF Workbench Project Utilities.
- *
- * @since 1.0.0
- */
-
-public class ProjectUtilities {
-
- /**
- * Project control file name in project.
- *
- * @since 1.0.0
- */
- public final static String DOT_PROJECT = ".project"; //$NON-NLS-1$
-
- /**
- * Classpath control file name in project.
- *
- * @since 1.0.0
- */
- public final static String DOT_CLASSPATH = ".classpath"; //$NON-NLS-1$
-
- public ProjectUtilities() {
- }
-
- /**
- * Add the nature id to the project ahead of all other nature ids.
- *
- * @param proj
- * @param natureId
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public static void addNatureToProject(IProject proj, String natureId) throws CoreException {
- IProjectDescription description = proj.getDescription();
- String[] prevNatures = description.getNatureIds();
- String[] newNatures = new String[prevNatures.length + 1];
- System.arraycopy(prevNatures, 0, newNatures, 1, prevNatures.length);
- newNatures[0] = natureId;
- description.setNatureIds(newNatures);
- proj.setDescription(description, null);
- }
-
- /**
- * Add the nature id after all of the other nature ids for the project.
- *
- * @param proj
- * @param natureId
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public static void addNatureToProjectLast(IProject proj, String natureId) throws CoreException {
- IProjectDescription description = proj.getDescription();
- String[] prevNatures = description.getNatureIds();
- String[] newNatures = new String[prevNatures.length + 1];
- System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
- newNatures[prevNatures.length] = natureId;
- description.setNatureIds(newNatures);
- proj.setDescription(description, null);
- }
-
- /**
- * Remove the nature id from the project.
- *
- * @param project
- * @param natureId
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public static void removeNatureFromProject(IProject project, String natureId) throws CoreException {
- IProjectDescription description = project.getDescription();
- String[] prevNatures = description.getNatureIds();
- int size = prevNatures.length;
- int newsize = 0;
- String[] newNatures = new String[size];
- boolean matchfound = false;
- for (int i = 0; i < size; i++) {
- if (prevNatures[i].equals(natureId)) {
- matchfound = true;
- continue;
- } else
- newNatures[newsize++] = prevNatures[i];
- }
- if (!matchfound)
- throw new CoreException(new Status(IStatus.ERROR, JEMUtilPlugin.ID, 0,
- "The nature id " + natureId + " does not exist on the project " + project.getName(), null)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- else {
- String[] temp = newNatures;
- newNatures = new String[newsize];
- System.arraycopy(temp, 0, newNatures, 0, newsize);
- description.setNatureIds(newNatures);
- project.setDescription(description, null);
- }
- }
-
- /**
- * Add the list of projects to end of the "referenced projects" list from the project's description.
- *
- * @param project
- * @param toBeAddedProjectsList
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public static void addReferenceProjects(IProject project, List toBeAddedProjectsList) throws CoreException {
-
- IProjectDescription description = project.getDescription();
- IProject[] projects = description.getReferencedProjects();
-
- ArrayList projectsList = new ArrayList();
-
- for (int i = 0; i < projects.length; i++) {
- projectsList.add(projects[i]);
- }
-
- for (int i = 0; i < toBeAddedProjectsList.size(); i++) {
- projectsList.add(toBeAddedProjectsList.get(i));
- }
-
- IProject[] refProjects = new IProject[projectsList.size()];
-
- for (int i = 0; i < refProjects.length; i++) {
- refProjects[i] = (IProject) (projectsList.get(i));
- }
-
- description.setReferencedProjects(refProjects);
- project.setDescription(description, null);
- }
-
- /**
- * Add the single project to the end of the "referenced projects" list from the project's description.
- *
- * @param project
- * @param projectToBeAdded
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public static void addReferenceProjects(IProject project, IProject projectToBeAdded) throws CoreException {
- IProjectDescription description = project.getDescription();
- IProject[] projects = description.getReferencedProjects();
-
- ArrayList projectsList = new ArrayList();
-
- for (int i = 0; i < projects.length; i++) {
- projectsList.add(projects[i]);
- }
-
- projectsList.add(projectToBeAdded);
-
- IProject[] refProjects = new IProject[projectsList.size()];
-
- for (int i = 0; i < refProjects.length; i++) {
- refProjects[i] = (IProject) (projectsList.get(i));
- }
-
- description.setReferencedProjects(refProjects);
- project.setDescription(description, null);
- }
-
- /**
- * Force a an immediate build of the project.
- *
- * @param project
- * @param progressMonitor
- *
- * @since 1.0.0
- */
- public static void forceAutoBuild(IProject project, IProgressMonitor progressMonitor) {
- try {
- project.build(IncrementalProjectBuilder.FULL_BUILD, progressMonitor);
- } catch (CoreException ce) {
- //Revisit: Need to use a Logger
- //Logger.getLogger().logError(ce);
- }
- }
-
- /**
- * Return if auto build is turned on.
- *
- * @return <code>true</code> if auto build is turned on.
- *
- * @since 1.0.0
- */
- public static boolean getCurrentAutoBuildSetting() {
-
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IWorkspaceDescription wd = workspace.getDescription();
- return wd.isAutoBuilding();
- }
-
- /**
- * Get the project associated with the given object.
- *
- * @param object
- * may be an <code>IProject, IResource, IAdaptable (to an IProject), EObject (gets IProject if object is in a ProjectResourceSet</code>.
- * @param natureId
- * if <code>null</code> then returns project. If not <code>null</code> then returns project only if project has this nature id.
- * @return project associated with the object or <code>null</code> if not found.
- *
- * @since 1.0.0
- */
- public static IProject getProject(Object object, String natureId) {
- IProject result = getProject(object);
- if (natureId == null)
- return result;
- if (result != null && result.isAccessible() && natureId != null)
- try {
- if (result.hasNature(natureId))
- return result;
- } catch (CoreException e) {
- Logger.getLogger().logError(e);
- }
- return null;
- }
-
- /**
- * Get the project associated with the given object.
- *
- * @param object
- * may be an <code>IProject, IResource, IAdaptable (to an IProject), EObject (gets IProject if object is in a ProjectResourceSet</code>.
- * @return project associated with the object or <code>null</code> if not found.
- *
- * @since 1.0.0
- */
- public static IProject getProject(Object object) {
- IProject result = null;
-
- if (object instanceof IProject)
- result = (IProject) object;
- else if (object instanceof IResource)
- result = ((IResource) object).getProject();
- else if (object instanceof IAdaptable)
- result = (IProject) ((IAdaptable) object).getAdapter(IProject.class);
- else if (object instanceof EObject)
- result = getProject((EObject) object);
-
- return result;
- }
-
- /**
- * Get the project associated with the given EObject. (If in a ProjectResourceSet, then the project from that resource set).
- *
- * @param aRefObject
- * @return project if associated or <code>null</code> if not found.
- *
- * @since 1.0.0
- */
- public static IProject getProject(EObject aRefObject) {
- if (aRefObject != null) {
- Resource resource = aRefObject.eResource();
- return getProject(resource);
- }
- return null;
- }
-
- /**
- * Get the project associated with the given Resource. (If in a ProjectResourceSet, then the project from that resource set).
- *
- * @param resource
- * @return project if associated or <code>null</code> if not found.
- *
- * @since 1.0.0
- */
- public static IProject getProject(Resource resource) {
- ResourceSet set = resource == null ? null : resource.getResourceSet();
- if (set instanceof ProjectResourceSet)
- return ((ProjectResourceSet) set).getProject();
- URIConverter converter = set == null ? null : set.getURIConverter();
- if (converter != null && converter instanceof WorkbenchURIConverter && ((WorkbenchURIConverter) converter).getOutputContainer() != null)
- return ((WorkbenchURIConverter) converter).getOutputContainer().getProject();
- else
- return null;
- }
-
- /**
- * Remove the list of projects from the list of "referenced projects" in the project's description.
- *
- * @param project
- * @param toBeRemovedProjectList
- * @throws org.eclipse.core.runtime.CoreException
- *
- * @since 1.0.0
- */
- public static void removeReferenceProjects(IProject project, List toBeRemovedProjectList) throws org.eclipse.core.runtime.CoreException {
- IProjectDescription description = project.getDescription();
- IProject[] projects = description.getReferencedProjects();
-
- ArrayList projectsList = new ArrayList();
-
- for (int i = 0; i < projects.length; i++) {
- projectsList.add(projects[i]);
- }
-
- for (int i = 0; i < toBeRemovedProjectList.size(); i++) {
- projectsList.remove(toBeRemovedProjectList.get(i));
- }
-
- IProject[] refProjects = new IProject[projectsList.size()];
-
- for (int i = 0; i < refProjects.length; i++) {
- refProjects[i] = (IProject) (projectsList.get(i));
- }
-
- description.setReferencedProjects(refProjects);
- project.setDescription(description, null);
- }
-
- /**
- * Remove the project from the list of "referenced projects" in the description for the given project.
- *
- * @param project
- * @param toBeRemovedProject
- * @throws org.eclipse.core.runtime.CoreException
- *
- * @since 1.0.0
- */
- public static void removeReferenceProjects(IProject project, IProject toBeRemovedProject) throws org.eclipse.core.runtime.CoreException {
- IProjectDescription description = project.getDescription();
- IProject[] projects = description.getReferencedProjects();
-
- ArrayList projectsList = new ArrayList();
-
- for (int i = 0; i < projects.length; i++) {
- projectsList.add((projects[i]));
- }
-
- projectsList.remove(toBeRemovedProject);
-
- IProject[] refProjects = new IProject[projectsList.size()];
-
- for (int i = 0; i < refProjects.length; i++) {
- refProjects[i] = (IProject) (projectsList.get(i));
- }
-
- description.setReferencedProjects(refProjects);
- project.setDescription(description, null);
- }
-
- /**
- * Turn auto-building off.
- *
- *
- * @since 1.0.0
- */
- public static void turnAutoBuildOff() {
- try {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IWorkspaceDescription wd = workspace.getDescription();
- wd.setAutoBuilding(false);
- workspace.setDescription(wd);
- } catch (CoreException ce) {
- //Logger.getLogger().logError(ce);
- }
- }
-
- /**
- * Turn auto-building on.
- *
- *
- * @since 1.0.0
- */
- public static void turnAutoBuildOn() {
- try {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IWorkspaceDescription wd = workspace.getDescription();
- wd.setAutoBuilding(true);
- workspace.setDescription(wd);
- } catch (CoreException ce) {
- //Logger.getLogger().logError(ce);
- }
- }
-
- /**
- * Set the auto-building state.
- *
- * @param aBoolean
- * <code>true</code> to turn auto-building on.
- *
- * @since 1.0.0
- */
- public static void turnAutoBuildOn(boolean aBoolean) {
- try {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IWorkspaceDescription wd = workspace.getDescription();
- wd.setAutoBuilding(aBoolean);
- workspace.setDescription(wd);
- } catch (CoreException ce) {
- //Logger.getLogger().logError(ce);
-
- }
- }
-
- /**
- * Adds a builder to the build spec for the given project.
- *
- * @param builderID
- * The id of the builder.
- * @param project
- * Project to add to.
- * @return whether the builder id was actually added (it may have already existed)
- * @throws CoreException
- * @since 1.0.0
- */
- public static boolean addToBuildSpec(String builderID, IProject project) throws CoreException {
- return addToBuildSpecBefore(builderID, null, project);
- }
-
- /**
- * Adds a builder to the build spec for the given project, immediately before the specified successor builder.
- *
- * @param builderID
- * The id of the builder.
- * @param successorID
- * The id to put the builder before.
- * @return whether the builder id was actually added (it may have already existed)
- * @throws CoreException
- * @since 1.0.0
- */
- public static boolean addToBuildSpecBefore(String builderID, String successorID, IProject project) throws CoreException {
- IProjectDescription description = project.getDescription();
- ICommand[] commands = description.getBuildSpec();
- boolean found = false;
- for (int i = 0; i < commands.length; ++i) {
- if (commands[i].getBuilderName().equals(builderID)) {
- found = true;
- break;
- }
- }
- if (!found) {
- boolean successorFound = false;
- ICommand command = description.newCommand();
- command.setBuilderName(builderID);
- ICommand[] newCommands = new ICommand[commands.length + 1];
- for (int j = 0, index = 0; j < commands.length; j++, index++) {
- if (successorID != null && commands[j].getBuilderName().equals(successorID)) {
- successorFound = true;
- newCommands[index++] = command;
- }
- newCommands[index] = commands[j];
- }
- if (!successorFound)
- newCommands[newCommands.length - 1] = command;
- description.setBuildSpec(newCommands);
- project.setDescription(description, null);
- }
- return !found;
- }
-
- /**
- * Remove the builder from the build spec.
- *
- * @param builderID
- * The id of the builder.
- * @param project
- * Project to remove from.
- * @return boolean if the builder id was found and removed
- * @throws CoreException
- * @since 1.0.0
- */
- public static boolean removeFromBuildSpec(String builderID, IProject project) throws CoreException {
- IProjectDescription description = project.getDescription();
- ICommand[] commands = description.getBuildSpec();
- boolean found = false;
- for (int i = 0; i < commands.length; ++i) {
- if (commands[i].getBuilderName().equals(builderID)) {
- found = true;
- break;
- }
- }
- if (found) {
- ICommand[] newCommands = new ICommand[commands.length - 1];
- int newCount = 0;
- for (int i = 0; i < commands.length; ++i) {
- if (!(commands[i].getBuilderName().equals(builderID))) {
- //Add the existng to the new array
- newCommands[newCount] = commands[i];
- newCount++;
- }
- }
-
- description.setBuildSpec(newCommands);
- project.setDescription(description, null);
-
- }
- return found;
-
- }
-
- /**
- * Ensure the container is not read-only.
- * <p>
- * For Linux, a Resource cannot be created in a ReadOnly folder. This is only necessary for new files.
- *
- * @param resource
- * workspace resource to make read/write
- * @since 1.0.0
- */
- public static void ensureContainerNotReadOnly(IResource resource) {
- if (resource != null && !resource.exists()) { //it must be new
- IContainer container = resource.getParent();
- while (container != null && !container.isReadOnly())
- container = container.getParent();
- if (container != null)
- container.setReadOnly(false);
- }
- }
-
- /**
- * Get projects from primary nature.
- *
- * @param natureID
- * @return All projects that have the given nature id as the first nature id.
- *
- * @since 1.0.0
- */
- public static IProject[] getProjectsForPrimaryNature(String natureID) {
- IProject[] projectsWithNature = new IProject[] {};
- List result = new ArrayList();
- IProject[] projects = getAllProjects();
- for (int i = 0; i < projects.length; i++) {
- if (isProjectPrimaryNature(projects[i], natureID))
- result.add(projects[i]);
- }
- return (IProject[]) result.toArray(projectsWithNature);
- }
-
- /**
- * Get all projects in the workspace
- *
- * @return all workspace projects
- *
- * @since 1.0.0
- */
- public static IProject[] getAllProjects() {
- return ResourcesPlugin.getWorkspace().getRoot().getProjects();
- }
-
- /**
- * Is this nature id the primary nature id for the project
- *
- * @param project
- * @param natureID
- * @return <code>true</code> if first nature id for the project.
- *
- * @since 1.0.0
- */
- public static boolean isProjectPrimaryNature(IProject project, String natureID) {
- String[] natures = null;
- try {
- natures = project.getDescription().getNatureIds();
- } catch (Exception e1) {
- }
- return (natures != null && natures.length > 0 && natures[0].equals(natureID));
- }
-
- protected static IPath createPath(IProject p, String defaultSourceName) {
- IPath path = new Path(p.getName());
- path = path.append(defaultSourceName);
- path = path.makeAbsolute();
- return path;
- }
-
- /**
- * Returns a list of existing files which will be modified if the classpath changes for the given proeject.
- *
- * @param p
- * project
- * @return list of affected files.
- *
- * @since 1.0.0
- */
- public static List getFilesAffectedByClasspathChange(IProject p) {
- List result = new ArrayList(2);
- addFileIfExists(p, result, DOT_CLASSPATH);
- addFileIfExists(p, result, DOT_PROJECT);
- return result;
- }
-
- protected static void addFileIfExists(IProject p, List aList, String filename) {
- IFile aFile = p.getFile(filename);
- if (aFile != null && aFile.exists())
- aList.add(aFile);
- }
-
- /**
- * Strip off a leading "/" from each project name in the array, if it has one.
- *
- * @param projecNames
- * @return array of project names with all leading '/' removed.
- *
- * @since 1.0.0
- */
- public static String[] getProjectNamesWithoutForwardSlash(String[] projecNames) {
- String[] projNames = new String[projecNames.length];
- List temp = java.util.Arrays.asList(projecNames);
- for (int i = 0; i < temp.size(); i++) {
- String name = (String) (temp.get(i));
- if (name.startsWith("/")) { //$NON-NLS-1$
- projNames[i] = name.substring(1, name.length());
- } else {
- projNames[i] = name;
- }
- }
- return projNames;
- }
-
- protected static URL createFileURL(IPath path) {
- try {
- return path.toFile().toURL();
- } catch (MalformedURLException e) {
- Logger.getLogger().log(e, Level.WARNING);
- return null;
- }
- }
-
- /**
- * Find first newObject that is not in the oldObjects array (using "==").
- *
- * @param oldObjects
- * @param newObjects
- * @return first newObject not found in oldObjects, or <code>null</code> if all found.
- *
- * @since 1.0.0
- */
- public static Object getNewObject(Object[] oldObjects, Object[] newObjects) {
- if (oldObjects != null && newObjects != null && oldObjects.length < newObjects.length) {
- for (int i = 0; i < newObjects.length; i++) {
- boolean found = false;
- Object object = newObjects[i];
- for (int j = 0; j < oldObjects.length; j++) {
- if (oldObjects[j] == object) {
- found = true;
- break;
- }
- }
- if (!found)
- return object;
- }
- }
- if (oldObjects == null && newObjects != null && newObjects.length == 1)
- return newObjects[0];
- return null;
- }
-
- /**
- * List of all files in the project.
- * <p>
- * Note: A more efficient way to do this is to use {@link IResource#accept(org.eclipse.core.resources.IResourceProxyVisitor, int)}
- *
- * @param 1.0.0
- * @return list of files in the project
- *
- * @see IResource#accept(org.eclipse.core.resources.IResourceProxyVisitor, int)
- * @since 1.0.0
- */
- public static List getAllProjectFiles(IProject project) {
- List result = new ArrayList();
- if (project == null)
- return result;
- try {
- result = collectFiles(project.members(), result);
- } catch (CoreException e) {
- }
- return result;
- }
-
- private static List collectFiles(IResource[] members, List result) throws CoreException {
- // recursively collect files for the given members
- for (int i = 0; i < members.length; i++) {
- IResource res = members[i];
- if (res instanceof IFolder) {
- collectFiles(((IFolder) res).members(), result);
- } else if (res instanceof IFile) {
- result.add(res);
- }
- }
- return result;
- }
-
- /**
- * Get the project.
- *
- * @param projectName
- * @return a IProject given the projectName
- * @since 1.0.0
- */
- public static IProject getProject(String projectName) {
- return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- }
-
- /**
- * Return whether the given builder name is attached to the project.
- *
- * @param project
- * @param builderName
- * @return <code>true</code> if builder name is attached to the project.
- *
- * @since 1.0.0
- */
- public static boolean hasBuilder(IProject project, String builderName) {
- try {
- ICommand[] builders = project.getDescription().getBuildSpec();
- for (int i = 0; i < builders.length; i++) {
- ICommand builder = builders[i];
- if (builder != null) {
- if (builder.getBuilderName().equals(builderName))
- return true;
- }
- }
- } catch (Exception e) {
- }
- return false;
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ResourceHandler.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ResourceHandler.java
deleted file mode 100644
index 0170780..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ResourceHandler.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: ResourceHandler.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-/**
- * Implementers of this interface are provide extension capabilities on resource set. Such as looking or creating in other resource sets for a
- * resource or an EObject.
- *
- * @see org.eclipse.jem.util.emf.workbench.ProjectResourceSet#add(ResourceHandler)
- * @since 1.0.0
- */
-public interface ResourceHandler {
-
- /**
- * Each ResourceHandler for a WorkbenchContext (which holds a ProjectResourceSet) will get an oportunity to get the Resource given the uriString
- * prior to the originatingResourceSet getting it in the normal manner.
- *
- * If this handler loaded a Resource in its create(ResourceSet, uriString) then this method should be able to return it as well.
- *
- * @param originatingResourceSet
- * @param uri
- * @return resource if found or <code>nulll/code> if this handler didn't find it.
- *
- * @since 1.0.0
- */
- Resource getResource(ResourceSet originatingResourceSet, URI uri);
-
- /**
- * Get the EObject for the given URI, if it can. Load the resource if loadOnDemand is <code>true</code>.
- *
- * @param originatingResourceSet
- * @param uri
- * uri of EObject being requested
- * @param loadOnDemand
- * <code>true</code> if resource should be loaded
- * @return eobject if found or <code>null</code> if not.
- */
- EObject getEObjectFailed(ResourceSet originatingResourceSet, URI uri, boolean loadOnDemand);
-
- /**
- * Create the resource pointed to be the URI if this handler will handle it.
- *
- * @param originatingResourceSet
- * @param uri
- * @return resource if created, or <code>null</code> if handler doesn't handle this type.
- */
- Resource createResource(ResourceSet originatingResourceSet, URI uri);
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ResourceSetWorkbenchSynchronizer.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ResourceSetWorkbenchSynchronizer.java
deleted file mode 100644
index 1781936..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ResourceSetWorkbenchSynchronizer.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: ResourceSetWorkbenchSynchronizer.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-
-package org.eclipse.jem.util.emf.workbench;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-import org.eclipse.jem.internal.util.emf.workbench.EMFWorkbenchContextFactory;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-/**
- * Synchronizer on the workbench. It listens for the project to see if it is closed or deleted. If it does it notifies this out.
- *
- * @since 1.0.0
- */
-public class ResourceSetWorkbenchSynchronizer implements IResourceChangeListener {
-
- protected IProject project;
-
- protected ResourceSet resourceSet;
-
- /** Extenders that will be notified after a pre build resource change */
- protected List extenders;
-
- /** The delta for this project that will be broadcast to the extenders */
- protected IResourceDelta currentProjectDelta;
-
- private int currentEventType = -1;
-
- /**
- * Constructor taking a resource set and project.
- *
- * @param aResourceSet
- * @param aProject
- *
- * @since 1.0.0
- */
- public ResourceSetWorkbenchSynchronizer(ResourceSet aResourceSet, IProject aProject) {
- resourceSet = aResourceSet;
- project = aProject;
- if (aResourceSet != null && aResourceSet instanceof ProjectResourceSet)
- ((ProjectResourceSet) aResourceSet).setSynchronizer(this);
- initialize();
- }
-
- /**
- * Get the project for this synchronizer
- *
- * @return project
- *
- * @since 1.0.0
- */
- public IProject getProject() {
- return project;
- }
-
- /*
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- currentEventType = event.getType();
- currentProjectDelta = null;
- if ((currentEventType == IResourceChangeEvent.PRE_CLOSE || currentEventType == IResourceChangeEvent.PRE_DELETE)
- && event.getResource().equals(getProject())) {
- release();
- notifyExtendersOfClose();
- }
- }
-
- protected void notifyExtendersIfNecessary() {
- if (currentEventType != IResourceChangeEvent.POST_CHANGE || extenders == null || currentProjectDelta == null)
- return;
- for (int i = 0; i < extenders.size(); i++) {
- ISynchronizerExtender extender = (ISynchronizerExtender) extenders.get(i);
- extender.projectChanged(currentProjectDelta);
- }
- }
-
- protected void notifyExtendersOfClose() {
- if (extenders != null && !extenders.isEmpty()) {
- for (int i = 0; i < extenders.size(); i++) {
- ISynchronizerExtender extender = (ISynchronizerExtender) extenders.get(i);
- extender.projectClosed();
- }
- }
- }
-
- protected IWorkspace getWorkspace() {
- if (getProject() == null)
- return ResourcesPlugin.getWorkspace();
- return getProject().getWorkspace();
- }
-
- protected void initialize() {
- getWorkspace().addResourceChangeListener(this,
- IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_BUILD);
- }
-
- /**
- * Dispose of the synchronizer. Called when no longer needed.
- *
- *
- * @since 1.0.0
- */
- public void dispose() {
- getWorkspace().removeResourceChangeListener(this);
- }
-
- /**
- * The project is going away so we need to cleanup ourself and the ResourceSet.
- */
- protected void release() {
- if (JEMUtilPlugin.isActivated()) {
- try {
- if (resourceSet instanceof ProjectResourceSet)
- ((ProjectResourceSet) resourceSet).release();
- } finally {
- EMFWorkbenchContextFactory.INSTANCE.removeCachedProject(getProject());
- dispose();
- }
- }
- }
-
- /**
- * Add an extender to be notified of events.
- *
- * @param extender
- *
- * @since 1.0.0
- */
- public void addExtender(ISynchronizerExtender extender) {
- if (extenders == null)
- extenders = new ArrayList(3);
- extenders.add(extender);
- }
-
- /**
- * Remove extender from notification of events.
- *
- * @param extender
- *
- * @since 1.0.0
- */
- public void removeExtender(ISynchronizerExtender extender) {
- if (extenders == null)
- return;
- extenders.remove(extender);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return getClass().getName() + '(' + ((getProject() != null) ? getProject().getName() : "null") + ')'; //$NON-NLS-1$
- }
-
- /**
- * Tell Synchronizer that a file is about to be saved. This method should be called prior to writing to an IFile from an EMF resource.
- * <p>
- * Default does nothing, but subclasses can do something.
- * </p>
- *
- * @param aFile
- * file about to be saved.
- *
- * @since 1.0.0
- */
- public void preSave(IFile aFile) {
- //Default is do nothing
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchByteArrayOutputStream.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchByteArrayOutputStream.java
deleted file mode 100644
index 9d72f51..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchByteArrayOutputStream.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: WorkbenchByteArrayOutputStream.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.ecore.resource.impl.URIConverterImpl;
-
-/**
- * ByteArray OutputStream for the Workbench. It works with the synchronizer {@link org.eclipse.jem.util.emf.workbench.ResourceSetWorkbenchSynchronizer}to
- * notify of a save. It also changes all of the line separators to the current system line separator, i.e. if there are some '\r' and we are on
- * Windows(R) then they will be converted to '\n\r'), if the setting for the stream is to do eol conversion.
- *
- * @since 1.0.0
- */
-public class WorkbenchByteArrayOutputStream extends URIConverterImpl.PlatformResourceOutputStream {
-
- private boolean fConvertEOL = false;
-
- protected ResourceSetWorkbenchSynchronizer synchronizer;
-
- /**
- * Construct with an IFile
- *
- * @param aFile
- *
- * @since 1.0.0
- */
- public WorkbenchByteArrayOutputStream(IFile aFile) {
- this(aFile, null);
- }
-
- /**
- * Construct with a IFile and a synchronizer. This way synchronizer will know when file is about to be saved.
- *
- * @param aFile
- * @param aSynchronizer
- *
- * @since 1.0.0
- */
- public WorkbenchByteArrayOutputStream(IFile aFile, ResourceSetWorkbenchSynchronizer aSynchronizer) {
- super(aFile, false, true, null);
- synchronizer = aSynchronizer;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.OutputStream#close()
- */
- public void close() throws IOException {
- if (synchronizer != null)
- synchronizer.preSave(file);
- super.close();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.resource.impl.URIConverterImpl.PlatformResourceOutputStream#flush()
- */
- public void flush() throws IOException {
- if (synchronizer != null)
- synchronizer.preSave(file);
- super.flush();
- }
-
- /*
- * Convert the end of line characters.
- */
- private int convertEOL(byte[] data) {
- // Algorithm:
- // Remove all '\r' chars
- // Replace all '\n' chars with line seperator chars
-
- String EOL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
- byte[] EOLBytes = EOL.getBytes();
-
- int out = 0;
-
- for (int in = 0; in < data.length; in++) {
- if (data[in] == '\r') {
- // don't output (ie, throw the char away)
- } else if (data[in] == '\n') {
- // The code does not currently handle expanding the array
- if ((in - out + 1) < EOLBytes.length)
- throw new UnsupportedOperationException("WorkbenchByteArrayOutputStream: Expanding EOL chars not implemented"); //$NON-NLS-1$
-
- for (int i = 0; i < EOLBytes.length; i++) {
- data[out++] = EOLBytes[i];
- }
- } else {
- // Just copy the data
- data[out++] = data[in];
- }
- }
-
- return out;
- }
-
- /**
- * Is EOL conversion turned on.
- *
- * @return <code>true</code> if EOL conversion is turned on.
- *
- * @since 1.0.0
- */
- public boolean isConvertEOLChars() {
- return fConvertEOL;
- }
-
- /**
- * Set the EOL conversion flag.
- *
- * @param set
- * <code>true</code> if EOL should be converted to current line separator.
- *
- * @since 1.0.0
- */
- public void setConvertEOLChars(boolean set) {
- fConvertEOL = set;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.ByteArrayOutputStream#toByteArray()
- */
- public synchronized byte[] toByteArray() {
- byte[] contents = super.toByteArray();
- if (isConvertEOLChars())
- convertEOL(contents);
- return contents;
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchResourceHelperBase.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchResourceHelperBase.java
deleted file mode 100644
index 6020156..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchResourceHelperBase.java
+++ /dev/null
@@ -1,648 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: WorkbenchResourceHelperBase.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import java.util.*;
-
-import org.eclipse.core.internal.resources.ResourceException;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.common.util.WrappedException;
-import org.eclipse.emf.ecore.*;
-import org.eclipse.emf.ecore.resource.*;
-import org.eclipse.emf.ecore.util.InternalEList;
-
-import org.eclipse.jem.internal.util.emf.workbench.EMFWorkbenchContextFactory;
-import org.eclipse.jem.internal.util.emf.workbench.WorkspaceResourceHandler;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-/**
- * Workbench resource helper
- *
- * @since 1.0.0
- */
-public class WorkbenchResourceHelperBase {
-
- /**
- * Everything is static, don't know why there is an instance here.
- */
- public static final WorkbenchResourceHelperBase INSTANCE = new WorkbenchResourceHelperBase();
-
- protected static WorkspaceResourceHandler workspaceURILoader = new WorkspaceResourceHandler();
-
- protected static void resolveContainedProxies(EObject refObject) {
- List contained = refObject.eContents();
- EObject mofObject;
- for (int i = 0; i < contained.size(); i++) {
- mofObject = (EObject) contained.get(i);
- resolveProxies(mofObject);
- }
- }
-
- protected static void resolveNonContainedProxies(EObject refObject) {
- List references = refObject.eClass().getEAllReferences();
- EReference reference;
- for (int i = 0; i < references.size(); i++) {
- reference = (EReference) references.get(i);
- if (!reference.isContainment()) {
- if (reference.isMany()) {
- List value = (List) refObject.eGet(reference);
- for (int j = 0; j < value.size(); j++)
- value.get(j);
- } else {
- refObject.eGet(reference);
- }
- }
- }
- }
-
- /**
- * Force all of the proxies with <code>resource</code> to be resolved.
- *
- * @param resource
- *
- * @since 1.0.0
- */
- public static void resolveProxies(Resource resource) {
- if (resource != null) {
- List topLevels = resource.getContents();
- EObject mofObject;
- for (int i = 0; i < topLevels.size(); i++) {
- mofObject = (EObject) topLevels.get(i);
- resolveProxies(mofObject);
- }
- }
- }
-
- /**
- * Return a List of proxies that are contained by the <code>resource</code>.
- *
- * @param resource
- * @return list of proxies.
- *
- * @since 1.0.0
- */
- public static List gatherProxies(Resource resource) {
- if (resource == null)
- return Collections.EMPTY_LIST;
- List list = new ArrayList();
- List topLevels = resource.getContents();
- int size = topLevels.size();
- EObject mofObject;
- for (int i = 0; i < size; i++) {
- mofObject = (EObject) topLevels.get(i);
- gatherProxies((InternalEObject) mofObject, list);
- }
- return list;
- }
-
- protected static void gatherProxies(InternalEObject refObject, List proxies) {
- if (refObject == null)
- return;
- List contains = refObject.eClass().getEAllContainments();
- if (contains != null) {
- int size = contains.size();
- EStructuralFeature sf = null;
- for (int i = 0; i < size; i++) {
- sf = (EStructuralFeature) contains.get(i);
- gatherProxies(refObject, sf, proxies);
- }
- }
- }
-
- protected static void gatherProxies(InternalEObject refObject, EStructuralFeature sf, List proxies) {
- Object value = null;
- InternalEObject proxy = null;
- if (sf.isMany() || refObject.eIsSet(sf)) {
- value = refObject.eGet(sf, false);
- if (value != null) {
- if (sf.isMany()) {
- Iterator j = ((InternalEList) value).basicIterator();
- while (j.hasNext()) {
- proxy = (InternalEObject) j.next();
- if (proxy.eIsProxy())
- proxies.add(proxy);
- }
- } else if (((InternalEObject) value).eIsProxy())
- proxies.add(value);
- }
- }
- }
-
- protected static void resolveProxies(EObject refObject) {
- if (refObject != null) {
- resolveNonContainedProxies(refObject);
- resolveContainedProxies(refObject);
- }
- }
-
- /**
- * Return an existing context base on <code>aProject</code>.
- *
- * @param aProject
- * @return the context base for the project or <code>null</code> if none.
- *
- * @since 1.0.0
- */
- public static EMFWorkbenchContextBase getEMFContext(IProject aProject) {
- return EMFWorkbenchContextFactory.INSTANCE.getEMFContext(aProject);
- }
-
- /**
- * Create a resource from the URI. The URI must contain the project name, either as the first segment, or if in platform resource url protocol.
- * {@link #getResourceSet(URI)}
- *
- * @param uri
- * @return a new resource for the uri or <code>null</code> if not a project uri
- *
- * @since 1.0.0
- */
- public static Resource createResource(URI uri) {
- ResourceSet set = getResourceSet(uri);
- if (set != null)
- return set.createResource(uri);
- return null;
- }
-
- /**
- * Check for a cached Resource for the given URI, if none is found, create a new Resource for with the URI against the proper ResourceSet.
- *
- * @param uri
- * @return resource or <code>null</code> if not a project uri.
- *
- * @since 1.0.0
- */
- public static Resource getExistingOrCreateResource(URI uri) {
- return getExistingOrCreateResource(uri, getResourceSet(uri));
- }
-
- /**
- * Check for a cached Resource for the given URI, if none is found, create a new Resource for with the URI against the given ResourceSet.
- *
- * @param uri
- * @param set
- * @return resource or <code>null</code> if set was <code>null</code>.
- *
- * @since 1.0.0
- */
- public static Resource getExistingOrCreateResource(URI uri, ResourceSet set) {
- Resource res = null;
- if (set != null) {
- res = set.getResource(uri, false);
- if (res == null)
- res = set.createResource(uri);
- }
- return res;
- }
-
- /**
- * Return a new or existing context base on <code>aProject</code>. Allow the <code>contributor</code> to contribute to the new or existing
- * nature prior to returning.
- *
- * @param aProject
- * @param contributor
- * @return the context base for the project.
- *
- * @since 1.0.0
- */
- public static EMFWorkbenchContextBase createEMFContext(IProject aProject, IEMFContextContributor contributor) {
- return EMFWorkbenchContextFactory.INSTANCE.createEMFContext(aProject, contributor);
- }
-
- /**
- * Does the passed URI have the form platform:/resource/... ?
- *
- * @param uri
- * @return <code>true</code> if it is a platform resource protocol.
- *
- * @since 1.0.0
- */
- public static boolean isPlatformResourceURI(URI uri) {
- return JEMUtilPlugin.PLATFORM_PROTOCOL.equals(uri.scheme()) && JEMUtilPlugin.PLATFORM_RESOURCE.equals(uri.segment(0));
- }
-
- /**
- * This api may be used to cache a Resource if it has a URI that is Workspace relative. Return true if it is cached.
- *
- * @param aResource
- * @return <code>true</code> if it was successful to cache.
- *
- * @since 1.0.0
- */
- public static boolean cacheResource(Resource aResource) {
- if (aResource != null) {
- ResourceSet set = getResourceSet(aResource.getURI());
- if (set != null)
- return set.getResources().add(aResource);
- }
- return false;
- }
-
- /**
- * This api is used if you create a new MOF resource and you want to add it to the correct ResourceSet. In order to do that, we need the IProject
- * that you want aResource to be cached within as well as the IPath which is the full path of the location of the new Resource.
- *
- * @param aProject
- * @param aResource
- * @param fullPath
- * @return <code>true</code> if resource was cached.
- *
- * @since 1.0.0
- */
- public static boolean cacheResource(IProject aProject, Resource aResource, IPath fullPath) {
- if (aProject == null || aResource == null || !aProject.isAccessible())
- return false;
- ResourceSet set = getResourceSet(aProject);
- if (set != null) {
- URI converted = set.getURIConverter().normalize(aResource.getURI());
- if (converted != aResource.getURI())
- aResource.setURI(converted);
- return set.getResources().add(aResource);
- }
- return false;
- }
-
- /**
- * Get the path of the project resource relative to the workspace or relative to the list of containers in this project.
- *
- * @param aResource
- * @return path
- *
- * @since 1.0.0
- */
- public static String getActualProjectRelativeURI(IResource aResource) {
- if (aResource == null || !aResource.isAccessible())
- return null;
- IProject project = aResource.getProject();
- IPath path = getPathInProject(project, aResource.getFullPath());
- return path.makeRelative().toString();
- }
-
- /**
- * Return an IPath that can be used to load a Resource using the <code>fullPath</code>. This will be a project relative path.
- *
- * @param project
- * @param fullPath
- * @return path
- *
- * @since 1.0.0
- */
- public static IPath getPathInProject(IProject project, IPath fullPath) {
- List containers = getProjectURIConverterContainers(project);
- if (!containers.isEmpty())
- return getPathFromContainers(containers, fullPath);
- return fullPath;
- }
-
- protected static List getProjectURIConverterContainers(IProject project) {
- EMFWorkbenchContextBase nature = createEMFContext(project, null);
- if (nature != null) {
- WorkbenchURIConverter conv = (WorkbenchURIConverter) nature.getResourceSet().getURIConverter();
- if (conv != null)
- return conv.getInputContainers();
- }
- return Collections.EMPTY_LIST;
- }
-
- /**
- * If this path is contained within one of the listed containers, then return the path relative to the container.
- *
- * @param containers
- * @param fullPath
- * @return path relative to a container, or unchanged path if not in a container.
- *
- * @since 1.0.0
- */
- public static IPath getPathFromContainers(List containers, IPath fullPath) {
- IContainer container = null;
- IPath result;
- int size = containers.size();
- int matching = -1;
- IPath containerPath;
- for (int i = 0; i < size; i++) {
- container = (IContainer) containers.get(i);
- containerPath = container.getFullPath();
- matching = fullPath.matchingFirstSegments(containerPath);
- if (matching > 0 && matching == containerPath.segmentCount()) {
- result = fullPath.removeFirstSegments(matching);
- result = result.makeRelative();
- return result;
- }
- }
- return fullPath;
- }
-
- /**
- * Return true if the <code>uri</code> has its container segments visible from the input containers for the <code>project</code>.
- *
- * @param project
- * @param uri
- * @return <code>true</code> if the uri is visible from the input containers.
- *
- * @since 1.0.0
- */
- public static boolean hasContainerStructure(IProject project, URI uri) {
- if (project != null && uri != null) {
- IPath path = new Path(uri.toString());
- List containers = getProjectURIConverterContainers(project);
- int segmentCount = path.segmentCount();
- IPath containerPath = segmentCount > 1 ? path.removeLastSegments(1) : null;
- IContainer container = null;
- for (int i = 0; i < containers.size(); i++) {
- container = (IContainer) containers.get(i);
- if (!container.isAccessible())
- continue;
- if (segmentCount == 1) {
- if (container == project)
- return true;
- } else if (containerPath != null) {
- IFolder folder = container.getFolder(containerPath);
- if (folder != null && folder.isAccessible())
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Get the resource for the uri.
- *
- * @param uri
- * @return
- *
- * @since 1.0.0
- */
- public static Resource getResource(URI uri) {
- return workspaceURILoader.getResource(null, uri);
- }
-
- /**
- * Return the Resource for the passed IFile without forcing a load.
- *
- * @param aFile
- * @return
- *
- * @since 1.0.0
- */
- public static Resource getResource(IFile aFile) {
- return getResource(aFile, false);
- }
-
- /**
- * Return the Resource for the passed IFile, forcing a load if <code>loadOnDemand</code> says so.
- *
- * @param aFile
- * @param loadOnDemand
- * <code>true</code> will force a load of resource if not loaded.
- * @return
- *
- * @since 1.0.0
- */
- public static Resource getResource(IFile aFile, boolean loadOnDemand) {
- if (aFile != null)
- return getResource(URI.createPlatformResourceURI(aFile.getFullPath().toString()), loadOnDemand);
- return null;
- }
-
- /**
- * Return the Resource for the passed IFile without a load if not loaded.
- *
- * @param aFile
- * @return
- *
- * @since 1.0.0
- */
- public static Resource load(IFile aFile) {
- return getResource(aFile, true);
- }
-
- /**
- * This method will direct the getResource(URI, boolean) call to the correct ProjectResourceSet based on the project name in the URI.
- *
- * @param uri
- * This must be an absolute URI of the form platform:/resource/...
- * @param loadOnDemand
- * <code>true</code> will force the resource to be loaded if not already loaded.
- * @return Resource
- */
- public static Resource getResource(URI uri, boolean loadOnDemand) {
- ResourceSet set = getResourceSet(uri);
- if (set != null)
- return set.getResource(uri, loadOnDemand);
- return null;
- }
-
- /**
- * Return a ResourceSet for the passed URI. The URI should be in the format platform:/resource/{project name}/... or {project name}/... for this
- * api to work.
- *
- * @param uri
- * @return the resource set or <code>null</code> if not of correct form or project doesn't have a resource set.
- *
- * @since 1.0.0
- */
- public static ResourceSet getResourceSet(URI uri) {
- String projectName = null;
- if (isPlatformResourceURI(uri))
- projectName = uri.segment(1);
- else {
- projectName = new org.eclipse.core.runtime.Path(uri.path()).segment(0);
- } //assume project name is first in the URI
- IProject project = getWorkspace().getRoot().getProject(projectName);
- if (project != null && project.isAccessible())
- return getResourceSet(project);
- return null;
- }
-
- /**
- * Return the ResourceSet for the passed IProject.
- *
- * @param project
- * @return resource set
- */
- public static ResourceSet getResourceSet(IProject project) {
- EMFWorkbenchContextBase nat = createEMFContext(project, null);
- if (nat != null)
- return nat.getResourceSet();
- return null;
- }
-
- /**
- * Get the workspace. (just use {@link ResourcesPlugin#getWorkspace()}).
- *
- * @return
- *
- * @since 1.0.0
- */
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- /**
- * Get the project associated with the resource set.
- *
- * @param set
- * @return project or <code>null</code> if resource set not associated with a project.
- *
- * @since 1.0.0
- */
- public static IProject getProject(ResourceSet set) {
- if (set != null) {
- if (set instanceof ProjectResourceSet) {
- ProjectResourceSet pset = (ProjectResourceSet) set;
- return pset.getProject();
- }
- }
- return null;
- }
-
- protected static boolean isRegisteredURIMapping(String href) {
- if (href != null) {
- String file = href;
- int index = href.indexOf('#');
- if (index > -1)
- file = href.substring(0, index);
- return URIConverter.URI_MAP.get(file) != null;
- }
- return false;
- }
-
- /**
- * Remove all of the resources from the resource set and then unload them. Unload forces all of the objects to become proxies so next resolve will
- * reload the resource.
- *
- * @param resources
- * @param aSet
- *
- * @since 1.0.0
- */
- public static void removeAndUnloadAll(List resources, ResourceSet aSet) {
- if (aSet == null || resources == null || resources.isEmpty())
- return;
- aSet.getResources().removeAll(resources);
- Resource res;
- for (int i = 0; i < resources.size(); i++) {
- res = (Resource) resources.get(i);
- res.unload();
- }
- }
-
- /**
- * Turn object into a proxy.
- *
- * @param anObject
- * @return <code>true</code> if object was able to become a proxy.
- *
- * @since 1.0.0
- */
- public static boolean becomeProxy(EObject anObject) {
- if (anObject != null) {
- Resource res = anObject.eResource();
- if (res != null) {
- URI uri = res.getURI();
- ((InternalEObject) anObject).eSetProxyURI(uri.appendFragment(res.getURIFragment(anObject)));
- //anObject.eAdapters().clear();
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return true if the WrappedException is actually a Resource Not Found.
- *
- * @param wrappedEx
- * @return <code>true</code> is exception wrappers a resource not found.
- * @since 1.0.0
- */
- public static boolean isResourceNotFound(WrappedException wrappedEx) {
- Exception excep = wrappedEx.exception();
- while (excep instanceof WrappedException) {
- excep = ((WrappedException) excep).exception();
- }
- return primIsResourceNotFound(excep);
- }
-
- private static boolean primIsResourceNotFound(Exception excep) {
- if (excep instanceof ResourceException) {
- IStatus status = ((ResourceException) excep).getStatus();
- return status.getCode() == IResourceStatus.RESOURCE_NOT_FOUND;
- }
- return false;
- }
-
- /**
- * Return true if the WrappedException is actually a Resource Not Found.
- *
- * @param wrappedEx
- * @return <code>true</code> is exception wrappers a resource not found.
- * @since 1.0.0
- */
- public static boolean isResourceNotFound(Resource.IOWrappedException wrappedEx) {
- return primIsResourceNotFound(wrappedEx.getWrappedException());
- }
-
- /**
- * Return a URI represenation of the platformURI without the leading "platform:/resource/" if present.
- *
- * @param platformURI
- * @return uri
- * @since 1.0.0
- */
- public static URI getNonPlatformURI(URI platformURI) {
- if (isPlatformResourceURI(platformURI)) {
- String uriString = primGetNonPlatformURIString(platformURI);
- return URI.createURI(uriString);
- }
- return platformURI;
- }
-
- /**
- * Return a String represenation of the platformURI without the leading "platform:/resource/" if present.
- *
- * @param platformURI
- * @return
- * @since 1.0.0
- */
- public static String getNonPlatformURIString(URI platformURI) {
- if (isPlatformResourceURI(platformURI)) { return primGetNonPlatformURIString(platformURI); }
- return platformURI.toString();
- }
-
- /*
- * Remove "platform:/resource/" from the front of the platformURI and return the remaining String.
- */
- private static String primGetNonPlatformURIString(URI platformURI) {
- String uriString = platformURI.toString();
- //"platform:/resource/" is 19 characters.
- return uriString.substring(19, uriString.length());
- }
-
- /**
- * Does the passed URI have the form platform:/plugin/... ?
- *
- * @param uri
- * @return <code>true</code> if uri is platform plugin protocol.
- *
- * @since 1.0.0
- */
- public static boolean isPlatformPluginResourceURI(URI uri) {
- return JEMUtilPlugin.PLATFORM_PROTOCOL.equals(uri.scheme()) && JEMUtilPlugin.PLATFORM_PLUGIN.equals(uri.segment(0));
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchURIConverter.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchURIConverter.java
deleted file mode 100644
index e556851..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchURIConverter.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: WorkbenchURIConverter.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.emf.ecore.resource.URIConverter;
-
-/**
- * Implementers of this interface are WorkbenchURI converters. Workbench URI converters handle references to files in the project's containers.
- * This converter is only necessary to resolve old ambiguous workbench URIs.
- * @since 1.0.0
- */
-public interface WorkbenchURIConverter extends URIConverter {
-
- /**
- * Add input container to to the converter.
- *
- * @param aContainer
- *
- * @since 1.0.0
- */
- void addInputContainer(IContainer aContainer);
-
- /**
- * Add list of containers to the converter.
- *
- * @param containers
- * list of <code>IContainer</code>
- *
- * @since 1.0.0
- */
- void addInputContainers(List containers);
-
- /**
- * Get the file relative to a container.
- *
- * @param uri
- * @return file relative to a container or <code>null</code> if not.
- *
- * @since 1.0.0
- */
- IFile getFile(String uri);
-
- /**
- * Get first input container
- *
- * @return first input container or <code>null</code> if none set.
- *
- * @since 1.0.0
- */
- IContainer getInputContainer();
-
- /**
- * Get all input containers.
- *
- * @return all input containers.
- *
- * @since 1.0.0
- */
- List getInputContainers();
-
- /**
- * Get the output container if set.
- *
- * @return output container or <code>null</code> if not set.
- *
- * @since 1.0.0
- */
- IContainer getOutputContainer();
-
- /**
- * Set the output container.
- *
- * @param container
- *
- * @since 1.0.0
- */
- void setOutputContainer(IContainer container);
-
- /**
- * Return an IFile for
- *
- * @aPath. If we have a parent and we do not contain the first segment of the aPath, forward to the parent to retrieve the file.
- * @param aPath
- * @return
- *
- * @since 1.0.0
- */
- IFile getOutputFile(IPath aPath);
-
- /**
- * Get output file with mapping applied.
- *
- * @param uri
- * @return
- *
- * @since 1.0.0
- */
- IFile getOutputFileWithMappingApplied(String uri);
-
- /**
- * Remove input container from list.
- *
- * @param aContainer
- * @return <code>true</code> if removed.
- *
- * @since 1.0.0
- */
- boolean removeInputContainer(IContainer aContainer);
-
- /**
- * Return true if we can retrieve the resource used to open an input stream on.
- *
- * @param aFileName
- * @return <code>true</code> if filename is valid for file stream access.
- * @since 1.0.0
- *
- */
- boolean canGetUnderlyingResource(String aFileName);
-
- /**
- * Is force save relative flag turned on.
- *
- * @return <code>true</code> if force save relative is turned on.
- *
- * @since 1.0.0
- */
- boolean isForceSaveRelative();
-
- /**
- * Set to true if you do not want any path manipulation when creating the output stream..
- *
- * @param forceSaveRelative
- * <code>true</code> to force saves as relative.
- */
- void setForceSaveRelative(boolean forceSaveRelative);
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchURIConverterImpl.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchURIConverterImpl.java
deleted file mode 100644
index 0064422..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchURIConverterImpl.java
+++ /dev/null
@@ -1,513 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: WorkbenchURIConverterImpl.java,v $$
- * $$Revision: 1.3 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.impl.URIConverterImpl;
-
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-/**
- * A default implementation of the WorkbenchURIConverter interface.
- *
- * @since 1.0.0
- */
-public class WorkbenchURIConverterImpl extends URIConverterImpl implements WorkbenchURIConverter {
-
- private final static IWorkspaceRoot WORKSPACE_ROOT = URIConverterImpl.workspaceRoot;
- private final static String WORKSPACE_ROOT_LOCATION = WORKSPACE_ROOT.getLocation().toString();
-
- private static final String FILE_PROTOCOL = "file"; //$NON-NLS-1$
-
- private static final IPath INVALID_PATH = new Path("!!!!~!!!!"); //$NON-NLS-1$
-
- private static final IFile INVALID_FILE = WORKSPACE_ROOT.getFile(INVALID_PATH.append(INVALID_PATH));
-
- //Used to avoid trying to fixup the URI when getting the
- //OutputStream
- protected boolean forceSaveRelative = false;
-
- protected List inputContainers;
-
- protected IContainer outputContainer;
-
- protected ResourceSetWorkbenchSynchronizer resourceSetSynchronizer;
-
- /*
- * KLUDGE: We need to know the meta data area. This is so that any uri that starts with the metadata directory
- * is considered a file uri and NOT a workspace uri. The metadata is where plugin's store their working data.
- * It is not part of the workspace root.
- *
- * There is no request for simply the metadata area. The log file is in the metadata directory. So we will
- * get the log file location and just remove the log file name. That should leave us with the metadata directory
- * only. If Eclipse ever decides to move it from here, this will no longer work. But it hasn't moved in three
- * versions.
- *
- * @since 1.1.0
- */
- static protected final String METADATA_LOCATION = Platform.getLogFileLocation().removeLastSegments(1).toString();
-
- /**
- * Default converter constructor, no containers.
- *
- *
- * @since 1.0.0
- */
- public WorkbenchURIConverterImpl() {
- super();
- }
-
- /**
- * Construct with an input container.
- *
- * @param anInputContainer
- *
- * @since 1.0.0
- */
- public WorkbenchURIConverterImpl(IContainer anInputContainer) {
- this(anInputContainer, (ResourceSetWorkbenchSynchronizer) null);
- }
-
- /**
- * Construct with an input container and a synchronzier.
- *
- * @param aContainer
- * @param aSynchronizer
- *
- * @since 1.0.0
- */
- public WorkbenchURIConverterImpl(IContainer aContainer, ResourceSetWorkbenchSynchronizer aSynchronizer) {
- this(aContainer, null, aSynchronizer);
- }
-
- /**
- * Construct with an input container and an output container.
- *
- * @param anInputContainer
- * @param anOutputContainer
- *
- * @since 1.0.0
- */
- public WorkbenchURIConverterImpl(IContainer anInputContainer, IContainer anOutputContainer) {
- this(anInputContainer, anOutputContainer, null);
- }
-
- /**
- * Construct with an input container, output container, and a synchronizer.
- *
- * @param anInputContainer
- * @param anOutputContainer
- * @param aSynchronizer
- *
- * @since 1.0.0
- */
- public WorkbenchURIConverterImpl(IContainer anInputContainer, IContainer anOutputContainer, ResourceSetWorkbenchSynchronizer aSynchronizer) {
- addInputContainer(anInputContainer);
- setOutputContainer(anOutputContainer);
- resourceSetSynchronizer = aSynchronizer;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#addInputContainer(org.eclipse.core.resources.IContainer)
- */
- public void addInputContainer(IContainer aContainer) {
- if (aContainer != null && !getInputContainers().contains(aContainer))
- getInputContainers().add(aContainer);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#addInputContainers(java.util.List)
- */
- public void addInputContainers(List containers) {
- for (int i = 0; i < containers.size(); i++) {
- addInputContainer((IContainer) containers.get(i));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#removeInputContainer(org.eclipse.core.resources.IContainer)
- */
- public boolean removeInputContainer(IContainer aContainer) {
- return getInputContainers().remove(aContainer);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#getInputContainers()
- */
- public List getInputContainers() {
- if (inputContainers == null)
- inputContainers = new ArrayList();
- return inputContainers;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#getInputContainer()
- */
- public IContainer getInputContainer() {
- if (!getInputContainers().isEmpty())
- return (IContainer) getInputContainers().get(0);
- else
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#getOutputContainer()
- */
- public IContainer getOutputContainer() {
- if (outputContainer == null)
- outputContainer = getInputContainer();
- return outputContainer;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#setOutputContainer(org.eclipse.core.resources.IContainer)
- */
- public void setOutputContainer(IContainer newOutputContainer) {
- outputContainer = newOutputContainer;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#getOutputFile(org.eclipse.core.runtime.IPath)
- */
- public IFile getOutputFile(IPath aPath) {
- IFile file = null;
- if (getOutputContainer() != null) {
- if (forceSaveRelative)
- return primGetOutputFile(aPath);
- file = getOutputFileForPathWithContainerSegments(aPath);
- if (file != null)
- return file;
- else
- return primGetOutputFile(aPath);
- }
- return file;
- }
-
- protected IFile primGetOutputFile(IPath aPath) {
- return primGetFile(getOutputContainer(), aPath);
- }
-
- protected IFile getOutputFileForPathWithContainerSegments(IPath aPath) {
- IContainer out = getOutputContainer();
- return getFileForPathWithContainerSegments(aPath, out, false);
- }
-
- protected IFile getFileForPathWithContainerSegments(IPath aPath, IContainer container, boolean testExists) {
- IPath containerPath = null;
- IFile file = null;
- if (testExists) {
- containerPath = container.getProjectRelativePath();
- if (!containerPath.isEmpty()) {
- file = getFileForMatchingPath(aPath, containerPath, container);
- if (file != null && file.exists())
- return file;
- }
- }
- containerPath = container.getFullPath();
- file = getFileForMatchingPath(aPath, containerPath, container);
- return file;
- }
-
- protected IFile getFileForMatchingPath(IPath containerPath, IPath sourcePath, IContainer container) {
- int matches = 0;
- matches = containerPath.matchingFirstSegments(sourcePath);
- if (matches > 0 && matches == sourcePath.segmentCount()) {
- IPath loadPath = containerPath.removeFirstSegments(matches);
- return primGetFile(container, loadPath);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#getFile(java.lang.String)
- */
- public IFile getFile(String uri) {
- return getFile(new Path(uri));
- }
-
- /**
- * Get the file from the path.
- *
- * @param path
- * @return
- * @see WorkbenchURIConverter#getFile(String)
- * @since 1.0.0
- */
- public IFile getFile(IPath path) {
- IFile file = null;
- if (getInputContainer() != null) {
- path = path.makeRelative();
- java.util.Iterator it = getInputContainers().iterator();
- while (it.hasNext()) {
- IContainer con = (IContainer) it.next();
- file = getInputFile(con, path);
- if (file != null && file.exists())
- return file;
- }
- }
- if (file == null)
- return INVALID_FILE;
- return file;
- }
-
- /**
- * Get output file from string path.
- *
- * @param uri
- * @return
- *
- * @see WorkbenchURIConverter#getOutputFile(IPath)
- * @since 1.0.0
- */
- public IFile getOutputFile(String uri) {
- return getOutputFile(new Path(uri));
- }
-
- /**
- * Get the input file from the container and path.
- *
- * @param con
- * @param path
- * @return
- *
- * @since 1.0.0
- */
- public IFile getInputFile(IContainer con, IPath path) {
- IFile file = null;
- if (WORKSPACE_ROOT.equals(con) && path.segmentCount() < 2)
- path = INVALID_PATH.append(path);
- file = primGetFile(con, path);
- if (file == null || !file.exists())
- file = getFileForPathWithContainerSegments(path, con, true);
- return file;
- }
-
- protected IFile primGetFile(IContainer container, IPath path) {
- try {
- return container.getFile(path);
- } catch (IllegalArgumentException ex) {
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#canGetUnderlyingResource(java.lang.String)
- */
- public boolean canGetUnderlyingResource(String aFileName) {
- IFile file = getFile(aFileName);
- return file != null && file.exists();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#isForceSaveRelative()
- */
- public boolean isForceSaveRelative() {
- return forceSaveRelative;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#setForceSaveRelative(boolean)
- */
- public void setForceSaveRelative(boolean forceSaveRelative) {
- this.forceSaveRelative = forceSaveRelative;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.resource.URIConverter#normalize(org.eclipse.emf.common.util.URI)
- */public URI normalize(URI uri) {
- URI result = uri;
- String fragment = null;
- if (uri.hasFragment()) {
- fragment = uri.fragment();
- result = uri.trimFragment();
- }
- result = getInternalURIMap().getURI(result);
- if (WorkbenchResourceHelperBase.isPlatformResourceURI(result))
- return appendFragment(result, fragment);
- if (WorkbenchResourceHelperBase.isPlatformPluginResourceURI(result)) {
- URI normalized = normalizePluginURI(result, fragment);
- return (normalized != null) ? normalized : uri;
- }
- String protocol = result.scheme();
- URI fileSearchURI = null;
- if (protocol == null) {
- fileSearchURI = normalizeEmptyProtocol(result, fragment);
- if (fileSearchURI != null)
- return fileSearchURI;
- } else if (FILE_PROTOCOL.equals(protocol)) {
- fileSearchURI = normalizeFileProtocol(result, fragment);
- if (fileSearchURI != null)
- return fileSearchURI;
- } else if (JEMUtilPlugin.WORKSPACE_PROTOCOL.equals(protocol))
- return normalizeWorkspaceProtocol(result, fragment);
- return super.normalize(uri);
- }
-
- /*
- * Resolves a plugin format into the actual.
- */
- protected URI normalizePluginURI(URI uri, String fragment) {
- if (uri.segmentCount() < 2)
- return uri; // Invalid, just let it go on.
- // See if already normalized.
- int u_scoreNdx = uri.segment(1).lastIndexOf('_');
- if (u_scoreNdx != -1) {
- // Not normalized. Remove the version to make it normalized.
- String[] segments = uri.segments();
- segments[1] = segments[1].substring(0, u_scoreNdx);
- return URI.createHierarchicalURI(uri.scheme(), uri.authority(), uri.device(), segments, uri.query(), fragment);
- } else
- return uri;
- }
-
- protected URI normalizeWorkspaceProtocol(URI aWorkspaceURI, String fragment) {
- URI result;
- String uriString = aWorkspaceURI.toString();
- uriString = uriString.substring(JEMUtilPlugin.WORKSPACE_PROTOCOL.length() + 1);
- result = URI.createPlatformResourceURI(uriString);
- if (fragment != null)
- result = appendFragment(aWorkspaceURI, fragment);
- return result;
- }
-
- protected URI normalizeEmptyProtocol(URI aFileUri, String fragment) {
- //Make the relative path absolute and return a platform URI.
- IPath path = new Path(aFileUri.toString());
- return normalizeToWorkspaceURI(path, fragment);
- }
-
- private URI normalizeToWorkspaceURI(IPath path, String fragment) {
- URI result = null;
- IFile file = getFile(path);
- if (file == null || !file.exists())
- file = getOutputFile(path);
- if (file != null) {
- result = URI.createPlatformResourceURI(file.getFullPath().toString());
- result = appendFragment(result, fragment);
- }
- return result;
- }
-
- protected URI normalizeFileProtocol(URI aFileUri, String fragment) {
- URI result = null;
- //Make the relative path absolute and return a platform URI.
- String devicePath = aFileUri.devicePath();
- //Test for workspace location.
- if (!devicePath.startsWith(METADATA_LOCATION) &&
- devicePath.startsWith(WORKSPACE_ROOT_LOCATION) && devicePath.length() > WORKSPACE_ROOT_LOCATION.length()) {
- //test for workspace location
- result = normalizeToWorkspaceURI(new Path(devicePath.substring(WORKSPACE_ROOT_LOCATION.length())), fragment);
- } else if (aFileUri.isRelative()) {
- result = normalizeToWorkspaceURI(new Path(aFileUri.toString()), fragment);
- } else {
- result = aFileUri;
- }
- return result;
- }
-
- protected URI appendFragment(URI result, String fragment) {
- if (fragment != null)
- return result.appendFragment(fragment);
- else
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#getOutputFileWithMappingApplied(java.lang.String)
- */
- public IFile getOutputFileWithMappingApplied(String uri) {
- URI converted = getInternalURIMap().getURI(URI.createURI(uri));
- return getOutputFile(new Path(converted.toString()));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.resource.impl.URIConverterImpl#createPlatformResourceOutputStream(java.lang.String)
- */
- public OutputStream createPlatformResourceOutputStream(String platformResourcePath) throws IOException {
- IFile file = WORKSPACE_ROOT.getFile(new Path(platformResourcePath));
- ProjectUtilities.ensureContainerNotReadOnly(file);
- return new WorkbenchByteArrayOutputStream(file, resourceSetSynchronizer);
- }
-
- protected URI getContainerRelativeURI(IFile aFile) {
- IPath path = WorkbenchResourceHelperBase.getPathFromContainers(inputContainers, aFile.getFullPath());
- if (path != null)
- return URI.createURI(path.toString());
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.resource.impl.URIConverterImpl#createPlatformResourceInputStream(java.lang.String)
- */
- public InputStream createPlatformResourceInputStream(String platformResourcePath) throws IOException {
- IFile file = WORKSPACE_ROOT.getFile(new Path(platformResourcePath));
- try {
- if (!file.isLocal(IResource.DEPTH_ONE) || !file.isSynchronized(IResource.DEPTH_ONE)) {
- try {
- File iofile = file.getFullPath().toFile();
- if (iofile.exists() || file.exists())
- file.refreshLocal(IResource.DEPTH_ONE, null);
- } catch (CoreException ce) {
- if (ce.getStatus().getCode() != IResourceStatus.WORKSPACE_LOCKED)
- throw ce;
- }
- }
- return file.getContents();
- } catch (CoreException exception) {
- throw new Resource.IOWrappedException(exception);
- }
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/nature/EMFNature.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/nature/EMFNature.java
deleted file mode 100644
index f7f288a..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/nature/EMFNature.java
+++ /dev/null
@@ -1,554 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: EMFNature.java,v $$
- * $$Revision: 1.4 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench.nature;
-
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.emf.common.util.*;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.xmi.XMLParserPool;
-import org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl;
-
-import org.eclipse.jem.internal.util.emf.workbench.nature.EMFNatureRegistry;
-import org.eclipse.jem.util.emf.workbench.*;
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-
-/**
- * The base EMFNature.
- * <p>
- * This is expected to be subclassed by clients, but there are default subclasses available.
- * </p>
- *
- * @since 1.0.0
- */
-public abstract class EMFNature implements IProjectNature, IEMFContextContributor {
-
- protected IProject project;
-
- protected EMFWorkbenchContextBase emfContext;
-
- protected boolean hasConfigured = false;
-
- public static XMLParserPool SHARED_PARSER_POOL = new XMLParserPoolImpl();
-
- public EMFNature() {
- super();
- }
-
- /**
- * Add the nature id to the project.
- *
- * @param proj
- * @param natureId
- * @throws CoreException
- *
- * @since 1.0.0
- */
- protected static void addNatureToProject(IProject proj, String natureId) throws CoreException {
- ProjectUtilities.addNatureToProject(proj, natureId);
- }
-
- /**
- * Configures the project with this nature. This is called by <code>IProject.addNature</code> and should not be called directly by clients. The
- * nature extension id is added to the list of natures on the project by <code>IProject.addNature</code>, and need not be added here.
- *
- * <p>
- * All subtypes must call super. The better way for subtypes is to override primConfigure instead.
- * </p>
- *
- * @throws CoreException
- * @since 1.0.0
- */
- public void configure() throws org.eclipse.core.runtime.CoreException {
- if (!hasConfigured) {
- hasConfigured = true;
- primConfigure();
- }
- }
-
- /**
- * Called from configure the first time configure is called on the nature. Default is do nothing. Subclasses should override and add in their own
- * configuration.
- *
- * @throws org.eclipse.core.runtime.CoreException
- *
- * @since 1.0.0
- */
- protected void primConfigure() throws org.eclipse.core.runtime.CoreException {
-
- }
-
- /**
- * Create an EMF context for the project.
- *
- * @throws CoreException
- *
- * @since 1.0.0
- */
- protected void createEmfContext() throws CoreException {
- WorkbenchResourceHelperBase.createEMFContext(getProject(), this);
- }
-
- /**
- * Create a folder relative to the project based on aProjectRelativePathString.
- *
- * @param aProjectRelativePathString
- * @return
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public IFolder createFolder(String aProjectRelativePathString) throws CoreException {
- if (aProjectRelativePathString != null && aProjectRelativePathString.length() > 0)
- return createFolder(new Path(aProjectRelativePathString));
- return null;
- }
-
- /**
- * Create a folder relative to the project based on aProjectRelativePathString.
- *
- * @param aProjectRelativePath
- * @return
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public IFolder createFolder(IPath aProjectRelativePath) throws CoreException {
- if (aProjectRelativePath != null && !aProjectRelativePath.isEmpty()) {
- IFolder folder = getWorkspace().getRoot().getFolder(getProjectPath().append(aProjectRelativePath));
- if (!folder.exists()) {
- ProjectUtilities.ensureContainerNotReadOnly(folder);
- folder.create(true, true, null);
- }
- return folder;
- }
- return null;
- }
-
- /**
- * Removes this nature from the project, performing any required deconfiguration. This is called by <code>IProject.removeNature</code> and
- * should not be called directly by clients. The nature id is removed from the list of natures on the project by
- * <code>IProject.removeNature</code>, and need not be removed here.
- *
- * @throws CoreException
- * @since 1.0.0
- */
- public void deconfigure() throws org.eclipse.core.runtime.CoreException {
- emfContext = null;
- }
-
- /**
- * Return true if the IFile with the given name exists in this project.
- *
- * @param aFileName
- * filename can be relative to one of the input file paths for the WorkbenchURIConverter.
- * @return <code>true</code> if filename exists in this project
- *
- * @since 1.0.0
- */
- public boolean fileExists(String aFileName) {
- if (aFileName == null)
- return false;
-
- IPath path = new Path(aFileName);
- if (path.isAbsolute())
- return ResourcesPlugin.getWorkspace().getRoot().getFile(path).exists();
- else
- return getWorkbenchURIConverter().canGetUnderlyingResource(aFileName);
- }
-
- /**
- * Get the resource set for the project
- *
- * @return
- *
- * @since 1.0.0
- */
- public ResourceSet getResourceSet() {
- return getEmfContextBase().getResourceSet();
- }
-
- /**
- * Returns the EMF root folder for the project. Defaults to the project. Subclasses can override.
- *
- * @return EMF root folder for the project.
- *
- * @since 1.0.0
- */
- public IContainer getEMFRoot() {
- return getProject();
- }
-
- /**
- * Used for optimizations; answers whether a mof context for this nature has exists yet
- *
- * @deprecated use hasResourceSet();
- * @since 1.0.0
- */
- public boolean hasContext() {
- return hasResourceSet();
- }
-
- /**
- * Is there a resource set yet for the project.
- *
- * @return <code>true</code> if there is a resource set for the project.
- *
- * @since 1.0.0
- */
- public boolean hasResourceSet() {
- return emfContext != null && emfContext.hasResourceSet();
- }
-
- /**
- * Lazy initializer; for migration of existing workspaces where configure will never get called.
- *
- * @return context base for the project.
- *
- * @since 1.0.0
- */
- protected EMFWorkbenchContextBase getEmfContextBase() {
- if (emfContext == null) {
- try {
- createEmfContext();
- } catch (CoreException ex) {
- Logger.getLogger().logError(ex);
- }
- }
- return emfContext;
- }
-
- /**
- * Get the IFile with the given name if it is in this project.
- *
- * @param aFileName
- * filename can be relative to one of the input file paths for the WorkbenchURIConverter.
- * @return file it it is in this project, or <code>null</code> if it doesn't.
- *
- * @since 1.0.0
- */
- public IFile getFile(String aFileName) {
- return getWorkbenchURIConverter().getFile(aFileName);
- }
-
- /**
- * Return the nature's ID.
- *
- * @return nature id
- *
- * @since 1.0.0
- */
- public abstract String getNatureID();
-
- /**
- * Return the ID of the plugin that this nature is contained within.
- *
- * @return
- *
- * @since 1.0.0
- */
- protected abstract String getPluginID();
-
- /**
- * Returns the project to which this project nature applies.
- *
- * @return the project handle
- * @since 1.0.0
- */
- public org.eclipse.core.resources.IProject getProject() {
- return project;
- }
-
- /**
- * Return the full path of the project.
- *
- * @return full project path (relative to workspace)
- * @since 1.0.0
- */
- public IPath getProjectPath() {
- return getProject().getFullPath();
- }
-
- /**
- * Get the server property of the project from the supplied key
- *
- * @param key
- * java.lang.String
- * @deprecated we cannont use persistent properties because they are not stored in the repository
- * @since 1.0.0
- */
- protected String getProjectServerValue(String key) {
- if (key == null)
- return null;
- try {
- QualifiedName wholeName = qualifiedKey(key);
- return getProject().getPersistentProperty(wholeName);
- } catch (CoreException exception) {
- //If we can't find it assume it is null
- exception.printStackTrace();
- return null;
- }
- }
-
- /**
- * Get WorkbenchURIConverter for this project.
- * <p>
- * This method assumes the URIConverter on the ResourceSet is the one that was created for the ResourceSet on behalf of this nature runtime.
- * </p>
- *
- * @return
- *
- * @since 1.0.0
- */
- protected WorkbenchURIConverter getWorkbenchURIConverter() {
- return (WorkbenchURIConverter) getResourceSet().getURIConverter();
- }
-
- public IWorkspace getWorkspace() {
- return getProject().getWorkspace();
- }
-
- /**
- * @deprecated use getResource(URI)
- */
- public Resource getXmiResource(String uri) {
- return getResource(URI.createURI(uri));
- }
-
- /**
- * Get the resource for this uri. It will use the resource set of the project to find it. It will load if not already loaded.
- *
- * @param uri
- * @return resource or <code>null</code> if resource is not found.
- *
- * @since 1.0.0
- */
- public Resource getResource(URI uri) {
- try {
- return getResourceSet().getResource(uri, true);
- } catch (WrappedException ex) {
- if (!WorkbenchResourceHelperBase.isResourceNotFound(ex))
- throw ex;
- }
- return null;
- }
-
- /**
- * @deprecated use getResourceSet()
- */
- public ResourceSet getXmiResourceSet() {
- return getResourceSet();
- }
-
- /**
- * Make sure that all dependent components are initialized before creating the ResourceSet.
- */
- protected void initializeDependentComponents() {
- //com.ibm.etools.java.init.JavaInit.init();
- }
-
- /**
- * @deprecated use createResource(URI)
- */
- public Resource makeXmiResource(String uri) {
- return createResource(URI.createURI(uri));
- }
-
- /**
- * @deprecated use createResource(URI)
- */
- public Resource makeXmiResource(String uri, EList anExtent) {
- Resource res = makeXmiResource(uri);
- if (res != null)
- res.getContents().addAll(anExtent);
- return res;
- }
-
- /**
- * Create the resource for this uri. It will use the resource set of the project to create it.
- *
- * @param uri
- * @return resource
- *
- * @since 1.0.0
- */
- public Resource createResource(URI uri) {
- return getResourceSet().createResource(uri);
- }
-
- /*
- * Return the QualifedValue for key for storage in the repository. The key is qualifed with the package name to avoid collision. @return
- * QualifedName @param key java.lang.String
- */
- private QualifiedName qualifiedKey(String key) {
- return new QualifiedName(getPluginID(), key);
- }
-
- /**
- * Register the given nature id as an EMFNature.
- *
- * @param natureID
- *
- * @since 1.0.0
- */
- public static void registerNatureID(String natureID) {
- EMFNatureRegistry.singleton().REGISTERED_NATURE_IDS.add(natureID);
- }
-
- /**
- * Sets the project to which this nature applies. Used when instantiating this project nature runtime. This is called by
- * <code>IProject.addNature</code> and should not be called directly by clients.
- *
- * @param project
- * the project to which this nature applies
- *
- * @since 1.0.0
- */
- public void setProject(org.eclipse.core.resources.IProject newProject) {
- project = newProject;
- }
-
- /**
- * Set the server property of the project from the supplied value
- *
- * @param key
- * java.lang.String
- * @param value
- * String
- * @deprecated we cannont use persistent properties because they are not stored in the repository
- */
- protected void setProjectServerValue(String key, String value) {
- if (key != null) {
- try {
- QualifiedName wholeName = qualifiedKey(key);
- getProject().setPersistentProperty(wholeName, value);
- } catch (CoreException exception) {
- //If we can't find it assume it is null
- exception.printStackTrace();
- return;
- }
- }
- }
-
- /**
- * Shutdown the EMF nature
- *
- *
- * @since 1.0.0
- */
- public void shutdown() {
- if (getResourceSet() != null)
- ((ProjectResourceSet) getResourceSet()).release();
- }
-
- /**
- * Return a list of EMFNatures based on the natures that have been configured for this project.
- *
- * @return List of EMFNatures
- * @param project
- * @return list of natures configured for the project.
- * @since 1.0.0
- */
- public static List getRegisteredRuntimes(IProject project) {
- List result = null;
- EMFNature nature = null;
- if (project != null && project.isAccessible()) {
- String natureID;
- Iterator it = EMFNatureRegistry.singleton().REGISTERED_NATURE_IDS.iterator();
- while (it.hasNext()) {
- natureID = (String) it.next();
- try {
- nature = (EMFNature) project.getNature(natureID);
- } catch (CoreException e) {
- }
- if (nature != null) {
- if (result == null)
- result = new ArrayList(2);
- result.add(nature);
- }
- }
- }
- return result == null ? Collections.EMPTY_LIST : result;
- }
-
- /**
- * Return a list of nature ids based on the natures that have been configured for this project.
- *
- * @return list of configured nature ids.
- * @param project
- */
- public static List getRegisteredRuntimeIDs(IProject project) {
- List result = null;
- String natureID = null;
- if (project != null && project.isAccessible()) {
- Iterator it = EMFNatureRegistry.singleton().REGISTERED_NATURE_IDS.iterator();
- while (it.hasNext()) {
- natureID = (String) it.next();
- try {
- if (project.hasNature(natureID)) {
- if (result == null)
- result = new ArrayList(2);
- result.add(natureID);
- }
- } catch (CoreException e) {
- }
- }
- }
- return result == null ? Collections.EMPTY_LIST : result;
- }
-
- /**
- * Return if the project has the given nature.
- *
- * @param project
- * @param natureId
- * @return <code>true</code> if project has given nature
- *
- * @since 1.0.0
- */
- public static boolean hasRuntime(IProject project, String natureId) {
- if (project == null || !project.isAccessible())
- return false;
- try {
- return project.hasNature(natureId);
- } catch (CoreException e) {
- return false;
- }
- }
-
- /**
- * Return if the project has any one of the possible given nature ids.
- *
- * @param project
- * @param possibleNatureIds
- * @return <code>true</code> if at least one of the possible natures id is configured for the project.
- *
- * @since 1.0.0
- */
- public static boolean hasRuntime(IProject project, String[] possibleNatureIds) {
- if (project != null) {
- for (int i = 0; i < possibleNatureIds.length; i++) {
- if (hasRuntime(project, possibleNatureIds[i]))
- return true;
- }
- }
- return false;
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/AbstractWorkBenchRenderer.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/AbstractWorkBenchRenderer.java
deleted file mode 100644
index 643c2f9..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/AbstractWorkBenchRenderer.java
+++ /dev/null
@@ -1,457 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $RCSfile: AbstractWorkBenchRenderer.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:04:14 $
- */
-package org.eclipse.jem.util.logger.proxyrender;
-
-import java.util.logging.Level;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.adaptor.EclipseStarter;
-import org.osgi.framework.Bundle;
-
-import org.eclipse.jem.util.logger.proxy.*;
-
-
-/**
- * Base log renderer that logs to the workbench.
- *
- * @since 1.1.0
- */
-public abstract class AbstractWorkBenchRenderer implements ILogRenderer2 {
-
- private boolean fTraceMode = false; // will we actually punch trace messaged or not
-
- private boolean fSettingTrace = false;
-
- protected Bundle fMyBundle = null;
-
- protected Logger fMyLogger = null;
-
- protected ILog fWorkBenchLogger = null;
-
- /**
- * Constructer taking a logger.
- *
- * @param logger
- *
- * @since 1.1.0
- */
- public AbstractWorkBenchRenderer(Logger logger) {
- super();
- fMyLogger = logger;
- fTraceMode = fMyLogger.getTraceMode();
-
- String pluginID = fMyLogger.getPluginID();
- fMyBundle = Platform.getBundle(pluginID);
- if (fMyBundle == null)
- throw new RuntimeException("Invalid Plugin ID"); //$NON-NLS-1$
-
- fWorkBenchLogger = Platform.getLog(fMyBundle);
- setTraceMode(fMyLogger.getTraceMode() || isDebugging(fMyBundle));
- fMyLogger.setRenderer(this);
- }
-
- /*
- * This used to come from the Plugin instance. But in new OSGi, there is not necessarily a Plugin instance. So use the same logic they use.
- */
- private boolean isDebugging(Bundle bundle) {
- String symbolicName = bundle.getSymbolicName();
- if (symbolicName != null) {
- String key = symbolicName + "/debug"; //$NON-NLS-1$
- String value = Platform.getDebugOption(key);
- return value == null ? false : value.equalsIgnoreCase("true"); //$NON-NLS-1$
- }
- return false;
- }
-
- /**
- * Is the console log for eclipse turned on to sysout. If true, then we shouldn't log to console anything already logged because Eclipse would of
- * logged it for us. This comes from the -Declipse.consoleLog="true" which is the default when starting eclipse from PDE.
- */
- protected static final boolean consoleLogOn = "true".equals(System.getProperty(EclipseStarter.PROP_CONSOLE_LOG));
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer#setTraceMode(boolean)
- */
- public void setTraceMode(boolean flag) {
- if (fSettingTrace)
- return; // Do not allow cycles
-
- fSettingTrace = true;
- fTraceMode = flag;
- fMyLogger.setTraceMode(flag);
- fSettingTrace = false;
- }
-
- // The following methods are for historical renderers in case this has been subclassed outside
- // of util.
-
- /**
- * Log a string to the trace.
- *
- * @param param
- * @return
- *
- * @since 1.0.0
- */
- public abstract String log(String param);
-
- /**
- * Default one that log a string to the trace given a level. Default simply passes it to log(String) so that we don't break old subclasses.
- * <p>
- * If loggedToWorkbench is true, then it shouldn't be logged to console if consoleLogOn is true because workbench already logged to console.
- *
- * @param msg
- * @param l
- *
- * @since 1.0.0
- */
- protected void log(String msg, Level l, boolean loggedToWorkbench) {
- log(msg);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer#log(java.lang.String, int)
- */
- public String log(String msg, int type) {
-
- String target = logWorkBench(msg, type);
- if (fTraceMode || target.equals(NOLOG_DESCRIPTION))
- return log(msg);
- else
- return target;
- }
-
- /**
- * Log to workbench, a string of the given level <code>ILogRenderer.LOG_</code>. levels.
- *
- * @param msg
- * @param type
- * @return description of the log's destination e.g., <code>CONSOLE_DESCRIPTION</code>
- *
- * @see ILogRenderer#LOG_ERROR and all of the other log types.
- * @see ILogRenderer#CONSOLE_DESCRIPTION
- * @since 1.0.0
- */
- public String logWorkBench(String msg, int type) {
-
- try {
- int ErrCode;
- if (fWorkBenchLogger != null) {
- switch (type) {
- case (ILogRenderer.LOG_ERROR):
- ErrCode = IStatus.ERROR;
- break;
- case (ILogRenderer.LOG_WARNING):
- ErrCode = IStatus.WARNING;
- break;
- case (ILogRenderer.LOG_INFO):
- ErrCode = IStatus.INFO;
- break;
- case (ILogRenderer.LOG_TRACE):
- ErrCode = IStatus.OK;
- break;
- default:
- throw new RuntimeException("Invalid Log Type"); //$NON-NLS-1$
- }
- Status status = new Status(ErrCode, fMyBundle.getSymbolicName(), IStatus.OK, msg, null);
- fWorkBenchLogger.log(status);
- return WORKBENCH_DESCRIPTION;
- } else
- return NOLOG_DESCRIPTION;
- } catch (Throwable t) {
- return NOLOG_DESCRIPTION;
- }
- }
-
- // Default implentation of the ILogRenderer2 interface.
- protected boolean isLogging(Level level) {
- return fTraceMode || fMyLogger.isLoggingLevel(level);
- }
-
- private static final int[] STATUS_LEVEL;
-
- private static final Level[] STATUS_LEVEL_LOOKUP;
-
- private static final Level[] LEVEL_STATUS;
-
- static {
- // Status levels that correspond to the log levels, from finest to none, same indexes as from STATUS_LEVEL_LOOKUP.
- STATUS_LEVEL_LOOKUP = new Level[] { Level.INFO, Level.WARNING, Level.SEVERE};
- STATUS_LEVEL = new int[] { IStatus.INFO, IStatus.WARNING, IStatus.ERROR};
-
- // Levels that correspond to the IStatus levels.
- int maxID = Math.max(IStatus.OK, Math.max(IStatus.INFO, Math.max(IStatus.WARNING, IStatus.ERROR)));
- LEVEL_STATUS = new Level[maxID + 1];
- LEVEL_STATUS[IStatus.OK] = Level.FINE;
- LEVEL_STATUS[IStatus.INFO] = Level.INFO;
- LEVEL_STATUS[IStatus.WARNING] = Level.WARNING;
- LEVEL_STATUS[IStatus.ERROR] = Level.SEVERE;
- }
-
- /**
- * Return the Java Level for the status code from the given IStatus.
- *
- * @param status
- * @return the Java Level
- *
- * @since 1.0.0
- */
- protected Level getLogLevel(IStatus status) {
- return LEVEL_STATUS[status.getSeverity()];
- }
-
- /**
- * Return the IStatus status code for the given Java Level.
- *
- * @param logLevel
- * @return the IStatus status code.
- *
- * @since 1.0.0
- */
- protected int getStatusSeverity(Level logLevel) {
- for (int i = 0; i < STATUS_LEVEL_LOOKUP.length; i++) {
- if (STATUS_LEVEL_LOOKUP[i] == logLevel)
- return STATUS_LEVEL[i];
- }
- return IStatus.OK; // Default to ok.
- }
-
- /**
- * Log the string to the workbench for the given level
- *
- * @param msg
- * @param level
- * @return description of the log's destination e.g., <code>CONSOLE_DESCRIPTION</code>
- *
- * @since 1.1.0
- */
- protected String logWorkbench(String msg, Level level) {
- String result = NOLOG_DESCRIPTION;
- // Test again because we could be here simply due to trace mode, in which case we
- // don't want to workbench log it.
- if (fMyLogger.isLoggingLevel(level)) {
- Platform.getLog(fMyBundle).log(new Status(getStatusSeverity(level), fMyBundle.getSymbolicName(), 0, msg, null));
- result = WORKBENCH_DESCRIPTION;
- if (fTraceMode)
- log(msg, level, true);
- } else if (fTraceMode)
- log(msg, level, false);
- return result;
- }
-
- private String getStatusMsg(IStatus s, Level l) {
- if (s.getException() != null)
- return fMyLogger.getGenericMsg(s.toString() + fMyLogger.fLineSeperator + fMyLogger.exceptionToString(s.getException()), l);
- else
- return fMyLogger.getGenericMsg(s.toString(), l);
- }
-
- /**
- * Log the IStatus to the workbench at the given level.
- *
- * @param s
- * @param level
- * @return description of the log's destination e.g., <code>CONSOLE_DESCRIPTION</code>
- *
- * @since 1.0.0
- */
- protected String logWorkbench(IStatus s, Level level) {
- if (level == DEFAULT)
- level = getLogLevel(s);
- String result = NOLOG_DESCRIPTION;
- // Test again because we could be here simply due to trace mode, in which case we
- // don't want to workbench log it.
- if (fMyLogger.isLoggingLevel(level)) {
- Platform.getLog(fMyBundle).log(s);
- result = WORKBENCH_DESCRIPTION;
- if (fTraceMode)
- log(getStatusMsg(s, level), level, true);
- } else if (fTraceMode)
- log(getStatusMsg(s, level), level, false);
- return result;
- }
-
- /**
- * Log to the workbench the Throwable at the given level.
- *
- * @param t
- * @param level
- * @return description of the log's destination e.g., <code>CONSOLE_DESCRIPTION</code>
- *
- * @since 1.0.0
- */
- protected String logWorkbench(Throwable t, Level level) {
- String result = NOLOG_DESCRIPTION;
- // Test again because we could be here simply due to trace mode, in which case we
- // don't want to workbench log it.
- if (fMyLogger.isLoggingLevel(level)) {
- Platform.getLog(fMyBundle).log(new Status(getStatusSeverity(level), fMyBundle.getSymbolicName(), 0, "Exception thrown.", t));
- result = WORKBENCH_DESCRIPTION;
- if (fTraceMode)
- log(fMyLogger.getGenericMsg(fMyLogger.exceptionToString(t), level), level, true);
- } else if (fTraceMode)
- log(fMyLogger.getGenericMsg(fMyLogger.exceptionToString(t), level), level, false);
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(byte, java.util.logging.Level)
- */
- public String log(boolean b, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(b), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(byte, java.util.logging.Level)
- */
- public String log(byte b, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(b), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(char, java.util.logging.Level)
- */
- public String log(char c, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(c), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(double, java.util.logging.Level)
- */
- public String log(double d, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(d), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(float, java.util.logging.Level)
- */
- public String log(float f, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(f), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(int, java.util.logging.Level)
- */
- public String log(int i, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(i), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(long, java.util.logging.Level)
- */
- public String log(long l, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(l), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(java.lang.Object, java.util.logging.Level)
- */
- public String log(Object o, Level level) {
- if (o instanceof IStatus)
- return logWorkbench((IStatus) o, level);
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(o), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(short, java.util.logging.Level)
- */
- public String log(short s, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(s), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(java.lang.Throwable, java.util.logging.Level)
- */
- public String log(Throwable t, Level level) {
- if (t instanceof CoreException)
- return logWorkbench(((CoreException) t).getStatus(), level);
- if (level == DEFAULT)
- level = Level.SEVERE;
- if (isLogging(level)) {
- return logWorkbench(t, level);
- } else
- return NOLOG_DESCRIPTION;
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/ConsoleLogRenderer.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/ConsoleLogRenderer.java
deleted file mode 100644
index 90b2963..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/ConsoleLogRenderer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $RCSfile: ConsoleLogRenderer.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:04:14 $
- */
-package org.eclipse.jem.util.logger.proxyrender;
-
-import java.util.logging.Level;
-
-import org.eclipse.jem.util.logger.proxy.ILogRenderer;
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-
-/**
- * Log renderer to the console.
- *
- * @since 1.0.0
- */
-public class ConsoleLogRenderer extends AbstractWorkBenchRenderer {
-
- /**
- * Constructor taking a logger.
- *
- * @param logger
- *
- * @since 1.0.0
- */
- public ConsoleLogRenderer(Logger logger) {
- super(logger);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxyrender.AbstractWorkBenchRenderer#log(java.lang.String)
- */
- public String log(String msg) {
-
- System.out.println(msg);
- return ILogRenderer.CONSOLE_DESCRIPTION;
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxyrender.AbstractWorkBenchRenderer#log(java.lang.String, java.util.logging.Level, boolean)
- */
- protected void log(String msg, Level l, boolean loggedToWorkbench) {
- if (!loggedToWorkbench || !consoleLogOn) {
- if (l == Level.SEVERE)
- System.err.println(msg);
- else
- System.out.println(msg);
- }
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/DefaultPluginTraceRenderer.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/DefaultPluginTraceRenderer.java
deleted file mode 100644
index bedf203..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/DefaultPluginTraceRenderer.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $RCSfile: DefaultPluginTraceRenderer.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:04:14 $
- */
-package org.eclipse.jem.util.logger.proxyrender;
-
-import java.io.*;
-import java.util.logging.Level;
-
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-
-/**
- * Logger that also logs to a trace file in the plugin's metadata area.
- *
- * @since 1.0.0
- */
-public class DefaultPluginTraceRenderer extends AbstractWorkBenchRenderer {
-
- /**
- * Name of the trace file in the metadata area.
- *
- * @since 1.0.0
- */
- public static final String PluginTraceFileName = "/.log"; //$NON-NLS-1$
-
- private String fTraceFile = null;
-
- private PrintWriter traceFile = null;
-
- /**
- * DefaultUILogRenderer constructor.
- *
- * @param logger
- */
- public DefaultPluginTraceRenderer(Logger logger) {
- super(logger);
-
- fTraceFile = Platform.getStateLocation(fMyBundle).toString() + PluginTraceFileName;
- (new File(fTraceFile)).delete(); // Start from fresh ... do not want to leak on disk space
-
- }
-
- private void closeTraceFile() {
- if (traceFile == null)
- return;
- try {
- traceFile.flush();
- traceFile.close();
- } finally {
- traceFile = null;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxyrender.AbstractWorkBenchRenderer#log(java.lang.String)
- */
- public String log(String msg) {
-
- System.out.println(msg);
-
- openTraceFile();
- if (traceFile != null) {
- traceFile.println(msg);
- closeTraceFile();
- }
- return fTraceFile;
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxyrender.AbstractWorkBenchRenderer#log(java.lang.String, java.util.logging.Level, boolean)
- */
- protected void log(String msg, Level l, boolean loggedToWorkbench) {
- if (!loggedToWorkbench || !consoleLogOn) {
- if (l == Level.SEVERE)
- System.err.println(msg);
- else
- System.out.println(msg);
- }
-
- openTraceFile();
- if (traceFile != null) {
- traceFile.println(msg);
- closeTraceFile();
- }
- }
-
- private void openTraceFile() {
- try {
- traceFile = new PrintWriter(new FileOutputStream(fTraceFile, true));
- } catch (IOException e) {
- // there was a problem opening the log file so log to the console
- traceFile = null;
- }
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/EclipseLogger.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/EclipseLogger.java
deleted file mode 100644
index 4dcc8c9..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/EclipseLogger.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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
- *******************************************************************************/
-/*
- * $RCSfile: EclipseLogger.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:04:14 $
- */
-package org.eclipse.jem.util.logger.proxyrender;
-
-import java.util.logging.Level;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.Bundle;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-/**
- * Get an Eclipse logger. This gets a logger that knows it is for a plugin.
- *
- * For each plugin, the following can be specified in the .option file:
- * {plugin-id}/debug/logTrace
- * The values valid for this are "true", "false", or "default". If true then loggers will be set into
- * trace mode. This means everything logged (even those that are filtered out due to not meeting log level)
- * will be traced out. If the value is "true" they will be traced to the system console.
- * If it is "default" or not set at all, then it will be the value in the "org.eclipse.jem.util/debug/logTrace" .options setting.
- * If not set there, then default value will be false.
- *
- * {plugin-id}/debug/logTraceFile
- * The values valid for this are "true", "false", or "default". If true then loggers will trace to
- * the system console AND to the ".log" file in the plugins work area in the metadata section of the workspace.
- * If "false" then not traced to a trace file.
- * If it is "default" or not set at all, then it will be the value in the "org.eclipse.jem.util/debug/logTraceFile" .options setting.
- * If not set there, then default value will be false.
- *
- * {plugin-id}.debug/logLevel
- * The values valid for this are the names from <code>java.util.logging.Level</code>, and "default". These
- * are the trace cutoff levels to use. For instance, if the level was SEVERE, then only level SEVERE msgs
- * are logged. The rest are skipped. Or if the level was WARNING, then only level SEVERE and WARNING are
- * logged.
- * If it is "default" or not set at all, then it will be the value in the "org.eclipse.jem.util/debug/logLevel" .options setting.
- * If not set there, then default value will be WARNING.
- *
- *
- * @since 1.0.0
- */
-public class EclipseLogger extends Logger {
-
- public static final String DEBUG_TRACE_OPTION = "/debug/logtrace"; //$NON-NLS-1$
- public static final String DEBUG_TRACE_FILE_OPTION = "/debug/logtracefile";
- public static final String DEBUG_LOG_LEVEL_OPTION = "/debug/loglevel"; // The logging level to use when no Hyaedes. (which we don't support at this time).
- public static final String DEFAULT_OPTION = "default"; // If option value is this, then the value from WTP Common plugin options will be used for both logTrace and logLevel.
-
- /**
- * Return a logger based upon the Plugin.
- * @param plugin
- * @return
- *
- * @since 1.0.0
- */
- public static Logger getEclipseLogger(Plugin plugin) {
- return getEclipseLogger(plugin.getBundle());
- }
-
- /**
- * Return a logger based upon the bundle.
- *
- * @param bundle
- * @return
- *
- * @since 1.0.0
- */
- public static Logger getEclipseLogger(Bundle bundle) {
- String id = bundle.getSymbolicName();
- Logger logger = getLoggerIfExists(id);
- if (logger != null)
- return logger;
-
- logger = getLogger(id); // Create one, we will now customize it.
-
- String pluginOption = Platform.getDebugOption(id + DEBUG_TRACE_OPTION);
- if (pluginOption == null || "default".equalsIgnoreCase(pluginOption))
- pluginOption = Platform.getDebugOption(JEMUtilPlugin.getDefault().getBundle().getSymbolicName() + DEBUG_TRACE_OPTION);
- boolean logTrace = "true".equalsIgnoreCase(pluginOption);
-
- pluginOption = Platform.getDebugOption(id + DEBUG_TRACE_FILE_OPTION);
- if (pluginOption == null || "default".equalsIgnoreCase(pluginOption))
- pluginOption = Platform.getDebugOption(JEMUtilPlugin.getDefault().getBundle().getSymbolicName() + DEBUG_TRACE_FILE_OPTION);
- boolean logTraceFile = "true".equalsIgnoreCase(pluginOption);
-
- pluginOption = Platform.getDebugOption(id + DEBUG_LOG_LEVEL_OPTION);
- if (pluginOption == null || "default".equalsIgnoreCase(pluginOption))
- pluginOption = Platform.getDebugOption(JEMUtilPlugin.getDefault().getBundle().getSymbolicName() + DEBUG_LOG_LEVEL_OPTION);
-
- Level logLevel = Level.WARNING;
- if (pluginOption != null) {
- try {
- logLevel = Level.parse(pluginOption);
- } catch (IllegalArgumentException e) {
- }
- }
-
- if (logTrace)
- logger.setTraceMode(true);
- logger.setLevel(logLevel);
- if (!logTraceFile)
- logger.setRenderer(new ConsoleLogRenderer(logger));
- else
- logger.setRenderer(new DefaultPluginTraceRenderer(logger));
-
- return logger;
- }
-
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/IMsgLogger.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/IMsgLogger.java
deleted file mode 100644
index 972ecdd..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/IMsgLogger.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $RCSfile: IMsgLogger.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:04:14 $
- */
-package org.eclipse.jem.util.logger.proxyrender;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-/**
- * Interface for a message logger.
- *
- * @since 1.0.0
- */
-public interface IMsgLogger {
- public Logger getMsgLogger();
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/plugin/JEMUtilPlugin.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/plugin/JEMUtilPlugin.java
deleted file mode 100644
index 9f51ff7..0000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/plugin/JEMUtilPlugin.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $$RCSfile: JEMUtilPlugin.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.plugin;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.*;
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.osgi.framework.Bundle;
-
-import org.eclipse.jem.internal.util.emf.workbench.ProjectResourceSetImpl;
-import org.eclipse.jem.internal.util.emf.workbench.WorkspaceResourceNotifier;
-import org.eclipse.jem.util.emf.workbench.ProjectResourceSet;
-import org.eclipse.jem.util.emf.workbench.ResourceHandler;
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-
-/**
- * Plugin for EMFWorkbench utils.
- *
- * @since 1.0.0
- */
-public class JEMUtilPlugin extends Plugin {
-
- public static final String ID = "org.eclipse.jem.util"; //$NON-NLS-1$
-
- /**
- * Plugin id of this plugin.
- *
- * @since 1.0.0
- */
- public static final String PLUGIN_ID = ID;
-
- /**
- * UI Context extension point.
- *
- * @since 1.0.0
- */
- public static final String UI_CONTEXT_EXTENSION_POINT = "uiContextSensitiveClass"; //$NON-NLS-1$
-
- /**
- * UITester element name.
- *
- * @since 1.0.0
- */
- public static final String UI_TESTER_EXTENSION_POINT = "uiTester"; //$NON-NLS-1$
-
- /**
- * Protocol for workspace
- *
- * @since 1.0.0
- */
- public static final String WORKSPACE_PROTOCOL = "workspace"; //$NON-NLS-1$
-
- /**
- * Protocol for platform uri's. i.e. "platform:/..."
- *
- * @since 1.0.0
- *
- */
- public static final String PLATFORM_PROTOCOL = "platform"; //$NON-NLS-1$
-
- /**
- * Resource indication in platform protocol. Indicates url is for a resource in the workspace. i.e. "platform:/resource/projectname/..."
- *
- * @since 1.0.0
- */
- public static final String PLATFORM_RESOURCE = "resource"; //$NON-NLS-1$
-
- /**
- * Plugin indication in platform protocol. Indicates url is for a file/directory in the plugins area. i.e. "platform:/plugin/pluginid/..."
- *
- * @since 1.0.0
- */
- public static final String PLATFORM_PLUGIN = "plugin"; //$NON-NLS-1$
-
- private static WorkspaceResourceNotifier sharedCache;
-
- private static ResourceSet pluginResourceSet;
-
- private static String[] GLOBAL_LOADING_PLUGIN_NAMES;
-
- private static JEMUtilPlugin DEFAULT;
-
- public JEMUtilPlugin() {
- super();
- DEFAULT = this;
- }
-
- /**
- * Get the workspace. Just use ResourcePlugin.getWorkspace() instead.
- *
- * @return
- *
- * @since 1.0.0
- */
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- /**
- * Get the plugin instance.
- *
- * @return plugin instance.
- *
- * @since 1.0.0
- */
- public static JEMUtilPlugin getDefault() {
- return DEFAULT;
- }
-
- /**
- * Gets the sharedCache.
- * <p>
- * This is not meant to be called by clients.
- * </p>
- *
- * @return a WorkspaceResourceNotifier
- * @since 1.0.0
- */
- public static WorkspaceResourceNotifier getSharedCache() {
- if (sharedCache == null)
- sharedCache = new WorkspaceResourceNotifier();
- return sharedCache;
- }
-
- /**
- * Sets the sharedCache.
- * <p>
- * This is not meant to be called by clients.
- * </p>
- *
- * @param sharedCache
- * The sharedCache to set
- * @since 1.0.0
- */
- public static void setSharedCache(WorkspaceResourceNotifier aSharedCache) {
- sharedCache = aSharedCache;
- }
-
- /**
- * @deprecated use createIsolatedResourceSet(IProject)
- */
- public static ResourceSet createIsolatedResourceSet() {
- return null;
- }
-
- /**
- * Add an Adapter. You can use this api to listen for any shared resource being loaded or removed from any ProjectResourceSet in the Workbench
- * instead of trying to listen to each individual ProjectResourceSet.
- *
- * @param adapter
- *
- * @since 1.0.0
- */
- public static void addWorkspaceEMFResourceListener(Adapter adapter) {
- if (adapter != null && !getSharedCache().eAdapters().contains(adapter))
- getSharedCache().eAdapters().add(adapter);
- }
-
- /**
- * Removes the adapter.
- *
- * @param adapter
- *
- * @see #addWorkspaceEMFResourceListener(Adapter)
- * @since 1.0.0
- */
- public static void removeWorkspaceEMFResourceListener(Adapter adapter) {
- if (adapter != null)
- getSharedCache().eAdapters().remove(adapter);
- }
-
- /**
- * Is this plugin active.
- *
- * @return <code>true</code> if active
- *
- * @since 1.0.0
- */
- public static boolean isActivated() {
- Bundle bundle = Platform.getBundle(ID);
- if (bundle != null)
- return bundle.getState() == Bundle.ACTIVE;
- return false;
- }
-
- /**
- * This method will be called when a WorkbenchContext is instantiated on an EMFNature.
- * <p>
- * This not meant to be called by clients.
- * </p>
- *
- * @param aResourceSet
- *
- * @see plugin.xml#ResourceHandlerExtension extension point.
- * @since 1.0.0
- */
- public void addExtendedResourceHandlers(ProjectResourceSet aResourceSet) {
- if (aResourceSet == null)
- return;
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint pct = registry.getExtensionPoint(getBundle().getSymbolicName(), "ResourceHandlerExtension"); //$NON-NLS-1$
- IExtension[] extension = pct.getExtensions();
- IExtension config;
- for (int l = 0; l < extension.length; ++l) {
- config = extension[l];
- IConfigurationElement[] cElems = config.getConfigurationElements();
- ResourceHandler handler = null;
- for (int i = 0; i < cElems.length; i++) {
- try {
- handler = (ResourceHandler) cElems[i].createExecutableExtension("run"); //$NON-NLS-1$
-
- } catch (Exception ex) {
- handler = null;
- }
- if (handler != null)
- aResourceSet.add(handler);
- }
- }
- }
-
- /**
- * Get the project resource set for the plugin (there is one for the whole system).
- *
- * @return system-wide resource set.
- * @since 1.0.0
- */
- public static ResourceSet getPluginResourceSet() {
- if (pluginResourceSet == null)
- pluginResourceSet = new ProjectResourceSetImpl(null);
- return pluginResourceSet;
- }
-
- /**
- * Set the system-wide resource set.
- *
- * @param set
- * @since 1.0.0
- */
- public static void setPluginResourceSet(ResourceSet set) {
- pluginResourceSet = set;
- }
-
- /**
- * Get the global loading plugin names.
- * <p>
- * This is not meant to be called by clients.
- * </p>
- *
- * @return
- *
- * @since 1.0.0
- */
- public static String[] getGlobalLoadingPluginNames() {
- if (GLOBAL_LOADING_PLUGIN_NAMES == null)
- GLOBAL_LOADING_PLUGIN_NAMES = readGlobalLoadingPluginNames();
- return GLOBAL_LOADING_PLUGIN_NAMES;
- }
-
- /**
- * Get the Logger for this plugin.
- *
- * @return logger for this plugin.
- *
- * @since 1.0.0
- */
- public static Logger getLogger() {
- return Logger.getLogger(ID);
- }
-
- private static String[] readGlobalLoadingPluginNames() {
- IExtensionRegistry reg = Platform.getExtensionRegistry();
- IExtensionPoint exPoint = reg.getExtensionPoint(ID, "globalPluginResourceLoad"); //$NON-NLS-1$
- IExtension[] extensions = exPoint.getExtensions();
- String[] names = new String[extensions.length];
- if (extensions.length > 0) {
- for (int i = 0; i < extensions.length; i++)
- names[i] = extensions[i].getNamespace();
- }
- return names;
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/.classpath b/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/.classpath
deleted file mode 100644
index 065ac06..0000000
--- a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/.cvsignore b/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/.cvsignore
deleted file mode 100644
index c5e82d7..0000000
--- a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/.project b/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/.project
deleted file mode 100644
index 5e29c82..0000000
--- a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.perfmsr.core</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/about.html b/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/about.html
deleted file mode 100644
index f9f238e..0000000
--- a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/about.html
+++ /dev/null
@@ -1,32 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>30th March, 2004</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, "Program" will mean the Content.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the EPL, any Contributions, as defined in the EPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the EPL and can be made available to others under the terms of the EPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the EPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the EPL and such Modifications can be made available to others under the terms of
-the EPL.</p>
-
-<p><b>Version:</b> v20040624a
-
-</body>
-</html>
\ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/build.properties b/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/build.properties
deleted file mode 100644
index 5a8edd7..0000000
--- a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/build.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 2004 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
-###############################################################################
-bin.includes = plugin.xml,\
- plugin.properties,\
- *.jar
-source.perfmsr.jar = src/
diff --git a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/plugin.properties b/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/plugin.properties
deleted file mode 100644
index bb541a2..0000000
--- a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/plugin.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 2004 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
-###############################################################################
-Plugin.name=Performance Monitor
-
diff --git a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/plugin.xml b/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/plugin.xml
deleted file mode 100644
index 596926d..0000000
--- a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/plugin.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.perfmsr.core"
- name="%Plugin.name"
- version="3.0.0"
- provider-name="Eclipse.org"
- class="org.eclipse.perfmsr.core.PerfMsrCorePlugin">
-
- <runtime>
- <library name="perfmsr.jar"><export name="*"/></library>
- </runtime>
-
- <requires>
- <import plugin="org.eclipse.core.runtime"/>
- </requires>
-</plugin>
diff --git a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/src/org/eclipse/perfmsr/core/IPerformanceMonitor.java b/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/src/org/eclipse/perfmsr/core/IPerformanceMonitor.java
deleted file mode 100644
index 9d4fc7a..0000000
--- a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/src/org/eclipse/perfmsr/core/IPerformanceMonitor.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.perfmsr.core;
-
-/**
- * Take snapshots of the various performance counters.
- * ************* This is just a stub of the real interface to get org.eclipse.jem.util
- * to compile. It is not usable by itself. ****************************
- */
-public interface IPerformanceMonitor
-{
- /**
- * These constants control how much information is gathered for a particular snapshot.
- * They are or'ed together and passed into the snapshot method.
- */
- interface Types
- {
- /**
- * 1 - Write out the performance counters from the operating system. These
- * include working set, peak working set, elapsed time, user time, and
- * kernel time.
- */
- int OperatingSystemCounters = 1;
-
- /**
- * 2 - Write out the global performance info. This includes things like the total
- * committed memory for the entire system.
- *
- * This function depends on the GetPerformanceInfo() function being available in
- * the Windows psapi.dll. This is available in XP but is usually not available
- * in Win/2000. If it is not available then this function throws an UnsupportedOperationException.
- */
- int GlobalSystemCounters = 2;
-
- /**
- * 4 - Write out the size of the Java Heap.
- */
- int JavaHeapSize = 4;
-
- /**
- * 8 - Write out how much of the Java heap is being used. This calls the
- * garbage collector so it may skew timing results.
- */
- int JavaHeapUsed = 8;
-
- /**
- * 16 - The plugin startup and size information.
- */
- int PluginInfo = 16;
-
- /** 0xffff - Everything. */
- int All = 0xffff;
- }
-
- /**
- * Add some more "extra" variations.
- *
- * The variations that are in effect are made up of these extra variations plus any variations
- * that may have been set with the setVar() method.
- *
- * @param varList a comma separated list of variations
- */
- public void addVarAppend(String varList);
-
- /**
- * Set the driver name.
- *
- * @param driver a label that identifies the driver that is being tested. If it is a WSAD
- * driver, this will usually be set by the extension.
- */
- public void setDriver(String driver);
-
- /**
- * Set the location of the performance measurement file, that is the place where
- * the measurements are stored.
- *
- * @param logFile the file name of where the log should be written. Usually this is fully qualified
- * path name. For example "x:\logs\timer.xml".
- */
- public void setLogFile(String logFile);
-
- /**
- * Set the performance monitor to be on or off. If it is off then most of the other
- * operations will no-op.
- *
- * The default is for the performance monitor to be off unless it's special environment variable is set.
- * When called from the UI, the UI should call this to make sure that it is on.
- */
- public void setIsOn(boolean isOn);
-
- /**
- * Sets the test case number for this measurement run.
- *
- * @param testd test case identifier
- */
- public void setTestd(int testd);
-
- /**
- * Sets the test case name. If will cause a new test case to be created if it does not already exist.
- *
- * @param testName a simple (short) test case name. In the case of JUnit test cases, it would usually
- * be the JUnit name.
- */
- public void setTestName(String testName);
-
- /**
- * Set the variations that are in effect.
- *
- * @param var a comma delimited string of variation numbers
- */
- public void setVar(String var);
-
- /**
- * Set the upload host
- *
- * @param host DNS name of the upload host
- */
- public void setUploadHost(String host);
-
- /**
- * Set the upload port
- *
- * @param port upload port
- */
- public void setUploadPort(int port);
-
- /**
- * Set the upload userid
- *
- * @param userid
- */
- public void setUploadUserid(String userid);
-
- /**
- * Take a snapshot of some default performance measurements.
- *
- * @param step this identifies the step that the snapshot is for
- */
- void snapshot(int step);
-
- /**
- * Take a snapshot of the selected performance measurements.
- *
- * @param step this identifies the step that the snapshot is for
- *
- * @param types This controls which measurements are selected. It is an or'd together
- * list of the IPerformanceMonitor.Types constants.
- *
- * @see IPerformanceMonitor.Types
- */
- void snapshot(int step, int types);
-
- /**
- * Write the comment to the performance measurement file.
- *
- * @param comment
- */
- void writeComment(String comment);
-
- /**
- * Upload the results to the server. This causes the file to be
- * closed, and the monitor to be placed into the finished state.
- *
- * This method can only be called if the uploadhost, uploadport and uploaduserid
- * have been configured before hand.
- *
- * @param description an optional description (it can be null)
- *
- * @return some status information
- */
- public Upload.Status upload(String description);
-//
-// /**
-// * Upload the results to the server. This causes the file to be
-// * closed, and the monitor to be placed into the finished state.
-// *
-// * @param host the host name that the file is being sent to
-// * @param port the port on the host
-// * @param userid the userid that is doing the upload
-// * @param description an optional description (it can be null)
-// *
-// * @return some status information
-// */
-// Upload.Status upload(String host, int port, String userid, String description);
-
-
-}
diff --git a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/src/org/eclipse/perfmsr/core/PerfMsrCorePlugin.java b/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/src/org/eclipse/perfmsr/core/PerfMsrCorePlugin.java
deleted file mode 100644
index 2b86e9e..0000000
--- a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/src/org/eclipse/perfmsr/core/PerfMsrCorePlugin.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $RCSfile: PerfMsrCorePlugin.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:06:47 $
- */
-package org.eclipse.perfmsr.core;
-
-import org.eclipse.core.runtime.Plugin;
-
-
-/**
- * ************* This is just a stub of the real class to get org.eclipse.jem.util
- * to compile. It is not usable by itself. ****************************
- * @since 1.0.0
- */
-public class PerfMsrCorePlugin extends Plugin {
-
- public static IPerformanceMonitor getPerformanceMonitor(boolean bool) {
- return null;
- }
-
-}
diff --git a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/src/org/eclipse/perfmsr/core/Upload.java b/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/src/org/eclipse/perfmsr/core/Upload.java
deleted file mode 100644
index c412f52..0000000
--- a/plugins/org.eclipse.jem.util/org.eclipse.perfmsr.core.stub/src/org/eclipse/perfmsr/core/Upload.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-/*
- * $RCSfile: Upload.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:06:47 $
- */
-package org.eclipse.perfmsr.core;
-
-
-/**
- * Upload.
- * ************* This is just a stub of the real interface to get org.eclipse.jem.util
- * to compile. It is not usable by itself. ****************************
- */
-public interface Upload {
- public static class Status {
- public boolean success;
- }
-}
diff --git a/plugins/org.eclipse.jem.util/plugin.properties b/plugins/org.eclipse.jem.util/plugin.properties
deleted file mode 100644
index a53db6a..0000000
--- a/plugins/org.eclipse.jem.util/plugin.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 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
-###############################################################################
-#
-# $Source: /cvsroot/webtools/common.move/webtools.common.git/plugins/org.eclipse.jem.util/plugin.properties,v $
-# $Revision: 1.2 $ $Date: 2005/02/15 23:07:45 $
-#
-
-
-pluginName=Java EMF Model Utilities
-providerName = Eclipse.org
diff --git a/plugins/org.eclipse.jem.util/plugin.xml b/plugins/org.eclipse.jem.util/plugin.xml
deleted file mode 100644
index 0eef4ea..0000000
--- a/plugins/org.eclipse.jem.util/plugin.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.jem.util"
- name="%pluginName"
- version="1.1.0"
- provider-name="%providerName"
- class="org.eclipse.jem.util.plugin.JEMUtilPlugin">
-
- <runtime>
- <library name="util.jar">
- <export name="*"/>
- </library>
- </runtime>
- <requires>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.emf.ecore"/>
- <import plugin="org.eclipse.emf.ecore.xmi"/>
- <import plugin="org.eclipse.jdt.core" optional="true"/>
- <import plugin="org.eclipse.perfmsr.core" optional="true"/>
- </requires>
-
-<!-- Extension point to register ResourceHandlers that will always be added to
- new WorkbenchContexts -->
- <extension-point id="ResourceHandlerExtension" name="ResourceHandlerExtension"/>
- <extension-point id="globalPluginResourceLoad" name="Global Plugin Resource Load"/>
- <extension-point id="nature_registration" name="EMF Nature registration"/>
- <extension-point id="internalWorkbenchContextFactory" name="Internal Workbench Context Factory"/>
- <extension-point id="uiContextSensitiveClass" name="UI Context Sensitive Class" schema="schema/uiContextSensitiveClass.exsd"/>
- <extension-point id="uiTester" name="UI Tester" schema="schema/uiTester.exsd"/>
-
-</plugin>
diff --git a/plugins/org.eclipse.jem.util/property_files/emfworkbench.properties b/plugins/org.eclipse.jem.util/property_files/emfworkbench.properties
deleted file mode 100644
index fc94f44..0000000
--- a/plugins/org.eclipse.jem.util/property_files/emfworkbench.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 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
-###############################################################################
-Cannot_Create_Resource_ERROR_=IWAE0001E Cannot create a resource for \" {0} \"
-Unable_to_save_read-only_f_ERROR_=IWAE0004E Unable to save read-only file: {0}
-The_following_resources_ne_UI_=The following resources need to be saved but are currently shared, do you want to save now?
-An_error_occurred_while_sa_ERROR_=IWAE0002E An error occurred while saving.
-EMFWorkbenchContextBase_ERROR_0=IWAE0003E Method not yet implemented.
-EMFWorkbenchContextBase_ERROR_1=IWAE0005E Project can not be null.
-EMFWorkbenchContextBase_ERROR_2=IWAE0006E Attempt to create resource set with null project
-EMFNatureRegistry_ERROR_0=IWAE0007E Duplicate EMF nature registration for id: {0}
-EMFWorkbenchContextFactory_UI_0=The project should not be null.
-EMFWorkbenchContextFactory_UI_1=The project \"{0}\" is not accessible.
-PleaseMigrateYourCodeError_ERROR_0=IWAE0008E Your source code uses obsolete methods. Please consult \n the design documents for guidelines on how to migrating \n your current source code.
-EMF2DOMAdapterImpl_ERROR_0=IWAE0009E Multiple elements exist where only 1 is expected. Node name: {0};
diff --git a/plugins/org.eclipse.jem.util/schema/uiContextSensitiveClass.exsd b/plugins/org.eclipse.jem.util/schema/uiContextSensitiveClass.exsd
deleted file mode 100644
index 7bcbfeb..0000000
--- a/plugins/org.eclipse.jem.util/schema/uiContextSensitiveClass.exsd
+++ /dev/null
@@ -1,136 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.jem.util">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.jem.util" id="uiContextSensitiveClass" name="UI Context Sensitive Class"/>
- </appInfo>
- <documentation>
- Edit models provide a framework for managing a set of EMF resources within a unit of work. For example, a workspace operation may affect a change to multiple EMF resources. Edit models provide basic services such as loads, saves (when necessary), and validate edit for the managed resources. Edit models are reference counted, therefore a single instance of an edit model can be shared by more than one operation or editor. By declaring an edit model, a plugin provider enables other components to contribute resources to be managed by that edit model.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="uiContextSensitiveClass" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="uiContextSensitiveClass">
- <annotation>
- <documentation>
- An extension point that defines an instance of a class and its appropriate context (UI or Headless)
- </documentation>
- </annotation>
- <complexType>
- <attribute name="key" type="string" use="required">
- <annotation>
- <documentation>
- The key that should be used to create an instance of the Context Sensitive super class/interface.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="className" type="string" use="required">
- <annotation>
- <documentation>
- A concrete implementation for either a UI or Headless context.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="context" use="required">
- <annotation>
- <documentation>
- One of "UI" or "Headless"
- </documentation>
- </annotation>
- <simpleType>
- <restriction base="string">
- <enumeration value="UI">
- </enumeration>
- <enumeration value="Headless">
- </enumeration>
- </restriction>
- </simpleType>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 6.0
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- <br>
-&nbsp;&nbsp;&nbsp;&lt;extension<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id="context.Sensitive.Class.workingCopyManager"<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name="Working&nbsp;Copy&nbsp;Manager&nbsp;-&nbsp;UI&nbsp;Context&nbsp;Class"<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;point="com.ibm.wtp.common.ui.ContextSensitiveClass"&gt;<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;uiContextSensitiveClass<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;context="UI"<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key="workingCopyManager"<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;className="com.ibm.wtp.common.ui.WTPUIWorkingCopyManager"&gt;<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/uiContextSensitiveClass&gt;<br>
-&nbsp;&nbsp;&nbsp;&lt;/extension&gt;<br>
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- See <code>org.eclipse.jem.util.UIContextDetermination</code>
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) IBM 2003.
- </documentation>
- </annotation>
-
-</schema>
diff --git a/plugins/org.eclipse.jem.util/schema/uiTester.exsd b/plugins/org.eclipse.jem.util/schema/uiTester.exsd
deleted file mode 100644
index 48d74fc..0000000
--- a/plugins/org.eclipse.jem.util/schema/uiTester.exsd
+++ /dev/null
@@ -1,104 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.jem.util">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.jem.util" id="uiTester" name="UI Tester"/>
- </appInfo>
- <documentation>
- Edit models provide a framework for managing a set of EMF resources within a unit of work. For example, a workspace operation may affect a change to multiple EMF resources. Edit models provide basic services such as loads, saves (when necessary), and validate edit for the managed resources. Edit models are reference counted, therefore a single instance of an edit model can be shared by more than one operation or editor. By declaring an edit model, a plugin provider enables other components to contribute resources to be managed by that edit model.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="uiTester"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="uiTester">
- <annotation>
- <documentation>
- The declaration for an edit model to be used in the workspace.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="className" type="string" use="required">
- <annotation>
- <documentation>
- A unique identifier for the edit model.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 6.0
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
-</schema>
diff --git a/plugins/org.eclipse.wst.common.emf/.classpath b/plugins/org.eclipse.wst.common.emf/.classpath
deleted file mode 100644
index e8d84f8..0000000
--- a/plugins/org.eclipse.wst.common.emf/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="wtpemf/"/>
- <classpathentry kind="src" path="workbench/"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/plugins/org.eclipse.wst.common.emf/.cvsignore b/plugins/org.eclipse.wst.common.emf/.cvsignore
deleted file mode 100644
index 21c0734..0000000
--- a/plugins/org.eclipse.wst.common.emf/.cvsignore
+++ /dev/null
@@ -1,4 +0,0 @@
-bin
-runtime
-temp.folder
-build.xml
diff --git a/plugins/org.eclipse.wst.common.emf/.project b/plugins/org.eclipse.wst.common.emf/.project
deleted file mode 100644
index 5b5f0fe..0000000
--- a/plugins/org.eclipse.wst.common.emf/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.wst.common.emf</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/plugins/org.eclipse.wst.common.emf/build.properties b/plugins/org.eclipse.wst.common.emf/build.properties
deleted file mode 100644
index 3d1eb1a..0000000
--- a/plugins/org.eclipse.wst.common.emf/build.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 2004 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
-###############################################################################
-output.runtime/workbench.jar=bin/
-bin.includes=plugin.xml,\
- runtime/workbench.jar,\
- runtime/wtpemf.jar
-source.runtime/workbench.jar=workbench/
-source.runtime/wtpemf.jar=wtpemf/
-output.runtime/wtpemf.jar=bin/
-jars.compile.order=runtime/wtpemf.jar,\
- runtime/workbench.jar
diff --git a/plugins/org.eclipse.wst.common.emf/plugin.xml b/plugins/org.eclipse.wst.common.emf/plugin.xml
deleted file mode 100644
index 7c2cdff..0000000
--- a/plugins/org.eclipse.wst.common.emf/plugin.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.wst.common.emf"
- name="EMF Utilities"
- version="1.0.0"
- provider-name="IBM"
- description="Provides support and utilities for emf integration into the workbench"
- class="org.eclipse.wst.common.internal.emf.plugin.EcoreUtilitiesPlugin">
-
- <runtime>
- <library name="runtime/wtpemf.jar">
- <export name="*"/>
- </library>
- <library name="runtime/workbench.jar">
- <export name="*"/>
- </library>
- </runtime>
- <requires>
- <import plugin="org.eclipse.emf.ecore.xmi"/>
- <import plugin="org.eclipse.wst.common.frameworks"/>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.core.resources"/>
- </requires>
-
-
- <extension-point id="packageURIMap" name="PackageURIMap"/>
-
-<!-- Need to register the Ecore specific package mappings -->
- <extension
- point="org.eclipse.wst.common.emf.packageURIMap">
- <map
- uri="http://www.eclipse.org/emf/2002/Ecore"
- prefix="ecore">
- </map>
- <map
- uri="http://www.eclipse.org/emf/2002/Mapping"
- prefix="mapping">
- </map>
-<!-- Trick to get Mapping.xmi for MOF5 serialization -->
- <map
- uri="http://www.eclipse.org/emf/2002/Mapping"
- prefix="Mapping">
- </map>
- </extension>
-
- <extension
- point="com.ibm.wtp.common.util.uiContextSensitiveClass">
- <uiContextSensitiveClass
- context="Headless"
- key="rendererFactory"
- className="org.eclipse.wst.common.internal.emf.resource.EMF2DOMRendererFactory">
- </uiContextSensitiveClass>
- </extension>
-
-</plugin>
diff --git a/plugins/org.eclipse.wst.common.emf/prepareforpii.xml b/plugins/org.eclipse.wst.common.emf/prepareforpii.xml
deleted file mode 100644
index 8007604..0000000
--- a/plugins/org.eclipse.wst.common.emf/prepareforpii.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<project name="PrepareForPII" default="main" basedir=".">
-
- <!-- Setup temp variables -->
- <target name="init">
- <property name="nlsDir" value="d:/NLS/Corona/0526"/>
- <property name="plugin" value="com.ibm.wtp.emf"/>
- <property name="plugindir" value="d:/workspaceCorona/${plugin}"/>
- <property name="outputDir" value="${nlsDir}/${plugin}"/>
-
-
- </target>
-
- <!-- Create the destination dir -->
- <target name="nlsDir" depends="init">
- <mkdir dir="${nlsDir}"/>
- </target>
-
- <!-- Create the destination dir -->
- <target name="plugindir" depends="nlsDir">
- <delete dir="${outputDir}"/>
- <mkdir dir="${outputDir}"/>
- </target>
-
- <!-- Move the files to the correct locations in the workspace. -->
- <target name="main" depends="plugindir">
-
- <messageIdGen folderPath = "${plugindir}" componentId = "E" />
-
- <copy todir = "${outputDir}/wtpemf" >
- <fileset dir="${plugindir}/wtpemf">
- <include name="**/*.properties"/>
- </fileset>
- </copy>
-
-
- </target>
-</project>
diff --git a/plugins/org.eclipse.wst.common.emf/workbench/org/eclipse/wst/common/internal/emf/plugin/EcoreUtilitiesPlugin.java b/plugins/org.eclipse.wst.common.emf/workbench/org/eclipse/wst/common/internal/emf/plugin/EcoreUtilitiesPlugin.java
deleted file mode 100644
index 0f04416..0000000
--- a/plugins/org.eclipse.wst.common.emf/workbench/org/eclipse/wst/common/internal/emf/plugin/EcoreUtilitiesPlugin.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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
- *******************************************************************************/
-/*
- * Created on Jun 9, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.wst.common.internal.emf.plugin;
-
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-import org.osgi.framework.BundleContext;
-
-/**
- * @author DABERG
- *
- * To change the template for this generated type comment go to Window>Preferences>Java>Code
- * Generation>Code and Comments
- */
-public class EcoreUtilitiesPlugin extends Plugin {
- public static final String ID = "org.eclipse.wst.common.emf"; //$NON-NLS-1$
-
- /**
- * @param descriptor
- */
- public EcoreUtilitiesPlugin() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.Plugin#startup()
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- RendererFactory.setDefaultHandler(PluginRendererFactoryDefaultHandler.INSTANCE);
- PackageURIMapReader reader = new PackageURIMapReader();
- reader.processExtensions();
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/workbench/org/eclipse/wst/common/internal/emf/plugin/PackageURIMapReader.java b/plugins/org.eclipse.wst.common.emf/workbench/org/eclipse/wst/common/internal/emf/plugin/PackageURIMapReader.java
deleted file mode 100644
index 253ffe3..0000000
--- a/plugins/org.eclipse.wst.common.emf/workbench/org/eclipse/wst/common/internal/emf/plugin/PackageURIMapReader.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.internal.emf.plugin;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.common.internal.emf.resource.CompatibilityPackageMappingRegistry;
-
-/**
- * This reader will read the packageURIMap extension point and populate the
- * CompatibilityPackageMappingRegistry.
- *
- * The packageURIMap will have the following configuration element.
- *
- * <map prefix="somePackagePrefix" uri="somePackageURI"/>
- *
- */
-public class PackageURIMapReader {
- private static final String URI_ATT_NAME = "uri"; //$NON-NLS-1$
- private static final String PREFIX_ATT_NAME = "prefix"; //$NON-NLS-1$
- private static final String EXTENSION_POINT_NAME = "packageURIMap"; //$NON-NLS-1$
-
- /**
- *
- */
- public PackageURIMapReader() {
- super();
- }
-
- private IExtensionPoint getExtensionPoint() {
- IPluginRegistry reg = Platform.getPluginRegistry();
- return reg.getExtensionPoint(EcoreUtilitiesPlugin.ID, EXTENSION_POINT_NAME);
- }
-
- /**
- * Call this method to read and process all of the packageURIMap extensions. *
- */
- public void processExtensions() {
- CompatibilityPackageMappingRegistry reg = CompatibilityPackageMappingRegistry.INSTANCE;
- IExtension[] extensions = getExtensionPoint().getExtensions();
- for (int i = 0; i < extensions.length; i++)
- processExtension(extensions[i], reg);
- }
-
- /**
- * @param extension
- */
- private void processExtension(IExtension extension, CompatibilityPackageMappingRegistry reg) {
- IConfigurationElement[] configs = extension.getConfigurationElements();
- for (int i = 0; i < configs.length; i++)
- processConfiguration(configs[i], reg);
- }
-
- /**
- * @param element
- */
- private void processConfiguration(IConfigurationElement element, CompatibilityPackageMappingRegistry reg) {
- String prefix = element.getAttribute(PREFIX_ATT_NAME);
- String uri = element.getAttribute(URI_ATT_NAME);
- reg.registerPrefixToPackageURI(prefix, uri);
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/workbench/org/eclipse/wst/common/internal/emf/plugin/PluginRendererFactoryDefaultHandler.java b/plugins/org.eclipse.wst.common.emf/workbench/org/eclipse/wst/common/internal/emf/plugin/PluginRendererFactoryDefaultHandler.java
deleted file mode 100644
index d65fbb4..0000000
--- a/plugins/org.eclipse.wst.common.emf/workbench/org/eclipse/wst/common/internal/emf/plugin/PluginRendererFactoryDefaultHandler.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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
- *******************************************************************************/
-/*
- * Created on Dec 1, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.wst.common.internal.emf.plugin;
-
-import org.eclipse.wst.common.internal.emf.resource.EMF2DOMRendererFactoryDefaultHandler;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-import com.ibm.wtp.common.UIContextDetermination;
-
-/**
- * @author schacher
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class PluginRendererFactoryDefaultHandler extends EMF2DOMRendererFactoryDefaultHandler {
-
- static final PluginRendererFactoryDefaultHandler INSTANCE = new PluginRendererFactoryDefaultHandler();
- static final String EXT_POINT_NAME = "rendererFactory"; //$NON-NLS-1$
-
- /**
- *
- */
- protected PluginRendererFactoryDefaultHandler() {
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.EMF2DOMRendererFactoryDefaultHandler#getDefaultRendererFactory()
- */
- public RendererFactory getDefaultRendererFactory() {
- RendererFactory aFactory = (RendererFactory) UIContextDetermination.createInstance(EXT_POINT_NAME);
- return aFactory == null ? super.getDefaultRendererFactory() : aFactory;
- }
-
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/AdapterFactoryDescriptor.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/AdapterFactoryDescriptor.java
deleted file mode 100644
index 3cf75a4..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/AdapterFactoryDescriptor.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.emf.utilities;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-
-public interface AdapterFactoryDescriptor {
-
- public AdapterFactory createAdapterFactory();
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/AdapterFactoryUtil.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/AdapterFactoryUtil.java
deleted file mode 100644
index ea37859..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/AdapterFactoryUtil.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.emf.utilities;
-
-import java.util.List;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.notify.Notifier;
-
-public class AdapterFactoryUtil {
-
- /**
- * Constructor for AdapterFactoryUtil.
- */
- public AdapterFactoryUtil() {
- super();
- }
-
- public static void adaptNew(Notifier newObject, List factories) {
- AdapterFactory fact;
- for (int i = 0; i < factories.size(); i++) {
- fact = (AdapterFactory) factories.get(i);
- fact.adaptNew(newObject, null);
- }
- }
-
- public static void createAdapterFactories(List descriptors, List factories) {
- AdapterFactoryDescriptor desc;
- AdapterFactory adapterFact;
- for (int i = 0; i < descriptors.size(); i++) {
- desc = (AdapterFactoryDescriptor) descriptors.get(i);
- adapterFact = desc.createAdapterFactory();
- if (adapterFact != null)
- factories.add(adapterFact);
- }
- descriptors.clear();
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/CommandContext.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/CommandContext.java
deleted file mode 100644
index 95bd6dc..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/CommandContext.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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
- *******************************************************************************/
-/*
- * Created on Apr 27, 2004
- */
-package org.eclipse.wst.common.emf.utilities;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-
-
-
-/**
- * @author John Mourra
- */
-public class CommandContext implements ICommandContext {
-
- private IProgressMonitor monitor;
- private Map properties;
- private ResourceSet resourceSet;
-
- /**
- * @param monitor
- */
- public CommandContext(IProgressMonitor monitor) {
- this(monitor, null, null);
- }
-
- /**
- * @param monitor
- * @param configurationProperties
- * @param resourceSet
- */
- public CommandContext(IProgressMonitor monitor, Map configurationProperties, ResourceSet resourceSet) {
- this.monitor = monitor;
- this.properties = configurationProperties;
- this.resourceSet = resourceSet;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.ws.rd.command.framework.ICommandContext#getProgressMonitor()
- */
- public IProgressMonitor getProgressMonitor() {
- if (monitor == null)
- monitor = new NullProgressMonitor();
- return monitor;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.ws.rd.command.framework.ICommandContext#getConfigurationProperties()
- */
- public Map getConfigurationProperties() {
- if (properties == null)
- properties = new HashMap();
- return properties;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.ws.rd.command.framework.ICommandContext#getResourceSet()
- */
- public ResourceSet getResourceSet() {
- if (resourceSet == null)
- resourceSet = new ResourceSetImpl();
- return resourceSet;
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/CopyGroup.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/CopyGroup.java
deleted file mode 100644
index ca93f20..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/CopyGroup.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.emf.utilities;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.wst.common.internal.emf.utilities.Association;
-
-/**
- * This class is used to copy a group of RefObjects and/or Resources. This group will ensure that
- * all non-composite relationships are deferred until all Resources and RefObjects are copied. This
- * allows you to make copies of a group of objects that may have non-composite relationships and
- * ensure that these relationships are pointing to the copied object if it is part of the group
- * (either directly or through a containment relationship). Creation date: (12/17/2000 1:21:17 PM)
- *
- * @author: Administrator
- */
-public class CopyGroup {
- protected String defaultIdSuffix;
- protected ResourceSet copyContext;
- protected List resources;
- protected List refObjects;
- protected List copiedResources;
- protected List copiedRefObjects;
- protected boolean preserveIds = false;
-
- /**
- * CopyGroup constructor comment.
- */
- public CopyGroup() {
- super();
- }
-
- /**
- * Insert the method's description here. Creation date: (12/17/2000 1:28:16 PM)
- *
- * @param aRefObject
- * org.eclipse.emf.ecore.EObject
- */
- public boolean add(EObject aRefObject) {
- return add(aRefObject, null);
- }
-
- /**
- * Insert the method's description here. Creation date: (12/17/2000 1:28:16 PM)
- *
- * @param aRefObject
- * org.eclipse.emf.ecore.EObject
- */
- public boolean add(EObject aRefObject, String idSuffix) {
- if (aRefObject != null && !containsRefObject(aRefObject)) {
- getRefObjects().add(createAssociation(aRefObject, idSuffix));
- return true;
- }
- return false;
- }
-
- /**
- * Insert the method's description here. Creation date: (12/17/2000 1:27:32 PM)
- *
- * @param aResources
- * org.eclipse.emf.ecore.resource.Resource
- */
- public void add(Resource aResource) {
- add(aResource, null);
- }
-
- /**
- * Insert the method's description here. Creation date: (12/17/2000 1:27:32 PM)
- *
- * @param aResources
- * org.eclipse.emf.ecore.resource.Resource
- */
- public void add(Resource aResource, String newUri) {
- if (aResource != null)
- getResources().add(createAssociation(aResource, newUri));
- }
-
- /**
- * Insert the method's description here. Creation date: (12/17/2000 1:28:16 PM)
- *
- * @param aRefObject
- * org.eclipse.emf.ecore.EObject
- */
- public void addCopied(EObject aRefObject) {
- if (aRefObject != null)
- getCopiedRefObjects().add(aRefObject);
- }
-
- /**
- * Insert the method's description here. Creation date: (12/17/2000 1:27:32 PM)
- *
- * @param aResources
- * org.eclipse.emf.ecore.resource.Resource
- */
- public void addCopied(Resource aResource) {
- if (aResource != null) {
- getCopiedResources().add(aResource);
- if (getCopyContext() != null)
- getCopyContext().getResources().add(aResource);
- }
- }
-
- protected boolean contains(List associations, Object anObject) {
- if (anObject == null)
- return false;
- int size = associations.size();
- Association assoc;
- for (int i = 0; i < size; i++) {
- assoc = (Association) associations.get(i);
- if (assoc.getKey() == anObject)
- return true;
- }
- return false;
- }
-
- /**
- * Return true if
- *
- * @aRefObject has been added to this group. Creation date: (12/17/2000 1:28:16 PM)
- * @param aRefObject
- * org.eclipse.emf.ecore.EObject
- */
- public boolean containsRefObject(EObject aRefObject) {
- return contains(getRefObjects(), aRefObject);
- }
-
- /**
- * Return true if
- *
- * @aResource has been added to this group. Creation date: (12/17/2000 1:28:16 PM)
- * @param aRefObject
- * org.eclipse.emf.ecore.EObject
- */
- public boolean containsResource(Resource aResource) {
- return contains(getResources(), aResource);
- }
-
- private Association createAssociation(Object key, Object value) {
- return new Association(key, value);
- }
-
- /**
- * Returns a List of RefObjects that were copied. Creation date: (12/17/2000 1:25:46 PM)
- *
- * @return java.util.List
- */
- public java.util.List getCopiedRefObjects() {
- if (copiedRefObjects == null)
- copiedRefObjects = new ArrayList();
- return copiedRefObjects;
- }
-
- /**
- * Returns a List of Resources that were copied. Creation date: (12/17/2000 1:25:46 PM)
- *
- * @return java.util.List
- */
- public java.util.List getCopiedResources() {
- if (copiedResources == null)
- copiedResources = new ArrayList();
- return copiedResources;
- }
-
- /**
- * The context to add all copied resources into. Creation date: (12/17/2000 8:09:45 PM)
- *
- * @return org.eclipse.emf.ecore.resource.ResourceSet
- */
- public org.eclipse.emf.ecore.resource.ResourceSet getCopyContext() {
- return copyContext;
- }
-
- /**
- * Insert the method's description here. Creation date: (12/17/2000 1:44:43 PM)
- *
- * @return java.lang.String
- */
- public java.lang.String getDefaultIdSuffix() {
- return defaultIdSuffix;
- }
-
- /**
- * Should the id be copied in the case where no suffix is specified? Defaults to false
- */
- public boolean getPreserveIds() {
- return preserveIds;
- }
-
- /**
- * Insert the method's description here. Creation date: (12/17/2000 1:25:46 PM)
- *
- * @return java.util.List
- */
- public java.util.List getRefObjects() {
- if (refObjects == null)
- refObjects = new ArrayList();
- return refObjects;
- }
-
- /**
- * Insert the method's description here. Creation date: (12/17/2000 1:25:46 PM)
- *
- * @return java.util.List
- */
- public java.util.List getResources() {
- if (resources == null)
- resources = new ArrayList();
- return resources;
- }
-
- /**
- * Insert the method's description here. Creation date: (12/17/2000 1:25:46 PM)
- *
- * @return java.util.List
- */
- public java.util.List primGetRefObjects() {
- return refObjects;
- }
-
- /**
- * Insert the method's description here. Creation date: (12/17/2000 1:25:46 PM)
- *
- * @return java.util.List
- */
- public java.util.List primGetResources() {
- return resources;
- }
-
- /**
- * Insert the method's description here. Creation date: (12/17/2000 1:28:16 PM)
- *
- * @param aRefObject
- * org.eclipse.emf.ecore.EObject
- * @return boolean
- */
- public boolean remove(EObject aRefObject) {
- if (aRefObject != null && primGetRefObjects() != null) {
- Iterator it = primGetRefObjects().iterator();
- Association association;
- while (it.hasNext()) {
- association = (Association) it.next();
- if (association.getKey() == aRefObject)
- return primGetRefObjects().remove(association);
- }
- }
- return false;
- }
-
- /**
- * Insert the method's description here. Creation date: (12/17/2000 1:27:32 PM)
- *
- * @param aResources
- * org.eclipse.emf.ecore.resource.Resource
- * @return boolean
- */
- public boolean remove(Resource aResource) {
- if (aResource != null && primGetResources() != null) {
- Iterator it = primGetResources().iterator();
- Association association;
- while (it.hasNext()) {
- association = (Association) it.next();
- if (association.getKey() == aResource)
- return primGetResources().remove(association);
- }
- }
- return false;
- }
-
- /**
- * Set the context to add all copied resources into. Creation date: (12/17/2000 8:09:45 PM)
- *
- * @param newCopyContext
- * org.eclipse.emf.ecore.resource.Context
- */
- public void setCopyContext(org.eclipse.emf.ecore.resource.ResourceSet newCopyContext) {
- copyContext = newCopyContext;
- }
-
- /**
- * If an ID suffix is not defined for a EObject that is to be copied, this value will be used.
- * Creation date: (12/17/2000 1:44:43 PM)
- *
- * @param newDefaultIdSuffix
- * java.lang.String
- */
- public void setDefaultIdSuffix(java.lang.String newDefaultIdSuffix) {
- defaultIdSuffix = newDefaultIdSuffix;
- }
-
- /**
- * Should the id be copied in the case where no suffix is specified?
- */
- public void setPreserveIds(boolean value) {
- preserveIds = value;
- }
-
- /**
- * Subclasses should override this method if they require additional processing after the group
- * has been copied.
- *
- * @param copyUtil
- */
- public void postCopy(EtoolsCopyUtility copyUtil) {
- }
-
-}
-
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/DanglingHREFException.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/DanglingHREFException.java
deleted file mode 100644
index ef6a68c..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/DanglingHREFException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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
- *******************************************************************************/
-/*
- * Created on May 12, 2003
- *
- */
-package org.eclipse.wst.common.emf.utilities;
-
-/**
- * Exception thrown when a proxy can not be resolved
- */
-public class DanglingHREFException extends Exception {
-
-
- public DanglingHREFException() {
- super();
- }
-
- /**
- * @param s
- */
- public DanglingHREFException(String s) {
- super(s);
- }
-
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/DefaultOverridableResourceFactoryRegistry.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/DefaultOverridableResourceFactoryRegistry.java
deleted file mode 100644
index 8e8bd41..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/DefaultOverridableResourceFactoryRegistry.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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
- *******************************************************************************/
-/*
- * Created on Mar 14, 2003
- *
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.wst.common.emf.utilities;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.Resource.Factory;
-import org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl;
-
-/**
- * @author DABERG
- *
- * To change this generated comment go to Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class DefaultOverridableResourceFactoryRegistry extends ResourceFactoryRegistryImpl {
- protected static Resource.Factory GLOBAL_FACTORY = Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI(DEFAULT_EXTENSION));
-
- /**
- *
- */
- public DefaultOverridableResourceFactoryRegistry() {
- super();
- }
-
- public Resource.Factory getFactory(URI uri) {
- Object resourceFactory = null;
- if (resourceFactory == null) {
- String protocol = uri.scheme();
- resourceFactory = protocolToFactoryMap.get(protocol);
- if (resourceFactory == null) {
- String extension = uri.fileExtension();
- resourceFactory = extensionToFactoryMap.get(extension);
- if (resourceFactory == null) {
- resourceFactory = delegatedGetFactory(uri);
- if (resourceFactory == GLOBAL_FACTORY) {
- resourceFactory = (Factory) extensionToFactoryMap.get(Resource.Factory.Registry.DEFAULT_EXTENSION);
- if (resourceFactory == null)
- resourceFactory = GLOBAL_FACTORY;
- }
-
- }
- }
- }
-
- return resourceFactory instanceof Resource.Factory.Descriptor ? ((Resource.Factory.Descriptor) resourceFactory).createFactory() : (Resource.Factory) resourceFactory;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl#delegatedGetFactory(org.eclipse.emf.common.util.URI)
- */
- protected Factory delegatedGetFactory(URI uri) {
- return Resource.Factory.Registry.INSTANCE.getFactory(uri);
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/EtoolsCopySession.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/EtoolsCopySession.java
deleted file mode 100644
index 939dd31..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/EtoolsCopySession.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.emf.utilities;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.notify.impl.NotificationImpl;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.xmi.XMLResource;
-
-/**
- * Insert the type's description here. Creation date: (05/04/01 11:25:59 PM)
- *
- * @author: Administrator
- */
-public class EtoolsCopySession extends EtoolsCopyUtility {
- public static final int RESOURCE_COPIED = 500;
- private EtoolsCopyUtility parentCopyUtility;
- private XMLResource currentResource;
- private XMLResource currentCopyResource;
-
- /**
- * EtoolsCopySession constructor comment.
- */
- public EtoolsCopySession(EtoolsCopyUtility aCopyUtility) {
- parentCopyUtility = aCopyUtility;
- setPreserveIds(aCopyUtility.preserveIds());
- setCopyAdapters(aCopyUtility.isCopyAdapters());
- }
-
- /**
- * Copy all Resources and RefObjects within <code>aGroup</code> and add them to
- * <code>aGroup</code>. Non composite references will be deferred until all objects are
- * copied from <code>aGroup</code>.
- *
- * Copy Resources first and then copy RefObjects.
- */
- public void copy(CopyGroup aGroup) {
- if (aGroup != null) {
- copyResources(aGroup);
- copyRefObjects(aGroup);
- executeDeferredCopyActions();
- aGroup.postCopy(this);
- notifyNewResourcesCopied(aGroup);
- }
- }
-
- /**
- * This method should be used if you are only going to copy <code>aRefObject</code> in this
- * copy execution.
- */
- public EObject copy(EObject aRefObject, String idSuffix) {
- EObject copied = containmentCopy(aRefObject, idSuffix);
- executeDeferredCopyActions();
- return copied;
- }
-
- /**
- * This method should be used if you are only going to copy <code>aRefObject</code> in this
- * copy execution. This method only copies <code>aRefObject</code> attributes.
- */
- public EObject copyObject(EObject aRefObject, String idSuffix) {
- EObject copied = containmentCopyObject(aRefObject, idSuffix);
- executeDeferredCopyActions();
- return copied;
- }
-
- /**
- * This method should be used if you are only going to copy <code>aResource</code> in this
- * copy execution. The copied Resource will have a URI equal to <code>newUri</code>.
- */
- public Resource copy(Resource aResource, String newUri) {
- Resource copied = containmentCopy(aResource, newUri);
- executeDeferredCopyActions();
- copyModificationFlag(aResource, copied);
- notifyNewResourceCopied(copied);
- return copied;
- }
-
- protected void notifyNewResourcesCopied(CopyGroup group) {
- List copied = group.getCopiedResources();
- for (int i = 0; i < copied.size(); i++) {
- notifyNewResourceCopied((Resource) copied.get(i));
- }
- }
-
- protected void notifyNewResourceCopied(Resource copied) {
- copied.eNotify(new NotificationImpl(RESOURCE_COPIED, null, null));
- }
-
- /**
- * @see com.ibm.etools.emf.ecore.utilities.copy.EtoolsCopyUtility#primCopyObject(EObject,
- * String)
- */
- protected EObject primCopyObject(EObject aRefObject, String idSuffix) {
- EObject copy = super.primCopyObject(aRefObject, idSuffix);
- copyIdIfNecessary(aRefObject, copy, idSuffix);
- return copy;
- }
-
- protected void copyIdIfNecessary(EObject obj, EObject copy, String idSuffix) {
- if ((idSuffix == null && !preserveIds) || currentResource == null)
- return;
- String id = currentResource.getID(obj);
- if (id == null)
- return;
- id = idSuffix == null ? id : id + idSuffix;
- currentCopyResource.setID(copy, id);
- }
-
-
- /**
- * Set delivery back on for all the cached objects and push them to the parentCopyUtility.
- */
- public void flush() {
- Iterator it = getCopiedObjects().entrySet().iterator();
- Map parentCopies = getParentCopyUtility().getCopiedObjects();
- Map.Entry entry;
- EObject copy;
- while (it.hasNext()) {
- entry = (Map.Entry) it.next();
- copy = (EObject) entry.getValue();
- copy.eSetDeliver(true);
- parentCopies.put(entry.getKey(), copy);
- }
- copiedObjects = null;
- }
-
- /**
- * Return a cached copy.
- */
- public EObject getCopy(EObject anObject) {
- EObject copied = super.getCopy(anObject);
- if (copied == null)
- copied = getParentCopyUtility().getCopy(anObject);
- return copied;
- }
-
- /**
- * Insert the method's description here. Creation date: (05/04/01 11:28:07 PM)
- *
- * @return com.ibm.etools.emf.ecore.utilities.copy.EtoolsCopyUtility
- */
- protected EtoolsCopyUtility getParentCopyUtility() {
- return parentCopyUtility;
- }
-
- /**
- * Return an instance of EObject that is the same type as <code>aRefObject</code>.
- */
- public EObject newInstance(EObject aRefObject) {
- EObject newType = super.newInstance(aRefObject);
- newType.eSetDeliver(false);
- return newType;
- }
-
- /**
- * @see com.ibm.etools.emf.ecore.utilities.copy.EtoolsCopyUtility#newInstance(Resource, String)
- */
- public Resource newInstance(Resource aResource, String newUri) {
- Resource copy = super.newInstance(aResource, newUri);
- if (aResource instanceof XMLResource) {
- currentResource = (XMLResource) aResource;
- currentCopyResource = (XMLResource) copy;
- } else {
- currentResource = null;
- currentCopyResource = null;
- }
- return copy;
- }
-
-}
-
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/EtoolsCopyUtility.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/EtoolsCopyUtility.java
deleted file mode 100644
index e23bd9c..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/EtoolsCopyUtility.java
+++ /dev/null
@@ -1,672 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.emf.utilities;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.wst.common.internal.emf.utilities.Association;
-import org.eclipse.wst.common.internal.emf.utilities.CloneablePublic;
-import org.eclipse.wst.common.internal.emf.utilities.DeferredReferenceUtilityAction;
-
-
-/**
- * Insert the type's description here. Creation date: (12/13/2000 9:10:55 PM)
- *
- * @author: Administrator
- */
-public class EtoolsCopyUtility {
- protected static final String REFENUMLITERAL_TYPE_NAME = "EEnumLiteral"; //$NON-NLS-1$
- private final EcorePackage pkg = EcorePackage.eINSTANCE;
-
- private final ETypedElement METAENAME = pkg.getENamedElement_Name();
-
- protected HashMap copiedObjects;
- protected List deferredReferenceCopies;
- protected boolean preserveIds = false;
- protected boolean copyAdapters = false;
- protected HashMap copiedAdapters;
-
- protected class DeferredSingleReferenceCopyAction extends DeferredReferenceUtilityAction {
- public DeferredSingleReferenceCopyAction(EReference aReference, Object aValue, String aSuffix, EObject aCopyContainer) {
- super(aReference, aValue, aSuffix, aCopyContainer);
- }
-
- public void performAction() {
- EObject value = (EObject) getReferenceValue();
- getCopyContainer().eSet(getReference(), getCopyIfFound(value));
- }
- }
-
- protected class DeferredManyReferenceCopyAction extends DeferredReferenceUtilityAction {
- public DeferredManyReferenceCopyAction(EReference aReference, List aValue, String aSuffix, EObject aCopyContainer) {
- super(aReference, aValue, aSuffix, aCopyContainer);
- }
-
- public void performAction() {
- List copyList = (List) getCopyContainer().eGet(getReference());
- Iterator it = ((List) getReferenceValue()).iterator();
- EObject next;
- while (it.hasNext()) {
- next = (EObject) it.next();
- copyList.add(getCopyIfFound(next));
- }
- }
- }
-
- /**
- * Insert the method's description here. Creation date: (12/13/2000 9:14:26 PM)
- *
- * @param aRefObject
- * org.eclipse.emf.ecore.EObject
- */
- public EtoolsCopyUtility() {
- }
-
- /**
- * Create a <code>DeferredManyReferenceCopyAction</code> and add it to the list of deferred
- * copy actions.
- */
- protected void addDeferredManyReferenceCopy(EReference reference, List aValue, String idSuffix, EObject aCopyContainer) {
- getDeferredReferenceCopies().add(new DeferredManyReferenceCopyAction(reference, aValue, idSuffix, aCopyContainer));
- }
-
- /**
- * Create a <code>DeferredSingleReferenceCopyAction</code> and add it to the list of deferred
- * copy actions.
- */
- protected void addDeferredSingleReferenceCopy(EReference reference, EObject aValue, String idSuffix, EObject aCopyContainer) {
- getDeferredReferenceCopies().add(new DeferredSingleReferenceCopyAction(reference, aValue, idSuffix, aCopyContainer));
- }
-
- /**
- * Check for an already copied object first.
- */
- protected EObject containmentCopy(EObject anObject, String idSuffix) {
- EObject copied = getCopy(anObject);
- if (copied == null)
- copied = primCopy(anObject, idSuffix);
- return copied;
- }
-
- /**
- * Check for an already copied object first.
- */
- protected EObject containmentCopyObject(EObject anObject, String idSuffix) {
- EObject copied = getCopy(anObject);
- if (copied == null)
- copied = primCopyObject(anObject, idSuffix);
- return copied;
- }
-
- protected Resource containmentCopy(Resource aResource, String newUri) {
- /* copied resources are never cached */
- return primCopy(aResource, newUri);
- }
-
- /**
- * Copy all Resources and RefObjects within <code>aGroup</code> and add them to
- * <code>aGroup</code>. Non composite references will be deferred until all objects are
- * copied from <code>aGroup</code>.
- *
- * Copy Resources first and then copy RefObjects.
- */
- public void copy(CopyGroup aGroup) {
- if (aGroup != null) {
- EtoolsCopySession session = new EtoolsCopySession(this);
- session.setPreserveIds(aGroup.getPreserveIds());
- session.copy(aGroup);
- session.flush();
- }
- }
-
- public EObject copy(EObject aRefObject) {
- return copy(aRefObject, null);
- }
-
- /**
- * This method should be used if you are only going to copy <code>aRefObject</code> in this
- * copy execution.
- */
- public EObject copy(EObject aRefObject, String idSuffix) {
- EtoolsCopySession session = new EtoolsCopySession(this);
- EObject copied = session.copy(aRefObject, idSuffix);
- session.flush();
- return copied;
- }
-
- /**
- * This method should be used if you are only going to copy <code>aRefObject</code> in this
- * copy execution. This method only copies <code>aRefObject</code> with its properties, not
- * references.
- */
- public EObject copyObject(EObject aRefObject, String idSuffix) {
- EtoolsCopySession session = new EtoolsCopySession(this);
- EObject copied = session.copyObject(aRefObject, idSuffix);
- session.flush();
- return copied;
- }
-
- /**
- * This method should be used if you are only going to copy <code>aResource</code> in this
- * copy execution. The copied Resource will have a URI equal to <code>newUri</code>.
- */
- public Resource copy(Resource aResource, String newUri) {
- EtoolsCopySession session = new EtoolsCopySession(this);
- Resource copied = session.copy(aResource, newUri);
- session.flush();
- return copied;
- }
-
- /**
- * If an attribute is set and its value is not <code>null</code>, then perform copy
- * <code>attribute</code> value from <code>aRefObject</code> to <code>copyRef</code>.
- * Null is a valid value if the attribute is set.
- */
-
- protected void copyAttribute(EAttribute attribute, EObject aRefObject, String idSuffix, EObject copyRef) {
- if (!attribute.isChangeable())
- return; //ignore
- if (attribute.isMany()) {
- List value = (List) aRefObject.eGet(attribute);
- if (value != null)
- copyManyAttribute(attribute, value, aRefObject, idSuffix, copyRef);
- } else if (aRefObject.eIsSet(attribute)) {
- Object value = aRefObject.eGet(attribute);
- if (value == null)
- copyRef.eSet(attribute, value);
- else
- copySingleAttribute(attribute, value, aRefObject, idSuffix, copyRef);
- } else if (attribute == METAENAME) {
- //set name to the ID (this is computed as a default), only get here if isSetName is
- // false.
- copyRef.eSet(attribute, aRefObject.eGet(attribute));
- }
- }
-
- /**
- * Iterate over the attributes of the receiver and copy each attribute.
- */
- protected void copyCurrentAttributes(EObject aRefObject, String idSuffix, EObject copyRef) {
- List attributes = aRefObject.eClass().getEAllAttributes();
- if (attributes != null) {
- Iterator it = attributes.iterator();
- EAttribute ra;
- while (it.hasNext()) {
- ra = (EAttribute) it.next();
- copyAttribute(ra, aRefObject, idSuffix, copyRef);
- }
- }
- }
-
- /**
- * This method will iterate over the references of the receiver. If a reference's value is not
- * <code>null</code>, then a series of tests are done before setting the value with the
- * copied object, <code>copyRef</code>.
- *
- * Tests: 1. Do nothing if the reference equals the metaEContainer or metaEContains references.
- */
-
- protected void copyCurrentReferences(EObject aRefObject, String idSuffix, EObject copyRef) {
- List references = aRefObject.eClass().getEAllReferences();
- if (references != null) {
- Iterator it = references.iterator();
- EReference rr;
- while (it.hasNext()) {
- rr = (EReference) it.next();
- if (shouldCopyReference(rr))
- copyReference(rr, aRefObject, idSuffix, copyRef);
- }
- }
- }
-
- /**
- * Iterate over <code>anExtent</code> and copy each element to <code>copyExtent</code>.
- */
- protected void copyExtent(EList anExtent, EList copyExtent) {
- Iterator it = anExtent.iterator();
- EObject refObject;
- while (it.hasNext()) {
- refObject = (EObject) it.next();
- copyExtent.add(containmentCopy(refObject, null));
- }
- }
-
- /**
- * Copy a many value attribute which is treated as a many valued reference.
- *
- * Tests:
- *
- * 1. If the type is <bold>not </bold> <code>null</code>, then set the value on
- * <code>copyRef</code> without making a copy. 2. If the type is <code>null</code>, then
- * obtain the list from <code>copyRef</code> and add a copy of each value from the original
- * list to it.
- */
-
- protected void copyManyAttribute(EAttribute attribute, List aValue, EObject aRefObject, String idSuffix, EObject copyRef) {
- if (attribute.getEType() == null)
- copyRef.eSet(attribute, aValue);
- else {
- List copyList = (List) copyRef.eGet(attribute);
- Iterator it = aValue.iterator();
- Object next;
- while (it.hasNext()) {
- next = it.next();
- if (next instanceof EObject)
- copyList.add(containmentCopy((EObject) next, idSuffix));
- else
- copyList.add(next);
- }
- }
- }
-
- /**
- * This method will iterate over the references of the receiver. If a reference's value is not
- * <code>null</code>, then a series of tests are done before setting the value with the
- * copied object, <code>copyRef</code>.
- *
- * Tests: 1. If the reference is many, obtain the list from the receiving object and make a copy
- * of each value if the reference is composite before adding to the list; otherwise, just add
- * each value to the of the <code>copyRef</code>.
- */
-
- protected void copyManyReference(EReference aReference, List aList, EObject aRefObject, String idSuffix, EObject copyRef) {
- if (!aList.isEmpty()) {
- if (aReference.isContainment()) {
- List copyList = (List) copyRef.eGet(aReference);
- Iterator it = aList.iterator();
- EObject targetValue;
- while (it.hasNext()) {
- targetValue = (EObject) it.next();
- copyList.add(containmentCopy(targetValue, idSuffix));
- }
- } else
- addDeferredManyReferenceCopy(aReference, aList, idSuffix, copyRef);
- }
- }
-
- /**
- * This method will iterate over the references of the receiver. If a reference's value is not
- * <code>null</code>, then perform the copy.
- */
-
- protected void copyReference(EReference aReference, EObject aRefObject, String idSuffix, EObject copyRef) {
- if (aReference.isMany()) {
- List value = (List) aRefObject.eGet(aReference);
- if (value != null)
- copyManyReference(aReference, value, aRefObject, idSuffix, copyRef);
- } else if (aRefObject.eIsSet(aReference)) {
- Object value = aRefObject.eGet(aReference);
- copySingleReference(aReference, (EObject) value, aRefObject, idSuffix, copyRef);
- }
- }
-
- /**
- * Copy all RefObjects from <code>aGroup</code> and add the copy back to <code>aGroup</code>.
- */
- protected void copyRefObjects(CopyGroup aGroup) {
- Association association;
- EObject refObject;
- String idSuffix;
- if (aGroup.primGetRefObjects() != null) {
- Iterator it = aGroup.primGetRefObjects().iterator();
- while (it.hasNext()) {
- association = (Association) it.next();
- refObject = (EObject) association.getKey();
- idSuffix = (String) association.getValue();
- if (idSuffix == null)
- idSuffix = aGroup.getDefaultIdSuffix();
- aGroup.addCopied(containmentCopy(refObject, idSuffix));
- }
- }
- }
-
- /**
- * Copy all Resources from <code>aGroup</code> and add the copy back to <code>aGroup</code>.
- */
- protected void copyResources(CopyGroup aGroup) {
- Association association;
- Resource resource;
- String uri;
- if (aGroup.primGetResources() != null) {
- Iterator it = aGroup.primGetResources().iterator();
- while (it.hasNext()) {
- association = (Association) it.next();
- resource = (Resource) association.getKey();
- uri = (String) association.getValue();
- Resource copied = containmentCopy(resource, uri);
- copyModificationFlag(resource, copied);
- aGroup.addCopied(copied);
- }
- }
- }
-
- /**
- * Copy a single value attribute.
- *
- * Tests:
- *
- * 1. If an attribute type is not <code>null</code> then it is an object type and it must be
- * copied. Do not copy the value if the attribute is an Enumeration type. 2. If an attribute
- * type is <bold>not </bold> <code>null</code> then copy the value before setting it on
- * <code>copyRef</code>.
- */
-
- protected void copySingleAttribute(EAttribute attribute, Object aValue, EObject aRefObject, String idSuffix, EObject copyRef) {
- if (attribute.getEType() == null) {
- copyRef.eSet(attribute, aValue);
- } else {
- //MOF108
- // if (attribute.isObjectType())
- if (attribute.getEType() instanceof EClass)
- copyRef.eSet(attribute, containmentCopy((EObject) aValue, idSuffix));
- else
- copyRef.eSet(attribute, aValue);
- }
- }
-
- /**
- * This method will iterate over the references of the receiver. If a reference's value is not
- * <code>null</code>, then a series of tests are done before setting the value with the
- * copied object, <code>copyRef</code>.
- *
- * Tests: 1. If the reference is <bold>not </bold> many, make a copy of the value if the
- * reference is composite before setting the value with <code>copyRef</code>; otherwise, just
- * set the value as is.
- */
-
- protected void copySingleReference(EReference aReference, EObject aValue, EObject aRefObject, String idSuffix, EObject copyRef) {
- //Exceptional case; the relationship is not the container relationship
- //And is not navigable in the other direction; go ahead and copy
- if (aValue != aRefObject.eContainer() || aReference.getEOpposite() == null) {
- if (aReference.isContainment())
- copyRef.eSet(aReference, containmentCopy(aValue, idSuffix));
- else
- addDeferredSingleReferenceCopy(aReference, aValue, idSuffix, copyRef);
- }
- }
-
- /**
- * Copy all Resources and RefObjects within <code>aGroup</code> and add them to
- * <code>aGroup</code>. Non composite references will be deferred until all objects are
- * copied from <code>aGroup</code>.
- *
- * Copy Resources first and then copy RefObjects.
- */
- public static void createCopy(CopyGroup aGroup) {
- EtoolsCopyUtility utility = new EtoolsCopyUtility();
- utility.copy(aGroup);
- }
-
- /**
- * Copies attributes
- */
- public static void createAttributeCopy(EObject aRefObject, EObject copyObject) {
- EtoolsCopyUtility utility = new EtoolsCopyUtility();
- utility.copyCurrentAttributes(aRefObject, null, copyObject);
- }
-
- /**
- * Copies all set attributes and references based on containment. Thus, it will copy the entire
- * containment tree. Use the idSuffix to define the suffix that will be appended to the existing
- * IDs of copied objects.
- */
- public static EObject createCopy(EObject aRefObject) {
- return createCopy(aRefObject, null);
- }
-
- /**
- * Copies all set attributes and references based on containment. Thus, it will copy the entire
- * containment tree. Use the idSuffix to define the suffix that will be appended to the existing
- * IDs of copied objects.
- */
- public static EObject createCopy(EObject aRefObject, String idSuffix) {
- EtoolsCopyUtility utility = new EtoolsCopyUtility();
- return utility.copy(aRefObject, idSuffix);
- }
-
- /**
- * Copy <code>aResource</code> using <code>newUri</code> for the URI.
- */
- public static Resource createCopy(Resource aResource, String newUri) {
- EtoolsCopyUtility utility = new EtoolsCopyUtility();
- return utility.copy(aResource, newUri);
- }
-
- protected void executeDeferredCopyActions() {
- if (primGetDeferredReferenceCopies() != null) {
- Iterator it = primGetDeferredReferenceCopies().iterator();
- DeferredReferenceUtilityAction action;
- while (it.hasNext()) {
- action = (DeferredReferenceUtilityAction) it.next();
- action.performAction();
- }
- primGetDeferredReferenceCopies().clear();
- }
- }
-
- /**
- * Insert the method's description here. Creation date: (12/13/2000 9:17:35 PM)
- *
- * @return java.util.HashMap
- */
- protected java.util.HashMap getCopiedObjects() {
- if (copiedObjects == null)
- copiedObjects = new HashMap(200);
- return copiedObjects;
- }
-
- protected java.util.HashMap getCopiedAdapters() {
- if (copiedAdapters == null)
- copiedAdapters = new HashMap(200);
- return copiedAdapters;
- }
-
- /**
- * Return a cached copy.
- */
- public EObject getCopy(EObject anObject) {
- if (anObject == null)
- return null;
- return (EObject) getCopiedObjects().get(anObject);
- }
-
- /**
- * Return a cached copy, if none, return the argument.
- */
- public EObject getCopyIfFound(EObject anObject) {
- EObject copied = getCopy(anObject);
- return copied == null ? anObject : copied;
- }
-
- /**
- * Insert the method's description here. Creation date: (12/16/2000 9:11:32 AM)
- *
- * @return java.util.List
- */
- protected java.util.List getDeferredReferenceCopies() {
- if (deferredReferenceCopies == null)
- deferredReferenceCopies = new ArrayList(100);
- return deferredReferenceCopies;
- }
-
- /**
- * Return an instance of EObject that is the same type as <code>aRefObject</code>.
- */
- public EObject newInstance(EObject aRefObject) {
- if (aRefObject == null)
- return null;
- EPackage epkg = (EPackage) aRefObject.eClass().eContainer();
- EFactory factory = epkg.getEFactoryInstance();
- EClass refObj = aRefObject.eClass();
- return factory.create(refObj);
- }
-
- /**
- * Return an instance of Resource that uses the same ResourceFactory as the one used by
- * <code>aResource</code>. If <code>newUri</code> is <code>null</code> then use the URI
- * from <code>aResource</code>.
- */
- public Resource newInstance(Resource aResource, String newUri) {
- if (aResource == null)
- return null;
- Resource newResource;
- String originalUri = aResource.getURI().toString();
- newUri = newUri == null ? originalUri : newUri;
-
- Resource.Factory factory = null;
- if (aResource.getResourceSet() == null)
- factory = Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI(originalUri));
- else
- factory = aResource.getResourceSet().getResourceFactoryRegistry().getFactory(URI.createURI(originalUri));
-
-
- newResource = factory.createResource(URI.createURI(newUri));
- return newResource;
- }
-
- /**
- * Should the id be copied in the case where no suffix is specified? Defaults to false
- */
- public boolean preserveIds() {
- return preserveIds;
- }
-
- /**
- * Copies all set attributes and references based on containment. Thus, it will copy the entire
- * containment tree. Use the idSuffix to define the suffix that will be appended to the existing
- * IDs of copied objects. If an idSuffix does not exist, do not set an id on the copied object.
- */
- protected EObject primCopy(EObject aRefObject, String idSuffix) {
- if (aRefObject == null)
- return null;
- EObject copyRef = primCopyObject(aRefObject, idSuffix);
-
- copyCurrentReferences(aRefObject, idSuffix, copyRef);
- return copyRef;
- }
-
- /**
- * Copies all set attributes based on containment. Thus, it will copy the entire containment
- * tree. Use the idSuffix to define the suffix that will be appended to the existing IDs of
- * copied objects. If an idSuffix does not exist, do not set an id on the copied object.
- */
- protected EObject primCopyObject(EObject aRefObject, String idSuffix) {
- if (aRefObject == null)
- return null;
- EObject copyRef = newInstance(aRefObject);
-
- recordCopy(aRefObject, copyRef);
- copyCurrentAttributes(aRefObject, idSuffix, copyRef);
- if (isCopyAdapters())
- copyAdapters(aRefObject, copyRef);
- return copyRef;
- }
-
- protected void copyAdapters(EObject aRefObject, EObject copyRef) {
- List adapters = aRefObject.eAdapters();
- for (int i = 0; i < adapters.size(); i++) {
- Adapter adapter = (Adapter) adapters.get(i);
- copyAdapter(aRefObject, copyRef, adapter);
-
- }
- }
-
- protected void copyAdapter(EObject aRefObject, EObject copyRef, Adapter adapter) {
- if (!(adapter instanceof CloneablePublic))
- return;
- CloneablePublic copyAdapter = (CloneablePublic) getCopiedAdapters().get(adapter);
- if (copyAdapter == null) {
- copyAdapter = (CloneablePublic) ((CloneablePublic) adapter).clone();
- getCopiedAdapters().put(adapter, copyAdapter);
- }
- if (copyAdapter != null)
- copyRef.eAdapters().add(copyAdapter);
- }
-
- /**
- * Copies all set attributes and references based on containment. Thus, it will copy the entire
- * containment tree. Use the idSuffix to define the suffix that will be appended to the existing
- * IDs of copied objects.
- */
- protected Resource primCopy(Resource aResource, String newUri) {
- if (aResource == null)
- return null;
- Resource copyResource = newInstance(aResource, newUri);
- copyExtent(aResource.getContents(), copyResource.getContents());
- return copyResource;
- }
-
- protected void copyModificationFlag(Resource aResource, Resource copied) {
- if (aResource.isModified())
- copied.setModified(true);
- }
-
- /**
- * Insert the method's description here. Creation date: (12/16/2000 9:11:32 AM)
- *
- * @return java.util.List
- */
- private java.util.List primGetDeferredReferenceCopies() {
- return deferredReferenceCopies;
- }
-
- public void recordCopy(EObject aSource, EObject aCopy) {
- getCopiedObjects().put(aSource, aCopy);
- }
-
- public void recordCopy(Adapter aSource, Adapter aCopy) {
- getCopiedAdapters().put(aSource, aCopy);
- }
-
- /**
- * Should the id be copied in the case where no suffix is specified?
- */
- public void setPreserveIds(boolean value) {
- preserveIds = value;
- }
-
- protected boolean shouldCopyReference(EReference aReference) {
- return aReference.isChangeable();
- }
-
- /**
- * @return
- */
- public boolean isCopyAdapters() {
- return copyAdapters;
- }
-
- /**
- * Flag used to indicate whether adapters should be copied as well. In order for an adapter to
- * be copied, it must implement the {@link CloneablePublic}interface.
- */
- public void setCopyAdapters(boolean b) {
- copyAdapters = b;
- }
-
-}
-
-
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/ExceptionHelper.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/ExceptionHelper.java
deleted file mode 100644
index dfc8592..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/ExceptionHelper.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.emf.utilities;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.wst.common.frameworks.internal.enablement.nonui.IWFTWrappedException;
-
-
-
-/**
- * Utility class to factor common code for implementers of IArchiveWrappedException
- */
-public class ExceptionHelper {
-
- /**
- * Utility class; cannot be instantiated
- */
- private ExceptionHelper() {
- super();
- }
-
- /**
- * Return the messages from
- *
- * @exception and
- * all nested exceptions, in order from outermost to innermost
- */
- public static java.lang.String[] getAllMessages(IWFTWrappedException exception) {
- List messages = new ArrayList(4);
- messages.add(exception.getMessage());
- Exception nested = exception.getNestedException();
- while (nested != null) {
- messages.add(nested.getMessage());
- if (nested instanceof IWFTWrappedException)
- nested = ((IWFTWrappedException) nested).getNestedException();
- else
- nested = null;
- }
- return (String[]) messages.toArray(new String[messages.size()]);
- }
-
- /**
- * Return the messages from
- *
- * @exception and
- * all nested exceptions, in order from outermost to innermost, concatenated as
- * one
- */
- public static String getConcatenatedMessages(IWFTWrappedException exception) {
- String[] messages = getAllMessages(exception);
- StringBuffer sb = new StringBuffer(256);
- for (int i = 0; i < messages.length; i++) {
- sb.append(messages[i]);
- if (i < messages.length - 1)
- sb.append('\n');
- }
- return sb.toString();
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/ExtendedEcoreUtil.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/ExtendedEcoreUtil.java
deleted file mode 100644
index ca61265..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/ExtendedEcoreUtil.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.emf.utilities;
-
-import java.io.FileNotFoundException;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.common.util.WrappedException;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.XMLResource;
-import org.eclipse.wst.common.internal.emf.utilities.IsLoadingDetector;
-import org.eclipse.wst.common.internal.emf.utilities.IsLoadingProxyAdapter;
-import org.eclipse.wst.common.internal.emf.utilities.WFTUtilsResourceHandler;
-
-
-
-public class ExtendedEcoreUtil extends EcoreUtil {
- private static FileNotFoundDetector FILE_NOT_FOUND_DETECTOR;
- private static String NAME_ATTRIBUTE_STRING = "name"; //$NON-NLS-1$
-
-
- public interface FileNotFoundDetector {
- boolean isFileNotFound(WrappedException wrappedEx);
- }
-
- public static void setFileNotFoundDetector(FileNotFoundDetector detector) {
- FILE_NOT_FOUND_DETECTOR = detector;
- }
-
- public static FileNotFoundDetector getFileNotFoundDetector() {
- if (FILE_NOT_FOUND_DETECTOR == null) {
- FILE_NOT_FOUND_DETECTOR = new FileNotFoundDetector() {
- public boolean isFileNotFound(WrappedException wrappedEx) {
- if (getInnerFileNotFoundException(wrappedEx) != null)
- return true;
- return false;
- }
- };
- }
- return FILE_NOT_FOUND_DETECTOR;
- }
-
- public static FileNotFoundException getInnerFileNotFoundException(WrappedException wrappedEx) {
- if (wrappedEx.exception() instanceof java.io.FileNotFoundException) {
- return (FileNotFoundException) wrappedEx.exception();
- } else if (wrappedEx.exception() instanceof WrappedException) {
- return getInnerFileNotFoundException((WrappedException) wrappedEx.exception());
- }
- return null;
- }
-
- public static void eSetOrAdd(EObject obj, EStructuralFeature feature, Object value) {
- eSetOrAdd(obj, feature, value, 0);
- }
-
- public static void eSetOrAdd(EObject obj, EStructuralFeature feature, Object value, int newIndex) {
- if (feature.isMany() && value != null) {
- if (newIndex >= 0)
- ((List) obj.eGet(feature)).add(newIndex, value);
- else
- ((List) obj.eGet(feature)).add(value);
- } else {
- obj.eSet(feature, value);
- }
- }
-
- public static void eUnsetOrRemove(EObject obj, EStructuralFeature feature, Object value) {
- if (feature == null || feature.isMany())
- ((List) obj.eGet(feature)).remove(value);
- else
- obj.eUnset(feature);
- }
-
- public static boolean endsWith(URI sourceUri, URI testUri) {
- //TODO Waiting on new emf URI API
- String[] sourceSegments = sourceUri.segments();
- String[] testSegments = testUri.segments();
- int i = testSegments.length;
- int j = sourceSegments.length;
- if (j >= i) {
- boolean test = true;
-
- while (test && i > 0) {
- i--;
- j--;
- test = testSegments[i].equals(sourceSegments[j]);
- }
- return test;
- }
- return false;
- }
-
- public static String getName(EObject obj) {
- if (obj == null)
- return null;
- if (obj instanceof ENamedElement)
- return ((ENamedElement) obj).getName();
- List allAtts = obj.eClass().getEAllAttributes();
- int size = allAtts.size();
- EAttribute att, nameAttribute = null;
- for (int i = 0; i < size; i++) {
- att = (EAttribute) allAtts.get(i);
- if (NAME_ATTRIBUTE_STRING.equals(att.getName())) {
- nameAttribute = att;
- break;
- }
- }
- if (nameAttribute != null)
- return (String) obj.eGet(nameAttribute);
- return null;
- }
-
- public static void addLoadingTag(Resource resource) {
- resource.eAdapters().add(IsLoadingDetector.INSTANCE);
- }
-
- public static void removeLoadingTag(Resource resource) {
- resource.eAdapters().remove(IsLoadingDetector.INSTANCE);
- }
-
- /**
- * Return true if the resource is currently being loaded. This is determined by checking for the
- * IsLoadingDector in the list of eAdapters on the resource.
- *
- * @param resource
- * @return boolean
- *
- * @see addLoadingTag(Resource)
- * @see removeLoadingTag(Resource)
- *
- */
- public static boolean isLoading(Resource resource) {
- if (resource != null) {
- return resource.eAdapters().contains(IsLoadingDetector.INSTANCE);
- }
- return false;
- }
-
- public static Adapter createAdapterForLoading(Adapter targetAdapter, EObject targetObject) {
- Resource res = targetObject.eResource();
- if (res == null || isLoading(res))
- return new IsLoadingProxyAdapter(targetAdapter, targetObject);
- return targetAdapter;
- }
-
- public static void preRegisterPackage(String nsPrefix, EPackage.Descriptor descriptor) {
- if (!EPackage.Registry.INSTANCE.containsKey(nsPrefix))
- EPackage.Registry.INSTANCE.put(nsPrefix, descriptor);
- }
-
- /**
- * Remove this object from it's container, and make it and all it's children proxies
- */
- public static void unload(EObject root) {
- Resource res = root.eResource();
- EObject container = root.eContainer();
- if (container == null)
- if (res != null)
- res.getContents().remove(root);
- else {
- EStructuralFeature feature = root.eContainmentFeature();
- if (feature != null)
- eUnsetOrRemove(container, feature, root);
- }
- if (root != null && res != null)
- becomeProxy(root, res);
- }
-
- /**
- * Turns this object and all it's children to proxies, and removes adapters precondition: The
- * object has been removed from it's container
- */
- public static void becomeProxy(EObject root, Resource res) {
- Iterator iter = root.eAllContents();
- while (iter.hasNext()) {
- doBecomeProxy((InternalEObject) iter.next(), res);
- }
- doBecomeProxy((InternalEObject) root, res);
- }
-
- protected static void doBecomeProxy(InternalEObject p, Resource res) {
- String id = res.getURIFragment(p);
- p.eSetProxyURI(res.getURI().appendFragment(id));
- if (res instanceof XMLResource) {
- ((XMLResource) res).getIDToEObjectMap().remove(id);
- ((XMLResource) res).getEObjectToIDMap().remove(p);
- }
- p.eAdapters().clear();
- }
-
- public static void removeProxy(EObject root, Resource res) {
- Iterator iter = root.eAllContents();
- while (iter.hasNext()) {
- doRemoveProxy((InternalEObject) iter.next(), res);
- }
- doRemoveProxy((InternalEObject) root, res);
- }
-
- protected static void doRemoveProxy(InternalEObject p, Resource res) {
- String id = p.eProxyURI().fragment();
- if (res instanceof XMLResource) {
- ((XMLResource) res).setID(p, id);
- }
- p.eSetProxyURI(null);
- }
-
-
- /**
- * Ensures the passed object is not a proxy; if it is, throws an exception indicating the bad
- * HREF. If the object is null, does nothing.
- *
- * @param object
- * @throws DanglingHREFException
- */
- public static void checkProxy(EObject object) throws DanglingHREFException {
- if (object == null || !object.eIsProxy())
- return;
- String msg = WFTUtilsResourceHandler.getString("DANGLING_HREF_ERROR_", new Object[]{((InternalEObject) object).eProxyURI()}); //$NON-NLS-1$
- throw new DanglingHREFException(msg);
- }
-
- /**
- * Return true if o1 and o2 are not the same values. This implementation takes into account that
- * either parameter can be null.
- *
- * @param o1
- * @param o2
- * @return
- */
- public static boolean valueChanged(Object o1, Object o2) {
- return (o1 == null ^ o2 == null) || (o1 == null || !o1.equals(o2));
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/ICommand.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/ICommand.java
deleted file mode 100644
index fd031d4..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/ICommand.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.emf.utilities;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * @author John Mourra
- */
-public interface ICommand {
-
- /*
- * This will contain the multi-selection of objects to deploy. This selection could be used to
- * filter elements within a Module. Any other setup code should be done here...
- */
- void init(Object[] selection);
-
- /**
- * @param resource
- * @param delta
- * @param context
- * @return
- * @throws CoreException
- */
- public boolean execute(IResource resource, IResourceDelta delta, ICommandContext context) throws CoreException;
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/ICommandContext.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/ICommandContext.java
deleted file mode 100644
index fc7df03..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/ICommandContext.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.emf.utilities;
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-/**
- * @author John Mourra
- */
-public interface ICommandContext {
-
- /**
- * @return
- */
- public IProgressMonitor getProgressMonitor();
-
- /**
- * @return
- */
- public Map getConfigurationProperties();
-
- /**
- * @return
- */
- public ResourceSet getResourceSet();
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/IDUtil.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/IDUtil.java
deleted file mode 100644
index e3259c4..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/IDUtil.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.emf.utilities;
-
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.xmi.XMLResource;
-
-public class IDUtil {
-
- /**
- * This method is invoked to assign a unique ID to the object. The object must be contained in a
- * resource.
- */
- public static void assignID(EObject object) {
- Resource aResource = object.eResource();
- if (aResource instanceof XMLResource)
- assignID(object, (XMLResource) aResource);
-
- }
-
- public static String getOrAssignID(EObject object) {
- Resource aResource = object.eResource();
- if (aResource instanceof XMLResource)
- return getOrAssignID(object, (XMLResource) aResource);
- return null;
- }
-
- public static String getOrAssignID(EObject object, XMLResource aResource) {
- String id = aResource.getID(object);
- if (id == null)
- return assignID(object, aResource);
- return id;
- }
-
- public static String assignID(EObject object, XMLResource aResource) {
- String name = getBaseIDForAssignment(object);
- if (name == null)
- return null;
- String id = ensureUniqueID(aResource, name);
- aResource.setID(object, id);
- return id;
- }
-
- protected static String ensureUniqueID(XMLResource aResource, String baseIDName) {
- baseIDName += "_"; //$NON-NLS-1$
- //Change to use the current time instead of incremental numbers to help
- //support team development.
- long currentTime = System.currentTimeMillis();
- String id = baseIDName + currentTime;
- Map idMap = aResource.getIDToEObjectMap();
- while (idMap.get(id) != null) {
- ++currentTime;
- id = baseIDName + currentTime;
- }
- return id;
- }
-
- protected static String getBaseIDForAssignment(EObject object) {
- EClass metaO = object.eClass();
- return metaO.getName();
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/NamespaceAdapter.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/NamespaceAdapter.java
deleted file mode 100644
index ca17103..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/emf/utilities/NamespaceAdapter.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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
- *******************************************************************************/
-/*
- * Created on Aug 20, 2003
- *
- */
-package org.eclipse.wst.common.emf.utilities;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.notify.impl.NotificationImpl;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.wst.common.internal.emf.utilities.CloneablePublic;
-import org.eclipse.wst.common.internal.emf.utilities.Namespace;
-
-
-/**
- * Internal class used to hold namespaces parsed from an XML file using the xmlns:prefix="aURI"
- * syntax
- */
-public class NamespaceAdapter extends AdapterImpl implements CloneablePublic {
-
- protected final static String ADAPTER_TYPE = NamespaceAdapter.class.getName();
- protected Map prefixesToNS;
- protected List namespaces;
-
- public final static EStructuralFeature NOTIFICATION_FEATURE = new EStructuralFeatureImpl() {
- };
-
- private static class Notification extends NotificationImpl {
-
- /**
- * @param eventType
- * @param oldValue
- * @param newValue
- */
- public Notification(int eventType, Object oldValue, Object newValue) {
- super(eventType, oldValue, newValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.common.notify.impl.NotificationImpl#getFeature()
- */
- public Object getFeature() {
- return NOTIFICATION_FEATURE;
- }
- }
-
- protected NamespaceAdapter() {
- super();
- }
-
- public static void addNamespace(String prefix, String uri, EObject obj) {
- if (obj == null)
- return;
- NamespaceAdapter adapter = getAdapter(obj);
- if (adapter != null)
- adapter.addNamespace(prefix, uri);
- }
-
- public static void removeNamespace(String prefix, EObject obj) {
- if (obj == null)
- return;
- NamespaceAdapter adapter = retrieveExistingAdapter(obj);
- if (adapter != null)
- adapter.removeNamespace(prefix);
- }
-
- /**
- * Facade method for resolving prefixes to an actual namespace URI. Used for objects contained
- * by instances of {@link com.ibm.etools.emf2xml.TranslatorResource}. Walks up the object
- * containment path until a namespace is found, or returns null.
- */
- public static String getResolvedNamespaceURI(String prefix, EObject obj) {
- if (prefix == null || obj == null)
- return null;
- EObject container = obj;
- String nsURI;
- while (container != null) {
- nsURI = getNamespaceURIAtThisLevel(prefix, container);
- if (nsURI != null)
- return nsURI;
- container = container.eContainer();
- }
- return null;
- }
-
- public static String getNamespaceURIAtThisLevel(String prefix, EObject obj) {
- if (obj == null)
- return null;
- NamespaceAdapter adapter = retrieveExistingAdapter(obj);
- return adapter == null ? null : adapter.getNamespaceURI(prefix);
- }
-
- public static List getNamespaces(EObject obj) {
- if (obj == null)
- return Collections.EMPTY_LIST;
- NamespaceAdapter adapter = retrieveExistingAdapter(obj);
- return adapter == null ? null : adapter.getNamespaces();
-
- }
-
- protected static NamespaceAdapter retrieveExistingAdapter(EObject obj) {
- return (NamespaceAdapter) EcoreUtil.getExistingAdapter(obj, ADAPTER_TYPE);
- }
-
- protected static NamespaceAdapter getAdapter(EObject obj) {
- NamespaceAdapter adapter = retrieveExistingAdapter(obj);
- return adapter == null ? createAdapter(obj) : adapter;
- }
-
- protected static NamespaceAdapter createAdapter(EObject obj) {
- NamespaceAdapter adapter = new NamespaceAdapter();
- adapter.setTarget(obj);
- obj.eAdapters().add(adapter);
- return adapter;
- }
-
- protected void addNamespace(String prefix, String uri) {
- Namespace ns = new Namespace(prefix, uri);
- if (namespaces == null)
- namespaces = new ArrayList();
- if (prefixesToNS == null)
- prefixesToNS = new HashMap();
-
- prefixesToNS.put(prefix, ns);
- namespaces.add(ns);
- fireNotification(Notification.ADD, null, ns);
-
- }
-
- protected void removeNamespace(String prefix) {
- Namespace ns = null;
- if (prefixesToNS != null)
- ns = (Namespace) prefixesToNS.get(prefix);
-
- if (ns != null)
- namespaces.remove(ns);
- fireNotification(Notification.REMOVE, ns, null);
- }
-
- protected String getNamespaceURI(String prefix) {
- if (prefixesToNS == null)
- return null;
- Namespace ns = (Namespace) prefixesToNS.get(prefix);
- if (ns != null)
- return ns.getNsURI();
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.common.notify.impl.AdapterImpl#isAdapterForType(java.lang.Object)
- */
- public boolean isAdapterForType(Object type) {
- return ADAPTER_TYPE.equals(type);
- }
-
- public List getNamespaces() {
- return namespaces == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(namespaces);
- }
-
- protected void fireNotification(int type, Object oldValue, Object newValue) {
- if (target != null)
- target.eNotify(new Notification(type, oldValue, newValue));
- }
-
- public boolean hasNamespaces() {
- return namespaces != null && !namespaces.isEmpty();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf.ecore.utilities.CloneablePublic#clone()
- */
- public Object clone() {
- NamespaceAdapter result = new NamespaceAdapter();
- if (hasNamespaces()) {
- for (int i = 0; i < namespaces.size(); i++) {
- Namespace ns = (Namespace) namespaces.get(i);
- result.addNamespace(ns.getPrefix(), ns.getNsURI());
- }
- }
- return result;
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/AbstractRendererImpl.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/AbstractRendererImpl.java
deleted file mode 100644
index 03b6992..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/AbstractRendererImpl.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.internal.emf.resource;
-
-
-public abstract class AbstractRendererImpl implements Renderer {
-
-
- protected TranslatorResource resource;
- private int versionId;
- private boolean validating = true;
-
- /**
- * Constructor for AbstractRendererImpl.
- */
- public AbstractRendererImpl() {
- super();
- }
-
- /**
- * @see com.ibm.etools.emf2xml.Renderer#setResource(TranslatorResource)
- */
- public void setResource(TranslatorResource aResource) {
- resource = aResource;
- }
-
- /**
- * @see com.ibm.etools.emf2xml.Renderer#getResource()
- */
- public TranslatorResource getResource() {
- return resource;
- }
-
- public int getVersionId() {
- return this.versionId;
- }
-
- public void setVersionId(int versionId) {
- this.versionId = versionId;
- }
-
- /**
- * @return
- */
- public boolean isValidating() {
- return validating;
- }
-
- /**
- * @param b
- */
- public void setValidating(boolean b) {
- validating = b;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#accessForRead()
- */
- public void accessForRead() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#accessForWrite()
- */
- public void accessForWrite() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#isModified()
- */
- public boolean isModified() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#isShared()
- */
- public boolean isShared() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#isSharedForWrite()
- */
- public boolean isSharedForWrite() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#preDelete()
- */
- public void preDelete() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#preUnload()
- */
- public void preUnload() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#releaseFromRead()
- */
- public void releaseFromRead() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#releaseFromWrite()
- */
- public void releaseFromWrite() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#setBatchMode(boolean)
- */
- public void setBatchMode(boolean isBatch) {
- }
-
- public boolean useStreamsForIO() {
- return true;
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/AttributeTranslatorFilter.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/AttributeTranslatorFilter.java
deleted file mode 100644
index b0d0869..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/AttributeTranslatorFilter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 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
- **************************************************************************************************/
-/*
- * Created on Sep 21, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-public final class AttributeTranslatorFilter extends TranslatorFilter {
-
- public AttributeTranslatorFilter() {
- super(null, -1);
- }
-
- public AttributeTranslatorFilter(Translator trans, int version) {
- super(trans, version);
- }
-
- public final int scanNextTranslator(Translator[] children, int start) {
- int found = start + 1;
- for (; found < children.length; ++found) {
- if (children[found].isDOMAttribute())
- break;
- }
- found = (found < children.length) ? found : -1;
- return found;
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventNode.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventNode.java
deleted file mode 100644
index e575833..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventNode.java
+++ /dev/null
@@ -1,585 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.internal.emf.resource;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EObject;
-import org.xml.sax.Attributes;
-
-
-/**
- * CacheEventNodes (CENOs) store information collected from SAX Events. This information can then be
- * used once all necessary SAX Events have been generated to create and/or set values on EMF model
- * objects.
- *
- * CacheEventNodes (CENOs) have a simple lifecycle: initialize, collect data, commit, discard. When
- * initialized, CENOs will attempt to find the appropriate translator for a given XML element name,
- * and also create/set any necessary EMF model values. Data is collected as SAX character() events
- * are generated. On the SAX endElement event, the CENO is committed(), which is where it will
- * complete its processing to create EMF model features. In those cases where it cannot complete its
- * processing, it will defer its processing to the updateEMF() method of its parent. Defered
- * processing is necessary to handle EMF features that require read ahead cues from the XML. CENOs
- * will add themselves to their parents as children in a tree data structure. When an CENO
- * determines it is the golden piece of information required to instantiate its parent feature, it
- * will trigger its parent CENO to process the rest of the cached CENO tree. As mentioned, the
- * building of a CENO tree will only occur for nodes with read ahead cues.
- *
- * discard() is invoked by init() to ensure that no junk state is left from a previous use of the
- * CENO. commit() will call discard as needed. Because of the use of discard, CENOs can be pooled
- * and reused. If a CENO determines that it is contained in a pool, it will manage its own release
- * from that pool. Self- management is necessary because of the way in which CENOs might cache
- * certain children while waiting to create the parent EMF feature.
- *
- * @author mdelder
- */
-public class CacheEventNode {
-
- public static final String ROOT_NODE = "EMF_ROOT_NODE"; //$NON-NLS-1$
-
- private String nodeName = null;
- private Translator translator = null;
- private Notifier emfOwner = null;
- private StringBuffer buffer = null;
- private List children = null;
- private int versionID;
-
- /*
- * The internal data structure used to store the attributes is a String[]. The choice was made
- * to use an array to avoid the creation of another object (probably a Hashtable) and to exploit
- * array-access times to get the name and value of the attributes (opposed to full fledged
- * method invocations).
- *
- */
- private String[] attributes = null;
- private CacheEventNode parent = null;
- private CacheEventPool containingPool = null;
- private Boolean ignorable = null;
-
- public CacheEventNode(CacheEventPool containingPool) {
- this.containingPool = containingPool;
- }
-
- /**
- * Lifecycle method. init(TranslatorResource) will configure this Adapter as a ROOT node.
- *
- * This method will invoke discard() before completing its tasks.
- */
- public void init(TranslatorResource resource) {
- this.discard();
- this.setEmfOwner(resource);
- this.setTranslator(resource.getRootTranslator());
- this.setVersionID(resource.getVersionID());
- this.nodeName = CacheEventNode.ROOT_NODE;
- }
-
- /**
- * Lifecycle method. init(CacheEventNode, String, Attributes) will configure this Adapter to be
- * a non-ROOT node of the Adapter data structure
- *
- * This method will invoke discard() before completing its tasks.
- */
- public void init(CacheEventNode parentArg, String nodeNameArg, Attributes attributesArg) {
- this.discard();
- this.nodeName = nodeNameArg;
- init(parentArg, attributesArg);
- }
-
- private void init(CacheEventNode parentRecord, Attributes attributesArg) {
- setParent(parentRecord);
-
- setAttributes(attributesArg);
- if (parent != null) {
- /* I am not the root */
-
- /*
- * If the parent is part of the DOM Path, then we ignore it and interact with the grand
- * parent
- */
- if (parent.translator != null && parent.isInDOMPath()) {
- setParent(parent.getParent());
- }
-
- setVersionID(parent.getVersionID());
- if (parent.getEmfOwner() != null && parent.getTranslator() != null) {
-
- /* My parent had enough information to create themself */
-
- if (parent.getParent() != null) {
- setTranslator(parent.getTranslator().findChild(nodeName, parent.getEmfOwner(), getVersionID()));
-
- } else {
- setTranslator(parent.getTranslator());
- }
-
- if (this.translator == null) {
- /* Our translator is null! Ahh! Run! */
- throw new IllegalStateException("Parent Translator (" + parent.getTranslator() + //$NON-NLS-1$
- ") did not find a Child Translator for \"" + //$NON-NLS-1$
- nodeName + "\"."); //$NON-NLS-1$
- }
-
- if (this.translator.getReadAheadHelper(nodeName) == null && !this.translator.isManagedByParent()) {
- /*
- * I do not require a read ahead cue, and I am not managed by my parent so I can
- * create an instance of my EMF object
- */
-
- Notifier myEmfOwner = this.translator.createEMFObject(getNodeName(), null);
- setEmfOwner(myEmfOwner);
- this.translator.setMOFValue(parent.getEmfOwner(), myEmfOwner);
- }
- /*
- * Else I require a read ahead value or I am being managed by my parent, so I have
- * no need to create an EMF object
- */
- }
- /*
- * Else I am not mapped to the EMF stack (XML Elements found in the DOMPath are ignored)
- */
- }
- /* processAttributes is guarded and will not execute unless ready */
- processAttributes();
-
- }
-
- /**
- * commit() is invoked only if the CacheEventNode (CENO) has all the information they need and
- * should be able to determine what to do to the EMF feature.
- *
- * The commit() method will invoke discard() when it has completed its tasks, if needed. Thus,
- * after invoking this method, the CENO may have no meaningful state. If discard() is invoked,
- * all previously held reference will be released in order to be made eligible for Garbage
- * Collection.
- *
- */
- public void commit() {
-
- if (parent == null || this.isIgnorable()) {
- discard();
- releaseFromContainingPool();
- return;
- }
-
- ReadAheadHelper helper = null;
- Translator activeTranslator = getTranslator();
- Translator parentTranslator = getParent().getTranslator();
-
- if (parent != null && parent.getEmfOwner() == null) {
-
- /*
- * Not enough information yet, add the CacheEventNode to the DOM Cache tree
- */
-
- parent.appendToBuffer(this);
- if ((helper = getParent().getReadAheadHelper()) != null) {
- /*
- * If the parentRecord's emfOwner is null, then it must not be initialized therefore
- * it or one of its ancestors must require read ahead clues
- *
- * The following if statement checks if the parent is the node waiting for a
- * readAhead cue
- */
- EObject parentOwner = null;
- if (helper.nodeValueIsReadAheadName(getNodeName())) {
- /* The readAheadName is the value of the qName child node */
-
- /* We have enough information to create the EmfOwner in the parent! */
- parentOwner = parentTranslator.createEMFObject(getParent().getNodeName(), getBuffer());
-
- /*
- * Now we need to parse the cached DOM tree and update the emfOwner of the
- * parent
- */
- getParent().updateEMF(parentOwner);
-
- } else if (helper.nodeNameIsReadAheadName(getNodeName())) {
- /* The readAheadName is the actual name of the child node (qName) */
-
- /* We have enough information to create the EmfOwner in the parent! */
- parentOwner = parentTranslator.createEMFObject(getParent().getNodeName(), getNodeName());
-
- /*
- * Now we need to parse the cached DOM tree and update the emfOwner of the
- * parent
- */
- getParent().updateEMF(parentOwner);
- }
-
- } /* Else an ancestor of the parent is waiting */
-
- } else {
- if (activeTranslator != null) {
- if (activeTranslator.isManagedByParent()) {
-
- Object value = activeTranslator.convertStringToValue(getNodeName(), null, getBuffer(), getParent().getEmfOwner());
- activeTranslator.setMOFValue(getParent().getEmfOwner(), value);
- processAttributes();
- } else {
-
- activeTranslator.setTextValueIfNecessary(getBuffer(), getEmfOwner(), getVersionID());
- }
-
- }
- discard();
- releaseFromContainingPool();
- }
- }
-
- /**
- * Instruct the CacheEventNode to discard all references to make everything eligible for garbage
- * collection. This should ONLY be called after commit has succeeded. In the case of EMF
- * features that require a readAheadName, process not be completed in commit(), but rather will
- * be defered to the updateEMF() method. This method was made private specifically because it
- * could erase all information contained in the CacheEventNode before it has been processed.
- *
- */
- private void discard() {
- translator = null;
- emfOwner = null;
- buffer = null;
- if (children != null)
- children.clear();
- children = null;
- attributes = null;
- parent = null;
- }
-
- private void releaseFromContainingPool() {
- if (containingPool != null)
- containingPool.releaseNode(this);
- }
-
- public boolean isIgnorable() {
- if (ignorable == null) {
- boolean result = false;
- if (this.translator != null) {
- if (this.translator.isEmptyContentSignificant()) {
- result = false;
- } else {
- String domPath = this.translator.getDOMPath();
- result = (domPath != null) ? domPath.indexOf(this.nodeName) >= 0 : false;
- }
- }
- ignorable = result ? Boolean.TRUE : Boolean.FALSE;
- }
- return ignorable.booleanValue();
- }
-
- /**
- * Determines if a given child has a translator.
- *
- * @param childNodeName
- * the name of the current XML child node
- * @return true only if the childNodeName can be ignored (e.g. it is part of the DOM Path)
- */
- public boolean isChildIgnorable(String childNodeName) {
- boolean result = false;
-
- Translator childTranslator = null;
- if (this.getTranslator() != null) {
- childTranslator = this.getTranslator().findChild(childNodeName, this.getEmfOwner(), this.getVersionID());
-
- if (childTranslator != null) {
- if (childTranslator.isEmptyContentSignificant()) {
- result = false;
- } else {
- String temp = null;
- result = ((temp = childTranslator.getDOMPath()) != null) ? temp.indexOf(childNodeName) >= 0 : false;
- }
- }
- }
-
- return result;
- }
-
- public boolean isInDOMPath() {
- boolean result = false;
-
- if (this.getTranslator() != null) {
-
- result = this.getNodeName().equals(this.getTranslator().getDOMPath());
- }
-
- return result;
- }
-
- public String toString() {
- StringBuffer output = new StringBuffer("CacheEventNode[");//$NON-NLS-1$
- output.append("nodeName=");//$NON-NLS-1$
- output.append(nodeName);
- output.append("; translator=");//$NON-NLS-1$
- output.append(translator);
- output.append("; emfOwner=");//$NON-NLS-1$
- try {
- output.append(emfOwner);
- } catch (RuntimeException re) {
- output.append("Could not render as string!");//$NON-NLS-1$
- }
- output.append("; buffer=");//$NON-NLS-1$
- output.append(this.buffer);
- output.append("; hasChildren=");//$NON-NLS-1$
- output.append((children != null && children.size() > 0));
- if (children != null) {
- for (int i = 0; i < this.children.size(); i++) {
- output.append("\n\tchildren(");//$NON-NLS-1$
- output.append(i);
- output.append("): ");//$NON-NLS-1$
- output.append(this.children.get(i));
- }
- }
- output.append("]");//$NON-NLS-1$
- return output.toString();
- }
-
- /**
- * Updates the EMF model by creating EMF Features as necessary from the DOM Tree Cache
- *
- * @param owner
- */
- public void updateEMF(EObject owner) {
- this.setEmfOwner(owner);
- if (this.parent != null) {
- this.translator.setMOFValue((EObject) this.parent.getEmfOwner(), owner);
- this.processAttributes();
- }
-
- this.updateEMF();
- }
-
- /**
- * The translator and the owner of the parent CENO passed to this method should be nonnull
- */
- public void updateEMF() {
- if (this.children == null)
- return;
-
- CacheEventNode child = null;
- Translator childTranslator = null;
- Object value = null;
- if (this.getEmfOwner() != null) {
- Notifier parentOwner = this.getEmfOwner();
- Translator parentTranslator = this.getTranslator();
- for (int i = 0; i < this.children.size(); i++) {
-
- child = (CacheEventNode) this.children.get(i); /* Create the EMF feature */
- if (this.isChildIgnorable(child.getNodeName())) {
- this.addChildren(child.getChildren());
- } else {
- childTranslator = parentTranslator.findChild(child.getNodeName(), parentOwner, child.getVersionID());
- child.setTranslator(childTranslator);
-
- value = childTranslator.convertStringToValue(child.getNodeName(), null, child.getBuffer(), parentOwner);
- childTranslator.setMOFValue(parentOwner, value);
-
- if (childTranslator.isObjectMap()) {
- child.setEmfOwner((Notifier) value);
- childTranslator.setTextValueIfNecessary(child.getBuffer(), child.getEmfOwner(), getVersionID());
- }
-
- child.processAttributes();
- child.updateEMF(); /* update the EMF of the child */
-
- }
- child.discard();
- child.releaseFromContainingPool();
- }
- this.children = null;
- }
- }
-
- public void addChild(CacheEventNode child) {
- if (this.children == null) {
- this.children = new ArrayList();
- }
- if (parent != null && this.isIgnorable()) {
- parent.addChild(child);
- } else {
- this.children.add(child);
- }
- }
-
- protected void addChildren(List childrenArg) {
- if (this.children == null) {
- this.children = new ArrayList();
- }
- this.children.addAll(childrenArg);
- }
-
- public boolean removeChild(CacheEventNode child) {
- if (this.children == null) {
- return false;
- }
- return this.children.remove(child);
- }
-
- public List getChildren() {
- return this.children;
- }
-
- public ReadAheadHelper getReadAheadHelper() {
- if (this.translator != null && this.translator.hasReadAheadNames()) {
- return translator.getReadAheadHelper(nodeName);
- }
- return null;
- }
-
-
- /* See the documentation for the attributes field for info on how it is structured */
- public void setAttributes(Attributes attr) {
-
- /*
- * The attributes returned from the parser may be stored by reference, so we must copy them
- * over to a local data store
- */
- if (attr != null && attr.getLength() > 0) {
-
- if (this.attributes == null) {
- this.attributes = new String[attr.getLength() * 2];
- }
- for (int i = 0; i < attr.getLength(); i++) {
- this.attributes[i] = attr.getQName(i);
- this.attributes[i + attr.getLength()] = attr.getValue(i);
- }
-
- }
- }
-
- /**
- * processAttributes may be invoked multiple times. It is configured to only carry out the
- * processing one time. After it successfully completes the construction of Translators and
- * values it will discard the value of the attributes field by setting it to null.
- *
- */
- public void processAttributes() {
- /* See the documentation for the attributes field for info on how it is structured */
- if (this.attributes != null && this.attributes.length > 0) {
-
- if (this.emfOwner != null && this.translator != null) {
- Translator attrTranslator = null;
- final int limit = this.attributes.length / 2;
- Object value = null;
- for (int i = 0; i < limit; i++) {
-
- /* Find the attribute translator by using the attribute name (attributes[i]) */
- attrTranslator = this.translator.findChild(this.attributes[i], this.emfOwner, this.versionID);
-
- if (attrTranslator != null) {
-
- /*
- * Convert the value of corresponding attribute value (attributes[i+limit])
- * to a meaningful value
- */
- value = attrTranslator.convertStringToValue(this.attributes[i + limit], (EObject) this.emfOwner);
- attrTranslator.setMOFValue((EObject) this.emfOwner, value);
- }
- }
-
- /* Forget the attributes so we do not process them again */
- this.attributes = null;
- }
- }
- }
-
- /**
- * Appends data to the buffer stored by this CENO. Text will be extracted from the data array
- * begining at positiong <i>start </i> and ending at position <i>start+length </i>.
- *
- * @param data
- * @param start
- * @param length
- */
- public void appendToBuffer(char[] data, int start, int length) {
-
- if (parent != null && this.isIgnorable()) {
- parent.appendToBuffer(data, start, length);
- return;
- }
-
- if (buffer == null) {
- this.buffer = new StringBuffer();
- }
-
- /*
- * acts as a more efficient form of "append". Using this method avoids the need to copy the
- * data into its own data structure (e.g. String) before being added to the buffer
- */
- this.buffer.insert(buffer.length(), data, start, length);
-
- }
-
- /**
- * Add the given CENO as a child of this CENO.
- *
- * @param record
- */
- public void appendToBuffer(CacheEventNode record) {
-
- this.addChild(record);
- }
-
- public String getBuffer() {
- if (this.buffer == null) {
- return null;
- }
- return this.buffer.toString();
- }
-
- public Notifier getEmfOwner() {
- return emfOwner;
- }
-
- public CacheEventNode getParent() {
- return parent;
- }
-
- private void setParent(CacheEventNode record) {
- this.parent = record;
- }
-
- public Translator getTranslator() {
- return this.translator;
- }
-
- public void setEmfOwner(Notifier notifier) {
-
- this.emfOwner = notifier;
- }
-
- public void setTranslator(Translator translator) {
- this.translator = translator;
- }
-
- public String getNodeName() {
- return nodeName;
- }
-
- public int getVersionID() {
-
- if (this.parent == null) {
- try {
- return ((TranslatorResource) this.getEmfOwner()).getVersionID();
-
- } catch (RuntimeException re) {
- }
- }
- return this.versionID;
- }
-
- public void setVersionID(int i) {
- versionID = i;
- }
-
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventPool.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventPool.java
deleted file mode 100644
index 55799e2..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventPool.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.internal.emf.resource;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.xml.sax.Attributes;
-
-/**
- * Provides an instance pool of reusable CacheEventNodes. The pool will default to 10 live
- * instances. When its available instances reach five times its initial capacity, it will shrink
- * itself down to the initial capacity.
- *
- * @author mdelder
- */
-public class CacheEventPool {
-
- public static final int DEFAULT_CAPACITY = 10;
- public static final int DEFAULT_CAPACITY_INCREMENT = 25;
-
- private int poolCapacity = DEFAULT_CAPACITY;
- private CacheEventStack availablePool = null;
- private Collection inusePool = null;
-
- public CacheEventPool() {
- this(DEFAULT_CAPACITY);
- }
-
- /**
- * Create a CacheEventPOol with the given initial capacity
- *
- * @param initialCapacity
- * The number of available instances to create.
- */
- public CacheEventPool(int initialCapacity) {
- poolCapacity = (initialCapacity > 0) ? initialCapacity : DEFAULT_CAPACITY;
- availablePool = new CacheEventStack();
- inusePool = new ArrayList(poolCapacity);
- }
-
- /**
- * Create a CacheEventNode (CENO) initialized to use the given resource as its EMF Owner.
- *
- * THIS METHOD SHOULD ONLY BE USED TO CREATE ROOT NODES.
- *
- * @param resource
- * the resource that will be populated
- * @return a CacheEventNode to serve as the root.
- */
- public CacheEventNode createCacheEventNode(TranslatorResource resource) {
- CacheEventNode adapter = fetchFreeNode();
- adapter.init(resource);
- return adapter;
- }
-
- /**
- * Create child CacheEventNodes (CENOs) that will branch from the given parent.
- *
- * @param parent
- * the containing CENO
- * @param nodeName
- * The value of the XML element node name
- * @param attributes
- * The attributes that were part of the given XML element
- * @return A CENO that has been properly initialized.
- */
- public CacheEventNode createCacheEventNode(CacheEventNode parent, String nodeName, Attributes attributes) {
- CacheEventNode adapter = fetchFreeNode();
- adapter.init(parent, nodeName, attributes);
- return adapter;
- }
-
- /**
- * Release the CacheEventNode CENO back to the pool of availabe instances. This method should
- * not be invoked directly. CENOs which are acquired from a given pool will automatically
- * release themselves when necessary.
- *
- * @param adapter
- */
- public void releaseNode(CacheEventNode adapter) {
- freeNode(adapter);
- }
-
- /**
- * freezePool() should be invoked to free any unused resources. After freezePool has been
- * invoked, warmPool() will need to be invoked before the pool can be used again.
- *
- */
- public void freezePool() {
- availablePool.clear();
- availablePool = null;
- }
-
- /**
- * warmPool() must be invoked to notify the pool it is about to be used. This should occur only
- * once per document rendering. Until the pool is in use, it contains no available
- * CacheEventNodes (CENOs) in order to limit the size of the in-memory footprint of the
- * EMF2SAXWriter.
- *
- */
- public void warmPool() {
- ensureMinimumCapacity();
- }
-
- private CacheEventNode fetchFreeNode() {
- CacheEventNode result = null;
-
- if (availablePool == null || availablePool.isEmpty())
- warmPool();
-
- result = availablePool.pop();
- inusePool.add(result);
-
- return result;
- }
-
- private void freeNode(CacheEventNode adapter) {
- if (inusePool.remove(adapter))
- availablePool.push(adapter);
- //else
- // throw new IllegalStateException("Adapter not contained in pool!");
- if (availablePool.size() > (5 * poolCapacity)) {
- availablePool.clear();
- ensureMinimumCapacity();
- }
- }
-
- private void ensureMinimumCapacity() {
- if (availablePool == null) {
- availablePool = new CacheEventStack();
- }
- if (availablePool.size() < poolCapacity) {
- final int minimumCapacity = poolCapacity - availablePool.size();
- for (int i = 0; i < minimumCapacity; i++)
- availablePool.push(new CacheEventNode(this));
- }
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventStack.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventStack.java
deleted file mode 100644
index 03f4198..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventStack.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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
- *******************************************************************************/
-/*
- * Created on Sep 24, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.ArrayList;
-import java.util.EmptyStackException;
-
-/**
- * An unsynchronized implementation of a Stack (LIFO) data structure. No casting is required when
- * using this data structure.
- *
- * @author mdelder
- */
-public class CacheEventStack extends ArrayList {
-
- /**
- *
- * @return the top of the stack without removing it
- */
- public CacheEventNode peek() {
- if (size() == 0)
- throw new EmptyStackException();
-
- return (CacheEventNode) get(size() - 1);
- }
-
- /**
- *
- * @return the top of the stack and removing it
- */
- public CacheEventNode pop() {
- if (size() == 0)
- throw new EmptyStackException();
-
- return (CacheEventNode) remove(size() - 1);
- }
-
- /**
- *
- * @param adapter
- * A CENO to push onto the top of the stack
- */
- public void push(CacheEventNode adapter) {
- add(adapter);
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityPackageMappingRegistry.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityPackageMappingRegistry.java
deleted file mode 100644
index 25367c8..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityPackageMappingRegistry.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.internal.emf.resource;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * This class is used to register mappings for a package prefix to its current namespace URI. Also,
- * this registry is used to map the package
- */
-public class CompatibilityPackageMappingRegistry {
- public static CompatibilityPackageMappingRegistry INSTANCE = new CompatibilityPackageMappingRegistry();
- private Map prefixToPackageURIs = new HashMap();
- private Map packageURIsToPrefixes = new HashMap();
-
- /**
- *
- */
- private CompatibilityPackageMappingRegistry() {
- super();
- }
-
- /**
- * @return
- */
- public Map getPackageURIsToPrefixes() {
- return packageURIsToPrefixes;
- }
-
- /**
- * @return
- */
- public Map getPrefixToPackageURIs() {
- return prefixToPackageURIs;
- }
-
- public void registerPrefixToPackageURI(String prefix, String uri) {
- if (prefix != null && uri != null) {
- prefixToPackageURIs.put(prefix, uri);
- packageURIsToPrefixes.put(uri, prefix);
- }
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityResourceFactory.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityResourceFactory.java
deleted file mode 100644
index f824de3..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityResourceFactory.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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
- *******************************************************************************/
-/*
- * Created on Apr 23, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.Map;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-
-/**
- * @author DABERG
- *
- * To change the template for this generated type comment go to Window>Preferences>Java>Code
- * Generation>Code and Comments
- */
-public class CompatibilityResourceFactory extends XMIResourceFactoryImpl {
- /**
- *
- */
- public CompatibilityResourceFactory() {
- super();
- }
-
- protected Map prefixToPackageURIs;
-
- protected Map packageURIsToPrefixes;
-
- public Map getPrefixToPackageURI() {
- return CompatibilityPackageMappingRegistry.INSTANCE.getPrefixToPackageURIs();
- }
-
- public Map getPackageURIsToPrefixes() {
- return CompatibilityPackageMappingRegistry.INSTANCE.getPackageURIsToPrefixes();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl#createResource(org.eclipse.emf.common.util.URI)
- */
- public Resource createResource(URI uri) {
- return new CompatibilityXMIResourceImpl(uri);
- }
-
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilitySAXXMIHandler.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilitySAXXMIHandler.java
deleted file mode 100644
index ee6ff3e..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilitySAXXMIHandler.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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
- *******************************************************************************/
-/*
- * Created on Apr 30, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.Map;
-
-import org.eclipse.emf.ecore.xmi.XMLHelper;
-import org.eclipse.emf.ecore.xmi.XMLResource;
-import org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler;
-
-/**
- * @author DABERG
- *
- * To change the template for this generated type comment go to Window>Preferences>Java>Code
- * Generation>Code and Comments
- */
-public class CompatibilitySAXXMIHandler extends SAXXMIHandler {
- protected final static String NULL_ATTRIB = XMLResource.XSI_NS + ":null"; //$NON-NLS-1$
-
- /**
- * @param xmiResource
- * @param helper
- * @param options
- */
- public CompatibilitySAXXMIHandler(XMLResource xmiResource, XMLHelper helper, Map options) {
- super(xmiResource, helper, options);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.xmi.impl.XMLHandler#isNull()
- */
- protected boolean isNull() {
- boolean isnull = super.isNull();
- if (!isnull)
- isnull = attribs.getValue(NULL_ATTRIB) != null;
- return isnull;
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityURIConverter.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityURIConverter.java
deleted file mode 100644
index ba135f5..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityURIConverter.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.URIConverter;
-
-public interface CompatibilityURIConverter extends URIConverter {
- URI deNormalize(URI uri);
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMILoadImpl.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMILoadImpl.java
deleted file mode 100644
index 5f17a46..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMILoadImpl.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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
- *******************************************************************************/
-/*
- * Created on Apr 30, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.ecore.xmi.XMLHelper;
-import org.eclipse.emf.ecore.xmi.impl.SAXWrapper;
-import org.eclipse.emf.ecore.xmi.impl.XMILoadImpl;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * @author DABERG
- *
- * To change the template for this generated type comment go to Window>Preferences>Java>Code
- * Generation>Code and Comments
- */
-public class CompatibilityXMILoadImpl extends XMILoadImpl {
-
- /**
- * @param helper
- */
- public CompatibilityXMILoadImpl(XMLHelper helper) {
- super(helper);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl#makeDefaultHandler()
- */
- protected DefaultHandler makeDefaultHandler() {
- return new SAXWrapper(new CompatibilitySAXXMIHandler(resource, helper, options));
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMIResource.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMIResource.java
deleted file mode 100644
index a954f5f..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMIResource.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-
-public interface CompatibilityXMIResource extends XMIResource {
- int FORMAT_EMF1 = 0;
- /**
- * format for MOF5 compatibility; note that this can NOT be used with resources usings the
- * "platform:/plugin" protocol"
- */
- int FORMAT_MOF5 = 1;
-
- void addOriginalPackageURI(String packageUri, String originalUri);
-
- int getFormat();
-
- /**
- * Set the serialization format. By default it is FORMAT_EMF1.
- *
- * @see CompatibilityXMIResource#FORMAT_EMF1
- * @see CompatibilityXMIResource#FORMAT_MOF5
- */
- void setFormat(int format);
-
- boolean usesDefaultFormat();
-
- /**
- * @param rootObject
- */
- void removePreservingIds(EObject rootObject);
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMIResourceImpl.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMIResourceImpl.java
deleted file mode 100644
index 061f18c..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMIResourceImpl.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.internal.emf.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.xmi.XMLHelper;
-import org.eclipse.emf.ecore.xmi.XMLLoad;
-import org.eclipse.emf.ecore.xmi.XMLSave;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
-import org.eclipse.wst.common.emf.utilities.ExtendedEcoreUtil;
-import org.eclipse.wst.common.emf.utilities.IDUtil;
-
-
-public class CompatibilityXMIResourceImpl extends XMIResourceImpl implements CompatibilityXMIResource {
- protected static final String DEFAULT_ENCODING = "UTF-8"; //$NON-NLS-1$
- protected int format = FORMAT_EMF1;
- protected Map originalPackageURIs = new HashMap();
- private boolean preserveIDs = false;
-
- private static final String PLATFORM_PROTOCOL = "platform"; //$NON-NLS-1$
- private static final String PLATFORM_PLUGIN = "plugin"; //$NON-NLS-1$
-
- /**
- * Constructor for MappableXMIResourceImpl.
- */
- public CompatibilityXMIResourceImpl() {
- super();
- initDefaultSaveOptions();
- }
-
- public CompatibilityXMIResourceImpl(URI uri) {
- super(uri);
- initDefaultSaveOptions();
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl#createXMLHelper()
- */
- protected final XMLHelper createXMLHelper() {
- MappedXMIHelper helper = doCreateXMLHelper();
- helper.setPackageURIsToPrefixes(getPackageURIsToPrefixes());
- return helper;
- }
-
- protected MappedXMIHelper doCreateXMLHelper() {
- return new MappedXMIHelper(this, getPrefixToPackageURIs());
- }
-
- /**
- * Subclasses should not need to override this method.
- *
- * @see CompatibilityPackageMappingRegistry#getPrefixToPackageURIs()
- */
- protected Map getPrefixToPackageURIs() {
- return CompatibilityPackageMappingRegistry.INSTANCE.getPrefixToPackageURIs();
- }
-
- /**
- * Subclasses should not need to override this method.
- *
- * @see CompatibilityPackageMappingRegistry#getPrefixToPackageURIs()
- */
- protected Map getPackageURIsToPrefixes() {
- return CompatibilityPackageMappingRegistry.INSTANCE.getPackageURIsToPrefixes();
- }
-
- public void addOriginalPackageURI(String packageUri, String originalUri) {
- originalPackageURIs.put(packageUri, originalUri);
- }
-
- public int getFormat() {
- return format;
- }
-
- public void setFormat(int format) {
- if (!isPlatformPluginResourceURI())
- this.format = format;
- }
-
- private boolean isPlatformPluginResourceURI() {
- URI aURI = getURI();
-
- return aURI != null && PLATFORM_PROTOCOL.equals(uri.scheme()) && PLATFORM_PLUGIN.equals(uri.segment(0));
- }
-
- /**
- * @see org.eclipse.emf.ecore.resource.Resource#getURIFragment(EObject)
- */
- public String getURIFragment(EObject eObject) {
- if (usesDefaultFormat())
- return super.getURIFragment(eObject);
- return IDUtil.getOrAssignID(eObject, this);
- }
-
- public boolean usesDefaultFormat() {
- return format == CompatibilityXMIResource.FORMAT_EMF1;
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl#createXMLSave()
- */
- protected XMLSave createXMLSave() {
- if (usesDefaultFormat())
- return super.createXMLSave();
- return new CompatibilityXMISaveImpl(createXMLHelper());
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#doSave(OutputStream, Map)
- */
- public void doSave(OutputStream outputStream, Map options) throws IOException {
- super.doSave(outputStream, options);
- }
-
- /**
- * Method initDefaultOptions.
- */
- protected void initDefaultSaveOptions() {
- if (defaultSaveOptions == null) {
- getDefaultSaveOptions();
- }
- }
-
- /**
- * @see org.eclipse.emf.ecore.resource.impl.ResourceImpl#getEObjectByID(String)
- */
- protected EObject getEObjectByID(String id) {
- if (idToEObjectMap != null) {
- EObject eObject = (EObject) idToEObjectMap.get(id);
- if (eObject != null) {
- return eObject;
- }
- }
- return null;
- }
-
- /**
- * Called when the object is unloaded. This implementation
- * {@link InternalEObject#eSetProxyURI sets}the object to be a proxy and clears the
- * {@link #eAdapters adapters}.
- */
- protected void unloaded(InternalEObject internalEObject) {
- //overridden from the super class; call super.getURIFragment instead of the implementation
- //at this level, to avoid ID generation during unload
- //internalEObject.eSetProxyURI(uri.appendFragment(getURIFragment(internalEObject)));
- internalEObject.eSetProxyURI(uri.appendFragment(super.getURIFragment(internalEObject)));
- internalEObject.eAdapters().clear();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#doLoad(java.io.InputStream,
- * java.util.Map)
- */
- public final void doLoad(InputStream inputStream, Map options) throws IOException {
- ExtendedEcoreUtil.addLoadingTag(this);
- try {
- basicDoLoad(inputStream, options);
- } finally {
- ExtendedEcoreUtil.removeLoadingTag(this);
- }
- }
-
- protected void basicDoLoad(InputStream inputStream, Map options) throws IOException {
- super.doLoad(inputStream, options);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#init()
- */
- protected void init() {
- super.init();
- setEncoding(DEFAULT_ENCODING);
- }
-
- protected XMLLoad createXMLLoad() {
- return new CompatibilityXMILoadImpl(createXMLHelper());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.internal.emf.resource.CompatibilityXMIResource#removePreservingIds(org.eclipse.emf.ecore.EObject)
- */
- public void removePreservingIds(EObject rootObject) {
- setPreserveIDs(true);
- getContents().remove(rootObject);
- }
-
- /**
- * @return Returns the preserveIDs.
- */
- public boolean isPreserveIDs() {
- return preserveIDs;
- }
-
- /**
- * @param preserveIDs
- * The preserveIDs to set.
- */
- public void setPreserveIDs(boolean preserveIDs) {
- this.preserveIDs = preserveIDs;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#detachedHelper(org.eclipse.emf.ecore.EObject)
- */
- protected void detachedHelper(EObject eObject) {
- if (modificationTrackingAdapter != null) {
- eObject.eAdapters().remove(modificationTrackingAdapter);
- }
-
- if (useUUIDs()) {
- DETACHED_EOBJECT_TO_ID_MAP.put(eObject, getID(eObject));
- }
-
- if (!isPreserveIDs() && idToEObjectMap != null && eObjectToIDMap != null) {
- idToEObjectMap.remove(eObjectToIDMap.remove(eObject));
- }
- }
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMISaveImpl.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMISaveImpl.java
deleted file mode 100644
index c1a7bf2..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMISaveImpl.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.internal.emf.resource;
-
-import java.util.Map;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.emf.ecore.xmi.XMLHelper;
-import org.eclipse.emf.ecore.xmi.XMLResource;
-import org.eclipse.emf.ecore.xmi.impl.XMISaveImpl;
-
-public class CompatibilityXMISaveImpl extends XMISaveImpl {
-
- /**
- * Constructor for CompatibilityXMISaveImpl.
- *
- * @param helper
- */
- public CompatibilityXMISaveImpl(XMLHelper helper) {
- super(helper);
- }
-
- /**
- * Constructor for CompatibilityXMISaveImpl.
- *
- * @param options
- * @param helper
- * @param encoding
- */
- public CompatibilityXMISaveImpl(Map options, XMLHelper helper, String encoding) {
- super(options, helper, encoding);
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMISaveImpl#init(XMLResource, Map)
- */
- protected void init(XMLResource resource, Map options) {
- super.init(resource, options);
- xmiType = true;
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMISaveImpl#addNamespaceDeclarations()
- */
- public void addNamespaceDeclarations() {
- doc.addAttribute(XMI_VER_NS, XMIResource.VERSION_VALUE);
- doc.addAttribute(XMI_XMLNS, XMIResource.XMI_URI);
- EPackage[] packages = helper.packages();
- StringBuffer xsiSchemaLocation = null;
- if (declareSchemaLocation) {
- for (int i = 0; i < packages.length; i++) {
- EPackage ePackage = packages[i];
-
- EObject root = EcoreUtil.getRootContainer(ePackage);
- if (root instanceof EPackage) {
- EPackage rootEPackage = (EPackage) root;
- Resource resource = rootEPackage.eResource();
- if (resource != null) {
- URI uri = resource.getURI();
- String rootNsURI = rootEPackage.getNsURI();
- if (uri == null ? rootNsURI != null : !uri.toString().equals(rootNsURI)) {
- declareXSI = true;
- if (xsiSchemaLocation == null) {
- xsiSchemaLocation = new StringBuffer();
- } else {
- xsiSchemaLocation.append(' ');
- }
- xsiSchemaLocation.append(rootNsURI);
- xsiSchemaLocation.append(' ');
- xsiSchemaLocation.append(helper.getHREF(rootEPackage));
- }
- }
- }
- }
- }
-
- if (declareXSI) {
- doc.addAttribute(XSI_XMLNS, XMLResource.XSI_URI);
- }
-
- for (int i = 0; i < packages.length; i++) {
- EPackage ePackage = packages[i];
- //Modified from superclass - dispatch back to helper for compatibility
- //String nsURI = ePackage.getNsURI();
- //String nsPrefix = ePackage.getNsPrefix();
- String[] nsInfo = ((MappedXMIHelper) helper).getNSInfo(ePackage);
- doc.addAttributeNS(XMLResource.XML_NS, nsInfo[0], nsInfo[1]);
- }
-
- if (xsiSchemaLocation != null) {
- doc.addAttribute(XSI_SCHEMA_LOCATION, xsiSchemaLocation.toString());
- }
- }
-
- protected void saveHref(EObject remote, EStructuralFeature f) {
- String name = helper.getQName(f);
- String href = helper.getHREF(remote);
- if (href != null) {
- doc.startElement(name);
- EClass eClass = remote.eClass();
-
- EClass expectedType = (EClass) f.getEType();
- //Changed next line to always write type if expectedType
- //is different from eClass
- if (eClass != expectedType) {
- saveTypeAttribute(eClass);
- }
-
- doc.addAttribute(XMLResource.HREF, href);
- doc.endEmptyElement();
- }
- }
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ConstantAttributeTranslator.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ConstantAttributeTranslator.java
deleted file mode 100644
index 356f102..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ConstantAttributeTranslator.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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
- *******************************************************************************/
-/*
- * Created on Apr 15, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * @author schacher
- */
-public class ConstantAttributeTranslator extends Translator {
-
- protected String attributeValue;
-
- /**
- * @param domNameAndPath
- * @param eClass
- */
- public ConstantAttributeTranslator(String domNameAndPath, String attributeValue) {
- super(domNameAndPath, null, DOM_ATTRIBUTE);
- this.attributeValue = attributeValue;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#getMOFValue(org.eclipse.emf.ecore.EObject)
- */
- public Object getMOFValue(EObject mofObject) {
- return attributeValue;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#isSetMOFValue(org.eclipse.emf.ecore.EObject)
- */
- public boolean isSetMOFValue(EObject emfObject) {
- return true;
- }
-
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/DefaultTranslatorFactory.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/DefaultTranslatorFactory.java
deleted file mode 100644
index 110a323..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/DefaultTranslatorFactory.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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
- *******************************************************************************/
-/*
- * Created on Aug 20, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.wst.common.emf.utilities.NamespaceAdapter;
-import org.eclipse.wst.common.internal.emf.utilities.Namespace;
-
-
-/**
- * @author schacher
- */
-public class DefaultTranslatorFactory implements VariableTranslatorFactory {
-
- public static final String XMLNS = "xmlns:"; //$NON-NLS-1$
- public static final DefaultTranslatorFactory INSTANCE = new DefaultTranslatorFactory();
-
- public DefaultTranslatorFactory() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.VariableTranslatorFactory#accepts(java.lang.String)
- */
- public boolean accepts(String domName) {
- return domName != null && domName.startsWith(XMLNS);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.VariableTranslatorFactory#accepts(org.eclipse.emf.common.notify.Notification)
- */
- public boolean accepts(Notification notif) {
- return notif.getFeature() == NamespaceAdapter.NOTIFICATION_FEATURE;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.VariableTranslatorFactory#create(java.lang.String)
- */
- public Translator create(String domName) {
- return new NamespaceTranslator(domName);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.VariableTranslatorFactory#create(org.eclipse.emf.ecore.EObject)
- */
- public List create(Notifier target) {
- if (!(target instanceof EObject))
- return null;
- List namespaces = NamespaceAdapter.getNamespaces((EObject) target);
- if (namespaces == null || namespaces.isEmpty())
- return null;
- List result = new ArrayList(namespaces.size());
- for (int i = 0; i < namespaces.size(); i++) {
- result.add(create((Namespace) namespaces.get(i)));
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.VariableTranslatorFactory#create(org.eclipse.emf.common.notify.Notification)
- */
- public Translator create(Notification notif) {
- Namespace ns = (Namespace) notif.getNewValue();
- return create(ns);
- }
-
- private Translator create(Namespace ns) {
- return new NamespaceTranslator(XMLNS + ns.getPrefix());
- }
-
-
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/DependencyTranslator.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/DependencyTranslator.java
deleted file mode 100644
index c7d1c62..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/DependencyTranslator.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 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
- *******************************************************************************/
-/*
- * Created on Mar 25, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * @author schacher
- */
-public class DependencyTranslator extends Translator {
-
- /**
- * @param domNameAndPath
- * @param aFeature
- */
- public DependencyTranslator(String domNameAndPath, EStructuralFeature aFeature, EStructuralFeature aDependentFeature) {
- super(domNameAndPath, aFeature);
- dependencyFeature = aDependentFeature;
- }
-
- public EObject getChild(EObject parent) {
- EObject child = basicGetDependencyObject(parent);
- if (child == null)
- return createChild(parent);
- return child;
- }
-
-
- protected EObject createChild(EObject parent) {
- EObject child = createEMFObject(dependencyFeature);
- parent.eSet(dependencyFeature, child);
- return child;
- }
-
- public List getMOFChildren(EObject mofObject) {
- //return super.getMOFChildren(getChild(mofObject));
- return super.getMOFChildren(mofObject);
- }
-
- public Object getMOFValue(EObject mofObject) {
- return super.getMOFValue(getChild(mofObject));
- }
-
- public void setMOFValue(EObject emfObject, Object value) {
- //super.setMOFValue(getChild(emfObject), value);
- super.setMOFValue(getChild(emfObject), value, -1);
- }
-
- public void setMOFValue(Notifier owner, Object value, int newIndex) {
- super.setMOFValue(getChild((EObject) owner), value, newIndex);
- }
-
- public void removeMOFValue(Notifier owner, Object value) {
- super.removeMOFValue(getChild((EObject) owner), value);
- }
-
- public boolean isSetMOFValue(EObject emfObject) {
- return super.isSetMOFValue(getChild(emfObject));
- }
-
- public void unSetMOFValue(EObject emfObject) {
- super.unSetMOFValue(getChild(emfObject));
- }
-
-
- public boolean isDependencyChild() {
- return true;
- }
-
- public boolean featureExists(EObject emfObject) {
- return super.featureExists(getChild(emfObject));
- }
-
- public void clearList(EObject mofObject) {
- super.clearList(getChild(mofObject));
- }
-
-
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapter.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapter.java
deleted file mode 100644
index 9782ea1..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.internal.emf.resource;
-
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.ecore.EObject;
-import org.w3c.dom.Node;
-
-public interface EMF2DOMAdapter extends Adapter {
-
-
- Class ADAPTER_CLASS = EMF2DOMAdapter.class;
-
- /**
- * Return the DOM node that the target of this adapter maps to. If the target MOF object maps to
- * more than one DOM node, this node is the top-most node.
- */
- Node getNode();
-
- void setNode(Node aNode);
-
- /**
- * Set to false and notification of changes from both the DOM node and the MOF object will be
- * ignored.
- */
- boolean isNotificationEnabled();
-
- /**
- * Set to false and notification of changes from both the DOM node and the MOF object will be
- * ignored.
- */
- void setNotificationEnabled(boolean isEnabled);
-
- /**
- * Updates the DOM tree for this adapter from the current values of the MOF Object. This method
- * updates ALL the DOM nodes from all the MOF attributes.
- */
- void updateDOM();
-
- /**
- * Updates the MOF Object from the DOM tree. All the children of the DOM tree are updated into
- * the MOF object.
- */
- void updateMOF();
-
- public void updateDOMFeature(Translator map, Node node, EObject mofObject);
-
- public void updateMOFFeature(Translator map, Node node, EObject mofObject);
-
- EObject getEObject();
-
- /**
- * Return true if MOF object is a proxy.
- */
- boolean isMOFProxy();
-
- /**
- * Remove the DOM adapters from the node AND all its child nodes, recursively.
- */
- void removeAdapters(Node node);
-}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapterImpl.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapterImpl.java
deleted file mode 100644
index 0321a1e..0000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapterImpl.java
+++ /dev/null
@@ -1,1740 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 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.eclipse.wst.common.internal.emf.resource;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.wst.common.emf.utilities.EtoolsCopySession;
-import org.eclipse.wst.common.emf.utilities.ExtendedEcoreUtil;
-import org.eclipse.wst.common.internal.emf.utilities.Assert;
-import org.eclipse.wst.common.internal.emf.utilities.DOMUtilities;
-import org.eclipse.wst.common.internal.emf.utilities.FeatureValueConversionException;
-import org.eclipse.wst.common.internal.emf.utilities.Revisit;
-import org.eclipse.wst.common.internal.emf.utilities.StringUtil;
-import org.eclipse.wst.common.internal.emf.utilities.WFTUtilsResourceHandler;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-
-
-public class EMF2DOMAdapterImpl extends AdapterImpl implements EMF2DOMAdapter {
-
- final protected static boolean fDebug = false;
-
- protected boolean fNotificationEnabled = true;
-
- protected Node fNode;
-
- protected Translator fTranslator;
-
- protected EMF2DOMRenderer fRenderer;
-
- protected Translator[] childTranslators;
-
- protected boolean isRoot = false;
-
- private class DependencyAdapter extends org.eclipse.emf.common.notify.impl.AdapterImpl {
-
- static final String KEY = "EMF2DOMDependencyAdapter"; //$NON-NLS-1$
-
- public void notifyChanged(Notification msg) {
- EMF2DOMAdapterImpl.this.notifyChanged(msg);
- }
-
- /**
- * @see org.eclipse.emf.common.notify.impl.AdapterImpl#isAdapterForType(Object)
- */
- public boolean isAdapterForType(Object type) {
- return KEY.equals(type);
- }
- }
-
- /**
- * Constructor for root adapters.
- */
- public EMF2DOMAdapterImpl(TranslatorResource resource, Document document, EMF2DOMRenderer renderer, Translator translator) {
- this((Notifier) resource, (Node) document, renderer, translator);
- isRoot = true;
- }
-
- /**
- * Construct an Adapter given an EObject and a node
- */
- public EMF2DOMAdapterImpl(Notifier object, Node node, EMF2DOMRenderer renderer, Translator translator) {
- super();
- setTarget(object);
- fNode = node;
- fRenderer = renderer;
- fTranslator = translator;
- initChildTranslators();
- addEMFAdapter();
- addDOMAdapter();
- addDependencyAdapterIfNecessary();
- }
-
- /**
- * Construct an adapter from a DOM Node. The EObject will be created
- */
- public EMF2DOMAdapterImpl(Node node, EMF2DOMRenderer renderer, Translator translator) {
- fNode = node;
- fRenderer = renderer;
- fTranslator = translator;
- setTargetFromNode();
- initChildTranslators();
- addEMFAdapter();
- addDOMAdapter();
- addDependencyAdapterIfNecessary();
-
- }
-
- protected void addDependencyAdapterIfNecessary() {
- if (!fTranslator.isDependencyParent())
- return;
- EObject child = fTranslator.basicGetDependencyObject(getEObject());
- if (child != null)
- addDependencyAdapter(child);
- }
-
- protected void initChildTranslators() {
-
- List children = new ArrayList();
- // TODO come up with translator extension mechanism
- //children.add(AnnotationsTranslator.INSTANCE);
- children.addAll(Arrays.asList(fTranslator.getChildren(getTarget(), fRenderer.getVersionID())));
-
- VariableTranslatorFactory factory = fTranslator.getVariableTranslatorFactory();
- if (factory != null) {
- String domName = null;
- NamedNodeMap map = fNode.getAttributes();
-
- if (map != null) {
- int length = map.getLength();
- for (int i = 0; i < length; i++) {
- Node attrNode = map.item(i);
- domName = attrNode.getNodeName();
- //Handle variable translators
- Translator t = fTranslator.findChild(domName, getTarget(), fRenderer.getVersionID());
- if (t != null && !children.contains(t))
- children.add(t);
- }
- }
- List childrenFromEMF = factory.create(getTarget());
- if (childrenFromEMF != null)
- children.addAll(childrenFromEMF);
- }
-
- childTranslators = (Translator[]) children.toArray(new Translator[children.size()]);
- }
-
- /**
- * Set to false and notification of changes from both the DOM node and the MOF object will be
- * ignored.
- */
- public boolean isNotificationEnabled() {
- return fNotificationEnabled;
- }
-
- /**
- * Set to false and notification of changes from both the DOM node and the MOF object will be
- * ignored.
- */
- public void setNotificationEnabled(boolean isEnabled) {
- fNotificationEnabled = isEnabled;
- }
-
- public boolean isAdapterForType(Object type) {
- return EMF2DOMAdapter.ADAPTER_CLASS == type;
- }
-
- protected void addEMFAdapter() {
- target.eAdapters().add(this);
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append(shortClassName(this));
- sb.append('(');
- sb.append(getNode().getNodeName());
- sb.append(',');
- sb.append(shortClassName(getTarget()));
- sb.append(')');
- return sb.toString();
- }
-
- protected String shortClassName(Object o) {
- String cn = o.getClass().getName();
- int i = cn.lastIndexOf('.');
- return cn.substring(i + 1, cn.length());
- }
-
- /*
- * Prints out a MOF notification for debugging
- */
- protected void debugMOFNotify(Notification msg) {
- if (fDebug) {
- String notifType = ""; //$NON-NLS-1$
- switch (msg.getEventType()) {
- case Notification.ADD :
- notifType = "ADD"; //$NON-NLS-1$
- break;
- case Notification.REMOVE :
- notifType = "REMOVE"; //$NON-NLS-1$
- break;
- case Notification.ADD_MANY :
- notifType = "ADD_MANY"; //$NON-NLS-1$
- break;
- case Notification.REMOVE_MANY :
- notifType = "REMOVE_MANY"; //$NON-NLS-1$
- break;
- case Notification.SET : {
- if (msg.getPosition() == Notification.NO_INDEX)
- notifType = "REPLACE"; //$NON-NLS-1$
- else
- notifType = "SET"; //$NON-NLS-1$
- break;
- }
- case Notification.UNSET :
- notifType = "UNSET"; //$NON-NLS-1$
- break;
- }
-
- com.ibm.wtp.common.logger.proxy.Logger.getLogger().logError("MOF Change: " + notifType); //$NON-NLS-1$
- com.ibm.wtp.common.logger.proxy.Logger.getLogger().logError("\tnotifier : " + msg.getNotifier()); //$NON-NLS-1$
- com.ibm.wtp.common.logger.proxy.Logger.getLogger().logError("\tchangedFeature: " + msg.getFeature()); //$NON-NLS-1$
- com.ibm.wtp.common.logger.proxy.Logger.getLogger().logError("\toldValue : " + msg.getOldValue()); //$NON-NLS-1$
- com.ibm.wtp.common.logger.proxy.Logger.getLogger().logError("\tnewValue : " + msg.getNewValue()); //$NON-NLS-1$
- }
- }
-
- /*
- * Override this method to create the feature maps for the adapter.
- */
- protected Translator[] getChildTranslators() {
- return childTranslators;
- }
-
- protected Translator findTranslator(Notification not) {
- if (not.getFeature() == null)
- return null;
- Translator[] maps = getChildTranslators();
- for (int i = 0; i < maps.length; i++) {
- if (maps[i].isMapFor(not.getFeature(), not.getOldValue(), not.getNewValue()))
- return maps[i];
- }
- return null;
- }
-
- /**
- * Update all the children of the target MOF object in the relationship described by
- *
- * @map.
- *
- * @param map
- * com.ibm.etools.mof2dom.AttributeTranslator Describes the mapping from the MOF
- * attribute name to the DOM node name
- */
- protected void primUpdateDOMMultiFeature(Translator map, Node node, List mofChildren, List domChildren, Notifier owner) {
-
- //Used for inserting primitives
- List inorderDOMChildren = null;
- if (!map.isObjectMap() || map.isManagedByParent()) {
- inorderDOMChildren = new ArrayList();
- inorderDOMChildren.addAll(domChildren);
- }
- Node parent = findDOMPath(node, map, false);
-
- // Go though the MOF children checking to see if the corresponding
- // MOF Adapter children exists. If not, create the adapter.
- // Also handles reordering children that have moved.
- int i = 0;
- for (; i < mofChildren.size(); i++) {
- Object child = mofChildren.get(i);
- EObject mofChild = null;
-
- EMF2DOMAdapter adapter = null;
-
- // Check to see if the child is a MOF Object.
- if (!map.isManagedByParent() && child instanceof EObject) {
- mofChild = (EObject) mofChildren.get(i);
- adapter = getExistingAdapter(mofChild);
- }
-
- if (adapter != null && i < domChildren.size() && domChildren.get(i) == adapter.getNode())
- continue;
- if (adapter != null) {
- if (domChildren.isEmpty())
- continue;
- // A node has been reordered in the list
- Node reorderNode = adapter.getNode();
- Node insertBeforeNode = (Node) domChildren.get(i);
- domChildren.remove(reorderNode);
- domChildren.add(i, reorderNode);
- if (reorderNode != insertBeforeNode) {
- reorderDOMChild(parent, reorderNode, insertBeforeNode, map);
- }
- } else {
- // A new node has been added, create it
- parent = createDOMPath(node, map);
- if (mofChild != null) {
- adapter = createAdapter(mofChild, map);
- Node newNode = adapter.getNode();
- Node insertBeforeNode = findInsertBeforeNode(parent, map, mofChildren, i, domChildren);
- DOMUtilities.insertBeforeNodeAndWhitespace(parent, newNode, insertBeforeNode);
- domChildren.add(i, newNode);
- boolean notificationFlag = adapter.isNotificationEnabled();
- adapter.setNotificationEnabled(false);
- try {
- indent(newNode, map);
- } finally {
- adapter.setNotificationEnabled(notificationFlag);
- }
- adapter.updateDOM();
- } else {
- // The mof feature is a collection of primitives.
- // create a new dom node and listen to it.
- Element newNode = createNewNode(null, map);
- Node insertBeforeNode = findInsertBeforeNode(parent, map, mofChildren, i, inorderDOMChildren);
- DOMUtilities.insertBeforeNodeAndWhitespace(parent, newNode, insertBeforeNode);
- indent(newNode, map);
- addDOMAdapter(newNode); // Hook up listeners
- domChildren.add(i, newNode);
- inorderDOMChildren.add(newNode);
- Text newText = parent.getOwnerDocument().createTextNode(map.convertValueToString(child, (EObject) owner));
- DOMUtilities.insertBeforeNode(newNode, newText, null);
- }
- }
- }
-
- // Remove any remaining adapters.
- for (; i < domChildren.size(); i++) {
- removeDOMChild(parent, (Element) domChildren.get(i));
- }
-
- // If there are no MOF children, remove any unnecessary DOM node paths
- if (mofChildren.size() == 0 && map.hasDOMPath()) {
- if (map.shouldRenderEmptyDOMPath((EObject) owner))
- createDOMPath(node, map);
- else
- removeDOMPath(node, map);
- }
-
- }
-
- /**
- * Update all the children of the target MOF object in the relationship described by
- *
- * @map.
- *
- * @param map
- * com.ibm.etools.mof2dom.AttributeTranslator Describes the mapping from the MOF
- * attribute name to the DOM node name
- */
- protected void primUpdateMOFMultiFeature(Translator map, Node node, List mofChildren, List domChilren) {
-
- Hashtable nodeToAdapter = new Hashtable();
-
- for (int i = 0; i < mofChildren.size(); i++) {
- EMF2DOMAdapter adapter = getExistingAdapter((EObject) mofChildren.get(i));
- if (adapter != null)
- nodeToAdapter.put(adapter.getNode(), adapter);
- }
-
- // Go though the DOM children checking to see if the corresponding
- // MOF Adapter children exists. If not, create the adapter.
- // Also handles reordering children that have moved.
- int i = 0;
- int mofIndex = 0;
- List adaptersToUpdate = new ArrayList();
- for (; i < domChilren.size(); i++) {
- Element childNode = (Element) domChilren.get(i);
- EMF2DOMAdapter adapter = i < mofChildren.size() ? getExistingAdapter((EObject) mofChildren.get(i)) : null;
- if (adapter != null && !adapter.isMOFProxy() && adapter.getNode() == childNode) {
- // Because the adapter is processing STRUCTURE_CHANGED from the
- // DOM, we
- // must update all the way down the tree since anything under
- // the notifying
- // DOM node could have changed.
- adapter.updateMOF();
- mofIndex++;
- continue;
- }
-
- adapter = (EMF2DOMAdapter) nodeToAdapter.get(childNode);
- if (adapter != null) {
- reorderIfNecessary((EList) mofChildren, adapter.getEObject(), mofIndex);
- mofIndex++;
- } else {
- adapter = createAdapter(childNode, map);
- if (adapter != null) {
- try {
- //We don't want to push anything back to the child dom
- adapter.setNotificationEnabled(false);
- map.setMOFValue(getTarget(), adapter.getTarget(), mofIndex);
- } finally {
- adapter.setNotificationEnabled(true);
- }
-
- adaptersToUpdate.add(adapter);
- mofIndex++;
- }
- }
- }
-
- // Remove any remaining adapters.
- for (; i < mofChildren.size();) {
- removeMOFValue((EObject) mofChildren.get(i), map);
- }
-
- // The adapters cannot be updated as they created. We must wait until
- // all of the adapters are created and removed before updating,
- // otherwise
- // we can get in a state where there are adapters fighting with
- // eachother
- // (one for the old node and one for the new node).
- for (int j = 0; j < adaptersToUpdate.size(); j++) {
- ((EMF2DOMAdapter) adaptersToUpdate.get(j)).updateMOF();
- }
- }
-
- /**
- * Removes a feature's value.
- *
- * @param childAdapter
- * com.ibm.etools.mof2dom.EMF2DOMAdapter The child to remove
- * @param mofAttributeName
- * String The name of the mofAttribute to remove the child from.
- */
- protected void removeMOFValue(EObject value, Translator translator) {
-
- if (value == null)
- return;
-
- EMF2DOMAdapter adapter = (EMF2DOMAdapter) EcoreUtil.getExistingAdapter(value, EMF2DOMAdapter.ADAPTER_CLASS);
- if (adapter != null) {
- // Remove the adapter from BOTH the MOF Object and the DOM Nodes
- value.eAdapters().remove(adapter);
- removeAdapters(adapter.getNode());
- }
-
- EStructuralFeature feature = translator.getFeature();
- boolean doUnload = feature == null || (translator.isObjectMap() && ((EReference) feature).isContainment());
-
- // translator.removeMOFValue() was here originally
-
- // Unload the objects.
- if (doUnload)
- ExtendedEcoreUtil.unload(value);
-
- // Remove the MOF value
- translator.removeMOFValue(getTarget(), value);
- }
-
- protected void reorderIfNecessary(EList emfChildren, EObject eObj, int emfIndex) {
- int currIndex = emfChildren.indexOf(eObj);
- if (currIndex > -1 && currIndex != emfIndex)
- emfChildren.move(emfIndex, eObj);
- }
-
- /**
- * default is to do nothing; subclasses can override
- */
- protected void indent(Node newNode, Translator map) {
-
- }
-
- protected Node findInsertBeforeNode(Node parentNode, Translator map, List mofList, int mofInx, List domList) {
- Node insertBeforeNode = null;
-
- // If there are no current dom children for this map, find the initial
- // insert pos.
- if (domList.size() == 0)
- return findInitialInsertBeforeNode(parentNode, map);
-
- // If some dom nodes then find the correct one to insert before.
- int i = mofInx + 1;
- while (i < mofList.size() && insertBeforeNode == null) {
- // Start at the mofInx passed in and look forward for the first
- // adapted
- // MOF object. Use that node as the insert before node.
- Object o = mofList.get(i);
- if (!map.isObjectMap() || map.isManagedByParent())
- break;
- EObject tMOFObject = (EObject) o;
- EMF2DOMAdapter tAdapter = (EMF2DOMAdapter) EcoreUtil.getExistingAdapter(tMOFObject, EMF2DOMAdapter.ADAPTER_CLASS);
- if (tAdapter != null) {
- insertBeforeNode = tAdapter.getNode();
- }
- i++;
- }
-
- // Handle inserting at the end of the list
- if (insertBeforeNode == null)
- insertBeforeNode = DOMUtilities.getNextNodeSibling((Node) domList.get(domList.size() - 1));
- if (insertBeforeNode == null)
- insertBeforeNode = ((Node) domList.get(domList.size() - 1)).getNextSibling();
-
- return insertBeforeNode;
- }
-
- protected Node findInitialInsertBeforeNode(Node parentNode, Translator mapNode) {
- Translator[] maps = getChildTranslators();
-
- // First, skip past all the maps in the ordered collection
- // of maps. We want to begin the search with this node.
- int i = 0;
- for (; i < maps.length; i++) {
- if (maps[i] == mapNode)
- break;
- }
-
- // Now search go through each map node until a child node matching
- // its DOM name is found.
- Node insertBeforeNode = null;
- for (int j = i; j < maps.length && insertBeforeNode == null; j++) {
- NodeList childNodes = parentNode.getChildNodes();
- Translator nodeToFindMap = maps[j];
- for (int k = 0; k < childNodes.getLength(); k++) {
- Node node = childNodes.item(k);
- if (nodeToFindMap.isMapFor(node.getNodeName())) {
- insertBeforeNode = node;
- break;
- }
- }
- }
- return insertBeforeNode;
- }
-
- /*
- * Traverses the path that <map> specifies. Returns the last node of the path that was able to
- * be traversed or null if the path could not be traversed. The <addAdapters> boolean is used to
- * determine if the receiver is added as an adapter to every node found on the path.
- */
- protected Node findDOMPath(Node parent, Translator map, boolean addAdapters) {
-
- String path = map.getDOMPath();
- Node curNode = parent;
- Iterator iter = DOMUtilities.createPathIterator(path);
-
- while (curNode != null && iter.hasNext()) {
- String nodeName = (String) iter.next();
- curNode = DOMUtilities.getNodeChild(curNode, nodeName);
- if (addAdapters && curNode != null) {
- addDOMAdapter(curNode);
- }
- }
- return curNode;
- }
-
- /**
- * Return the list of DOM node children that currently exist with the specified tagname.
- */
- protected List getDOMChildren(Node node, Translator map) {
- Node parent = findDOMPath(node, map, true);
- if (parent != null)
- return DOMUtilities.getNodeChildren(parent, map.getDOMNames());
- return new ArrayList();
- }
-
- protected EMF2DOMAdapter getExistingAdapter(EObject refObject) {
- EMF2DOMAdapter adapter = (EMF2DOMAdapter) EcoreUtil.getExistingAdapter(refObject, EMF2DOMAdapter.ADAPTER_CLASS);
- if (adapter != null && adapter.isMOFProxy()) {
- refObject.eAdapters().remove(adapter);
- removeDOMAdapter(adapter.getNode(), adapter);
- adapter = null;
- }
- return adapter;
- }
-
- protected void primAddDOMAdapter(Node aNode, EMF2DOMAdapter anAdapter) {
- fRenderer.registerDOMAdapter(aNode, anAdapter);
- }
-
- protected EMF2DOMAdapter primGetExistingAdapter(Node aNode) {
- return fRenderer.getExistingDOMAdapter(aNode);
- }
-
- protected void removeDOMAdapter(Node aNode, EMF2DOMAdapter anAdapter) {
- fRenderer.removeDOMAdapter(aNode, anAdapter);
- }
-
- protected void addDOMAdapter(Node childNode) {
-
- // Only add the adapter if this is an child node that will not be
- // adapted. For instance a subtree that maps to a MOF attribute
- // setting.
- if (childNode.getNodeType() == Node.ELEMENT_NODE) {
- EMF2DOMAdapter attrAdapter = primGetExistingAdapter(childNode);
-
- if (attrAdapter == null || attrAdapter.getNode() != getNode()) {
- // If the node is adapted, but not by this adapter then remove
- // it. This happens to non-object children when the parent tag
- // name is changed.
- removeDOMAdapter(childNode, attrAdapter);
-
- if (fDebug) {
- com.ibm.wtp.common.logger.proxy.Logger.getLogger().logError("\tCHILD: Adding DOM adapter: " + this); //$NON-NLS-1$
- com.ibm.wtp.common.logger.proxy.Logger.getLogger().logError("\t\tto: " + childNode); //$NON-NLS-1$
- }
- primAddDOMAdapter(childNode, this);
- }
- }
- }
-
- /**
- * Reorder a child before a given node
- */
- protected void reorderDOMChild(Node parentNode, Node childNode, Node insertBeforeNode, Translator map) {
- removeDOMChild(parentNode, childNode, false);
- parentNode.insertBefore(childNode, insertBeforeNode);
- }
-
- protected String getNewlineString(Node node) {
- return DOMUtilities.NEWLINE_STRING;
- }
-
- protected String primGetIndentString(Node node) {
- return DOMUtilities.getIndentString(node);
- }
-
- /**
- * Remove a child node
- */
- protected void removeDOMChild(Node parentNode, Node childNode) {
- removeDOMChild(parentNode, childNode, true);
- }
-
- /**
- * Remove a child node
- */
- protected void removeDOMChild(Node parentNode, Node childNode, boolean removeAdapter) {
- if (childNode == null)
- return;
-
- // Look for any whitespace preceeding the node being
- // removed and remove it as well.
- Text prevText = DOMUtilities.getPreviousTextSibling(childNode);
- if (prevText != null && DOMUtilities.isWhitespace(prevText)) {
- parentNode.removeChild(prevText);
- }
-
- // Remove the node.
- if (removeAdapter)
- removeAdapters(childNode);
-
- parentNode.removeChild(childNode);
- }
-
- /**
- * Remove the DOM adapters from the node AND all its child nodes, recursively.
- */
- public void removeAdapters(Node node) {
- EMF2DOMAdapter adapter = primGetExistingAdapter(node);
- if (adapter != null) {
- // Remove the adapter from both the DOM node and the MOF Object.
- removeDOMAdapter(node, adapter);
- if (adapter.getNode() == node) {
- Notifier localTarget = adapter.getTarget();
- if (localTarget != null)
- localTarget.eAdapters().remove(adapter);
- }
- }
-
- NodeList nl = node.getChildNodes();
- for (int i = 0; i < nl.getLength(); i++) {
- Node n = nl.item(i);
- removeAdapters(n);
- }
- }
-
- /**
- * Creates the path specified by <map>under <node>. Only the portion of the path that does not
- * exist (if any) is created
- *
- * @param node
- * org.w3c.dom.Node
- * @param map
- * com.ibm.etools.mof2dom.Translator
- */
- protected Node createDOMPath(Node node, Translator map) {
- Iterator i = DOMUtilities.createPathIterator(map.getDOMPath());
- Node curNode = node;
- while (i.hasNext()) {
- String nodeName = (String) i.next();
- curNode = findOrCreateNode(node, map, nodeName);
- }
- return curNode;
- }
-
- protected Element findOrCreateNode(Node parent, Translator map, String segment) {
- Node node = DOMUtilities.getNodeChild(parent, segment);
- if (node == null) {
- // The node did not already exist, create it.
- Document doc = parent.getOwnerDocument();
- node = doc.createElement(segment);
- if (map.isEmptyTag())
- setEmptyTag((Element) node);
-
- Node insertBeforeNode = findInitialInsertBeforeNode(parent, map);
- DOMUtilities.insertBeforeNodeAndWhitespace(parent, node, insertBeforeNode);
- indent(node, map);
- addDOMAdapter(node); // Hook up listeners
- }
- return (Element) node;
- }
-
- /**
- * Remove the node passed in if it has only whitespace nodes as children
- *
- * @param node
- * org.w3c.dom.Node The node to check
- */
- protected void removeIfEmpty(Node node) {
- NodeList nl = node.getChildNodes();
-
- // Run through all the nodes children. If a non-whitespace node
- // pis found, bail.
- for (int i = 0; i < nl.getLength(); i++) {
- Node childNode = nl.item(i);
- if (!DOMUtilities.isWhitespace(childNode))
- return;
- }
-
- // We only get here if there are no non-whitespace chars, so
- // simply remove the node.
- removeDOMChild(node.getParentNode(), node);
- }
-
- /**
- * Remove the DOM path specified by <map>from <node>
- */
- protected void removeDOMPath(Node node, Translator map) {
- Node childNode = findDOMPath(node, map, false);
- while (childNode != null && childNode != node) {
- removeIfEmpty(childNode);
- childNode = childNode.getParentNode();
- }
- }
-
- /**
- * Create an adapter for a child DOM node
- *
- * @param node
- * org.w3c.dom.Node The node to create the adapter for.
- */
- protected EMF2DOMAdapter createAdapter(EObject mofObject, Translator childMap) {
- // Assert.isNotNull(childMap.getChildAdapterClass());
- Assert.isNotNull(mofObject);
-
- EMF2DOMAdapter adapter = (EMF2DOMAdapter) EcoreUtil.getAdapter(mofObject.eAdapters(), EMF2DOMAdapter.ADAPTER_CLASS);
-
- if (adapter != null && adapter.isMOFProxy()) {
- mofObject.eAdapters().remove(adapter);
- removeAdapters(adapter.getNode());
- adapter = null;
- }
- if (adapter == null)
- adapter = primCreateAdapter(mofObject, childMap);
- return adapter;
- }
-
- /**
- * Create an adapter for a child DOM node
- *
- * @param node
- * org.w3c.dom.Node The node to create the adapter for.
- */
- protected EMF2DOMAdapter primCreateAdapter(EObject mofObject, Translator childMap) {
-
- Element newNode = createNewNode(mofObject, childMap);
- return new EMF2DOMAdapterImpl(mofObject, newNode, fRenderer, childMap);
- }
-
- /**
- * Create an adapter for a child DOM node
- *
- * @param node
- * org.w3c.dom.Node The node to create the adapter for.
- */
- protected EMF2DOMAdapter primCreateAdapter(Node node, Translator childMap) {
- return new EMF2DOMAdapterImpl(node, fRenderer, childMap);
- }
-
- /**
- * Create an adapter for a child DOM node
- *
- * @param node
- * org.w3c.dom.Node The node to create the adapter for.
- */
- protected EMF2DOMAdapter createAdapter(Node node, Translator childMap) {
-
- //Assert.isNotNull(childMap.getChildAdapterClass());
- Assert.isNotNull(node);
-
- EMF2DOMAdapter adapter = primGetExistingAdapter(node);
-
- if (adapter != null && adapter.isMOFProxy()) {
- removeDOMAdapter(node, adapter);
- adapter.getTarget().eAdapters().remove(adapter);
- adapter = null;
- }
-
- if (adapter == null) {
- adapter = primCreateAdapter(node, childMap);
- }
- return adapter;
- }
-
- protected Element createNewNode(EObject mofObject, Translator childMap) {
- Node node = getNode();
- Document doc = (node instanceof Document) ? (Document) node : node.getOwnerDocument();
-
- Element element = doc.createElement(childMap.getDOMName(mofObject));
- if (childMap.isEmptyTag())
- setEmptyTag(element);
-
- return element;
- }
-
- protected void setEmptyTag(Element element) {
- Revisit.toDo();
- //Need to figure out how to do this with pure DOM apis, if it is
- // possible
- }
-
- /*
- * Return true if MOF object is a proxy.
- */
- public boolean isMOFProxy() {
- if (isRoot || target == null)
- return false;
- return ((InternalEObject) target).eIsProxy();
- }
-
- public EObject getEObject() {
- if (isRoot)
- return null;
- return (EObject) target;
- }
-
- /**
- * Return the DOM node that the target of this adapter maps to. If the target MOF object maps to
- * more than one DOM node, this node is the top-most node.
- */
- public Node getNode() {
- return fNode;
- }
-
- public void setNode(Node aNode) {
- fNode = aNode;
- }
-
- public void updateDOM() {
- if (!isNotificationEnabled())
- return;
- primUpdateDOM();
- }
-
- public void updateMOF() {
- if (!isNotificationEnabled())
- return;
- primUpdateMOF();
- }
-
- protected void primUpdateDOM() {
- if (isRoot)
- updateDOMRootFeature();
- else {
- Translator[] maps = getChildTranslators();
- for (int i = 0; i < maps.length; i++) {
- updateDOMFeature(maps[i], getNode(), getEObject());
- }
- }
- }
-
- public void primUpdateMOF() {
- if (isRoot)
- updateMOFRootFeature();
- else {
- Translator[] maps = getChildTranslators();
- for (int i = 0; i < maps.length; i++) {
- updateMOFFeature(maps[i], getNode(), getEObject());
- }
- }
- }
-
- protected void updateDOMRootFeature() {
- boolean notificationFlag = isNotificationEnabled();
- try {
- setNotificationEnabled(false);
- primUpdateDOMMultiFeature(fTranslator, fNode, getResourceContents(), getDOMChildren(fNode, fTranslator), null);
- updateDOMDocumentType();
- } finally {
- setNotificationEnabled(notificationFlag);
- }
- }
-
- protected void updateMOFRootFeature() {
- boolean notificationFlag = isNotificationEnabled();
- try {
- setNotificationEnabled(false);
- updateMOFDocumentType();
- primUpdateMOFMultiFeature(fTranslator, fNode, getResourceContents(), getDOMChildren(fNode, fTranslator));
- } finally {
- setNotificationEnabled(notificationFlag);
- }
- }
-
- protected DocumentType getDocumentType() {
- return ((Document) fNode).getDoctype();
- }
-
- protected TranslatorResource getResource() {
- return (TranslatorResource) getTarget();
- }
-
- protected EList getResourceContents() {
- if (!isRoot)
- throw new IllegalStateException();
- return ((Resource) getTarget()).getContents();
- }
-
- protected void updateDOMDocumentType() {
-
- DocumentType docType = getDocumentType();
- String publicId = null, systemId = null, oldPublicId, oldSystemId;
- oldPublicId = docType == null ? null : docType.getPublicId();
- oldSystemId = docType == null ? null : docType.getSystemId();
- TranslatorResource resource = getResource();
- if (resource != null) {
- publicId = resource.getPublicId();
- systemId = resource.getSystemId();
- }
- if (!(StringUtil.stringsEqual(publicId, oldPublicId) && StringUtil.stringsEqual(systemId, oldSystemId)))
- fRenderer.replaceDocumentType(resource.getDoctype(), publicId, systemId);
- }
-
- protected void updateDOMDocumentType(Notification msg) {
- if (msg.getFeature() == TranslatorResource.DOC_TYPE_FEATURE)
- updateDOMDocumentType();
- }
-
- protected void updateMOFDocumentType() {
-
- TranslatorResource resource = getResource();
- if (resource == null)
- return;
-
- String publicId = null, systemId = null;
- DocumentType docType = getDocumentType();
-
- if (docType != null) {
- publicId = docType.getPublicId();
- systemId = docType.getSystemId();
- }
- if (!(StringUtil.stringsEqual(publicId, resource.getPublicId()) && StringUtil.stringsEqual(systemId, resource.getSystemId())))
- resource.setDoctypeValues(publicId, systemId);
- }
-
- public void notifyChanged(Notification msg) {
-
- if (isRoot) {
- notifyChangedForRoot(msg);
- return;
- }
- if (isDependencyFeature(msg))
- handleDependencyFeature(msg);
-
- if (!isNotificationEnabled())
- return;
-
- debugMOFNotify(msg);
-
- switch (msg.getEventType()) {
- case Notification.ADD :
- case Notification.REMOVE :
- case Notification.ADD_MANY :
- case Notification.REMOVE_MANY :
- case Notification.SET :
- case Notification.UNSET :
- case Notification.MOVE :
- Translator translator = findTranslator(msg);
- if (translator == null)
- translator = addVariableTranslatorIfNecessary(msg);
- if (translator != null)
- updateDOMFeature(translator, getNode(), getEObject());
- break;
- }
- }
-
- protected void notifyChangedForRoot(Notification msg) {
- if (!isNotificationEnabled())
- return;
-
- debugMOFNotify(msg);
-
- switch (msg.getEventType()) {
- case Notification.ADD :
- case Notification.REMOVE :
- case Notification.ADD_MANY :
- case Notification.REMOVE_MANY :
- primUpdateDOM();
- break;
- case Notification.SET :
- updateDOMDocumentType(msg);
- break;
- case EtoolsCopySession.RESOURCE_COPIED :
- updateDOM();
- break;
- }
- }
-
- protected void addDependencyAdapter(EObject child) {
- Adapter existing = EcoreUtil.getExistingAdapter(child, DependencyAdapter.KEY);
- if (existing != null)
- return;
- DependencyAdapter forwarder = new DependencyAdapter();
- child.eAdapters().add(forwarder);
- forwarder.setTarget(child);
- }
-
- protected void addDOMAdapter() {
-
- primAddDOMAdapter(fNode, this);
- if (fDebug) {
- com.ibm.wtp.common.logger.proxy.Logger.getLogger().logError("Adding DOM adapter: " + this); //$NON-NLS-1$
- com.ibm.wtp.common.logger.proxy.Logger.getLogger().logError("\tto: " + fNode); //$NON-NLS-1$
- }
-
- // Go through the maps. All of the DOM nodes that are not listened
- // to by another DOM Node adapter, must be listened to by this adapter.
- NodeList childNodes = fNode.getChildNodes();
- for (int j = 0; j < childNodes.getLength(); j++) {
- Node childNode = childNodes.item(j);
- int nodeType = childNode.getNodeType();
- if (!DOMUtilities.isTextNode(childNode) && nodeType != Node.COMMENT_NODE) {
- Translator map = findTranslator(childNode.getNodeName(), false);
- if (map != null && map.isManagedByParent())
- addDOMAdapter(childNode);
- }
- }
- }
-
- protected Translator addVariableTranslatorIfNecessary(Notification msg) {
- VariableTranslatorFactory fact = fTranslator.getVariableTranslatorFactory();
- Translator trans = null;
- if (fact != null && fact.accepts(msg)) {
- trans = fact.create(msg);
- if (trans != null)
- childTranslators = (Translator[]) Translator.concat(childTranslators, trans);
- }
- return trans;
- }
-
- protected Text createTextNode(Document doc, Translator map, String text) {
- String nonnulltext = (text != null) ? text : ""; //$NON-NLS-1$
- return map.isCDATAContent() ? doc.createCDATASection(nonnulltext) : doc.createTextNode(nonnulltext);
- }
-
- protected String extractReadAheadName() {
- if (!fTranslator.hasReadAheadNames())
- return null;
- String readAheadName = null;
-
- ReadAheadHelper helper = fTranslator.getReadAheadHelper(fNode.getNodeName());
- if (helper == null)
- return null;
-
- Node child = null;
- String[] names = helper.getValues();
- if (helper.getChildDOMName() == null) {
- for (int i = 0; i < names.length; i++) {
- child = DOMUtilities.getNodeChild(fNode, names[i]);
- if (child != null) {
- readAheadName = names[i];
- break;
- }
- }
- } else {
- child = DOMUtilities.getNodeChild(fNode, helper.getChildDOMName());
- if (child != null)
- readAheadName = DOMUtilities.getChildText(child);
- }
- if (readAheadName == null)
- readAheadName = names[0];
- return readAheadName;
- }
-
- /**
- * Extracts the text from <node>and converts it to an object suitable for setting into <feature>
- */
- protected Object extractValue(Node node, Translator map, EObject emfObject) {
-
- // Extract the value from the text child
- Node textNode = DOMUtilities.getChildTextNode(node);
- String trimmedValue = null;
- if (textNode != null)
- trimmedValue = textNode.getNodeValue();
- try {
- return map.convertStringToValue(trimmedValue, emfObject);
- } catch (FeatureValueConversionException ex) {
- handleFeatureValueConversionException(ex);
- return null;
- }
- }
-
- /**
- * @param ex
- */
- protected void handleFeatureValueConversionException(FeatureValueConversionException ex) {
- throw ex;
-
- }
-
- /*
- * Finds the child node that <map> specifies. If there is more than one child that satisfies
- * <map> then the first one is returned.
- *
- * This method traverses past the domPath if one is specified in the <map>.
- */
- protected Node findDOMNode(Node parent, Translator map) {
- return findDOMNode(parent, map, false);
- }
-
- /*
- * Finds the child node that <map> specifies. If there is more than one child that satisfies
- * <map> then the first one is returned. The <addAdapters> boolean is used to determine if the
- * receiver is added as an adapter to every node found on the path.
- *
- * This method traverses past the domPath if one is specified in the <map>.
- */
- protected Node findDOMNode(Node parent, Translator map, boolean addAdapters) {
-
- // First, trace down the path
- Node curNode = findDOMPath(parent, map, addAdapters);
- if (map.isDOMTextValue() || map.isDOMAttribute() || curNode == null)
- return curNode;
-
- // Now look for the first DOM name we can find
- String[] domNames = map.getDOMNames();
- Node node = null;
- for (int i = 0; i < domNames.length; i++) {
- String nodeName = domNames[i];
- List nodes = DOMUtilities.getNodeChildren(curNode, nodeName);
- if (nodes != null && !nodes.isEmpty()) {
- if (nodes.size() > 1)
- handleInvali