Author: vyemialyanchyk
Date: 2009-04-10 08:52:20 -0400 (Fri, 10 Apr 2009)
New Revision: 14679
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/views/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/views/test/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/views/test/QueryPageViewerTest.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryPageViewer.java
Log:
JBIDE-4139
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryPageViewer.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryPageViewer.java 2009-04-10
12:40:07 UTC (rev 14678)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryPageViewer.java 2009-04-10
12:52:20 UTC (rev 14679)
@@ -59,7 +59,7 @@
*/
public class QueryPageViewer {
- class LabelProviderImpl implements ITableLabelProvider {
+ static public class LabelProviderImpl implements ITableLabelProvider {
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
@@ -69,7 +69,9 @@
if (element instanceof QueryPage) {
value = ( (QueryPage) element).getList().get(columnIndex);
}
-
+ if (value == null) {
+ return ""; //$NON-NLS-1$
+ }
if (value.getClass().isArray() ) {
Object[] arr = (Object[]) value;
if (columnIndex > arr.length - 1) {
@@ -80,7 +82,7 @@
if(columnIndex!=0) {
return "?"; //$NON-NLS-1$
} else {
- return value == null ? "" : value.toString(); //$NON-NLS-1$
+ return value.toString();
}
}
}
@@ -110,7 +112,7 @@
};
// should map to our table model instead
- class ContentProviderImpl implements IStructuredContentProvider {
+ static class ContentProviderImpl implements IStructuredContentProvider {
public Object[] getElements(Object inputElement) {
if (inputElement instanceof QueryPage) {
QueryPage qp = ( (QueryPage) inputElement);
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/views/test/QueryPageViewerTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/views/test/QueryPageViewerTest.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/views/test/QueryPageViewerTest.java 2009-04-10
12:52:20 UTC (rev 14679)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.hibernate.eclipse.console.views.test;
+
+import org.hibernate.eclipse.console.views.QueryPageViewer;
+import junit.framework.TestCase;
+
+public class QueryPageViewerTest extends TestCase {
+
+ public void testLabelProviderImpl() {
+
+ QueryPageViewer.LabelProviderImpl labelProvider =
+ new QueryPageViewer.LabelProviderImpl();
+ String res = labelProvider.getColumnText(null, 0);
+ assertTrue("".equals(res)); //$NON-NLS-1$
+ String[] arr = new String[1];
+ final String testStr = "testVal"; //$NON-NLS-1$
+ arr[0] = testStr;
+ res = labelProvider.getColumnText(arr, 0);
+ assertTrue(testStr.equals(res));
+ }
+}