schemaexplorer.java
来自「数据仓库展示程序」· Java 代码 · 共 669 行 · 第 1/2 页
JAVA
669 行
cube.dimensions[cube.dimensions.length - 1] = dimension;
refreshTree(tree.getSelectionPath());
}
/**
* @param evt
*/
protected void addLevel(ActionEvent evt)
{
Object path = tree.getSelectionPath().getLastPathComponent();
if (!(path instanceof MondrianDef.Hierarchy))
return;
MondrianDef.Hierarchy hierarchy = (MondrianDef.Hierarchy) path;
MondrianDef.Level level = new MondrianDef.Level();
level.uniqueMembers = new Boolean(false);
level.name = "New Level " + hierarchy.levels.length;
level.properties = new MondrianDef.Property[0];
level.nameExp = new MondrianDef.NameExpression();
level.nameExp.expressions = new MondrianDef.SQL[1];
level.nameExp.expressions[0] = new MondrianDef.SQL();
level.ordinalExp = new MondrianDef.OrdinalExpression();
level.ordinalExp.expressions = new MondrianDef.SQL[1];
level.ordinalExp.expressions[0] = new MondrianDef.SQL();
//dimension.hierarchies[0].memberReaderParameters[0] = new MondrianDef.Parameter();
//add cube to schema
NodeDef[] temp = hierarchy.levels;
hierarchy.levels = new MondrianDef.Level[temp.length + 1];
for (int i = 0; i < temp.length; i++)
hierarchy.levels[i] = (MondrianDef.Level) temp[i];
hierarchy.levels[hierarchy.levels.length - 1] = level;
refreshTree(tree.getSelectionPath());
}
/**
* @param evt
*/
protected void addProperty(ActionEvent evt)
{
Object path = tree.getSelectionPath().getLastPathComponent();
if (!(path instanceof MondrianDef.Level))
return;
MondrianDef.Level level = (MondrianDef.Level) path;
MondrianDef.Property property = new MondrianDef.Property();
property.name = "New Property " + level.properties.length;
//add cube to schema
NodeDef[] temp = level.properties;
level.properties = new MondrianDef.Property[temp.length + 1];
for (int i = 0; i < temp.length; i++)
level.properties[i] = (MondrianDef.Property) temp[i];
level.properties[level.properties.length - 1] = property;
refreshTree(tree.getSelectionPath());
}
public MondrianDef.Schema getSchema()
{
return this.schema;
}
/**
* returns the schema file
* @return File
*/
public File getSchemaFile()
{
return this.schemaFile;
}
/**
* sets the schema file
* @param f
*/
public void setSchemaFile(File f)
{
this.schemaFile = f;
}
/**
* Called whenever the value of the selection changes.
* @param e the event that characterizes the change.
*
*/
public void valueChanged(TreeSelectionEvent e)
{
Object o = e.getPath().getLastPathComponent();
String[] pNames = DEF_DEFAULT;
if (o instanceof MondrianDef.Column)
{
pNames = DEF_COLUMN;
targetLabel.setText(LBL_COLUMN);
}
else if (o instanceof MondrianDef.Cube)
{
pNames = DEF_CUBE;
targetLabel.setText(LBL_CUBE);
}
else if (o instanceof MondrianDef.Dimension)
{
pNames = DEF_DIMENSION;
targetLabel.setText(LBL_DIMENSION);
}
else if (o instanceof MondrianDef.DimensionUsage)
{
pNames = DEF_DIMENSION_USAGE;
targetLabel.setText(LBL_DIMENSION_USAGE);
}
else if (o instanceof MondrianDef.ExpressionView)
{
pNames = DEF_EXPRESSION_VIEW;
targetLabel.setText(LBL_EXPRESSION_VIEW);
}
else if (o instanceof MondrianDef.Hierarchy)
{
pNames = DEF_HIERARCHY;
targetLabel.setText(LBL_HIERARCHY);
}
else if (o instanceof MondrianDef.Join)
{
pNames = DEF_JOIN;
targetLabel.setText(LBL_JOIN);
}
else if (o instanceof MondrianDef.Level)
{
pNames = DEF_LEVEL;
targetLabel.setText(LBL_LEVEL);
}
else if (o instanceof MondrianDef.Measure)
{
pNames = DEF_MEASURE;
targetLabel.setText(LBL_MEASURE);
}
else if (o instanceof MondrianDef.Parameter)
{
pNames = DEF_PARAMETER;
targetLabel.setText(LBL_PARAMETER);
}
else if (o instanceof MondrianDef.Property)
{
pNames = DEF_PROPERTY;
targetLabel.setText(LBL_PROPERTY);
}
else if (o instanceof MondrianDef.Schema)
{
pNames = DEF_SCHEMA;
targetLabel.setText(LBL_SCHEMA);
}
else if (o instanceof MondrianDef.SQL)
{
pNames = DEF_SQL;
targetLabel.setText(LBL_SQL);
}
else if (o instanceof MondrianDef.Table)
{
pNames = DEF_TABLE;
targetLabel.setText(LBL_TABLE);
}
else if (o instanceof MondrianDef.View)
{
pNames = DEF_VIEW;
targetLabel.setText(LBL_VIEW);
}
else if (o instanceof MondrianDef.VirtualCube)
{
pNames = DEF_VIRTUAL_CUBE;
targetLabel.setText(LBL_VIRTUAL_CUBE);
}
else if (o instanceof MondrianDef.VirtualCubeDimension)
{
pNames = DEF_VIRTUAL_CUBE_DIMENSION;
targetLabel.setText(LBL_VIRTUAL_CUBE_DIMENSION);
}
else if (o instanceof MondrianDef.VirtualCubeMeasure)
{
pNames = DEF_VIRTUAL_CUBE_MEASURE;
targetLabel.setText(LBL_VIRTUAL_CUBE_MEASURE);
}
else
{
targetLabel.setText(LBL_UNKNOWN_TYPE);
}
PropertyTableModel ptm = new PropertyTableModel(o, pNames);
propertyTable.setModel(ptm);
for (int i = 0; i < propertyTable.getRowCount(); i++)
{
TableCellRenderer renderer = propertyTable.getCellRenderer(i, 1);
Component comp = renderer.getTableCellRendererComponent(propertyTable, propertyTable.getValueAt(i, 1), false, false, i, 1);
try
{
int height = comp.getMaximumSize().height;
propertyTable.setRowHeight(i, height);
}
catch (Exception ea)
{
}
}
}
/**
* @see javax.swing.event.CellEditorListener#editingCanceled(ChangeEvent)
*/
public void editingCanceled(ChangeEvent e)
{
updater.update();
}
/**
* @see javax.swing.event.CellEditorListener#editingStopped(ChangeEvent)
*/
public void editingStopped(ChangeEvent e)
{
updater.update();
}
class PopupTrigger extends MouseAdapter
{
public void mouseReleased(MouseEvent e)
{
if (e.isPopupTrigger())
{
int x = e.getX();
int y = e.getY();
TreePath path = tree.getPathForLocation(x, y);
if (path != null)
{
jPopupMenu.removeAll();
Object pathSelected = path.getLastPathComponent();
if (pathSelected instanceof MondrianDef.Schema)
{
jPopupMenu.add(addCube);
}
else if (pathSelected instanceof MondrianDef.Cube)
{
jPopupMenu.add(addDimension);
jPopupMenu.add(addMeasure);
}
else if (pathSelected instanceof MondrianDef.Hierarchy)
{
jPopupMenu.add(addLevel);
}
else if (pathSelected instanceof MondrianDef.Level)
{
jPopupMenu.add(addProperty);
}
else
{
return;
}
jPopupMenu.show(tree, x, y);
}
}
}
}
public static final String[] DEF_DEFAULT = {};
public static final String[] DEF_VIRTUAL_CUBE = { "name" };
public static final String[] DEF_VIRTUAL_CUBE_MEASURE = { "name", "cubeName" };
public static final String[] DEF_VIRTUAL_CUBE_DIMENSION = { "cubeName" };
public static final String[] DEF_VIEW = { "alias" };
public static final String[] DEF_TABLE = { "name", "alias", "schema" };
public static final String[] DEF_RELATION = { "name" };
public static final String[] DEF_SQL = { "cdata", "dialect" };
public static final String[] DEF_SCHEMA = {};
public static final String[] DEF_PROPERTY = { "name", "column", "type" };
public static final String[] DEF_PARAMETER = { "name", "value" };
public static final String[] DEF_MEASURE = { "name", "aggregator", "column", "formatString" };
public static final String[] DEF_LEVEL = { "name", "column", "nameExp", "ordinalColumn", "ordinalExp", "table", "type", "uniqueMembers" };
public static final String[] DEF_JOIN = { "left", "leftAlias", "leftKey", "right", "rightAlias", "rightKey" };
public static final String[] DEF_HIERARCHY = { "hasAll", "defaultMember", "memberReaderClass", "primaryKey", "primaryKeyTable", "relation" };
public static final String[] DEF_EXPRESSION_VIEW = {};
public static final String[] DEF_DIMENSION_USAGE = { "name", "foreignKey", "source" };
public static final String[] DEF_DIMENSION = { "name", "foreignKey" };
public static final String[] DEF_CUBE = { "name", "fact" };
public static final String[] DEF_COLUMN = { "name", "table" };
private static final String LBL_COLUMN = "Column";
private static final String LBL_CUBE = "Cube";
private static final String LBL_DIMENSION = "Dimension";
private static final String LBL_DIMENSION_USAGE = "Dimension Usage";
private static final String LBL_EXPRESSION_VIEW = "Expression View";
private static final String LBL_HIERARCHY = "Hierarchy";
private static final String LBL_JOIN = "Join";
private static final String LBL_LEVEL = "Level";
private static final String LBL_MEASURE = "Measure";
private static final String LBL_PARAMETER = "Parameter";
private static final String LBL_PROPERTY = "Property";
private static final String LBL_SCHEMA = "Schema";
private static final String LBL_SQL = "SQL";
private static final String LBL_TABLE = "Table";
private static final String LBL_VIEW = "View";
private static final String LBL_VIRTUAL_CUBE = "Virtual Cube";
private static final String LBL_VIRTUAL_CUBE_DIMENSION = "Virtual Cube Dimension";
private static final String LBL_VIRTUAL_CUBE_MEASURE = "Virtual Cube Measure";
private static final String LBL_UNKNOWN_TYPE = "Unknown Type";
private AbstractAction addCube;
private AbstractAction addDimension;
private AbstractAction addMeasure;
private AbstractAction addLevel;
private AbstractAction addProperty;
private JTable propertyTable;
private JPanel jPanel2;
private JPanel jPanel1;
private JButton addLevelButton;
private JScrollPane jScrollPane2;
private JScrollPane jScrollPane1;
private JButton addPropertyButton;
private JButton pasteButton;
private JLabel targetLabel;
private JTree tree;
private JSplitPane jSplitPane1;
private JButton addDimensionButton;
private JButton cutButton;
private JButton addMeasureButton;
private JButton addCubeButton;
private JButton copyButton;
private JToolBar jToolBar1;
private JPopupMenu jPopupMenu;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?