[jbosstools-commits] JBoss Tools SVN: r17408 - in trunk/jst: plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view and 4 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Sep 1 11:34:02 EDT 2009


Author: sdzmitrovich
Date: 2009-09-01 11:34:01 -0400 (Tue, 01 Sep 2009)
New Revision: 17408

Added:
   trunk/jst/tests/org.jboss.tools.jst.css.test/resources/cssTest/WebContent/pages/JBIDE/4791/
   trunk/jst/tests/org.jboss.tools.jst.css.test/resources/cssTest/WebContent/pages/JBIDE/4791/propertyViewTest.css
   trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/jbide/SelectionLosingByPropertySheet_JBIDE4791.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/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/AbstractCSSViewTest.java
   trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/CSSAllTests.java
   trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/CSSViewTest.java
   trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/jbide/InputFractionalValueTest_JBIDE4790.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4791

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-01 15:06:21 UTC (rev 17407)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/CSSPropertyPage.java	2009-09-01 15:34:01 UTC (rev 17408)
@@ -20,6 +20,8 @@
 import org.eclipse.core.databinding.observable.IChangeListener;
 import org.eclipse.core.databinding.observable.IObservable;
 import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.StructuredSelection;
@@ -67,6 +69,26 @@
 		super.init(pageSite);
 		pageSite.getWorkbenchWindow().getSelectionService()
 				.addPostSelectionListener(this);
+
+		// FIXED FOR JBIDE-4791
+		pageSite.setSelectionProvider(new ISelectionProvider() {
+
+			public void setSelection(ISelection selection) {
+			}
+
+			public void removeSelectionChangedListener(
+					ISelectionChangedListener listener) {
+			}
+
+			public ISelection getSelection() {
+				return selectedObject != null ? new StructuredSelection(
+						selectedObject) : StructuredSelection.EMPTY;
+			}
+
+			public void addSelectionChangedListener(
+					ISelectionChangedListener listener) {
+			}
+		});
 	}
 
 	@Override

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-01 15:06:21 UTC (rev 17407)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSEditorView.java	2009-09-01 15:34:01 UTC (rev 17408)
@@ -13,6 +13,7 @@
 
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.IContributedContentsView;
 import org.eclipse.ui.part.IPageBookViewPage;
 import org.eclipse.ui.views.properties.IPropertySheetPage;
 import org.eclipse.ui.views.properties.PropertySheet;
@@ -57,4 +58,16 @@
 	public void postSelectionChanged(SelectionChangedEvent event){
 		getSelectionProvider().postSelectionChanged(event);
 	}
+
+	@Override
+	public Object getAdapter(Class key) {
+		if (key == IContributedContentsView.class) {
+			return new IContributedContentsView() {
+				public IWorkbenchPart getContributingPart() {
+					return getCurrentContributingPart();
+				}
+			};
+		}
+		return super.getAdapter(key);
+	}
 }

