[jbosstools-commits] JBoss Tools SVN: r17664 - in trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css: view and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Sep 18 11:03:48 EDT 2009


Author: sdzmitrovich
Date: 2009-09-18 11:03:45 -0400 (Fri, 18 Sep 2009)
New Revision: 17664

Removed:
   trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/TypeMapper.java
Modified:
   trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/CSSPropertyPage.java
   trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSEditorView.java
   trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4849

Modified: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/CSSPropertyPage.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/CSSPropertyPage.java	2009-09-18 15:03:39 UTC (rev 17663)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/CSSPropertyPage.java	2009-09-18 15:03:45 UTC (rev 17664)
@@ -99,6 +99,8 @@
 					|| (!selectedObject.equals(newSelectedObject)))
 				super.selectionChanged(part, selection);
 			selectedObject = newSelectedObject;
+			
+			update();
 
 		}
 

Deleted: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/TypeMapper.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/TypeMapper.java	2009-09-18 15:03:39 UTC (rev 17663)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/TypeMapper.java	2009-09-18 15:03:45 UTC (rev 17664)
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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.jst.css.properties;
-
-import org.eclipse.ui.views.properties.tabbed.ITypeMapper;
-import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
-import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
-
-/**
- * @author Sergey Dzmitrovich
- * 
- */
-public class TypeMapper implements ITypeMapper {
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.eclipse.ui.views.properties.tabbed.ITypeMapper#mapType(java.lang.
-	 * Object)
-	 */
-	public Class mapType(Object object) {
-
-		while (object instanceof ICSSNode) {
-			if ((object instanceof ICSSStyleRule)
-					|| (((ICSSNode) object).getParentNode() == null)) {
-				break;
-			} else {
-				object = ((ICSSNode) object).getParentNode();
-			}
-		}
-		return object.getClass();
-	}
-
-}

Modified: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSEditorView.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSEditorView.java	2009-09-18 15:03:39 UTC (rev 17663)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSEditorView.java	2009-09-18 15:03:45 UTC (rev 17664)
@@ -11,24 +11,27 @@
 
 package org.jboss.tools.jst.css.view;
 
-import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IViewSite;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.part.IContributedContentsView;
 import org.eclipse.ui.part.IPageBookViewPage;
+import org.eclipse.ui.views.contentoutline.ContentOutline;
 import org.eclipse.ui.views.properties.IPropertySheetPage;
 import org.eclipse.ui.views.properties.PropertySheet;
 import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
-import org.jboss.tools.jst.css.common.CSSSelectionListener;
+import org.jboss.tools.jst.css.common.CSSStyleListener;
+import org.jboss.tools.jst.css.common.ICSSViewListner;
+import org.jboss.tools.jst.css.common.StyleContainer;
 import org.jboss.tools.jst.css.properties.CSSPropertyPage;
 
 /**
  * @author Sergey Dzmitrovich
  * 
  */
