Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarvin Mueller2014-08-29 12:21:49 +0000
committerMarvin Mueller2014-08-29 12:29:36 +0000
commit2583bfadba5f520a4386b951434375c052ac04e0 (patch)
tree4b2c426d86d7db6d3e0c8231ad2b71329fa9a998 /org.eclipse.jubula.client.wiki.ui
parent9b0dc10899639a3f6b832e1a66a2b4578ba5face (diff)
downloadorg.eclipse.jubula.core-2583bfadba5f520a4386b951434375c052ac04e0.tar.gz
org.eclipse.jubula.core-2583bfadba5f520a4386b951434375c052ac04e0.tar.xz
org.eclipse.jubula.core-2583bfadba5f520a4386b951434375c052ac04e0.zip
Sprint task - Adding markup languge chooser to project properties page
Diffstat (limited to 'org.eclipse.jubula.client.wiki.ui')
-rw-r--r--org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/dialogs/DescriptionEditDialog.java6
-rw-r--r--org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/utils/ProjectMarkupUtil.java63
-rw-r--r--org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/views/DescriptionView.java12
3 files changed, 76 insertions, 5 deletions
diff --git a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/dialogs/DescriptionEditDialog.java b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/dialogs/DescriptionEditDialog.java
index e8e68bcca..b933ebc88 100644
--- a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/dialogs/DescriptionEditDialog.java
+++ b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/dialogs/DescriptionEditDialog.java
@@ -19,8 +19,8 @@ import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jubula.client.core.model.INodePO;
import org.eclipse.jubula.client.ui.utils.DelayableTimer;
import org.eclipse.jubula.client.wiki.ui.i18n.Messages;
+import org.eclipse.jubula.client.wiki.ui.utils.ProjectMarkupUtil;
import org.eclipse.jubula.client.wiki.ui.Activator;
-import org.eclipse.mylyn.wikitext.tracwiki.core.TracWikiLanguage;
import org.eclipse.mylyn.wikitext.ui.editor.MarkupSourceViewer;
import org.eclipse.mylyn.wikitext.ui.editor.MarkupSourceViewerConfiguration;
import org.eclipse.mylyn.wikitext.ui.viewer.MarkupViewer;
@@ -142,7 +142,7 @@ public class DescriptionEditDialog extends TitleAreaDialog {
private MarkupSourceViewer createsMarkupSourceViewer(Composite parent,
int styles) {
final MarkupSourceViewer sourceViewer = new MarkupSourceViewer(parent,
- null, styles, new TracWikiLanguage());
+ null, styles, ProjectMarkupUtil.getProjectMarkupLanguage());
sourceViewer.setDocument(m_description);
MarkupSourceViewerConfiguration sourceViewerConfig =
new MarkupSourceViewerConfiguration(null);
@@ -165,7 +165,7 @@ public class DescriptionEditDialog extends TitleAreaDialog {
viewerConfiguration.setEnableSelfContainedIncrementalFind(true);
viewerConfiguration.setDisableHyperlinkModifiers(false);
viewer.configure(viewerConfiguration);
- viewer.setMarkupLanguage(new TracWikiLanguage());
+ viewer.setMarkupLanguage(ProjectMarkupUtil.getProjectMarkupLanguage());
viewer.getControl().setLayoutData(createGridData());
viewer.setDocument(new Document(m_workNode.getDescription()));
return viewer;
diff --git a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/utils/ProjectMarkupUtil.java b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/utils/ProjectMarkupUtil.java
new file mode 100644
index 000000000..aeb8c4856
--- /dev/null
+++ b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/utils/ProjectMarkupUtil.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2014 BREDEX GmbH.
+ * 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:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.wiki.ui.utils;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.jubula.client.core.model.IProjectPO;
+import org.eclipse.jubula.client.core.persistence.GeneralStorage;
+import org.eclipse.mylyn.wikitext.core.WikiText;
+import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage;
+import org.eclipse.jubula.client.ui.constants.Constants;
+/**
+ *
+ * @author BREDEX GmbH
+ */
+public class ProjectMarkupUtil {
+
+ /**
+ * Utils class for the markup language
+ */
+ private ProjectMarkupUtil() {
+ // this is a Util class
+ }
+
+ /**
+ * gets the MarkupLanguage for the loaded project, if not project is
+ * loaded it gives back the default language
+ * @return the {@link MarkupLanguage} from the project or the default
+ */
+ public static MarkupLanguage getProjectMarkupLanguage() {
+ IProjectPO project = GeneralStorage.getInstance().getProject();
+ if (project == null) {
+ return getDefaultMarkupLanguage();
+ }
+ return getMarkupForFileName(project.getMarkupLanguage());
+ }
+
+ /**
+ *
+ * @param markupLanguage null safe string name of the markup language
+ * @return the {@link MarkupLanguage} for the given string
+ */
+ public static MarkupLanguage getMarkupForFileName(String markupLanguage) {
+ if (StringUtils.isBlank(markupLanguage)) {
+ return getDefaultMarkupLanguage();
+ }
+ return WikiText.getMarkupLanguageForFilename(markupLanguage);
+ }
+
+ /** the default {@link MarkupLanguage} for the ite
+ * @return the default {@link MarkupLanguage} (MediaWikiLanguage)
+ */
+ public static MarkupLanguage getDefaultMarkupLanguage() {
+ return WikiText.getMarkupLanguageForFilename(Constants.DEFAULT_MARKUP);
+ }
+}
diff --git a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/views/DescriptionView.java b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/views/DescriptionView.java
index a9243e544..4e86c087c 100644
--- a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/views/DescriptionView.java
+++ b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/views/DescriptionView.java
@@ -11,6 +11,7 @@
package org.eclipse.jubula.client.wiki.ui.views;
import java.net.URL;
+
import org.apache.commons.lang.StringUtils;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.hyperlink.URLHyperlink;
@@ -21,10 +22,11 @@ import org.eclipse.jubula.client.core.events.DataEventDispatcher;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.IDataChangedListener;
import org.eclipse.jubula.client.core.model.IExecTestCasePO;
import org.eclipse.jubula.client.core.model.INodePO;
+import org.eclipse.jubula.client.core.model.IProjectPropertiesPO;
import org.eclipse.jubula.client.core.model.IRefTestSuitePO;
import org.eclipse.jubula.client.wiki.ui.i18n.Messages;
+import org.eclipse.jubula.client.wiki.ui.utils.ProjectMarkupUtil;
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser;
-import org.eclipse.mylyn.wikitext.mediawiki.core.MediaWikiLanguage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.LocationEvent;
@@ -120,7 +122,8 @@ public class DescriptionView extends ViewPart implements IDataChangedListener {
});
m_markupParser = new MarkupParser();
- m_markupParser.setMarkupLanguage(new MediaWikiLanguage());
+ m_markupParser.setMarkupLanguage(ProjectMarkupUtil
+ .getProjectMarkupLanguage());
getSite().getWorkbenchWindow().getSelectionService()
.addSelectionListener(m_listener);
@@ -142,6 +145,11 @@ public class DescriptionView extends ViewPart implements IDataChangedListener {
public void handleDataChanged(DataChangedEvent... events) {
boolean isRefreshNecessary = false;
for (DataChangedEvent dataChangedEvent : events) {
+ if (dataChangedEvent.getPo() instanceof IProjectPropertiesPO) {
+ m_markupParser.setMarkupLanguage(ProjectMarkupUtil
+ .getProjectMarkupLanguage());
+ isRefreshNecessary = true;
+ }
if (m_selectedNode.equals(dataChangedEvent.getPo())) {
isRefreshNecessary = true;
}

Back to the top