Author: dmaliarevich
Date: 2012-01-26 11:25:50 -0500 (Thu, 26 Jan 2012)
New Revision: 38205
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/icons/scroll_lock.gif
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/VpeBooleanFieldEditor.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/ScrollLockSourceVisualHandler.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/preferences/IVpePreferencesPage.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/preferences/VpePreferencesInitializer.java
trunk/vpe/plugins/org.jboss.tools.vpe/plugin.properties
trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/SliderFieldEditor.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/VpePreferencesPage.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ISelectionManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/ShowBorderHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/ShowOptionAbstractHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
Log:
https://issues.jboss.org/browse/JBIDE-8701 - scrolling is performed on percentage basis
now, preferences page option was added, toolbar icon was added.
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/preferences/IVpePreferencesPage.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/preferences/IVpePreferencesPage.java 2012-01-26
16:23:14 UTC (rev 38204)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/preferences/IVpePreferencesPage.java 2012-01-26
16:25:50 UTC (rev 38205)
@@ -21,6 +21,7 @@
static final String DEFAULT_VPE_TAB = "Default VPE Tab"; //$NON-NLS-1$
static final String VISUAL_SOURCE_EDITORS_SPLITTING = "Visual/Source Editors
Splitting"; //$NON-NLS-1$
static final String VISUAL_SOURCE_EDITORS_WEIGHTS = "Size of Visual Editor Pane
0-100%"; //$NON-NLS-1$
+ static final String SYNCHRONIZE_SCROLLING_BETWEEN_SOURCE_VISUAL_PANES =
"Synchronize scrolling between source and visual panes"; //$NON-NLS-1$
static final String SHOW_VISUAL_TOOLBAR = "Show VPE Toolbar"; //$NON-NLS-1$
static final String DEFAULT_VPE_TAB_VISUAL_SOURCE_VALUE = "0"; //$NON-NLS-1$
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/preferences/VpePreferencesInitializer.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/preferences/VpePreferencesInitializer.java 2012-01-26
16:23:14 UTC (rev 38204)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/preferences/VpePreferencesInitializer.java 2012-01-26
16:25:50 UTC (rev 38205)
@@ -30,8 +30,7 @@
defaultPreferences.putBoolean(IVpePreferencesPage.INFORM_WHEN_PROJECT_MIGHT_NOT_BE_CONFIGURED_PROPERLY_FOR_VPE,
true);
defaultPreferences.put(IVpePreferencesPage.DEFAULT_VPE_TAB,
IVpePreferencesPage.DEFAULT_VPE_TAB_VISUAL_SOURCE_VALUE);
defaultPreferences.put(IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING,
IVpePreferencesPage.SPLITTING_VERT_TOP_SOURCE_VALUE);
+ defaultPreferences.putBoolean(IVpePreferencesPage.SYNCHRONIZE_SCROLLING_BETWEEN_SOURCE_VISUAL_PANES,
false);
defaultPreferences.putInt(IVpePreferencesPage.VISUAL_SOURCE_EDITORS_WEIGHTS,
IVpePreferencesPage.DEFAULT_VISUAL_SOURCE_EDITORS_WEIGHTS);
-
}
-
-}
+}
\ No newline at end of file
Added: trunk/vpe/plugins/org.jboss.tools.vpe/icons/scroll_lock.gif
===================================================================
(Binary files differ)
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe/icons/scroll_lock.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/plugin.properties
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/plugin.properties 2012-01-26 16:23:14 UTC (rev
38204)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/plugin.properties 2012-01-26 16:25:50 UTC (rev
38205)
@@ -22,4 +22,5 @@
vpe.toolbar.show_non_visual_tags=Show non-visual tags
vpe.toolbar.show_text_formatting=Show text formatting bar
vpe.toolbar.show_bundle_as_el=Show bundle's messages as EL expressions
+vpe.toolbar.scroll_lock=Synchronize scrolling between source and visual panes
vpe.toolbar.name=Visual Page Editor Toolbar
\ No newline at end of file
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml 2012-01-26 16:23:14 UTC (rev 38204)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml 2012-01-26 16:25:50 UTC (rev 38205)
@@ -97,6 +97,14 @@
id="org.eclipse.ui.commands.toggleState">
</state>
</command>
+ <command categoryId="org.jboss.tools.vpe.category"
+ id="org.jboss.tools.vpe.commands.scrollLockSourceVisual"
+ name="%vpe.toolbar.scroll_lock">
+ <state
+ class="org.eclipse.ui.handlers.RegistryToggleState:false"
+ id="org.eclipse.ui.commands.toggleState">
+ </state>
+ </command>
</extension>
<extension point="org.eclipse.ui.bindings">
<key commandId="org.jboss.tools.vpe.source.maxmin"
@@ -261,6 +269,16 @@
<reference definitionId="org.jboss.tools.ui.vpe.editor"/>
</visibleWhen>
</command>
+ <command
+ commandId="org.jboss.tools.vpe.commands.scrollLockSourceVisual"
+ icon="icons/scroll_lock.gif"
+ style="toggle"
+ id="org.jboss.tools.vpe.toolbars.scrollLockSourceVisual"
+ tooltip="%vpe.toolbar.scroll_lock">
+ <visibleWhen checkEnabled="false">
+ <reference definitionId="org.jboss.tools.ui.vpe.editor"/>
+ </visibleWhen>
+ </command>
</menuContribution>
</extension>
<extension
@@ -313,6 +331,9 @@
<handler
class="org.jboss.tools.vpe.handlers.ShowBundleAsELHandler"
commandId="org.jboss.tools.vpe.commands.showBundleAsELCommand"/>
+ <handler
+
class="org.jboss.tools.vpe.handlers.ScrollLockSourceVisualHandler"
+
commandId="org.jboss.tools.vpe.commands.scrollLockSourceVisual"/>
</extension>
<extension
point="org.eclipse.core.expressions.propertyTesters">
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2012-01-26
16:23:14 UTC (rev 38204)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2012-01-26
16:25:50 UTC (rev 38205)
@@ -56,6 +56,7 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
@@ -91,10 +92,12 @@
import org.jboss.tools.common.model.util.XModelTreeListenerSWTSync;
import org.jboss.tools.common.resref.core.ResourceReferenceListListener;
import org.jboss.tools.common.util.SwtUtil;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.jst.jsp.editor.IJSPTextEditor;
import org.jboss.tools.jst.jsp.editor.IVisualController;
import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPPaletteInsertHelper;
+import org.jboss.tools.jst.jsp.preferences.IVpePreferencesPage;
import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.jst.jsp.selection.SelectionHelper;
import org.jboss.tools.jst.web.model.helpers.WebAppHelper;
@@ -158,9 +161,12 @@
import org.mozilla.interfaces.nsIDOMMutationEvent;
import org.mozilla.interfaces.nsIDOMNSUIEvent;
import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMWindow;
+import org.mozilla.interfaces.nsIDOMWindowInternal;
import org.mozilla.interfaces.nsISelection;
import org.mozilla.interfaces.nsISelectionDisplay;
import org.mozilla.interfaces.nsISelectionListener;
+import org.mozilla.interfaces.nsIWebBrowser;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -175,6 +181,15 @@
MozillaContextMenuListener, MozillaResizeListener,
MozillaAfterPaintListener, MozillaScrollListener {
+ /*
+ *
https://issues.jboss.org/browse/JBIDE-8701
+ * Scroll listeners staff.
+ */
+ private SelectionListener sourceScrollSelectionListener;
+ private ScrollBar sourceEditorVerticalScrollBar;
+ private boolean sourceScrollEventFlag = false;
+ private boolean visualScrollEventFlag = false;
+
public static final int DEFAULT_UPDATE_DELAY_TIME = 400;
private boolean visualEditorVisible = true;
private boolean synced = true;
@@ -335,12 +350,62 @@
// sourceEditor.getViewerSelectionManager();
// selectionManager.addNodeSelectionListener(this);
// selectionManager.addTextSelectionListener(this);
- StyledText textWidget = SelectionHelper
- .getSourceTextWidget(sourceEditor);
+ final StyledText textWidget = SelectionHelper.getSourceTextWidget(sourceEditor);
if (textWidget != null) {
textWidget.addSelectionListener(this);
}
-
+ /*
+ *
https://issues.jboss.org/browse/JBIDE-8701
+ * Add Source ScrollBar Listener
+ */
+ if ((visualEditor != null) && (sourceEditor != null)) {
+ sourceEditorVerticalScrollBar = textWidget.getVerticalBar();
+ if (sourceEditorVerticalScrollBar != null) {
+ if (visualEditor.getXulRunnerEditor() != null) {
+ nsIWebBrowser webBrowser = visualEditor.getXulRunnerEditor().getWebBrowser();
+ if (webBrowser != null) {
+ /*
+ * Initialize mozilla browser content window
+ */
+ final nsIDOMWindow domWindow = webBrowser.getContentDOMWindow();
+ final nsIDOMWindowInternal windowInternal =
org.jboss.tools.vpe.xulrunner.util.XPCOM
+ .queryInterface(domWindow, nsIDOMWindowInternal.class);
+ /*
+ * Adding source listener
+ */
+ sourceScrollSelectionListener = new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (JspEditorPlugin.getDefault().getPreferenceStore().getBoolean(
+ IVpePreferencesPage.SYNCHRONIZE_SCROLLING_BETWEEN_SOURCE_VISUAL_PANES)
+ && !visualScrollEventFlag &&
!selectionManager.isUpdateSelectionEventPerformed()) { // ignore internal visual scroll
event
+ sourceScrollEventFlag = true;
+ ScrollBar sb = (ScrollBar)e.widget;
+ int pageYOffsetSrc = sb.getSelection();
+ int scrollMaxYSrc = sb.getMaximum() - sb.getThumb();
+ float percentsSrc = ((float)pageYOffsetSrc/scrollMaxYSrc);
+ if (windowInternal.getScrollbars().getVisible()) {
+ int scrollMaxYVisual = -1;
+ scrollMaxYVisual = windowInternal.getScrollMaxY();
+ if (scrollMaxYVisual != 0 && scrollMaxYVisual != -1) {
+ // there is a visual scroll bar
+ int posY = ((int) (scrollMaxYVisual*percentsSrc));
+ domWindow.scrollTo(windowInternal.getPageXOffset(),posY);
+ }
+ }
+ } else {
+ visualScrollEventFlag = false;
+ selectionManager.setUpdateSelectionEventFlag(false);
+ }
+ }
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) { }
+ };
+ sourceEditorVerticalScrollBar.addSelectionListener(sourceScrollSelectionListener);
+ }
+ }
+ }
+ } // End of fix JBIDE-8701
registerEventTargets();
if (optionsListener == null) {
@@ -356,12 +421,10 @@
taglibReferenceListListener = TaglibReferenceList.getInstance();
taglibReferenceListListener.addChangeListener(this);
- absoluteFolderReferenceListListener = AbsoluteFolderReferenceList
- .getInstance();
+ absoluteFolderReferenceListListener = AbsoluteFolderReferenceList.getInstance();
absoluteFolderReferenceListListener.addChangeListener(this);
- relativeFolderReferenceListListener = RelativeFolderReferenceList
- .getInstance();
+ relativeFolderReferenceListListener = RelativeFolderReferenceList.getInstance();
relativeFolderReferenceListListener.addChangeListener(this);
elReferenceListListener = ELReferenceList.getInstance();
@@ -376,8 +439,28 @@
// JBIDE-4037)
sourceSelectionChanged(true);
refreshCommands();
+ /*
+ * Reset the flag, to enable scroll synchronizing right after init
+ */
+ selectionManager.setUpdateSelectionEventFlag(false);
}
+ private ScrollBar getSourceEditorVerticalScrollBar() {
+ return sourceEditorVerticalScrollBar;
+ }
+
+ private void removeSourceScrollListener() {
+ if (sourceEditorVerticalScrollBar != null && sourceScrollSelectionListener !=
null) {
+ sourceEditorVerticalScrollBar.removeSelectionListener(sourceScrollSelectionListener);
+ }
+ }
+
+ private void addSourceScrollListener() {
+ if (sourceEditorVerticalScrollBar != null && sourceScrollSelectionListener !=
null) {
+ sourceEditorVerticalScrollBar.addSelectionListener(sourceScrollSelectionListener);
+ }
+ }
+
public void dispose() {
if (job != null) {
job.cancel();
@@ -958,7 +1041,6 @@
}
onRefresh();
}
-
public boolean isKeyBinding(Event keyboardEvent) {
boolean keyBindingPressed = false;
@@ -1007,7 +1089,45 @@
}
public void editorScrolled(nsIDOMEvent domEvent) {
+ /*
+ * Redraw selection rectangle
+ */
onRefresh();
+ /*
+ *
https://issues.jboss.org/browse/JBIDE-8701
+ * Perform visual and source scroll synchronizing.
+ * The idea of visual scroll listener is to scroll src part when it is required
+ * (when src hasn't been scrolled to a proper position).
+ */
+ if (JspEditorPlugin.getDefault().getPreferenceStore().getBoolean(
+ IVpePreferencesPage.SYNCHRONIZE_SCROLLING_BETWEEN_SOURCE_VISUAL_PANES)
+ && !sourceScrollEventFlag &&
!selectionManager.isUpdateSelectionEventPerformed()) { // ignore internal event from
source
+ if (visualEditor.getXulRunnerEditor() != null) {
+ visualScrollEventFlag = true;
+ final nsIWebBrowser webBrowser = visualEditor.getXulRunnerEditor().getWebBrowser();
+ removeSourceScrollListener();
+ final StyledText textWidget = SelectionHelper.getSourceTextWidget(sourceEditor);
+ final nsIDOMWindow domWindow = webBrowser.getContentDOMWindow();
+ nsIDOMWindowInternal windowInternal = org.jboss.tools.vpe.xulrunner.util.XPCOM
+ .queryInterface(domWindow, nsIDOMWindowInternal.class);
+ int pageYOffsetVisual = windowInternal.getPageYOffset();
+ int scrollMaxYVisual = windowInternal.getScrollMaxY();
+ float percentsVisual = ((float)pageYOffsetVisual/scrollMaxYVisual);
+ ScrollBar sb = getSourceEditorVerticalScrollBar();
+ if ((sb != null) && (sb.getMaximum() != 1)) {
+ int srcLinesCount = textWidget.getLineCount();
+ // there is a source scroll bar
+ if (srcLinesCount != 1) {
+ int posLines = ((int) (srcLinesCount*percentsVisual));
+ textWidget.setTopIndex(posLines);
+ }
+ }
+ addSourceScrollListener();
+ }
+ } else {
+ sourceScrollEventFlag = false;
+ selectionManager.setUpdateSelectionEventFlag(false);
+ } // End of fix JBIDE-8701
}
/**
@@ -1768,10 +1888,8 @@
public void setZoomEventManager(IZoomEventManager zoomEventManager) {
this.zoomEventManager = zoomEventManager;
- }
+ }
-
-
public VpeDropWindow getDropWindow() {
return dropWindow;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/SliderFieldEditor.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/SliderFieldEditor.java 2012-01-26
16:23:14 UTC (rev 38204)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/SliderFieldEditor.java 2012-01-26
16:25:50 UTC (rev 38205)
@@ -65,7 +65,7 @@
@Override
protected void createControl(Composite parent) {
- doFillIntoGrid(parent, 2);
+ doFillIntoGrid(parent, 1);
}
@Override
@@ -110,6 +110,8 @@
return 2;
}
+
+
private Composite getSliderComposite(Composite parent) {
if (sliderComposite == null) {
/*
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/VpeBooleanFieldEditor.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/VpeBooleanFieldEditor.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/VpeBooleanFieldEditor.java 2012-01-26
16:25:50 UTC (rev 38205)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.preferences;
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+public class VpeBooleanFieldEditor extends BooleanFieldEditor {
+
+
+ public VpeBooleanFieldEditor() {
+ super();
+ }
+
+ public VpeBooleanFieldEditor(String name, String label, Composite parent) {
+ super(name, label, parent);
+ }
+
+ public VpeBooleanFieldEditor(String name, String labelText, int style,
+ Composite parent) {
+ super(name, labelText, style, parent);
+ }
+
+ @Override
+ protected void createControl(Composite parent) {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = getNumberOfControls();
+ layout.marginWidth = 5;
+ layout.marginHeight = 5;
+ layout.horizontalSpacing = HORIZONTAL_GAP;
+ parent.setLayout(layout);
+ doFillIntoGrid(parent, layout.numColumns);
+ }
+
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/VpePreferencesPage.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/VpePreferencesPage.java 2012-01-26
16:23:14 UTC (rev 38204)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/preferences/VpePreferencesPage.java 2012-01-26
16:25:50 UTC (rev 38205)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.preferences;
-import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT;
@@ -116,25 +115,27 @@
@Override
protected void createFieldEditors() {
- addField(new BooleanFieldEditor(SHOW_VISUAL_TOOLBAR,
+ addField(new VpeBooleanFieldEditor(SHOW_VISUAL_TOOLBAR,
VpeUIMessages.SHOW_VPE_TOOLBAR,
visualEditorToolbarGroup));
- addField(new BooleanFieldEditor(SHOW_BORDER_FOR_UNKNOWN_TAGS,
+ addField(new VpeBooleanFieldEditor(SHOW_BORDER_FOR_UNKNOWN_TAGS,
VpeUIMessages.SHOW_BORDER_FOR_UNKNOWN_TAGS,
visualAppearanceGroup));
- addField(new BooleanFieldEditor(SHOW_NON_VISUAL_TAGS,
+ addField(new VpeBooleanFieldEditor(SHOW_NON_VISUAL_TAGS,
VpeUIMessages.SHOW_NON_VISUAL_TAGS, visualAppearanceGroup));
- addField(new BooleanFieldEditor(SHOW_TEXT_FORMATTING,
+ addField(new VpeBooleanFieldEditor(SHOW_TEXT_FORMATTING,
VpeUIMessages.SHOW_TEXT_FORMATTING, visualAppearanceGroup));
- addField(new BooleanFieldEditor(SHOW_RESOURCE_BUNDLES_USAGE_AS_EL,
+ addField(new VpeBooleanFieldEditor(SHOW_RESOURCE_BUNDLES_USAGE_AS_EL,
VpeUIMessages.SHOW_RESOURCE_BUNDLES_USAGE_AS_EL,
visualAppearanceGroup));
- addField(new BooleanFieldEditor(ASK_TAG_ATTRIBUTES_ON_TAG_INSERT,
+ addField(new VpeBooleanFieldEditor(ASK_TAG_ATTRIBUTES_ON_TAG_INSERT,
VpeUIMessages.ASK_TAG_ATTRIBUTES_ON_TAG_INSERT,
confirmationGroup));
- addField(new
BooleanFieldEditor(INFORM_WHEN_PROJECT_MIGHT_NOT_BE_CONFIGURED_PROPERLY_FOR_VPE,
+ addField(new
VpeBooleanFieldEditor(INFORM_WHEN_PROJECT_MIGHT_NOT_BE_CONFIGURED_PROPERLY_FOR_VPE,
VpeUIMessages.INFORM_WHEN_PROJECT_MIGHT_NOT_BE_CONFIGURED_PROPERLY_FOR_VPE,
confirmationGroup));
+ addField(new VpeBooleanFieldEditor(SYNCHRONIZE_SCROLLING_BETWEEN_SOURCE_VISUAL_PANES,
+ VpeUIMessages.SYNCHRONIZE_SCROLLING_BETWEEN_SOURCE_VISUAL_PANES, tabsGroup));
addField(new VpeComboFieldEditor(DEFAULT_VPE_TAB,
VpeUIMessages.DEFAULT_VPE_TAB,
DEFAULT_VPE_TAB_COMBO_BOX_VALUES, tabsGroup));
@@ -182,17 +183,18 @@
return JspEditorPlugin.getDefault().getPreferenceStore();
}
/**
- * Creates a layout group for vpe preferencess
+ * Creates a layout group for vpe preferences
* @param parent
* @param style
* @param groupTitle
- * @return layut grop for VPE Preferences
+ * @return layout group for VPE Preferences
* @author mareshkau
*/
private static Group createLayoutGroup(final Composite parent,final int style, final
String groupTitle){
Group prefGroup = new Group(parent, style);
prefGroup.setText(groupTitle);
GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
layout.marginHeight = 10;
layout.marginWidth = 10;
layout.horizontalSpacing = 10;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ISelectionManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ISelectionManager.java 2012-01-26
16:23:14 UTC (rev 38204)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/ISelectionManager.java 2012-01-26
16:25:50 UTC (rev 38205)
@@ -32,5 +32,14 @@
* to bring in correspondence visual selection and source selection
*/
public void refreshVisualSelection();
+
+ /**
+ * Check the flag
+ */
+ public boolean isUpdateSelectionEventPerformed();
+ /**
+ * Set the flag indicating that source and visual selection is updating
+ */
+ public void setUpdateSelectionEventFlag(boolean event);
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java 2012-01-26
16:23:14 UTC (rev 38204)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java 2012-01-26
16:25:50 UTC (rev 38205)
@@ -40,6 +40,11 @@
public class SelectionManager implements ISelectionManager {
/**
+ * Flag indicates that the source and visual selection is updating.
+ */
+ public static boolean updateSelectionEventFlag = false;
+
+ /**
* pageContext keeps information about page
*/
private VpePageContext pageContext;
@@ -62,7 +67,18 @@
this.selectionController = selectionController;
}
+ @Override
+ public boolean isUpdateSelectionEventPerformed() {
+ return updateSelectionEventFlag;
+ }
+
+ @Override
+ public void setUpdateSelectionEventFlag(boolean isPerforming) {
+ updateSelectionEventFlag = isPerforming;
+ }
+
public final void setSelection(nsIDOMNode visualNode, int focusOffset, int anchorOffset)
{
+ setUpdateSelectionEventFlag(true);
if (visualNode == null) {
return;
}
@@ -186,6 +202,7 @@
* Selects text in the Visual Part Visual Part according to source selection.
*/
private void refreshVisualTextSelection() {
+ setUpdateSelectionEventFlag(true);
// checks for null, for case when we close editor and background
// update job is running
if (getSourceEditor().getTextViewer() == null) {
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/ScrollLockSourceVisualHandler.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/ScrollLockSourceVisualHandler.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/ScrollLockSourceVisualHandler.java 2012-01-26
16:25:50 UTC (rev 38205)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.preferences.IVpePreferencesPage;
+
+/**
+ * Class that set flag for synchronize scrolling between source and visual panes
+ */
+public class ScrollLockSourceVisualHandler extends VisualPartAbstractHandler {
+
+ public static final String
COMMAND_ID="org.jboss.tools.vpe.commands.scrollLockSourceVisual"; //$NON-NLS-1$
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ /*
+ * Change the enabled state, listeners in VpeController will do the rest
+ */
+ JspEditorPlugin.getDefault().getPreferenceStore().setValue(
+ IVpePreferencesPage.SYNCHRONIZE_SCROLLING_BETWEEN_SOURCE_VISUAL_PANES,
+ !HandlerUtil.toggleCommandState(event.getCommand()));
+ return null;
+ }
+}
\ No newline at end of file
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/ShowBorderHandler.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/ShowBorderHandler.java 2012-01-26
16:23:14 UTC (rev 38204)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/ShowBorderHandler.java 2012-01-26
16:25:50 UTC (rev 38205)
@@ -27,8 +27,6 @@
@Override
protected void toogleShow(VpeController vpeController, boolean state) {
- vpeController.getVisualBuilder().setShowBorderForUnknownTags(
- state);
-
+ vpeController.getVisualBuilder().setShowBorderForUnknownTags(state);
}
-}
+}
\ No newline at end of file
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/ShowOptionAbstractHandler.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/ShowOptionAbstractHandler.java 2012-01-26
16:23:14 UTC (rev 38204)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/handlers/ShowOptionAbstractHandler.java 2012-01-26
16:25:50 UTC (rev 38205)
@@ -27,15 +27,16 @@
public abstract class ShowOptionAbstractHandler extends VisualPartAbstractHandler{
public Object execute(ExecutionEvent event) throws ExecutionException {
- boolean toggleState = !HandlerUtil.toggleCommandState(event
- .getCommand());
+ /*
+ * Change the toggle state
+ */
+ boolean toggleState = !HandlerUtil.toggleCommandState(event.getCommand());
+ /*
+ * Save new state into PreferenceStore
+ */
+ JspEditorPlugin.getDefault().getPreferenceStore()
+ .setValue(getPreferenceKey(),toggleState);
- JspEditorPlugin
- .getDefault()
- .getPreferenceStore()
- .setValue(getPreferenceKey(),
- toggleState);
-
IEditorReference[] openedEditors = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage()
.getEditorReferences();
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2012-01-26
16:23:14 UTC (rev 38204)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2012-01-26
16:25:50 UTC (rev 38205)
@@ -137,6 +137,7 @@
public static String INFORM_WHEN_PROJECT_MIGHT_NOT_BE_CONFIGURED_PROPERLY_FOR_VPE;
public static String DEFAULT_VPE_TAB;
public static String VISUAL_SOURCE_EDITORS_SPLITTING;
+ public static String SYNCHRONIZE_SCROLLING_BETWEEN_SOURCE_VISUAL_PANES;
public static String VISUAL_SOURCE_EDITORS_WEIGHTS;
public static String DEFAULT_VPE_TAB_VISUAL_SOURCE;
public static String DEFAULT_VPE_TAB_SOURCE;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2012-01-26
16:23:14 UTC (rev 38204)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2012-01-26
16:25:50 UTC (rev 38205)
@@ -123,6 +123,7 @@
INFORM_WHEN_PROJECT_MIGHT_NOT_BE_CONFIGURED_PROPERLY_FOR_VPE=Inform if the project is not
configured properly to use Visual Page Editor
DEFAULT_VPE_TAB=Select the default active editor's tab
VISUAL_SOURCE_EDITORS_SPLITTING=Visual/Source editors splitting
+SYNCHRONIZE_SCROLLING_BETWEEN_SOURCE_VISUAL_PANES=Synchronize scrolling between source
and visual panes
VISUAL_SOURCE_EDITORS_WEIGHTS=Size of the Visual Editor pane (0-100%)
VISUAL_APPEARANCE_GROUP_TITLE=Visual appearance
VISUAL_EDITOR_TOOLBAR_BEHAVIOR=Visual Page Editor toolbar behavior