summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Wouters2014-04-04 10:11:36 (EDT)
committerLaurent Wouters2014-04-04 10:11:36 (EDT)
commit53d8fc7cdbfa861daf9e565678ba3355be6a4ff8 (patch)
tree7478d8d12fdd89519a6b444dbefcf496ed87c017
parent3c89905ce10e339d3e0f1ad26fe83543ea75efb2 (diff)
downloadorg.eclipse.papyrus-53d8fc7cdbfa861daf9e565678ba3355be6a4ff8.zip
org.eclipse.papyrus-53d8fc7cdbfa861daf9e565678ba3355be6a4ff8.tar.gz
org.eclipse.papyrus-53d8fc7cdbfa861daf9e565678ba3355be6a4ff8.tar.bz2
[clean] Retiring org.eclipse.papyrus.infra.xtext.widgetslast/org.eclipse.papyrus.infra.xtext.widgets
Signed-off-by: Laurent Wouters <laurent.wouters@cea.fr>
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/.classpath7
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/.project28
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/META-INF/MANIFEST.MF25
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/OSGI-INF/l10n/bundle.properties3
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/about.html28
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/build.properties7
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/Activator.java69
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/adapter/IXtextAdapter.java49
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/creation/XtextEditorDialog.java70
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/creation/XtextValueFactory.java74
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/editor/ReferenceXtextEditor.java99
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/EmbeddedFoldingStructureProvider.java207
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/EmbeddedXtextEditor.java761
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/EmbeddedXtextResource.java33
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/HighlightingHelper.java138
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/HighlightingReconciler.java284
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/TextViewerAction.java64
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/ToggleSLCommentAction.java305
-rw-r--r--deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/XTextEditor.java53
20 files changed, 0 insertions, 2312 deletions
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/.classpath b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/.classpath
deleted file mode 100644
index 2d1a430..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/.project b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/.project
deleted file mode 100644
index 3273127..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.papyrus.infra.xtext.widgets</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.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/.settings/org.eclipse.jdt.core.prefs b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 0afca15..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,8 +0,0 @@
-#Thu Jan 13 09:14:20 CET 2011
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/META-INF/MANIFEST.MF b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/META-INF/MANIFEST.MF
deleted file mode 100644
index 338823d..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,25 +0,0 @@
-Manifest-Version: 1.0
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.xtext.ui;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.widgets;bundle-version="0.10.1",
- org.eclipse.core.databinding;bundle-version="1.3.100",
- org.eclipse.core.expressions;bundle-version="3.4.200",
- org.eclipse.ui.navigator;bundle-version="3.5.0",
- org.eclipse.papyrus.infra.core.log;bundle-version="0.10.1",
- org.eclipse.emf.compare;bundle-version="1.1.1",
- org.eclipse.emf.compare.match;bundle-version="1.1.1",
- org.eclipse.emf.compare.diff;bundle-version="1.1.1"
-Export-Package: org.eclipse.papyrus.infra.xtext.widgets.adapter,
- org.eclipse.papyrus.infra.xtext.widgets.creation,
- org.eclipse.papyrus.infra.xtext.widgets.editor,
- org.eclipse.papyrus.infra.xtext.widgets.embedded
-Bundle-Vendor: %Bundle-Vendor
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 0.10.1.qualifier
-Bundle-Name: %Bundle-Name
-Bundle-ManifestVersion: 2
-Bundle-Activator: org.eclipse.papyrus.infra.widgets.xtext.Activator
-Bundle-SymbolicName: org.eclipse.papyrus.infra.xtext.widgets
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/OSGI-INF/l10n/bundle.properties b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/OSGI-INF/l10n/bundle.properties
deleted file mode 100644
index 1737fc8..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/OSGI-INF/l10n/bundle.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-#Properties file for org.eclipse.papyrus.infra.widgets.xtext
-Bundle-Vendor = Eclipse Modeling Project
-Bundle-Name = Papyrus widgets Xtext (Incubation) \ No newline at end of file
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/about.html b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/about.html
deleted file mode 100644
index 82d49bf..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/about.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 5, 2007</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
-
-</body>
-</html>
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/build.properties b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/build.properties
deleted file mode 100644
index f7bd3f6..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/build.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-#
-#Mon Sep 12 09:30:25 CEST 2011
-bin.includes=META-INF/,.,about.html,OSGI-INF/
-output..=bin/
-src.includes=META-INF/,.,about.html,OSGI-INF/
-source..=src/
-bin..=bin/
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/Activator.java b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/Activator.java
deleted file mode 100644
index 020fcae..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/Activator.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.xtext.widgets;
-
-import org.eclipse.papyrus.infra.core.log.LogHelper;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.xtext.widgets"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- public static LogHelper log;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- log = new LogHelper(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/adapter/IXtextAdapter.java b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/adapter/IXtextAdapter.java
deleted file mode 100644
index ff4a5b4..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/adapter/IXtextAdapter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.xtext.widgets.adapter;
-
-import org.eclipse.emf.ecore.EObject;
-
-import com.google.inject.Injector;
-
-
-public interface IXtextAdapter {
-
- /**
- * In some cases, the Xtext object is different from the model object
- * This method is called when the modifications on the Xtext model are
- * validated
- *
- * @param xtextObject
- * The EObject generated by the compilation of the Xtext model
- * @param sourceModelObject
- * The current value for the reference being edited
- * @return the Model object
- * The new value for the reference being edited
- */
- public EObject reconcile(EObject sourceModelObject, EObject xtextObject);
-
- /**
- * Returns the Xtext String representing the given EObject
- *
- * @param modelObject
- * The EObject being edited. May be null if the reference is unset.
- * @return
- * The Xtext String representing the given EObject
- */
- public String getText(EObject modelObject);
-
- /**
- * @return the Injector to initialize the Xtext editor
- */
- public Injector getInjector();
-}
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/creation/XtextEditorDialog.java b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/creation/XtextEditorDialog.java
deleted file mode 100644
index fab008b..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/creation/XtextEditorDialog.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.xtext.widgets.creation;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.infra.xtext.widgets.adapter.IXtextAdapter;
-import org.eclipse.papyrus.infra.xtext.widgets.embedded.EmbeddedXtextEditor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.SelectionDialog;
-
-
-public class XtextEditorDialog extends SelectionDialog {
-
- protected IXtextAdapter adapter;
-
- protected EObject currentValue;
-
- protected EmbeddedXtextEditor editor;
-
- public XtextEditorDialog(Shell shell, IXtextAdapter adapter, EObject currentValue) {
- super(shell);
- this.adapter = adapter;
- this.currentValue = currentValue;
- }
-
- @Override
- public void create() {
- super.create();
- editor = new EmbeddedXtextEditor(getDialogArea(), adapter.getInjector(), SWT.NONE);
- editor.update(adapter.getText(currentValue));
- getShell().pack();
- }
-
- @Override
- protected void okPressed() {
- Resource resource = editor.getResource();
- if(resource != null) {
- List<EObject> contents = resource.getContents();
- if(!contents.isEmpty()) {
- currentValue = adapter.reconcile(currentValue, contents.get(0));
- setResult(contents);
- }
- }
- super.okPressed();
- }
-
- public EObject getValue() {
- return currentValue;
- }
-
- @Override
- protected Composite getDialogArea() {
- return (Composite)super.getDialogArea();
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/creation/XtextValueFactory.java b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/creation/XtextValueFactory.java
deleted file mode 100644
index 009e90d..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/creation/XtextValueFactory.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.xtext.widgets.creation;
-
-import java.util.Collection;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.infra.widgets.Activator;
-import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
-import org.eclipse.papyrus.infra.xtext.widgets.adapter.IXtextAdapter;
-import org.eclipse.swt.widgets.Control;
-
-//This factory should only be used for containment references, as there is no "CreateIn" parameter
-public class XtextValueFactory implements ReferenceValueFactory {
-
- protected IXtextAdapter adapter;
-
- public XtextValueFactory() {
- }
-
- public void setAdapter(IXtextAdapter adapter) {
- this.adapter = adapter;
- }
-
- public IXtextAdapter getAdapter() {
- return adapter;
- }
-
- public XtextValueFactory(IXtextAdapter adapter) {
- this.adapter = adapter;
- }
-
- public Object createObject(Control widget) {
- XtextEditorDialog dialog = new XtextEditorDialog(widget.getShell(), adapter, null);
- int result = dialog.open();
- if(result == Window.OK) {
- return dialog.getValue();
- }
- return null;
- }
-
- public Collection<Object> validateObjects(Collection<Object> objectsToValidate) {
- return objectsToValidate; //add the objects to the right resource
- }
-
- public boolean canEdit() {
- return true; //Unsupported yet (We need a Write Transaction)
- }
-
- public Object edit(Control widget, Object object) {
- if(object instanceof EObject) {
- XtextEditorDialog dialog = new XtextEditorDialog(widget.getShell(), adapter, (EObject)object);
- dialog.open();
- } else {
- Activator.log.warn("The XtextValueFactory can only edit EObjects"); //$NON-NLS-1$
- }
- return object;
- }
-
- public boolean canCreateObject() {
- return true;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/editor/ReferenceXtextEditor.java b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/editor/ReferenceXtextEditor.java
deleted file mode 100644
index a374c35..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/editor/ReferenceXtextEditor.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.xtext.widgets.editor;
-
-import org.eclipse.core.databinding.observable.ChangeEvent;
-import org.eclipse.core.databinding.observable.IChangeListener;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.infra.widgets.editors.AbstractValueEditor;
-import org.eclipse.papyrus.infra.xtext.widgets.Activator;
-import org.eclipse.papyrus.infra.xtext.widgets.adapter.IXtextAdapter;
-import org.eclipse.papyrus.infra.xtext.widgets.embedded.EmbeddedXtextEditor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-
-
-public class ReferenceXtextEditor extends AbstractValueEditor implements IChangeListener {
-
- protected EmbeddedXtextEditor editor;
-
- protected String xtextAdapterClassName;
-
- protected IXtextAdapter adapter;
-
- public ReferenceXtextEditor(Composite parent, int style) {
- super(parent, style);
- }
-
- public void setAdapter(String xtextAdapterClassName) {
- this.xtextAdapterClassName = xtextAdapterClassName;
- try {
- Class<? extends IXtextAdapter> xtextAdapterClass = Class.forName(xtextAdapterClassName).asSubclass(IXtextAdapter.class);
- IXtextAdapter xtextAdapter = xtextAdapterClass.newInstance();
- editor = new EmbeddedXtextEditor(this, xtextAdapter.getInjector(), SWT.None);
- } catch (ClassNotFoundException e) {
- Activator.log.error(e);
- } catch (InstantiationException e) {
- Activator.log.error(e);
- } catch (IllegalAccessException e) {
- Activator.log.error(e);
- }
- }
-
- public String getAdapter() {
- return xtextAdapterClassName;
- }
-
- @Override
- protected void doBinding() {
- if(editor != null && modelProperty != null) {
- modelProperty.addChangeListener(this);
- }
- }
-
- @Override
- public void dispose() {
- if(modelProperty != null) {
- modelProperty.removeChangeListener(this);
- }
- }
-
- @Override
- public Object getValue() {
- return editor.getResource().getContents().get(0);
- }
-
- @Override
- public Object getEditableType() {
- return EObject.class;
- }
-
- @Override
- public void setReadOnly(boolean readOnly) {
- //TODO
- }
-
- @Override
- public boolean isReadOnly() {
- return false; //TODO
- }
-
- public void handleChange(ChangeEvent event) {
- editor.update(adapter.getText((EObject)modelProperty.getValue()));
- }
-
- @Override
- public void setToolTipText(String text) {
- //TODO
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/EmbeddedFoldingStructureProvider.java b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/EmbeddedFoldingStructureProvider.java
deleted file mode 100644
index 13f8ea1..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/EmbeddedFoldingStructureProvider.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.xtext.widgets.embedded;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.emf.ecore.resource.Resource.Diagnostic;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.projection.IProjectionListener;
-import org.eclipse.jface.text.source.projection.ProjectionAnnotation;
-import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel;
-import org.eclipse.jface.text.source.projection.ProjectionViewer;
-import org.eclipse.xtext.resource.XtextResource;
-import org.eclipse.xtext.resource.XtextSyntaxDiagnostic;
-import org.eclipse.xtext.ui.editor.folding.IFoldingRegionProvider;
-import org.eclipse.xtext.ui.editor.model.IXtextModelListener;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
-import com.google.inject.Inject;
-
-/**
- * Default implementation of interface {@link IFoldingStructureProvider}
- *
- * @author Michael Clay - Initial contribution and API
- * @author Mikael Barbero - Dependant of Embedded XtextEditor
- */
-public class EmbeddedFoldingStructureProvider implements IXtextModelListener {
-
- @Inject
- private IFoldingRegionProvider foldingRegionProvider;
-
- private EmbeddedXtextEditor editor;
-
- private ProjectionViewer viewer;
-
- private ProjectionChangeListener projectionListener;
-
- public void install(EmbeddedXtextEditor editor, ProjectionViewer viewer) {
- Assert.isNotNull(editor);
- Assert.isNotNull(viewer);
- uninstall();
- this.editor = editor;
- this.viewer = viewer;
- projectionListener = new ProjectionChangeListener(viewer);
- }
-
- public void initialize() {
- calculateProjectionAnnotationModel(false);
- }
-
- public void uninstall() {
- if(isInstalled()) {
- handleProjectionDisabled();
- projectionListener.dispose();
- projectionListener = null;
- editor = null;
- }
- }
-
- /**
- * Returns <code>true</code> if the provider is installed, <code>false</code> otherwise.
- *
- * @return <code>true</code> if the provider is installed, <code>false</code> otherwise
- */
- protected final boolean isInstalled() {
- return editor != null;
- }
-
- /**
- * @see org.eclipse.xtext.ui.editor.model.IXtextModelListener#modelChanged(org.eclipse.xtext.resource.XtextResource)
- */
- public void modelChanged(XtextResource resource) {
- boolean existingSyntaxErrors = Iterables.any(resource.getErrors(), new Predicate<Diagnostic>() {
-
- public boolean apply(Diagnostic diagnostic) {
- return diagnostic instanceof XtextSyntaxDiagnostic;
- }
- });
-
- if(!existingSyntaxErrors) {
- calculateProjectionAnnotationModel(false);
- }
- }
-
- protected void handleProjectionEnabled() {
- handleProjectionDisabled();
- if(isInstalled()) {
- initialize();
- editor.getDocument().addModelListener(this);
- }
- }
-
- protected void handleProjectionDisabled() {
- if(editor.getDocument() != null) {
- editor.getDocument().removeModelListener(this);
- }
- }
-
- protected void calculateProjectionAnnotationModel(boolean allowCollapse) {
- ProjectionAnnotationModel projectionAnnotationModel = this.viewer.getProjectionAnnotationModel();
- if(projectionAnnotationModel != null) {
- List<IFoldingRegion> foldingRegions = foldingRegionProvider.getFoldingRegions(editor.getDocument());
- HashBiMap<Position, IFoldingRegion> positionsMap = toPositionIndexedMap(foldingRegions);
- Annotation[] newRegions = mergeFoldingRegions(positionsMap, projectionAnnotationModel);
- updateFoldingRegions(allowCollapse, projectionAnnotationModel, positionsMap, newRegions);
- }
- }
-
- protected HashBiMap<Position, IFoldingRegion> toPositionIndexedMap(List<IFoldingRegion> foldingRegions) {
- HashBiMap<Position, IFoldingRegion> positionsMap = Maps.newHashBiMap();
- for(IFoldingRegion foldingRegion : foldingRegions) {
- positionsMap.put(foldingRegion.getPosition(), foldingRegion);
- }
- return positionsMap;
- }
-
- @SuppressWarnings("unchecked")
- protected Annotation[] mergeFoldingRegions(HashBiMap<Position, IFoldingRegion> positionsMap, ProjectionAnnotationModel projectionAnnotationModel) {
- List<Annotation> deletions = new ArrayList<Annotation>();
- for(Iterator<Annotation> iterator = projectionAnnotationModel.getAnnotationIterator(); iterator.hasNext();) {
- Annotation annotation = iterator.next();
- if(annotation instanceof ProjectionAnnotation) {
- Position position = projectionAnnotationModel.getPosition(annotation);
- if(positionsMap.remove(position) == null) {
- deletions.add(annotation);
- }
- }
- }
- return deletions.toArray(new Annotation[deletions.size()]);
- }
-
- protected void updateFoldingRegions(boolean allowCollapse, ProjectionAnnotationModel model, HashBiMap<Position, IFoldingRegion> positionsMap, Annotation[] deletions) {
- Map<ProjectionAnnotation, Position> additionsMap = new HashMap<ProjectionAnnotation, Position>();
- for(Iterator<IFoldingRegion> iterator = positionsMap.values().iterator(); iterator.hasNext();) {
- IFoldingRegion foldingRegion = iterator.next();
- addProjectionAnnotation(allowCollapse, foldingRegion, additionsMap);
- }
- if(deletions.length != 0 || additionsMap.size() != 0) {
- model.modifyAnnotations(deletions, additionsMap, new Annotation[]{});
- }
- }
-
- protected void addProjectionAnnotation(boolean allowCollapse, IFoldingRegion foldingRegion, Map<ProjectionAnnotation, Position> additionsMap) {
- ProjectionAnnotation projectionAnnotation = createProjectionAnnotation(allowCollapse, foldingRegion);
- additionsMap.put(projectionAnnotation, foldingRegion.getPosition());
- }
-
- protected ProjectionAnnotation createProjectionAnnotation(boolean allowCollapse, IFoldingRegion foldingRegion) {
- return new StyledProjectionAnnotation(allowCollapse, foldingRegion.getAlias());
- }
-
- /**
- * Internal projection listener.
- */
- public class ProjectionChangeListener implements IProjectionListener {
-
- private ProjectionViewer projectionViewer;
-
- /**
- * Registers the listener with the viewer.
- *
- * @param viewer
- * the viewer to register a listener with
- */
- public ProjectionChangeListener(ProjectionViewer viewer) {
- Assert.isLegal(viewer != null);
- projectionViewer = viewer;
- projectionViewer.addProjectionListener(this);
- }
-
- /**
- * Disposes of this listener and removes the projection listener from the viewer.
- */
- public void dispose() {
- if(projectionViewer != null) {
- projectionViewer.removeProjectionListener(this);
- projectionViewer = null;
- }
- }
-
- public void projectionEnabled() {
- handleProjectionEnabled();
- }
-
- public void projectionDisabled() {
- handleProjectionDisabled();
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/EmbeddedXtextEditor.java b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/EmbeddedXtextEditor.java
deleted file mode 100644
index e8c5192..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/EmbeddedXtextEditor.java
+++ /dev/null
@@ -1,761 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.xtext.widgets.embedded;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.compare.diff.metamodel.DiffModel;
-import org.eclipse.emf.compare.diff.service.DiffService;
-import org.eclipse.emf.compare.match.MatchOptions;
-import org.eclipse.emf.compare.match.metamodel.MatchModel;
-import org.eclipse.emf.compare.match.service.MatchService;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.commands.ActionHandler;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ISynchronizable;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.AnnotationModel;
-import org.eclipse.jface.text.source.AnnotationPainter;
-import org.eclipse.jface.text.source.AnnotationRulerColumn;
-import org.eclipse.jface.text.source.CompositeRuler;
-import org.eclipse.jface.text.source.IAnnotationAccess;
-import org.eclipse.jface.text.source.IAnnotationAccessExtension;
-import org.eclipse.jface.text.source.IOverviewRuler;
-import org.eclipse.jface.text.source.ISharedTextColors;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.jface.text.source.IVerticalRulerColumn;
-import org.eclipse.jface.text.source.OverviewRuler;
-import org.eclipse.jface.text.source.projection.ProjectionSupport;
-import org.eclipse.jface.text.source.projection.ProjectionViewer;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.ActiveShellExpression;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.contexts.IContextActivation;
-import org.eclipse.ui.contexts.IContextService;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.handlers.IHandlerActivation;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.internal.editors.text.EditorsPlugin;
-import org.eclipse.ui.navigator.ICommonMenuConstants;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.ui.texteditor.AnnotationPreference;
-import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
-import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
-import org.eclipse.xtext.Constants;
-import org.eclipse.xtext.IGrammarAccess;
-import org.eclipse.xtext.resource.XtextResource;
-import org.eclipse.xtext.ui.editor.XtextSourceViewer;
-import org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration;
-import org.eclipse.xtext.ui.editor.bracketmatching.BracketMatchingPreferencesInitializer;
-import org.eclipse.xtext.ui.editor.model.IXtextDocument;
-import org.eclipse.xtext.ui.editor.model.XtextDocument;
-import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreAccess;
-import org.eclipse.xtext.ui.editor.quickfix.IssueResolutionProvider;
-import org.eclipse.xtext.ui.editor.validation.AnnotationIssueProcessor;
-import org.eclipse.xtext.ui.editor.validation.IValidationIssueProcessor;
-import org.eclipse.xtext.ui.editor.validation.ValidationJob;
-import org.eclipse.xtext.ui.resource.IResourceSetProvider;
-import org.eclipse.xtext.util.StringInputStream;
-import org.eclipse.xtext.validation.CheckMode;
-import org.eclipse.xtext.validation.IResourceValidator;
-import org.eclipse.xtext.validation.Issue;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.Provider;
-import com.google.inject.name.Named;
-
-public class EmbeddedXtextEditor {
-
- private static final String XTEXT_UI_FORMAT_ACTION = "org.eclipse.xtext.ui.FormatAction"; //$NON-NLS-1$
-
- private static final String XTEXT_UI_TOGGLE_SL_COMMENT_ACTION = "org.eclipse.xtext.ui.ToggleCommentAction"; //$NON-NLS-1$
-
- private Composite fControl;
-
- private int fStyle;
-
- private XtextSourceViewer fSourceViewer;
-
- private EmbeddedXtextResource fResource;
-
- private XtextDocument fDocument;
-
- @Inject
- @Named(Constants.FILE_EXTENSIONS)
- private String fFileExtension;
-
- private XtextSourceViewerConfiguration fViewerConfiguration;
-
- @Inject
- private HighlightingHelper fHighlightingHelper;
-
- @Inject
- private IResourceSetProvider fResourceSetProvider;
-
- @Inject
- private IGrammarAccess fGrammarAccess;
-
- @Inject
- private XtextSourceViewer.Factory fSourceViewerFactory;
-
- @Inject
- private Provider<XtextSourceViewerConfiguration> fSourceViewerConfigurationProvider;
-
- @Inject
- private Provider<XtextDocument> fDocumentProvider;
-
- @Inject
- private Provider<EmbeddedXtextResource> fEmbeddedXtextResourceProvider;
-
- @Inject
- private IResourceValidator fResourceValidator;
-
- @Inject
- private IPreferenceStoreAccess fPreferenceStoreAccess;
-
- @Inject
- private CharacterPairMatcher characterPairMatcher;
-
- @Inject(optional = true)
- private AnnotationPainter.IDrawingStrategy projectionAnnotationDrawingStrategy;
-
- private EmbeddedFoldingStructureProvider fFoldingStructureProvider;
-
- private IOverviewRuler fOverviewRuler;
-
- private IAnnotationAccess fAnnotationAccess;
-
- /**
- * Creates a new EmbeddedXtextEditor. It must have the SWT.V_SCROLL style at least not to
- * throw NPE when computing overview ruler.
- *
- * @param control
- * the parent composite that will contain the editor
- * @param injector
- * the Guice injector to get Xtext configuration elements
- * @param job
- * the synchronization job that will be scheduled/rescheduled at each
- * modification of the editor text. It may be use to reconcile the content of
- * the editor with something else.
- * @param style
- * the SWT style of the {@link SourceViewer} of this editor.
- * @param fileExtension
- * the file extension (without the DOT) of the textual DSL to edit
- */
- public EmbeddedXtextEditor(Composite control, Injector injector, int style) {
- fControl = control;
- fStyle = style;
- fAnnotationPreferences = EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
- fFoldingStructureProvider = new EmbeddedFoldingStructureProvider();
-
- injector.injectMembers(this);
-
- createEditor(fControl);
- }
-
- /**
- * Creates a new EmbeddedXtextEditor.
- *
- * Equivalent to EmbeddedXtextEditor(control, injector, job, fileExtension, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- *
- * @param control
- * the parent composite that will contain the editor
- * @param injector
- * the Guice injector to get Xtext configuration elements
- * @param job
- * the synchronization job that will be scheduled/rescheduled at each
- * modification of the editor text. It may be use to reconcile the content of
- * the editor with something else.
- * @param fileExtension
- * the file extension (without the DOT) of the textual DSL to edit
- * @param fileExtension
- */
- public EmbeddedXtextEditor(Composite control, Injector injector) {
- this(control, injector, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- }
-
- public Composite getControl() {
- return fControl;
- }
-
- public XtextSourceViewer getViewer() {
- return fSourceViewer;
- }
-
- public XtextResource getResource() {
- return fResource;
- }
-
- public IXtextDocument getDocument() {
- return fDocument;
- }
-
- /**
- * Should be called only once, during initialization.
- *
- * Then, you should call {@link #updateText(String, String, String)};
- *
- * @param document
- * @param prefix
- * @param text
- * @param suffix
- */
- protected void setText(XtextDocument document, String text) {
- document.set(text);
- fResource = createResource(text);
- document.setInput(fResource);
- AnnotationModel annotationModel = new AnnotationModel();
- if(document instanceof ISynchronizable) {
- Object lock = ((ISynchronizable)document).getLockObject();
- if(lock == null) {
- lock = new Object();
- ((ISynchronizable)document).setLockObject(lock);
- }
- ((ISynchronizable)annotationModel).setLockObject(lock);
- }
- fSourceViewer.setDocument(document, annotationModel);
- }
-
- private EmbeddedXtextResource createResource(String content) {
- EmbeddedXtextResource result = createResource();
- try {
- result.load(new StringInputStream(content, result.getEncoding()), Collections.emptyMap());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- return result;
- }
-
- private void createEditor(Composite parent) {
- createViewer(parent);
-
- Control control = fSourceViewer.getControl();
- GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
- control.setLayoutData(data);
-
- createActions();
-
- MenuManager manager = new MenuManager(null, null);
- manager.setRemoveAllWhenShown(true);
- manager.addMenuListener(new IMenuListener() {
-
- public void menuAboutToShow(IMenuManager mgr) {
- EmbeddedXtextEditor.this.menuAboutToShow(mgr);
- }
- });
-
- StyledText text = fSourceViewer.getTextWidget();
- Menu menu = manager.createContextMenu(text);
- text.setMenu(menu);
- }
-
- private void menuAboutToShow(IMenuManager menu) {
- menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
- menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fActions.get(ITextEditorActionConstants.CUT));
- menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fActions.get(ITextEditorActionConstants.COPY));
- menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fActions.get(ITextEditorActionConstants.PASTE));
-
- menu.add(new Separator(ICommonMenuConstants.GROUP_GENERATE));
- menu.appendToGroup(ICommonMenuConstants.GROUP_GENERATE, fActions.get(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS));
- }
-
- private void createViewer(Composite parent) {
- createSourceViewer(parent);
- installFoldingSupport(fSourceViewer);
- setText(fDocument, ""); //$NON-NLS-1$
- fHighlightingHelper.install(fViewerConfiguration, fSourceViewer);
- }
-
- /**
- * Creates the vertical ruler to be used by this editor.
- * Subclasses may re-implement this method.
- *
- * @return the vertical ruler
- */
- private IVerticalRuler createVerticalRuler() {
- return new CompositeRuler();
- }
-
- /** The editor's vertical ruler. */
- private IVerticalRuler fVerticalRuler;
-
- /**
- * Creates the annotation ruler column. Subclasses may re-implement or extend.
- *
- * @param ruler
- * the composite ruler that the column will be added
- * @return an annotation ruler column
- * @since 3.2
- */
- protected IVerticalRulerColumn createAnnotationRulerColumn(CompositeRuler ruler) {
- return new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, getAnnotationAccess());
- }
-
-
- private void createSourceViewer(Composite parent) {
- fVerticalRuler = createVerticalRuler();
- fSourceViewer = fSourceViewerFactory.createSourceViewer(parent, fVerticalRuler, getOverviewRuler(), true, fStyle);
- fViewerConfiguration = fSourceViewerConfigurationProvider.get();
- fSourceViewer.configure(fViewerConfiguration);
-
- installProjectionSupport(fSourceViewer);
-
- // make sure the source viewer decoration support is initialized
- getSourceViewerDecorationSupport(fSourceViewer);
-
- fSourceViewer.getTextWidget().addFocusListener(new SourceViewerFocusListener());
-
- fSourceViewerDecorationSupport.install(fPreferenceStoreAccess.getPreferenceStore());
- parent.addDisposeListener(new DisposeListener() {
-
- public void widgetDisposed(DisposeEvent e) {
- fSourceViewerDecorationSupport.dispose();
- }
- });
- fDocument = fDocumentProvider.get();
- ValidationJob job = new ValidationJob(fResourceValidator, fDocument, new IValidationIssueProcessor() {
-
- private AnnotationIssueProcessor annotationIssueProcessor;
-
- public void processIssues(List<Issue> issues, IProgressMonitor monitor) {
- if(annotationIssueProcessor == null) {
- annotationIssueProcessor = new AnnotationIssueProcessor(fDocument, fSourceViewer.getAnnotationModel(), new IssueResolutionProvider.NullImpl());
- }
- if(annotationIssueProcessor != null)
- annotationIssueProcessor.processIssues(issues, monitor);
- }
- }, CheckMode.FAST_ONLY);
- fDocument.setValidationJob(job);
-
- fSourceViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- updateSelectionDependentActions();
- }
- });
- }
-
- private static final String ERROR_ANNOTATION_TYPE = "org.eclipse.xtext.ui.editor.error"; //$NON-NLS-1$
-
- private static final String WARNING_ANNOTATION_TYPE = "org.eclipse.xtext.ui.editor.warning"; //$NON-NLS-1$
-
- private ProjectionSupport installProjectionSupport(ProjectionViewer projectionViewer) {
- ProjectionSupport projectionSupport = new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors());
- projectionSupport.addSummarizableAnnotationType(WARNING_ANNOTATION_TYPE);
- projectionSupport.addSummarizableAnnotationType(ERROR_ANNOTATION_TYPE);
- projectionSupport.setAnnotationPainterDrawingStrategy(projectionAnnotationDrawingStrategy);
- projectionSupport.install();
- return projectionSupport;
- }
-
- /**
- * Helper for managing the decoration support of this editor's viewer.
- *
- * <p>
- * This field should not be referenced by subclasses. It is <code>protected</code> for API compatibility reasons and will be made
- * <code>private</code> soon. Use {@link #getSourceViewerDecorationSupport(ISourceViewer)} instead.
- * </p>
- */
- private SourceViewerDecorationSupport fSourceViewerDecorationSupport;
-
- private void installFoldingSupport(ProjectionViewer projectionViewer) {
- fFoldingStructureProvider.install(this, projectionViewer);
- projectionViewer.doOperation(ProjectionViewer.TOGGLE);
- fFoldingStructureProvider.initialize();
- }
-
- /**
- * Returns the source viewer decoration support.
- *
- * @param viewer
- * the viewer for which to return a decoration support
- * @return the source viewer decoration support
- */
- private SourceViewerDecorationSupport getSourceViewerDecorationSupport(ISourceViewer viewer) {
- if(fSourceViewerDecorationSupport == null) {
- fSourceViewerDecorationSupport = new SourceViewerDecorationSupport(viewer, getOverviewRuler(), getAnnotationAccess(), getSharedColors());
- configureSourceViewerDecorationSupport(fSourceViewerDecorationSupport);
- }
- return fSourceViewerDecorationSupport;
- }
-
- /**
- * Configures the decoration support for this editor's source viewer. Subclasses may override this
- * method, but should call their superclass' implementation at some point.
- *
- * @param support
- * the decoration support to configure
- */
- private void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
-
- Iterator<AnnotationPreference> e = Iterators.filter(fAnnotationPreferences.getAnnotationPreferences().iterator(), AnnotationPreference.class);
- while(e.hasNext())
- support.setAnnotationPreference(e.next());
-
- support.setCursorLinePainterPreferenceKeys(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR);
- support.setMarginPainterPreferenceKeys(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN);
- // support.setSymbolicFontName(getFontPropertyPreferenceKey());
-
- if(characterPairMatcher != null) {
- support.setCharacterPairMatcher(characterPairMatcher);
- support.setMatchingCharacterPainterPreferenceKeys(BracketMatchingPreferencesInitializer.IS_ACTIVE_KEY, BracketMatchingPreferencesInitializer.COLOR_KEY);
- }
- }
-
- /**
- * Returns the overview ruler.
- *
- * @return the overview ruler
- */
- private IOverviewRuler getOverviewRuler() {
- if(fOverviewRuler == null && (fStyle & SWT.V_SCROLL) != 0)
- fOverviewRuler = createOverviewRuler(getSharedColors());
- return fOverviewRuler;
- }
-
- /** The width of the vertical ruler. */
- private static final int VERTICAL_RULER_WIDTH = 12;
-
- /**
- * Returns the annotation access.
- *
- * @return the annotation access
- */
- private IAnnotationAccess getAnnotationAccess() {
- if(fAnnotationAccess == null)
- fAnnotationAccess = createAnnotationAccess();
- return fAnnotationAccess;
- }
-
- /**
- * Creates the annotation access for this editor.
- *
- * @return the created annotation access
- */
- private IAnnotationAccess createAnnotationAccess() {
- return new DefaultMarkerAnnotationAccess() {
-
- @Override
- public int getLayer(Annotation annotation) {
- if(annotation.isMarkedDeleted()) {
- return IAnnotationAccessExtension.DEFAULT_LAYER;
- }
- return super.getLayer(annotation);
- }
- };
- }
-
- /**
- * The annotation preferences.
- */
- private MarkerAnnotationPreferences fAnnotationPreferences;
-
- private IOverviewRuler createOverviewRuler(ISharedTextColors sharedColors) {
- IOverviewRuler ruler = new OverviewRuler(getAnnotationAccess(), VERTICAL_RULER_WIDTH, sharedColors);
-
- Iterator<?> e = fAnnotationPreferences.getAnnotationPreferences().iterator();
- while(e.hasNext()) {
- AnnotationPreference preference = (AnnotationPreference)e.next();
- if(preference.contributesToHeader())
- ruler.addHeaderAnnotationType(preference.getAnnotationType());
- }
- return ruler;
- }
-
- private ISharedTextColors getSharedColors() {
- return EditorsUI.getSharedTextColors();
- }
-
- /**
- * Updates the text of this editor with the given String
- *
- * @param text
- */
- public void update(String text) {
- IDocument document = fSourceViewer.getDocument();
-
- fSourceViewer.setRedraw(false);
- document.set(text);
- fSourceViewer.setVisibleRegion(0, text.length());
- fSourceViewer.setRedraw(true);
- }
-
- /**
- * Updates the text of this editor with the given String or the
- * serialized form of the EObject if the semantic model of the
- * String does not contain any error and is different from the
- * given EObject.
- *
- * @param eObject
- * @param asString
- */
- public void update(EObject eObject, String asString) {
- if(eObject != null) {
- fResource.setParentResource(eObject.eResource());
- EObject asStringEObject = null;
- // XtextResource asStringResource = (XtextResource) fResourceSetProvider.get(null).createResource(URI.createURI("asStringResource." + fFileExtension));
- ResourceSet resourceSet = fResourceSetProvider.get(null);
- EmbeddedXtextResource asStringResource = fEmbeddedXtextResourceProvider.get();
- resourceSet.getResources().add(asStringResource);
- // EmbeddedXtextResource asStringResource = new EmbeddedXtextResource();
- asStringResource.setURI(URI.createURI("asStringResource." + fFileExtension)); //$NON-NLS-1$
- asStringResource.setParentResource(eObject.eResource());
- try {
- asStringResource.load(new StringInputStream(asString), Collections.emptyMap());
- if(!asStringResource.getContents().isEmpty()) {
- asStringEObject = asStringResource.getContents().get(0);
- }
- } catch (IOException e) {
- // ignore, will set the string to the serialization of the given eObject
- }
-
- try {
- EcoreUtil.resolveAll(asStringResource);
- } catch (Exception e) {
- // ignore
- }
-
- if(!asStringResource.getErrors().isEmpty() || (asStringResource.getParseResult() != null && !asStringResource.getParseResult().getParseErrors().isEmpty())) {
- // if there are parsing errors in the saved string, then we update with it
- update(asString);
- } else if(asStringEObject != null) {
- try {
- // Resource copyResource = (XtextResource) fResourceSetProvider.get(null).createResource(URI.createURI("copyResource." + fFileExtension));
- // EmbeddedXtextResource copyResource = (EmbeddedXtextResource) fResourceSetProvider.get(null).createResource(URI.createURI("copyResource." + fFileExtension));
- EmbeddedXtextResource copyResource = fEmbeddedXtextResourceProvider.get();
- // EmbeddedXtextResource copyResource = new EmbeddedXtextResource();
- copyResource.setURI(URI.createURI("copyResource." + fFileExtension)); //$NON-NLS-1$
- copyResource.setParentResource(eObject.eResource());
- try {
- EObject copyEObject = EcoreUtil.copy(eObject);
- copyResource.getContents().add(copyEObject);
- EcoreUtil.resolveAll(copyResource);
- if(!equals(copyEObject, asStringEObject)) {
- // String model = getResource().getSerializer().serialize(copyEObject, SaveOptions.newBuilder().noValidation().format().getOptions());
- update(asString); // FIXME: should update with the serialized form of the copyEObject but throw RuntimeException!!!
- } else {
- // if there is no error and the content are equals, then we also update with the string
- update(asString);
- }
- } catch (Exception e) {
- update(asString);
- }
-
- copyResource.unload();
- } catch (Exception e) {
- update(asString);
- }
- } else {
- update("");
- }
-
- asStringResource.unload();
- asStringResource.getResourceSet().getResources().remove(asStringResource);
- } else {
- update("");
- }
- }
-
- private void createActions() {
- {
- TextViewerAction action = new TextViewerAction(fSourceViewer, ITextOperationTarget.CUT);
- action.setText("Cut");
- setAction(ITextEditorActionConstants.CUT, action);
- setAsSelectionDependantAction(action);
- }
-
- {
- TextViewerAction action = new TextViewerAction(fSourceViewer, ITextOperationTarget.COPY);
- action.setText("Copy");
- setAction(ITextEditorActionConstants.COPY, action);
- setAsSelectionDependantAction(action);
- }
-
- {
- TextViewerAction action = new TextViewerAction(fSourceViewer, ITextOperationTarget.PASTE);
- action.setText("Paste");
- setAction(ITextEditorActionConstants.PASTE, action);
- setAsSelectionDependantAction(action);
- }
-
- {
- TextViewerAction action = new TextViewerAction(fSourceViewer, ISourceViewer.CONTENTASSIST_PROPOSALS);
- action.setText("Content Assist");
- setAction(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, action);
- setAsContextDependantAction(action);
- }
-
- if(fViewerConfiguration.getContentFormatter(fSourceViewer) != null) {
- TextViewerAction action = new TextViewerAction(fSourceViewer, ISourceViewer.FORMAT);
- action.setText("Format");
- setAction(XTEXT_UI_FORMAT_ACTION, action);
- setAsContextDependantAction(action);
- }
-
- {
- ToggleSLCommentAction action = new ToggleSLCommentAction(fSourceViewer);
- setAction(XTEXT_UI_TOGGLE_SL_COMMENT_ACTION, action);
- setAsContextDependantAction(action);
- action.configure(fSourceViewer, fViewerConfiguration);
- }
- }
-
- private void setAction(String actionID, IAction action) {
- if(action.getId() == null)
- action.setId(actionID); // make sure the action ID has been set
-
- fActions.put(actionID, action);
- }
-
- private void setAsContextDependantAction(IAction action) {
- fActionHandlers.add(new ActionHandler(action));
- }
-
- private void setAsSelectionDependantAction(IAction action) {
- fSelectionDependentActions.add(action);
- }
-
- private void updateSelectionDependentActions() {
- for(IAction action : fSelectionDependentActions) {
- if(action instanceof IUpdate) {
- ((IUpdate)action).update();
- }
- }
- }
-
- protected void updateAction(IAction action) {
- //Nothing
- }
-
- private Map<String, IAction> fActions = Maps.newHashMap();
-
- private List<IAction> fSelectionDependentActions = Lists.newArrayList();
-
- private List<ActionHandler> fActionHandlers = Lists.newArrayList();
-
- /**
- * Source viewer focus listener that activates/deactivates action handlers on focus state change.
- *
- * @author Mikaël Barbero
- *
- */
- private final class SourceViewerFocusListener implements FocusListener {
-
- private static final String EMBEDEDXTEXT_EDITOR_CONTEXT = "org.eclipselabs.xtfo.embededxtextEditor.context"; //$NON-NLS-1$
-
- private final Expression fExpression;
-
- private final List<IHandlerActivation> fHandlerActivations;
-
- private IContextActivation fContextActivation;
-
- public SourceViewerFocusListener() {
- fExpression = new ActiveShellExpression(fSourceViewer.getControl().getShell());
- fHandlerActivations = Lists.newArrayList();
-
- fSourceViewer.getControl().addDisposeListener(new DisposeListener() {
-
- public void widgetDisposed(DisposeEvent e) {
- IHandlerService handlerService = (IHandlerService)PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
- handlerService.deactivateHandlers(fHandlerActivations);
- fHandlerActivations.clear();
- }
- });
- }
-
- public void focusLost(FocusEvent e) {
- if(fContextActivation != null) {
-
- IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
-
- if(activeEditor != null) {
- IContextService contextService = (IContextService)activeEditor.getSite().getService(IContextService.class);
-
- contextService.deactivateContext(fContextActivation);
- }
- }
-
- IHandlerService handlerService = (IHandlerService)PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
- handlerService.deactivateHandlers(fHandlerActivations);
- }
-
- public void focusGained(FocusEvent e) {
- IContextService contextService = (IContextService)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getSite().getService(IContextService.class);
- fContextActivation = contextService.activateContext(EMBEDEDXTEXT_EDITOR_CONTEXT);
-
- IHandlerService handlerService = (IHandlerService)PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
-
- for(ActionHandler actionHandler : fActionHandlers) {
- fHandlerActivations.add(handlerService.activateHandler(actionHandler.getAction().getId(), actionHandler, fExpression));
- }
- }
- }
-
- protected EmbeddedXtextResource createResource() {
- ResourceSet resourceSet = fResourceSetProvider.get(null);
- // XtextResource result = (XtextResource) resourceSet.createResource(
- // URI.createURI(fGrammarAccess.getGrammar().getName() + "." + fFileExtension));
- EmbeddedXtextResource result = fEmbeddedXtextResourceProvider.get();
- result.setURI(URI.createURI(fGrammarAccess.getGrammar().getName() + "." + fFileExtension)); //$NON-NLS-1$
- resourceSet.getResources().add(result);
- return result;
- }
-
- private static boolean equals(EObject expected, EObject actual) {
- Map<String, Object> options = ImmutableMap.<String, Object> builder().put(MatchOptions.OPTION_IGNORE_XMI_ID, Boolean.TRUE).build();
- MatchModel match = null;
- try {
- match = MatchService.doMatch(expected, actual, options);
- DiffModel diff = DiffService.doDiff(match, false);
- return diff.getDifferences().isEmpty();
- } catch (InterruptedException e) {
- throw new AssertionError(e);
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/EmbeddedXtextResource.java b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/EmbeddedXtextResource.java
deleted file mode 100644
index 8a240da..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/EmbeddedXtextResource.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.xtext.widgets.embedded;
-
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.xtext.linking.lazy.LazyLinkingResource;
-
-public class EmbeddedXtextResource extends LazyLinkingResource {
-
- private Resource parentResource = null;
-
- public Resource getParentResource() {
- return parentResource;
- }
-
- public void setParentResource(Resource parentResource) {
- this.parentResource = parentResource;
- }
-
- public EmbeddedXtextResource() {
- super();
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/HighlightingHelper.java b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/HighlightingHelper.java
deleted file mode 100644
index 425389c..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/HighlightingHelper.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.xtext.widgets.embedded;
-
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.xtext.ui.editor.XtextPresentationReconciler;
-import org.eclipse.xtext.ui.editor.XtextSourceViewer;
-import org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration;
-import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreAccess;
-import org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingPresenter;
-
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-/**
- * @author Sebastian Zarnekow - Initial contribution and API
- */
-public class HighlightingHelper implements IPropertyChangeListener {
-
- @Inject
- private Provider<HighlightingReconciler> reconcilerProvider;
-
- @Inject
- private Provider<HighlightingPresenter> presenterProvider;
-
- @Inject
- private IPreferenceStoreAccess preferenceStoreAccessor;
-
- /** Highlighting presenter */
- @Inject
- private HighlightingPresenter fPresenter;
-
- /** Highlighting reconciler */
- @Inject
- private HighlightingReconciler fReconciler;
-
- /** The source viewer */
- private XtextSourceViewer fSourceViewer;
-
- /** The source viewer configuration */
- private XtextSourceViewerConfiguration fConfiguration;
-
- /** The presentation reconciler */
- private XtextPresentationReconciler fPresentationReconciler;
-
- public void install(XtextSourceViewerConfiguration configuration, XtextSourceViewer sourceViewer) {
- fSourceViewer = sourceViewer;
- fConfiguration = configuration;
-
- fPresentationReconciler = (XtextPresentationReconciler)fConfiguration.getPresentationReconciler(sourceViewer);
- preferenceStoreAccessor.getPreferenceStore().addPropertyChangeListener(this);
- enable();
- }
-
- /**
- * Enable advanced highlighting.
- */
- private void enable() {
- fPresenter = getPresenterProvider().get();
- fPresenter.install(fSourceViewer, fPresentationReconciler);
-
- if(fSourceViewer.getDocument() != null) {
- fReconciler = reconcilerProvider.get();
- fReconciler.install(fSourceViewer, fPresenter);
- }
- }
-
- public void uninstall() {
- disable();
- preferenceStoreAccessor.getPreferenceStore().removePropertyChangeListener(this);
- fSourceViewer = null;
- fConfiguration = null;
- fPresentationReconciler = null;
- }
-
- /**
- * Disable advanced highlighting.
- */
- private void disable() {
- if(fReconciler != null) {
- fReconciler.uninstall();
- fReconciler = null;
- }
-
- if(fPresenter != null) {
- fPresenter.uninstall();
- fPresenter = null;
- }
- }
-
- /**
- * Returns this hightlighter's reconciler.
- *
- * @return the highlighter reconciler or <code>null</code> if none
- */
- public HighlightingReconciler getReconciler() {
- return fReconciler;
- }
-
- public void setReconcilerProvider(Provider<HighlightingReconciler> reconcilerProvider) {
- this.reconcilerProvider = reconcilerProvider;
- }
-
- public Provider<HighlightingReconciler> getReconcilerProvider() {
- return reconcilerProvider;
- }
-
- public void setPresenterProvider(Provider<HighlightingPresenter> presenterProvider) {
- this.presenterProvider = presenterProvider;
- }
-
- public Provider<HighlightingPresenter> getPresenterProvider() {
- return presenterProvider;
- }
-
- public void setPreferenceStoreAccessor(IPreferenceStoreAccess preferenceStoreAccessor) {
- this.preferenceStoreAccessor = preferenceStoreAccessor;
- }
-
- public IPreferenceStoreAccess getPreferenceStoreAccessor() {
- return preferenceStoreAccessor;
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- if(fReconciler != null && event.getProperty().contains(".syntaxColorer.tokenStyles")) //$NON-NLS-1$
- fReconciler.refresh();
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/HighlightingReconciler.java b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/HighlightingReconciler.java
deleted file mode 100644
index 4cb8173..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/HighlightingReconciler.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/**
- * Copyright (c) 2010 itemis AG (http://www.itemis.eu) and others.
- *
- * 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
- */
-package org.eclipse.papyrus.infra.xtext.widgets.embedded;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.xtext.resource.XtextResource;
-import org.eclipse.xtext.ui.editor.XtextSourceViewer;
-import org.eclipse.xtext.ui.editor.model.IXtextDocument;
-import org.eclipse.xtext.ui.editor.model.IXtextModelListener;
-import org.eclipse.xtext.ui.editor.model.XtextDocument;
-import org.eclipse.xtext.ui.editor.syntaxcoloring.AttributedPosition;
-import org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingPresenter;
-import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightedPositionAcceptor;
-import org.eclipse.xtext.ui.editor.syntaxcoloring.ISemanticHighlightingCalculator;
-import org.eclipse.xtext.ui.editor.syntaxcoloring.ITextAttributeProvider;
-import org.eclipse.xtext.ui.editor.syntaxcoloring.MergingHighlightedPositionAcceptor;
-import org.eclipse.xtext.util.concurrent.IUnitOfWork;
-
-import com.google.inject.Inject;
-
-/**
- * @author Sebastian Zarnekow - Initial contribution and API
- */
-public class HighlightingReconciler implements ITextInputListener, IXtextModelListener, IHighlightedPositionAcceptor {
-
- @Inject(optional=true)
- private ISemanticHighlightingCalculator calculator;
-
- @Inject
- private ITextAttributeProvider attributeProvider;
-
- /** The source viewer this highlighting reconciler is installed on */
- private XtextSourceViewer sourceViewer;
- /** The highlighting presenter */
- private HighlightingPresenter presenter;
-
- /** Background job's added highlighted positions */
- private final List<AttributedPosition> addedPositions = new ArrayList<AttributedPosition>();
- /** Background job's removed highlighted positions */
- private List<AttributedPosition> removedPositions = new ArrayList<AttributedPosition>();
- /** Number of removed positions */
- private int removedPositionCount;
-
- /**
- * Reconcile operation lock.
- *
- * @since 3.2
- */
- private final Object fReconcileLock = new Object();
- /**
- * <code>true</code> if any thread is executing <code>reconcile</code>, <code>false</code> otherwise.
- *
- * @since 3.2
- */
- private boolean reconciling = false;
-
- /**
- * Start reconciling positions.
- */
- private void startReconcilingPositions() {
- presenter.addAllPositions(removedPositions);
- removedPositionCount = removedPositions.size();
- }
-
- /**
- * Reconcile positions based on the AST subtrees
- *
- * @param subtrees
- * the AST subtrees
- */
- private void reconcilePositions(XtextResource resource) {
- // for (int i= 0, n= subtrees.length; i < n; i++)
- // subtrees[i].accept(fCollector);
- MergingHighlightedPositionAcceptor acceptor = new MergingHighlightedPositionAcceptor(calculator);
- acceptor.provideHighlightingFor(resource, this);
-// calculator.provideHighlightingFor(resource, this);
- List<AttributedPosition> oldPositions = removedPositions;
- List<AttributedPosition> newPositions = new ArrayList<AttributedPosition>(removedPositionCount);
- for (int i = 0, n = oldPositions.size(); i < n; i++) {
- AttributedPosition current = oldPositions.get(i);
- if (current != null)
- newPositions.add(current);
- }
- removedPositions = newPositions;
- }
-
- /**
- * Add a position with the given range and highlighting if it does not exist already.
- * @param offset The range offset
- * @param length The range length
- * @param highlighting The highlighting
- */
- public void addPosition(int offset, int length, String... ids) {
- TextAttribute highlighting = ids.length == 1 ?
- attributeProvider.getAttribute(ids[0])
- : attributeProvider.getMergedAttributes(ids);
- boolean isExisting= false;
- // TODO: use binary search
- for (int i= 0, n= removedPositions.size(); i < n; i++) {
- AttributedPosition position= removedPositions.get(i);
- if (position == null)
- continue;
- if (position.isEqual(offset, length, highlighting)) {
- isExisting= true;
- removedPositions.set(i, null);
- removedPositionCount--;
- break;
- }
- }
-
- if (!isExisting) {
- AttributedPosition position= presenter.createHighlightedPosition(offset, length, highlighting);
- addedPositions.add(position);
- }
- }
-
- /**
- * Update the presentation.
- *
- * @param textPresentation
- * the text presentation
- * @param addedPositions
- * the added positions
- * @param removedPositions
- * the removed positions
- */
- private void updatePresentation(TextPresentation textPresentation, List<AttributedPosition> addedPositions,
- List<AttributedPosition> removedPositions) {
- Runnable runnable = presenter.createUpdateRunnable(textPresentation, addedPositions, removedPositions);
- if (runnable == null)
- return;
-
- Display display = getDisplay();
- display.asyncExec(runnable);
- }
-
- private Display getDisplay() {
- return this.sourceViewer.getControl().getDisplay();
- }
-
- /**
- * Stop reconciling positions.
- */
- private void stopReconcilingPositions() {
- removedPositions.clear();
- removedPositionCount = 0;
- addedPositions.clear();
- }
-
- /**
- * Install this reconciler on the given editor and presenter.
- *
- * @param editor
- * the editor
- * @param sourceViewer
- * the source viewer
- * @param presenter
- * the highlighting presenter
- */
- public void install(XtextSourceViewer sourceViewer, HighlightingPresenter presenter) {
- this.presenter = presenter;
- this.sourceViewer = sourceViewer;
- if (calculator != null) {
- ((IXtextDocument) sourceViewer.getDocument()).addModelListener(this);
- sourceViewer.addTextInputListener(this);
- }
- refresh();
- }
-
- /**
- * Uninstall this reconciler from the editor
- */
- public void uninstall() {
- if (presenter != null)
- presenter.setCanceled(true);
-
- if (sourceViewer.getDocument() != null) {
- if (calculator != null) {
- XtextDocument document = (XtextDocument) sourceViewer.getDocument();
- document.removeModelListener(this);
- sourceViewer.removeTextInputListener(this);
- }
- }
-
- sourceViewer = null;
- presenter = null;
- }
-
- /*
- * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
- */
- public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- if (oldInput != null)
- ((IXtextDocument) oldInput).removeModelListener(this);
- }
-
- /*
- * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
- */
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
- if (newInput != null) {
- refresh();
- ((IXtextDocument) newInput).addModelListener(this);
- }
- }
-
- /**
- * Refreshes the highlighting.
- */
- public void refresh() {
- if (calculator != null) {
- ((XtextDocument) sourceViewer.getDocument()).readOnly(new IUnitOfWork.Void<XtextResource>() {
- @Override
- public void process(XtextResource state) throws Exception {
- modelChanged(state);
- }
- });
- } else {
- Display display = getDisplay();
- display.asyncExec(presenter.createSimpleUpdateRunnable());
- }
- }
-
- public void modelChanged(XtextResource resource) {
- // ensure at most one thread can be reconciling at any time
- synchronized (fReconcileLock) {
- if (reconciling)
- return;
- reconciling = true;
- }
- final HighlightingPresenter highlightingPresenter = presenter;
- try {
- if (highlightingPresenter == null)
- return;
-
- highlightingPresenter.setCanceled(false);
-
- if (highlightingPresenter.isCanceled())
- return;
-
- startReconcilingPositions();
-
- if (!highlightingPresenter.isCanceled()) {
- reconcilePositions(resource);
- }
-
- final TextPresentation[] textPresentation = new TextPresentation[1];
- if (!highlightingPresenter.isCanceled()) {
- textPresentation[0] = highlightingPresenter.createPresentation(addedPositions, removedPositions);
- }
-
- if (!highlightingPresenter.isCanceled())
- updatePresentation(textPresentation[0], addedPositions, removedPositions);
-
- stopReconcilingPositions();
- }
- finally {
- synchronized (fReconcileLock) {
- reconciling = false;
- }
- }
- }
-
- public void setCalculator(ISemanticHighlightingCalculator calculator) {
- this.calculator = calculator;
- }
-
- public ISemanticHighlightingCalculator getCalculator() {
- return calculator;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/TextViewerAction.java b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/TextViewerAction.java
deleted file mode 100644
index fca5e4e..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/TextViewerAction.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.xtext.widgets.embedded;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.ui.texteditor.IUpdate;
-
-public class TextViewerAction extends Action implements IUpdate {
-
- private int fOperationCode = -1;
-
- private ITextOperationTarget fOperationTarget;
-
- /**
- * Creates a new action.
- *
- * @param viewer
- * the viewer
- * @param operationCode
- * the opcode
- */
- public TextViewerAction(ITextViewer viewer, int operationCode) {
- fOperationCode = operationCode;
- fOperationTarget = viewer.getTextOperationTarget();
- update();
- }
-
- /**
- * Updates the enabled state of the action.
- * Fires a property change if the enabled state changes.
- *
- * @see Action#firePropertyChange(String, Object, Object)
- */
- public void update() {
- boolean wasEnabled = isEnabled();
- boolean isEnabled = (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
- setEnabled(isEnabled);
-
- if(wasEnabled != isEnabled) {
- firePropertyChange(ENABLED, wasEnabled ? Boolean.TRUE : Boolean.FALSE, isEnabled ? Boolean.TRUE : Boolean.FALSE);
- }
- }
-
- /**
- * @see Action#run()
- */
- @Override
- public void run() {
- if(fOperationCode != -1 && fOperationTarget != null) {
- fOperationTarget.doOperation(fOperationCode);
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/ToggleSLCommentAction.java b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/ToggleSLCommentAction.java
deleted file mode 100644
index 1ef1778..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/ToggleSLCommentAction.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.xtext.widgets.embedded;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.infra.xtext.widgets.Activator;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.texteditor.IUpdate;
-
-/**
- * This implementation has been copied from org.eclipse.jdt.internal.ui.javaeditor.ToggleCommentAction.
- *
- * @author Sebastian Zarnekow - Initial contribution and API
- * @author Mikaël Barbero - Changed from TextEditorAction to TextViewerAction as superclass.
- */
-public final class ToggleSLCommentAction extends Action implements IUpdate {
-
- private ITextOperationTarget fOperationTarget;
-
- private ITextViewer fViewer;
-
- /** The document partitioning */
- private String fDocumentPartitioning;
-
- /** The comment prefixes */
- private Map<String, String[]> fPrefixesMap;
-
- /**
- * Creates and initializes the action for the given text editor. The action
- * configures its visual representation from the given resource bundle.
- *
- * @param bundle
- * the resource bundle
- * @param prefix
- * a prefix to be prepended to the various resource keys
- * (described in <code>ResourceAction</code> constructor), or <code>null</code> if none
- * @param editor
- * the text editor
- * @see ResourceAction#ResourceAction(ResourceBundle, String, int)
- */
- public ToggleSLCommentAction(ITextViewer viewer) {
- fViewer = viewer;
- fOperationTarget = viewer.getTextOperationTarget();
- }
-
- /**
- * Implementation of the <code>IAction</code> prototype. Checks if the selected
- * lines are all commented or not and uncomments/comments them respectively.
- */
- @Override
- public void run() {
- if(fOperationTarget == null || fDocumentPartitioning == null || fPrefixesMap == null)
- return;
-
- final int operationCode;
- if(isSelectionCommented(fViewer.getSelectionProvider().getSelection()))
- operationCode = ITextOperationTarget.STRIP_PREFIX;
- else
- operationCode = ITextOperationTarget.PREFIX;
-
- Shell shell = fViewer.getTextWidget().getShell();
- if(!fOperationTarget.canDoOperation(operationCode)) {
- if(shell != null)
- MessageDialog.openError(shell, "An error occured", "ToggleComment_error_message=An error occurred while toggling comments.");
- return;
- }
-
- Display display = null;
- if(shell != null && !shell.isDisposed())
- display = shell.getDisplay();
-
- BusyIndicator.showWhile(display, new Runnable() {
-
- public void run() {
- fOperationTarget.doOperation(operationCode);
- }
- });
- }
-
- /**
- * Is the given selection single-line commented?
- *
- * @param selection
- * Selection to check
- * @return <code>true</code> iff all selected lines are commented
- */
- private boolean isSelectionCommented(ISelection selection) {
- if(!(selection instanceof ITextSelection))
- return false;
-
- ITextSelection textSelection = (ITextSelection)selection;
- if(textSelection.getStartLine() < 0 || textSelection.getEndLine() < 0)
- return false;
-
- IDocument document = fViewer.getDocument();
-
- try {
-
- IRegion block = getTextBlockFromSelection(textSelection, document);
- ITypedRegion[] regions = TextUtilities.computePartitioning(document, fDocumentPartitioning, block.getOffset(), block.getLength(), false);
-
- int[] lines = new int[regions.length * 2]; // [startline, endline, startline, endline, ...]
- for(int i = 0, j = 0; i < regions.length; i++, j += 2) {
- // start line of region
- lines[j] = getFirstCompleteLineOfRegion(regions[i], document);
- // end line of region
- int length = regions[i].getLength();
- int offset = regions[i].getOffset() + length;
- if(length > 0)
- offset--;
- lines[j + 1] = (lines[j] == -1 ? -1 : document.getLineOfOffset(offset));
- }
-
- // Perform the check
- for(int i = 0, j = 0; i < regions.length; i++, j += 2) {
- String[] prefixes = fPrefixesMap.get(regions[i].getType());
- if(prefixes != null && prefixes.length > 0 && lines[j] >= 0 && lines[j + 1] >= 0)
- if(!isBlockCommented(lines[j], lines[j + 1], prefixes, document))
- return false;
- }
-
- return true;
-
- } catch (BadLocationException x) {
- // should not happen
- Activator.log.error(x);
- }
-
- return false;
- }
-
- /**
- * Creates a region describing the text block (something that starts at
- * the beginning of a line) completely containing the current selection.
- *
- * @param selection
- * The selection to use
- * @param document
- * The document
- * @return the region describing the text block comprising the given selection
- */
- private IRegion getTextBlockFromSelection(ITextSelection selection, IDocument document) {
-
- try {
- IRegion line = document.getLineInformationOfOffset(selection.getOffset());
- int length = selection.getLength() == 0 ? line.getLength() : selection.getLength() + (selection.getOffset() - line.getOffset());
- return new Region(line.getOffset(), length);
-
- } catch (BadLocationException x) {
- // should not happen
- Activator.log.error(x);
- }
-
- return null;
- }
-
- /**
- * Returns the index of the first line whose start offset is in the given text range.
- *
- * @param region
- * the text range in characters where to find the line
- * @param document
- * The document
- * @return the first line whose start index is in the given range, -1 if there is no such line
- */
- private int getFirstCompleteLineOfRegion(IRegion region, IDocument document) {
-
- try {
-
- int startLine = document.getLineOfOffset(region.getOffset());
-
- int offset = document.getLineOffset(startLine);
- if(offset >= region.getOffset())
- return startLine;
-
- offset = document.getLineOffset(startLine + 1);
- return (offset > region.getOffset() + region.getLength() ? -1 : startLine + 1);
-
- } catch (BadLocationException x) {
- // should not happen
- Activator.log.error(x);
- }
-
- return -1;
- }
-
- /**
- * Determines whether each line is prefixed by one of the prefixes.
- *
- * @param startLine
- * Start line in document
- * @param endLine
- * End line in document
- * @param prefixes
- * Possible comment prefixes
- * @param document
- * The document
- * @return <code>true</code> iff each line from <code>startLine</code> to and including <code>endLine</code> is prepended by one
- * of the <code>prefixes</code>, ignoring whitespace at the
- * begin of line
- */
- private boolean isBlockCommented(int startLine, int endLine, String[] prefixes, IDocument document) {
-
- try {
-
- // check for occurrences of prefixes in the given lines
- for(int i = startLine; i <= endLine; i++) {
-
- IRegion line = document.getLineInformation(i);
- String text = document.get(line.getOffset(), line.getLength());
-
- int[] found = TextUtilities.indexOf(prefixes, text, 0);
-
- if(found[0] == -1)
- // found a line which is not commented
- return false;
-
- String s = document.get(line.getOffset(), found[0]);
- s = s.trim();
- if(s.length() != 0)
- // found a line which is not commented
- return false;
-
- }
-
- return true;
-
- } catch (BadLocationException x) {
- // should not happen
- Activator.log.error(x);
- }
-
- return false;
- }
-
- /**
- * Implementation of the <code>IUpdate</code> prototype method discovers
- * the operation through the current editor's <code>ITextOperationTarget</code> adapter, and sets the enabled state
- * accordingly.
- */
- public void update() {
- boolean isEnabled = (fOperationTarget != null && fOperationTarget.canDoOperation(ITextOperationTarget.PREFIX) && fOperationTarget.canDoOperation(ITextOperationTarget.STRIP_PREFIX));
- setEnabled(isEnabled);
- }
-
- public void configure(ISourceViewer sourceViewer, SourceViewerConfiguration configuration) {
- fPrefixesMap = null;
-
- String[] types = configuration.getConfiguredContentTypes(sourceViewer);
- Map<String, String[]> prefixesMap = new HashMap<String, String[]>(types.length);
- for(int i = 0; i < types.length; i++) {
- String type = types[i];
- String[] prefixes = configuration.getDefaultPrefixes(sourceViewer, type);
- if(prefixes != null && prefixes.length > 0) {
- int emptyPrefixes = 0;
- for(int j = 0; j < prefixes.length; j++)
- if(prefixes[j].length() == 0)
- emptyPrefixes++;
-
- if(emptyPrefixes > 0) {
- String[] nonemptyPrefixes = new String[prefixes.length - emptyPrefixes];
- for(int j = 0, k = 0; j < prefixes.length; j++) {
- String prefix = prefixes[j];
- if(prefix.length() != 0) {
- nonemptyPrefixes[k] = prefix;
- k++;
- }
- }
- prefixes = nonemptyPrefixes;
- }
-
- prefixesMap.put(type, prefixes);
- }
- }
- fDocumentPartitioning = configuration.getConfiguredDocumentPartitioning(sourceViewer);
- fPrefixesMap = prefixesMap;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/XTextEditor.java b/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/XTextEditor.java
deleted file mode 100644
index dd9f856..0000000
--- a/deprecated/org.eclipse.papyrus.infra.xtext.widgets/src/org/eclipse/papyrus/infra/xtext/widgets/embedded/XTextEditor.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.xtext.widgets.embedded;
-
-import org.eclipse.papyrus.infra.widgets.editors.AbstractValueEditor;
-import org.eclipse.swt.widgets.Composite;
-
-
-public class XTextEditor extends AbstractValueEditor {
-
- public XTextEditor(Composite parent, int style) {
- super(parent, style);
- }
-
- @Override
- public Object getValue() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Object getEditableType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void setReadOnly(boolean readOnly) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public boolean isReadOnly() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public void setToolTipText(String text) {
- // TODO Auto-generated method stub
- }
-
-}