Author: mareshkau
Date: 2008-10-16 12:52:15 -0400 (Thu, 16 Oct 2008)
New Revision: 10895
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPContentOutlineConfiguration.java
Log:
JBIDE-2674, checks for null was added in case when visual editor plugin are not installed
in system, editor will be work only in source mode.
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2008-10-16
16:12:40 UTC (rev 10894)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2008-10-16
16:52:15 UTC (rev 10895)
@@ -88,7 +88,7 @@
IReusableEditor, ITextEditorExtension, ITextEditorExtension2,
ITextEditorExtension3, INavigationLocationProvider, IMultiPageEditor {
- public static final String EDITOR_ID =
"org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor";
+ public static final String EDITOR_ID =
"org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor"; //$NON-NLS-1$
private static final String VISUALSOURCE_TAB_LABEL =
"JSPMultiPageEditor.TabLabel.VisualSource"; //$NON-NLS-1$
@@ -108,8 +108,6 @@
private int visualSourceIndex;
- private int visualIndex;
-
private JSPTextEditor sourceEditor;
private int sourceIndex;
@@ -141,9 +139,12 @@
static {
try {
Bundle b = Platform.getBundle("org.jboss.tools.vpe"); //$NON-NLS-1$
- Class cls = b
- .loadClass("org.jboss.tools.vpe.editor.VpeEditorPartFactory");
//$NON-NLS-1$
- visualEditorFactory = (IVisualEditorFactory) cls.newInstance();
+ //FIX for JBIDE-2248
+ if(b!=null) {
+ Class cls = b
+ .loadClass("org.jboss.tools.vpe.editor.VpeEditorPartFactory");
//$NON-NLS-1$
+ visualEditorFactory = (IVisualEditorFactory) cls.newInstance();
+ }
} catch (Exception e) {
JspEditorPlugin.getPluginLog().logError("Error in loading visual editor
factory", e); //$NON-NLS-1$
}
@@ -219,22 +220,22 @@
protected void pageChange(int newPageIndex) {
selectedPageIndex = newPageIndex;
-
- if (newPageIndex == visualSourceIndex) {
- if (visualEditor.getVisualEditor() == null) {
- visualEditor.createVisualEditor();
- }
- visualEditor.setVisualMode(IVisualEditor.VISUALSOURCE_MODE);
-
- }else if (newPageIndex == sourceIndex)
- visualEditor.setVisualMode(IVisualEditor.SOURCE_MODE);
- else if (newPageIndex == previewIndex) {
- if (visualEditor.getPreviewWebBrowser() == null) {
- visualEditor.createPreviewBrowser();
- }
- visualEditor.setVisualMode(IVisualEditor.PREVIEW_MODE);
- }
+ if(visualEditor!=null) {
+ if (newPageIndex == visualSourceIndex) {
+ if (visualEditor.getVisualEditor() == null) {
+ visualEditor.createVisualEditor();
+ }
+ visualEditor.setVisualMode(IVisualEditor.VISUALSOURCE_MODE);
+ }else if (newPageIndex == sourceIndex)
+ visualEditor.setVisualMode(IVisualEditor.SOURCE_MODE);
+ else if (newPageIndex == previewIndex) {
+ if (visualEditor.getPreviewWebBrowser() == null) {
+ visualEditor.createPreviewBrowser();
+ }
+ visualEditor.setVisualMode(IVisualEditor.PREVIEW_MODE);
+ }
+ }
superPageChange(newPageIndex);
}
@@ -252,7 +253,9 @@
((AbstractTextEditor) sourceEditor)
.setInput(getEditorInput());
}
- visualEditor.setInput(getEditorInput());
+ if(visualEditor!=null) {
+ visualEditor.setInput(getEditorInput());
+ }
updateTitle();
}
updateFile();
@@ -450,14 +453,17 @@
private void createPagesForVPE() {
sourceEditor = new JSPTextEditor(this);
- visualEditor = visualEditorFactory.createVisualEditor(this,
- sourceEditor, false);
-
+ if(visualEditorFactory!=null) {
+ visualEditor = visualEditorFactory.createVisualEditor(this,
+ sourceEditor, false);
+ }
try {
- visualSourceIndex = addPage(visualEditor, getEditorInput());
- setPageText(visualSourceIndex, JSPEditorMessages
- .getString(VISUALSOURCE_TAB_LABEL));
- setPartName(visualEditor.getTitle());
+ if(visualEditor!=null) {
+ visualSourceIndex = addPage(visualEditor, getEditorInput());
+ setPageText(visualSourceIndex, JSPEditorMessages
+ .getString(VISUALSOURCE_TAB_LABEL));
+ setPartName(visualEditor.getTitle());
+ }
} catch (PartInitException e) {
JspEditorPlugin.getPluginLog().logError(e);
}
@@ -471,20 +477,29 @@
}*/
try {
- sourceIndex = addPage(visualEditor, getEditorInput());
- setPageText(sourceIndex, JSPEditorMessages
- .getString(SOURCE_TAB_LABEL));
- setPartName(visualEditor.getTitle());
+ if(visualEditor!=null) {
+ sourceIndex = addPage(visualEditor, getEditorInput());
+ setPageText(sourceIndex, JSPEditorMessages
+ .getString(SOURCE_TAB_LABEL));
+ setPartName(visualEditor.getTitle());
+ } else {
+ sourceIndex = addPage(sourceEditor, getEditorInput());
+ setPageText(sourceIndex, JSPEditorMessages
+ .getString(SOURCE_TAB_LABEL));
+ setPartName(sourceEditor.getTitle());
+ }
} catch (PartInitException e) {
JspEditorPlugin.getPluginLog().logError(e);
}
// Add tab contain default web-browser
try {
- previewIndex = addPage(visualEditor, getEditorInput());
- setPageText(previewIndex, JSPEditorMessages
- .getString(PREVIEW_TAB_LABEL));
- setPartName(visualEditor.getTitle());
+ if(visualEditor!=null) {
+ previewIndex = addPage(visualEditor, getEditorInput());
+ setPageText(previewIndex, JSPEditorMessages
+ .getString(PREVIEW_TAB_LABEL));
+ setPartName(visualEditor.getTitle());
+ }
} catch (PartInitException e) {
JspEditorPlugin.getPluginLog().logError(e);
}
@@ -566,7 +581,9 @@
((MultiPageEditorActionBarContributor) contributor)
.setActivePage(null);
}
- visualEditor.dispose();
+ if(visualEditor!=null) {
+ visualEditor.dispose();
+ }
site.dispose();
outlinePage = null;
XModelObject o = getModelObject();
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPContentOutlineConfiguration.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPContentOutlineConfiguration.java 2008-10-16
16:12:40 UTC (rev 10894)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPContentOutlineConfiguration.java 2008-10-16
16:52:15 UTC (rev 10895)
@@ -62,9 +62,10 @@
static {
try {
Bundle b = Platform.getBundle("org.jboss.tools.vpe");
- Class cls =
b.loadClass("org.jboss.tools.vpe.editor.dnd.context.ViewerDropAdapterFactory");
- dropAdapterFactory = (IViewerDropAdapterFactory)cls.newInstance();
-
+ if(b!=null) {
+ Class cls =
b.loadClass("org.jboss.tools.vpe.editor.dnd.context.ViewerDropAdapterFactory");
+ dropAdapterFactory = (IViewerDropAdapterFactory)cls.newInstance();
+ }
} catch (Exception e) {
JspEditorPlugin.getPluginLog().logError(e);
}
@@ -86,12 +87,13 @@
FileTransfer.getInstance(),
TextTransfer.getInstance()
};
+ if(dropAdapterFactory!=null) {
fTransferDropTargetListeners = new TransferDropTargetListener[transfers.length];
for (int i = 0; i < transfers.length; i++) {
final Transfer transfer = transfers[i];
DropContext dropContext = new DropContext();
- final ViewerDropAdapter dropAdapter = dropAdapterFactory.createDropAdapter(transfer,
treeViewer, editor, transfer, dropContext);
- fTransferDropTargetListeners[i] = new TransferDropTargetListener() {
+ final ViewerDropAdapter dropAdapter = dropAdapterFactory.createDropAdapter(transfer,
treeViewer, editor, transfer, dropContext);
+ fTransferDropTargetListeners[i] = new TransferDropTargetListener() {
public void dragEnter(DropTargetEvent event) {
dropAdapter.dragEnter(event);
}
@@ -124,6 +126,9 @@
return getTransfer().isSupportedType(event.currentDataType);
}
};
+ }
+ } else {
+ fTransferDropTargetListeners = new TransferDropTargetListener[0];
}
}
return fTransferDropTargetListeners;