Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Yann Ollivier committed Jan 22, 2012
0 parents commit 144182a
Show file tree
Hide file tree
Showing 14 changed files with 304 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
28 changes: 28 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>se.ya2o.targetderivator</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>
8 changes: 8 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Sat Jan 21 23:58:25 CET 2012
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.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
12 changes: 12 additions & 0 deletions META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Targetderivator
Bundle-SymbolicName: se.ya2o.targetderivator; singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: se.ya2o.targetderivator.Activator
Bundle-Vendor: Yann Ollivier
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.core.resources
4 changes: 4 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This Eclipse plugin (developped on Eclipse 3.7.1) is for Maven users who want to mark the target folders as derived resources.
The point is to filter the derived resources when searching for resources (with i.e. Ctrl+Shift+R). After a mvn clean, the target
folders are recreated, and the plugin will help to mark these new folders as derivated.

Binary file added bin/se/ya2o/targetderivator/Activator.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/
Binary file added icons/Pointy.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>

<extension
point="org.eclipse.ui.actionSets">
<actionSet
label="Sample Action Set"
visible="true"
id="se.ya2o.targetderivator.actionSet">
<menu
label="Sample &amp;Menu"
id="sampleMenu">
<separator
name="sampleGroup">
</separator>
</menu>
<action
label="&amp;Sample Action"
icon="icons/Pointy.gif"
class="se.ya2o.targetderivator.actions.TargetDerivatorAction"
tooltip="Mark target folders as derived resources"
menubarPath="sampleMenu/sampleGroup"
toolbarPath="sampleGroup"
id="se.ya2o.targetderivator.actions.TargetDerivatorAction">
</action>
</actionSet>
</extension>

</plugin>
Binary file not shown.
61 changes: 61 additions & 0 deletions src/se/ya2o/targetderivator/Activator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package se.ya2o.targetderivator;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {

// The plug-in ID
public static final String PLUGIN_ID = "se.ya2o.targetderivator"; //$NON-NLS-1$

// The shared instance
private static Activator plugin;

/**
* The constructor
*/
public Activator() {
}

/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}

/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}

/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}

/**
* Returns an image descriptor for the image file at the given
* plug-in relative path
*
* @param path the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
}
148 changes: 148 additions & 0 deletions src/se/ya2o/targetderivator/actions/TargetDerivatorAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package se.ya2o.targetderivator.actions;

import java.util.Arrays;
import java.util.List;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.jface.dialogs.MessageDialog;

/**
* Our sample action implements workbench action delegate.
* The action proxy will be created by the workbench and
* shown in the UI. When the user tries to use the action,
* this delegate will be created and execution will be
* delegated to it.
*
* @see IWorkbenchWindowActionDelegate
*/
public class TargetDerivatorAction implements IWorkbenchWindowActionDelegate
{
private IWorkbenchWindow window;

/**
* The constructor.
*/
public TargetDerivatorAction()
{}

/**
* The action has been activated. The argument of the
* method represents the 'real' action sitting
* in the workbench UI.
*
* @see IWorkbenchWindowActionDelegate#run
*/
@Override
public void run(IAction action)
{
// MessageDialog.openInformation(
// window.getShell(),
// "Targetderivator",
// "Marking target folders as derivated resources...");

IWorkspace workspace = ResourcesPlugin.getWorkspace();
List<IProject> projects = Arrays.asList(workspace.getRoot().getProjects());

IProgressMonitor monitor = new IProgressMonitor()
{

@Override
public void beginTask(String arg0, int arg1)
{}

@Override
public void done()
{}

@Override
public void internalWorked(double arg0)
{}

@Override
public boolean isCanceled()
{
return false;
}

@Override
public void setCanceled(boolean arg0)
{}

@Override
public void setTaskName(String arg0)
{}

@Override
public void subTask(String arg0)
{}

@Override
public void worked(int arg0)
{}
};

for(IProject project : projects)
{
if(project.isOpen())
{
try
{
List<IResource> resources = Arrays.asList(project.members());
for(IResource resource : resources)
{
if("target".equals(resource.getName()))
{
resource.setDerived(true, monitor);
}
}
}
catch(CoreException e)
{}
}
}

}

/**
* Selection in the workbench has been changed. We
* can change the state of the 'real' action here
* if we want, but this can only happen after
* the delegate has been created.
*
* @see IWorkbenchWindowActionDelegate#selectionChanged
*/
@Override
public void selectionChanged(IAction action, ISelection selection)
{}

/**
* We can use this method to dispose of any system
* resources we previously allocated.
*
* @see IWorkbenchWindowActionDelegate#dispose
*/
@Override
public void dispose()
{}

/**
* We will cache window object in order to
* be able to provide parent shell for the message dialog.
*
* @see IWorkbenchWindowActionDelegate#init
*/
@Override
public void init(IWorkbenchWindow window)
{
this.window = window;
}
}

0 comments on commit 144182a

Please sign in to comment.