You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2012/01/04 14:22:42 UTC
svn commit: r1227144 [9/18] - in /karaf/eik/trunk: ./ features/
features/info.evanchik.eclipse.karaf.feature/
features/info.evanchik.eclipse.karaf.jmx.feature/
features/info.evanchik.eclipse.karaf.update/
features/info.evanchik.eclipse.karaf.update/fea...
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/KarafProjectBuilder.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/KarafProjectBuilder.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/KarafProjectBuilder.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/KarafProjectBuilder.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,406 @@
+/**
+ * Copyright (c) 2011 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.project;
+
+import info.evanchik.eclipse.karaf.core.KarafCorePluginUtils;
+import info.evanchik.eclipse.karaf.core.KarafPlatformModel;
+import info.evanchik.eclipse.karaf.core.PropertyUtils;
+import info.evanchik.eclipse.karaf.core.configuration.FeaturesSection;
+import info.evanchik.eclipse.karaf.core.features.FeaturesRepository;
+import info.evanchik.eclipse.karaf.ui.IKarafProject;
+import info.evanchik.eclipse.karaf.ui.KarafUIPluginActivator;
+import info.evanchik.eclipse.karaf.ui.features.FeaturesResolverJob;
+import info.evanchik.eclipse.karaf.ui.internal.KarafLaunchUtils;
+import info.evanchik.eclipse.karaf.ui.internal.PopulateObrFileJob;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
+import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
+import org.eclipse.pde.internal.core.target.provisional.ITargetHandle;
+import org.eclipse.pde.internal.core.target.provisional.ITargetPlatformService;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class KarafProjectBuilder extends IncrementalProjectBuilder {
+
+ public static final String ID = "info.evanchik.eclipse.karaf.ui.karafProjectBuilder";
+
+ public KarafProjectBuilder() {
+ }
+
+ @Override
+ protected IProject[] build(final int kind, @SuppressWarnings("rawtypes") final Map args, final IProgressMonitor monitor)
+ throws CoreException
+ {
+ final IProject project = getProject();
+
+ monitor.beginTask("Building Apache Karaf Project: " + project.getName(), 1);
+
+ try {
+ if (kind == IncrementalProjectBuilder.FULL_BUILD) {
+ fullBuild(monitor);
+ } else {
+ final IResourceDelta delta = getDelta(getProject());
+ if (delta == null) {
+ fullBuild(monitor);
+ } else {
+ incrementalBuild(delta, monitor);
+ }
+ }
+
+ getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ } finally {
+ monitor.done();
+ }
+
+ return null;
+ }
+
+ /**
+ * Filters all of the JAR entries that begin with {@code org/osgi}.
+ *
+ * @param karafJar
+ * the source JAR
+ * @throws CoreException
+ * if there is a problem filtering the input JAR's contents
+ */
+ private void filterOsgiInterfaceClasses(final File karafJar) throws CoreException {
+ final IKarafProject karafProject = getKarafProject();
+
+ final IFile generatedKarafFile = karafProject.getFile("runtime");
+ final IPath path = generatedKarafFile.getRawLocation();
+
+ JarInputStream sourceJar = null;
+ JarOutputStream destJar = null;
+
+ try {
+ sourceJar = new JarInputStream(new FileInputStream(karafJar));
+ final File filteredKarafJar = new File(path.toFile(), "generatedKaraf.jar");
+
+ final Manifest mf = sourceJar.getManifest();
+ if (mf != null) {
+ destJar = new JarOutputStream(new FileOutputStream(filteredKarafJar), mf);
+ } else {
+ destJar = new JarOutputStream(new FileOutputStream(filteredKarafJar));
+ }
+
+ ZipEntry z = sourceJar.getNextEntry();
+ while (z != null) {
+ if (!z.getName().startsWith("org/osgi")) {
+ destJar.putNextEntry(z);
+
+ copyJarEntryData(sourceJar, destJar);
+ } else {
+ sourceJar.closeEntry();
+ }
+
+ z = sourceJar.getNextEntry();
+ }
+ } catch (final FileNotFoundException e) {
+ throw new CoreException(new Status(IStatus.ERROR, KarafUIPluginActivator.PLUGIN_ID, "Could not filter OSGi Interfaces from JAR", e));
+ } catch (final IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, KarafUIPluginActivator.PLUGIN_ID, "Could not filter OSGi Interfaces from JAR", e));
+ } finally {
+ if (sourceJar != null) {
+ try {
+ sourceJar.close();
+ } catch (final IOException e) {
+ // ignore
+ }
+ }
+
+ if (destJar != null) {
+ try {
+ destJar.close();
+ } catch (final IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Performs a full build of this {@link IKarafProject}
+ *
+ * @param monitor
+ * @throws CoreException
+ */
+ private void fullBuild(final IProgressMonitor monitor) throws CoreException {
+ createTargetPlatform(monitor);
+ buildRuntimeProperties(monitor);
+ buildFeaturesRepositories(monitor);
+ buildObr(monitor);
+ buildFilteredOsgiInterfaceJar(monitor);
+ }
+
+ private void buildFilteredOsgiInterfaceJar(final IProgressMonitor monitor) throws CoreException {
+ final List<String> karafModelClasspath = getKarafPlatformModel().getBootClasspath();
+
+ File karafJar = null;
+
+ final Iterator<String> itr = karafModelClasspath.iterator();
+ while (itr.hasNext()) {
+ final String classpathEntry = itr.next();
+ karafJar = new File(classpathEntry);
+
+ if (!karafJar.getName().equalsIgnoreCase("karaf.jar")) {
+ continue;
+ }
+
+ filterOsgiInterfaceClasses(karafJar);
+ }
+ }
+
+ private void buildRuntimeProperties(final IProgressMonitor monitor)
+ throws CoreException
+ {
+ final String karafHome = getKarafPlatformModel().getRootDirectory().toOSString();
+
+ final Properties combinedProperties = new Properties();
+ combinedProperties.put("karaf.home", karafHome);
+ combinedProperties.put("karaf.base", karafHome);
+ combinedProperties.put("karaf.data", getKarafPlatformModel().getRootDirectory().append("data").toOSString());
+
+ for (final String filename : new String[] { "config.properties", "system.properties", "users.properties" }) {
+ final Properties fileProperties = KarafCorePluginUtils.loadProperties(getKarafPlatformModel().getConfigurationDirectory().toFile(), filename, true);
+ combinedProperties.putAll(fileProperties);
+ }
+
+ PropertyUtils.interpolateVariables(combinedProperties, combinedProperties);
+
+ final IFolder runtimeFolder = getKarafProject().getFolder("runtime");
+ if (!runtimeFolder.exists()) {
+ runtimeFolder.create(true, true, monitor);
+ }
+
+ final IPath runtimeProperties =
+ runtimeFolder.getRawLocation().append("runtime").addFileExtension("properties");
+
+ FileOutputStream out;
+ try {
+ out = new FileOutputStream(runtimeProperties.toFile());
+ combinedProperties.store(out, "Combined interpolated runtime properties");
+ } catch (final IOException e) {
+ throw new CoreException(
+ new Status(
+ IStatus.ERROR,
+ KarafUIPluginActivator.PLUGIN_ID,
+ "Unable to build runtime property file",
+ e));
+ }
+ }
+
+ /**
+ * Build the Apache Karaf features repository files in this
+ * {@link IKarafProject}'s project location
+ *
+ * @param monitor
+ * @throws CoreException
+ */
+ private void buildFeaturesRepositories(final IProgressMonitor monitor)
+ throws CoreException
+ {
+ final IKarafProject karafProject = getKarafProject();
+ final KarafPlatformModel karafPlatformModel = getKarafPlatformModel();
+
+ monitor.subTask("Resolving Features Repository for Apache Karaf Project: " + karafProject.getName());
+
+ final FeaturesSection featuresSection = (FeaturesSection) karafPlatformModel.getAdapter(FeaturesSection.class);
+ final FeaturesResolverJob job = new FeaturesResolverJob(karafProject.getName(), karafPlatformModel, featuresSection);
+ job.schedule();
+ try {
+ job.join();
+
+ final List<FeaturesRepository> featuresRepositories = job.getFeaturesRepositories();
+
+ final IFolder folder = getKarafProject().getFolder("features");
+ if (!folder.exists()) {
+ folder.create(true, true, monitor);
+ }
+
+ for (final FeaturesRepository repo : featuresRepositories) {
+ final IPath featuresRepositoryFilename = new Path(repo.getName()).addFileExtension("xml");
+ final IFile featuresRepositoryFile = folder.getFile(featuresRepositoryFilename.toOSString());
+ final File file = new File(featuresRepositoryFile.getRawLocation().toOSString());
+
+ FileOutputStream fout = null;
+ try {
+ fout = new FileOutputStream(file);
+ repo.write(fout);
+ } finally {
+ if (fout != null) {
+ try {
+ fout.close();
+ } catch (final IOException e) {
+ // This space left blank
+ }
+ }
+ }
+ }
+
+ monitor.worked(1);
+ } catch (final IOException e) {
+ e.printStackTrace();
+ } catch (final InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Builds the OBR file for the installed Eclipse platform in this
+ * {@link IKarafProject}'s project location
+ *
+ * @param monitor
+ * @throws CoreException
+ */
+ private void buildObr(final IProgressMonitor monitor) throws CoreException {
+ final IKarafProject karafProject = getKarafProject();
+
+ monitor.subTask("Creating OBR for Apache Karaf Project: " + karafProject.getName());
+
+ final IPath obrFile =
+ karafProject.getFolder("platform").getRawLocation().append("eclipse.obr").addFileExtension("xml");
+
+ final PopulateObrFileJob populateObrJob = new PopulateObrFileJob(karafProject.getName(), obrFile.toFile());
+ populateObrJob.schedule();
+
+ try {
+ populateObrJob.join();
+ } catch (final InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Copies the data of a {@link JarEntry} or {@link ZipEntry} from one JAR to
+ * another
+ *
+ * @param in
+ * the source JAR {@link JarInputStream}
+ * @param out
+ * the destination JAR {@link JarOutputStream}
+ * @throws IOException
+ * thrown if there is a problem copying the data
+ */
+ private void copyJarEntryData(final JarInputStream in, final JarOutputStream out) throws IOException {
+ final byte buffer[] = new byte[4096];
+ int bytesRead;
+ while ((bytesRead = in.read(buffer)) > 0) {
+ out.write(buffer, 0, bytesRead);
+ }
+ }
+
+ /**
+ * @return
+ */
+ private IFile createTargetDefinitionFile() {
+ final String projectName = getKarafProject().getName();
+ final IPath targetFilename = new Path(projectName).addFileExtension("target");
+ return getKarafProject().getProjectHandle().getFile(targetFilename);
+ }
+
+ /**
+ *
+ * @param monitor
+ * @throws CoreException
+ */
+ @SuppressWarnings("restriction")
+ private void createTargetPlatform(final IProgressMonitor monitor) throws CoreException {
+ final ITargetPlatformService targetPlatformService =
+ (ITargetPlatformService) KarafUIPluginActivator.getDefault().getService(ITargetPlatformService.class.getName());
+
+ final IFile targetLocation = createTargetDefinitionFile();
+ final ITargetHandle targetHandle = targetPlatformService.getTarget(targetLocation);
+
+ final ITargetDefinition target = targetHandle.getTargetDefinition();
+
+ target.setName(getKarafProject().getName());
+
+ final List<IBundleContainer> bundleContainers = KarafLaunchUtils.getBundleContainers(getKarafPlatformModel());
+ target.setBundleContainers(bundleContainers.toArray(new IBundleContainer[0]));
+
+ targetPlatformService.saveTargetDefinition(target);
+ }
+
+ /**
+ * Getter for the {@link IKarafProject} of this builder's {@link IProject}
+ *
+ * @return the {@code IKarafProject}
+ */
+ private IKarafProject getKarafProject() {
+ final IProject project = getProject();
+ return (IKarafProject) project.getAdapter(IKarafProject.class);
+ }
+
+ /**
+ * Getter for the {@link KarafPlatformModel} that this builder's
+ * {@link IProject} is bound to
+ *
+ * @return the {@code KarafPlatformModel} that this builder's
+ * {@code IProject} is bound to
+ */
+ private KarafPlatformModel getKarafPlatformModel() {
+ return (KarafPlatformModel) getKarafProject().getAdapter(KarafPlatformModel.class);
+ }
+
+ /**
+ * Performs an incremental build of this {@link IKarafProject}
+ *
+ * @param delta
+ * @param monitor
+ * @throws CoreException
+ */
+ private void incrementalBuild(final IResourceDelta delta, final IProgressMonitor monitor) throws CoreException {
+ try {
+ delta.accept(new IResourceDeltaVisitor() {
+ @Override
+ public boolean visit(final IResourceDelta delta) {
+ // if is a bundle file then schedule an update to the target platform file
+ // if something in eclipse home changes then update obr
+ // if it is a feature file update features repo
+ return true;
+ }
+ });
+ fullBuild(monitor);
+ } catch (final CoreException e) {
+ e.printStackTrace();
+ }
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/KarafProjectNature.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/KarafProjectNature.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/KarafProjectNature.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/KarafProjectNature.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,113 @@
+/**
+ * Copyright (c) 2011 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.project;
+
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class KarafProjectNature implements IProjectNature {
+
+ public static final String ID = "info.evanchik.eclipse.karaf.KarafProjectNature";
+
+ private IProject project;
+
+ @Override
+ public void configure() throws CoreException {
+ addToBuildSpec(KarafProjectBuilder.ID);
+ }
+
+ @Override
+ public void deconfigure() throws CoreException {
+ removeFromBuildSpec(KarafProjectBuilder.ID);
+ }
+
+ @Override
+ public IProject getProject() {
+ return project;
+ }
+
+ @Override
+ public void setProject(final IProject project) {
+ this.project = project;
+ }
+
+ private void addToBuildSpec(final String builderID) throws CoreException {
+
+ final IProjectDescription description = this.project.getDescription();
+ final int commandIndex = getKarafProjectBuilderCommandIndex(description.getBuildSpec());
+
+ if (commandIndex == -1) {
+
+ final ICommand command = description.newCommand();
+ command.setBuilderName(builderID);
+ setKarafProjectBuilderCommand(description, command);
+ }
+ }
+
+ private int getKarafProjectBuilderCommandIndex(final ICommand[] buildSpec) {
+
+ for (int i = 0; i < buildSpec.length; ++i) {
+ if (buildSpec[i].getBuilderName().equals(KarafProjectBuilder.ID)) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ protected void removeFromBuildSpec(final String builderID) throws CoreException {
+
+ final IProjectDescription description = this.project.getDescription();
+ final ICommand[] commands = description.getBuildSpec();
+ for (int i = 0; i < commands.length; ++i) {
+ if (commands[i].getBuilderName().equals(builderID)) {
+ final ICommand[] newCommands = new ICommand[commands.length - 1];
+ System.arraycopy(commands, 0, newCommands, 0, i);
+ System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
+ description.setBuildSpec(newCommands);
+ this.project.setDescription(description, null);
+ return;
+ }
+ }
+ }
+
+ private void setKarafProjectBuilderCommand(
+ final IProjectDescription description,
+ final ICommand newCommand)
+ throws CoreException {
+
+ final ICommand[] oldBuildSpec = description.getBuildSpec();
+ final int oldJavaCommandIndex = getKarafProjectBuilderCommandIndex(oldBuildSpec);
+ ICommand[] newCommands;
+
+ if (oldJavaCommandIndex == -1) {
+ // Add a Java build spec before other builders (1FWJK7I)
+ newCommands = new ICommand[oldBuildSpec.length + 1];
+ System.arraycopy(oldBuildSpec, 0, newCommands, 1, oldBuildSpec.length);
+ newCommands[0] = newCommand;
+ } else {
+ oldBuildSpec[oldJavaCommandIndex] = newCommand;
+ newCommands = oldBuildSpec;
+ }
+
+ // Commit the spec change into the project
+ description.setBuildSpec(newCommands);
+ this.project.setDescription(description, null);
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/NewKarafProjectOperation.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/NewKarafProjectOperation.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/NewKarafProjectOperation.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/NewKarafProjectOperation.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,166 @@
+/**
+ * Copyright (c) 2011 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.project;
+
+import info.evanchik.eclipse.karaf.core.KarafPlatformModel;
+import info.evanchik.eclipse.karaf.core.KarafWorkingPlatformModel;
+import info.evanchik.eclipse.karaf.ui.IKarafProject;
+import info.evanchik.eclipse.karaf.ui.KarafLaunchConfigurationInitializer;
+import info.evanchik.eclipse.karaf.ui.KarafUIPluginActivator;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.variables.IDynamicVariable;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class NewKarafProjectOperation extends WorkspaceModifyOperation {
+
+ private final KarafPlatformModel karafPlatformModel;
+
+ private final IKarafProject newKarafProject;
+
+ private final KarafWorkingPlatformModel workingPlatformModel;
+
+ /**
+ *
+ * @param karafPlatformModel
+ * @param workingPlatformModel
+ * @param newKarafProject
+ */
+ public NewKarafProjectOperation(
+ final KarafPlatformModel karafPlatformModel,
+ final KarafWorkingPlatformModel workingPlatformModel,
+ final IKarafProject newKarafProject)
+ {
+ this.karafPlatformModel = karafPlatformModel;
+ this.newKarafProject = newKarafProject;
+ this.workingPlatformModel = workingPlatformModel;
+ }
+
+ @Override
+ protected void execute(final IProgressMonitor monitor)
+ throws CoreException, InvocationTargetException, InterruptedException
+ {
+ monitor.beginTask("Creating Apache Karaf Project", 3);
+
+ createProject(monitor);
+
+ monitor.worked(1);
+
+ addNatureToProject(KarafProjectNature.ID, monitor);
+
+ monitor.worked(1);
+
+ createKarafPlatformResources(monitor);
+
+ monitor.worked(1);
+
+ newKarafProject.getProjectHandle().refreshLocal(2, monitor);
+
+ monitor.done();
+ }
+
+ /**
+ *
+ * @param natureId
+ * @param monitor
+ * @throws CoreException
+ */
+ private void addNatureToProject(final String natureId, final IProgressMonitor monitor) throws CoreException {
+ final IProject project = newKarafProject.getProjectHandle();
+
+ final IProjectDescription description = project.getDescription();
+ final String[] prevNatures = description.getNatureIds();
+ final String[] newNatures = new String[prevNatures.length + 1];
+
+ System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
+
+ newNatures[prevNatures.length] = natureId;
+ description.setNatureIds(newNatures);
+ project.setDescription(description, monitor);
+ }
+
+ /**
+ *
+ * @param monitor
+ * @throws CoreException
+ */
+ private void createKarafPlatformResources(final IProgressMonitor monitor) throws CoreException {
+ newKarafProject.getProjectHandle().getFolder(".bin").create(true, true, monitor);
+ newKarafProject.getProjectHandle().getFolder(".bin/platform").create(true, true, monitor);
+ newKarafProject.getProjectHandle().getFolder(".bin/platform/etc").createLink(workingPlatformModel.getParentKarafModel().getConfigurationDirectory(), 0, monitor);
+ newKarafProject.getProjectHandle().getFolder(".bin/platform/deploy").createLink(workingPlatformModel.getParentKarafModel().getUserDeployedDirectory(), 0, monitor);
+ newKarafProject.getProjectHandle().getFolder(".bin/platform/lib").createLink(workingPlatformModel.getParentKarafModel().getRootDirectory().append("lib"), 0, monitor);
+ newKarafProject.getProjectHandle().getFolder(".bin/platform/system").createLink(workingPlatformModel.getParentKarafModel().getPluginRootDirectory(), 0, monitor);
+ newKarafProject.getProjectHandle().getFolder(".bin/runtime").create(true, true, monitor);
+
+ // TODO: Is this the right way to add the current installation?
+ final IDynamicVariable eclipseHomeVariable = VariablesPlugin.getDefault().getStringVariableManager().getDynamicVariable("eclipse_home");
+ final String eclipseHome = eclipseHomeVariable.getValue("");
+ newKarafProject.getProjectHandle().getFolder(".bin/platform/eclipse").create(true, true, monitor);
+ newKarafProject.getProjectHandle().getFolder(".bin/platform/eclipse/dropins").createLink(new Path(eclipseHome).append("dropins"), 0, monitor);
+ newKarafProject.getProjectHandle().getFolder(".bin/platform/eclipse/plugins").createLink(new Path(eclipseHome).append("plugins"), 0, monitor);
+
+ newKarafProject.getProjectHandle().setPersistentProperty(
+ new QualifiedName(KarafUIPluginActivator.PLUGIN_ID, "karafProject"),
+ "true");
+
+ newKarafProject.getProjectHandle().setPersistentProperty(
+ new QualifiedName(KarafUIPluginActivator.PLUGIN_ID, "karafModel"),
+ karafPlatformModel.getRootDirectory().toString());
+
+ final ILaunchConfigurationType launchType =
+ DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType("org.eclipse.pde.ui.EquinoxLauncher");
+
+ final ILaunchConfigurationWorkingCopy launchConfiguration =
+ launchType.newInstance(newKarafProject.getProjectHandle(), newKarafProject.getName());
+
+ KarafLaunchConfigurationInitializer.initializeConfiguration(launchConfiguration);
+
+ launchConfiguration.doSave();
+ }
+
+ /**
+ *
+ * @param monitor
+ * @throws CoreException
+ */
+ private void createProject(final IProgressMonitor monitor) throws CoreException {
+ final IProject project = newKarafProject.getProjectHandle();
+ final IPath projectLocation = newKarafProject.getLocation();
+
+ if (!Platform.getLocation().equals(projectLocation)) {
+ final IProjectDescription projectDescription = project.getWorkspace().newProjectDescription(project.getName());
+ projectDescription.setLocation(projectLocation);
+ project.create(projectDescription, monitor);
+ } else {
+ project.create(monitor);
+ }
+
+ project.open(null);
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/AbstractKarafBuildUnit.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/AbstractKarafBuildUnit.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/AbstractKarafBuildUnit.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/AbstractKarafBuildUnit.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2011 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.project.impl;
+
+import info.evanchik.eclipse.karaf.core.KarafPlatformModel;
+import info.evanchik.eclipse.karaf.ui.IKarafProject;
+import info.evanchik.eclipse.karaf.ui.project.KarafBuildUnit;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public abstract class AbstractKarafBuildUnit implements KarafBuildUnit {
+
+ private final KarafPlatformModel karafPlatformModel;
+
+ private final IKarafProject karafProject;
+
+ /**
+ *
+ * @param karafPlatformModel
+ * @param karafProject
+ */
+ public AbstractKarafBuildUnit(final KarafPlatformModel karafPlatformModel, final IKarafProject karafProject) {
+ this.karafPlatformModel = karafPlatformModel;
+ this.karafProject = karafProject;
+ }
+
+ protected final KarafPlatformModel getKarafPlatformModel() {
+ return karafPlatformModel;
+ }
+
+ protected final IKarafProject getKarafProject() {
+ return karafProject;
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/ConfigurationFileBuildUnit.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/ConfigurationFileBuildUnit.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/ConfigurationFileBuildUnit.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/ConfigurationFileBuildUnit.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2011 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.project.impl;
+
+import info.evanchik.eclipse.karaf.core.KarafPlatformModel;
+import info.evanchik.eclipse.karaf.ui.IKarafProject;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
+import java.util.Map;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class ConfigurationFileBuildUnit extends AbstractKarafBuildUnit {
+
+ /**
+ *
+ * @param karafPlatformModel
+ * @param karafProject
+ */
+ public ConfigurationFileBuildUnit(final KarafPlatformModel karafPlatformModel, final IKarafProject karafProject) {
+ super(karafPlatformModel, karafProject);
+ }
+
+ /**
+ *
+ * @param kind
+ * @param args
+ * @param monitor
+ */
+ @Override
+ public void build(final int kind, @SuppressWarnings("rawtypes") final Map args, final IProgressMonitor monitor) throws CoreException {
+
+ final File configurationDirectory = getKarafPlatformModel().getConfigurationDirectory().toFile();
+ final File configFiles[] = configurationDirectory.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(final File dir, final String name) {
+ return name.endsWith(".cfg");
+ }
+ });
+
+ final IFolder runtimeFolder = getKarafProject().getFolder("runtime");
+ if (!runtimeFolder.exists()) {
+ runtimeFolder.create(true, true, monitor);
+ }
+
+ final Properties configProperties = getKarafProject().getRuntimeProperties();
+
+ for (final File f : configFiles) {
+ if (f.isDirectory()) {
+ continue;
+ }
+
+ try {
+ final FileInputStream in = new FileInputStream(f);
+ } catch (final FileNotFoundException e) {
+ }
+
+ }
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/FeaturesRepositoriesBuildUnit.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/FeaturesRepositoriesBuildUnit.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/FeaturesRepositoriesBuildUnit.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/FeaturesRepositoriesBuildUnit.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,97 @@
+/**
+ * Copyright (c) 2011 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.project.impl;
+
+import info.evanchik.eclipse.karaf.core.KarafPlatformModel;
+import info.evanchik.eclipse.karaf.core.configuration.FeaturesSection;
+import info.evanchik.eclipse.karaf.core.features.FeaturesRepository;
+import info.evanchik.eclipse.karaf.ui.IKarafProject;
+import info.evanchik.eclipse.karaf.ui.KarafUIPluginActivator;
+import info.evanchik.eclipse.karaf.ui.features.FeaturesResolverJob;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class FeaturesRepositoriesBuildUnit extends AbstractKarafBuildUnit {
+
+ /**
+ * @param karafPlatformModel
+ * @param karafProject
+ */
+ public FeaturesRepositoriesBuildUnit(final KarafPlatformModel karafPlatformModel, final IKarafProject karafProject) {
+ super(karafPlatformModel, karafProject);
+ }
+
+ @Override
+ public void build(final int kind, @SuppressWarnings("rawtypes") final Map args, final IProgressMonitor monitor) throws CoreException {
+ final IKarafProject karafProject = getKarafProject();
+ final KarafPlatformModel karafPlatformModel = getKarafPlatformModel();
+
+ monitor.subTask("Resolving Features Repository for Apache Karaf Project: " + karafProject.getName());
+
+ final FeaturesSection featuresSection = (FeaturesSection) karafPlatformModel.getAdapter(FeaturesSection.class);
+ final FeaturesResolverJob job = new FeaturesResolverJob(karafProject.getName(), karafPlatformModel, featuresSection);
+ job.schedule();
+ try {
+ job.join();
+
+ final List<FeaturesRepository> featuresRepositories = job.getFeaturesRepositories();
+
+ final IFolder folder = getKarafProject().getFolder("features");
+ if (!folder.exists()) {
+ folder.create(true, true, monitor);
+ }
+
+ for (final FeaturesRepository repo : featuresRepositories) {
+ final IPath featuresRepositoryFilename = new Path(repo.getName()).addFileExtension("xml");
+ final IFile featuresRepositoryFile = folder.getFile(featuresRepositoryFilename.toOSString());
+ final File file = new File(featuresRepositoryFile.getRawLocation().toOSString());
+
+ FileOutputStream fout = null;
+ try {
+ fout = new FileOutputStream(file);
+ repo.write(fout);
+ } finally {
+ if (fout != null) {
+ try {
+ fout.close();
+ } catch (final IOException e) {
+ // This space left blank
+ }
+ }
+ }
+ }
+
+ monitor.worked(1);
+ } catch (final IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, KarafUIPluginActivator.PLUGIN_ID, "Unable to build Features Repository", e));
+ } catch (final InterruptedException e) {
+ Thread.interrupted();
+ throw new CoreException(new Status(IStatus.ERROR, KarafUIPluginActivator.PLUGIN_ID, "Unable to build Features Repository", e));
+ }
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/FilteredOsgiFrameworkJarBuildUnit.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/FilteredOsgiFrameworkJarBuildUnit.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/FilteredOsgiFrameworkJarBuildUnit.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/FilteredOsgiFrameworkJarBuildUnit.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,152 @@
+/**
+ * Copyright (c) 2011 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.project.impl;
+
+import info.evanchik.eclipse.karaf.core.KarafPlatformModel;
+import info.evanchik.eclipse.karaf.ui.IKarafProject;
+import info.evanchik.eclipse.karaf.ui.KarafUIPluginActivator;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class FilteredOsgiFrameworkJarBuildUnit extends AbstractKarafBuildUnit {
+
+ /**
+ * @param karafPlatformModel
+ * @param karafProject
+ */
+ public FilteredOsgiFrameworkJarBuildUnit(final KarafPlatformModel karafPlatformModel, final IKarafProject karafProject) {
+ super(karafPlatformModel, karafProject);
+ }
+
+ @Override
+ public void build(final int kind, @SuppressWarnings("rawtypes") final Map args, final IProgressMonitor monitor) throws CoreException {
+ final List<String> karafModelClasspath = getKarafPlatformModel().getBootClasspath();
+
+ File karafJar = null;
+
+ final Iterator<String> itr = karafModelClasspath.iterator();
+ while (itr.hasNext()) {
+ final String classpathEntry = itr.next();
+ karafJar = new File(classpathEntry);
+
+ if (!karafJar.getName().equalsIgnoreCase("karaf.jar")) {
+ continue;
+ }
+
+ filterOsgiInterfaceClasses(karafJar);
+ }
+ }
+
+ /**
+ * Copies the data of a {@link JarEntry} or {@link ZipEntry} from one JAR to
+ * another
+ *
+ * @param in
+ * the source JAR {@link JarInputStream}
+ * @param out
+ * the destination JAR {@link JarOutputStream}
+ * @throws IOException
+ * thrown if there is a problem copying the data
+ */
+ private void copyJarEntryData(final JarInputStream in, final JarOutputStream out) throws IOException {
+ final byte buffer[] = new byte[4096];
+ int bytesRead;
+ while ((bytesRead = in.read(buffer)) > 0) {
+ out.write(buffer, 0, bytesRead);
+ }
+ }
+
+ /**
+ * Filters all of the JAR entries that begin with {@code org/osgi}.
+ *
+ * @param karafJar
+ * the source JAR
+ * @throws CoreException
+ * if there is a problem filtering the input JAR's contents
+ */
+ private void filterOsgiInterfaceClasses(final File karafJar) throws CoreException {
+ final IKarafProject karafProject = getKarafProject();
+
+ final IFile generatedKarafFile = karafProject.getFile("runtime");
+ final IPath path = generatedKarafFile.getRawLocation();
+
+ JarInputStream sourceJar = null;
+ JarOutputStream destJar = null;
+
+ try {
+ sourceJar = new JarInputStream(new FileInputStream(karafJar));
+ final File filteredKarafJar = new File(path.toFile(), "generatedKaraf.jar");
+
+ final Manifest mf = sourceJar.getManifest();
+ if (mf != null) {
+ destJar = new JarOutputStream(new FileOutputStream(filteredKarafJar), mf);
+ } else {
+ destJar = new JarOutputStream(new FileOutputStream(filteredKarafJar));
+ }
+
+ ZipEntry z = sourceJar.getNextEntry();
+ while (z != null) {
+ if (!z.getName().startsWith("org/osgi")) {
+ destJar.putNextEntry(z);
+
+ copyJarEntryData(sourceJar, destJar);
+ } else {
+ sourceJar.closeEntry();
+ }
+
+ z = sourceJar.getNextEntry();
+ }
+ } catch (final FileNotFoundException e) {
+ throw new CoreException(new Status(IStatus.ERROR, KarafUIPluginActivator.PLUGIN_ID, "Could not filter OSGi Interfaces from JAR", e));
+ } catch (final IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, KarafUIPluginActivator.PLUGIN_ID, "Could not filter OSGi Interfaces from JAR", e));
+ } finally {
+ if (sourceJar != null) {
+ try {
+ sourceJar.close();
+ } catch (final IOException e) {
+ // ignore
+ }
+ }
+
+ if (destJar != null) {
+ try {
+ destJar.close();
+ } catch (final IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/KarafPlatformResourcesBuildUnit.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/KarafPlatformResourcesBuildUnit.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/KarafPlatformResourcesBuildUnit.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/KarafPlatformResourcesBuildUnit.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,85 @@
+/**
+ * Copyright (c) 2011 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.project.impl;
+
+import info.evanchik.eclipse.karaf.core.KarafPlatformModel;
+import info.evanchik.eclipse.karaf.ui.IKarafProject;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.variables.IDynamicVariable;
+import org.eclipse.core.variables.VariablesPlugin;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class KarafPlatformResourcesBuildUnit extends AbstractKarafBuildUnit {
+
+ /**
+ *
+ * @param karafPlatformModel
+ * @param karafProject
+ */
+ public KarafPlatformResourcesBuildUnit(final KarafPlatformModel karafPlatformModel, final IKarafProject karafProject) {
+ super(karafPlatformModel, karafProject);
+ }
+
+ @Override
+ public void build(final int kind, @SuppressWarnings("rawtypes") final Map args, final IProgressMonitor monitor) throws CoreException {
+ final IKarafProject newKarafProject = getKarafProject();
+ final IProject project = newKarafProject.getProjectHandle();
+
+ for (final String folderName : new String[] { ".bin", ".bin/platform", ".bin/runtime" }) {
+ final IFolder folder = project.getFolder(folderName);
+ if (!folder.exists()) {
+ folder.create(true, true, monitor);
+ }
+ }
+
+ if (!project.getFolder(".bin/platform/etc").exists()) {
+ project.getFolder(".bin/platform/etc").createLink(getKarafPlatformModel().getConfigurationDirectory(), 0, monitor);
+ }
+
+ if (!project.getFolder(".bin/platform/deploy").exists()) {
+ project.getFolder(".bin/platform/deploy").createLink(getKarafPlatformModel().getUserDeployedDirectory(), 0, monitor);
+ }
+
+ if (!project.getFolder(".bin/platform/lib").exists()) {
+ project.getFolder(".bin/platform/lib").createLink(getKarafPlatformModel().getRootDirectory().append("lib"), 0, monitor);
+ }
+
+ if (!project.getFolder(".bin/platform/system").exists()) {
+ project.getFolder(".bin/platform/system").createLink(getKarafPlatformModel().getPluginRootDirectory(), 0, monitor);
+ }
+
+ // TODO: Is this the right way to add the current installation?
+ final IDynamicVariable eclipseHomeVariable = VariablesPlugin.getDefault().getStringVariableManager().getDynamicVariable("eclipse_home");
+ final String eclipseHome = eclipseHomeVariable.getValue("");
+
+ if (!project.getFolder(".bin/platform/eclipse").exists()) {
+ project.getFolder(".bin/platform/eclipse").create(true, true, monitor);
+ }
+
+ if (!project.getFolder(".bin/platform/eclipse/dropins").exists()) {
+ project.getFolder(".bin/platform/eclipse/dropins").createLink(new Path(eclipseHome).append("dropins"), 0, monitor);
+ }
+
+ if (!project.getFolder(".bin/platform/eclipse/plugins").exists()) {
+ project.getFolder(".bin/platform/eclipse/plugins").createLink(new Path(eclipseHome).append("plugins"), 0, monitor);
+ }
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/KarafRuntimePropertyBuildUnit.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/KarafRuntimePropertyBuildUnit.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/KarafRuntimePropertyBuildUnit.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/KarafRuntimePropertyBuildUnit.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,86 @@
+/**
+ * Copyright (c) 2011 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.project.impl;
+
+import info.evanchik.eclipse.karaf.core.KarafCorePluginUtils;
+import info.evanchik.eclipse.karaf.core.KarafPlatformModel;
+import info.evanchik.eclipse.karaf.core.PropertyUtils;
+import info.evanchik.eclipse.karaf.ui.IKarafProject;
+import info.evanchik.eclipse.karaf.ui.KarafUIPluginActivator;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ *
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class KarafRuntimePropertyBuildUnit extends AbstractKarafBuildUnit {
+
+ public KarafRuntimePropertyBuildUnit(final KarafPlatformModel karafPlatformModel, final IKarafProject karafProject) {
+ super(karafPlatformModel, karafProject);
+ }
+
+ @Override
+ public void build(final int kind, @SuppressWarnings("rawtypes") final Map args, final IProgressMonitor monitor) throws CoreException {
+ final String karafHome = getKarafPlatformModel().getRootDirectory().toOSString();
+
+ final Properties combinedProperties = new Properties();
+ combinedProperties.put("karaf.home", karafHome);
+ combinedProperties.put("karaf.base", karafHome);
+ combinedProperties.put("karaf.data", getKarafPlatformModel().getRootDirectory().append("data").toOSString());
+
+ for (final String filename : new String[] { "config.properties", "system.properties", "users.properties" }) {
+ final Properties fileProperties =
+ KarafCorePluginUtils.loadProperties(
+ getKarafPlatformModel().getConfigurationDirectory().toFile(),
+ filename,
+ true);
+
+ combinedProperties.putAll(fileProperties);
+ }
+
+ PropertyUtils.interpolateVariables(combinedProperties, combinedProperties);
+
+ final IFolder runtimeFolder = getKarafProject().getFolder("runtime");
+ if (!runtimeFolder.exists()) {
+ runtimeFolder.create(true, true, monitor);
+ }
+
+ final IPath runtimeProperties =
+ runtimeFolder.getRawLocation().append("runtime").addFileExtension("properties");
+
+ runtimeFolder.refreshLocal(0, monitor);
+
+ FileOutputStream out;
+ try {
+ out = new FileOutputStream(runtimeProperties.toFile());
+ combinedProperties.store(out, "Combined interpolated runtime properties");
+ } catch (final IOException e) {
+ throw new CoreException(
+ new Status(
+ IStatus.ERROR,
+ KarafUIPluginActivator.PLUGIN_ID,
+ "Unable to build runtime property file",
+ e));
+ }
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/PopulateObrFileBuildUnit.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/PopulateObrFileBuildUnit.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/PopulateObrFileBuildUnit.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/PopulateObrFileBuildUnit.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,64 @@
+/**
+ * Copyright (c) 2011 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.project.impl;
+
+import info.evanchik.eclipse.karaf.core.KarafPlatformModel;
+import info.evanchik.eclipse.karaf.ui.IKarafProject;
+import info.evanchik.eclipse.karaf.ui.KarafUIPluginActivator;
+import info.evanchik.eclipse.karaf.ui.internal.PopulateObrFileJob;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class PopulateObrFileBuildUnit extends AbstractKarafBuildUnit {
+
+ /**
+ * @param karafPlatformModel
+ * @param karafProject
+ */
+ public PopulateObrFileBuildUnit(final KarafPlatformModel karafPlatformModel, final IKarafProject karafProject) {
+ super(karafPlatformModel, karafProject);
+ }
+
+ @Override
+ public void build(final int kind, @SuppressWarnings("rawtypes") final Map args, final IProgressMonitor monitor) throws CoreException {
+ final IKarafProject karafProject = getKarafProject();
+
+ monitor.subTask("Creating OBR for Apache Karaf Project: " + karafProject.getName());
+
+ final IFolder platformFolder = karafProject.getFolder("platform");
+
+ final IPath obrFile =
+ platformFolder.getRawLocation().append("eclipse.obr").addFileExtension("xml");
+
+ platformFolder.refreshLocal(0, monitor);
+
+ final PopulateObrFileJob populateObrJob = new PopulateObrFileJob(karafProject.getName(), obrFile.toFile());
+ populateObrJob.schedule();
+
+ try {
+ populateObrJob.join();
+ } catch (final InterruptedException e) {
+ Thread.interrupted();
+ throw new CoreException(new Status(IStatus.ERROR, KarafUIPluginActivator.PLUGIN_ID, "Unable to populate OBR file", e));
+ }
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/NewKarafProjectWizard.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/NewKarafProjectWizard.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/NewKarafProjectWizard.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/NewKarafProjectWizard.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,98 @@
+/**
+ * Copyright (c) 2011 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.wizards;
+
+import info.evanchik.eclipse.karaf.core.KarafPlatformModel;
+import info.evanchik.eclipse.karaf.core.KarafWorkingPlatformModel;
+import info.evanchik.eclipse.karaf.core.model.WorkingKarafPlatformModel;
+import info.evanchik.eclipse.karaf.ui.IKarafProject;
+import info.evanchik.eclipse.karaf.ui.KarafUIPluginActivator;
+import info.evanchik.eclipse.karaf.ui.project.KarafProject;
+import info.evanchik.eclipse.karaf.ui.project.NewKarafProjectOperation;
+import info.evanchik.eclipse.karaf.ui.wizards.provisioner.KarafInstallationSelectionPage;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class NewKarafProjectWizard extends Wizard implements INewWizard {
+
+ private KarafInstallationSelectionPage installationSelectionPage;
+
+ private KarafPlatformModel karafPlatformModel;
+
+ private NewKarafProjectWizardPage mainPage;
+
+ private IStructuredSelection selection;
+
+ private IWorkbench workbench;;
+
+ /**
+ *
+ */
+ public NewKarafProjectWizard() {
+ setDefaultPageImageDescriptor(KarafUIPluginActivator.getDefault().getImageRegistry().getDescriptor(KarafUIPluginActivator.LOGO_64X64_IMG));
+ setDialogSettings(KarafUIPluginActivator.getDefault().getDialogSettings());
+ setNeedsProgressMonitor(true);
+ }
+
+ @Override
+ public void addPages() {
+ mainPage = new NewKarafProjectWizardPage("Create a new Apache Karaf Project", selection);
+
+ addPage(mainPage);
+
+ installationSelectionPage = new KarafInstallationSelectionPage("Locate an Apache Karaf Installation");
+
+ addPage(installationSelectionPage);
+
+ super.addPages();
+ }
+
+ @Override
+ public void init(final IWorkbench workbench, final IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ }
+
+ @Override
+ public boolean performFinish() {
+ karafPlatformModel = installationSelectionPage.getKarafPlatformModel();
+ if (karafPlatformModel != null) {
+ try {
+ final KarafWorkingPlatformModel workingPlatformModel =
+ new WorkingKarafPlatformModel(mainPage.getLocationPath().append(mainPage.getProjectName()), karafPlatformModel);
+
+ final IKarafProject karafProject = new KarafProject(mainPage.getProjectHandle());
+ if (mainPage.getProjectHandle().exists()) {
+ return false;
+ }
+
+ getContainer().run(false, true, new NewKarafProjectOperation(karafPlatformModel, workingPlatformModel, karafProject));
+
+ return true;
+ } catch (final InvocationTargetException e) {
+ return false;
+ } catch (final InterruptedException e) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/NewKarafProjectWizardPage.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/NewKarafProjectWizardPage.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/NewKarafProjectWizardPage.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/NewKarafProjectWizardPage.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2011 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.wizards;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class NewKarafProjectWizardPage extends WizardNewProjectCreationPage {
+
+ public NewKarafProjectWizardPage(final String pageName, final IStructuredSelection selection) {
+ super(pageName);
+
+ setTitle("Create an Apache Karaf project");
+ setDescription("Name the project");
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/provisioner/KarafInstallationProvisionerWizard.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/provisioner/KarafInstallationProvisionerWizard.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/provisioner/KarafInstallationProvisionerWizard.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/provisioner/KarafInstallationProvisionerWizard.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,62 @@
+/**
+ * Copyright (c) 2009 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.wizards.provisioner;
+
+import info.evanchik.eclipse.karaf.core.KarafPlatformModel;
+import info.evanchik.eclipse.karaf.ui.KarafUIPluginActivator;
+import info.evanchik.eclipse.karaf.ui.internal.KarafLaunchUtils;
+
+import java.io.File;
+import java.util.Collection;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.pde.ui.IProvisionerWizard;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class KarafInstallationProvisionerWizard extends Wizard implements IProvisionerWizard {
+
+ private KarafPlatformModel karafPlatformModel;
+
+ private KarafInstallationSelectionPage karafInstallationPage;
+
+ public KarafInstallationProvisionerWizard() {
+ setDialogSettings(KarafUIPluginActivator.getDefault().getDialogSettings());
+
+ setWindowTitle("Select an Apache Karaf Installation Directory");
+ }
+
+ @Override
+ public void addPages() {
+ karafInstallationPage = new KarafInstallationSelectionPage("Locate an Apache Karaf Installation");
+ addPage(karafInstallationPage);
+ super.addPages();
+ }
+
+ /**
+ * Getter for all directories that contain JARs in the Karaf Platform
+ *
+ * @return the directories that contain JARs in the Karaf Platform
+ */
+ @Override
+ public File[] getLocations() {
+ final Collection<File> directories = KarafLaunchUtils.getJarDirectories(karafPlatformModel);
+ return directories.toArray(new File[0]);
+ }
+
+ @Override
+ public boolean performFinish() {
+ karafPlatformModel = karafInstallationPage.getKarafPlatformModel();
+ return true;
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/provisioner/KarafInstallationSelectionPage.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/provisioner/KarafInstallationSelectionPage.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/provisioner/KarafInstallationSelectionPage.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/wizards/provisioner/KarafInstallationSelectionPage.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,189 @@
+/**
+ * Copyright (c) 2009 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.wizards.provisioner;
+
+import info.evanchik.eclipse.karaf.core.KarafPlatformDetails;
+import info.evanchik.eclipse.karaf.core.KarafPlatformModel;
+import info.evanchik.eclipse.karaf.core.KarafPlatformModelRegistry;
+import info.evanchik.eclipse.karaf.ui.KarafUIPluginActivator;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class KarafInstallationSelectionPage extends WizardPage {
+
+ protected KarafPlatformModel karafPlatform;
+
+ /**
+ * The Karaf platform installation directory as selected by the user
+ */
+ protected Text installDir;
+
+ protected Text platformDescription;
+
+ protected Text platformName;
+
+ protected Text platformVersion;
+
+ /**
+ * Constructs a page in the wizard with the given name
+ *
+ * @param pageName
+ * the name of the page
+ */
+ public KarafInstallationSelectionPage(final String pageName) {
+ super(pageName);
+
+ setTitle("Apache Karaf Provisioner");
+ setDescription("Browse for an Apache Karaf installation directory to use as your target platform");
+
+ setPageComplete(false);
+ setImageDescriptor(KarafUIPluginActivator.getDefault().getImageRegistry().getDescriptor(KarafUIPluginActivator.LOGO_64X64_IMG)); // $NON-NLS-1$
+ }
+
+ @Override
+ public void createControl(final Composite parent) {
+ final Composite client = new Composite(parent, SWT.NONE);
+
+ final GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+
+ client.setLayout(layout);
+
+ GridData data = new GridData();
+ data.horizontalSpan = 2;
+
+ // The installation directory selection controls
+ final Label label = new Label(client, SWT.NONE);
+ label.setText("Installation directory");
+ data = new GridData();
+ data.horizontalSpan = 2;
+ label.setLayoutData(data);
+
+ Dialog.applyDialogFont(label);
+
+ installDir = new Text(client, SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ installDir.setLayoutData(data);
+ installDir.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(final ModifyEvent e) {
+ validateWizardState();
+ }
+ });
+
+ // File system browse button
+ final Button browse = new Button(client, SWT.PUSH);
+ browse.setText("Browse");
+ browse.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent se) {
+ final DirectoryDialog dialog = new DirectoryDialog(
+ KarafInstallationSelectionPage.this.getShell());
+ dialog.setMessage("Select the Apache Karaf installation directory");
+ dialog.setFilterPath(installDir.getText());
+
+ final String selectedDirectory = dialog.open();
+
+ if (selectedDirectory != null) {
+ installDir.setText(selectedDirectory);
+ }
+ }
+ });
+
+ final Group group = new Group(client, SWT.BORDER);
+ group.setText("Karaf Platform Details");
+ group.setLayout(new GridLayout(2, false));
+ data = new GridData(GridData.FILL_BOTH);
+ data.horizontalSpan = 2;
+ group.setLayoutData(data);
+
+ Label l = new Label(group, SWT.NONE);
+ l.setText("Name");
+ Dialog.applyDialogFont(l);
+
+ platformName = new Text(group, SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ platformName.setLayoutData(data);
+ platformName.setEnabled(false);
+
+ l = new Label(group, SWT.NONE);
+ l.setText("Version");
+ Dialog.applyDialogFont(l);
+
+ platformVersion = new Text(group, SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ platformVersion.setLayoutData(data);
+ platformVersion.setEnabled(false);
+
+ l = new Label(group, SWT.NONE);
+ l.setText("Description");
+ Dialog.applyDialogFont(l);
+
+ platformDescription = new Text(group, SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ platformDescription.setLayoutData(data);
+ platformDescription.setEnabled(false);
+
+
+ setControl(client);
+ }
+
+ /**
+ * Getter for the newly identified Karaf platform
+ *
+ * @return the newly identified {@link KarafPlatformModel}
+ */
+ public KarafPlatformModel getKarafPlatformModel() {
+ return karafPlatform;
+ }
+
+ private void validateWizardState() {
+ try {
+ karafPlatform = KarafPlatformModelRegistry.findPlatformModel(new Path(installDir.getText()));
+ if (karafPlatform == null) {
+ setErrorMessage("The specified directory does not contain a recognized installation");
+ } else {
+ setErrorMessage(null);
+ setPageComplete(true);
+
+ final KarafPlatformDetails platformDetails =
+ (KarafPlatformDetails) karafPlatform.getAdapter(KarafPlatformDetails.class);
+
+ platformName.setText(platformDetails.getName());
+ platformVersion.setText(platformDetails.getVersion());
+ platformDescription.setText(platformDetails.getDescription());
+ }
+ } catch (final CoreException e) {
+ setErrorMessage("There was an error loading the installation: " + e.getMessage());
+ KarafUIPluginActivator.getLogger().error("There was an error loading the installation", e);
+ }
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/workbench/KarafWorkbenchService.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/workbench/KarafWorkbenchService.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/workbench/KarafWorkbenchService.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/workbench/KarafWorkbenchService.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2010 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.workbench;
+
+import info.evanchik.eclipse.karaf.core.KarafWorkingPlatformModel;
+import info.evanchik.eclipse.karaf.core.equinox.BundleEntry;
+
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public interface KarafWorkbenchService {
+
+ /**
+ *
+ * @param platformModel
+ * @param configuration
+ * @return
+ */
+ public List<BundleEntry> getAdditionalBundles(KarafWorkingPlatformModel platformModel, ILaunchConfiguration configuration);
+
+ /**
+ * Gets the {@link Map<String, String>} of additional Equinox configuration
+ * properties
+ *
+ * @param platformModel
+ * @param configuration
+ * @return the {@code Map<String, String>} of additional Equinox
+ * configuration
+ */
+ public Map<String, String> getAdditionalEquinoxConfiguration(KarafWorkingPlatformModel platformModel, ILaunchConfiguration configuration);
+
+ /**
+ *
+ * @param configuration
+ * @return
+ * @throws CoreException
+ */
+ public List<String> getVMArguments(KarafWorkingPlatformModel platformModel, ILaunchConfiguration configuration) throws CoreException;
+
+ /**
+ * Called when the {@link ILaunchConfiguration} is being initialized
+ *
+ * @param platformModel
+ * the {@link KarafWorkingPlatformModel} that this launch
+ * configuration is executing against
+ * @param configuration
+ * the {@code ILaunchConfigurationWorkingCopy}
+ */
+ public void initialize(KarafWorkingPlatformModel platformModel, ILaunchConfigurationWorkingCopy configuration);
+
+ /**
+ *
+ * @param configuration
+ * @param mode
+ * @param launch
+ * @param monitor
+ * @throws CoreException
+ */
+ public void launch(KarafWorkingPlatformModel platformModel, ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException;
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/workbench/KarafWorkbenchServiceFactory.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/workbench/KarafWorkbenchServiceFactory.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/workbench/KarafWorkbenchServiceFactory.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/workbench/KarafWorkbenchServiceFactory.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2010 Stephen Evanchik
+ * 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.ui.workbench;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public interface KarafWorkbenchServiceFactory {
+
+ /**
+ *
+ * @return
+ */
+ public KarafWorkbenchService getWorkbenchService();
+}