Skip to content

Commit

Permalink
MONDRIAN: Fixes for bug 2138161 Workbench Dimension Selection Issue
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//open/mondrian/": change = 11686]
  • Loading branch information
e-cuellar committed Oct 7, 2008
1 parent 8c5fd31 commit d3c8d48
Showing 1 changed file with 37 additions and 14 deletions.
51 changes: 37 additions & 14 deletions src/main/mondrian/gui/SchemaPropertyCellEditor.java
Expand Up @@ -26,6 +26,7 @@
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.TreeSet;
import java.util.Vector;
import javax.swing.border.*;
import javax.swing.text.JTextComponent;
Expand Down Expand Up @@ -163,6 +164,7 @@ public Component getTableCellEditorComponent(final JTable table, Object value, b
String selectedFactTable = tableModel.getFactTable();
String selectedFactTableSchema = tableModel.getFactTableSchema();
listEditorValue = null; // reset value of combo-box
Object parent = this.getParentObject();

if (targetClassz == MondrianGuiDef.UserDefinedFunction.class && propertyName.equals("className")) {
Vector udfs = getUdfs();
Expand Down Expand Up @@ -390,6 +392,17 @@ public Component getTableCellEditorComponent(final JTable table, Object value, b

String lTable = lProps.table;
Vector allcols;
//EC: Sets the corresponding columns on the selection dropdown for the specified table.
if (targetClassz == MondrianGuiDef.Level.class && parent != null) {
if (parent instanceof MondrianGuiDef.Hierarchy) {
MondrianGuiDef.RelationOrJoin relation = ((MondrianGuiDef.Hierarchy) parent).relation;
if (relation instanceof MondrianGuiDef.Table) {
lTable = ((MondrianGuiDef.Table) relation).name;
} else if (relation instanceof MondrianGuiDef.Join) {
lTable = SchemaExplorer.getTableNameForAlias(relation, lTable);
}
}
}
if (lTable != null) {
allcols = jdbcMetaData.getAllColumns(null, lTable);
} else {
Expand Down Expand Up @@ -462,6 +475,18 @@ public Component getTableCellEditorComponent(final JTable table, Object value, b
ComboBoxModel cFactTables = new DefaultComboBoxModel(factTables); //suggestive fact tables
ComboBoxModel cAllTables = new DefaultComboBoxModel((allTablesMinusFact.size() > 0) ? allTablesMinusFact : allTables); // all tables of selected schema
ComboBoxModel cDimeTables = new DefaultComboBoxModel(dimeTables); // suggestive dimension tables based on selected fact table .
//EC: Sets the corresponding join tables on selection dropdown when using joins.
if (targetClassz == MondrianGuiDef.Level.class && parent != null) {
if (parent instanceof MondrianGuiDef.Hierarchy) {
MondrianGuiDef.RelationOrJoin relation = ((MondrianGuiDef.Hierarchy) parent).relation;
if (relation instanceof MondrianGuiDef.Join) {
TreeSet joinTables = new TreeSet();
//EC: getTableNamesForJoin calls itself recursively and collects table names in joinTables.
SchemaExplorer.getTableNamesForJoin(relation, joinTables);
cAllTables = new DefaultComboBoxModel(new Vector(joinTables));
}
}
}

listEditor.setEditable(true);
listEditor.setToolTipText(null);
Expand Down Expand Up @@ -496,6 +521,16 @@ public Component getTableCellEditorComponent(final JTable table, Object value, b
listEditor.setSelectedItem((String)value);
listEditorValue = (String)value;
activeEditor = listEditor;
//EC: Disables table selection when not using joins.
if (targetClassz == MondrianGuiDef.Level.class && propertyName.equals(SchemaExplorer.DEF_LEVEL[1]) && parent != null) {
if (parent instanceof MondrianGuiDef.Hierarchy) {
MondrianGuiDef.RelationOrJoin relation = ((MondrianGuiDef.Hierarchy) parent).relation;
if (relation instanceof MondrianGuiDef.Table) {
activeEditor = stringEditor;
stringEditor.setText((String)value);
}
}
}
} else if (value instanceof String) {
activeEditor = stringEditor;
stringEditor.setText((String)value);
Expand Down Expand Up @@ -846,31 +881,19 @@ private Vector getFormatStrings() {
}

private MondrianGuiDef.Schema getSchema() {
SchemaExplorer se = this.getSchemaExplorer();
SchemaExplorer se = workbench.getCurrentSchemaExplorer();
return (se == null) ? null : se.getSchema();
}

private Object getParentObject() {
SchemaExplorer se = this.getSchemaExplorer();
SchemaExplorer se = workbench.getCurrentSchemaExplorer();
if (se != null) {
Object po = se.getParentObject();
return po;
}
return null;
}

private SchemaExplorer getSchemaExplorer() {
SchemaExplorer se = null;
for (int i = listeners.size() - 1; i >= 0; i--) {
CellEditorListener cel = ((CellEditorListener)listeners.get(i));
if (cel instanceof SchemaExplorer) {
se = (SchemaExplorer) cel;
break;
}
}
return se;
}

private Vector getSource() { //shared dimensions in schema
Vector source = new Vector();
MondrianGuiDef.Schema s = this.getSchema();
Expand Down

0 comments on commit d3c8d48

Please sign in to comment.