Improve Preference Page's Preview
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/IntentMultiPageEditor.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/IntentMultiPageEditor.java
index aa2cd00..1a58a5f 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/IntentMultiPageEditor.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/IntentMultiPageEditor.java
@@ -154,7 +154,7 @@
@Override
protected void pageChange(int newPageIndex) {
super.pageChange(newPageIndex);
- if (newPageIndex == 1) {
+ if (browser != null && newPageIndex == 1) {
// Refresh browser URL in case section was renamed
browser.setUrl(getHTMLPreviewURL());
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferencePage.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferencePage.java
index df0e6cc..e47908b 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferencePage.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/preferences/IntentPreferencePage.java
@@ -58,7 +58,7 @@
public static final String LINK_DROPPED_ELEMENTS_USING_EXTERNAL_REFERENCES = "Link dropped elements using External References";
- private static final String INTENT_PREVIEW_EXAMPLE = "Section Title {\n\t Default text \n\t\"Strings\"\n\t* lists\n\t!images!\n\t\n\t@M\n\t\tnew Element{}\n\tM@\n}";
+ private static final String INTENT_PREVIEW_EXAMPLE = "Section Title {\n\tDefault text \n\t\"Strings\"\n\t@Code@\n\t* lists\n\t!images!\n\t\n\t@M\n\t\tnew Element{}\n\tM@\n}";
private RefreshPreviewEditorListener refreshPreviewEditorListener;
@@ -185,10 +185,10 @@
// Create preview viewer
Label infoLabel2 = new Label(colorComposite, SWT.NONE);
infoLabel2.setText("Preview: ");
- IntentEditorDocument document = createIntentPreviewViewer(colorComposite);
+ createIntentPreviewViewer(colorComposite);
// Add change listener so that preview is refreshed when changing a color
- this.refreshPreviewEditorListener = new RefreshPreviewEditorListener(document);
+ this.refreshPreviewEditorListener = new RefreshPreviewEditorListener();
getPreferenceStore().addPropertyChangeListener(refreshPreviewEditorListener);
return colorComposite;
}
@@ -283,7 +283,7 @@
* the parent of the source viewer to create
* @return a source viewer allowing to preview an Intent document (to see impact of color changes)
*/
- private IntentEditorDocument createIntentPreviewViewer(Composite parent) {
+ private void createIntentPreviewViewer(Composite parent) {
editor = new IntentEditorImpl();
IntentEditorDocument document = new IntentEditorDocument(editor);
partitioner = new FastPartitioner(new IntentPartitionScanner(),
@@ -309,7 +309,6 @@
sourceViewer.getTextWidget().setFont(JFaceResources.getTextFont());
sourceViewer.setDocument(document);
document.set(INTENT_PREVIEW_EXAMPLE);
- return document;
}
/**
@@ -394,27 +393,15 @@
*/
private class RefreshPreviewEditorListener implements IPropertyChangeListener {
- private IntentEditorDocument document;
-
- /**
- * Constructor.
- *
- * @param document
- * the document to refresh
- */
- public RefreshPreviewEditorListener(IntentEditorDocument document) {
- this.document = document;
- }
-
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
public void propertyChange(PropertyChangeEvent event) {
- // TODO REFRESH PREVIEW VIEW
+ sourceViewer.unconfigure();
+ sourceViewer.configure(new IntentEditorConfiguration(editor, null));
}
-
}
// CHECKSTYLE:OFF
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/src/org/eclipse/mylyn/docs/intent/exporter/ui/IntentPreviewView.java b/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/src/org/eclipse/mylyn/docs/intent/exporter/ui/IntentPreviewView.java
index fb028b5..ebf74ce 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/src/org/eclipse/mylyn/docs/intent/exporter/ui/IntentPreviewView.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/src/org/eclipse/mylyn/docs/intent/exporter/ui/IntentPreviewView.java
@@ -123,7 +123,7 @@
}
private void refreshPreviewView(IWorkbenchPart activeEditor, boolean setURL) {
- if (!browser.isDisposed() && activeEditor instanceof IEditorPart
+ if (browser != null && !browser.isDisposed() && activeEditor instanceof IEditorPart
&& ((IEditorPart)activeEditor).getEditorInput() instanceof IntentEditorInput) {
if (!IntentPreferenceService.getBoolean(IntentPreferenceConstants.SHOW_PREVIEW_PAGE)) {
browser.setText(PREF_NOT_ACTIVATED_MESSAGE);