From b083150945fefc12f294c4350e0ca476094dc332 Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Wed, 4 Feb 2009 11:02:43 -0800 Subject: adding eclipse plugin --- .../slice2javaplugin/builder/Slice2JavaNature.java | 108 +++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 eclipse/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/builder/Slice2JavaNature.java (limited to 'eclipse/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/builder/Slice2JavaNature.java') diff --git a/eclipse/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/builder/Slice2JavaNature.java b/eclipse/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/builder/Slice2JavaNature.java new file mode 100644 index 00000000000..b401f63493d --- /dev/null +++ b/eclipse/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/builder/Slice2JavaNature.java @@ -0,0 +1,108 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +// +// This plug-in is provided to you under the terms and conditions +// of the Eclipse Public License Version 1.0 ("EPL"). A copy of +// the EPL is available at http://www.eclipse.org/legal/epl-v10.html. +// +// ********************************************************************** + +package com.zeroc.slice2javaplugin.builder; + +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; + +import com.zeroc.slice2javaplugin.internal.Configuration; + +public class Slice2JavaNature implements IProjectNature +{ + /** + * ID of this project nature + */ + public static final String NATURE_ID = "com.zeroc.Slice2JavaPlugin.Slice2JavaNature"; + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.resources.IProjectNature#configure() + */ + public void configure() + throws CoreException + { + IProjectDescription desc = _project.getDescription(); + ICommand[] commands = desc.getBuildSpec(); + + for(int i = 0; i < commands.length; ++i) + { + if(commands[i].getBuilderName().equals(Slice2JavaBuilder.BUILDER_ID)) + { + return; + } + } + + ICommand[] newCommands = new ICommand[commands.length + 1]; + System.arraycopy(commands, 0, newCommands, 0, commands.length); + ICommand command = desc.newCommand(); + command.setBuilderName(Slice2JavaBuilder.BUILDER_ID); + newCommands[newCommands.length - 1] = command; + desc.setBuildSpec(newCommands); + + _project.setDescription(desc, null); + + // Initialize a new configuration for this project. + Configuration config = new Configuration(_project); + config.initialize(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.resources.IProjectNature#deconfigure() + */ + public void deconfigure() + throws CoreException + { + IProjectDescription description = getProject().getDescription(); + ICommand[] commands = description.getBuildSpec(); + for(int i = 0; i < commands.length; ++i) + { + if(commands[i].getBuilderName().equals(Slice2JavaBuilder.BUILDER_ID)) + { + 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); + return; + } + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.resources.IProjectNature#getProject() + */ + public IProject getProject() + { + return _project; + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core + * .resources.IProject) + */ + public void setProject(IProject project) + { + _project = project; + } + + + private IProject _project; +} -- cgit v1.2.3 From 22b0fa10566956b2a3c4e325498226e9fef8055f Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Fri, 20 Mar 2009 13:24:27 -0700 Subject: bug 3920 - Eclipse plug-in issues --- .../builder/Slice2JavaBuilder.java | 54 ++++++++++++---------- .../slice2javaplugin/builder/Slice2JavaNature.java | 4 +- 2 files changed, 32 insertions(+), 26 deletions(-) (limited to 'eclipse/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/builder/Slice2JavaNature.java') diff --git a/eclipse/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/builder/Slice2JavaBuilder.java b/eclipse/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/builder/Slice2JavaBuilder.java index 132424f4f2e..ce75d4062e2 100644 --- a/eclipse/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/builder/Slice2JavaBuilder.java +++ b/eclipse/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/builder/Slice2JavaBuilder.java @@ -279,10 +279,16 @@ public class Slice2JavaBuilder extends IncrementalProjectBuilder String ext = file.getFileExtension(); if(ext != null && ext.equals("ice")) { - IFolder folder = (IFolder)file.getParent(); - if(_sourceLocations.contains(folder)) + // + // The parent may not be an IFolder (e.g., it could be a Project). + // + if(file.getParent() instanceof IFolder) { - return true; + IFolder folder = (IFolder)file.getParent(); + if(_sourceLocations.contains(folder)) + { + return true; + } } } return false; @@ -945,32 +951,32 @@ public class Slice2JavaBuilder extends IncrementalProjectBuilder // Any remaining are complete orphans and should // be removed. orphanCandidateSet.removeAll(generatedJavaFiles); - - if(state.out != null) + } + + if(state.out != null) + { + if(orphanCandidateSet.isEmpty()) { - if(orphanCandidateSet.isEmpty()) - { - state.out.println("No orphans from this build."); - } - else - { - state.out.println("Orphans from this build:"); - for(Iterator p = orphanCandidateSet.iterator(); p.hasNext();) - { - state.out.println(" " + p.next().getProjectRelativePath().toString()); - } - } + state.out.println("No orphans from this build."); } - - // - // Remove orphans. - // - for(Iterator p = orphanCandidateSet.iterator(); p.hasNext();) + else { - p.next().delete(true, false, monitor); + state.out.println("Orphans from this build:"); + for(Iterator p = orphanCandidateSet.iterator(); p.hasNext();) + { + state.out.println(" " + p.next().getProjectRelativePath().toString()); + } } } - + + // + // Remove orphans. + // + for(Iterator p = orphanCandidateSet.iterator(); p.hasNext();) + { + p.next().delete(true, false, monitor); + } + // The dependencies of any files without build errors should be updated. if(!depends.isEmpty()) { diff --git a/eclipse/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/builder/Slice2JavaNature.java b/eclipse/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/builder/Slice2JavaNature.java index b401f63493d..5dbfff46203 100644 --- a/eclipse/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/builder/Slice2JavaNature.java +++ b/eclipse/Slice2javaPlugin/src/com/zeroc/slice2javaplugin/builder/Slice2JavaNature.java @@ -45,10 +45,10 @@ public class Slice2JavaNature implements IProjectNature } ICommand[] newCommands = new ICommand[commands.length + 1]; - System.arraycopy(commands, 0, newCommands, 0, commands.length); + System.arraycopy(commands, 0, newCommands, 1, commands.length); ICommand command = desc.newCommand(); command.setBuilderName(Slice2JavaBuilder.BUILDER_ID); - newCommands[newCommands.length - 1] = command; + newCommands[0] = command; desc.setBuildSpec(newCommands); _project.setDescription(desc, null); -- cgit v1.2.3