Skip to content

Commit

Permalink
Merge pull request #22 from nlepine/master
Browse files Browse the repository at this point in the history
add UI actions : initialize genconf and generate documentation
  • Loading branch information
RomainGuider authored Jul 18, 2016
2 parents 3e6b72a + ac99fc6 commit 668f453
Show file tree
Hide file tree
Showing 11 changed files with 698 additions and 287 deletions.
3 changes: 2 additions & 1 deletion plugins/org.obeonetwork.m2doc.genconf/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ Export-Package: org.obeonetwork.m2doc.genconf,
org.obeonetwork.m2doc.genconf.impl,
org.obeonetwork.m2doc.genconf.util
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.ecore;visibility:=reexport
org.eclipse.emf.ecore;visibility:=reexport,
org.obeonetwork.m2doc;bundle-version="0.7.1"
Bundle-ActivationPolicy: lazy
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*******************************************************************************
* Copyright (c) 2016 Obeo.
* 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:
* Obeo - initial API and implementation
*
*******************************************************************************/
package org.obeonetwork.m2doc.genconf.util;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.obeonetwork.m2doc.genconf.Definition;
import org.obeonetwork.m2doc.genconf.GenconfFactory;
import org.obeonetwork.m2doc.genconf.Generation;
import org.obeonetwork.m2doc.properties.M2DocCustomProperties;
import org.obeonetwork.m2doc.properties.TemplateInfo;

/**
* Services for genconf metamodels.
*
* @author <a href="mailto:[email protected]">Nathalie Lepine</a>
*/
public class ConfigurationServices {

/**
* @param generation
* Generation
* @param templateInfo
* TemplateInfo
* @return generation eObject with definitions template information.
*/
public Generation addProperties(Generation generation, TemplateInfo templateInfo) {
for (String key : templateInfo.getVariables().keySet()) {
String value = templateInfo.getVariables().get(key);
Definition definition = null;
if (M2DocCustomProperties.INT_TYPE.equals(value) || M2DocCustomProperties.REAL_TYPE.equals(value)
|| M2DocCustomProperties.STRING_TYPE.equals(value)) {
definition = GenconfFactory.eINSTANCE.createStringDefinition();
} else {
definition = GenconfFactory.eINSTANCE.createModelDefinition();
}
if (definition != null) {
definition.setKey(key);

}
generation.getDefinitions().add(definition);
}
return generation;
}

/**
* Create generation eObject.
*
* @param name
* @param templateFileName
* @return Generation
*/
public Generation createInitialModel(String name, String templateFileName) {
Generation generation = GenconfFactory.eINSTANCE.createGeneration();
generation.setName(name);
generation.setTemplateFileName(templateFileName);
return generation;
}

/**
* @param uri
* URI
* @return generation element from URI.
*/
public static Generation getGeneration(URI uri) {
ResourceSet rs = new ResourceSetImpl();
Resource modelResource = rs.getResource(uri, true);
if (modelResource != null && !modelResource.getContents().isEmpty()) {
EObject root = modelResource.getContents().get(0);
if (root instanceof Generation) {
return (Generation) root;
}
}
return null;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 84 additions & 21 deletions plugins/org.obeonetwork.m2doc.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,91 @@

<plugin>
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.emf.ecore.EObject"
id="org.obeonetwork.m2doc.ui.genaction">
<menu
icon="icons/m2doc.gif"
id="org.obeonetwork.m2doc.ui.menu1"
label="M2Doc"
path="additions">
<separator
name="group1">
</separator>
</menu>
<action
class="org.obeonetwork.m2doc.ui.popup.actions.GenerateDocumentation"
enablesFor="1"
point="org.eclipse.ui.commands">
<command
name="Generate Documentation Command"
id="org.obeonetwork.m2doc.ui.generateDocumentation">
</command>
<command
name="Initialize Configurations Command"
id="org.obeonetwork.m2doc.ui.initializeConfigurations">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="org.obeonetwork.m2doc.ui.generateDocumentation"
class="org.obeonetwork.m2doc.ui.command.GenerateHandler">
</handler>
<handler
commandId="org.obeonetwork.m2doc.ui.initializeConfigurations"
class="org.obeonetwork.m2doc.ui.command.InitializeConfigurationsHandler">
</handler>
</extension>

<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<command
commandId="org.obeonetwork.m2doc.ui.generateDocumentation"
icon="icons/m2doc.gif"
id="org.obeonetwork.m2doc.ui.genAction"
label="Generate Doc"
menubarPath="org.obeonetwork.m2doc.ui.menu1/group1">
</action>
</objectContribution>
label="Generate Documentation"
style="push">
<visibleWhen
checkEnabled="false">
<with
variable="selection">
<iterate
ifEmpty="false"
operator="or">
<test
forcePluginActivation="true"
property="org.obeonetwork.m2doc.ui.testGeneration">
</test>
</iterate>
</with>
</visibleWhen>
</command>
<command
commandId="org.obeonetwork.m2doc.ui.initializeConfigurations"
icon="icons/m2doc_init.png"
label="Initialize Documentation Configurations"
style="push">
<visibleWhen
checkEnabled="false">
<with
variable="selection">
<iterate
ifEmpty="false"
operator="or">
<test
forcePluginActivation="true"
property="org.obeonetwork.m2doc.ui.testTemplate">
</test>
</iterate>
</with>
</visibleWhen>
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
class="org.obeonetwork.m2doc.ui.propertyTester.GenerationPropertyTester"
id="org.obeonetwork.m2doc.ui.testGeneration"
namespace="org.obeonetwork.m2doc.ui"
properties="testGeneration"
type="java.lang.Object">
</propertyTester>
<propertyTester
class="org.obeonetwork.m2doc.ui.propertyTester.TemplatePropertyTester"
id="org.obeonetwork.m2doc.ui.testTemplate"
namespace="org.obeonetwork.m2doc.ui"
properties="testTemplate"
type="java.lang.Object">
</propertyTester>
</extension>

</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class Activator extends AbstractUIPlugin {
* The plug-in ID.
*/
public static final String PLUGIN_ID = "org.obeonetwork.m2doc.ui"; //$NON-NLS-1$
public static final String GENCONF_EXTENSION_FILE = "genconf";
public static final String DOCX_EXTENSION_FILE = "docx";

/**
* The shared instance.
*/
Expand Down
Loading

0 comments on commit 668f453

Please sign in to comment.