eclipse plugin: cleanup and add missing @override

This commit is contained in:
Timotei Dolean 2010-07-08 22:07:41 +00:00
parent 2eeee402bc
commit 174d5e4dfc
8 changed files with 252 additions and 133 deletions

View file

@ -3,11 +3,12 @@ package org.wesnoth.wml.schema.impl;
import org.wesnoth.wml.schema.SchemaAttribute;
import org.wesnoth.wml.schema.SchemaAttributeChild;
public class SchemaAttributeChildImpl implements SchemaAttributeChild {
public class SchemaAttributeChildImpl implements SchemaAttributeChild
{
SchemaAttribute child;
String name;
boolean required;
SchemaAttribute child;
String name;
boolean required;
public SchemaAttributeChildImpl(String name, SchemaAttribute child, boolean required) {
super();
@ -16,38 +17,36 @@ public class SchemaAttributeChildImpl implements SchemaAttributeChild {
this.required = required;
}
public SchemaAttribute getChild() {
@Override
public SchemaAttribute getChild()
{
return this.child;
}
public void setChild(SchemaAttribute child) {
public void setChild(SchemaAttribute child)
{
this.child = child;
}
public boolean isRequired() {
@Override
public boolean isRequired()
{
return this.required;
}
public void setRequired(boolean required) {
public void setRequired(boolean required)
{
this.required = required;
}
public String getName() {
@Override
public String getName()
{
return this.name;
}
public void setName(String name) {
public void setName(String name)
{
this.name = name;
}

View file

@ -2,42 +2,53 @@ package org.wesnoth.wml.schema.impl;
import org.wesnoth.wml.schema.SchemaAttribute;
public class SchemaAttributeImpl implements SchemaAttribute {
public class SchemaAttributeImpl implements SchemaAttribute
{
private String name;
private String description;
private String valueExpression;
private String name;
private String description;
private String valueExpression;
public SchemaAttributeImpl(String name) {
this.name = name;
}
public String getValueExpression() {
@Override
public String getValueExpression()
{
return this.valueExpression;
}
public void setValueExpression(String valueExpression) {
public void setValueExpression(String valueExpression)
{
this.valueExpression = valueExpression;
}
public String getName() {
@Override
public String getName()
{
return this.name;
}
public void setName(String name) {
public void setName(String name)
{
this.name = name;
}
public String getDescription() {
@Override
public String getDescription()
{
return this.description;
}
public void setDescription(String description) {
public void setDescription(String description)
{
this.description = description;
}
@Override
public boolean isTag() {
public boolean isTag()
{
return false;
}

View file

@ -3,44 +3,54 @@ 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;
public class SchemaTagChildImpl implements SchemaTagChild
{
SchemaTag child;
String name;
boolean repeated;
boolean required;
@Override
public SchemaTag getChild() {
public SchemaTag getChild()
{
return this.child;
}
@Override
public boolean isRepeated() {
public boolean isRepeated()
{
return this.repeated;
}
@Override
public boolean isRequired() {
public boolean isRequired()
{
return this.required;
}
public void setChild(SchemaTag child) {
public void setChild(SchemaTag child)
{
this.child = child;
}
public void setRepeated(boolean repeated) {
public void setRepeated(boolean repeated)
{
this.repeated = repeated;
}
public void setRequired(boolean required) {
public void setRequired(boolean required)
{
this.required = required;
}
public String getName() {
@Override
public String getName()
{
return this.name;
}
public void setName(String name) {
public void setName(String name)
{
this.name = name;
}

View file

@ -1,53 +1,76 @@
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;
import java.util.ArrayList;
import java.util.List;
public List<SchemaAttributeChild> getAttributes() {
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;
@Override
public List<SchemaAttributeChild> getAttributes()
{
return this.attributes;
}
public void setAttributes(List<SchemaAttributeChild> attributes) {
public void setAttributes(List<SchemaAttributeChild> attributes)
{
this.attributes = attributes;
}
public List<SchemaTagChild> getTags() {
@Override
public List<SchemaTagChild> getTags()
{
return this.tags;
}
public void setTags(List<SchemaTagChild> tags) {
public void setTags(List<SchemaTagChild> tags)
{
this.tags = tags;
}
public String getName() {
@Override
public String getName()
{
return this.name;
}
public void setName(String name) {
public void setName(String name)
{
this.name = name;
}
public String getDescription() {
@Override
public String getDescription()
{
return this.description;
}
public void setDescription(String description) {
public void setDescription(String description)
{
this.description = description;
}
@Override
public boolean isTag() {
public boolean isTag()
{
return true;
}
public void addAttribute(SchemaAttributeChild attribute) {
public void addAttribute(SchemaAttributeChild attribute)
{
this.attributes.add(attribute);
}
public void addTag(SchemaTagChild tag) {
public void addTag(SchemaTagChild tag)
{
this.tags.add(tag);
}

View file

@ -6,21 +6,25 @@ import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
public class WesnothProjectNature implements IProjectNature {
public class WesnothProjectNature implements IProjectNature
{
/**
* ID of this project nature
*/
public static final String NATURE_ID = "Wesnoth_Eclipse_Plugin.sampleNature";
public static final String NATURE_ID = "Wesnoth_Eclipse_Plugin.sampleNature";
private IProject project;
private IProject project;
public void configure() throws CoreException {
@Override
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(WesnothProjectBuilder.BUILDER_ID)) {
for (int i = 0; i < commands.length; ++i)
{
if (commands[i].getBuilderName().equals(WesnothProjectBuilder.BUILDER_ID))
{
return;
}
}
@ -34,11 +38,15 @@ public class WesnothProjectNature implements IProjectNature {
project.setDescription(desc, null);
}
public void deconfigure() throws CoreException {
@Override
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(WesnothProjectBuilder.BUILDER_ID)) {
for (int i = 0; i < commands.length; ++i)
{
if (commands[i].getBuilderName().equals(WesnothProjectBuilder.BUILDER_ID))
{
ICommand[] newCommands = new ICommand[commands.length - 1];
System.arraycopy(commands, 0, newCommands, 0, i);
System.arraycopy(commands, i + 1, newCommands, i,
@ -50,11 +58,15 @@ public class WesnothProjectNature implements IProjectNature {
}
}
public IProject getProject() {
@Override
public IProject getProject()
{
return project;
}
public void setProject(IProject project) {
@Override
public void setProject(IProject project)
{
this.project = project;
}

View file

@ -29,6 +29,6 @@ public class ImportMapHandler extends AbstractHandler
"You need to select a \"maps\" folder before importing anything");
}
return (selectedFolder != null && selectedFolder.getName().equals("maps"));
return (selectedFolder.getName().equals("maps"));
}
}

View file

@ -27,10 +27,11 @@ import wesnoth_eclipse_plugin.Activator;
* be accessed directly via the preference store.
*/
public class WesnothEditorPreferences
extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {
extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage
{
private DirectoryFieldEditor wmlToolsField;
private DirectoryFieldEditor wmlToolsField;
public WesnothEditorPreferences() {
super(GRID);
@ -45,20 +46,23 @@ public class WesnothEditorPreferences
* restore itself.
*/
@Override
public void createFieldEditors() {
public void createFieldEditors()
{
addField(new FileFieldEditor(PreferenceConstants.P_WESNOTH_EXEC_PATH,
"Wesnoth executable path:", getFieldEditorParent()));
addField(new DirectoryFieldEditor(PreferenceConstants.P_WESNOTH_WORKING_DIR,
addField(new DirectoryFieldEditor(PreferenceConstants.P_WESNOTH_WORKING_DIR,
"Working directory:", getFieldEditorParent()));
addField(new DirectoryFieldEditor(PreferenceConstants.P_WESNOTH_USER_DIR,
addField(new DirectoryFieldEditor(PreferenceConstants.P_WESNOTH_USER_DIR,
"User data directory:", getFieldEditorParent()));
wmlToolsField = new DirectoryFieldEditor(PreferenceConstants.P_WESNOTH_WMLTOOLS_DIR,
wmlToolsField = new DirectoryFieldEditor(PreferenceConstants.P_WESNOTH_WMLTOOLS_DIR,
"WML* tools directory:", getFieldEditorParent());
addField(wmlToolsField);
}
public void init(IWorkbench workbench) {
@Override
public void init(IWorkbench workbench)
{
}
@Override

View file

@ -1,16 +1,31 @@
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.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.*;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
/**
* This sample class demonstrates how to plug-in a new
@ -30,17 +45,18 @@ import org.eclipse.swt.SWT;
* <p>
*/
public class SampleView extends ViewPart {
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";
public static final String ID = "wesnoth_eclipse_plugin.views.SampleView";
private TableViewer viewer;
private Action action1;
private Action action2;
private Action doubleClickAction;
private TableViewer viewer;
private Action action1;
private Action action2;
private Action doubleClickAction;
/*
* The content provider class is responsible for
@ -51,29 +67,50 @@ public class SampleView extends ViewPart {
* 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) {
class ViewContentProvider implements IStructuredContentProvider
{
@Override
public void inputChanged(Viewer v, Object oldInput, Object newInput)
{
}
public void dispose() {
@Override
public void dispose()
{
}
public Object[] getElements(Object parent) {
@Override
public Object[] getElements(Object parent)
{
return new String[] { "One", "Two", "Three" };
}
}
class ViewLabelProvider extends LabelProvider implements ITableLabelProvider {
public String getColumnText(Object obj, int index) {
class ViewLabelProvider extends LabelProvider implements ITableLabelProvider
{
@Override
public String getColumnText(Object obj, int index)
{
return getText(obj);
}
public Image getColumnImage(Object obj, int index) {
@Override
public Image getColumnImage(Object obj, int index)
{
return getImage(obj);
}
public Image getImage(Object obj) {
@Override
public Image getImage(Object obj)
{
return PlatformUI.getWorkbench().
getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
}
}
class NameSorter extends ViewerSorter {
class NameSorter extends ViewerSorter
{
}
/**
@ -86,7 +123,9 @@ public class SampleView extends ViewPart {
* This is a callback that will allow us
* to create the viewer and initialize it.
*/
public void createPartControl(Composite parent) {
@Override
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());
@ -101,11 +140,14 @@ public class SampleView extends ViewPart {
contributeToActionBars();
}
private void hookContextMenu() {
private void hookContextMenu()
{
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
@Override
public void menuAboutToShow(IMenuManager manager)
{
SampleView.this.fillContextMenu(manager);
}
});
@ -114,43 +156,52 @@ public class SampleView extends ViewPart {
getSite().registerContextMenu(menuMgr, viewer);
}
private void contributeToActionBars() {
private void contributeToActionBars()
{
IActionBars bars = getViewSite().getActionBars();
fillLocalPullDown(bars.getMenuManager());
fillLocalToolBar(bars.getToolBarManager());
}
private void fillLocalPullDown(IMenuManager manager) {
private void fillLocalPullDown(IMenuManager manager)
{
manager.add(action1);
manager.add(new Separator());
manager.add(action2);
}
private void fillContextMenu(IMenuManager manager) {
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) {
private void fillLocalToolBar(IToolBarManager manager)
{
manager.add(action1);
manager.add(action2);
}
private void makeActions() {
private void makeActions()
{
action1 = new Action() {
public void run() {
@Override
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));
getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
action2 = new Action() {
public void run() {
@Override
public void run()
{
showMessage("Action 2 executed");
}
};
@ -159,32 +210,41 @@ public class SampleView extends ViewPart {
action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
doubleClickAction = new Action() {
public void run() {
@Override
public void run()
{
ISelection selection = viewer.getSelection();
Object obj = ((IStructuredSelection)selection).getFirstElement();
showMessage("Double-click detected on "+obj.toString());
Object obj = ((IStructuredSelection) selection).getFirstElement();
showMessage("Double-click detected on " + obj.toString());
}
};
}
private void hookDoubleClickAction() {
private void hookDoubleClickAction()
{
viewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
@Override
public void doubleClick(DoubleClickEvent event)
{
doubleClickAction.run();
}
});
}
private void showMessage(String message) {
private void showMessage(String message)
{
MessageDialog.openInformation(
viewer.getControl().getShell(),
"Sample View",
message);
viewer.getControl().getShell(),
"Sample View",
message);
}
/**
* Passing the focus request to the viewer's control.
*/
public void setFocus() {
@Override
public void setFocus()
{
viewer.getControl().setFocus();
}
}