-public class CSSEditorView extends PropertySheet {
+public class CSSEditorView extends PropertySheet implements ICSSViewListner {
 
 	static public String CONTRIBUTOR_ID = "org.eclipse.wst.css.core.csssource.source"; //$NON-NLS-1$
 
@@ -37,33 +40,22 @@
 
 		super.init(site);
 		getSite().getPage().removeSelectionListener(this);
-		CSSSelectionListener.getInstance().addSelectionListener(this);
+		CSSStyleListener.getInstance().addSelectionListener(this);
 	}
 
 	@Override
 	public void dispose() {
 
 		super.dispose();
-		CSSSelectionListener.getInstance().removeSelectionListener(this);
+		CSSStyleListener.getInstance().removeSelectionListener(this);
 
 	}
 
 	@Override
-	public void selectionChanged(IWorkbenchPart part, ISelection sel) {
-		super.selectionChanged(part, sel);
-
-		// TODO find better way to react upon changing of node i source editor.
-		// Description of problem: when node is been editing PropertySheet will
-		// not send selection event to page as selection is same;
-		if (getCurrentPage() instanceof CSSPropertyPage)
-			((CSSPropertyPage) getCurrentPage()).update();
-	}
-
-	@Override
 	protected PageRec doCreatePage(final IWorkbenchPart part) {
-		if (part instanceof PropertySheet) {
-			return null;
-		}
+		// if (part instanceof PropertySheet) {
+		// return null;
+		// }
 		IPropertySheetPage page = new CSSPropertyPage(
 				new ITabbedPropertySheetPageContributor() {
 
@@ -102,4 +94,16 @@
 		}
 		return super.getAdapter(key);
 	}
+
+	public void styleChanged(StyleContainer styleContainer) {
+		if (getCurrentPage() instanceof CSSPropertyPage)
+			((CSSPropertyPage) getCurrentPage()).update();
+
+	}
+	@Override
+	protected boolean isImportant(IWorkbenchPart part) {
+		if ((part instanceof IEditorPart) || (part instanceof ContentOutline))
+			return true;
+		return false;
+	}
 }

Modified: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java	2009-09-18 15:03:39 UTC (rev 17663)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java	2009-09-18 15:03:45 UTC (rev 17664)
@@ -11,6 +11,7 @@
 
 package org.jboss.tools.jst.css.view;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -27,12 +28,12 @@
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.ISelectionListener;
 import org.eclipse.ui.IViewSite;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.part.ViewPart;
-import org.jboss.tools.jst.css.common.CSSSelectionListener;
+import org.jboss.tools.jst.css.common.CSSStyleListener;
+import org.jboss.tools.jst.css.common.ICSSViewListner;
 import org.jboss.tools.jst.css.common.StyleContainer;
 import org.jboss.tools.jst.css.messages.CSSUIMessages;
 import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
@@ -41,7 +42,7 @@
  * @author Sergey Dzmitrovich
  * 
  */
-public class CSSPreview extends ViewPart implements ISelectionListener {
+public class CSSPreview extends ViewPart implements ICSSViewListner {
 
 	private Browser browser;
 
@@ -57,13 +58,13 @@
 	public void init(IViewSite site) throws PartInitException {
 		super.init(site);
 
-		CSSSelectionListener.getInstance().addSelectionListener(this);
+		CSSStyleListener.getInstance().addSelectionListener(this);
 	}
 
 	@Override
 	public void dispose() {
 
-		CSSSelectionListener.getInstance().removeSelectionListener(this);
+		CSSStyleListener.getInstance().removeSelectionListener(this);
 		super.dispose();
 	}
 
@@ -155,23 +156,19 @@
 	public void selectionChanged(IWorkbenchPart part, ISelection selection) {
 
 		if (selection instanceof IStructuredSelection) {
+			Map<String, String> newAttributes;
 			IStructuredSelection structuredSelection = (IStructuredSelection) selection;
 			if (structuredSelection.getFirstElement() instanceof StyleContainer) {
 
-				styleAttributes = ((StyleContainer) structuredSelection
+				newAttributes = ((StyleContainer) structuredSelection
 						.getFirstElement()).getStyleAttributes();
 
 			} else {
-				styleAttributes.clear();
+				newAttributes = Collections.EMPTY_MAP;
 			}
 
-			String newStyle = getStyle(styleAttributes);
-			if (!newStyle.equals(currentStyle)) {
+			updateView(newAttributes);
 
-				currentStyle = newStyle;
-				updateBrowser();
-			}
-
 		}
 
 	}
@@ -196,4 +193,17 @@
 	public String getCurrentStyle() {
 		return currentStyle;
 	}
+
+	public void styleChanged(StyleContainer styleContainer) {
+		updateView(styleContainer.getStyleAttributes());
+
+	}
+
+	protected void updateView(Map<String, String> attributes) {
+
+		this.styleAttributes = attributes;
+		this.currentStyle = getStyle(attributes);
+		updateBrowser();
+
+	}
 }



More information about the jbosstools-commits mailing list