Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.richtext/src/org/eclipse/papyrus/uml/nattable/richtext/celleditor/config/RichTextCellEditorConfiguration.java86
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.richtext/src/org/eclipse/papyrus/uml/nattable/richtext/cellpainter/PapyrusRichTextCellPainter.java5
2 files changed, 86 insertions, 5 deletions
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.richtext/src/org/eclipse/papyrus/uml/nattable/richtext/celleditor/config/RichTextCellEditorConfiguration.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.richtext/src/org/eclipse/papyrus/uml/nattable/richtext/celleditor/config/RichTextCellEditorConfiguration.java
index 4103bb8001c..4d517483fe5 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.richtext/src/org/eclipse/papyrus/uml/nattable/richtext/celleditor/config/RichTextCellEditorConfiguration.java
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.richtext/src/org/eclipse/papyrus/uml/nattable/richtext/celleditor/config/RichTextCellEditorConfiguration.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2016, 2017 CEA LIST and others.
+ * Copyright (c) 2016, 2017, 2018 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,10 +10,12 @@
* Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr
* Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 527733
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 535545
*****************************************************************************/
package org.eclipse.papyrus.uml.nattable.richtext.celleditor.config;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
@@ -24,7 +26,9 @@ import org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter;
import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter;
import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.nebula.widgets.richtext.RichTextPainter;
import org.eclipse.papyrus.infra.emf.nattable.celleditor.config.SingleStringCellEditorConfiguration;
+import org.eclipse.papyrus.infra.emf.utils.TextReferencesHelper;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
@@ -36,6 +40,9 @@ import org.eclipse.papyrus.infra.ui.preferences.RichtextPreferencePage;
import org.eclipse.papyrus.uml.nattable.richtext.celleditor.RichTextCellEditorWithUMLReferences;
import org.eclipse.papyrus.uml.nattable.richtext.celleditor.config.messages.Messages;
import org.eclipse.papyrus.uml.nattable.richtext.cellpainter.PapyrusRichTextCellPainter;
+import org.eclipse.papyrus.uml.tools.namereferences.NameReferencesHelper;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.uml2.uml.UMLPackage;
/**
@@ -122,19 +129,92 @@ public class RichTextCellEditorConfiguration extends SingleStringCellEditorConfi
// If nattable model could be retrieved
if (null != nattableManager && null != nattableManager.getTable()) {
final Table table = nattableManager.getTable();
+ final TextReferencesHelper helper = new NameReferencesHelper(table.getContext().eResource());
+
// Get wraptext and auto resize cell height boolean value from the table
final boolean wrapTextFlag = StyleUtils.getBooleanNamedStyleValue(table, NamedStyleConstants.WRAP_TEXT);
final boolean autoResizeCellHeightFlag = StyleUtils.getBooleanNamedStyleValue(table, NamedStyleConstants.AUTO_RESIZE_CELL_HEIGHT);
// Then create the richtext cell painter with these values as parameters
- return new BackgroundPainter(new PaddingDecorator(new PapyrusRichTextCellPainter(wrapTextFlag, false, autoResizeCellHeightFlag), 2, 5, 2, 5));
+ final PapyrusRichTextCellPainter pCellPainter = new CustomPapyrusRichTextCellPainter(wrapTextFlag, false, autoResizeCellHeightFlag, helper);
+ return new BackgroundPainter(new PaddingDecorator(pCellPainter, 2, 5, 2, 5));
} else {
// Otherwise, create the richtext cell painter without parameters
- return new BackgroundPainter(new PaddingDecorator(new PapyrusRichTextCellPainter(), 2, 5, 2, 5));
+ return new BackgroundPainter(new PaddingDecorator(new PapyrusRichTextCellPainter(), 2, 5, 2, 5));
}
}
return super.getCellPainter(configRegistry, axis, configLabel);
}
+
+ /**
+ *
+ * A Richtext cell painter using the Papyrus Richtext Painter
+ *
+ */
+ private class CustomPapyrusRichTextCellPainter extends PapyrusRichTextCellPainter {
+
+ /**
+ * the helper used to replace link to element by a string representing them
+ */
+ private final TextReferencesHelper helper;
+
+ /**
+ * Constructor.
+ *
+ * @param wrapText
+ * @param calculateByTextLength
+ * @param calculateByTextHeight
+ * @param helper
+ * the helper used to replace link to element by a string representing them
+ */
+ public CustomPapyrusRichTextCellPainter(final boolean wrapText, final boolean calculateByTextLength, final boolean calculateByTextHeight, final TextReferencesHelper helper) {
+ super(wrapText, calculateByTextLength, calculateByTextHeight);
+ Assert.isNotNull(helper);
+ this.helper = helper;
+ this.richTextPainter = new PapyrusRichTextPainter(wrapText, this.helper);
+ }
+ }
+
+
+ /**
+ *
+ * @author Vincent LORENZO
+ *
+ * An extension of the richtext painter, which is able to replace the @link intriduced by Papyrus to reference UML models elements, by the label of these elements
+ *
+ */
+ private class PapyrusRichTextPainter extends RichTextPainter {
+
+ /**
+ * the helper used to replace link to element by a string representing them
+ */
+
+ private final TextReferencesHelper helper;
+
+ /**
+ * Constructor.
+ *
+ * @param wordWrap
+ */
+ public PapyrusRichTextPainter(final boolean wordWrap, final TextReferencesHelper helper) {
+ super(wordWrap);
+ this.helper = helper;
+ }
+
+
+ /**
+ * @see org.eclipse.nebula.widgets.richtext.RichTextPainter#paintHTML(java.lang.String, org.eclipse.swt.graphics.GC, org.eclipse.swt.graphics.Rectangle)
+ *
+ * @param html
+ * @param gc
+ * @param bounds
+ */
+ @Override
+ public void paintHTML(String html, GC gc, Rectangle bounds) {
+ super.paintHTML(this.helper.replaceReferences(html), gc, bounds);
+ }
+ }
+
} \ No newline at end of file
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.richtext/src/org/eclipse/papyrus/uml/nattable/richtext/cellpainter/PapyrusRichTextCellPainter.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.richtext/src/org/eclipse/papyrus/uml/nattable/richtext/cellpainter/PapyrusRichTextCellPainter.java
index 15f6909acf8..0741b0149f8 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.richtext/src/org/eclipse/papyrus/uml/nattable/richtext/cellpainter/PapyrusRichTextCellPainter.java
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.richtext/src/org/eclipse/papyrus/uml/nattable/richtext/cellpainter/PapyrusRichTextCellPainter.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2017 CEA LIST and others.
+ * Copyright (c) 2017, 2018 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 527733
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 535545
*****************************************************************************/
package org.eclipse.papyrus.uml.nattable.richtext.cellpainter;
@@ -34,7 +35,7 @@ public class PapyrusRichTextCellPainter extends RichTextCellPainter {
* Create a new {@link PapyrusRichTextCellPainter} with text wrapping enabled and auto-resizing disabled.
*/
public PapyrusRichTextCellPainter() {
- super(true, false, false);
+ this(true, false, false);
}
/**

Back to the top