diff options
author | Nicolas FAUVERGUE | 2017-04-24 16:26:18 +0000 |
---|---|---|
committer | vincent lorenzo | 2017-05-18 09:29:26 +0000 |
commit | 0c5113e025f33352d3a9c41d43656d3a60d5d555 (patch) | |
tree | 657f57ea8142153f3b8a374f4a032a59b0ca3489 /plugins/infra | |
parent | 87e59afcb3ab0a3419e731c33530b41fa6bc2611 (diff) | |
download | org.eclipse.papyrus-0c5113e025f33352d3a9c41d43656d3a60d5d555.tar.gz org.eclipse.papyrus-0c5113e025f33352d3a9c41d43656d3a60d5d555.tar.xz org.eclipse.papyrus-0c5113e025f33352d3a9c41d43656d3a60d5d555.zip |
Bug 515706: [Table][RichText] The RichText editor must be in agreement
with the preferences
https://bugs.eclipse.org/bugs/show_bug.cgi?id=515706
- Move the RichText preferences into infra.ui instead of
uml.diagram.common to use it in table.
- Use the preferences into nattable editors.
- Upgrade MANIFEST versions when needed.
Change-Id: Iee4505223a8e2de23c91a4d46f25ed2627fa04b1
Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins/infra')
6 files changed, 144 insertions, 4 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleStringCellEditorConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleStringCellEditorConfiguration.java index 546ce326c7d..0b44f941c68 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleStringCellEditorConfiguration.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleStringCellEditorConfiguration.java @@ -19,6 +19,8 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes; import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes; +import org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor; +import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter; import org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter; import org.eclipse.nebula.widgets.nattable.style.DisplayMode; import org.eclipse.papyrus.infra.emf.utils.EMFContants; @@ -95,6 +97,21 @@ public class SingleStringCellEditorConfiguration implements ICellAxisConfigurati */ @Override public void configureCellEditor(IConfigRegistry configRegistry, Object axis, String configLabel) { + configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, getCellPainter(configRegistry, axis, configLabel), DisplayMode.EDIT, configLabel); + configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, getCellEditor(configRegistry, axis, configLabel), DisplayMode.EDIT, configLabel); + // I believe that we don't need converters because we are working with the standard type --String. + // configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, null, DisplayMode.EDIT, configLabel); + } + + /** + * This allows to get the cell painter to use for the table. + * + * @return The cell painter. + * + * @since 3.0 + */ + protected ICellPainter getCellPainter(final IConfigRegistry configRegistry, final Object axis, final String configLabel) { + final INattableModelManager nattableManager = configRegistry.getConfigAttribute( NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, @@ -111,9 +128,17 @@ public class SingleStringCellEditorConfiguration implements ICellAxisConfigurati // TODO: using wordWrapping when upgrade to the new NatTable version // textPainter.setWordWrapping(true); - configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, textPainter, DisplayMode.NORMAL, configLabel); - configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new MultiLineTextCellEditorEx(true), DisplayMode.EDIT, configLabel); - // I believe that we don't need converters because we are working with the standard type --String. - // configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, null, DisplayMode.EDIT, configLabel); + return textPainter; + } + + /** + * This allows to get the cell editor to use for the table. + * + * @return The cell editor. + * + * @since 3.0 + */ + protected ICellEditor getCellEditor(final IConfigRegistry configRegistry, final Object axis, final String configLabel) { + return new MultiLineTextCellEditorEx(true); } } diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/plugin.xml b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/plugin.xml index ff9af9bae91..63a17356b45 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/plugin.xml +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/plugin.xml @@ -543,6 +543,9 @@ <initializer class="org.eclipse.papyrus.infra.ui.internal.preferences.EditorPreferences$Initializer"> </initializer> + <initializer + class="org.eclipse.papyrus.infra.ui.preferences.RichtextPreferenceInitializer"> + </initializer> </extension> <extension point="org.eclipse.ui.preferencePages"> @@ -552,6 +555,12 @@ id="org.eclipse.papyrus.infra.core.editorPrefs" name="Editor"> </page> + <page + category="org.eclipse.papyrus.infra.core.sasheditor.preferences.generalcategory" + class="org.eclipse.papyrus.infra.ui.preferences.RichtextPreferencePage" + id="org.eclipse.papyrus.infra.ui.RichtextPreferencePage" + name="Rich text"> + </page> </extension> <extension diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/messages/Messages.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/messages/Messages.java index 1a5703ed215..fbab3fc2dbd 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/messages/Messages.java +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/messages/Messages.java @@ -38,6 +38,12 @@ public class Messages extends NLS { public static String AbstractStringValueConverter_TheStringValueXCantBeResolved; public static String AbstractStringValueConverter_TheStringXIsNotValidToCreateY; + + public static String RichtextPreferencePage_Description; + + public static String RichtextPreferencePage_FirstBooleanEditorName; + + public static String RichtextPreferencePage_SecondBooleanEditorName; static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/messages/messages.properties b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/messages/messages.properties index 845a45e10ab..315ef860135 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/messages/messages.properties +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/messages/messages.properties @@ -8,3 +8,6 @@ AbstractStringValueConverter_SomeStringsCantBeResolvedToFindY=Some Strings can't AbstractStringValueConverter_TheFeatureXCantBeResolved=The feature {0} can't be resolved AbstractStringValueConverter_TheStringValueXCantBeResolved=The string value {0} can't be resolved AbstractStringValueConverter_TheStringXIsNotValidToCreateY=The String {0} is not valid to create {1} +RichtextPreferencePage_Description=Rich Text Preferences +RichtextPreferencePage_FirstBooleanEditorName=Use advanced rich text renderer (needs a reload of opened diagrams). Warning: may raise stability issues. +RichtextPreferencePage_SecondBooleanEditorName=Use advanced rich text editor diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/preferences/RichtextPreferenceInitializer.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/preferences/RichtextPreferenceInitializer.java new file mode 100644 index 00000000000..7a2f34a40ae --- /dev/null +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/preferences/RichtextPreferenceInitializer.java @@ -0,0 +1,42 @@ +/***************************************************************************** + * Copyright (c) 2016 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: + * Shuai Li (CEA LIST) shuai.li@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.ui.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.papyrus.infra.ui.Activator; + + +/** + * This preference initializer initializes Stereotype strategy preferences + * + * @since 2.0 + */ +public class RichtextPreferenceInitializer extends AbstractPreferenceInitializer { + + /** + * Initialize default preferences + */ + @Override + public void initializeDefaultPreferences() { + IPreferenceStore store = getPreferenceStore(); + store.setDefault(RichtextPreferencePage.USE_HTML_RENDERER, false); + store.setDefault(RichtextPreferencePage.USE_CK_EDITOR, false); + } + + /** + * Get the preference store + */ + protected IPreferenceStore getPreferenceStore() { + return Activator.getDefault().getPreferenceStore(); + } +} diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/preferences/RichtextPreferencePage.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/preferences/RichtextPreferencePage.java new file mode 100644 index 00000000000..10702ac9f12 --- /dev/null +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/preferences/RichtextPreferencePage.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * 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: + * Shuai Li (CEA List) <shuai.li@cea.fr> - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.infra.ui.preferences; + +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.papyrus.infra.ui.Activator; +import org.eclipse.papyrus.infra.ui.messages.Messages; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +/** + * Rich text preferences page to choose basic or advanced renderer + * + * @since 2.0 + */ +public class RichtextPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + public static final String USE_HTML_RENDERER = "useHtmlRenderer"; //$NON-NLS-1$ + public static final String USE_CK_EDITOR = "useCkEditor"; //$NON-NLS-1$ + + public RichtextPreferencePage() { + super(GRID); + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + setDescription(Messages.RichtextPreferencePage_Description); + } + + /** + * Creates the field editors. + */ + @Override + public void createFieldEditors() { + addField(new BooleanFieldEditor(USE_HTML_RENDERER, Messages.RichtextPreferencePage_FirstBooleanEditorName, getFieldEditorParent())); + addField(new BooleanFieldEditor(USE_CK_EDITOR, Messages.RichtextPreferencePage_SecondBooleanEditorName, getFieldEditorParent())); + } + + /** + * Init. + * + * @param workbench + * the workbench + */ + @Override + public void init(IWorkbench workbench) { + } + +} |