From jbosstools-commits at lists.jboss.org Thu Feb 18 11:10:48 2010 Content-Type: multipart/mixed; boundary="===============4573838547502259282==" MIME-Version: 1.0 From: jbosstools-commits at lists.jboss.org To: jbosstools-commits at lists.jboss.org Subject: [jbosstools-commits] JBoss Tools SVN: r20362 - in trunk: jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5872 and 3 other directories. Date: Thu, 18 Feb 2010 11:10:48 -0500 Message-ID: <201002181610.o1IGAmwQ027478@svn01.web.mwc.hst.phx2.redhat.com> --===============4573838547502259282== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: yradtsevich Date: 2010-02-18 11:10:47 -0500 (Thu, 18 Feb 2010) New Revision: 20362 Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebCo= ntent/pages/JBIDE/5872/ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebCo= ntent/pages/JBIDE/5872/JBIDE-5872.html trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf= /vpe/jsf/test/jbide/EditFontFamilyTest_JBIDE5872.java Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf= /vpe/jsf/test/JsfAllTests.java trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/too= lbar/format/FontNameFormatController.java Log: https://jira.jboss.org/jira/browse/JBIDE-5872 VPE throws java.lang.NullPointerException, while editing font-family - fixed - JUnit created Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/W= ebContent/pages/JBIDE/5872/JBIDE-5872.html =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebC= ontent/pages/JBIDE/5872/JBIDE-5872.html (rev 0) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebC= ontent/pages/JBIDE/5872/JBIDE-5872.html 2010-02-18 16:10:47 UTC (rev 20362) @@ -0,0 +1,5 @@ + +
+ + + \ No newline at end of file Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/to= ols/jsf/vpe/jsf/test/JsfAllTests.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/JsfAllTests.java 2010-02-18 15:38:34 UTC (rev 20361) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/JsfAllTests.java 2010-02-18 16:10:47 UTC (rev 20362) @@ -18,6 +18,7 @@ = import org.jboss.tools.jsf.vpe.jsf.test.jbide.ChangeMessageBundleTest_JBID= E5818; import org.jboss.tools.jsf.vpe.jsf.test.jbide.ContextMenuDoubleInsertionTe= st_JBIDE3888; +import org.jboss.tools.jsf.vpe.jsf.test.jbide.EditFontFamilyTest_JBIDE5872; import org.jboss.tools.jsf.vpe.jsf.test.jbide.FacetProcessingTest; import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE1105Test; import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE1460Test; @@ -122,6 +123,7 @@ = TestSuite suite =3D new TestSuite("Tests for Vpe Jsf components"); //$NO= N-NLS-1$ // $JUnit-BEGIN$ + suite.addTestSuite(EditFontFamilyTest_JBIDE5872.class); suite.addTestSuite(ChangeMessageBundleTest_JBIDE5818.class); suite.addTestSuite(TestForUsingComponentsLibrariesWithDefaultNamespace.c= lass); suite.addTestSuite(EditingSPecialSymbolsVPE_JBIDE3810.class); Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools= /jsf/vpe/jsf/test/jbide/EditFontFamilyTest_JBIDE5872.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/jbide/EditFontFamilyTest_JBIDE5872.java = (rev 0) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/jbide/EditFontFamilyTest_JBIDE5872.java 2010-02-18 16:10:47 = UTC (rev 20362) @@ -0,0 +1,72 @@ +/*************************************************************************= ****** + * 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.jsf.vpe.jsf.test.jbide; + +import org.eclipse.jface.text.TextViewer; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.graphics.Point; +import org.eclipse.wst.sse.ui.StructuredTextEditor; +import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests; +import org.jboss.tools.vpe.editor.VpeController; +import org.jboss.tools.vpe.ui.test.TestUtil; +import org.jboss.tools.vpe.ui.test.VpeTest; + +/** + * Test for JBIDE-5872: VPE throws java.lang.NullPointerException, + * while editing font-family. + * = + * @see JBIDE-58= 72 + * @author Yahor Radtsevich (yradtsevich) + */ +public class EditFontFamilyTest_JBIDE5872 extends VpeTest { + private static final Point EDIT_POSITION =3D new Point(3, 40); + private static final int SELECTION_LENGTH =3D 1; + private static final String TEST_PAGE_NAME =3D "JBIDE/5872/JBIDE-5872.htm= l"; + + public EditFontFamilyTest_JBIDE5872(String name) { + super(name); + } + + /** + * Deletes quote after style attribute. This may lead to NPE. + * = + * @see JBIDE-5= 872 + */ + public void testEditFontFamily() throws Throwable { + TestUtil.waitForJobs(); + setException(null); + + VpeController vpeController + =3D openInVpe(JsfAllTests.IMPORT_PROJECT_NAME, TEST_PAGE_NAME); + StructuredTextEditor sourceEditor =3D vpeController.getSourceEditor(); + TextViewer textViewer =3D sourceEditor.getTextViewer(); + StyledText textWidget =3D textViewer.getTextWidget(); + + int offset =3D getCaretOffset(textViewer, EDIT_POSITION); + textWidget.setSelectionRange(offset, SELECTION_LENGTH); + textWidget.insert(""); + TestUtil.waitForIdle(); + = + ISelectionProvider selectionProvider =3D sourceEditor.getSelectionProvid= er(); + vpeController.selectionChanged(new SelectionChangedEvent( + selectionProvider, selectionProvider.getSelection())); + + if(getException() !=3D null) { + throw new Exception(getException()); + } + } + = + private static int getCaretOffset(TextViewer textViewer, Point position) { + return TestUtil.getLinePositionOffcet(textViewer, position.x, position.y= ); + } +} Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/edi= tor/toolbar/format/FontNameFormatController.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/to= olbar/format/FontNameFormatController.java 2010-02-18 15:38:34 UTC (rev 203= 61) +++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/to= olbar/format/FontNameFormatController.java 2010-02-18 16:10:47 UTC (rev 203= 62) @@ -14,6 +14,7 @@ import org.jboss.tools.vpe.editor.template.textformating.FormatAttributeDa= ta; import org.jboss.tools.vpe.editor.toolbar.format.css.StyleAttribute; import org.jboss.tools.vpe.editor.toolbar.format.css.StyleProperty; +import org.jboss.tools.vpe.editor.toolbar.format.css.Token; import org.w3c.dom.Attr; = /** @@ -80,33 +81,34 @@ * enabled) */ public void setToolbarItemEnabled(boolean enabled) { - comboBlockFormat.setEnabled(enabled); - if (enabled) { - Attr style =3D getStyleAttributeFromSelectedNode(true); - if (style !=3D null) { - StyleAttribute styleAttribute =3D new StyleAttribute(style); - StyleProperty fontProperty =3D styleAttribute - .getProperty(STYLE_PROPERTY_NAME); - if (fontProperty !=3D null) { - String fontName =3D fontProperty.getPropertyValue() - .getDirtyValue().trim(); - if (fontName !=3D null) { - fontName =3D fontName.replaceAll(REPLACE_VALUE, EMPTY); - if (getComboBlockFormat().getText().equalsIgnoreCase( - fontName)) { - return; - } - String[] items =3D this.getComboBlockFormat().getItems(); - for (int i =3D 0; i < items.length; i++) { - if (items[i].equalsIgnoreCase(fontName)) { - this.getComboBlockFormat().select(i); - return; - } - } + comboBlockFormat.setEnabled(enabled); + if (enabled) { + Attr style =3D getStyleAttributeFromSelectedNode(true); + if (style !=3D null) { + StyleAttribute styleAttribute =3D new StyleAttribute(style); + StyleProperty fontProperty + =3D styleAttribute.getProperty(STYLE_PROPERTY_NAME); + if (fontProperty !=3D null) { + Token fontPropertyValue =3D fontProperty.getPropertyValue(); + if (fontPropertyValue !=3D null) { + String fontName + =3D fontPropertyValue.getDirtyValue().trim(); + fontName =3D fontName.replaceAll(REPLACE_VALUE, EMPTY); + if (getComboBlockFormat().getText().equalsIgnoreCase( + fontName)) { + return; + } + String[] items =3D this.getComboBlockFormat().getItems(); + for (int i =3D 0; i < items.length; i++) { + if (items[i].equalsIgnoreCase(fontName)) { + this.getComboBlockFormat().select(i); + return; + } + } + } + } } } - } - } - getComboBlockFormat().select(0); + getComboBlockFormat().select(0); } -} \ No newline at end of file +} --===============4573838547502259282==--