Commit 5325c8a4 authored by Dominique Marcadet's avatar Dominique Marcadet

Initial import in new git repositories

parent b8efd43f
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>fr.centralesupelec.edf.riseclipse.editor</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.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: fr.centralesupelec.edf.riseclipse.editor;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: fr.centralesupelec.edf.riseclipse.ui.RiseClipseEditorPlugin$Implementation
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: fr.centralesupelec.edf.riseclipse.ui
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources;visibility:=reexport,
org.eclipse.emf.edit.ui;visibility:=reexport,
org.eclipse.ui.ide;visibility:=reexport,
org.eclipse.ui.console,
fr.centralesupelec.edf.riseclipse.main,
org.eclipse.emf.ecore.xmi
Bundle-ActivationPolicy: lazy
#
# Copyright (c) 2017 CentraleSupélec & EDF.
# 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
#
# This file is part of the RiseClipse tool
#
# Contributors:
# Computer Science Department, CentraleSupélec : initial implementation
# Contacts:
# Dominique.Marcadet@centralesupelec.fr
#
bin.includes = .,\
icons/,\
META-INF/,\
plugin.xml,\
plugin.properties
jars.compile.order = .
source.. = src/
output.. = bin
#
# Copyright (c) 2017 CentraleSupélec & EDF.
# 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
#
# This file is part of the RiseClipse tool
#
# Contributors:
# Computer Science Department, CentraleSupélec : initial implementation
# Contacts:
# Dominique.Marcadet@centralesupelec.fr
#
pluginName = RiseClipse Editor
providerName = CentraleSupélec & EDF
_UI_RiseClipseEditor_menu = &RiseClipse Editor
_UI_CreateChild_menu_item = &New Child
_UI_CreateSibling_menu_item = N&ew Sibling
_UI_ShowPropertiesView_menu_item = Show &Properties View
_UI_RefreshViewer_menu_item = &Refresh
_UI_SelectionPage_label = Selection
_UI_ParentPage_label = Parent
_UI_ListPage_label = List
_UI_TreePage_label = Tree
_UI_TablePage_label = Table
_UI_TreeWithColumnsPage_label = Tree with Columns
_UI_ObjectColumn_label = Object
_UI_SelfColumn_label = Self
_UI_NoObjectSelected = Selected Nothing
_UI_SingleObjectSelected = Selected Object: {0}
_UI_MultiObjectSelected = Selected {0} Objects
_UI_OpenEditorError_label = Open Editor
_UI_CreateModelError_message = Problems encountered in file "{0}"
_UI_RiseClipseEditor_label = RiseClipse Model Editor
_UI_RiseClipseEditorFilenameDefaultBase = model
_UI_RiseClipseEditorFilenameExtensions = xml
_WARN_FilenameExtension = The file name must end in ''.{0}''
_WARN_FilenameExtensions = The file name must have one of the following extensions: {0}
_UI_ModelObject = &Model Object
_UI_XMLEncoding = &XML Encoding
_UI_XMLEncodingChoices = UTF-8 ASCII UTF-16 UTF-16BE UTF-16LE ISO-8859-1
_UI_Wizard_initial_object_description = Select a model object to create
_UI_FileConflict_label = File Conflict
_WARN_FileConflict = There are unsaved changes that conflict with changes made outside the editor. Do you wish to discard this editor's changes?
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<!--
Copyright (c) 2017 CentraleSupélec & EDF.
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
This file is part of the RiseClipse tool
Contributors:
Computer Science Department, CentraleSupélec : initial implementation
Contacts:
Dominique.Marcadet@centralesupelec.fr
-->
<plugin>
<extension point="org.eclipse.ui.editors">
<editor
id="fr.centralesupelec.edf.riseclipse.editor.RiseClipseEditorID"
name="%_UI_RiseClipseEditor_label"
icon="icons/full/obj16/RiseClipseModelFile.gif"
extensions="xml"
class="fr.centralesupelec.edf.riseclipse.ui.RiseClipseEditor"
contributorClass="fr.centralesupelec.edf.riseclipse.ui.RiseClipseActionBarContributor">
</editor>
</extension>
<extension
point="org.eclipse.ui.commands">
<category
id="fr.centralesupelec.edf.riseclipse.editor.commands.category"
name="RiseClipse Category">
</category>
<command
categoryId="fr.centralesupelec.edf.riseclipse.editor.commands.category"
id="fr.centralesupelec.edf.riseclipse.editor.commands.navigateTo"
name="Navigate to">
</command>
<command
id="fr.centralesupelec.edf.riseclipse.editor.commands.displayStatistics"
name="Display Statistics">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="fr.centralesupelec.edf.riseclipse.editor.handlers.NavigateToHandler"
commandId="fr.centralesupelec.edf.riseclipse.editor.commands.navigateTo">
</handler>
<handler
class="fr.centralesupelec.edf.riseclipse.editor.handlers.displayStatisticsHandler"
commandId="fr.centralesupelec.edf.riseclipse.editor.commands.displayStatistics">
</handler>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any?before=additions">
<menu
id="fr.centralesupelec.edf.riseclipse.editor.popup.navigateToID"
label="Selected object">
<dynamic
class="fr.centralesupelec.edf.riseclipse.editor.handlers.NavigateToMenuBuilder"
id="fr.centralesupelec.edf.riseclipse.editor.commands.navigateTo.dynamic">
<visibleWhen>
<with
variable="activeMenuSelection">
<iterate>
<adapt
type="org.eclipse.emf.ecore.EObject">
</adapt>
</iterate>
</with>
</visibleWhen>
</dynamic>
<visibleWhen>
<with
variable="activeMenuSelection">
<iterate>
<adapt
type="org.eclipse.emf.ecore.EObject">
</adapt>
</iterate>
</with>
</visibleWhen>
</menu>
</menuContribution>
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
id="fr.centralesupelec.edf.riseclipse.editor.riseclipseMenuID"
label="RiseClipse">
<separator
name="tools">
</separator>
</menu>
</menuContribution>
<menuContribution
locationURI="menu:fr.centralesupelec.edf.riseclipse.editor.riseclipseMenuID?after=tools">
<command
commandId="fr.centralesupelec.edf.riseclipse.editor.commands.displayStatistics"
label="Display Statistics"
style="push">
</command>
</menuContribution>
</extension>
</plugin>
/**
* Copyright (c) 2017 CentraleSupélec & EDF.
* 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
*
* This file is part of the RiseClipse tool
*
* Contributors:
* Computer Science Department, CentraleSupélec : initial implementation
* Contacts:
* Dominique.Marcadet@centralesupelec.fr
*/
package fr.centralesupelec.edf.riseclipse.editor.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.menus.CommandContributionItem;
import fr.centralesupelec.edf.riseclipse.ui.RiseClipseEditor;
public class NavigateToHandler extends AbstractHandler {
public NavigateToHandler() {
}
@Override
public Object execute( ExecutionEvent event ) throws ExecutionException {
RiseClipseEditor e = ( RiseClipseEditor ) HandlerUtil.getActiveEditor( event );
Event v = ( Event ) event.getTrigger();
CommandContributionItem c = ( CommandContributionItem ) v.widget.getData();
e.navigateTo( c );
return null;
}
}
/**
* Copyright (c) 2017 CentraleSupélec & EDF.
* 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
*
* This file is part of the RiseClipse tool
*
* Contributors:
* Computer Science Department, CentraleSupélec : initial implementation
* Contacts:
* Dominique.Marcadet@centralesupelec.fr
*/
package fr.centralesupelec.edf.riseclipse.editor.handlers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.CompoundContributionItem;
import org.eclipse.ui.menus.CommandContributionItem;
import org.eclipse.ui.menus.CommandContributionItemParameter;
import org.eclipse.ui.menus.IWorkbenchContribution;
import org.eclipse.ui.services.IServiceLocator;
import fr.centralesupelec.edf.riseclipse.ui.RiseClipseEditor;
public class NavigateToMenuBuilder extends CompoundContributionItem implements IWorkbenchContribution {
private IServiceLocator serviceLocator;
public NavigateToMenuBuilder() {
}
// from CompoundContributionItem
@Override
protected IContributionItem[] getContributionItems() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if( ! ( window.getActivePage().getActiveEditor() instanceof RiseClipseEditor )) return null;
RiseClipseEditor editor = ( RiseClipseEditor ) window.getActivePage().getActiveEditor();
ISelection selection = window.getActivePage().getSelection();
if( ! ( selection instanceof TreeSelection )) return null;
TreeSelection tree = ( TreeSelection ) selection;
if( ! ( tree.getFirstElement() instanceof EObject )) return null;
IContributionItem[] items = new IContributionItem[1];
MenuManager navigateTo = new MenuManager( "Navigate to" );
items[0] = navigateTo;
EObject o = ( EObject ) tree.getFirstElement();
AdapterFactory adapter = editor.getAdapterFactory( o.eClass().getEPackage().getNsURI() );
EList< EReference > refs = o.eClass().getEAllReferences();
ArrayList< EReference > usedRefs = new ArrayList< EReference >();
ArrayList< Object > values = new ArrayList< Object >();
for( EReference r : refs ) {
Object v = o.eGet( r );
if( v != null ) {
usedRefs.add( r );
values.add( v );
}
}
IContributionItem[] list = new IContributionItem[usedRefs.size()];
// We need to get back the referenced eObject when the command is executed.
// As it seems that there is no way to associate an arbitrary object to
// the command, we build a map and give it to the editor
Map< CommandContributionItem, Object > map = new HashMap< CommandContributionItem, Object >();
for( int i = 0; i < list.length; ++i ) {
MenuManager ref = new MenuManager( usedRefs.get( i ).getName() );
int numberOfRefs = 1;
if( values.get( i ) instanceof EList ) {
numberOfRefs = (( EList< ? > ) values.get( i )).size();
}
for( int j = 0; j < numberOfRefs; ++j ) {
CommandContributionItemParameter contributionParameters = new CommandContributionItemParameter(
serviceLocator, null, "fr.centralesupelec.edf.riseclipse.editor.commands.navigateTo",
CommandContributionItem.STYLE_PUSH );
Object val;
if( values.get( i ) instanceof EList ) {
val = (( EList< ? > ) values.get( i )).get( j );
}
else {
val = values.get( i );
}
IItemLabelProvider labelProvider = ( IItemLabelProvider ) adapter.adapt( val, IItemLabelProvider.class );
contributionParameters.label = labelProvider.getText( val );
CommandContributionItem c = new CommandContributionItem( contributionParameters );
map.put( c, val );
ref.add( c );
}
navigateTo.add( ref );
}
editor.setNavigateToMap( map );
return items;
}
// from IWorkbenchContribution
@Override
public void initialize( IServiceLocator serviceLocator ) {
this.serviceLocator = serviceLocator;
}
}
/**
* Copyright (c) 2017 CentraleSupélec & EDF.
* 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
*
* This file is part of the RiseClipse tool
*
* Contributors:
* Computer Science Department, CentraleSupélec : initial implementation
* Contacts:
* Dominique.Marcadet@centralesupelec.fr
*/
package fr.centralesupelec.edf.riseclipse.editor.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.ui.handlers.HandlerUtil;
import fr.centralesupelec.edf.riseclipse.ui.RiseClipseEditor;
import fr.centralesupelec.edf.riseclipse.util.AbstractRiseClipseConsole;
import fr.centralesupelec.edf.riseclipse.util.IRiseClipseResource;
public class displayStatisticsHandler extends AbstractHandler {
@Override
public Object execute( ExecutionEvent event ) throws ExecutionException {
RiseClipseEditor e = ( RiseClipseEditor ) HandlerUtil.getActiveEditor( event );
ResourceSet r = e.getEditingDomain().getResourceSet();
for( int i = 0; i < r.getResources().size(); ++i ) {
Resource c = r.getResources().get( i );
if( c instanceof IRiseClipseResource ) {
(( IRiseClipseResource ) c ).printStatistics( AbstractRiseClipseConsole.getConsole() );
}
}
return null;
}
}
/**
* Copyright (c) 2017 CentraleSupélec & EDF.
* 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
*
* This file is part of the RiseClipse tool
*
* Contributors:
* Computer Science Department, CentraleSupélec : initial implementation
* Contacts:
* Dominique.Marcadet@centralesupelec.fr
*/
package fr.centralesupelec.edf.riseclipse.ui;
import java.io.IOException;
import java.io.PrintStream;
import org.eclipse.core.runtime.Platform;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.console.MessageConsoleStream;
import fr.centralesupelec.edf.riseclipse.util.AbstractRiseClipseConsole;
import fr.centralesupelec.edf.riseclipse.util.IRiseClipseConsole;
public class EclipseRiseClipseConsole extends AbstractRiseClipseConsole {
public static final IRiseClipseConsole INSTANCE = new EclipseRiseClipseConsole();
private static final String ConsoleName = "RiseClipseConsole";
private MessageConsole findConsole() {
if( !Platform.isRunning() ) return null;
ConsolePlugin plugin = ConsolePlugin.getDefault();
// Got null if running as Java instead of running as Eclipse
if( plugin == null ) return null;
IConsoleManager conMan = plugin.getConsoleManager();
IConsole[] existing = conMan.getConsoles();
for( int i = 0; i < existing.length; i++ ) {
if( ConsoleName.equals( existing[i].getName() )) {
return ( MessageConsole ) existing[i];
}
}
// no console found, so create a new one
MessageConsole myConsole = new MessageConsole( ConsoleName, null );
conMan.addConsoles( new IConsole[] { myConsole } );
return myConsole;
}
private void out( String message, PrintStream std ) {
MessageConsole myConsole = findConsole();
if( myConsole == null ) {
std.println( message );
std.flush();
return;
}
MessageConsoleStream stream = myConsole.newMessageStream();
stream.println( message );
try {
stream.flush();
}
catch( IOException e ) {
}
}
@Override
protected void doOutputMessage( String m ) {
out( m, System.out );
}
}
/**
* Copyright (c) 2017 CentraleSupélec & EDF.
* 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
*
* This file is part of the RiseClipse tool
*
* Contributors:
* Computer Science Department, CentraleSupélec : initial implementation
* Contacts:
* Dominique.Marcadet@centralesupelec.fr
*/
package fr.centralesupelec.edf.riseclipse.ui;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.Resource.Factory;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import fr.centralesupelec.edf.riseclipse.util.RiseClipseResourceSet;
public class RiseClipseAdapterFactoryEditingDomain extends AdapterFactoryEditingDomain {
public RiseClipseAdapterFactoryEditingDomain( AdapterFactory adapterFactory, CommandStack commandStack,
Map< Resource, Boolean > resourceToReadOnlyMap, HashMap< String, Resource.Factory > factories ) {
super( adapterFactory, commandStack, resourceToReadOnlyMap );
// We use RiseClipse specific ResourceSet
this.resourceSet = new LocalResourceSet( factories );
}
public RiseClipseAdapterFactoryEditingDomain( AdapterFactory adapterFactory, CommandStack commandStack,
ResourceSet resourceSet, HashMap< String, Resource.Factory > factories ) {
super( adapterFactory, commandStack, resourceSet );
// TODO: ??
throw new RuntimeException( "RiseClipseAdapterFactoryEditingDomain got a resourceSet" );
}
public RiseClipseAdapterFactoryEditingDomain( AdapterFactory adapterFactory, CommandStack commandStack,
HashMap< String, Resource.Factory > factories ) {
super( adapterFactory, commandStack );
// We use RiseClipse specific ResourceSet
this.resourceSet = new LocalResourceSet( factories );
}
public RiseClipseAdapterFactoryEditingDomain( ComposedAdapterFactory adapterFactory,
BasicCommandStack commandStack, HashMap< Resource, Boolean > hashMap,
HashMap< String, Resource.Factory > factories ) {
super( adapterFactory, commandStack, hashMap );
// We use RiseClipse specific ResourceSet
this.resourceSet = new LocalResourceSet( factories );
}
// From
// org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain.AdapterFactoryEditingDomainResourceSet
protected class LocalResourceSet extends RiseClipseResourceSet implements IEditingDomainProvider {
LocalResourceSet( HashMap< String, Factory > resourceFactories ) {
super( resourceFactories );
}
public EditingDomain getEditingDomain() {
return RiseClipseAdapterFactoryEditingDomain.this;
}
}
}
/**
* Copyright (c) 2017 CentraleSupélec & EDF.
* 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
*
* This file is part of the RiseClipse tool
*
* Contributors:
* Computer Science Department, CentraleSupélec : initial implementation
* Contacts:
* Dominique.Marcadet@centralesupelec.fr
*/
package fr.centralesupelec.edf.riseclipse.ui;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.ui.EclipseUIPlugin;
import org.eclipse.emf.common.util.ResourceLocator;
/**
* This is the central singleton for the RiseClipse editor plugin.
*/
public final class RiseClipseEditorPlugin extends EMFPlugin {
/**
* Keep track of the singleton.
*/
public static final RiseClipseEditorPlugin INSTANCE = new RiseClipseEditorPlugin();
/**
* Keep track of the singleton.
*/
private static Implementation plugin;
/**
* Create the instance.