Author: ayukhovich
Date: 2007-08-23 08:11:07 -0400 (Thu, 23 Aug 2007)
New Revision: 3292
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/JSPMultiPageEditorPart.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-815
add functionality for restoting maxinum tab number
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 2007-08-23
11:06:28 UTC (rev 3291)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2007-08-23
12:11:07 UTC (rev 3292)
@@ -158,7 +158,8 @@
selectedPageIndex = 0;
else {
int qi = Integer.parseInt(q);
- if (qi >= 0 && qi <= 2)
+
+ if (qi >= 0 && qi < getTabFolder().getItemCount())
selectedPageIndex = qi;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorPart.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorPart.java 2007-08-23
11:06:28 UTC (rev 3291)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorPart.java 2007-08-23
12:11:07 UTC (rev 3292)
@@ -12,24 +12,22 @@
import java.util.ArrayList;
import java.util.Iterator;
-import org.eclipse.core.runtime.SafeRunner;
-import org.jboss.tools.common.core.resources.XModelObjectEditorInput;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.util.SafeRunnable;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.events.*;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Item;
-
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.util.SafeRunnable;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-
import org.eclipse.ui.IEditorActionBarContributor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -39,12 +37,11 @@
import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
-
-import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.part.EditorPart;
import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
import org.eclipse.ui.part.MultiPageEditorSite;
import org.eclipse.ui.part.MultiPageSelectionProvider;
+import org.jboss.tools.common.core.resources.XModelObjectEditorInput;
/**
*
@@ -194,7 +191,7 @@
return getItem(pageIndex).getText();
}
- private CTabFolder getTabFolder() {
+ protected CTabFolder getTabFolder() {
return container;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-08-23
11:06:28 UTC (rev 3291)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-08-23
12:11:07 UTC (rev 3292)
@@ -64,626 +64,626 @@
import org.jboss.tools.vpe.selbar.SelectionBar;
public class VpeEditorPart extends EditorPart implements ITextEditor,
- ITextEditorExtension, IReusableEditor, IVisualEditor {
- private SashForm container;
- private StructuredTextEditor sourceEditor = null;
- private MozillaEditor visualEditor;
- private IEditorPart activeEditor;
- private VpeController controller;
- private XModelTreeListener listener;
- XModelObject optionsObject;
- private SelectionBar selectionBar = new SelectionBar();
- private ActivationListener activationListener = new ActivationListener();
- private int visualMode = 0;
- private EditorPart multiPageEditor;
- private static final QualifiedName SPLITTER_POSITION_KEY1 = new QualifiedName(
- "", "splitter_position1");
- private static final QualifiedName SPLITTER_POSITION_KEY2 = new QualifiedName(
- "", "splitter_position2");
- private static final QualifiedName SPLITTER_POSITION_KEY3 = new QualifiedName(
- "", "splitter_position3");
- private int controlCount = 0;
+ ITextEditorExtension, IReusableEditor, IVisualEditor {
+ private SashForm container;
+ private StructuredTextEditor sourceEditor = null;
+ private MozillaEditor visualEditor;
+ private IEditorPart activeEditor;
+ private VpeController controller;
+ private XModelTreeListener listener;
+ XModelObject optionsObject;
+ private SelectionBar selectionBar = new SelectionBar();
+ private ActivationListener activationListener = new ActivationListener();
+ private int visualMode = 0;
+ private EditorPart multiPageEditor;
+ private static final QualifiedName SPLITTER_POSITION_KEY1 = new QualifiedName(
+ "", "splitter_position1");
+ private static final QualifiedName SPLITTER_POSITION_KEY2 = new QualifiedName(
+ "", "splitter_position2");
+ private static final QualifiedName SPLITTER_POSITION_KEY3 = new QualifiedName(
+ "", "splitter_position3");
+ private int controlCount = 0;
- /** default web-browser */
- private MozillaPreview previewWebBrowser = null;
+ /** default web-browser */
+ private MozillaPreview previewWebBrowser = null;
- /** preview content */
- private Composite previewContent = null;
+ /** preview content */
+ private Composite previewContent = null;
- public StructuredTextEditor getSourceEditor() {
- return sourceEditor;
- }
+ public StructuredTextEditor getSourceEditor() {
+ return sourceEditor;
+ }
- // returns JSPMultipageEditor for closing by ctrl+F4 and ctrl+shift+F4 keys
- public EditorPart getParentEditor() {
- return multiPageEditor;
- }
+ // returns JSPMultipageEditor for closing by ctrl+F4 and ctrl+shift+F4 keys
+ public EditorPart getParentEditor() {
+ return multiPageEditor;
+ }
- public void close(boolean save) {
- if (sourceEditor != null)
- sourceEditor.close(save);
- }
+ public void close(boolean save) {
+ if (sourceEditor != null)
+ sourceEditor.close(save);
+ }
- public void doRevertToSaved() {
- if (sourceEditor != null)
- sourceEditor.doRevertToSaved();
- }
+ public void doRevertToSaved() {
+ if (sourceEditor != null)
+ sourceEditor.doRevertToSaved();
+ }
- public IDocumentProvider getDocumentProvider() {
- if (sourceEditor != null)
- return sourceEditor.getDocumentProvider();
- else {
- return null;
+ public IDocumentProvider getDocumentProvider() {
+ if (sourceEditor != null)
+ return sourceEditor.getDocumentProvider();
+ else {
+ return null;
+ }
}
- }
- public IRegion getHighlightRange() {
- if (sourceEditor != null)
- return sourceEditor.getHighlightRange();
- else {
- return null;
+ public IRegion getHighlightRange() {
+ if (sourceEditor != null)
+ return sourceEditor.getHighlightRange();
+ else {
+ return null;
+ }
}
- }
- public ISelectionProvider getSelectionProvider() {
- if (sourceEditor != null)
- return sourceEditor.getSelectionProvider();
- else {
- return null;
+ public ISelectionProvider getSelectionProvider() {
+ if (sourceEditor != null)
+ return sourceEditor.getSelectionProvider();
+ else {
+ return null;
+ }
}
- }
- public boolean isEditable() {
- if (sourceEditor != null)
- return sourceEditor.isEditable();
- else {
- return false;
+ public boolean isEditable() {
+ if (sourceEditor != null)
+ return sourceEditor.isEditable();
+ else {
+ return false;
+ }
}
- }
- public void removeActionActivationCode(String actionId) {
- if (sourceEditor != null)
- sourceEditor.removeActionActivationCode(actionId);
- }
+ public void removeActionActivationCode(String actionId) {
+ if (sourceEditor != null)
+ sourceEditor.removeActionActivationCode(actionId);
+ }
- public void resetHighlightRange() {
- if (sourceEditor != null)
- sourceEditor.resetHighlightRange();
- }
+ public void resetHighlightRange() {
+ if (sourceEditor != null)
+ sourceEditor.resetHighlightRange();
+ }
- public void selectAndReveal(int offset, int length) {
- if (sourceEditor != null)
- sourceEditor.selectAndReveal(offset, length);
- }
+ public void selectAndReveal(int offset, int length) {
+ if (sourceEditor != null)
+ sourceEditor.selectAndReveal(offset, length);
+ }
- public void setAction(String actionID, IAction action) {
- if (sourceEditor != null)
- sourceEditor.setAction(actionID, action);
- }
+ public void setAction(String actionID, IAction action) {
+ if (sourceEditor != null)
+ sourceEditor.setAction(actionID, action);
+ }
- public void setActionActivationCode(String actionId,
- char activationCharacter, int activationKeyCode,
- int activationStateMask) {
- if (sourceEditor != null)
- sourceEditor.setActionActivationCode(actionId, activationCharacter,
- activationKeyCode, activationStateMask);
- }
+ public void setActionActivationCode(String actionId,
+ char activationCharacter, int activationKeyCode,
+ int activationStateMask) {
+ if (sourceEditor != null)
+ sourceEditor.setActionActivationCode(actionId, activationCharacter,
+ activationKeyCode, activationStateMask);
+ }
- public void setHighlightRange(int offset, int length, boolean moveCursor) {
- if (sourceEditor != null)
- sourceEditor.setHighlightRange(offset, length, moveCursor);
- }
+ public void setHighlightRange(int offset, int length, boolean moveCursor) {
+ if (sourceEditor != null)
+ sourceEditor.setHighlightRange(offset, length, moveCursor);
+ }
- public void showHighlightRangeOnly(boolean showHighlightRangeOnly) {
- if (sourceEditor != null)
- sourceEditor.showHighlightRangeOnly(showHighlightRangeOnly);
- }
+ public void showHighlightRangeOnly(boolean showHighlightRangeOnly) {
+ if (sourceEditor != null)
+ sourceEditor.showHighlightRangeOnly(showHighlightRangeOnly);
+ }
- public boolean showsHighlightRangeOnly() {
- if (sourceEditor != null)
- return sourceEditor.showsHighlightRangeOnly();
- else {
- return false;
+ public boolean showsHighlightRangeOnly() {
+ if (sourceEditor != null)
+ return sourceEditor.showsHighlightRangeOnly();
+ else {
+ return false;
+ }
}
- }
- public void addRulerContextMenuListener(IMenuListener listener) {
- if (sourceEditor != null)
- sourceEditor.addRulerContextMenuListener(listener);
- }
+ public void addRulerContextMenuListener(IMenuListener listener) {
+ if (sourceEditor != null)
+ sourceEditor.addRulerContextMenuListener(listener);
+ }
- public boolean isEditorInputReadOnly() {
- if (sourceEditor != null)
- return sourceEditor.isEditorInputReadOnly();
- else {
- return false;
+ public boolean isEditorInputReadOnly() {
+ if (sourceEditor != null)
+ return sourceEditor.isEditorInputReadOnly();
+ else {
+ return false;
+ }
}
- }
- public void removeRulerContextMenuListener(IMenuListener listener) {
- if (sourceEditor != null)
- sourceEditor.removeRulerContextMenuListener(listener);
- }
+ public void removeRulerContextMenuListener(IMenuListener listener) {
+ if (sourceEditor != null)
+ sourceEditor.removeRulerContextMenuListener(listener);
+ }
- public void setStatusField(IStatusField field, String category) {
- if (visualMode == VISUAL_MODE) {
- if (field != null) {
- field.setImage(null);
- field.setText(null);
- }
- } else if (sourceEditor != null)
- sourceEditor.setStatusField(field, category);
- }
+ public void setStatusField(IStatusField field, String category) {
+ if (visualMode == VISUAL_MODE) {
+ if (field != null) {
+ field.setImage(null);
+ field.setText(null);
+ }
+ } else if (sourceEditor != null)
+ sourceEditor.setStatusField(field, category);
+ }
- public VpeEditorPart(EditorPart multiPageEditor,
- StructuredTextEditor textEditor, boolean visualMode) {
- sourceEditor = textEditor;
- // this.visualMode = visualMode;
- this.multiPageEditor = multiPageEditor;
- }
+ public VpeEditorPart(EditorPart multiPageEditor,
+ StructuredTextEditor textEditor, boolean visualMode) {
+ sourceEditor = textEditor;
+ // this.visualMode = visualMode;
+ this.multiPageEditor = multiPageEditor;
+ }
- public IAction getAction(String actionID) {
- return sourceEditor.getAction(actionID);
- }
+ public IAction getAction(String actionID) {
+ return sourceEditor.getAction(actionID);
+ }
- public VpeEditorPart() {
- }
+ public VpeEditorPart() {
+ }
- public void doSave(IProgressMonitor monitor) {
- if (sourceEditor != null) {
- sourceEditor.doSave(monitor);
+ public void doSave(IProgressMonitor monitor) {
+ if (sourceEditor != null) {
+ sourceEditor.doSave(monitor);
+ }
}
- }
- public void doSaveAs() {
- if (sourceEditor != null) {
- sourceEditor.doSaveAs();
- setInput(sourceEditor.getEditorInput());
+ public void doSaveAs() {
+ if (sourceEditor != null) {
+ sourceEditor.doSaveAs();
+ setInput(sourceEditor.getEditorInput());
+ }
}
- }
- public void init(IEditorSite site, IEditorInput input)
- throws PartInitException {
- setSite(site);
- setInput(input);
- }
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
+ setSite(site);
+ setInput(input);
+ }
- public void setInput(IEditorInput input) {
- super.setInput(input);
- if (visualEditor != null && visualEditor.getEditorInput() != null
- && visualEditor.getEditorInput() != getEditorInput()) {
- visualEditor.setInput(input);
+ public void setInput(IEditorInput input) {
+ super.setInput(input);
+ if (visualEditor != null && visualEditor.getEditorInput() != null
+ && visualEditor.getEditorInput() != getEditorInput()) {
+ visualEditor.setInput(input);
+ }
}
- }
- public boolean isDirty() {
- if (sourceEditor != null) {
- return sourceEditor.isDirty();
- } else {
- return false;
+ public boolean isDirty() {
+ if (sourceEditor != null) {
+ return sourceEditor.isDirty();
+ } else {
+ return false;
+ }
}
- }
- public boolean isSaveAsAllowed() {
- if (sourceEditor != null) {
- return sourceEditor.isSaveAsAllowed();
- } else {
- return false;
+ public boolean isSaveAsAllowed() {
+ if (sourceEditor != null) {
+ return sourceEditor.isSaveAsAllowed();
+ } else {
+ return false;
+ }
}
- }
- protected int[] loadSplitterPosition() {
- int[] sizes = new int[3];
- try {
- IEditorInput input = getEditorInput();
- if (!(input instanceof IFileEditorInput))
- return null;
- IFile file = ((IFileEditorInput) input).getFile();
- String s = file.getPersistentProperty(SPLITTER_POSITION_KEY1);
- if (s != null) {
- sizes[0] = Integer.parseInt(s);
- } else
- return null;
- s = file.getPersistentProperty(SPLITTER_POSITION_KEY2);
- if (s != null) {
- sizes[1] = Integer.parseInt(s);
- } else
- return null;
- s = file.getPersistentProperty(SPLITTER_POSITION_KEY3);
- if (s != null) {
- sizes[2] = Integer.parseInt(s);
- } else
- return null;
- } catch (Exception e) {
- VpePlugin.getPluginLog().logError(e);
- return null;
+ protected int[] loadSplitterPosition() {
+ int[] sizes = new int[3];
+ try {
+ IEditorInput input = getEditorInput();
+ if (!(input instanceof IFileEditorInput))
+ return null;
+ IFile file = ((IFileEditorInput) input).getFile();
+ String s = file.getPersistentProperty(SPLITTER_POSITION_KEY1);
+ if (s != null) {
+ sizes[0] = Integer.parseInt(s);
+ } else
+ return null;
+ s = file.getPersistentProperty(SPLITTER_POSITION_KEY2);
+ if (s != null) {
+ sizes[1] = Integer.parseInt(s);
+ } else
+ return null;
+ s = file.getPersistentProperty(SPLITTER_POSITION_KEY3);
+ if (s != null) {
+ sizes[2] = Integer.parseInt(s);
+ } else
+ return null;
+ } catch (Exception e) {
+ VpePlugin.getPluginLog().logError(e);
+ return null;
+ }
+ return sizes;
}
- return sizes;
- }
- protected void saveSplitterPosition(int[] weights) {
- IEditorInput input = getEditorInput();
- if (!(input instanceof IFileEditorInput))
- return;
- IFile file = ((IFileEditorInput) input).getFile();
- try {
- String s = String.valueOf(weights[0]);
- file.setPersistentProperty(SPLITTER_POSITION_KEY1, s);
- s = String.valueOf(weights[1]);
- file.setPersistentProperty(SPLITTER_POSITION_KEY2, s);
- s = String.valueOf(weights[2]);
- file.setPersistentProperty(SPLITTER_POSITION_KEY3, s);
- } catch (Exception e) {
- VpePlugin.getPluginLog().logError(e);
+ protected void saveSplitterPosition(int[] weights) {
+ IEditorInput input = getEditorInput();
+ if (!(input instanceof IFileEditorInput))
+ return;
+ IFile file = ((IFileEditorInput) input).getFile();
+ try {
+ String s = String.valueOf(weights[0]);
+ file.setPersistentProperty(SPLITTER_POSITION_KEY1, s);
+ s = String.valueOf(weights[1]);
+ file.setPersistentProperty(SPLITTER_POSITION_KEY2, s);
+ s = String.valueOf(weights[2]);
+ file.setPersistentProperty(SPLITTER_POSITION_KEY3, s);
+ } catch (Exception e) {
+ VpePlugin.getPluginLog().logError(e);
+ }
}
- }
- Composite sourceContent = null;
- Composite visualContent = null;
+ Composite sourceContent = null;
+ Composite visualContent = null;
- public void setVisualMode(int type) {
- String showSelectionBar = VpePreference.SHOW_SELECTION_TAG_BAR
- .getValue();
- switch (type) {
- case VISUALSOURCE_MODE:
- selectionBar.showBar(showSelectionBar);
- if (sourceContent != null)
- sourceContent.setVisible(true);
- if (visualContent != null)
- visualContent.setVisible(true);
- if (previewContent != null) {
- previewContent.setVisible(false);
- }
- break;
+ public void setVisualMode(int type) {
+ String showSelectionBar = VpePreference.SHOW_SELECTION_TAG_BAR
+ .getValue();
+ switch (type) {
+ case VISUALSOURCE_MODE:
+ selectionBar.showBar(showSelectionBar);
+ if (sourceContent != null)
+ sourceContent.setVisible(true);
+ if (visualContent != null)
+ visualContent.setVisible(true);
+ if (previewContent != null) {
+ previewContent.setVisible(false);
+ }
+ break;
- case VISUAL_MODE:
- selectionBar.showBar(showSelectionBar);
- if (sourceContent != null)
- sourceContent.setVisible(false);
- if (visualContent != null)
- visualContent.setVisible(true);
- if (previewContent != null) {
- previewContent.setVisible(false);
- }
- break;
+ case VISUAL_MODE:
+ selectionBar.showBar(showSelectionBar);
+ if (sourceContent != null)
+ sourceContent.setVisible(false);
+ if (visualContent != null)
+ visualContent.setVisible(true);
+ if (previewContent != null) {
+ previewContent.setVisible(false);
+ }
+ break;
- case SOURCE_MODE:
- selectionBar.showBar(showSelectionBar);
- if (sourceContent != null)
- sourceContent.setVisible(true);
- if (visualContent != null)
- visualContent.setVisible(false);
- if (previewContent != null) {
- previewContent.setVisible(false);
- }
- break;
+ case SOURCE_MODE:
+ selectionBar.showBar(showSelectionBar);
+ if (sourceContent != null)
+ sourceContent.setVisible(true);
+ if (visualContent != null)
+ visualContent.setVisible(false);
+ if (previewContent != null) {
+ previewContent.setVisible(false);
+ }
+ break;
- case PREVIEW_MODE:
- if (selectionBar != null) {
- selectionBar.showBar("no");
- }
- if (sourceContent != null) {
- sourceContent.setVisible(false);
- }
+ case PREVIEW_MODE:
+ if (selectionBar != null) {
+ selectionBar.showBar("no");
+ }
+ if (sourceContent != null) {
+ sourceContent.setVisible(false);
+ }
- if (visualContent != null) {
- visualContent.setVisible(false);
- }
+ if (visualContent != null) {
+ visualContent.setVisible(false);
+ }
- if (previewContent != null) {
- previewWebBrowser.rebuildDom();
- previewContent.setVisible(true);
- }
- break;
+ if (previewContent != null) {
+ previewWebBrowser.rebuildDom();
+ previewContent.setVisible(true);
+ }
+ break;
+ }
+ container.layout();
+ if (visualMode == SOURCE_MODE && type != SOURCE_MODE) {
+ visualMode = type;
+ if (controller != null) {
+ controller.visualRefresh();
+ controller.sourceSelectionChanged();
+ }
+ }
+ visualMode = type;
}
- container.layout();
- if (visualMode == SOURCE_MODE && type != SOURCE_MODE) {
- visualMode = type;
- if (controller != null) {
- controller.visualRefresh();
- controller.sourceSelectionChanged();
- }
+
+ public int getVisualMode() {
+ return visualMode;
}
- visualMode = type;
- }
- public int getVisualMode() {
- return visualMode;
- }
+ public void createPartControl(Composite parent) {
+ controlCount++;
+ if (controlCount > 1)
+ return;
+ // //////////////////////////////////////////////////////////////
- public void createPartControl(Composite parent) {
- controlCount++;
- if (controlCount > 1)
- return;
- // //////////////////////////////////////////////////////////////
+ Composite cmpEdTl = new Composite(parent, SWT.NONE);
+ GridLayout layoutEdTl = new GridLayout(1, false);
+ layoutEdTl.verticalSpacing = 0;
+ layoutEdTl.marginHeight = 0;
+ layoutEdTl.marginBottom = 3;
+ layoutEdTl.marginWidth = 0;
+ cmpEdTl.setLayout(layoutEdTl);
+ cmpEdTl.setLayoutData(new GridData(GridData.FILL_BOTH));
- Composite cmpEdTl = new Composite(parent, SWT.NONE);
- GridLayout layoutEdTl = new GridLayout(1, false);
- layoutEdTl.verticalSpacing = 0;
- layoutEdTl.marginHeight = 0;
- layoutEdTl.marginBottom = 3;
- layoutEdTl.marginWidth = 0;
- cmpEdTl.setLayout(layoutEdTl);
- cmpEdTl.setLayoutData(new GridData(GridData.FILL_BOTH));
+ Composite cmpEd = new Composite(cmpEdTl, SWT.NATIVE);
+ GridLayout layoutEd = new GridLayout(1, false);
+ layoutEd.marginBottom = 0;
+ layoutEd.marginHeight = 1;
+ layoutEd.marginWidth = 0;
+ layoutEd.marginRight = 0;
+ layoutEd.marginLeft = 1;
+ layoutEd.verticalSpacing = 0;
+ layoutEd.horizontalSpacing = 0;
+ cmpEd.setLayout(layoutEd);
+ cmpEd.setLayoutData(new GridData(GridData.FILL_BOTH));
+ // /////////////////////////////////////////////////////////////////
+ container = new SashForm(cmpEd, SWT.VERTICAL);
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ sourceContent = new Composite(container, SWT.NONE);
+ sourceContent.setLayout(new FillLayout());
+ visualContent = new Composite(container, SWT.NONE);
+ visualContent.setLayout(new FillLayout());
- Composite cmpEd = new Composite(cmpEdTl, SWT.NATIVE);
- GridLayout layoutEd = new GridLayout(1, false);
- layoutEd.marginBottom = 0;
- layoutEd.marginHeight = 1;
- layoutEd.marginWidth = 0;
- layoutEd.marginRight = 0;
- layoutEd.marginLeft = 1;
- layoutEd.verticalSpacing = 0;
- layoutEd.horizontalSpacing = 0;
- cmpEd.setLayout(layoutEd);
- cmpEd.setLayoutData(new GridData(GridData.FILL_BOTH));
- // /////////////////////////////////////////////////////////////////
- container = new SashForm(cmpEd, SWT.VERTICAL);
- container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- sourceContent = new Composite(container, SWT.NONE);
- sourceContent.setLayout(new FillLayout());
- visualContent = new Composite(container, SWT.NONE);
- visualContent.setLayout(new FillLayout());
+ // Create a preview content
+ previewContent = new Composite(container, SWT.NONE);
+ previewContent.setLayout(new FillLayout());
- // Create a preview content
- previewContent = new Composite(container, SWT.NONE);
- previewContent.setLayout(new FillLayout());
+ // ////////////////////////////////////////////////////
- // ////////////////////////////////////////////////////
+ selectionBar.createToolBarComposite(cmpEdTl, true);
+ // ///////////////////////////////////////////////////
+ if (sourceEditor == null)
+ sourceEditor = new StructuredTextEditor() {
+ public void safelySanityCheckState(IEditorInput input) {
+ super.safelySanityCheckState(input);
+ }
+ };
+ int[] weights = loadSplitterPosition();
+ if (weights != null)
+ container.setWeights(weights);
+ container.addWeightsChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ saveSplitterPosition(container.getWeights());
+ }
+ });
+ parent.addControlListener(new ControlListener() {
+ public void controlMoved(ControlEvent event) {
- selectionBar.createToolBarComposite(cmpEdTl, true);
- // ///////////////////////////////////////////////////
- if (sourceEditor == null)
- sourceEditor = new StructuredTextEditor() {
- public void safelySanityCheckState(IEditorInput input) {
- super.safelySanityCheckState(input);
+ }
+
+ public void controlResized(ControlEvent event) {
+ container.layout();
+ }
+ });
+ visualEditor = new MozillaEditor();
+ try {
+ visualEditor.init(getEditorSite(), getEditorInput());
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
}
- };
- int[] weights = loadSplitterPosition();
- if (weights != null)
- container.setWeights(weights);
- container.addWeightsChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- saveSplitterPosition(container.getWeights());
- }
- });
- parent.addControlListener(new ControlListener() {
- public void controlMoved(ControlEvent event) {
- }
+ previewWebBrowser = new MozillaPreview(this, sourceEditor);
+ try {
+ previewWebBrowser.init(getEditorSite(), getEditorInput());
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ }
- public void controlResized(ControlEvent event) {
- container.layout();
- }
- });
- visualEditor = new MozillaEditor();
- try {
- visualEditor.init(getEditorSite(), getEditorInput());
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- }
+ try {
+ sourceEditor.addPropertyListener(new IPropertyListener() {
+ public void propertyChanged(Object source, int propId) {
+ if (propId == IWorkbenchPartConstants.PROP_TITLE) {
+ VpeEditorPart.this.setPartName(sourceEditor.getTitle());
+ }
+ VpeEditorPart.this.firePropertyChange(propId);
+ }
+ });
+ sourceEditor.init(getEditorSite(), getEditorInput());
- previewWebBrowser = new MozillaPreview(this, sourceEditor);
- try {
- previewWebBrowser.init(getEditorSite(), getEditorInput());
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- }
+ if (sourceContent != null) {
+ sourceEditor.createPartControl(sourceContent);
+ }
+ if (visualEditor != null) {
+ visualEditor
+ .setEditorLoadWindowListener(new EditorLoadWindowListener() {
+ public void load() {
+ visualEditor.setEditorLoadWindowListener(null);
+ controller = new VpeController(
+ VpeEditorPart.this);
+ selectionBar.setVpeController(controller);
+ controller
+ .setSelectionBarController(selectionBar);
+ try {
+ controller.init(sourceEditor, visualEditor);
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ }
+ }
+ });
+ visualEditor.createPartControl(visualContent);
+ }
- try {
- sourceEditor.addPropertyListener(new IPropertyListener() {
- public void propertyChanged(Object source, int propId) {
- if (propId == IWorkbenchPartConstants.PROP_TITLE) {
- VpeEditorPart.this.setPartName(sourceEditor.getTitle());
- }
- VpeEditorPart.this.firePropertyChange(propId);
- }
- });
- sourceEditor.init(getEditorSite(), getEditorInput());
+ if (previewWebBrowser != null) {
+ previewWebBrowser
+ .setEditorLoadWindowListener(new EditorLoadWindowListener() {
+ public void load() {
+ previewWebBrowser
+ .setEditorLoadWindowListener(null);
+ previewWebBrowser.buildDom();
+ }
+ });
+ previewWebBrowser.createPartControl(previewContent);
+ }
- if (sourceContent != null) {
- sourceEditor.createPartControl(sourceContent);
- }
- if (visualEditor != null) {
- visualEditor
- .setEditorLoadWindowListener(new EditorLoadWindowListener() {
- public void load() {
- visualEditor.setEditorLoadWindowListener(null);
- controller = new VpeController(
- VpeEditorPart.this);
- selectionBar.setVpeController(controller);
- controller
- .setSelectionBarController(selectionBar);
- try {
- controller.init(sourceEditor, visualEditor);
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
+ activeEditor = sourceEditor;
+
+ sourceContent.addListener(SWT.Activate, new Listener() {
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Activate) {
+ if (activeEditor != sourceEditor) {
+ activeEditor = sourceEditor;
+ setFocus();
+ }
+ }
}
- }
});
- visualEditor.createPartControl(visualContent);
- }
- if (previewWebBrowser != null) {
- previewWebBrowser
- .setEditorLoadWindowListener(new EditorLoadWindowListener() {
- public void load() {
- previewWebBrowser
- .setEditorLoadWindowListener(null);
- previewWebBrowser.buildDom();
- }
+ visualContent.addListener(SWT.Activate, new Listener() {
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Activate) {
+ if (visualEditor != null
+ && activeEditor != visualEditor) {
+ activeEditor = visualEditor;
+ setFocus();
+ }
+ }
+ }
});
- previewWebBrowser.createPartControl(previewContent);
- }
- activeEditor = sourceEditor;
+ previewContent.addListener(SWT.Activate, new Listener() {
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Activate) {
+ if (previewWebBrowser != null
+ && activeEditor != previewWebBrowser) {
+ activeEditor = previewWebBrowser;
+ setFocus();
+ }
+ }
+ }
+ });
- sourceContent.addListener(SWT.Activate, new Listener() {
- public void handleEvent(Event event) {
- if (event.type == SWT.Activate) {
- if (activeEditor != sourceEditor) {
- activeEditor = sourceEditor;
- setFocus();
- }
- }
+ IWorkbenchWindow window = getSite().getWorkbenchWindow();
+ window.getPartService().addPartListener(activationListener);
+ window.getShell().addShellListener(activationListener);
+
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
}
- });
+ // setVisualMode(visualMode);
+ // ///////////////////////////////////////
+ // ///// Add preference listener
+ optionsObject = ModelUtilities.getPreferenceModel().getByPath(
+ VpePreference.EDITOR_PATH);
+ listener = new XModelTreeListener() {
- visualContent.addListener(SWT.Activate, new Listener() {
- public void handleEvent(Event event) {
- if (event.type == SWT.Activate) {
- if (visualEditor != null
- && activeEditor != visualEditor) {
- activeEditor = visualEditor;
- setFocus();
+ public void nodeChanged(XModelTreeEvent event) {
+ String showSelectionBar = VpePreference.SHOW_SELECTION_TAG_BAR
+ .getValue();
+ selectionBar.showBar(showSelectionBar);
}
- }
- }
- });
- previewContent.addListener(SWT.Activate, new Listener() {
- public void handleEvent(Event event) {
- if (event.type == SWT.Activate) {
- if (previewWebBrowser != null
- && activeEditor != previewWebBrowser) {
- activeEditor = previewWebBrowser;
- setFocus();
+ public void structureChanged(XModelTreeEvent event) {
}
- }
- }
- });
- IWorkbenchWindow window = getSite().getWorkbenchWindow();
- window.getPartService().addPartListener(activationListener);
- window.getShell().addShellListener(activationListener);
-
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
+ };
+ optionsObject.getModel().addModelTreeListener(listener);
+ // ///////////////////////////////////////
+ cmpEd.layout();
}
- // setVisualMode(visualMode);
- // ///////////////////////////////////////
- // ///// Add preference listener
- optionsObject = ModelUtilities.getPreferenceModel().getByPath(
- VpePreference.EDITOR_PATH);
- listener = new XModelTreeListener() {
- public void nodeChanged(XModelTreeEvent event) {
- String showSelectionBar = VpePreference.SHOW_SELECTION_TAG_BAR
- .getValue();
- selectionBar.showBar(showSelectionBar);
- }
-
- public void structureChanged(XModelTreeEvent event) {
- }
-
- };
- optionsObject.getModel().addModelTreeListener(listener);
- // ///////////////////////////////////////
- cmpEd.layout();
- }
-
- public void setFocus() {
- if (activeEditor != null) {
- activeEditor.setFocus();
+ public void setFocus() {
+ if (activeEditor != null) {
+ activeEditor.setFocus();
+ }
}
- }
- public void dispose() {
- super.dispose();
- if (optionsObject != null) {
- optionsObject.getModel().removeModelTreeListener(listener);
- }
- if (activationListener != null) {
- IWorkbenchWindow window = getSite().getWorkbenchWindow();
- window.getPartService().removePartListener(activationListener);
- Shell shell = window.getShell();
- if (shell != null && !shell.isDisposed())
- shell.removeShellListener(activationListener);
- activationListener = null;
- }
- if (controller != null) {
- controller.dispose();
- controller = null;
- }
+ public void dispose() {
+ super.dispose();
+ if (optionsObject != null) {
+ optionsObject.getModel().removeModelTreeListener(listener);
+ }
+ if (activationListener != null) {
+ IWorkbenchWindow window = getSite().getWorkbenchWindow();
+ window.getPartService().removePartListener(activationListener);
+ Shell shell = window.getShell();
+ if (shell != null && !shell.isDisposed())
+ shell.removeShellListener(activationListener);
+ activationListener = null;
+ }
+ if (controller != null) {
+ controller.dispose();
+ controller = null;
+ }
- // editor will disposed as part of multipart editor
- if (sourceEditor != null) {
- sourceEditor.dispose();
- sourceEditor = null;
- }
+ // editor will disposed as part of multipart editor
+ if (sourceEditor != null) {
+ sourceEditor.dispose();
+ sourceEditor = null;
+ }
- if (visualEditor != null) {
- visualEditor.dispose();
- visualEditor = null;
- }
+ if (visualEditor != null) {
+ visualEditor.dispose();
+ visualEditor = null;
+ }
- if (previewContent != null) {
- previewContent.dispose();
- previewContent = null;
+ if (previewContent != null) {
+ previewContent.dispose();
+ previewContent = null;
+ }
}
- }
- public Object getAdapter(Class adapter) {
- if (sourceEditor != null) {
- return sourceEditor.getAdapter(adapter);
- } else {
- return null;
+ public Object getAdapter(Class adapter) {
+ if (sourceEditor != null) {
+ return sourceEditor.getAdapter(adapter);
+ } else {
+ return null;
+ }
}
- }
- private class ActivationListener extends ShellAdapter implements
- IPartListener {
- private IWorkbenchPart fActivePart;
- private boolean fIsHandlingActivation = false;
+ private class ActivationListener extends ShellAdapter implements
+ IPartListener {
+ private IWorkbenchPart fActivePart;
+ private boolean fIsHandlingActivation = false;
- public void partActivated(IWorkbenchPart part) {
- fActivePart = part;
- handleActivation();
- }
+ public void partActivated(IWorkbenchPart part) {
+ fActivePart = part;
+ handleActivation();
+ }
- public void partBroughtToTop(IWorkbenchPart part) {
- }
+ public void partBroughtToTop(IWorkbenchPart part) {
+ }
- public void partClosed(IWorkbenchPart part) {
- }
+ public void partClosed(IWorkbenchPart part) {
+ }
- public void partDeactivated(IWorkbenchPart part) {
- fActivePart = null;
- }
+ public void partDeactivated(IWorkbenchPart part) {
+ fActivePart = null;
+ }
- public void partOpened(IWorkbenchPart part) {
- }
+ public void partOpened(IWorkbenchPart part) {
+ }
- public void shellActivated(ShellEvent e) {
- e.widget.getDisplay().asyncExec(new Runnable() {
- public void run() {
- handleActivation();
+ public void shellActivated(ShellEvent e) {
+ e.widget.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ handleActivation();
+ }
+ });
}
- });
- }
- private void handleActivation() {
- if (fIsHandlingActivation)
- return;
+ private void handleActivation() {
+ if (fIsHandlingActivation)
+ return;
- if (fActivePart == multiPageEditor) {
- fIsHandlingActivation = true;
- try {
- if (sourceEditor != null) {
- if (controller != null) {
- controller.refreshTemplates();
+ if (fActivePart == multiPageEditor) {
+ fIsHandlingActivation = true;
+ try {
+ if (sourceEditor != null) {
+ if (controller != null) {
+ controller.refreshTemplates();
+ }
+ sourceEditor.safelySanityCheckState(getEditorInput());
+ }
+ } finally {
+ fIsHandlingActivation = false;
+ }
}
- sourceEditor.safelySanityCheckState(getEditorInput());
- }
- } finally {
- fIsHandlingActivation = false;
}
- }
}
- }
- public VpeController getController() {
- return controller;
- }
+ public VpeController getController() {
+ return controller;
+ }
}