Skip to content

Commit

Permalink
Merge branch 'develop' into master2
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexLandau committed Jul 7, 2015
2 parents 7397256 + d3e8e4e commit daea381
Show file tree
Hide file tree
Showing 81 changed files with 3,605 additions and 3,002 deletions.
2 changes: 1 addition & 1 deletion net.alloyggp.griddle/.classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="validation-0.1.1.jar"/>
<classpathentry exported="true" kind="lib" path="validation-0.2.0.jar"/>
<classpathentry exported="true" kind="lib" path="java-cup-11b-runtime.jar"/>
<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"/>
Expand Down
4 changes: 2 additions & 2 deletions net.alloyggp.griddle/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Griddle
Bundle-SymbolicName: net.alloyggp.griddle;singleton:=true
Bundle-Version: 0.1.1.qualifier
Bundle-Version: 0.2.0.qualifier
Bundle-Activator: net.alloyggp.griddle.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
Expand All @@ -11,6 +11,6 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.resources;bundle-version="3.9.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: validation-0.1.1.jar,
Bundle-ClassPath: validation-0.2.0.jar,
java-cup-11b-runtime.jar,
.
2 changes: 1 addition & 1 deletion net.alloyggp.griddle/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ bin.includes = plugin.xml,\
.,\
icons/,\
java-cup-11b-runtime.jar,\
validation-0.1.1.jar
validation-0.2.0.jar
jars.compile.order = .
14 changes: 14 additions & 0 deletions net.alloyggp.griddle/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
</command>
<command defaultHandler="net.alloyggp.griddle.builder.RemoveBuilder" id="net.alloyggp.griddle.removeBuilder" name="Remove GDL Validation">
</command>
<command
defaultHandler="net.alloyggp.griddle.actions.FormatGdlAction"
id="net.alloyggp.griddle.reformatGdl"
name="Reformat GDL">
</command>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution allPopups="false" locationURI="popup:org.eclipse.ui.projectConfigure?after=additions">
Expand All @@ -41,6 +46,15 @@
<command commandId="net.alloyggp.griddle.removeBuilder" style="push">
</command>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:net.alloyggp.griddle.editors.GdlEditor#TextEditorContext?after=additions">
<command
commandId="net.alloyggp.griddle.reformatGdl"
label="Reformat GDL"
style="push">
</command>
</menuContribution>
</extension>

</plugin>
102 changes: 51 additions & 51 deletions net.alloyggp.griddle/src/net/alloyggp/griddle/Activator.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,55 @@
*/
public class Activator extends AbstractUIPlugin {

// The plug-in ID
public static final String PLUGIN_ID = "net.alloyggp.griddle"; //$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)
*/
@Override
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)
*/
@Override
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);
}
// The plug-in ID
public static final String PLUGIN_ID = "net.alloyggp.griddle"; //$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)
*/
@Override
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)
*/
@Override
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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package net.alloyggp.griddle.actions;

import net.alloyggp.griddle.editors.GdlEditor;
import net.alloyggp.griddle.indentation.GameIndenter;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.texteditor.IDocumentProvider;

public class FormatGdlAction extends AbstractHandler implements IHandler {

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditorChecked(event);
GdlEditor gdlEditor = (GdlEditor) editor;
IDocumentProvider documentProvider = gdlEditor.getDocumentProvider();
IDocument document = documentProvider.getDocument(gdlEditor.getEditorInput());
String docAsText = document.get();
try {
String formatted = GameIndenter.reindentGameDescription(docAsText);
document.set(formatted);
} catch (Exception e) {
throw new ExecutionException("Failed to reformat game description", e);
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,59 +22,59 @@
*/
public class AddBuilder extends AbstractHandler implements IHandler {

@Override
public Object execute(final ExecutionEvent event) {
final IProject project = getProject(event);
@Override
public Object execute(final ExecutionEvent event) {
final IProject project = getProject(event);

if (project != null) {
try {
// verify already registered builders
if (hasBuilder(project)) {
// already enabled
return null;
}
if (project != null) {
try {
// verify already registered builders
if (hasBuilder(project)) {
// already enabled
return null;
}

// add builder to project properties
IProjectDescription description = project.getDescription();
final ICommand buildCommand = description.newCommand();
buildCommand.setBuilderName(GdlBuilder.BUILDER_ID);
// add builder to project properties
IProjectDescription description = project.getDescription();
final ICommand buildCommand = description.newCommand();
buildCommand.setBuilderName(GdlBuilder.BUILDER_ID);

final List<ICommand> commands = new ArrayList<ICommand>();
commands.addAll(Arrays.asList(description.getBuildSpec()));
commands.add(buildCommand);
final List<ICommand> commands = new ArrayList<ICommand>();
commands.addAll(Arrays.asList(description.getBuildSpec()));
commands.add(buildCommand);

description.setBuildSpec(commands.toArray(new ICommand[commands.size()]));
project.setDescription(description, null);
description.setBuildSpec(commands.toArray(new ICommand[commands.size()]));
project.setDescription(description, null);

} catch (final CoreException e) {
// TODO could not read/write project description
e.printStackTrace();
}
}
} catch (final CoreException e) {
// TODO could not read/write project description
e.printStackTrace();
}
}

return null;
}
return null;
}

public static IProject getProject(final ExecutionEvent event) {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
final Object element = ((IStructuredSelection) selection).getFirstElement();
public static IProject getProject(final ExecutionEvent event) {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
final Object element = ((IStructuredSelection) selection).getFirstElement();

return (IProject) Platform.getAdapterManager().getAdapter(element, IProject.class);
}
return (IProject) Platform.getAdapterManager().getAdapter(element, IProject.class);
}

return null;
}
return null;
}

public static final boolean hasBuilder(final IProject project) {
try {
for (final ICommand buildSpec : project.getDescription().getBuildSpec()) {
if (GdlBuilder.BUILDER_ID.equals(buildSpec.getBuilderName()))
return true;
}
} catch (final CoreException e) {
}
public static final boolean hasBuilder(final IProject project) {
try {
for (final ICommand buildSpec : project.getDescription().getBuildSpec()) {
if (GdlBuilder.BUILDER_ID.equals(buildSpec.getBuilderName()))
return true;
}
} catch (final CoreException e) {
}

return false;
}
return false;
}
}
Loading

0 comments on commit daea381

Please sign in to comment.