Skip to content

Commit

Permalink
Show the warning message(when prolog wasn't updated) in resultsManager.
Browse files Browse the repository at this point in the history
  • Loading branch information
DunaMariusCosmin committed Feb 5, 2018
1 parent 2922416 commit fb9914e
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions src/main/java/com/oxygenxml/prolog/updater/DitaUpdater.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.oxygenxml.prolog.updater;

import java.net.URL;
import com.oxygenxml.prolog.updater.dita.editor.DitaEditor;
import com.oxygenxml.prolog.updater.dita.editor.DitaTopicAuthorEditor;
import com.oxygenxml.prolog.updater.dita.editor.DitaTopicTextEditor;
import com.oxygenxml.prolog.updater.plugin.PrologUpdaterPlugin;
import com.oxygenxml.prolog.updater.prolog.content.PrologContentCreator;
import com.oxygenxml.prolog.updater.tags.OptionKeys;
import com.oxygenxml.prolog.updater.tags.Tags;
import com.oxygenxml.prolog.updater.utils.AWTUtil;

import ro.sync.document.DocumentPositionedInfo;
import ro.sync.exml.workspace.api.PluginResourceBundle;
import ro.sync.exml.workspace.api.PluginWorkspaceProvider;
import ro.sync.exml.workspace.api.editor.WSEditor;
Expand All @@ -16,6 +19,8 @@
import ro.sync.exml.workspace.api.editor.page.ditamap.WSDITAMapEditorPage;
import ro.sync.exml.workspace.api.editor.page.text.xml.WSXMLTextEditorPage;
import ro.sync.exml.workspace.api.options.WSOptionsStorage;
import ro.sync.exml.workspace.api.results.ResultsManager;
import ro.sync.exml.workspace.api.results.ResultsManager.ResultType;
import ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace;

/**
Expand All @@ -39,7 +44,7 @@ public class DitaUpdater {
* @param wsEditor
* Workspace editor.
*/
public void updateProlog(WSEditor wsEditor, final boolean isNewDocument) {
public void updateProlog(final WSEditor wsEditor, final boolean isNewDocument) {
// get the currentPage
WSEditorPage currentPage = wsEditor.getCurrentPage();

Expand Down Expand Up @@ -69,7 +74,7 @@ public void run() {
if (ditaEditor[0] != null) {
boolean wasUpdated = ditaEditor[0].updateProlog(isNewDocument);
if (!wasUpdated) {
showErrorMessage();
showWarnMessage(wsEditor);
}
}
}
Expand All @@ -95,12 +100,36 @@ protected String getAuthorName() {
return toReturn;
}

private void showErrorMessage() {
/**
* Show a warning message("The prolog wasn't updated") in results manager.
* @param wsEditor The workspace editor access.
*/
private void showWarnMessage(WSEditor wsEditor) {
StandalonePluginWorkspace pluginWorkspace = (StandalonePluginWorkspace) PluginWorkspaceProvider
.getPluginWorkspace();
if (pluginWorkspace != null) {

final ResultsManager resultsManager = pluginWorkspace.getResultsManager();
PluginResourceBundle messages = pluginWorkspace.getResourceBundle();
pluginWorkspace.showErrorMessage(messages.getMessage(Tags.ERROR_MESSAGE));
if(resultsManager != null && messages != null) {
// Get the message that will be showed.
final String message = messages.getMessage(Tags.ERROR_MESSAGE);
final URL editorLocation = wsEditor.getEditorLocation();

// Add the message in results manager.
DocumentPositionedInfo result = null;
if (editorLocation != null) {
result = new DocumentPositionedInfo(DocumentPositionedInfo.SEVERITY_WARN, message, editorLocation.toString());
} else {
result = new DocumentPositionedInfo(DocumentPositionedInfo.SEVERITY_WARN, message);
}

resultsManager.addResult(PrologUpdaterPlugin.getInstance().getDescriptor().getName(),
result,
ResultType.PROBLEM,
false,
false);
}
}
}
}

0 comments on commit fb9914e

Please sign in to comment.