Skip to content
Snippets Groups Projects
Commit 27dcdd4a authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

Added a TeeTime nature

parent 4fa2ed3b
Branches
No related tags found
No related merge requests found
Showing
with 184 additions and 1 deletion
...@@ -375,6 +375,7 @@ ...@@ -375,6 +375,7 @@
</command> </command>
</menuContribution> </menuContribution>
</extension> </extension>
<extension point="org.eclipse.ui.preferencePages"> <extension point="org.eclipse.ui.preferencePages">
<page <page
category="teetime.configuration.dsl.Config" category="teetime.configuration.dsl.Config"
...@@ -418,10 +419,53 @@ ...@@ -418,10 +419,53 @@
label="Show Configuration" label="Show Configuration"
tooltip="Shows the configuration as image"> tooltip="Shows the configuration as image">
</command> </command>
<visibleWhen
checkEnabled="false">
<with variable="selection">
<iterate operator="or" ifEmpty="false">
<test property="org.eclipse.core.resources.projectNature"
value="teetime.configuration.dsl.teetimeNature" />
</iterate>
</with>
</visibleWhen>
</menu> </menu>
</menuContribution> </menuContribution>
</extension> </extension>
<extension point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.ui.projectConfigure">
<command commandId="teetime.configuration.dsl.addNature"
label="Add TeeTime Nature">
<visibleWhen
checkEnabled="false">
<with variable="selection">
<iterate operator="and" ifEmpty="true">
<not>
<test property="org.eclipse.core.resources.projectNature"
value="teetime.configuration.dsl.teetimeNature" />
</not>
</iterate>
</with>
</visibleWhen>
</command>
</menuContribution>
<menuContribution
locationURI="popup:org.eclipse.ui.projectConfigure">
<command commandId="teetime.configuration.dsl.addNature"
label="Remove TeeTime Nature">
<visibleWhen
checkEnabled="false">
<with variable="selection">
<iterate operator="or" ifEmpty="false">
<test property="org.eclipse.core.resources.projectNature"
value="teetime.configuration.dsl.teetimeNature" />
</iterate>
</with>
</visibleWhen>
</command>
</menuContribution>
</extension>
<extension <extension
point="org.eclipse.core.contenttype.contentTypes"> point="org.eclipse.core.contenttype.contentTypes">
<content-type <content-type
...@@ -483,4 +527,12 @@ ...@@ -483,4 +527,12 @@
relative="left"/> relative="left"/>
</perspectiveExtension> </perspectiveExtension>
</extension> </extension>
<extension
point="org.eclipse.ui.ide.projectNatureImages">
<image
icon="icons/sign-8x8.png"
id="teetime.configuration.dsl.ui.natureImage"
natureId="teetime.configuration.dsl.teetimeNature">
</image>
</extension>
</plugin> </plugin>
...@@ -18,7 +18,8 @@ Require-Bundle: org.eclipse.xtext, ...@@ -18,7 +18,8 @@ Require-Bundle: org.eclipse.xtext,
org.eclipse.core.resources;bundle-version="3.10.1", org.eclipse.core.resources;bundle-version="3.10.1",
org.eclipse.core.contenttype;bundle-version="3.5.0", org.eclipse.core.contenttype;bundle-version="3.5.0",
org.eclipse.debug.core, org.eclipse.debug.core,
org.eclipse.debug.ui org.eclipse.debug.ui,
org.apache.commons.lang;bundle-version="2.6.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: teetime.configuration.dsl, Export-Package: teetime.configuration.dsl,
teetime.configuration.dsl.scoping, teetime.configuration.dsl.scoping,
......
...@@ -7,6 +7,24 @@ ...@@ -7,6 +7,24 @@
class = "teetime.configuration.dsl.config.ConfigPackage" class = "teetime.configuration.dsl.config.ConfigPackage"
genModel = "model/generated/Config.genmodel" /> genModel = "model/generated/Config.genmodel" />
</extension> </extension>
<extension
id="teetimeNature"
name="TeeTime Nature"
point="org.eclipse.core.resources.natures">
<runtime>
<run
class="teetime.configuration.dsl.nature.ProjectNature">
</run>
</runtime>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="teetime.configuration.dsl.nature.AddNature"
id="teetime.configuration.dsl.addNature"
name="Add TeeTime Nature">
</command>
</extension>
<!-- <extension <!-- <extension
point="org.eclipse.debug.core.launchConfigurationTypes"> point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType <launchConfigurationType
......
package teetime.configuration.dsl.nature;
import org.apache.commons.lang.ArrayUtils;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.commands.IHandlerListener;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
public class AddNature implements IHandler {
@Override
public void addHandlerListener(IHandlerListener handlerListener) {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection sel = HandlerUtil.getCurrentSelection(event);
if (sel instanceof IStructuredSelection) {
Object selected = ((IStructuredSelection) sel).getFirstElement();
if (selected instanceof IProject) {
IProject project = (IProject) selected;
try {
IProjectDescription description = project.getDescription();
String[] natures = description.getNatureIds();
if (project.hasNature("teetime.configuration.dsl.teetimeNature")) {
String[] newNatures = (String[]) ArrayUtils.removeElement(natures, "teetime.configuration.dsl.teetimeNature");
description.setNatureIds(newNatures);
} else {
String[] newNatures = new String[natures.length + 1];
System.arraycopy(natures, 0, newNatures, 0, natures.length);
newNatures[natures.length] = "teetime.configuration.dsl.teetimeNature";
description.setNatureIds(newNatures);
}
project.setDescription(description, null);
} catch (CoreException e) {
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Internal error",
"Could not add TeeTime nature to " + project.getName() + ".");
}
}
}
return null;
}
@Override
public boolean isEnabled() {
// TODO Auto-generated method stub
return true;
}
@Override
public boolean isHandled() {
// TODO Auto-generated method stub
return true;
}
@Override
public void removeHandlerListener(IHandlerListener handlerListener) {
// TODO Auto-generated method stub
}
}
package teetime.configuration.dsl.nature;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
public class ProjectNature implements IProjectNature {
private IProject project;
@Override
public void configure() throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void deconfigure() throws CoreException {
// TODO Auto-generated method stub
}
@Override
public IProject getProject() {
return project;
}
@Override
public void setProject(IProject project) {
this.project = project;
}
}
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment