Revision: 3444
Author: silva.josemanuel1
Date: Thu Apr 8 07:59:33 2010
Log: Created test classes for the OLAP UI components.
http://code.google.com/p/power-architect/source/detail?r=3444
Added:
/trunk/regress/ca/sqlpower/architect/swingui/olap
/trunk/regress/ca/sqlpower/architect/swingui/olap/TestCubePane.java
/trunk/regress/ca/sqlpower/architect/swingui/olap/TestDimensionPane.java
/trunk/regress/ca/sqlpower/architect/swingui/olap/TestOLAPComponent.java
/trunk/regress/ca/sqlpower/architect/swingui/olap/TestUsageComponent.java
/trunk/regress/ca/sqlpower/architect/swingui/olap/TestVirtualCubePane.java
Modified:
/trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSession.java
/trunk/regress/ca/sqlpower/architect/util/ArchitectNewValueMaker.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/olap/CubePane.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/olap/DimensionPane.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/olap/OLAPPane.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/olap/UsageComponent.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/olap/VirtualCubePane.java
=======================================
--- /dev/null
+++ /trunk/regress/ca/sqlpower/architect/swingui/olap/TestCubePane.java Thu
Apr 8 07:59:33 2010
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2010, SQL Power Group Inc.
+ *
+ * This file is part of Power*Architect.
+ *
+ * Power*Architect is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Power*Architect is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package ca.sqlpower.architect.swingui.olap;
+
+import ca.sqlpower.architect.olap.MondrianModel.Cube;
+import ca.sqlpower.object.SPObject;
+
+public class TestCubePane extends TestOLAPComponent {
+
+ public TestCubePane(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ Cube cube = new Cube();
+ schema.addCube(cube);
+ olapComponent = new CubePane(cube, contentPane);
+ contentPane.addChild(olapComponent, 0);
+ }
+
+ @Override
+ protected Class<? extends SPObject> getChildClassType() {
+ return CubePane.class;
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/regress/ca/sqlpower/architect/swingui/olap/TestDimensionPane.java
Thu Apr 8 07:59:33 2010
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2010, SQL Power Group Inc.
+ *
+ * This file is part of Power*Architect.
+ *
+ * Power*Architect is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Power*Architect is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package ca.sqlpower.architect.swingui.olap;
+
+import ca.sqlpower.architect.olap.MondrianModel.Dimension;
+import ca.sqlpower.object.SPObject;
+
+public class TestDimensionPane extends TestOLAPComponent {
+
+ public TestDimensionPane(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ Dimension dimension = new Dimension();
+ schema.addDimension(dimension);
+ olapComponent = new DimensionPane(dimension, contentPane);
+ contentPane.addChild(olapComponent, 0);
+ }
+
+ @Override
+ protected Class<? extends SPObject> getChildClassType() {
+ return DimensionPane.class;
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/regress/ca/sqlpower/architect/swingui/olap/TestOLAPComponent.java
Thu Apr 8 07:59:33 2010
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2010, SQL Power Group Inc.
+ *
+ * This file is part of Power*Architect.
+ *
+ * Power*Architect is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Power*Architect is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package ca.sqlpower.architect.swingui.olap;
+
+import ca.sqlpower.architect.ArchitectProject;
+import ca.sqlpower.architect.olap.OLAPSession;
+import ca.sqlpower.architect.olap.MondrianModel.Schema;
+import ca.sqlpower.architect.swingui.PlayPenComponent;
+import ca.sqlpower.architect.swingui.PlayPenContentPane;
+import ca.sqlpower.architect.util.ArchitectNewValueMaker;
+import ca.sqlpower.object.PersistedSPObjectTest;
+import ca.sqlpower.object.SPObject;
+import ca.sqlpower.sql.DataSourceCollection;
+import ca.sqlpower.sql.SPDataSource;
+import ca.sqlpower.testutil.NewValueMaker;
+
+/**
+ * A abstract test class that can be used to help test any of the
+ * OLAP swing ui components. It sets up a project for containing
+ * the OLAP model, and another project containing the OLAP content pane.
+ */
+public abstract class TestOLAPComponent extends PersistedSPObjectTest {
+
+ protected PlayPenContentPane contentPane;
+ protected Schema schema;
+ protected PlayPenComponent olapComponent;
+
+ public TestOLAPComponent(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ ArchitectProject project = new ArchitectProject();
+ getRootObject().addChild(project, 0);
+ OLAPSession session = new OLAPSession(new Schema());
+ project.getOlapRootObject().addChild(session);
+ schema = session.getSchema();
+ contentPane = new PlayPenContentPane(session);
+ project.addOLAPContentPane(contentPane);
+ }
+
+ @Override
+ public NewValueMaker createNewValueMaker(SPObject root,
DataSourceCollection<SPDataSource> dsCollection) {
+ return new ArchitectNewValueMaker(root, dsCollection);
+ }
+
+ @Override
+ public SPObject getSPObjectUnderTest() {
+ return olapComponent;
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/regress/ca/sqlpower/architect/swingui/olap/TestUsageComponent.java
Thu Apr 8 07:59:33 2010
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010, SQL Power Group Inc.
+ *
+ * This file is part of Power*Architect.
+ *
+ * Power*Architect is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Power*Architect is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package ca.sqlpower.architect.swingui.olap;
+
+import ca.sqlpower.architect.olap.MondrianModel.Cube;
+import ca.sqlpower.architect.olap.MondrianModel.Dimension;
+import ca.sqlpower.architect.olap.MondrianModel.DimensionUsage;
+import ca.sqlpower.object.SPObject;
+
+public class TestUsageComponent extends TestOLAPComponent {
+
+ public TestUsageComponent(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ Cube cube = new Cube();
+ Dimension dimension = new Dimension();
+ DimensionUsage usage = new DimensionUsage();
+ cube.addDimension(usage);
+ schema.addCube(cube);
+ schema.addDimension(dimension);
+ CubePane cPane = new CubePane(cube, contentPane);
+ DimensionPane dPane = new DimensionPane(dimension, contentPane);
+ olapComponent = new UsageComponent(contentPane, usage, dPane,
cPane);
+ contentPane.addChild(dPane, 0);
+ contentPane.addChild(cPane, 1);
+ contentPane.addChild(olapComponent, 2);
+ }
+
+ @Override
+ protected Class<? extends SPObject> getChildClassType() {
+ return UsageComponent.class;
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/regress/ca/sqlpower/architect/swingui/olap/TestVirtualCubePane.java
Thu Apr 8 07:59:33 2010
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2010, SQL Power Group Inc.
+ *
+ * This file is part of Power*Architect.
+ *
+ * Power*Architect is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Power*Architect is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package ca.sqlpower.architect.swingui.olap;
+
+import ca.sqlpower.architect.olap.MondrianModel.VirtualCube;
+import ca.sqlpower.object.SPObject;
+
+public class TestVirtualCubePane extends TestOLAPComponent {
+
+ public TestVirtualCubePane(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ VirtualCube virtualCube = new VirtualCube();
+ schema.addVirtualCube(virtualCube);
+ olapComponent = new VirtualCubePane(virtualCube, contentPane);
+ contentPane.addChild(olapComponent, 0);
+ }
+
+ @Override
+ protected Class<? extends SPObject> getChildClassType() {
+ return VirtualCubePane.class;
+ }
+
+}
=======================================
---
/trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSession.java
Tue Apr 6 14:44:35 2010
+++
/trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSession.java
Thu Apr 8 07:59:33 2010
@@ -103,6 +103,7 @@
userSettings = context.getUserSettings();
sourceDatabases = new DBTree(this);
playpen = RelationalPlayPenFactory.createPlayPen(this,
sourceDatabases);
+
delegateSession.getWorkspace().setPlayPenContentPane(playpen.getContentPane());
undoManager = new ArchitectUndoManager(playpen);
olapRootObject = new OLAPRootObject();
=======================================
--- /trunk/regress/ca/sqlpower/architect/util/ArchitectNewValueMaker.java
Tue Mar 23 13:58:01 2010
+++ /trunk/regress/ca/sqlpower/architect/util/ArchitectNewValueMaker.java
Thu Apr 8 07:59:33 2010
@@ -26,14 +26,20 @@
import ca.sqlpower.architect.olap.OLAPObject;
import ca.sqlpower.architect.olap.OLAPRootObject;
import ca.sqlpower.architect.olap.OLAPSession;
+import ca.sqlpower.architect.olap.MondrianModel.Cube;
+import ca.sqlpower.architect.olap.MondrianModel.Dimension;
import ca.sqlpower.architect.olap.MondrianModel.Schema;
import ca.sqlpower.architect.profile.ColumnProfileResult;
import ca.sqlpower.architect.profile.ColumnValueCount;
+import ca.sqlpower.architect.profile.ProfileManager;
+import ca.sqlpower.architect.profile.ProfileManagerImpl;
import ca.sqlpower.architect.profile.ProfileSettings;
import ca.sqlpower.architect.profile.TableProfileResult;
import ca.sqlpower.architect.swingui.PlayPenComponent;
import ca.sqlpower.architect.swingui.PlayPenContentPane;
import ca.sqlpower.architect.swingui.TablePane;
+import ca.sqlpower.architect.swingui.olap.CubePane;
+import ca.sqlpower.architect.swingui.olap.DimensionPane;
import ca.sqlpower.object.SPObject;
import ca.sqlpower.sql.DataSourceCollection;
import ca.sqlpower.sql.PlDotIni;
@@ -103,9 +109,13 @@
}
getRootObject().addChild(project, 0);
return project;
+ } else if (ProfileManager.class.isAssignableFrom(valueType)) {
+ ProfileManagerImpl profileManager = new ProfileManagerImpl();
+ valueMakerProject.setProfileManager(profileManager);
+ return profileManager;
} else if (valueType == PlayPenContentPane.class) {
PlayPenContentPane pane = new PlayPenContentPane();
- ((ArchitectProject) makeNewValue(ArchitectProject.class, null,
null)).setPlayPenContentPane(pane);
+ ((ArchitectProject) makeNewValue(ArchitectProject.class, null,
null)).setPlayPenContentPane(pane);
return pane;
} else if (valueType == PlayPenComponent.class) {
return makeNewValue(TablePane.class, null, null);
@@ -114,6 +124,22 @@
TablePane tp = new TablePane((SQLTable)
super.makeNewValue(SQLTable.class, null, null), p);
p.addChild(tp, p.getChildren(TablePane.class).size());
return tp;
+ } else if (valueType == DimensionPane.class) {
+ PlayPenContentPane contentPane = makeOlapContentPane();
+ Schema schema = ((OLAPSession)
contentPane.getModelContainer()).getSchema();
+ Dimension dimension = new Dimension();
+ schema.addDimension(dimension);
+ DimensionPane dPane = new DimensionPane(dimension,
contentPane);
+ contentPane.addChild(dPane, 0);
+ return dPane;
+ } else if (valueType == CubePane.class) {
+ PlayPenContentPane contentPane = makeOlapContentPane();
+ Schema schema = ((OLAPSession)
contentPane.getModelContainer()).getSchema();
+ Cube cube = new Cube();
+ schema.addCube(cube);
+ CubePane cPane = new CubePane(cube, contentPane);
+ contentPane.addChild(cPane, 0);
+ return cPane;
} else if (valueType == OLAPSession.class) {
OLAPSession session = new OLAPSession(new Schema());
OLAPRootObject root = new OLAPRootObject();
@@ -128,5 +154,14 @@
return super.makeNewValue(valueType, oldVal, propName);
}
}
+
+ private PlayPenContentPane makeOlapContentPane() {
+ OLAPSession session = new OLAPSession(new Schema());
+ valueMakerProject.getOlapRootObject().addChild(session);
+ PlayPenContentPane contentPane = new PlayPenContentPane(session);
+ contentPane.setParent(valueMakerProject);
+ valueMakerProject.addOLAPContentPane(contentPane);
+ return contentPane;
+ }
}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java
Wed Apr 7 12:43:35 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java
Thu Apr 8 07:59:33 2010
@@ -282,6 +282,11 @@
public ArchitectProject getParent() {
return (ArchitectProject) super.getParent();
}
+
+ @Mutator
+ public void setParent(ArchitectProject parent) {
+ super.setParent(parent);
+ }
public boolean allowsChildren() {
return true;
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/olap/CubePane.java
Tue Apr 6 14:44:35 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/olap/CubePane.java
Thu Apr 8 07:59:33 2010
@@ -37,6 +37,7 @@
import ca.sqlpower.architect.swingui.PlayPenComponent;
import ca.sqlpower.architect.swingui.PlayPenContentPane;
import ca.sqlpower.architect.swingui.PlayPenCoordinate;
+import ca.sqlpower.object.SPObject;
import ca.sqlpower.object.annotation.Accessor;
import ca.sqlpower.object.annotation.Constructor;
import ca.sqlpower.object.annotation.ConstructorParameter;
@@ -48,6 +49,8 @@
@SuppressWarnings("unused")
private static final Logger logger = Logger.getLogger(CubePane.class);
+
+ public static final List<Class<? extends SPObject>> allowedChildTypes
= PlayPenComponent.allowedChildTypes;
public CubePane(Cube model) {
super(model.getName());
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/olap/DimensionPane.java
Tue Apr 6 14:44:35 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/olap/DimensionPane.java
Thu Apr 8 07:59:33 2010
@@ -31,10 +31,12 @@
import ca.sqlpower.architect.olap.MondrianModel.Hierarchy;
import ca.sqlpower.architect.olap.MondrianModel.Level;
import ca.sqlpower.architect.swingui.ContainerPaneUI;
+import ca.sqlpower.architect.swingui.PlayPenComponent;
import ca.sqlpower.architect.swingui.PlayPenContentPane;
import ca.sqlpower.architect.swingui.PlayPenCoordinate;
import ca.sqlpower.object.SPChildEvent;
import ca.sqlpower.object.SPListener;
+import ca.sqlpower.object.SPObject;
import ca.sqlpower.object.annotation.Constructor;
import ca.sqlpower.object.annotation.ConstructorParameter;
import ca.sqlpower.object.annotation.NonBound;
@@ -50,6 +52,8 @@
public class DimensionPane extends OLAPPane<Dimension, OLAPObject> {
private static final Logger logger =
Logger.getLogger(DimensionPane.class);
+
+ public static final List<Class<? extends SPObject>> allowedChildTypes
= PlayPenComponent.allowedChildTypes;
private class HierarchyWatcher implements SPListener {
@@ -145,7 +149,6 @@
}
@Override
- @NonBound
protected List<OLAPObject> getItems() {
List<OLAPObject> oos = new ArrayList<OLAPObject>();
for (Hierarchy h : model.getHierarchies()) {
@@ -225,6 +228,7 @@
/**
* Returns a list of levels which are selected.
*/
+ @NonBound
public List<Level> getSelectedLevels() {
List<Level> selectedItems = new ArrayList<Level>();
for (int i=0; i < getItems().size(); i++) {
@@ -236,6 +240,7 @@
}
@Override
+ @NonBound
protected List<OLAPObject> getItemsFromCoordinates(
List<PlayPenCoordinate<? extends OLAPObject, ? extends
OLAPObject>> coords) {
List<OLAPObject> items = new ArrayList<OLAPObject>();
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/olap/OLAPPane.java
Tue Apr 6 14:44:35 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/olap/OLAPPane.java
Thu Apr 8 07:59:33 2010
@@ -59,6 +59,7 @@
import ca.sqlpower.architect.swingui.event.SelectionEvent;
import ca.sqlpower.architect.swingui.olap.DimensionPane.HierarchySection;
import ca.sqlpower.object.annotation.Accessor;
+import ca.sqlpower.object.annotation.Mutator;
import ca.sqlpower.object.annotation.NonBound;
import ca.sqlpower.object.annotation.Transient;
import ca.sqlpower.sqlobject.SQLObjectException;
@@ -119,7 +120,8 @@
/**
* Returns this pane's list of sections.
- */
+ */
+ @Transient @Accessor
public List<PaneSection<? extends C>> getSections() {
return sections;
}
@@ -683,6 +685,7 @@
* @param newIP The new insertion point. Null is allowed, and means
* there shouldn't be a visible insertion point.
*/
+ @Transient @Mutator
public void setInsertionPoint(PlayPenCoordinate<T, C> newIP) {
PlayPenCoordinate<T, C> oldIP = insertionPoint;
insertionPoint = newIP;
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/olap/UsageComponent.java
Tue Apr 6 14:44:35 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/olap/UsageComponent.java
Thu Apr 8 07:59:33 2010
@@ -54,6 +54,8 @@
*/
public class UsageComponent extends PlayPenComponent implements LayoutEdge
{
+ public static final List<Class<? extends SPObject>> allowedChildTypes
= PlayPenComponent.allowedChildTypes;
+
private final OLAPObject model;
private final OLAPPane<?, ?> pane1;
private final OLAPPane<?, ?> pane2;
@@ -89,6 +91,7 @@
this.pane2 = pane2;
setOpaque(false);
setForegroundColor(Color.BLACK);
+ setBackgroundColor(Color.BLACK);
updateUI();
parent.addSPListener(olapPanesWatcher);
}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/olap/VirtualCubePane.java
Tue Apr 6 14:44:35 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/olap/VirtualCubePane.java
Thu Apr 8 07:59:33 2010
@@ -33,8 +33,10 @@
import ca.sqlpower.architect.olap.MondrianModel.VirtualCubeDimension;
import ca.sqlpower.architect.olap.MondrianModel.VirtualCubeMeasure;
import ca.sqlpower.architect.swingui.ContainerPaneUI;
+import ca.sqlpower.architect.swingui.PlayPenComponent;
import ca.sqlpower.architect.swingui.PlayPenContentPane;
import ca.sqlpower.architect.swingui.PlayPenCoordinate;
+import ca.sqlpower.object.SPObject;
import ca.sqlpower.object.annotation.Constructor;
import ca.sqlpower.object.annotation.ConstructorParameter;
import ca.sqlpower.object.annotation.NonBound;
@@ -42,6 +44,8 @@
import ca.sqlpower.swingui.DataEntryPanel;
public class VirtualCubePane extends OLAPPane<VirtualCube, OLAPObject> {
+
+ public static final List<Class<? extends SPObject>> allowedChildTypes
= PlayPenComponent.allowedChildTypes;
public VirtualCubePane(VirtualCubePane copyMe, PlayPenContentPane
parent) {
super(copyMe, parent);
--
To unsubscribe, reply using "remove me" as the subject.