Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Charles David2017-08-24 08:06:02 +0000
committerJoao Barata2017-08-28 11:00:02 +0000
commit8eaad9253d1b8020fd9389232d43a95359e33c41 (patch)
treea04f4eb9e74897fbb3b3aef4b8f08fcbd99f34b9
parent87ea675af5108bf0ed8db6edfa2fe946847288ef (diff)
downloadorg.eclipse.amalgam-8eaad9253d1b8020fd9389232d43a95359e33c41.tar.gz
org.eclipse.amalgam-8eaad9253d1b8020fd9389232d43a95359e33c41.tar.xz
org.eclipse.amalgam-8eaad9253d1b8020fd9389232d43a95359e33c41.zip
[509735] Cleanup HTMLHelper
Make HTMLHelper independant of the "Page" type, to allow its reuse in different contexts. Bug: 509735 Change-Id: I330743db4c2aff59e14475bb01fbf1ce7d8237b2 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
-rw-r--r--plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/ActivityExplorerPage.java2
-rw-r--r--plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/OverviewActivityExplorerPage.java4
-rw-r--r--plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/helper/HTMLHelper.java113
3 files changed, 49 insertions, 70 deletions
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/ActivityExplorerPage.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/ActivityExplorerPage.java
index 8b9fec9e..30f6223c 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/ActivityExplorerPage.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/ActivityExplorerPage.java
@@ -222,7 +222,7 @@ public class ActivityExplorerPage extends CommonActivityExplorerPage implements
final IFormPage nextPage = getEditor().getNextPage(this);
// create rich text
- String body = HTMLHelper.breadcrumbForm(previousPage, this, nextPage);
+ String body = HTMLHelper.breadcrumbForm(previousPage.getId(), this.getId(), nextPage.getId());
FormText richText = org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.helper.FormHelper.createRichText(managedForm.getToolkit(), sectionContainer, body,
new FormTextPageLinkAdapter(getEditor()));
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/OverviewActivityExplorerPage.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/OverviewActivityExplorerPage.java
index f1b85d9e..fd0dfe67 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/OverviewActivityExplorerPage.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/OverviewActivityExplorerPage.java
@@ -206,7 +206,7 @@ public class OverviewActivityExplorerPage extends CommonActivityExplorerPage {
if (page.isVisible()) {
// image
- String txt = HTMLHelper.imageLinkForm(page);
+ String txt = HTMLHelper.imageLinkForm(page.getId());
if (!(txt == null || txt.isEmpty())) {
richText = FormHelper.createRichText(managedForm.getToolkit(), composite, txt,
@@ -221,7 +221,7 @@ public class OverviewActivityExplorerPage extends CommonActivityExplorerPage {
layoutData.valign = TableWrapData.MIDDLE;
richText.setLayoutData(layoutData);
- txt = HTMLHelper.overviewDescForm(page);
+ txt = HTMLHelper.overviewDescForm(page.getOverViewText());
// Set Layout data.
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/helper/HTMLHelper.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/helper/HTMLHelper.java
index 5e9358b2..d9a3fab3 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/helper/HTMLHelper.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/helper/HTMLHelper.java
@@ -1,67 +1,46 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2015 THALES GLOBAL SERVICES.
- * 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:
- * Thales - initial API and implementation
- *******************************************************************************/
-package org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.helper;
-
-import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.CommonActivityExplorerPage;
-import org.eclipse.ui.forms.editor.IFormPage;
-
-public class HTMLHelper {
-
- public static String overviewDescForm(CommonActivityExplorerPage page) {
- String description = page.getOverViewText();
-
- return formWrapper2(description);
- }
-
- public static String imageLinkForm(IFormPage page) {
- String link = linkForm(page);
- return formWrapper(link);
- }
-
- public static String linkForm(IFormPage page) {
- String id = page.getId();
- String link = "<a href=\"" + id + "\"><img href=\"" + id //$NON-NLS-1$ //$NON-NLS-2$
- + "\"/>" + "</a>"; //$NON-NLS-1$ //$NON-NLS-2$
- return link;
- }
-
- public static String breadcrumbForm(IFormPage previous, IFormPage current, IFormPage next) {
- String txt = ""; //$NON-NLS-1$
-
- if (previous != null)
- txt += linkForm(previous);
- if (current != null)
- txt += linkForm(current);
- if (next != null)
- txt += linkForm(next);
-
- return formWrapper(txt);
- }
-
- public static String formWrapper(String txt) {
- StringBuffer buffer = new StringBuffer();
- buffer.append("<form>"); //$NON-NLS-1$
- buffer.append("<p>"); //$NON-NLS-1
- buffer.append(txt);
- buffer.append("</p>"); //$NON-NLS-1$
- buffer.append("</form>"); //$NON-NLS-1$
- return buffer.toString();
- }
-
- public static String formWrapper2(String txt) {
- StringBuffer buffer = new StringBuffer();
- buffer.append("<form>"); //$NON-NLS-1$
- buffer.append(txt);
- buffer.append("</form>"); //$NON-NLS-1$
- return buffer.toString();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2006, 2017 THALES GLOBAL SERVICES.
+ * 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:
+ * Thales - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.helper;
+
+public class HTMLHelper {
+
+ public static String overviewDescForm(String description) {
+ return formWrapper2(description);
+ }
+
+ public static String imageLinkForm(String id) {
+ String link = linkForm(id);
+ return formWrapper(link);
+ }
+
+ public static String linkForm(String id) {
+ return String.format("<a href=\"%s\"><img href=\"%s\"/></a>", id, id); //$NON-NLS-1$
+ }
+
+ public static String breadcrumbForm(String previous, String current, String next) {
+ String txt = ""; //$NON-NLS-1$
+ if (previous != null)
+ txt += linkForm(previous);
+ if (current != null)
+ txt += linkForm(current);
+ if (next != null)
+ txt += linkForm(next);
+ return formWrapper(txt);
+ }
+
+ public static String formWrapper(String txt) {
+ return String.format("<form><p>%s</p></form>", txt); //$NON-NLS-1$
+ }
+
+ public static String formWrapper2(String txt) {
+ return String.format("<form>%s</form>", txt); //$NON-NLS-1$
+ }
+}

Back to the top