diff options
author | afinkbein | 2008-12-01 16:52:33 +0000 |
---|---|---|
committer | afinkbein | 2008-12-01 16:52:33 +0000 |
commit | fc29cc94d8deea7e3056ff60d8e251877508e083 (patch) | |
tree | 754f1f55f59511edb6eabffe021cfcdfaafc087f | |
parent | 5fee5218711d4efcb9b41437b63a28b46c712da0 (diff) | |
download | org.eclipse.osee-fc29cc94d8deea7e3056ff60d8e251877508e083.tar.gz org.eclipse.osee-fc29cc94d8deea7e3056ff60d8e251877508e083.tar.xz org.eclipse.osee-fc29cc94d8deea7e3056ff60d8e251877508e083.zip |
17 files changed, 1000 insertions, 0 deletions
diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/.classpath b/0.5.0_20081201/org.eclipse.osee.framework.svn/.classpath new file mode 100644 index 00000000000..02159672985 --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/.project b/0.5.0_20081201/org.eclipse.osee.framework.svn/.project new file mode 100644 index 00000000000..51f10227857 --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.osee.framework.svn</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/0.5.0_20081201/org.eclipse.osee.framework.svn/.settings/org.eclipse.jdt.core.prefs b/0.5.0_20081201/org.eclipse.osee.framework.svn/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..a8020f2dc2e --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +#Fri Mar 28 14:00:57 GMT 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/META-INF/MANIFEST.MF b/0.5.0_20081201/org.eclipse.osee.framework.svn/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..e1d9e08be30 --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/META-INF/MANIFEST.MF @@ -0,0 +1,24 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: OSEE Svn Integration (Incubation) +Bundle-SymbolicName: org.eclipse.osee.framework.svn +Bundle-Version: 0.4.0.qualifier +Bundle-Activator: org.eclipse.osee.framework.svn.SvnActivator +Bundle-Vendor: Eclipse.org +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.core.resources, + org.eclipse.team.ui, + org.eclipse.osee.framework.plugin.core, + org.eclipse.team.core, + org.polarion.eclipse.team.svn.connector, + org.eclipse.team.svn, + org.eclipse.team.svn.core, + org.eclipse.team.svn.ui +Bundle-ActivationPolicy: lazy +Export-Package: org.eclipse.osee.framework.svn, + org.eclipse.osee.framework.svn.entry, + org.eclipse.osee.framework.svn.enums +Bundle-ClassPath: library.jar +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Import-Package: org.eclipse.osee.framework.logging diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/build.properties b/0.5.0_20081201/org.eclipse.osee.framework.svn/build.properties new file mode 100644 index 00000000000..97c13f300cb --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/build.properties @@ -0,0 +1,5 @@ +bin.includes = META-INF/,\ + library.jar +source.library.jar = src/ +output.library.jar = bin/ +jars.compile.order = library.jar diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/CheckoutJob.java b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/CheckoutJob.java new file mode 100644 index 00000000000..8d7e507adae --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/CheckoutJob.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.svn; + +import java.util.logging.Level; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.osee.framework.logging.OseeLog; + +/** + * @author Roberto E. Escobar + */ +public class CheckoutJob extends Job { + private String[] fileToCheckout; + + public CheckoutJob(String jobName, String[] fileToCheckout) { + super(jobName); + this.fileToCheckout = fileToCheckout; + } + + @Override + protected IStatus run(final IProgressMonitor monitor) { + IStatus toReturn = Status.OK_STATUS; + try { + ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { + public void run(IProgressMonitor monitor) throws CoreException { + VersionControl.getInstance().checkOut(fileToCheckout, monitor); + } + }, this.getRule(), IWorkspace.AVOID_UPDATE, monitor); + } catch (Exception ex) { + OseeLog.log(SvnActivator.class, Level.SEVERE, ex); + toReturn = new Status(Status.ERROR, SvnActivator.PLUGIN_ID, "Unable to Checkout Files", ex); + } + return toReturn; + } +} diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/CheckoutProjectSetJob.java b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/CheckoutProjectSetJob.java new file mode 100644 index 00000000000..ce5d6ae63d5 --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/CheckoutProjectSetJob.java @@ -0,0 +1,135 @@ +/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.svn;
+
+import java.io.File;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ui.TeamUIMessages;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@SuppressWarnings("restriction")
+public class CheckoutProjectSetJob extends Job {
+ private URL projectSetFile;
+ private String workingSetName;
+
+ public CheckoutProjectSetJob(String jobName, String workingSetName, URL projectSetFile) {
+ super(jobName);
+ this.projectSetFile = projectSetFile;
+ this.workingSetName = workingSetName;
+ }
+
+ @Override
+ protected IStatus run(final IProgressMonitor monitor) {
+ IStatus toReturn = Status.OK_STATUS;
+ try {
+ boolean result = performImportProjectSet(monitor, getProjectSetPath(), workingSetName);
+ if (result != true) {
+ toReturn = Status.CANCEL_STATUS;
+ }
+ } catch (Throwable ex) {
+ OseeLog.log(SvnActivator.class, Level.SEVERE, ex);
+ }
+ return toReturn;
+ }
+
+ private String getProjectSetPath() throws Exception {
+ URL url = FileLocator.resolve(projectSetFile);
+ File file = new File(url.getFile());
+ return file.getAbsolutePath();
+ }
+
+ private boolean performImportProjectSet(IProgressMonitor monitor, String fileName, String workingSet) {
+ boolean result = false;
+ try {
+ Class<?> clazz =
+ Platform.getBundle("org.eclipse.team.ui").loadClass(
+ "org.eclipse.team.internal.ui.wizards.ImportProjectSetOperation");
+ Object object = null;
+ if (EclipseVersion.isVersion("3.3")) {
+ Constructor<?> constructor = clazz.getConstructor(IRunnableContext.class, String.class, String.class);
+ object = constructor.newInstance(null, fileName, workingSet);
+ } else if (EclipseVersion.isVersion("3.4")) {
+ List<IWorkingSet> workingSets = new ArrayList<IWorkingSet>();
+ IWorkingSet workingSetObject =
+ PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSetName);
+ if (workingSetObject != null) {
+ workingSets.add(workingSetObject);
+ }
+ Constructor<?> constructor =
+ clazz.getConstructor(IRunnableContext.class, String.class, IWorkingSet[].class);
+ object = constructor.newInstance(null, fileName, workingSets.toArray(new IWorkingSet[workingSets.size()]));
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ Method method = clazz.getDeclaredMethod("run", IProgressMonitor.class);
+ method.invoke(object, monitor);
+ result = true;
+ } catch (Exception ex) {
+ handleException(ex);
+ }
+ return result;
+ }
+
+ private boolean handleException(Exception ex) {
+ Throwable target = ex.getCause();
+ if (target instanceof TeamException) {
+ displayErrorMessage(true, null, target);
+ return false;
+ }
+ if (target instanceof RuntimeException) {
+ throw (RuntimeException) target;
+ }
+ if (target instanceof Error) {
+ throw (Error) target;
+ }
+ String message =
+ target instanceof SAXException ? TeamUIMessages.ProjectSetImportWizard_2 : TeamUIMessages.ProjectSetImportWizard_3;
+ displayErrorMessage(false, message, target);
+ return false;
+ }
+
+ private void displayErrorMessage(final boolean isTeamException, final String message, final Throwable target) {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ if (isTeamException) {
+ ErrorDialog.openError(shell, null, null, ((TeamException) target).getStatus());
+ } else {
+ ErrorDialog.openError(shell, null, null, new Status(IStatus.ERROR, TeamUIPlugin.ID, 0, NLS.bind(message,
+ new String[] {target.getMessage()}), target));
+ }
+ }
+ });
+ }
+};
diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/ClearCaseInfo.java b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/ClearCaseInfo.java new file mode 100644 index 00000000000..b4a75ae288c --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/ClearCaseInfo.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.svn; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import org.eclipse.osee.framework.svn.entry.IRepositoryEntry; + +public class ClearCaseInfo implements IRepositoryEntry { + + private File file; + + public ClearCaseInfo(File tmpFile) { + super(); + file = tmpFile; + } + + public String getURL() { + return file.getAbsolutePath(); + } + + public String getVersion() { + try { + Process ct = Runtime.getRuntime().exec("cleartool lshistory -last " + file.getAbsolutePath()); + BufferedReader reader = new BufferedReader(new InputStreamReader(ct.getInputStream())); + String lineRead = null; + if ((lineRead = reader.readLine()) != null) { + return lineRead; + } else + return "unknown"; + } catch (IOException ex) { + System.out.println("ClearCase not found"); + } + + return "unknown"; + } + + public String getVersionControlSystem() { + return "CLEARCASE"; + } + + public String getModifiedFlag() { + return " "; + } + + /* (non-Javadoc) + * @see org.eclipse.osee.framework.svn.entry.IRepositoryEntry#getLastAuthor() + */ + public String getLastAuthor() { + return " "; + } + + /* (non-Javadoc) + * @see org.eclipse.osee.framework.svn.entry.IRepositoryEntry#getLastModificationDate() + */ + public String getLastModificationDate() { + return " "; + } +} diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/EclipseVersion.java b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/EclipseVersion.java new file mode 100644 index 00000000000..cb4612b1794 --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/EclipseVersion.java @@ -0,0 +1,27 @@ +/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.svn;
+
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class EclipseVersion {
+
+ private EclipseVersion() {
+ }
+
+ public static boolean isVersion(String toCheck) {
+ String value = (String) Platform.getBundle("org.eclipse.pde").getHeaders().get("Bundle-Version");
+ return value.startsWith(toCheck);
+ }
+}
diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/NodeKind.java b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/NodeKind.java new file mode 100644 index 00000000000..b9de776acf7 --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/NodeKind.java @@ -0,0 +1,25 @@ +package org.eclipse.osee.framework.svn;
+ public class NodeKind {
+ /** absent */
+ public static final int none = 0;
+
+ /** regular file */
+ public static final int file = 1;
+
+ /** directory */
+ public static final int dir = 2;
+
+ /** something's here, but we don't know what */
+ public static final int unknown = 3;
+
+ /**
+ * mapping for the constants to text
+ */
+ public static final String[] NAMES = {
+ "none",
+ "file",
+ "dir",
+ "unknown",
+ };
+
+ }
\ No newline at end of file diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/SvnAPI.java b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/SvnAPI.java new file mode 100644 index 00000000000..15aeea9ddd1 --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/SvnAPI.java @@ -0,0 +1,238 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ + +package org.eclipse.osee.framework.svn; + +import java.io.File; +import java.lang.reflect.Constructor; +import java.net.URI; +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Platform; +import org.eclipse.osee.framework.svn.entry.IRepositoryEntry; +import org.eclipse.osee.framework.svn.entry.NullRepositoryEntry; +import org.eclipse.osee.framework.svn.entry.RepositoryEntry; +import org.eclipse.osee.framework.svn.enums.RepositoryEnums.ControlledType; +import org.eclipse.osee.framework.svn.enums.RepositoryEnums.EntryFields; +import org.eclipse.team.svn.core.connector.SVNEntryInfo; +import org.eclipse.team.svn.core.connector.ISVNConnector.Depth; +import org.eclipse.team.svn.core.operation.remote.CheckoutOperation; +import org.eclipse.team.svn.core.resource.ILocalResource; +import org.eclipse.team.svn.core.resource.IRepositoryLocation; +import org.eclipse.team.svn.core.resource.IRepositoryResource; +import org.eclipse.team.svn.core.resource.IRepositoryRoot; +import org.eclipse.team.svn.core.svnstorage.SVNRemoteStorage; +import org.eclipse.team.svn.core.utility.SVNUtility; +import org.eclipse.team.svn.ui.action.remote.CheckoutAction; +import org.eclipse.ui.PlatformUI; + +/** + * @author Roberto E. Escobar + */ +public class SvnAPI { + private static SvnAPI instance = null; + + private SvnAPI() { + } + + protected static SvnAPI getInstance() { + if (instance == null) { + instance = new SvnAPI(); + } + return instance; + } + + protected boolean isSvn(File file) { + File svn = new File(file.getParentFile(), SVNUtility.getSVNFolderName()); + return svn.exists(); + } + + protected IRepositoryEntry getSVNInfo(File file) { + IRepositoryEntry toReturn = new NullRepositoryEntry(); + SVNEntryInfo info = SVNUtility.getSVNInfo(file); + if (info != null) { + toReturn = toRepositoryEntry(file, info); + } + return toReturn; + } + + private RepositoryEntry toRepositoryEntry(File file, SVNEntryInfo info) { + String entryType = "undefined"; + if (info.kind >= 0 && info.kind < NodeKind.NAMES.length) { + entryType = NodeKind.NAMES[info.kind]; + } + DateFormat dateFormat = + DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.getDefault()); + final RepositoryEntry entry = new RepositoryEntry(entryType, getVersionControlSystem()); + entry.addField(EntryFields.checksum, info.checksum); + entry.addField(EntryFields.committedRev, Long.toString(info.lastChangedRevision)); + entry.addField(EntryFields.fileName, info.path); + entry.addField(EntryFields.committeDate, dateFormat.format(new Date(info.lastChangedDate))); + entry.addField(EntryFields.url, info.url); + entry.addField(EntryFields.lastAuthor, info.lastChangedAuthor); + entry.addField(EntryFields.kind, + info.kind == NodeKind.dir ? ControlledType.dir.name() : ControlledType.file.name()); + entry.addField(EntryFields.uuid, info.reposUUID); + entry.addField(EntryFields.repository, info.reposRootUrl); + entry.addField(EntryFields.currentRevision, Long.toString(info.revision)); + entry.addField(EntryFields.textTime, dateFormat.format(new Date(info.textTime))); + entry.addField(EntryFields.dateCommitted, dateFormat.format(new Date(info.lastChangedDate))); + entry.addField(EntryFields.properTime, dateFormat.format(new Date(info.propTime))); + + IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(file.toURI()); + if (files != null && files.length > 0) { + ILocalResource local = SVNRemoteStorage.instance().asLocalResource(files[0]); + entry.setModifiedFlag(SVNUtility.getStatusText(local.getStatus())); + } + return entry; + } + + protected String getVersionControlSystem() { + return "svn"; + } + + public void addRepositoryLocation(String reference) { + SVNRemoteStorage remoteStorage = SVNRemoteStorage.instance(); + IRepositoryLocation newRepository = remoteStorage.newRepositoryLocation(reference); + remoteStorage.addRepositoryLocation(newRepository); + } + + public void checkOut(String[] fileToCheckout, final IProgressMonitor monitor) { + HashMap<String, IRepositoryResource> checkoutMap = toMap(getRepositoryResources(fileToCheckout)); + if (checkoutMap.size() > 0) { + CheckoutOperationBuilder operationBuilder = new CheckoutOperationBuilder(checkoutMap); + operationBuilder.getOperation().run(monitor); + } + } + + private IRepositoryResource[] getRepositoryResources(String[] fileToCheckout) { + // TODO: Create Repository Locations if they are not available. + List<IRepositoryResource> toReturn = new ArrayList<IRepositoryResource>(); + IRepositoryLocation[] locations = SVNRemoteStorage.instance().getRepositoryLocations(); + for (IRepositoryLocation location : locations) { + IRepositoryRoot root = location.getRoot(); + String repository = root.getUrl(); + for (String target : fileToCheckout) { + if (target.startsWith(repository)) { + IRepositoryResource repositoryResource = root.asRepositoryFile(target, false); + if (repositoryResource != null) { + toReturn.add(repositoryResource); + } + } + } + } + return toReturn.toArray(new IRepositoryResource[toReturn.size()]); + } + + private HashMap<String, IRepositoryResource> toMap(IRepositoryResource[] resources) { + HashMap<String, IRepositoryResource> checkoutMap = new HashMap<String, IRepositoryResource>(); + for (IRepositoryResource repositoryResource : resources) { + checkoutMap.put(repositoryResource.getName(), repositoryResource); + } + return checkoutMap; + } + + public URI getLocalFileMatchingRepositoryUrl(String url, String revision) { + return null; + } + + private final class CheckoutOperationBuilder { + private static final int WAIT_TIME = 30000; + private CheckoutOperation checkoutOperation; + private HashMap<String, IRepositoryResource> checkoutMap; + private boolean callbackReceived; + + public CheckoutOperationBuilder(HashMap<String, IRepositoryResource> checkoutMap) { + this.checkoutMap = checkoutMap; + this.callbackReceived = false; + } + + public void callbackReceived() { + synchronized (this) { + this.notify(); + callbackReceived = true; + } + } + + protected void setCallbackReceived(boolean received) { + callbackReceived = received; + } + + protected boolean wasCallbackReceived() { + return callbackReceived; + } + + public CheckoutOperation getOperation() { + PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { + public void run() { + checkoutOperation = getCheckoutOperation(checkoutMap); + callbackReceived(); + } + }); + synchronized (this) { + if (!wasCallbackReceived()) { + try { + this.wait(WAIT_TIME); + } catch (InterruptedException ex) { + } + } + } + return checkoutOperation; + } + + @SuppressWarnings("unchecked") + private CheckoutOperation getCheckoutOperation(HashMap<String, IRepositoryResource> checkoutMap) { + CheckoutOperation toReturn = null; + if (checkoutMap != null) { + HashMap resources2names = CheckoutAction.getResources2Names(checkoutMap); + ArrayList operateResources = + CheckoutAction.getOperateResources(checkoutMap, resources2names, + PlatformUI.getWorkbench().getDisplay().getActiveShell(), + ResourcesPlugin.getWorkspace().getRoot().getLocation().toString(), true); + + if (operateResources.size() > 0) { + IRepositoryResource[] checkoutSet = + (IRepositoryResource[]) operateResources.toArray(new IRepositoryResource[operateResources.size()]); + HashMap operateMap = new HashMap(); + for (int i = 0; i < checkoutSet.length; i++) { + operateMap.put(resources2names.get(checkoutSet[i]), checkoutSet[i]); + } + try { + Class<?> clazz = + Platform.getBundle("org.eclipse.team.svn.core").loadClass( + "org.eclipse.team.svn.core.operation.remote.CheckoutOperation"); + if (EclipseVersion.isVersion("3.3")) { + Constructor<?> constructor = + clazz.getConstructor(Map.class, boolean.class, String.class, boolean.class); + toReturn = (CheckoutOperation) constructor.newInstance(operateMap, false, null, true); + } else if (EclipseVersion.isVersion("3.4")) { + Constructor<?> constructor = + clazz.getConstructor(Map.class, boolean.class, String.class, int.class); + toReturn = + (CheckoutOperation) constructor.newInstance(operateMap, true, null, Depth.INFINITY, true); + } + } catch (Exception ex) { + throw new UnsupportedOperationException(); + } + } + } + return toReturn; + } + } +} diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/SvnActivator.java b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/SvnActivator.java new file mode 100644 index 00000000000..65a584bcf6a --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/SvnActivator.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.svn; + +import org.eclipse.osee.framework.plugin.core.OseeActivator; + +/** + * The activator class controls the plug-in life cycle see http://svnkit.com/kb/examples/index.php for code examples on + * svn + * + * @author Ryan D. Brooks + */ +public class SvnActivator extends OseeActivator { + private static SvnActivator pluginInstance; // The shared instance. + public static final String PLUGIN_ID = "osee.svn"; + + public SvnActivator() { + pluginInstance = this; + } + + /** + * Returns the shared instance. + */ + public static SvnActivator getInstance() { + return pluginInstance; + } +}
\ No newline at end of file diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/VersionControl.java b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/VersionControl.java new file mode 100644 index 00000000000..2b698f1b9c7 --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/VersionControl.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ + +package org.eclipse.osee.framework.svn; + +import java.io.File; +import java.net.URI; +import java.util.Properties; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.osee.framework.svn.entry.IRepositoryEntry; +import org.eclipse.osee.framework.svn.entry.NullRepositoryEntry; + +public class VersionControl { + + private static VersionControl instance; + + public static VersionControl getInstance() { + if (instance == null) { + instance = new VersionControl(); + } + return instance; + } + + private VersionControl() { + } + + public URI getLocalFileMatchingRepositoryUrl(String url, String revision) { + return SvnAPI.getInstance().getLocalFileMatchingRepositoryUrl(url, revision); + } + + public IRepositoryEntry getRepositoryEntry(File file) { + if (SvnAPI.getInstance().isSvn(file)) { + return SvnAPI.getInstance().getSVNInfo(file); + } else if (isClearcase(file)) { + return new ClearCaseInfo(file); + } else { + return new NullRepositoryEntry(); + } + } + + public String getRepositoryType(File file) { + String toReturn = "unknown"; + if (SvnAPI.getInstance().isSvn(file)) { + toReturn = SvnAPI.getInstance().getVersionControlSystem(); + } else if (isClearcase(file)) { + toReturn = "clearcase"; + } + return toReturn; + } + + public void checkOut(String[] fileToCheckout, IProgressMonitor monitor) { + SvnAPI.getInstance().checkOut(fileToCheckout, monitor); + } + + private boolean isClearcase(File file) { + Properties p = System.getProperties(); + // Unix + if (p.getProperty("file.separator").equals("/")) { + File ctFile = new File("/usr/src/rational/2003.06.00/rhat_x86/clearcase/rhat_x86/bin/cleartool"); + + if (ctFile.exists()) + return true; + else + return false; + } + // Windows + if (p.getProperty("file.separator").equals("\\")) { + File ctFile = new File("C:\\Program Files\\Rational\\ClearCase\\bin\\cleartool.exe"); + + if (ctFile.exists()) + return true; + else + return false; + } + return false; + } +} diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/entry/IRepositoryEntry.java b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/entry/IRepositoryEntry.java new file mode 100644 index 00000000000..6445fe384b9 --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/entry/IRepositoryEntry.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.svn.entry; + +public interface IRepositoryEntry { + + String getVersion(); + + String getURL(); + + String getVersionControlSystem(); + + String getModifiedFlag(); + + String getLastModificationDate(); + + String getLastAuthor(); + +} diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/entry/NullRepositoryEntry.java b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/entry/NullRepositoryEntry.java new file mode 100644 index 00000000000..ab316aa6c85 --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/entry/NullRepositoryEntry.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ + +package org.eclipse.osee.framework.svn.entry; + +public class NullRepositoryEntry implements IRepositoryEntry { + + /* + * (non-Javadoc) + * + * @see org.eclipse.osee.framework.svn.entry.IRepositoryEntry#getVersion() + */ + public String getVersion() { + return "-"; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.osee.framework.svn.entry.IRepositoryEntry#getURL() + */ + public String getURL() { + return "-"; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.osee.framework.svn.entry.IRepositoryEntry#getVersionControlSystem() + */ + public String getVersionControlSystem() { + return "-"; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.osee.framework.svn.entry.IRepositoryEntry#getModifiedFlag() + */ + public String getModifiedFlag() { + return "-"; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.osee.framework.svn.entry.IRepositoryEntry#getLastAuthor() + */ + public String getLastAuthor() { + return "-"; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.osee.framework.svn.entry.IRepositoryEntry#getLastModificationDate() + */ + public String getLastModificationDate() { + return "-"; + } + +} diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/entry/RepositoryEntry.java b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/entry/RepositoryEntry.java new file mode 100644 index 00000000000..2e1d4c8f1a3 --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/entry/RepositoryEntry.java @@ -0,0 +1,106 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ + +package org.eclipse.osee.framework.svn.entry; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import org.eclipse.osee.framework.svn.enums.RepositoryEnums.EntryFields; + +/** + * @author Roberto E. Escobar + */ +public class RepositoryEntry implements IRepositoryEntry { + + private Map<EntryFields, String> entryMap; + private String modifiedFlag; + private String fileType; + private String controlSystem; + + public RepositoryEntry(String fileType, String controlSystem) { + this.entryMap = new HashMap<EntryFields, String>(); + this.modifiedFlag = ""; + this.fileType = fileType; + this.controlSystem = controlSystem; + } + + public String getField(EntryFields field) { + if (entryMap.containsKey(field)) { + return entryMap.get(field); + } + return ""; + } + + public boolean containsField(EntryFields field) { + return entryMap.containsKey(field); + } + + public void setModifiedFlag(String modifiedFlag) { + this.modifiedFlag = modifiedFlag; + } + + public void addField(EntryFields field, String value) { + entryMap.put(field, value); + } + + public String toString() { + String toReturn = " Entry: " + getType() + "\n"; + Set<EntryFields> keys = entryMap.keySet(); + for (EntryFields field : keys) { + toReturn += "\t" + field + ": " + entryMap.get(field) + "\n"; + } + return toReturn; + } + + public String getVersion() { + return getField(EntryFields.committedRev); + } + + public String getURL() { + return getField(EntryFields.url); + } + + public String getModifiedFlag() { + return modifiedFlag; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.osee.framework.svn.entry.IRepositoryEntry#getLastAuthor() + */ + public String getLastAuthor() { + return getField(EntryFields.lastAuthor); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.osee.framework.svn.entry.IRepositoryEntry#getLastModificationDate() + */ + public String getLastModificationDate() { + return getField(EntryFields.dateCommitted); + } + + public String getType() { + return fileType; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.osee.framework.svn.entry.IRepositoryEntry#getVersionControlSystem() + */ + public String getVersionControlSystem() { + return controlSystem; + } +} diff --git a/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/enums/RepositoryEnums.java b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/enums/RepositoryEnums.java new file mode 100644 index 00000000000..9ddfa1cef5f --- /dev/null +++ b/0.5.0_20081201/org.eclipse.osee.framework.svn/src/org/eclipse/osee/framework/svn/enums/RepositoryEnums.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.svn.enums; + +/** + * @author Roberto E. Escobar + */ +public class RepositoryEnums { + + public enum ControlledType { + dir, file; + + public static boolean isDefined(String value) { + ControlledType[] types = ControlledType.values(); + for (ControlledType type : types) { + if (type.name().equals(value)) { + return true; + } + } + return false; + } + } + + public enum EntryFields { + committedRev("committed-rev"), + fileName("name"), + committeDate("committed-date"), + url("url"), + lastAuthor("last-author"), + kind("kind"), + uuid("uuid"), + repository("repos"), + currentRevision("revision"), + textTime("text-time"), + dateCommitted("committed-date"), + checksum("checksum"), + properTime("prop-time"); + + private String value; + + private EntryFields(String value) { + this.value = value; + } + + public String getEntryName() { + return value; + } + } +} |