move eclipse plugin to a better place
[[Split portion of a mixed commit.]]
This commit is contained in:
parent
0cf46578b0
commit
020dce3efb
34 changed files with 1682 additions and 0 deletions
7
utils/eclipse_plugin/.classpath
Normal file
7
utils/eclipse_plugin/.classpath
Normal file
|
@ -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
utils/eclipse_plugin/.project
Normal file
28
utils/eclipse_plugin/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Wesnoth Eclipse Plugin</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>
|
|
@ -0,0 +1,8 @@
|
|||
#Sun Mar 21 05:00:10 CET 2010
|
||||
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
|
13
utils/eclipse_plugin/META-INF/MANIFEST.MF
Normal file
13
utils/eclipse_plugin/META-INF/MANIFEST.MF
Normal file
|
@ -0,0 +1,13 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Wesnoth_Eclipse_Plugin
|
||||
Bundle-SymbolicName: Wesnoth_Eclipse_Plugin; singleton:=true
|
||||
Bundle-Version: 0.1
|
||||
Bundle-Activator: wesnoth_eclipse_plugin.Activator
|
||||
Bundle-Vendor: www.wesnoth.org
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.core.resources,
|
||||
org.eclipse.ui.ide
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-ActivationPolicy: lazy
|
9
utils/eclipse_plugin/build.properties
Normal file
9
utils/eclipse_plugin/build.properties
Normal file
|
@ -0,0 +1,9 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = plugin.xml,\
|
||||
META-INF/,\
|
||||
.,\
|
||||
html/,\
|
||||
*.xml,\
|
||||
icons/,\
|
||||
contexts.xml
|
12
utils/eclipse_plugin/contexts.xml
Normal file
12
utils/eclipse_plugin/contexts.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<contexts>
|
||||
<context id="viewer" title="Sample View">
|
||||
<description>This is the context help for the sample view with a table viewer. It was generated by a PDE template.</description>
|
||||
<topic href="/PLUGINS_ROOT/org.eclipse.platform.doc.isv/guide/ua_help_context.htm" label="Context-sensitive help">
|
||||
<enablement>
|
||||
<with variable="platform">
|
||||
<test property="org.eclipse.core.runtime.isBundleInstalled" args="org.eclipse.platform.doc.isv"/>
|
||||
</with>
|
||||
</enablement>
|
||||
</topic>
|
||||
</context>
|
||||
</contexts>
|
13
utils/eclipse_plugin/html/maintopic.html
Normal file
13
utils/eclipse_plugin/html/maintopic.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<title>Main Topic</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Main Topic</h1>
|
||||
Please enter your text here.
|
||||
</body>
|
||||
</html>
|
13
utils/eclipse_plugin/html/subtopic.html
Normal file
13
utils/eclipse_plugin/html/subtopic.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<title>Sub Topic</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Sub Topic</h1>
|
||||
Please enter your text here.
|
||||
</body>
|
||||
</html>
|
13
utils/eclipse_plugin/html/toc.html
Normal file
13
utils/eclipse_plugin/html/toc.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<title>Table of Contents</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Table of Contents</h1>
|
||||
Please enter your text here.
|
||||
</body>
|
||||
</html>
|
BIN
utils/eclipse_plugin/icons/sample.gif
Normal file
BIN
utils/eclipse_plugin/icons/sample.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 983 B |
129
utils/eclipse_plugin/plugin.xml
Normal file
129
utils/eclipse_plugin/plugin.xml
Normal file
|
@ -0,0 +1,129 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
|
||||
<extension
|
||||
id="sampleBuilder"
|
||||
name="Sample Project Builder"
|
||||
point="org.eclipse.core.resources.builders">
|
||||
<builder
|
||||
hasNature="true">
|
||||
<run
|
||||
class="wesnoth_eclipse_plugin.builder.SampleBuilder">
|
||||
</run>
|
||||
</builder>
|
||||
</extension>
|
||||
<extension
|
||||
id="sampleNature"
|
||||
name="Sample Project Nature"
|
||||
point="org.eclipse.core.resources.natures">
|
||||
<runtime>
|
||||
<run
|
||||
class="wesnoth_eclipse_plugin.builder.SampleNature">
|
||||
</run>
|
||||
</runtime>
|
||||
<builder
|
||||
id="Wesnoth_Eclipse_Plugin.sampleBuilder">
|
||||
</builder>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.popupMenus">
|
||||
<objectContribution
|
||||
adaptable="true"
|
||||
objectClass="org.eclipse.core.resources.IProject"
|
||||
nameFilter="*"
|
||||
id="Wesnoth_Eclipse_Plugin.contribution1">
|
||||
<action
|
||||
label="Add/Remove Sample Nature"
|
||||
class="wesnoth_eclipse_plugin.builder.ToggleNatureAction"
|
||||
menubarPath="additions"
|
||||
enablesFor="+"
|
||||
id="Wesnoth_Eclipse_Plugin.addRemoveNatureAction">
|
||||
</action>
|
||||
</objectContribution>
|
||||
</extension>
|
||||
<extension
|
||||
id="xmlProblem"
|
||||
name="XML Problem"
|
||||
point="org.eclipse.core.resources.markers">
|
||||
<super
|
||||
type="org.eclipse.core.resources.problemmarker">
|
||||
</super>
|
||||
<persistent
|
||||
value="true">
|
||||
</persistent>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.help.toc">
|
||||
<toc
|
||||
file="toc.xml">
|
||||
</toc>
|
||||
<toc
|
||||
file="testToc.xml"
|
||||
primary="true">
|
||||
</toc>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.views">
|
||||
<category
|
||||
name="Sample Category"
|
||||
id="Wesnoth_Eclipse_Plugin">
|
||||
</category>
|
||||
<view
|
||||
name="Wesnoth View"
|
||||
icon="icons/sample.gif"
|
||||
category="Wesnoth_Eclipse_Plugin"
|
||||
class="wesnoth_eclipse_plugin.views.SampleView"
|
||||
id="wesnoth_eclipse_plugin.views.SampleView">
|
||||
</view>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.perspectiveExtensions">
|
||||
<perspectiveExtension
|
||||
targetID="org.eclipse.jdt.ui.JavaPerspective">
|
||||
<view
|
||||
ratio="0.5"
|
||||
relative="org.eclipse.ui.views.TaskList"
|
||||
relationship="right"
|
||||
id="wesnoth_eclipse_plugin.views.SampleView">
|
||||
</view>
|
||||
</perspectiveExtension>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.help.contexts">
|
||||
<contexts
|
||||
file="contexts.xml">
|
||||
</contexts>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.newWizards">
|
||||
<category name="Wesnoth"
|
||||
id="wesnoth.eclipse.newWizards">
|
||||
</category>
|
||||
<wizard name="Wesnoth Campaign"
|
||||
icon="icons/sample.gif"
|
||||
category="wesnoth.eclipse.newWizards"
|
||||
class="wesnoth_eclipse_plugin.wizards.CampaignNewWizard"
|
||||
id="wesnoth_eclipse_plugin.wizards.CampaignNewWizard"
|
||||
project="true">
|
||||
<description>Create a Wesnoth campaign.</description>
|
||||
</wizard>
|
||||
<!-- </extension> -->
|
||||
|
||||
<!-- <extension
|
||||
point="org.eclipse.ui.newWizards">
|
||||
<category name="Wesnoth"
|
||||
id="wesnoth.eclipse.newWizards">
|
||||
</category> -->
|
||||
<wizard name="Wesnoth Scenario"
|
||||
icon="icons/sample.gif"
|
||||
category="wesnoth.eclipse.newWizards"
|
||||
class="wesnoth_eclipse_plugin.wizards.ScenarioNewWizard"
|
||||
id="wesnoth_eclipse_plugin.wizards.ScenarioNewWizard"
|
||||
project="false">
|
||||
<description>Create a Wesnoth campaign.</description>
|
||||
</wizard>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
|
@ -0,0 +1,76 @@
|
|||
package org.wesnoth.wml.core;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.wesnoth.wml.schema.SchemaAttribute;
|
||||
import org.wesnoth.wml.schema.SchemaChild;
|
||||
import org.wesnoth.wml.schema.SchemaTag;
|
||||
import org.wesnoth.wml.schema.impl.SchemaAttributeChildImpl;
|
||||
import org.wesnoth.wml.schema.impl.SchemaAttributeImpl;
|
||||
import org.wesnoth.wml.schema.impl.SchemaTagImpl;
|
||||
|
||||
public class SchemaFactory {
|
||||
private static Map<String,SchemaTag> schemaTagsMap;
|
||||
private static Map<String,SchemaAttribute> schemaAttributesMap;
|
||||
|
||||
public static SchemaTag getSchemaForTag(String name) {
|
||||
return schemaTagsMap.get(name);
|
||||
}
|
||||
public static SchemaAttribute getSchemaForAttribute(String name) {
|
||||
return schemaAttributesMap.get(name);
|
||||
}
|
||||
|
||||
{
|
||||
//stub code
|
||||
schemaAttributesMap = new LinkedHashMap<String,SchemaAttribute>();
|
||||
schemaTagsMap = new LinkedHashMap<String,SchemaTag>();
|
||||
SchemaTagImpl scenario = new SchemaTagImpl();
|
||||
scenario.setName("scenario");
|
||||
scenario.setDescription("this is a scenario tag");
|
||||
schemaTagsMap.put("scenario", scenario);
|
||||
|
||||
SchemaTagImpl campaign = new SchemaTagImpl();
|
||||
campaign.setName("campaign");
|
||||
campaign.setDescription("this is a campaign tag");
|
||||
|
||||
SchemaAttributeImpl string = new SchemaAttributeImpl("string");
|
||||
schemaAttributesMap.put("string", string);
|
||||
SchemaAttributeImpl tstring = new SchemaAttributeImpl("tstring");
|
||||
schemaAttributesMap.put("tstring", tstring);
|
||||
SchemaAttributeImpl identifier = new SchemaAttributeImpl("identifier");
|
||||
schemaAttributesMap.put("identifier", identifier);
|
||||
SchemaAttributeImpl path = new SchemaAttributeImpl("path");
|
||||
schemaAttributesMap.put("path", path);
|
||||
SchemaAttributeImpl integer = new SchemaAttributeImpl("integer");
|
||||
schemaAttributesMap.put("integer", integer);
|
||||
|
||||
campaign.addAttribute(new SchemaAttributeChildImpl("abbrev",identifier,SchemaChild.REQUIRED));
|
||||
|
||||
campaign.addAttribute(new SchemaAttributeChildImpl("define",identifier,SchemaChild.REQUIRED));
|
||||
|
||||
campaign.addAttribute(new SchemaAttributeChildImpl("description",tstring,SchemaChild.REQUIRED));
|
||||
|
||||
campaign.addAttribute(new SchemaAttributeChildImpl("difficulties",string,SchemaChild.REQUIRED));
|
||||
|
||||
campaign.addAttribute(new SchemaAttributeChildImpl("difficulty_descriptions",string,SchemaChild.REQUIRED));
|
||||
|
||||
campaign.addAttribute(new SchemaAttributeChildImpl("extra_defines",string,SchemaChild.OPTIONAL));
|
||||
|
||||
campaign.addAttribute(new SchemaAttributeChildImpl("first_scenario",identifier,SchemaChild.REQUIRED));
|
||||
|
||||
campaign.addAttribute(new SchemaAttributeChildImpl("icon",path,SchemaChild.OPTIONAL));
|
||||
|
||||
campaign.addAttribute(new SchemaAttributeChildImpl("id",string,SchemaChild.REQUIRED));
|
||||
|
||||
campaign.addAttribute(new SchemaAttributeChildImpl("image",path,SchemaChild.OPTIONAL));
|
||||
|
||||
campaign.addAttribute(new SchemaAttributeChildImpl("name",tstring,SchemaChild.REQUIRED));
|
||||
|
||||
campaign.addAttribute(new SchemaAttributeChildImpl("rank",integer,SchemaChild.REQUIRED));
|
||||
|
||||
|
||||
schemaTagsMap.put("campaign", campaign);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.wesnoth.wml.schema;
|
||||
|
||||
public interface SchemaAttribute extends SchemaElement{
|
||||
String getValueExpression();
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.wesnoth.wml.schema;
|
||||
|
||||
public interface SchemaAttributeChild extends SchemaChild {
|
||||
SchemaAttribute getChild();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.wesnoth.wml.schema;
|
||||
|
||||
public interface SchemaChild {
|
||||
public static boolean REQUIRED = true;
|
||||
public static boolean OPTIONAL = false;
|
||||
boolean isRequired();
|
||||
String getName();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.wesnoth.wml.schema;
|
||||
|
||||
|
||||
public interface SchemaElement {
|
||||
public String getDescription();
|
||||
public String getName();
|
||||
public boolean isTag();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.wesnoth.wml.schema;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SchemaTag extends SchemaElement{
|
||||
List<SchemaAttributeChild> getAttributes();
|
||||
List<SchemaTagChild> getTags();
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.wesnoth.wml.schema;
|
||||
|
||||
|
||||
public interface SchemaTagChild extends SchemaChild {
|
||||
SchemaTag getChild();
|
||||
boolean isRepeated();
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package org.wesnoth.wml.schema.impl;
|
||||
|
||||
import org.wesnoth.wml.schema.SchemaAttribute;
|
||||
import org.wesnoth.wml.schema.SchemaAttributeChild;
|
||||
|
||||
public class SchemaAttributeChildImpl implements SchemaAttributeChild {
|
||||
|
||||
SchemaAttribute child;
|
||||
String name;
|
||||
boolean required;
|
||||
|
||||
public SchemaAttributeChildImpl(String name, SchemaAttribute child, boolean required) {
|
||||
super();
|
||||
this.child = child;
|
||||
this.name = name;
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public SchemaAttribute getChild() {
|
||||
return this.child;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setChild(SchemaAttribute child) {
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
|
||||
public boolean isRequired() {
|
||||
return this.required;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setRequired(boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package org.wesnoth.wml.schema.impl;
|
||||
|
||||
import org.wesnoth.wml.schema.SchemaAttribute;
|
||||
|
||||
public class SchemaAttributeImpl implements SchemaAttribute {
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private String valueExpression;
|
||||
|
||||
public SchemaAttributeImpl(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValueExpression() {
|
||||
return this.valueExpression;
|
||||
}
|
||||
|
||||
public void setValueExpression(String valueExpression) {
|
||||
this.valueExpression = valueExpression;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTag() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package org.wesnoth.wml.schema.impl;
|
||||
|
||||
import org.wesnoth.wml.schema.SchemaTag;
|
||||
import org.wesnoth.wml.schema.SchemaTagChild;
|
||||
|
||||
public class SchemaTagChildImpl implements SchemaTagChild {
|
||||
SchemaTag child;
|
||||
String name;
|
||||
boolean repeated;
|
||||
boolean required;
|
||||
|
||||
@Override
|
||||
public SchemaTag getChild() {
|
||||
return this.child;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepeated() {
|
||||
return this.repeated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequired() {
|
||||
return this.required;
|
||||
}
|
||||
|
||||
public void setChild(SchemaTag child) {
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public void setRepeated(boolean repeated) {
|
||||
this.repeated = repeated;
|
||||
}
|
||||
|
||||
public void setRequired(boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package org.wesnoth.wml.schema.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.wesnoth.wml.schema.SchemaAttributeChild;
|
||||
import org.wesnoth.wml.schema.SchemaTag;
|
||||
import org.wesnoth.wml.schema.SchemaTagChild;
|
||||
|
||||
public class SchemaTagImpl implements SchemaTag {
|
||||
private List<SchemaAttributeChild> attributes = new ArrayList<SchemaAttributeChild>();
|
||||
private List<SchemaTagChild> tags = new ArrayList<SchemaTagChild>();
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
public List<SchemaAttributeChild> getAttributes() {
|
||||
return this.attributes;
|
||||
}
|
||||
public void setAttributes(List<SchemaAttributeChild> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
public List<SchemaTagChild> getTags() {
|
||||
return this.tags;
|
||||
}
|
||||
public void setTags(List<SchemaTagChild> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTag() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addAttribute(SchemaAttributeChild attribute) {
|
||||
this.attributes.add(attribute);
|
||||
}
|
||||
|
||||
public void addTag(SchemaTagChild tag) {
|
||||
this.tags.add(tag);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package wesnoth_eclipse_plugin;
|
||||
|
||||
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 = "Wesnoth_Eclipse_Plugin";
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
package wesnoth_eclipse_plugin.builder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
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.IResourceVisitor;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
public class SampleBuilder extends IncrementalProjectBuilder {
|
||||
|
||||
class SampleDeltaVisitor implements IResourceDeltaVisitor {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
|
||||
*/
|
||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||
IResource resource = delta.getResource();
|
||||
switch (delta.getKind()) {
|
||||
case IResourceDelta.ADDED:
|
||||
// handle added resource
|
||||
checkXML(resource);
|
||||
break;
|
||||
case IResourceDelta.REMOVED:
|
||||
// handle removed resource
|
||||
break;
|
||||
case IResourceDelta.CHANGED:
|
||||
// handle changed resource
|
||||
checkXML(resource);
|
||||
break;
|
||||
}
|
||||
//return true to continue visiting children.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class SampleResourceVisitor implements IResourceVisitor {
|
||||
public boolean visit(IResource resource) {
|
||||
checkXML(resource);
|
||||
//return true to continue visiting children.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class XMLErrorHandler extends DefaultHandler {
|
||||
|
||||
private IFile file;
|
||||
|
||||
public XMLErrorHandler(IFile file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
private void addMarker(SAXParseException e, int severity) {
|
||||
SampleBuilder.this.addMarker(file, e.getMessage(), e
|
||||
.getLineNumber(), severity);
|
||||
}
|
||||
|
||||
public void error(SAXParseException exception) throws SAXException {
|
||||
addMarker(exception, IMarker.SEVERITY_ERROR);
|
||||
}
|
||||
|
||||
public void fatalError(SAXParseException exception) throws SAXException {
|
||||
addMarker(exception, IMarker.SEVERITY_ERROR);
|
||||
}
|
||||
|
||||
public void warning(SAXParseException exception) throws SAXException {
|
||||
addMarker(exception, IMarker.SEVERITY_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String BUILDER_ID = "Wesnoth_Eclipse_Plugin.sampleBuilder";
|
||||
|
||||
private static final String MARKER_TYPE = "Wesnoth_Eclipse_Plugin.xmlProblem";
|
||||
|
||||
private SAXParserFactory parserFactory;
|
||||
|
||||
private void addMarker(IFile file, String message, int lineNumber,
|
||||
int severity) {
|
||||
try {
|
||||
IMarker marker = file.createMarker(MARKER_TYPE);
|
||||
marker.setAttribute(IMarker.MESSAGE, message);
|
||||
marker.setAttribute(IMarker.SEVERITY, severity);
|
||||
if (lineNumber == -1) {
|
||||
lineNumber = 1;
|
||||
}
|
||||
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.core.internal.events.InternalBuilder#build(int,
|
||||
* java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
if (kind == FULL_BUILD) {
|
||||
fullBuild(monitor);
|
||||
} else {
|
||||
IResourceDelta delta = getDelta(getProject());
|
||||
if (delta == null) {
|
||||
fullBuild(monitor);
|
||||
} else {
|
||||
incrementalBuild(delta, monitor);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void checkXML(IResource resource) {
|
||||
if (resource instanceof IFile && resource.getName().endsWith(".xml")) {
|
||||
IFile file = (IFile) resource;
|
||||
deleteMarkers(file);
|
||||
XMLErrorHandler reporter = new XMLErrorHandler(file);
|
||||
try {
|
||||
getParser().parse(file.getContents(), reporter);
|
||||
} catch (Exception e1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteMarkers(IFile file) {
|
||||
try {
|
||||
file.deleteMarkers(MARKER_TYPE, false, IResource.DEPTH_ZERO);
|
||||
} catch (CoreException ce) {
|
||||
}
|
||||
}
|
||||
|
||||
protected void fullBuild(final IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
try {
|
||||
getProject().accept(new SampleResourceVisitor());
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
|
||||
private SAXParser getParser() throws ParserConfigurationException,
|
||||
SAXException {
|
||||
if (parserFactory == null) {
|
||||
parserFactory = SAXParserFactory.newInstance();
|
||||
}
|
||||
return parserFactory.newSAXParser();
|
||||
}
|
||||
|
||||
protected void incrementalBuild(IResourceDelta delta,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
// the visitor does the work.
|
||||
delta.accept(new SampleDeltaVisitor());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package wesnoth_eclipse_plugin.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;
|
||||
|
||||
public class SampleNature implements IProjectNature {
|
||||
|
||||
/**
|
||||
* ID of this project nature
|
||||
*/
|
||||
public static final String NATURE_ID = "Wesnoth_Eclipse_Plugin.sampleNature";
|
||||
|
||||
private IProject project;
|
||||
|
||||
/*
|
||||
* (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(SampleBuilder.BUILDER_ID)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ICommand[] newCommands = new ICommand[commands.length + 1];
|
||||
System.arraycopy(commands, 0, newCommands, 0, commands.length);
|
||||
ICommand command = desc.newCommand();
|
||||
command.setBuilderName(SampleBuilder.BUILDER_ID);
|
||||
newCommands[newCommands.length - 1] = command;
|
||||
desc.setBuildSpec(newCommands);
|
||||
project.setDescription(desc, null);
|
||||
}
|
||||
|
||||
/*
|
||||
* (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(SampleBuilder.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);
|
||||
project.setDescription(description, null);
|
||||
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) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package wesnoth_eclipse_plugin.builder;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.IObjectActionDelegate;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
|
||||
public class ToggleNatureAction implements IObjectActionDelegate {
|
||||
|
||||
private ISelection selection;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
||||
*/
|
||||
public void run(IAction action) {
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
for (Iterator it = ((IStructuredSelection) selection).iterator(); it
|
||||
.hasNext();) {
|
||||
Object element = it.next();
|
||||
IProject project = null;
|
||||
if (element instanceof IProject) {
|
||||
project = (IProject) element;
|
||||
} else if (element instanceof IAdaptable) {
|
||||
project = (IProject) ((IAdaptable) element)
|
||||
.getAdapter(IProject.class);
|
||||
}
|
||||
if (project != null) {
|
||||
toggleNature(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
|
||||
* org.eclipse.jface.viewers.ISelection)
|
||||
*/
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
this.selection = selection;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction,
|
||||
* org.eclipse.ui.IWorkbenchPart)
|
||||
*/
|
||||
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles sample nature on a project
|
||||
*
|
||||
* @param project
|
||||
* to have sample nature added or removed
|
||||
*/
|
||||
private void toggleNature(IProject project) {
|
||||
try {
|
||||
IProjectDescription description = project.getDescription();
|
||||
String[] natures = description.getNatureIds();
|
||||
|
||||
for (int i = 0; i < natures.length; ++i) {
|
||||
if (SampleNature.NATURE_ID.equals(natures[i])) {
|
||||
// Remove the nature
|
||||
String[] newNatures = new String[natures.length - 1];
|
||||
System.arraycopy(natures, 0, newNatures, 0, i);
|
||||
System.arraycopy(natures, i + 1, newNatures, i,
|
||||
natures.length - i - 1);
|
||||
description.setNatureIds(newNatures);
|
||||
project.setDescription(description, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the nature
|
||||
String[] newNatures = new String[natures.length + 1];
|
||||
System.arraycopy(natures, 0, newNatures, 0, natures.length);
|
||||
newNatures[natures.length] = SampleNature.NATURE_ID;
|
||||
description.setNatureIds(newNatures);
|
||||
project.setDescription(description, null);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,190 @@
|
|||
package wesnoth_eclipse_plugin.views;
|
||||
|
||||
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.ui.part.*;
|
||||
import org.eclipse.jface.viewers.*;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.jface.action.*;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.ui.*;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
||||
|
||||
/**
|
||||
* This sample class demonstrates how to plug-in a new
|
||||
* workbench view. The view shows data obtained from the
|
||||
* model. The sample creates a dummy model on the fly,
|
||||
* but a real implementation would connect to the model
|
||||
* available either in this or another plug-in (e.g. the workspace).
|
||||
* The view is connected to the model using a content provider.
|
||||
* <p>
|
||||
* The view uses a label provider to define how model
|
||||
* objects should be presented in the view. Each
|
||||
* view can present the same model objects using
|
||||
* different labels and icons, if needed. Alternatively,
|
||||
* a single label provider can be shared between views
|
||||
* in order to ensure that objects of the same type are
|
||||
* presented in the same way everywhere.
|
||||
* <p>
|
||||
*/
|
||||
|
||||
public class SampleView extends ViewPart {
|
||||
|
||||
/**
|
||||
* The ID of the view as specified by the extension.
|
||||
*/
|
||||
public static final String ID = "wesnoth_eclipse_plugin.views.SampleView";
|
||||
|
||||
private TableViewer viewer;
|
||||
private Action action1;
|
||||
private Action action2;
|
||||
private Action doubleClickAction;
|
||||
|
||||
/*
|
||||
* The content provider class is responsible for
|
||||
* providing objects to the view. It can wrap
|
||||
* existing objects in adapters or simply return
|
||||
* objects as-is. These objects may be sensitive
|
||||
* to the current input of the view, or ignore
|
||||
* it and always show the same content
|
||||
* (like Task List, for example).
|
||||
*/
|
||||
|
||||
class ViewContentProvider implements IStructuredContentProvider {
|
||||
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
|
||||
}
|
||||
public void dispose() {
|
||||
}
|
||||
public Object[] getElements(Object parent) {
|
||||
return new String[] { "One", "Two", "Three" };
|
||||
}
|
||||
}
|
||||
class ViewLabelProvider extends LabelProvider implements ITableLabelProvider {
|
||||
public String getColumnText(Object obj, int index) {
|
||||
return getText(obj);
|
||||
}
|
||||
public Image getColumnImage(Object obj, int index) {
|
||||
return getImage(obj);
|
||||
}
|
||||
public Image getImage(Object obj) {
|
||||
return PlatformUI.getWorkbench().
|
||||
getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
|
||||
}
|
||||
}
|
||||
class NameSorter extends ViewerSorter {
|
||||
}
|
||||
|
||||
/**
|
||||
* The constructor.
|
||||
*/
|
||||
public SampleView() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a callback that will allow us
|
||||
* to create the viewer and initialize it.
|
||||
*/
|
||||
public void createPartControl(Composite parent) {
|
||||
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
viewer.setContentProvider(new ViewContentProvider());
|
||||
viewer.setLabelProvider(new ViewLabelProvider());
|
||||
viewer.setSorter(new NameSorter());
|
||||
viewer.setInput(getViewSite());
|
||||
|
||||
// Create the help context id for the viewer's control
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "Wesnoth_Eclipse_Plugin.viewer");
|
||||
makeActions();
|
||||
hookContextMenu();
|
||||
hookDoubleClickAction();
|
||||
contributeToActionBars();
|
||||
}
|
||||
|
||||
private void hookContextMenu() {
|
||||
MenuManager menuMgr = new MenuManager("#PopupMenu");
|
||||
menuMgr.setRemoveAllWhenShown(true);
|
||||
menuMgr.addMenuListener(new IMenuListener() {
|
||||
public void menuAboutToShow(IMenuManager manager) {
|
||||
SampleView.this.fillContextMenu(manager);
|
||||
}
|
||||
});
|
||||
Menu menu = menuMgr.createContextMenu(viewer.getControl());
|
||||
viewer.getControl().setMenu(menu);
|
||||
getSite().registerContextMenu(menuMgr, viewer);
|
||||
}
|
||||
|
||||
private void contributeToActionBars() {
|
||||
IActionBars bars = getViewSite().getActionBars();
|
||||
fillLocalPullDown(bars.getMenuManager());
|
||||
fillLocalToolBar(bars.getToolBarManager());
|
||||
}
|
||||
|
||||
private void fillLocalPullDown(IMenuManager manager) {
|
||||
manager.add(action1);
|
||||
manager.add(new Separator());
|
||||
manager.add(action2);
|
||||
}
|
||||
|
||||
private void fillContextMenu(IMenuManager manager) {
|
||||
manager.add(action1);
|
||||
manager.add(action2);
|
||||
// Other plug-ins can contribute there actions here
|
||||
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
||||
}
|
||||
|
||||
private void fillLocalToolBar(IToolBarManager manager) {
|
||||
manager.add(action1);
|
||||
manager.add(action2);
|
||||
}
|
||||
|
||||
private void makeActions() {
|
||||
action1 = new Action() {
|
||||
public void run() {
|
||||
showMessage("Action 1 executed");
|
||||
}
|
||||
};
|
||||
action1.setText("Action 1");
|
||||
action1.setToolTipText("Action 1 tooltip");
|
||||
action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
|
||||
getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
|
||||
|
||||
action2 = new Action() {
|
||||
public void run() {
|
||||
showMessage("Action 2 executed");
|
||||
}
|
||||
};
|
||||
action2.setText("Action 2");
|
||||
action2.setToolTipText("Action 2 tooltip");
|
||||
action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
|
||||
getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
|
||||
doubleClickAction = new Action() {
|
||||
public void run() {
|
||||
ISelection selection = viewer.getSelection();
|
||||
Object obj = ((IStructuredSelection)selection).getFirstElement();
|
||||
showMessage("Double-click detected on "+obj.toString());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void hookDoubleClickAction() {
|
||||
viewer.addDoubleClickListener(new IDoubleClickListener() {
|
||||
public void doubleClick(DoubleClickEvent event) {
|
||||
doubleClickAction.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
private void showMessage(String message) {
|
||||
MessageDialog.openInformation(
|
||||
viewer.getControl().getShell(),
|
||||
"Sample View",
|
||||
message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passing the focus request to the viewer's control.
|
||||
*/
|
||||
public void setFocus() {
|
||||
viewer.getControl().setFocus();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package wesnoth_eclipse_plugin.wizards;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.wizard.IWizardPage;
|
||||
import org.eclipse.jface.wizard.Wizard;
|
||||
import org.eclipse.ui.INewWizard;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
|
||||
public class CampaignNewWizard extends Wizard implements INewWizard {
|
||||
|
||||
private org.eclipse.ui.IWorkbench workbench;
|
||||
private org.eclipse.jface.viewers.IStructuredSelection selection;
|
||||
|
||||
protected NewCampaignCreationPage fMainPage;
|
||||
private IConfigurationElement fConfig;
|
||||
|
||||
public void addPages() {
|
||||
fMainPage = new NewCampaignCreationPage("blah");
|
||||
addPage(fMainPage);
|
||||
}
|
||||
|
||||
// protected PluginContentPage fContentPage;
|
||||
|
||||
public CampaignNewWizard() {
|
||||
// setDefaultPageImageDescriptor(PDEPluginImages.DESC_NEWPPRJ_WIZ);
|
||||
// setDialogSettings(PDEPlugin.getDefault().getDialogSettings());
|
||||
// setWindowTitle(PDEUIMessages.NewProjectWizard_title);
|
||||
// System.exit(0);
|
||||
setWindowTitle("Create a new Campaign");
|
||||
setNeedsProgressMonitor(true);
|
||||
|
||||
// fPluginData = new PluginFieldData();
|
||||
}
|
||||
|
||||
public CampaignNewWizard(String osgiFramework) {
|
||||
this();
|
||||
// fPluginData.setOSGiFramework(osgiFramework);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
||||
this.workbench = workbench;
|
||||
this.selection = selection;
|
||||
}
|
||||
|
||||
|
||||
// public void init(IWorkbench workbench, IStructuredSelection selection) {
|
||||
// // TODO Auto-generated method stub
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean performFinish() {
|
||||
|
||||
// try {
|
||||
// fMainPage.updateData();
|
||||
//// fContentPage.updateData();
|
||||
// // IDialogSettings settings = getDialogSettings();
|
||||
//// if (settings != null) {
|
||||
//// fMainPage.saveSettings(settings);
|
||||
//// fContentPage.saveSettings(settings);
|
||||
//// }
|
||||
// BasicNewProjectResourceWizard.updatePerspective(fConfig);
|
||||
// // IPluginContentWizard contentWizard = fWizardListPage.getSelectedWizard();
|
||||
// // getContainer().run(false, true, new NewProjectCreationOperation(fPluginData, fProjectProvider, contentWizard));
|
||||
//
|
||||
// // IWorkingSet[] workingSets = fMainPage.getSelectedWorkingSets();
|
||||
//// if (workingSets.length > 0)
|
||||
//// getWorkbench().getWorkingSetManager().addToWorkingSets(fProjectProvider.getProject(), workingSets);
|
||||
//
|
||||
// return true;
|
||||
//// } catch (InvocationTargetException e) {
|
||||
//// // PDEPlugin.logException(e);
|
||||
//// } catch (InterruptedException e) {
|
||||
//// }
|
||||
//// return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.wizard.Wizard#canFinish()
|
||||
*/
|
||||
public boolean canFinish() {
|
||||
IWizardPage page = getContainer().getCurrentPage();
|
||||
return super.canFinish() && page != fMainPage;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package wesnoth_eclipse_plugin.wizards;
|
||||
|
||||
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
|
||||
|
||||
public class NewCampaignCreationPage extends WizardNewProjectCreationPage {
|
||||
|
||||
public NewCampaignCreationPage(String pageName) {
|
||||
super(pageName);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public void updateData() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
package wesnoth_eclipse_plugin.wizards;
|
||||
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.wizard.Wizard;
|
||||
import org.eclipse.ui.INewWizard;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.core.runtime.*;
|
||||
import org.eclipse.jface.operation.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.core.resources.*;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import java.io.*;
|
||||
import org.eclipse.ui.*;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
/**
|
||||
* This is a sample new wizard. Its role is to create a new file
|
||||
* resource in the provided container. If the container resource
|
||||
* (a folder or a project) is selected in the workspace
|
||||
* when the wizard is opened, it will accept it as the target
|
||||
* container. The wizard creates one file with the extension
|
||||
* "cfg". If a sample multi-page editor (also available
|
||||
* as a template) is registered for the same extension, it will
|
||||
* be able to open it.
|
||||
*/
|
||||
|
||||
public class ScenarioNewWizard extends Wizard implements INewWizard {
|
||||
private ScenarioNewWizardPage page;
|
||||
private ISelection selection;
|
||||
|
||||
/**
|
||||
* Constructor for ScenarioNewWizard.
|
||||
*/
|
||||
public ScenarioNewWizard() {
|
||||
super();
|
||||
setNeedsProgressMonitor(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding the page to the wizard.
|
||||
*/
|
||||
|
||||
public void addPages() {
|
||||
page = new ScenarioNewWizardPage(selection);
|
||||
addPage(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when 'Finish' button is pressed in
|
||||
* the wizard. We will create an operation and run it
|
||||
* using wizard as execution context.
|
||||
*/
|
||||
public boolean performFinish() {
|
||||
final String containerName = page.getContainerName();
|
||||
final String fileName = page.getFileName();
|
||||
IRunnableWithProgress op = new IRunnableWithProgress() {
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException {
|
||||
try {
|
||||
doFinish(containerName, fileName, monitor);
|
||||
} catch (CoreException e) {
|
||||
throw new InvocationTargetException(e);
|
||||
} finally {
|
||||
monitor.done();
|
||||
}
|
||||
}
|
||||
};
|
||||
try {
|
||||
getContainer().run(true, false, op);
|
||||
} catch (InterruptedException e) {
|
||||
return false;
|
||||
} catch (InvocationTargetException e) {
|
||||
Throwable realException = e.getTargetException();
|
||||
MessageDialog.openError(getShell(), "Error", realException.getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The worker method. It will find the container, create the
|
||||
* file if missing or just replace its contents, and open
|
||||
* the editor on the newly created file.
|
||||
*/
|
||||
|
||||
private void doFinish(
|
||||
String containerName,
|
||||
String fileName,
|
||||
IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
// create a sample file
|
||||
monitor.beginTask("Creating " + fileName, 2);
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
IResource resource = root.findMember(new Path(containerName));
|
||||
if (!resource.exists() || !(resource instanceof IContainer)) {
|
||||
throwCoreException("Container \"" + containerName + "\" does not exist.");
|
||||
}
|
||||
IContainer container = (IContainer) resource;
|
||||
final IFile file = container.getFile(new Path(fileName));
|
||||
try {
|
||||
InputStream stream = openContentStream();
|
||||
if (file.exists()) {
|
||||
file.setContents(stream, true, true, monitor);
|
||||
} else {
|
||||
file.create(stream, true, monitor);
|
||||
}
|
||||
stream.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
monitor.worked(1);
|
||||
monitor.setTaskName("Opening file for editing...");
|
||||
getShell().getDisplay().asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
IWorkbenchPage page =
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||
try {
|
||||
IDE.openEditor(page, file, true);
|
||||
} catch (PartInitException e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* We will initialize file contents with a sample text.
|
||||
*/
|
||||
|
||||
private InputStream openContentStream() {
|
||||
String contents =
|
||||
"This is the initial file contents for *.cfg file that should be word-sorted in the Preview page of the multi-page editor";
|
||||
return new ByteArrayInputStream(contents.getBytes());
|
||||
}
|
||||
|
||||
private void throwCoreException(String message) throws CoreException {
|
||||
IStatus status =
|
||||
new Status(IStatus.ERROR, "Wesnoth_Eclipse_Plugin", IStatus.OK, message, null);
|
||||
throw new CoreException(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* We will accept the selection in the workbench to see if
|
||||
* we can initialize from it.
|
||||
* @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
|
||||
*/
|
||||
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
||||
this.selection = selection;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,210 @@
|
|||
package wesnoth_eclipse_plugin.wizards;
|
||||
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
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.Label;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
|
||||
|
||||
/**
|
||||
* The "New" wizard page allows setting the container for the new file as well
|
||||
* as the file name. The page will only accept file name without the extension
|
||||
* OR with the extension that matches the expected one (cfg).
|
||||
*/
|
||||
|
||||
public class ScenarioNewWizardPage extends WizardPage {
|
||||
private Text containerText;
|
||||
|
||||
private Text fileText;
|
||||
private Text scenarioIdText;
|
||||
private Text scenarioNameText;
|
||||
|
||||
private ISelection selection;
|
||||
|
||||
/**
|
||||
* Constructor for SampleNewWizardPage.
|
||||
*
|
||||
* @param pageName
|
||||
*/
|
||||
public ScenarioNewWizardPage(ISelection selection) {
|
||||
super("wizardPage");
|
||||
setTitle("Scenario File");
|
||||
setDescription("This wizard creates a new file with *.cfg extension that can be opened by a multi-page editor.");
|
||||
this.selection = selection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IDialogPage#createControl(Composite)
|
||||
*/
|
||||
public void createControl(Composite parent) {
|
||||
Composite container = new Composite(parent, SWT.NULL);
|
||||
GridLayout layout = new GridLayout();
|
||||
container.setLayout(layout);
|
||||
layout.numColumns = 3;
|
||||
layout.verticalSpacing = 9;
|
||||
|
||||
Label label = new Label(container, SWT.NULL);
|
||||
label.setText("&Container:");
|
||||
containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
|
||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
containerText.setLayoutData(gd);
|
||||
containerText.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
dialogChanged();
|
||||
}
|
||||
});
|
||||
|
||||
Button button = new Button(container, SWT.PUSH);
|
||||
button.setText("Browse...");
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
handleBrowse();
|
||||
}
|
||||
});
|
||||
|
||||
label = new Label(container, SWT.NULL);
|
||||
label.setText("&File name:");
|
||||
fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
|
||||
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
fileText.setLayoutData(gd);
|
||||
fileText.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
dialogChanged();
|
||||
}
|
||||
});
|
||||
|
||||
label = new Label(container, SWT.NULL);
|
||||
label.setText("&Scenario Id:");
|
||||
scenarioIdText = new Text(container, SWT.BORDER | SWT.SINGLE);
|
||||
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
scenarioIdText.setLayoutData(gd);
|
||||
scenarioIdText.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
dialogChanged();
|
||||
}
|
||||
});
|
||||
|
||||
label = new Label(container, SWT.NULL);
|
||||
label.setText("&Scenario name:");
|
||||
scenarioNameText = new Text(container, SWT.BORDER | SWT.SINGLE);
|
||||
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
scenarioNameText.setLayoutData(gd);
|
||||
scenarioNameText.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
dialogChanged();
|
||||
}
|
||||
});
|
||||
|
||||
initialize();
|
||||
dialogChanged();
|
||||
setControl(container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the current workbench selection is a suitable container to use.
|
||||
*/
|
||||
|
||||
private void initialize() {
|
||||
if (selection != null && selection.isEmpty() == false
|
||||
&& selection instanceof IStructuredSelection) {
|
||||
IStructuredSelection ssel = (IStructuredSelection) selection;
|
||||
if (ssel.size() > 1)
|
||||
return;
|
||||
Object obj = ssel.getFirstElement();
|
||||
if (obj instanceof IResource) {
|
||||
IContainer container;
|
||||
if (obj instanceof IContainer)
|
||||
container = (IContainer) obj;
|
||||
else
|
||||
container = ((IResource) obj).getParent();
|
||||
containerText.setText(container.getFullPath().toString());
|
||||
}
|
||||
}
|
||||
fileText.setText("new_scenario.cfg");
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses the standard container selection dialog to choose the new value for
|
||||
* the container field.
|
||||
*/
|
||||
|
||||
private void handleBrowse() {
|
||||
ContainerSelectionDialog dialog = new ContainerSelectionDialog(
|
||||
getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
|
||||
"Select new file container");
|
||||
if (dialog.open() == ContainerSelectionDialog.OK) {
|
||||
Object[] result = dialog.getResult();
|
||||
if (result.length == 1) {
|
||||
containerText.setText(((Path) result[0]).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that both text fields are set.
|
||||
*/
|
||||
|
||||
private void dialogChanged() {
|
||||
IResource container = ResourcesPlugin.getWorkspace().getRoot()
|
||||
.findMember(new Path(getContainerName()));
|
||||
String fileName = getFileName();
|
||||
|
||||
if (getContainerName().length() == 0) {
|
||||
updateStatus("File container must be specified");
|
||||
return;
|
||||
}
|
||||
if (container == null
|
||||
|| (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
|
||||
updateStatus("File container must exist");
|
||||
return;
|
||||
}
|
||||
if (!container.isAccessible()) {
|
||||
updateStatus("Project must be writable");
|
||||
return;
|
||||
}
|
||||
if (fileName.length() == 0) {
|
||||
updateStatus("File name must be specified");
|
||||
return;
|
||||
}
|
||||
if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
|
||||
updateStatus("File name must be valid");
|
||||
return;
|
||||
}
|
||||
int dotLoc = fileName.lastIndexOf('.');
|
||||
if (dotLoc != -1) {
|
||||
String ext = fileName.substring(dotLoc + 1);
|
||||
if (ext.equalsIgnoreCase("cfg") == false) {
|
||||
updateStatus("File extension must be \"cfg\"");
|
||||
return;
|
||||
}
|
||||
}
|
||||
updateStatus(null);
|
||||
}
|
||||
|
||||
private void updateStatus(String message) {
|
||||
setErrorMessage(message);
|
||||
setPageComplete(message == null);
|
||||
}
|
||||
|
||||
public String getContainerName() {
|
||||
return containerText.getText();
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileText.getText();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package wesnoth_eclipse_plugin.wizards;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.wizard.WizardPage;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.wesnoth.wml.schema.SchemaTag;
|
||||
|
||||
/**
|
||||
* @author fabi
|
||||
*
|
||||
*/
|
||||
public class WmlTagWizardPage extends WizardPage {
|
||||
|
||||
/**
|
||||
* @param pageName
|
||||
*/
|
||||
public WmlTagWizardPage(SchemaTag tag, ImageDescriptor titleImage) {
|
||||
super(tag.getName(), tag.getName(), titleImage);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @param pageName
|
||||
// * @param title
|
||||
// * @param titleImage
|
||||
// */
|
||||
// public WmlTagWizardPage(String pageName, String title,
|
||||
// ImageDescriptor titleImage) {
|
||||
// super(pageName, title, titleImage);
|
||||
// // TODO Auto-generated constructor stub
|
||||
// }
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
@Override
|
||||
public void createControl(Composite parent) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
6
utils/eclipse_plugin/testToc.xml
Normal file
6
utils/eclipse_plugin/testToc.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?NLS TYPE="org.eclipse.help.toc"?>
|
||||
|
||||
<toc label="Test TOC" topic="html/toc.html">
|
||||
<link toc="toc.xml" />
|
||||
</toc>
|
9
utils/eclipse_plugin/toc.xml
Normal file
9
utils/eclipse_plugin/toc.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?NLS TYPE="org.eclipse.help.toc"?>
|
||||
|
||||
<toc label="Sample Table of Contents">
|
||||
<topic label="Main Topic" href="html/maintopic.html">
|
||||
<topic label="Sub Topic" href="html/subtopic.html"/>
|
||||
</topic>
|
||||
<topic label="Main Topic 2"/>
|
||||
</toc>
|
Loading…
Add table
Reference in a new issue