Added: trunk/jst/tests/org.jboss.tools.jst.css.test/resources/cssTest/WebContent/pages/JBIDE/4791/propertyViewTest.css
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.css.test/resources/cssTest/WebContent/pages/JBIDE/4791/propertyViewTest.css	                        (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.css.test/resources/cssTest/WebContent/pages/JBIDE/4791/propertyViewTest.css	2009-09-01 15:34:01 UTC (rev 17408)
@@ -0,0 +1,4 @@
+/* test */
+.test {
+	color: red;
+}
\ No newline at end of file


Property changes on: trunk/jst/tests/org.jboss.tools.jst.css.test/resources/cssTest/WebContent/pages/JBIDE/4791/propertyViewTest.css
___________________________________________________________________
Name: svn:mime-type
   + text/css
Name: svn:eol-style
   + native

Modified: trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/AbstractCSSViewTest.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/AbstractCSSViewTest.java	2009-09-01 15:06:21 UTC (rev 17407)
+++ trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/AbstractCSSViewTest.java	2009-09-01 15:34:01 UTC (rev 17408)
@@ -31,6 +31,9 @@
 /**
  * @author Sergey Dzmitrovich
  * 
+ *         abstract base class for css test's classes. Override getProjectName()
+ *         method if other imported project is used.
+ * 
  */
 public abstract class AbstractCSSViewTest extends TestCase {
 
@@ -39,6 +42,8 @@
 	public static final String CSS_PREVIEW_VIEW = "org.jboss.tools.jst.css.view.preview"; //$NON-NLS-1$
 	public static final String CSS_EDITOR_ID = "org.eclipse.wst.css.core.csssource.source"; //$NON-NLS-1$
 	public static final String CSS_PERSPECTIVE = "org.jboss.tools.jst.cssPerspective"; //$NON-NLS-1$
+	public static final String IMPORT_PROJECT_NAME = "cssTest"; //$NON-NLS-1$
+
 	/**
 	 * 
 	 * @param componentPage
@@ -170,6 +175,8 @@
 	 * 
 	 * @return
 	 */
-	public abstract String getProjectName();
+	public String getProjectName() {
+		return IMPORT_PROJECT_NAME;
+	}
 
 }

Modified: trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/CSSAllTests.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/CSSAllTests.java	2009-09-01 15:06:21 UTC (rev 17407)
+++ trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/CSSAllTests.java	2009-09-01 15:34:01 UTC (rev 17408)
@@ -15,11 +15,14 @@
 import junit.framework.TestSuite;
 
 import org.jboss.tools.jst.css.test.jbide.InputFractionalValueTest_JBIDE4790;
+import org.jboss.tools.jst.css.test.jbide.SelectionLosingByPropertySheet_JBIDE4791;
 import org.jboss.tools.test.util.ProjectImportTestSetup;
 
 /**
  * @author Sergey Dzmitrovich
  * 
+ *         To import other projects add names of imported projects to array the
+ *         same way as AbstractCSSViewTest.IMPORT_PROJECT_NAME
  */
 public class CSSAllTests {
 
@@ -29,14 +32,15 @@
 
 		TestSuite suite = new TestSuite("Tests for CSS views"); //$NON-NLS-1$
 		// $JUnit-BEGIN$
-		suite.addTestSuite(CSSViewTest.class);
-		suite.addTestSuite(InputFractionalValueTest_JBIDE4790.class);
+//		suite.addTestSuite(CSSViewTest.class);
+//		suite.addTestSuite(InputFractionalValueTest_JBIDE4790.class);
+		suite.addTestSuite(SelectionLosingByPropertySheet_JBIDE4791.class);
 		// $JUnit-END$
 
 		return new ProjectImportTestSetup(
 				suite,
 				CSSTestPlugin.PLUGIN_ID,
 				new String[] { RESOURCE_PATH + CSSViewTest.IMPORT_PROJECT_NAME },
-				new String[] { CSSViewTest.IMPORT_PROJECT_NAME });
+				new String[] { AbstractCSSViewTest.IMPORT_PROJECT_NAME });
 	}
 }

