[jbosstools-commits] JBoss Tools SVN: r39471 - in trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor: mozilla and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Tue Mar 13 09:30:44 EDT 2012
Author: dmaliarevich
Date: 2012-03-13 09:30:44 -0400 (Tue, 13 Mar 2012)
New Revision: 39471
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/mozilla/MozillaEditor.java
Log:
https://issues.jboss.org/browse/JBIDE-11271 - reverting changes from r.39442
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 2012-03-13 13:14:10 UTC (rev 39470)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2012-03-13 13:30:44 UTC (rev 39471)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.vpe.editor;
+import org.eclipse.compare.Splitter;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
@@ -33,6 +34,7 @@
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
@@ -112,6 +114,9 @@
private Composite sourceContent = null;
private Composite visualContent = null;
private Composite previewContent = null;
+ private Splitter verticalToolbarSplitter = null;
+ private Composite verticalToolbarEmpty = null;
+ private ToolBar toolBar = null;
public StructuredTextEditor getSourceEditor() {
return sourceEditor;
@@ -219,6 +224,9 @@
* Restore the state after switching from Preview, for example.
*/
// selectionBar.setVisible(selectionBar.getAlwaysVisibleOption());
+// setVerticalToolbarVisible(true);
+ setVerticalToolbarVisible(JspEditorPlugin.getDefault().getPreferenceStore()
+ .getBoolean(IVpePreferencesPage.SHOW_VISUAL_TOOLBAR));
/*
* Fixes https://jira.jboss.org/jira/browse/JBIDE-3140
* author Denis Maliarevich.
@@ -250,6 +258,7 @@
case SOURCE_MODE:
// selectionBar.setVisible(selectionBar.getAlwaysVisibleOption());
+ setVerticalToolbarVisible(false);
if (sourceContent != null) {
sourceContent.setVisible(true);
if (sourceEditor != null) {
@@ -284,6 +293,7 @@
// if (selectionBar != null) {
// selectionBar.setVisible(false);
// }
+ setVerticalToolbarVisible(false);
/*
* Fixes https://jira.jboss.org/jira/browse/JBIDE-3140
* author Denis Maliarevich.
@@ -326,15 +336,37 @@
return visualMode;
}
+ /**
+ * Sets the visibility of the vertical toolbar for visual editor part.
+ *
+ * @param visible if visible
+ */
+ public void setVerticalToolbarVisible(boolean visible) {
+ if ((null == verticalToolbarSplitter) || (null == verticalToolbarEmpty)
+ || (null == toolBar)) {
+ return;
+ }
+ if (visible) {
+ verticalToolbarSplitter.setVisible(toolBar, true);
+ verticalToolbarSplitter.setVisible(verticalToolbarEmpty, false);
+ } else {
+ verticalToolbarSplitter.setVisible(toolBar, false);
+ verticalToolbarSplitter.setVisible(verticalToolbarEmpty, true);
+ }
+ verticalToolbarSplitter.getParent().layout(true, true);
+ }
+
public void createPartControl(final Composite parent) {
+
controlCount++;
- if (controlCount > 1) {
+ if (controlCount > 1)
return;
- }
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IVpeHelpContextIds.VISUAL_PAGE_EDITOR);
/*
- * cmpEdTl -- is a container composite for editor part.
+ * Container composite for editor part
+ */
+ /*
* Fix for https://jira.jboss.org/jira/browse/JBIDE-5744
* Where is a problem with composite parent redrawing in a case
* cmpEdTl = new Composite (parent, SWT.NONE)
@@ -342,7 +374,7 @@
* see https://bugs.eclipse.org/bugs/show_bug.cgi?id=302950
*/
cmpEdTl = parent;
- GridLayout layoutEdTl = new GridLayout(1, false);
+ GridLayout layoutEdTl = new GridLayout(2, false);
layoutEdTl.verticalSpacing = 0;
layoutEdTl.marginHeight = 0;
layoutEdTl.marginBottom = 3;
@@ -351,6 +383,32 @@
cmpEdTl.setLayoutData(new GridData(GridData.FILL_BOTH));
/*
+ * https://jira.jboss.org/jira/browse/JBIDE-4429
+ * Composite for the left vertical toolbar
+ */
+ verticalToolbarSplitter = new Splitter(cmpEdTl, SWT.NONE);
+ GridLayout layout = new GridLayout(1,false);
+ layout.marginHeight = 2;
+ layout.marginWidth = 0;
+ layout.verticalSpacing = 0;
+ layout.horizontalSpacing = 0;
+ verticalToolbarSplitter.setLayout(layout);
+ verticalToolbarSplitter.setLayoutData(new GridData(SWT.CENTER, SWT.TOP | SWT.FILL, false, true, 1, 2));
+
+ /*
+ * The empty vertical toolbar component
+ */
+ verticalToolbarEmpty = new Composite(verticalToolbarSplitter, SWT.NONE) {
+ public Point computeSize(int wHint, int hHint, boolean changed) {
+ Point point = super.computeSize(wHint, hHint, changed);
+ point.x = 1;
+ return point;
+ }
+ };
+ verticalToolbarEmpty.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ verticalToolbarEmpty.setVisible(true);
+
+ /*
* The Visual Page Editor itself
*/
cmpEd = new Composite(cmpEdTl, SWT.BORDER);
@@ -441,8 +499,11 @@
visualContent.removeDisposeListener(this);
}
});
+
// createVisualEditor();
+
// createPreviewBrowser();
+
try {
sourceEditor.addPropertyListener(new IPropertyListener() {
public void propertyChanged(Object source, int propId) {
@@ -743,13 +804,15 @@
}
});
- visualEditor.createPartControl(visualContent);
- // initialize editor
- // this method must be invoked before any visual
- // node is created, see JBIDE-5105
- // this method should be called after browser was loading
- // see JBIDE-5161
- // visualEditor.getEditor();
+ toolBar = visualEditor.createVisualToolbar(verticalToolbarSplitter);
+ visualEditor.createPartControl(visualContent);
+
+ // initialize editor
+ // this method must be invoked before any visual
+ // node is created, see JBIDE-5105
+ // this method should be called after browser was loading
+ // see JBIDE-5161
+ // visualEditor.getEditor();
}
public void createPreviewBrowser() {
@@ -797,7 +860,12 @@
visualMaxmin = null;
jumpingActivation = null;
jumping = null;
-
+ if (verticalToolbarEmpty != null) {
+ if (!verticalToolbarEmpty.isDisposed()) {
+ verticalToolbarEmpty.dispose();
+ }
+ verticalToolbarEmpty = null;
+ }
if (optionsObject != null) {
optionsObject.getModel().removeModelTreeListener(listener);
listener=null;
@@ -1019,6 +1087,12 @@
*/
public void updatePartAccordingToPreferences() {
/*
+ * Update MozillaEditor's toolbar items
+ */
+ if (visualEditor != null) {
+ visualEditor.updateToolbarItemsAccordingToPreferences();
+ }
+ /*
* When switching from Source view to Visual/Source controller could be null.
*/
if (getController() != null) {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2012-03-13 13:14:10 UTC (rev 39470)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2012-03-13 13:30:44 UTC (rev 39471)
@@ -22,15 +22,24 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.browser.ProgressEvent;
import org.eclipse.swt.browser.ProgressListener;
import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.graphics.Color;
@@ -40,25 +49,34 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IReusableEditor;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+import org.eclipse.ui.editors.text.ILocationProvider;
import org.eclipse.ui.internal.part.StatusPart;
import org.eclipse.ui.part.EditorPart;
+import org.eclipse.ui.statushandlers.StatusAdapter;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.preferences.IVpePreferencesPage;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.VpeController;
import org.jboss.tools.vpe.editor.mozilla.listener.EditorLoadWindowListener;
import org.jboss.tools.vpe.editor.mozilla.listener.MozillaResizeListener;
import org.jboss.tools.vpe.editor.mozilla.listener.MozillaTooltipListener;
+import org.jboss.tools.vpe.editor.preferences.VpeEditorPreferencesPage;
+import org.jboss.tools.vpe.editor.preferences.VpeResourcesDialogFactory;
import org.jboss.tools.vpe.editor.toolbar.IVpeToolBarManager;
import org.jboss.tools.vpe.editor.toolbar.VpeDropDownMenu;
import org.jboss.tools.vpe.editor.toolbar.VpeToolBarManager;
import org.jboss.tools.vpe.editor.toolbar.format.FormatControllerManager;
import org.jboss.tools.vpe.editor.toolbar.format.TextFormattingToolBar;
import org.jboss.tools.vpe.editor.util.DocTypeUtil;
+import org.jboss.tools.vpe.editor.util.FileUtil;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.jboss.tools.vpe.xulrunner.XulRunnerException;
@@ -80,33 +98,100 @@
import org.mozilla.interfaces.nsIPlaintextEditor;
public class MozillaEditor extends EditorPart implements IReusableEditor {
-
+ /**
+ *
+ */
protected static final File INIT_FILE = new File(VpePlugin.getDefault().getResourcePath("ve"), "init.html"); //$NON-NLS-1$ //$NON-NLS-2$
public static final String CONTENT_AREA_ID = "__content__area__"; //$NON-NLS-1$
+ /*
+ * Paths for tool bar icons
+ */
+ public static final String ICON_PREFERENCE = "icons/preference.gif"; //$NON-NLS-1$
+ public static final String ICON_PREFERENCE_DISABLED = "icons/preference_disabled.gif"; //$NON-NLS-1$
+ public static final String ICON_REFRESH = "icons/refresh.gif"; //$NON-NLS-1$
+ public static final String ICON_REFRESH_DISABLED = "icons/refresh_disabled.gif"; //$NON-NLS-1$
+ public static final String ICON_PAGE_DESIGN_OPTIONS = "icons/point_to_css.gif"; //$NON-NLS-1$
+ public static final String ICON_PAGE_DESIGN_OPTIONS_DISABLED = "icons/point_to_css_disabled.gif"; //$NON-NLS-1$
+ public static final String ICON_ORIENTATION_SOURCE_LEFT = "icons/source_left.gif"; //$NON-NLS-1$
+ public static final String ICON_ORIENTATION_SOURCE_TOP = "icons/source_top.gif"; //$NON-NLS-1$
+ public static final String ICON_ORIENTATION_VISUAL_LEFT = "icons/visual_left.gif"; //$NON-NLS-1$
+ public static final String ICON_ORIENTATION_VISUAI_TOP = "icons/visual_top.gif"; //$NON-NLS-1$
+ public static final String ICON_ORIENTATION_SOURCE_LEFT_DISABLED = "icons/source_left_disabled.gif"; //$NON-NLS-1$
+ public static final String ICON_SHOW_BORDER_FOR_UNKNOWN_TAGS = "icons/border.gif"; //$NON-NLS-1$
+ public static final String ICON_NON_VISUAL_TAGS = "icons/non-visusal-tags.gif"; //$NON-NLS-1$
+ public static final String ICON_TEXT_FORMATTING = "icons/text-formatting.gif"; //$NON-NLS-1$
+ public static final String ICON_BUNDLE_AS_EL= "icons/bundle-as-el.gif"; //$NON-NLS-1$
+
private XulRunnerEditor xulRunnerEditor;
private nsIDOMElement contentArea;
private nsIDOMNode headNode;
private MozillaEventAdapter mozillaEventAdapter = createMozillaEventAdapter();
+
private EditorLoadWindowListener editorLoadWindowListener;
+
private IVpeToolBarManager vpeToolBarManager;
private FormatControllerManager formatControllerManager = new FormatControllerManager();
private VpeController controller;
private boolean isRefreshPage = false;
private String doctype;
+ private static Map<String, String> layoutIcons;
+ private static Map<String, String> layoutNames;
+ private static List<String> layoutValues;
+ private int currentOrientationIndex = 1;
+ private Action openVPEPreferencesAction;
+ private Action visualRefreshAction;
+ private Action showResouceDialogAction;
+ private Action rotateEditorsAction;
+ private Action showBorderAction;
+ private Action showNonVisualTagsAction;
+ private Action showTextFormattingAction;
+ private Action showBundleAsELAction;
+
+
+ static {
+ /*
+ * Values from <code>layoutValues</code> should correspond to the order
+ * when increasing the index of the array will cause
+ * the source editor rotation
+ */
+ layoutIcons = new HashMap<String, String>();
+ layoutIcons.put(IVpePreferencesPage.SPLITTING_HORIZ_LEFT_SOURCE_VALUE, ICON_ORIENTATION_SOURCE_LEFT);
+ layoutIcons.put(IVpePreferencesPage.SPLITTING_VERT_TOP_SOURCE_VALUE, ICON_ORIENTATION_SOURCE_TOP);
+ layoutIcons.put(IVpePreferencesPage.SPLITTING_HORIZ_LEFT_VISUAL_VALUE, ICON_ORIENTATION_VISUAL_LEFT);
+ layoutIcons.put(IVpePreferencesPage.SPLITTING_VERT_TOP_VISUAL_VALUE, ICON_ORIENTATION_VISUAI_TOP);
+
+ layoutNames = new HashMap<String, String>();
+ layoutNames.put(IVpePreferencesPage.SPLITTING_HORIZ_LEFT_SOURCE_VALUE, VpeUIMessages.SPLITTING_HORIZ_LEFT_SOURCE_TOOLTIP);
+ layoutNames.put(IVpePreferencesPage.SPLITTING_VERT_TOP_SOURCE_VALUE, VpeUIMessages.SPLITTING_VERT_TOP_SOURCE_TOOLTIP);
+ layoutNames.put(IVpePreferencesPage.SPLITTING_HORIZ_LEFT_VISUAL_VALUE, VpeUIMessages.SPLITTING_HORIZ_LEFT_VISUAL_TOOLTIP);
+ layoutNames.put(IVpePreferencesPage.SPLITTING_VERT_TOP_VISUAL_VALUE, VpeUIMessages.SPLITTING_VERT_TOP_VISUAL_TOOLTIP);
+
+ layoutValues= new ArrayList<String>();
+ layoutValues.add(IVpePreferencesPage.SPLITTING_HORIZ_LEFT_SOURCE_VALUE);
+ layoutValues.add(IVpePreferencesPage.SPLITTING_VERT_TOP_SOURCE_VALUE);
+ layoutValues.add(IVpePreferencesPage.SPLITTING_HORIZ_LEFT_VISUAL_VALUE);
+ layoutValues.add(IVpePreferencesPage.SPLITTING_VERT_TOP_VISUAL_VALUE);
+
+ }
+
/**
- * Used for manipulation of browser in design mode,
+ * Used for manupalation of browser in design mode,
* for example enable or disable readOnlyMode
*/
private nsIEditor editor;
private VpeDropDownMenu dropDownMenu = null;
+ private ToolBar verBar = null;
private MozillaResizeListener resizeListener;
private MozillaTooltipListener tooltipListener;
- public void doSave(IProgressMonitor monitor) {}
- public void doSaveAs() {}
+ public void doSave(IProgressMonitor monitor) {
+ }
+ public void doSaveAs() {
+ }
+
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
super.setSite(site);
super.setInput(input);
@@ -132,6 +217,259 @@
controller.setToolbarFormatControllerManager(formatControllerManager);
}
+ public ToolBar createVisualToolbar(Composite parent) {
+ final ToolBarManager toolBarManager = new ToolBarManager(SWT.VERTICAL | SWT.FLAT);
+ verBar = toolBarManager.createControl(parent);
+
+ /*
+ * Create OPEN VPE PREFERENCES tool bar item
+ */
+ openVPEPreferencesAction = new Action(VpeUIMessages.PREFERENCES,
+ IAction.AS_PUSH_BUTTON) {
+ @Override
+ public void run() {
+ VpeEditorPreferencesPage.openPreferenceDialog();
+ }
+ };
+ openVPEPreferencesAction.setImageDescriptor(ImageDescriptor.createFromFile(MozillaEditor.class,
+ ICON_PREFERENCE));
+ openVPEPreferencesAction.setToolTipText(VpeUIMessages.PREFERENCES);
+ toolBarManager.add(openVPEPreferencesAction);
+
+ /*
+ * Create VPE VISUAL REFRESH tool bar item
+ */
+ visualRefreshAction = new Action(VpeUIMessages.REFRESH,
+ IAction.AS_PUSH_BUTTON) {
+ @Override
+ public void run() {
+ if (controller != null) {
+ controller.visualRefresh();
+ }
+ }
+ };
+ visualRefreshAction.setImageDescriptor(ImageDescriptor.createFromFile(MozillaEditor.class,
+ ICON_REFRESH));
+ visualRefreshAction.setToolTipText(VpeUIMessages.REFRESH);
+ toolBarManager.add(visualRefreshAction);
+
+ /*
+ * Create SHOW RESOURCE DIALOG tool bar item
+ *
+ * https://jira.jboss.org/jira/browse/JBIDE-3966
+ * Disabling Page Design Options for external files.
+ */
+ IEditorInput input = getEditorInput();
+ IFile file = null;
+ if (input instanceof IFileEditorInput) {
+ file = ((IFileEditorInput) input).getFile();
+ } else if (input instanceof ILocationProvider) {
+ ILocationProvider provider = (ILocationProvider) input;
+ IPath path = provider.getPath(input);
+ if (path != null) {
+ file = FileUtil.getFile(input, path.lastSegment());
+ }
+ }
+ boolean fileExistsInWorkspace = ((file != null) && (file.exists()));
+ showResouceDialogAction = new Action(VpeUIMessages.PAGE_DESIGN_OPTIONS,
+ IAction.AS_PUSH_BUTTON) {
+ @Override
+ public void run() {
+ VpeResourcesDialogFactory.openVpeResourcesDialog(getEditorInput());
+ }
+ };
+ showResouceDialogAction.setImageDescriptor(ImageDescriptor.createFromFile(MozillaEditor.class,
+ fileExistsInWorkspace ? ICON_PAGE_DESIGN_OPTIONS : ICON_PAGE_DESIGN_OPTIONS_DISABLED));
+ if (!fileExistsInWorkspace) {
+ showResouceDialogAction.setEnabled(false);
+ }
+ showResouceDialogAction.setToolTipText(VpeUIMessages.PAGE_DESIGN_OPTIONS);
+ toolBarManager.add(showResouceDialogAction);
+
+
+ /*
+ * Create ROTATE EDITORS tool bar item
+ *
+ * https://jira.jboss.org/jira/browse/JBIDE-4152
+ * Compute initial icon state and add it to the tool bar.
+ */
+ String newOrientation = JspEditorPlugin
+ .getDefault().getPreferenceStore().getString(
+ IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING);
+ currentOrientationIndex = layoutValues.indexOf(newOrientation);
+ rotateEditorsAction = new Action(
+ VpeUIMessages.VISUAL_SOURCE_EDITORS_SPLITTING,
+ IAction.AS_PUSH_BUTTON) {
+ @Override
+ public void run() {
+ /*
+ * Rotate editors orientation clockwise.
+ */
+ currentOrientationIndex++;
+ if (currentOrientationIndex >= layoutValues.size()) {
+ currentOrientationIndex = currentOrientationIndex % layoutValues.size();
+ }
+ String newOrientation = layoutValues.get(currentOrientationIndex);
+ /*
+ * Update icon and tooltip
+ */
+ this.setImageDescriptor(ImageDescriptor.createFromFile(
+ MozillaEditor.class, layoutIcons.get(newOrientation)));
+
+ this.setToolTipText(layoutNames.get(newOrientation));
+ /*
+ * Call <code>filContainer()</code> from VpeEditorPart
+ * to redraw CustomSashForm with new layout.
+ */
+ getController().getPageContext().getEditPart().fillContainer(true, newOrientation);
+ JspEditorPlugin.getDefault().getPreferenceStore().
+ setValue(IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING, newOrientation);
+ }
+ };
+ rotateEditorsAction.setImageDescriptor(ImageDescriptor.createFromFile(MozillaEditor.class,
+ layoutIcons.get(newOrientation)));
+ rotateEditorsAction.setToolTipText(layoutNames.get(newOrientation));
+ toolBarManager.add(rotateEditorsAction);
+
+ /*
+ * Create SHOW BORDER FOR UNKNOWN TAGS tool bar item
+ */
+ showBorderAction = new Action(
+ VpeUIMessages.SHOW_BORDER_FOR_UNKNOWN_TAGS,
+ IAction.AS_CHECK_BOX) {
+ @Override
+ public void run() {
+ /*
+ * Set new value to VpeVisualDomBuilder.
+ */
+ getController().getVisualBuilder().setShowBorderForUnknownTags(this.isChecked());
+ /*
+ * Update VPE
+ */
+ controller.visualRefresh();
+ JspEditorPlugin.getDefault().getPreferenceStore().
+ setValue(IVpePreferencesPage.SHOW_BORDER_FOR_UNKNOWN_TAGS, this.isChecked());
+ }
+ };
+ showBorderAction.setImageDescriptor(ImageDescriptor.createFromFile(MozillaEditor.class,
+ ICON_SHOW_BORDER_FOR_UNKNOWN_TAGS));
+ showBorderAction.setToolTipText(VpeUIMessages.SHOW_BORDER_FOR_UNKNOWN_TAGS);
+ toolBarManager.add(showBorderAction);
+
+ /*
+ * Create SHOW INVISIBLE TAGS tool bar item
+ */
+ showNonVisualTagsAction = new Action(
+ VpeUIMessages.SHOW_NON_VISUAL_TAGS, IAction.AS_CHECK_BOX) {
+ @Override
+ public void run() {
+
+ /*
+ * Change flag
+ */
+ controller.getVisualBuilder().setShowInvisibleTags(
+ this.isChecked());
+ /*
+ * Update VPE
+ */
+ controller.visualRefresh();
+ JspEditorPlugin.getDefault().getPreferenceStore().
+ setValue(IVpePreferencesPage.SHOW_NON_VISUAL_TAGS, this.isChecked());
+ }
+ };
+ showNonVisualTagsAction.setImageDescriptor(ImageDescriptor.createFromFile(MozillaEditor.class,
+ ICON_NON_VISUAL_TAGS));
+ showNonVisualTagsAction.setToolTipText(VpeUIMessages.SHOW_NON_VISUAL_TAGS);
+ toolBarManager.add(showNonVisualTagsAction);
+
+ /*
+ * Create SHOW TEXT FORMATTING tool bar item
+ */
+ showTextFormattingAction = new Action(
+ VpeUIMessages.SHOW_TEXT_FORMATTING, IAction.AS_CHECK_BOX) {
+ @Override
+ public void run() {
+ /*
+ * Update Text Formatting Bar
+ */
+ vpeToolBarManager.setToolbarVisibility(this.isChecked());
+ JspEditorPlugin.getDefault().getPreferenceStore().
+ setValue(IVpePreferencesPage.SHOW_TEXT_FORMATTING, this.isChecked());
+ }
+ };
+ showTextFormattingAction.setImageDescriptor(ImageDescriptor.createFromFile(MozillaEditor.class,
+ ICON_TEXT_FORMATTING));
+ showTextFormattingAction.setToolTipText(VpeUIMessages.SHOW_TEXT_FORMATTING);
+ toolBarManager.add(showTextFormattingAction);
+
+ /*
+ * Create SHOW BUNDLE'S MESSAGES AS EL tool bar item
+ */
+ showBundleAsELAction = new Action(VpeUIMessages.SHOW_BUNDLES_AS_EL,
+ IAction.AS_CHECK_BOX) {
+ @Override
+ public void run() {
+ /*
+ * Update bundle messages.
+ */
+ controller.getPageContext().getBundle().updateShowBundleUsageAsEL(this.isChecked());
+ controller.visualRefresh();
+ JspEditorPlugin.getDefault().getPreferenceStore().
+ setValue(IVpePreferencesPage.SHOW_RESOURCE_BUNDLES_USAGE_AS_EL, this.isChecked());
+ }
+ };
+ showBundleAsELAction.setImageDescriptor(ImageDescriptor.createFromFile(MozillaEditor.class,
+ ICON_BUNDLE_AS_EL));
+ showBundleAsELAction.setToolTipText(VpeUIMessages.SHOW_BUNDLES_AS_EL);
+ toolBarManager.add(showBundleAsELAction);
+
+ /*
+ * Create EXTERNALIZE STRINGS tool bar item
+ */
+// externalizeStringsAction = new Action(JstUIMessages.EXTERNALIZE_STRINGS,
+// IAction.AS_PUSH_BUTTON) {
+// @Override
+// public void run() {
+// /*
+// * Externalize strings action.
+// * Show a dialog to add properties key and value.
+// * When selection is correct show the dialog
+// * otherwise the toolbar icon will be disabled.
+// */
+// ExternalizeStringsDialog dlg = new ExternalizeStringsDialog(
+// PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+// new ExternalizeStringsWizard(controller.getSourceEditor(),
+// controller.getPageContext().getBundle()));
+// dlg.open();
+// }
+// };
+// externalizeStringsAction.setImageDescriptor(ImageDescriptor.createFromFile(MozillaEditor.class,
+// ICON_EXTERNALIZE_STRINGS));
+// externalizeStringsAction.setToolTipText(JstUIMessages.EXTERNALIZE_STRINGS);
+// toolBarManager.add(externalizeStringsAction);
+
+ updateToolbarItemsAccordingToPreferences();
+ toolBarManager.update(true);
+
+ parent.addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ toolBarManager.dispose();
+ toolBarManager.removeAll();
+ openVPEPreferencesAction = null;
+ visualRefreshAction = null;
+ showResouceDialogAction = null;
+ rotateEditorsAction = null;;
+ showBorderAction = null;
+ showNonVisualTagsAction = null;
+ showTextFormattingAction = null;
+ showBundleAsELAction = null;
+// externalizeStringsAction = null;
+ }
+ });
+ return verBar;
+ }
+
/*
* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
@@ -156,14 +494,20 @@
layoutEdTl.marginWidth = 0;
cmpEdTl.setLayout(layoutEdTl);
cmpEdTl.setLayoutData(new GridData(GridData.FILL_BOTH));
-
+
/*
- * Create VPETextFormattingToolBar
+ * https://jira.jboss.org/jira/browse/JBIDE-4429
+ * Toolbar was moved to VpeEditorPart.
+ * 'verBar' should be created in createVisualToolbar(..) in VpeEditorPart
+ * and only after that MozillaEditor should be created itself.
*/
- vpeToolBarManager = new VpeToolBarManager();
- if (vpeToolBarManager != null) {
- vpeToolBarManager.createToolBarComposite(cmpEdTl);
- vpeToolBarManager.addToolBar(new TextFormattingToolBar(formatControllerManager));
+ if (null != verBar) {
+ // Use vpeToolBarManager to create a horizontal toolbar.
+ vpeToolBarManager = new VpeToolBarManager();
+ if (vpeToolBarManager != null) {
+ vpeToolBarManager.createToolBarComposite(cmpEdTl);
+ vpeToolBarManager.addToolBar(new TextFormattingToolBar(formatControllerManager));
+ }
}
//Create a composite to the Editor
@@ -186,7 +530,10 @@
try {
xulRunnerEditor = new XulRunnerEditor2(cmpEd, this);
xulRunnerEditor.getBrowser().addProgressListener(new ProgressListener() {
- public void changed(ProgressEvent event) {}
+
+ public void changed(ProgressEvent event) {
+ }
+
public void completed(ProgressEvent event) {
if (MozillaEditor.this.getXulRunnerEditor().getWebBrowser() != null) {
//process this code only in case when editor hasn't been disposed,
@@ -196,9 +543,17 @@
}
}
});
+
setInitialContent();
xulRunnerEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
} catch (Throwable t) {
+ /*
+ * Disable VPE toolbar
+ */
+ if (verBar != null) {
+ verBar.setEnabled(false);
+ }
showXulRunnerError(cmpEd, t);
}
}
@@ -287,6 +642,7 @@
BusyIndicator.showWhile(link.getDisplay(), new Runnable() {
public void run() {
URL theURL = null;
+ ;
try {
theURL = new URL(VpeUIMessages.MOZILLA_LOADING_ERROR_LINK);
} catch (MalformedURLException e) {
@@ -301,8 +657,11 @@
}
});
}
- public void mouseDoubleClick(MouseEvent e) {}
- public void mouseUp(MouseEvent e) {}
+
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+ public void mouseUp(MouseEvent e) {
+ }
});
}
@@ -426,6 +785,7 @@
if (node.getNodeType() != nsIDOMNode.ELEMENT_NODE) {
throw new RuntimeException("The content area node should by element node."); //$NON-NLS-1$
}
+
area = queryInterface(node, nsIDOMElement.class);
break;
}
@@ -435,8 +795,11 @@
area = xulRunnerEditor.getDOMDocument().createElement(HTML.TAG_BODY);
xulRunnerEditor.getDOMDocument().getDocumentElement().appendChild(area);
}
+
nsIDOMNode root = xulRunnerEditor.getDOMDocument().getDocumentElement();
+
headNode = findHeadNode(root);
+
return area;
}
@@ -545,6 +908,9 @@
return mozillaEventAdapter;
}
+ /**
+ *
+ */
public void onReloadWindow() {
detachMozillaEventAdapter();
xulRunnerEditor.removeResizeListener();
@@ -554,13 +920,16 @@
controller.reinit();
}
+ /**
+ *
+ */
public void reload() {
+
doctype = DocTypeUtil.getDoctype(getEditorInput());
- //cause page to be refreshed
+ //coused page to be refreshed
setRefreshPage(true);
setInitialContent();
}
-
/**
* Initialized design mode in visual refresh
*/
@@ -637,6 +1006,41 @@
return dropDownMenu;
}
+ public void updateToolbarItemsAccordingToPreferences() {
+ String prefsOrientation = JspEditorPlugin
+ .getDefault().getPreferenceStore().getString(
+ IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING);
+ int prefsOrientationIndex = layoutValues.indexOf(prefsOrientation);
+
+ boolean prefsShowBorderForUnknownTags = JspEditorPlugin.getDefault().getPreferenceStore()
+ .getBoolean(IVpePreferencesPage.SHOW_BORDER_FOR_UNKNOWN_TAGS);
+ boolean prefsShowNonVisualTags = JspEditorPlugin.getDefault().getPreferenceStore()
+ .getBoolean(IVpePreferencesPage.SHOW_NON_VISUAL_TAGS);
+ boolean prefsShowTextFormatting = JspEditorPlugin.getDefault().getPreferenceStore()
+ .getBoolean(IVpePreferencesPage.SHOW_TEXT_FORMATTING);
+ boolean prefsShowBundlesAsEL = JspEditorPlugin.getDefault().getPreferenceStore()
+ .getBoolean(IVpePreferencesPage.SHOW_RESOURCE_BUNDLES_USAGE_AS_EL);
+
+ if (showBorderAction != null) {
+ showBorderAction.setChecked(prefsShowBorderForUnknownTags);
+ }
+ if (showNonVisualTagsAction != null) {
+ showNonVisualTagsAction.setChecked(prefsShowNonVisualTags);
+ }
+ if (showTextFormattingAction != null) {
+ showTextFormattingAction.setChecked(prefsShowTextFormatting);
+ }
+ if (showBundleAsELAction != null) {
+ showBundleAsELAction.setChecked(prefsShowBundlesAsEL);
+ }
+ if (rotateEditorsAction != null) {
+ currentOrientationIndex = prefsOrientationIndex;
+ rotateEditorsAction.setImageDescriptor(ImageDescriptor.createFromFile(
+ MozillaEditor.class, layoutIcons.get(prefsOrientation)));
+ rotateEditorsAction.setToolTipText(layoutNames.get(prefsOrientation));
+ }
+ }
+
public void setResizeListener(MozillaResizeListener resizeListener) {
this.resizeListener = resizeListener;
}
More information about the jbosstools-commits
mailing list