[Esbox-commits] r397 - in trunk/org.indt.esbox.core: . META-INF schema src/org/indt/esbox/core src/org/indt/esbox/core/tool
raul at garage.maemo.org
raul at garage.maemo.org
Tue Jan 29 14:38:56 EET 2008
Author: raul
Date: 2008-01-29 14:38:52 +0200 (Tue, 29 Jan 2008)
New Revision: 397
Added:
trunk/org.indt.esbox.core/schema/tool.exsd
trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/
trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/ESboxToolEngine.java
trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/ITool.java
trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/IToolParam.java
trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/IToolProvider.java
trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/IToolRunner.java
trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/Tool.java
trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/ToolParam.java
Modified:
trunk/org.indt.esbox.core/META-INF/MANIFEST.MF
trunk/org.indt.esbox.core/plugin.xml
Log:
new tool extension point.
Modified: trunk/org.indt.esbox.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.indt.esbox.core/META-INF/MANIFEST.MF 2008-01-29 12:33:41 UTC (rev 396)
+++ trunk/org.indt.esbox.core/META-INF/MANIFEST.MF 2008-01-29 12:38:52 UTC (rev 397)
@@ -18,4 +18,5 @@
org.indt.esbox.core.maemosdk,
org.indt.esbox.core.platform,
org.indt.esbox.core.scratchbox,
- org.indt.esbox.core.templateengine
+ org.indt.esbox.core.templateengine,
+ org.indt.esbox.core.tool
Modified: trunk/org.indt.esbox.core/plugin.xml
===================================================================
--- trunk/org.indt.esbox.core/plugin.xml 2008-01-29 12:33:41 UTC (rev 396)
+++ trunk/org.indt.esbox.core/plugin.xml 2008-01-29 12:38:52 UTC (rev 397)
@@ -5,6 +5,7 @@
<extension-point id="maemo_sdk" name="Maemo SDK" schema="schema/maemo_sdk.exsd"/>
<extension-point id="esbox_templates" name="ESbox templates" schema="schema/esbox_templates.exsd"/>
<extension-point id="esbox_templateAssociations" name="Esbox Template Associations Extension Point" schema="schema/esbox_templatesAssociations.exsd"/>
+ <extension-point id="tool" name="Tool" schema="schema/tool.exsd"/>
<extension
id="ESboxNature"
name="ESbox Project Nature"
Added: trunk/org.indt.esbox.core/schema/tool.exsd
===================================================================
--- trunk/org.indt.esbox.core/schema/tool.exsd (rev 0)
+++ trunk/org.indt.esbox.core/schema/tool.exsd 2008-01-29 12:38:52 UTC (rev 397)
@@ -0,0 +1,154 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.indt.esbox.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.indt.esbox.core" id="tool" name="Tool"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="tool" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="provider">
+ <complexType>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.indt.esbox.core.tool.IToolProvider"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="param">
+ <complexType>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="description" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="value" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="tool">
+ <complexType>
+ <sequence>
+ <element ref="provider"/>
+ <element ref="param" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
Added: trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/ESboxToolEngine.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/ESboxToolEngine.java (rev 0)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/ESboxToolEngine.java 2008-01-29 12:38:52 UTC (rev 397)
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+package org.indt.esbox.core.tool;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.Platform;
+import org.indt.esbox.core.CoreActivator;
+
+/**
+ *
+ */
+public class ESboxToolEngine {
+
+ public static String TOOLS_EXTENSION_ID = CoreActivator.PLUGIN_ID + ".tool";
+
+ private static ESboxToolEngine singleton = null;
+
+ private List<ITool> tools;
+
+ /**
+ *
+ */
+ private ESboxToolEngine() {
+ initTools();
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static synchronized ESboxToolEngine getInstance() {
+ if (singleton == null)
+ singleton = new ESboxToolEngine();
+ return singleton;
+ }
+
+ /**
+ *
+ */
+ private void initTools() {
+ IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(TOOLS_EXTENSION_ID).getExtensions();
+ String pluginId = null;
+ String toolName = null;
+ String id = null;
+
+ for(int i=0; i<extensions.length; i++) {
+ ITool tool = null;
+
+ IExtension extension = extensions[i];
+ IConfigurationElement[] configElements = extension.getConfigurationElements();
+ pluginId = extension.getNamespaceIdentifier(); // Plugin-id of the extending plugin.
+ for(int j=0; j<configElements.length; j++) {
+ IConfigurationElement config = configElements[j];
+ toolName = config.getAttribute("name");
+ id = config.getAttribute("id");
+
+ IConfigurationElement[] provider = config.getChildren("provider");
+ IConfigurationElement[] params = config.getChildren("param");
+
+ String className = provider[0].getAttribute("class");
+ IToolProvider toolProvider = null;
+ try {
+ toolProvider = (IToolProvider) Class.forName(className).newInstance();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+
+ tool = new Tool(toolName,id,toolProvider);
+
+ for (int k=0; k < params.length; k++) {
+ String paramName, description, value;
+ paramName = params[k].getAttribute("name");
+ description = params[k].getAttribute("description");
+ value = params[k].getAttribute("value");
+ IToolParam param = new ToolParam(paramName, description, value);
+ tool.addParam(param);
+ }
+ }
+
+ tools.add(tool);
+ }
+ }
+
+ /**
+ *
+ * @return
+ */
+ public List<ITool> getTools() {
+ return tools;
+ }
+
+ /**
+ *
+ * @param name
+ * @return
+ */
+ public ITool[] getTool(String name) {
+ List<ITool> result = new ArrayList<ITool>();
+
+ for (ITool tool : tools) {
+ if (name.equals(tool.getName()))
+ result.add(tool);
+ }
+
+ return result.toArray(new ITool[0]);
+ }
+
+
+}
+
Added: trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/ITool.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/ITool.java (rev 0)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/ITool.java 2008-01-29 12:38:52 UTC (rev 397)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+package org.indt.esbox.core.tool;
+
+import java.util.List;
+
+/**
+ *
+ */
+public interface ITool {
+
+ public List<IToolParam> getParams();
+
+ public boolean addParam(IToolParam param);
+
+ public IToolProvider getProvider();
+
+ public String getName();
+
+ public String getId();
+
+}
Added: trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/IToolParam.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/IToolParam.java (rev 0)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/IToolParam.java 2008-01-29 12:38:52 UTC (rev 397)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+package org.indt.esbox.core.tool;
+
+/**
+ *
+ */
+public interface IToolParam {
+
+ public String getName();
+
+ public String getDescription();
+
+ public String getValue();
+
+}
Added: trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/IToolProvider.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/IToolProvider.java (rev 0)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/IToolProvider.java 2008-01-29 12:38:52 UTC (rev 397)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+package org.indt.esbox.core.tool;
+
+
+/**
+ *
+ */
+public interface IToolProvider {
+
+ public IToolRunner getRunner();
+
+ public boolean isInstalled();
+
+}
Added: trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/IToolRunner.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/IToolRunner.java (rev 0)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/IToolRunner.java 2008-01-29 12:38:52 UTC (rev 397)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+package org.indt.esbox.core.tool;
+
+import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
+
+/**
+ *
+ */
+public interface IToolRunner {
+
+ public boolean runTool(String[] args);
+
+ public ScratchboxCommandLauncher getCommandLauncher();
+
+}
Added: trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/Tool.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/Tool.java (rev 0)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/Tool.java 2008-01-29 12:38:52 UTC (rev 397)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+package org.indt.esbox.core.tool;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author raul
+ *
+ */
+public class Tool implements ITool {
+
+ private String name;
+
+ private String id;
+
+ private IToolProvider provider;
+
+ private List<IToolParam> params;
+
+ public Tool(String name, String id, IToolProvider provider) {
+ this.name = name;
+ this.id = id;
+ this.provider = provider;
+ }
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.ITool#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.ITool#getParams()
+ */
+ public List<IToolParam> getParams() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.ITool#getProvider()
+ */
+ public IToolProvider getProvider() {
+ return provider;
+ }
+
+ public boolean addParam(IToolParam param) {
+ if (params == null) {
+ params = new ArrayList<IToolParam>();
+ }
+ return params.add(param);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.indt.esbox.core.tool.ITool#getId()
+ */
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( !this.getClass().equals(obj.getClass()) )
+ return false;
+ ITool tool = (ITool)obj;
+ return name.equals(tool.getName()) && id.equals(tool.getId());
+ }
+
+}
Added: trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/ToolParam.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/ToolParam.java (rev 0)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/tool/ToolParam.java 2008-01-29 12:38:52 UTC (rev 397)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+package org.indt.esbox.core.tool;
+
+
+/**
+ * @author raul
+ *
+ */
+public class ToolParam implements IToolParam {
+
+ private String description;
+
+ private String name;
+
+ private String value;
+
+ public ToolParam(String name, String description, String value) {
+ this.name = name;
+ this.description = description;
+ this.value = value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.IToolParam#getDescription()
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.IToolParam#getName()
+ */
+ public String getName() {
+ // TODO Auto-generated method stub
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.IToolParam#getValue()
+ */
+ public String getValue() {
+ // TODO Auto-generated method stub
+ return value;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( !this.getClass().equals(obj.getClass()) )
+ return false;
+ IToolParam param = (IToolParam)obj;
+ return name.equals(param.getName());
+ }
+
+}
More information about the Esbox-commits
mailing list