Modified: trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/CSSViewTest.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/CSSViewTest.java	2009-09-01 15:06:21 UTC (rev 17407)
+++ trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/CSSViewTest.java	2009-09-01 15:34:01 UTC (rev 17408)
@@ -43,16 +43,11 @@
  */
 public class CSSViewTest extends AbstractCSSViewTest {
 
-	public static final String IMPORT_PROJECT_NAME = "cssTest"; //$NON-NLS-1$
 
 	public static final String TEST_PAGE_NAME = "test.css"; //$NON-NLS-1$
 
 	public static final int COUNT_TABS = 5;
 
-	@Override
-	public String getProjectName() {
-		return IMPORT_PROJECT_NAME;
-	}
 
 	/**
 	 * 

Modified: trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/jbide/InputFractionalValueTest_JBIDE4790.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/jbide/InputFractionalValueTest_JBIDE4790.java	2009-09-01 15:06:21 UTC (rev 17407)
+++ trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/jbide/InputFractionalValueTest_JBIDE4790.java	2009-09-01 15:34:01 UTC (rev 17408)
@@ -32,8 +32,6 @@
  */
 public class InputFractionalValueTest_JBIDE4790 extends AbstractCSSViewTest {
 
-	public static final String IMPORT_PROJECT_NAME = "cssTest"; //$NON-NLS-1$
-
 	public static final String TEST_PAGE_NAME = "JBIDE/4790/inputFractional.css"; //$NON-NLS-1$
 
 	public static final String TEST_CSS_ATTRIBUTE_NAME = "font-size"; //$NON-NLS-1$
@@ -128,14 +126,4 @@
 		return text.replaceAll(" ", ""); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.jboss.tools.jst.css.test.AbstractCSSViewTest#getProjectName()
-	 */
-	@Override
-	public String getProjectName() {
-		return IMPORT_PROJECT_NAME;
-	}
-
 }

Added: trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/jbide/SelectionLosingByPropertySheet_JBIDE4791.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/jbide/SelectionLosingByPropertySheet_JBIDE4791.java	                        (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/jbide/SelectionLosingByPropertySheet_JBIDE4791.java	2009-09-01 15:34:01 UTC (rev 17408)
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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.test.jbide;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.views.properties.PropertySheet;
+import org.eclipse.wst.css.core.internal.document.CSSStructuredDocumentRegionContainer;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.jst.css.test.AbstractCSSViewTest;
+import org.jboss.tools.jst.css.view.CSSEditorView;
+import org.jboss.tools.test.util.JobUtils;
+import org.w3c.dom.css.CSSRule;
+
+/**
+ * @author Sergey Dzmitrovich
+ * 
+ *         https://jira.jboss.org/jira/browse/JBIDE-4791
+ * 
+ */
+public class SelectionLosingByPropertySheet_JBIDE4791 extends
+		AbstractCSSViewTest {
+
+	public static final String TEST_PAGE_NAME = "JBIDE/4791/propertyViewTest.css"; //$NON-NLS-1$
+
+	public static final String PROPERTY_SHEET_VIEW_ID = "org.eclipse.ui.views.PropertySheet"; //$NON-NLS-1$
+
+	public static final String SELECTION_FIELD_NAME = "currentSelection"; //$NON-NLS-1$
+
+	public void testSelectionLosingByPropertySheet() throws CoreException,
+			SecurityException, IllegalArgumentException, NoSuchFieldException,
+			IllegalAccessException {
+
+		IFile pageFile = getComponentPath(TEST_PAGE_NAME, getProjectName());
+
+		assertNotNull(pageFile);
+
+		PropertySheet propertySheet = (PropertySheet) openView(PROPERTY_SHEET_VIEW_ID);
+
+		assertNotNull(propertySheet);
+
+		StructuredTextEditor editor = (StructuredTextEditor) openEditor(
+				pageFile, CSS_EDITOR_ID);
+
+		assertNotNull(editor);
+
+		ICSSModel model = (ICSSModel) getStructuredModel(pageFile);
+
+		assertNotNull(model);
+
+		ICSSStyleSheet document = (ICSSStyleSheet) model.getDocument();
+
+		assertNotNull(document);
+
+		CSSRule cssRule = document.getCssRules().item(0);
+
+		assertNotNull(cssRule);
+
+		int offset = ((CSSStructuredDocumentRegionContainer) cssRule)
+				.getStartOffset();
+
+		setSelection(editor, offset, 0);
+
+		ISelection selection = (ISelection) getFieldValue(propertySheet,
+				SELECTION_FIELD_NAME);
+
+		assertTrue(selection instanceof IStructuredSelection);
+
+		assertEquals(cssRule, ((IStructuredSelection) selection)
+				.getFirstElement());
+
+		CSSEditorView view = (CSSEditorView) openView(CSS_EDITOR_VIEW);
+		
+		JobUtils.delay(2000);
+
+		selection = (ISelection) getFieldValue(propertySheet,
+				SELECTION_FIELD_NAME);
+
+		assertTrue(selection instanceof IStructuredSelection);
+
+		assertEquals(cssRule, ((IStructuredSelection) selection)
+				.getFirstElement());
+
+	}
+
+}


Property changes on: trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/jbide/SelectionLosingByPropertySheet_JBIDE4791.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native



More information about the jbosstools-commits mailing list