Author: mareshkau
Date: 2010-09-20 07:24:26 -0400 (Mon, 20 Sep 2010)
New Revision: 25019
Removed:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/ISelectionBarController.java
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/selection/bar/SelectionBar.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/handlers/SelectionBarHandler.java
Log:
JBIDE-7059
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 2010-09-20
09:13:07 UTC (rev 25018)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorPart.java 2010-09-20
11:24:26 UTC (rev 25019)
@@ -46,13 +46,12 @@
import org.eclipse.ui.part.MultiPageSelectionProvider;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.jboss.tools.common.core.resources.XModelObjectEditorInput;
-import org.jboss.tools.jst.jsp.selection.bar.ISelectionBarController;
import org.jboss.tools.jst.jsp.selection.bar.SelectionBar;
/**
*
*/
-public abstract class JSPMultiPageEditorPart extends EditorPart implements
ISelectionBarController {
+public abstract class JSPMultiPageEditorPart extends EditorPart {
private CTabFolder container;
@@ -94,7 +93,7 @@
parent2.setLayout(new GridLayout(2, false));
selectionBar = new SelectionBar(sourcePart);
- selectionBar.createToolBarComposite(parent2, true);
+ selectionBar.createToolBarComposite(parent2);
editor.addPropertyListener(new IPropertyListener() {
public void propertyChanged(Object source, int propertyId) {
JSPMultiPageEditorPart.this
@@ -151,12 +150,12 @@
protected abstract IEditorSite createSite(IEditorPart editor);
public void dispose() {
+ selectionBar.dispose();
getSite().setSelectionProvider(null);
for (int i = 0; i < nestedEditors.size(); ++i) {
IEditorPart editor = (IEditorPart) nestedEditors.get(i);
disposePart(editor);
}
- selectionBar.dispose();
nestedEditors.clear();
}
@@ -347,16 +346,5 @@
protected void setPageText(int pageIndex, String text) {
getItem(pageIndex).setText(text);
}
-
- public void showSelectionBar() {
- selectionBar.setVisible(true);
- }
-
- public void hideSelectionBar() {
- selectionBar.setVisible(false);
- }
-
- public boolean isSelectionBarAvailable() {
- return selectionBar.isVisible();
- }
+
}
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/ISelectionBarController.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/ISelectionBarController.java 2010-09-20
09:13:07 UTC (rev 25018)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/ISelectionBarController.java 2010-09-20
11:24:26 UTC (rev 25019)
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.selection.bar;
-
-/**
- * Controller to control state of selection bar
- *
- * @author mareshkau
- *
- */
-public interface ISelectionBarController {
- /**
- * Shows selection bar
- */
- public void showSelectionBar();
- /**
- * Hides selection bar
- */
- public void hideSelectionBar();
- /**
- * retry the availability of selection bar
- */
- public boolean isSelectionBarAvailable();
-}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/SelectionBar.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/SelectionBar.java 2010-09-20
09:13:07 UTC (rev 25018)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/SelectionBar.java 2010-09-20
11:24:26 UTC (rev 25019)
@@ -14,8 +14,12 @@
import java.util.List;
import org.eclipse.compare.Splitter;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.CommandEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.ICommandListener;
+import org.eclipse.core.commands.IStateListener;
+import org.eclipse.core.commands.State;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
@@ -47,6 +51,8 @@
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
import org.eclipse.ui.internal.WorkbenchImages;
import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
@@ -54,7 +60,6 @@
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
-import org.jboss.tools.jst.jsp.preferences.IVpePreferencesPage;
import org.jboss.tools.jst.jsp.selection.SelectionHelper;
import org.jboss.tools.jst.jsp.selection.SourceSelection;
import org.jboss.tools.jst.jsp.selection.SourceSelectionBuilder;
@@ -70,7 +75,7 @@
* @author yradtsevich
* @author mareshkau
*/
-public class SelectionBar implements ISelectionChangedListener{
+public class SelectionBar implements ISelectionChangedListener, IStateListener{
/**
*
*/
@@ -88,23 +93,33 @@
private Composite cmpToolBar = null;
private Composite cmpTlEmpty = null;
private StructuredTextEditor textEditor;
-
+ //Selection Bar State
+ private State toggleSelBarState;
+
public SelectionBar(StructuredTextEditor textEditor) {
super();
this.textEditor = textEditor;
this.textEditor.getTextViewer().addSelectionChangedListener(this);
+
+ ICommandService commandService =
+ (ICommandService) PlatformUI.getWorkbench()
+ .getService(ICommandService.class);
+ toggleSelBarState= commandService.getCommand(
+ "org.jboss.tools.jst.jsp.commands.showSelectionBar") //$NON-NLS-1$
+ .getState("org.eclipse.ui.commands.toggleState"); //$NON-NLS-1$
+ toggleSelBarState.addListener(this);
}
/**
* Visibility state of the {@code SelectionBar}.
*/
- private static boolean visible;
+ //private boolean visible;
private ImageButton arrowButton;
private Node currentSelectedNode = null;
private Node currentLastNode = null;
- public Composite createToolBarComposite(Composite parent, boolean visible) {
+ public Composite createToolBarComposite(Composite parent) {
splitter = new Splitter(parent, SWT.NONE);
splitter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
/*
@@ -134,6 +149,7 @@
* Hide the selection bar
*/
setVisible(false);
+ toggleSelBarState.setValue(false);
}
};
@@ -155,7 +171,8 @@
selBar.setLayoutData(selBarData);
createArrowButton();
cmpToolBar.layout();
- setVisible(visible);
+ splitter.getParent().layout(true, true);
+ setVisible((Boolean)toggleSelBarState.getValue());
return splitter;
}
@@ -172,68 +189,9 @@
splitter.setVisible(cmpTlEmpty, true);
}
splitter.getParent().layout(true, true);
-
- this.visible = visible;
-// /*
-// *
https://jira.jboss.org/jira/browse/JBIDE-4968
-// * Updating VPE toolbar icon on selection bar changes.
-// */
-// if (vpeController != null) {
-// vpeController.updateVpeToolbar();
-// }
-// fireVisibilityListeners();
}
- /**
- * Returns {@code visible} state of this {@code SelectionBar}.
- */
- public boolean isVisible() {
- return visible;
- }
-// /**
-// * Adds the listener to the collection of listeners who will
-// * be notified when the {@code #visible} state is changed.
-// *
-// * @param listener the listener which should be notified
-// *
-// * @see VisibilityListener
-// * @see VisibilityEvent
-// */
-// public void addVisibilityListener(VisibilityListener listener) {
-// visibilityListeners.add(listener);
-// }
-//
-// /**
-// * Removes the listener from the collection of listeners who will
-// * be notified when the {@link #visible} state is changed.
-// *
-// * @param listener the listener which should be removed
-// *
-// * @see VisibilityListener
-// */
-// public void removeVisibilityListener(VisibilityListener listener) {
-// visibilityListeners.remove(listener);
-// }
-//
-// /**
-// * Fires all registered instances of {@code VisibilityListener} by
-// * sending them {@link VisibilityEvent}.
-// *
-// * @see #addVisibilityListener(VisibilityListener)
-// * @see #removeVisibilityListener(VisibilityListener)
-// */
-// private void fireVisibilityListeners() {
-// VisibilityEvent event = new VisibilityEvent(this);
-// for (VisibilityListener listener : visibilityListeners) {
-// listener.visibilityChanged(event);
-// }
-// }
-//
-// public void setVpeController(VpeController vpeController) {
-// this.vpeController = vpeController;
-// }
-
/**
* Updates buttons in the selection bar and the drop-down menu
* according to the source selection.
@@ -530,7 +488,9 @@
public void dispose() {
removeNodeListenerFromAllNodes();
-
+ if(textEditor.getTextViewer()!=null)
+ textEditor.getTextViewer().removeSelectionChangedListener(this);
+ toggleSelBarState.removeListener(this);
if (splitter != null) {
splitter.dispose();
splitter = null;
@@ -684,6 +644,12 @@
public void selectionChanged(SelectionChangedEvent event) {
updateNodes(true);
}
+
+ @Override
+ public void handleStateChange(State state, Object oldValue) {
+ setVisible((Boolean)state.getValue());
+ }
+
}
/**
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/handlers/SelectionBarHandler.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/handlers/SelectionBarHandler.java 2010-09-20
09:13:07 UTC (rev 25018)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/handlers/SelectionBarHandler.java 2010-09-20
11:24:26 UTC (rev 25019)
@@ -15,10 +15,7 @@
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.jboss.tools.jst.jsp.selection.bar.ISelectionBarController;
/**
* Selection bar handler
@@ -35,13 +32,13 @@
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
- IEditorPart activeEditor = HandlerUtil.getActiveEditorChecked(event);
- boolean togleState = HandlerUtil.toggleCommandState(event.getCommand());
- if(!togleState){
- ((ISelectionBarController)activeEditor).showSelectionBar();
- }else{
- ((ISelectionBarController)activeEditor).hideSelectionBar();
- }
+// IEditorPart activeEditor = HandlerUtil.getActiveEditorChecked(event);
+ HandlerUtil.toggleCommandState(event.getCommand());
+// if(!togleState){
+// ((ISelectionBarController)activeEditor).showSelectionBar();
+// }else{
+// ((ISelectionBarController)activeEditor).hideSelectionBar();
+// }
return null;
}