You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pp...@apache.org on 2010/10/05 21:22:19 UTC
svn commit: r1004775 [3/3] - in /openjpa/tools/trunk/openjpa-tools/src/main:
java/org/apache/openjpa/swing/ java/org/apache/openjpa/swing/graph/
java/org/apache/openjpa/swing/layout/ java/org/apache/openjpa/swing/print/
java/org/apache/openjpa/tools/ j...
Added: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/AttributeView.java
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/AttributeView.java?rev=1004775&view=auto
==============================================================================
--- openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/AttributeView.java (added)
+++ openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/AttributeView.java Tue Oct 5 19:22:16 2010
@@ -0,0 +1,256 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.openjpa.tools.metamodel;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.geom.Path2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.ManagedType;
+import javax.swing.BoxLayout;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import org.apache.openjpa.swing.Geometry;
+import org.apache.openjpa.swing.graph.Edge;
+import org.apache.openjpa.swing.graph.EdgeRenderer;
+
+/**
+ * View of one or more persistent attributes.
+ * The attribute names and types are {@linkplain MetamodelUIManager#getHTMLName(Attribute) decorated}
+ * based on the attribute properties such as whether it is a version or identity or a many-to-one
+ * relation etc. The attributes are displayed as JLabel or JCheckBox based on whether they can
+ * be selected.
+ * The order of the attributes puts identity attribute at top, version attribute at bottom and others
+ * are ordered lexically.
+ *
+ *
+ * @author Pinaki Poddar
+ *
+ */
+@SuppressWarnings("serial")
+public class AttributeView extends JPanel {
+ private static final String MODEL_OBJECT = "attribute";
+
+ private final boolean _selectable;
+
+ public <A extends Attribute<?,?>> AttributeView(A attr) {
+ this(Collections.singleton(attr));
+ }
+
+ public <A extends Attribute<?,?>> AttributeView(A attr, boolean selectable) {
+ this(Collections.singleton(attr), selectable);
+ }
+
+ public <A extends Attribute<?,?>> AttributeView(Set<A> attrs) {
+ this(attrs, true);
+ }
+
+ public <A extends Attribute<?,?>> AttributeView(Set<A> attrs, boolean selectable) {
+ super(true);
+ _selectable = selectable;
+ setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
+ if (attrs.isEmpty()) {
+ setVisible(false);
+ return;
+ }
+ List<A> sortedAttrs = new ArrayList<A>();
+ sortedAttrs.addAll(attrs);
+ Collections.sort(sortedAttrs, new MetamodelHelper.AttributeComparator());
+ for (Attribute<?,?> attr : sortedAttrs) {
+ String label = MetamodelUIManager.getHTMLName(attr);
+ JComponent view = selectable ? new JCheckBox(label) : new JLabel(label);
+ view.putClientProperty(MODEL_OBJECT, attr);
+ add(view);
+ }
+ }
+
+ public boolean isSelectionEnabled() {
+ return _selectable;
+ }
+
+ public Collection<Attribute<?,?>> getSelected() {
+ Collection<Attribute<?,?>> selected = new ArrayList<Attribute<?,?>>();
+ if (isSelectionEnabled()) {
+ int N = getComponentCount();
+ for (int i = 0; i < N; i++) {
+ JCheckBox c = (JCheckBox)getComponent(i);
+ if (c.isSelected()) {
+ selected.add((Attribute<?,?>)c.getClientProperty(MODEL_OBJECT));
+ }
+ }
+ }
+ return selected;
+ }
+
+ /**
+ * Gets the the component representing the given attribute.
+ */
+ public <A extends Attribute<?,?>> Component getComponentFor(A attr) {
+ int N = getComponentCount();
+ for (int i = 0; i < N; i++) {
+ Component c = getComponent(i);
+ if (c instanceof JComponent && ((JComponent)c).getClientProperty(MODEL_OBJECT) == attr) {
+ return c;
+ }
+ }
+ return null;
+ }
+
+
+ public static class AttributeEdgeRenderer implements EdgeRenderer<ManagedType<?>> {
+ @Override
+ public String getLabelText(Edge<ManagedType<?>, ManagedType<?>> edge) {
+ return ((AttributeView.AttributeLink)edge).getAttribute().getName();
+ }
+
+ @Override
+ public JLabel getLabel(String text) {
+ return new JLabel(text);
+ }
+
+ @Override
+ public void render(Graphics2D g, Path2D edgePath, Edge<ManagedType<?>, ManagedType<?>> edge) {
+ Color newColor = MetamodelUIManager.getColor(((AttributeView.AttributeLink)edge).getAttribute());
+ g.setColor(newColor);
+ g.draw(edgePath);
+ Shape arrow = Geometry.addEndArrow(edgePath,
+ MetamodelUIManager.getInt(MetamodelUIManager.ARROW_SIZE),
+ MetamodelUIManager.getInt(MetamodelUIManager.ARROW_ANGLE));
+ g.fill(arrow);
+ }
+ }
+
+
+ public static class IdLinkRenderer implements EdgeRenderer<ManagedType<?>> {
+ private static Stroke THICK_LINE = new BasicStroke(2);
+ @Override
+ public String getLabelText(Edge<ManagedType<?>, ManagedType<?>> edge) {
+ return ((IdLink)edge).getAttribute().getName();
+ }
+
+ public JLabel getLabel(String text) {
+ return new JLabel(MetamodelUIManager.createHTMLLabel(text, "font-weight", "bold"));
+ }
+
+ public void render(Graphics2D g2, Path2D edgePath, Edge<ManagedType<?>,ManagedType<?>> edge) {
+ Color newColor = MetamodelUIManager.getColor(((IdLink)edge).getAttribute());
+ g2.setColor(newColor);
+ g2.setStroke(THICK_LINE);
+ g2.draw(edgePath);
+ Shape arrow = Geometry.addEndArrow(edgePath,
+ MetamodelUIManager.getInt(MetamodelUIManager.ARROW_SIZE),
+ MetamodelUIManager.getInt(MetamodelUIManager.ARROW_ANGLE));
+ g2.fill(arrow);
+ }
+ }
+
+ /**
+ * Renders a inheritance edge.
+ *
+ */
+ public static class InheritenceEdgeRenderer implements EdgeRenderer<ManagedType<?>> {
+ private static Stroke THICK_LINE = new BasicStroke(2);
+
+ public void render(Graphics2D g2, Path2D edgePath, Edge<ManagedType<?>,ManagedType<?>> edge) {
+ g2.setColor(MetamodelUIManager.getColor(MetamodelUIManager.COLOR_LINK_INHERIT));
+ g2.setStroke(THICK_LINE);
+ g2.draw(edgePath);
+ Shape arrow = Geometry.addEndArrow(edgePath,
+ 1.2*MetamodelUIManager.getInt(MetamodelUIManager.ARROW_SIZE),
+ 1.2*MetamodelUIManager.getInt(MetamodelUIManager.ARROW_ANGLE));
+ g2.fill(arrow);
+ }
+
+ @Override
+ public String getLabelText(Edge<ManagedType<?>, ManagedType<?>> edge) {
+ return "extends";
+ }
+
+ public JLabel getLabel(String text) {
+ return new JLabel("<HTML><b>extends</b></HTML>");
+ }
+
+ }
+
+
+ static abstract class MetaModelLink implements Edge<ManagedType<?>, ManagedType<?>> {
+ final protected ManagedType<?> source;
+ final protected ManagedType<?> target;
+
+ public MetaModelLink(ManagedType<?> source, ManagedType<?> target) {
+ super();
+ this.source = source;
+ this.target = target;
+ }
+
+ @Override
+ public final ManagedType<?> getSource() {
+ return source;
+ }
+
+ @Override
+ public final ManagedType<?> getTarget() {
+ return target;
+ }
+ }
+
+
+ /**
+ * Represents a association persistent attribute.
+ *
+ *
+ */
+ public static class AttributeLink extends MetaModelLink {
+ final Attribute<?, ?> attr;
+
+ public AttributeLink(ManagedType<?> source, ManagedType<?> target, Attribute<?, ?> attr) {
+ super(source, target);
+ this.attr = attr;
+ }
+
+ public Attribute<?, ?> getAttribute() {
+ return attr;
+ }
+
+ }
+
+
+ public static class InheritenceLink extends MetaModelLink {
+ public InheritenceLink(ManagedType<?> derived, ManagedType<?> base) {
+ super(derived, base);
+ }
+ }
+
+
+ public static class IdLink extends AttributeLink {
+ Attribute<?, ?> attr;
+
+ public IdLink(ManagedType<?> source, ManagedType<?> target, Attribute<?, ?> attr) {
+ super(source, target, attr);
+ }
+ }
+}
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/AttributeView.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/AttributeView.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/EntityTypeView.java
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/EntityTypeView.java?rev=1004775&view=auto
==============================================================================
--- openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/EntityTypeView.java (added)
+++ openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/EntityTypeView.java Tue Oct 5 19:22:16 2010
@@ -0,0 +1,171 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.openjpa.tools.metamodel;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.ManagedType;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.swing.BorderFactory;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+
+import org.apache.openjpa.swing.SectionalView;
+import org.apache.openjpa.swing.graph.Connectable;
+import org.apache.openjpa.swing.graph.Edge;
+
+/**
+ * View of a persistent entity type as a JPanel.
+ *
+ * @author Pinaki Poddar
+ *
+ */
+@SuppressWarnings("serial")
+public class EntityTypeView<T> extends SectionalView implements Connectable<ManagedType<?>> {
+ public static int PIN_SIZE = 20; // size of entry/exit pin in pixel
+ public static int PIN_LOCATION_OFFSET = 8; // offset of pin location from corners
+ private static final String MODEL_OBJECT = "entity";
+
+ protected AttributeView _basics;
+ protected AttributeView _singulars;
+ protected AttributeView _plurals;
+
+ /**
+ * Create a visual component to display the persistent attributes of the given managed type.
+ *
+ * @param <X> the Java type of the managed type.
+ * @param type the managed type
+ * @param selectableAttribute if true then each attribute is displayed with a check box.
+ */
+ public EntityTypeView(ManagedType<T> type, boolean selectableAttribute) {
+ super();
+ putClientProperty(MODEL_OBJECT, type);
+ setBackground(Color.WHITE);
+// setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ JLabel title = new JLabel(MetamodelUIManager.createHTMLLabel(type.getJavaType().getSimpleName(),
+ "font-weight", "bold"));
+ title.setToolTipText(type.getJavaType().getName());
+ title.setHorizontalAlignment(JLabel.LEFT);
+ title.setIcon(MetamodelUIManager.getIcon(type));
+ title.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ add(title);
+
+ Set<SingularAttribute<T, ?>> singulars = type.getDeclaredSingularAttributes();
+ if (!singulars.isEmpty()) {
+ Set<Attribute<?, ?>> basics = new HashSet<Attribute<?,?>>();
+ for (SingularAttribute<?, ?> attr : singulars) {
+ if (!attr.isAssociation()) {
+ basics.add(attr);
+ }
+ }
+ singulars.removeAll(basics);
+ if (!basics.isEmpty()) {
+ _basics = new AttributeView(basics, selectableAttribute);
+ addSection(_basics, "Show/Hide Basic Properties");
+ }
+ if (!singulars.isEmpty()) {
+ _singulars = new AttributeView(singulars, selectableAttribute);
+ addSection(_singulars, "Show/Hide Singular Association");
+ }
+ }
+ Set<PluralAttribute<T, ?, ?>> plurals = type.getDeclaredPluralAttributes();
+ if (!plurals.isEmpty()) {
+ _plurals = new AttributeView(plurals, selectableAttribute);
+ addSection(_plurals, "Show/Hide Plural Association");
+ }
+ }
+
+ /**
+ * Exit pins come out of left/right edge at attribute line location.
+ */
+ public Line2D[] getExitPins(Edge<ManagedType<?>, ManagedType<?>> edge,
+ Connectable<ManagedType<?>> target) {
+ double P = PIN_SIZE;
+ double x = getX();
+ double y = getY();
+ double w = getWidth();
+ double h = getHeight();
+ double cx = x + w/2;
+ double o = PIN_LOCATION_OFFSET;
+ Line2D.Double line = new Line2D.Double(cx, y, cx, y - P);
+
+ if (edge instanceof AttributeView.AttributeLink) {
+ Attribute<?,?> attr = ((AttributeView.AttributeLink)edge).getAttribute();
+ AttributeView group = (attr instanceof SingularAttribute<?,?>)
+ ? _singulars : _plurals;
+ Component c = group.getComponentFor(attr);
+
+ Rectangle2D b = c == null ? new Rectangle2D.Double(0,o, w,o) : c.getBounds();
+ return new Line2D.Double[] {
+ horizontal(x, y + group.getY() + b.getY() + b.getHeight()/2, -P),
+ horizontal(x + w, y + group.getY() + b.getY() + b.getHeight()/2, +P),
+ };
+ } else if (edge instanceof AttributeView.InheritenceLink) {
+ // Exit points are at top-mid, top-left, top-right and bottom-mid
+ return new Line2D.Double[] {
+ vertical(cx, y, -P),
+ vertical(cx, y+h, +P)
+ };
+ }
+ return new Line2D.Double[]{line};
+ }
+
+ @Override
+ public Line2D[] getEntryPins(Edge<ManagedType<?>, ManagedType<?>> edge,
+ Connectable<ManagedType<?>> source) {
+ double P = PIN_SIZE;
+ double x = getX();
+ double y = getY();
+ double w = getWidth();
+ double h = getHeight();
+ double cx = x + w/2;
+ double o = PIN_LOCATION_OFFSET;
+ if (edge instanceof AttributeView.InheritenceLink) {
+ // Entry points are at bottom
+ return new Line2D.Double[] {
+ vertical(cx, y+h+P, -P),
+ };
+ }
+ // Entry Port is near the top
+ return new Line2D.Double[] {
+ horizontal(x-P, y+o, +P),
+ horizontal(x+w+P, y+o, -P),
+ vertical(x+o, y-P, +P),
+ vertical(x+w-o, y-P, +P),
+
+ };
+
+ }
+
+ Line2D.Double horizontal(double x, double y, double L) {
+ return new Line2D.Double(x,y, x+L,y);
+ }
+ Line2D.Double vertical(double x, double y, double L) {
+ return new Line2D.Double(x,y, x,y+L);
+ }
+
+ @Override
+ public JComponent asComponent() {
+ return this;
+ }
+}
+
+
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/EntityTypeView.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/EntityTypeView.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/ErrorHandler.java
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/ErrorHandler.java?rev=1004775&view=auto
==============================================================================
--- openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/ErrorHandler.java (added)
+++ openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/ErrorHandler.java Tue Oct 5 19:22:16 2010
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.tools.metamodel;
+
+import javax.swing.SwingUtilities;
+
+import org.apache.openjpa.swing.ErrorDialog;
+import org.apache.openjpa.swing.Images;
+
+
+
+/**
+ * Handles error.
+ *
+ * @author Pinaki Poddar
+ *
+ */
+public class ErrorHandler implements Thread.UncaughtExceptionHandler{
+
+ static {
+ System.setProperty("sun.awt.exception.handler", ErrorHandler.class.getName());
+ }
+
+ public void handle(Throwable e) {
+ uncaughtException(Thread.currentThread(), e);
+ }
+
+ public void uncaughtException(Thread t, Throwable e) {
+ if (SwingUtilities.isEventDispatchThread()) {
+ new ErrorDialog(null, Images.ERROR, e).setVisible(true);
+ } else {
+ e.printStackTrace();
+ }
+ }
+}
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/ErrorHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/ErrorHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/InMemoryBrokerFactory.java
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/InMemoryBrokerFactory.java?rev=1004775&view=auto
==============================================================================
--- openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/InMemoryBrokerFactory.java (added)
+++ openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/InMemoryBrokerFactory.java Tue Oct 5 19:22:16 2010
@@ -0,0 +1,54 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.openjpa.tools.metamodel;
+
+import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
+import org.apache.openjpa.kernel.AbstractBrokerFactory;
+import org.apache.openjpa.kernel.Broker;
+import org.apache.openjpa.kernel.StoreManager;
+import org.apache.openjpa.lib.conf.ConfigurationProvider;
+
+/**
+ * A specialized broker factory for in-memory analysis of the meta-model.
+ *
+ * @author Pinaki Poddar
+ *
+ */
+@SuppressWarnings("serial")
+public class InMemoryBrokerFactory extends AbstractBrokerFactory {
+
+ protected InMemoryBrokerFactory(OpenJPAConfiguration config) {
+ super(config);
+ }
+
+ @Override
+ protected StoreManager newStoreManager() {
+ return null;
+ }
+
+ public static InMemoryBrokerFactory newInstance(ConfigurationProvider cp) {
+ OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
+ cp.setInto(conf);
+ return new InMemoryBrokerFactory(conf);
+ }
+
+ public Broker newBroker(String user, String password, boolean isManaged, int retainMode, boolean findExisting) {
+ return null;
+ }
+
+ public void postCreationCallback() {
+
+ }
+}
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/InMemoryBrokerFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/InMemoryBrokerFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelBrowser.java
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelBrowser.java?rev=1004775&view=auto
==============================================================================
--- openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelBrowser.java (added)
+++ openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelBrowser.java Tue Oct 5 19:22:16 2010
@@ -0,0 +1,312 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.openjpa.tools.metamodel;
+
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.event.ActionEvent;
+import java.awt.print.PrinterException;
+import java.awt.print.PrinterJob;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.ManagedType;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JOptionPane;
+import javax.swing.JProgressBar;
+import javax.swing.JScrollPane;
+import javax.swing.JToolBar;
+import javax.swing.SwingWorker;
+
+import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.swing.Images;
+import org.apache.openjpa.swing.SwingHelper;
+import org.apache.openjpa.swing.graph.GraphPanel;
+import org.apache.openjpa.swing.print.PrintableDelegateComponent;
+
+/**
+ * Displays the persistent classes using JPA MetaModel interface.
+ *
+ *
+ * @author Pinaki Poddar
+ *
+ */
+@SuppressWarnings("serial")
+public class MetamodelBrowser extends JFrame implements Runnable {
+ private JMenuBar menubar;
+ private JScrollPane scrollableView;
+ private GraphPanel<ManagedType<?>> graphView;
+
+ private OpenUnitAction openUnitAction;
+ private RefreshUnitAction refreshUnitAction;
+ private ExitAction exitAction;
+ private PrintAction printAction;
+ private MaskAction maskEdgeAction;
+ private HelpAction helpAction;
+ private AboutAction aboutAction;
+
+ private static final Localizer _loc = Localizer.forPackage(MetamodelBrowser.class);
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) throws Exception {
+ MetamodelUIManager.setLookAndFeel();
+ EventQueue.invokeAndWait(new MetamodelBrowser());
+ }
+
+ private MetamodelBrowser() throws Exception {
+ super(_loc.get("metamodel.title").toString());
+ }
+
+ public void run() {
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ createActions();
+
+ menubar = createMenuBar();
+ graphView = createViewingArea();
+ JToolBar toolbar = createToolbar();
+
+ Container content = getContentPane();
+ content.setLayout(new BorderLayout());
+
+ setJMenuBar(menubar);
+
+ scrollableView = new JScrollPane(graphView);
+ scrollableView.setPreferredSize(new Dimension(1000, 800));
+ content.add(toolbar, BorderLayout.NORTH);
+ content.add(scrollableView, BorderLayout.CENTER);
+ pack();
+ SwingHelper.position(this, null);
+ setVisible(true);
+ }
+
+ void createActions() {
+ openUnitAction = new OpenUnitAction("action.open");
+ refreshUnitAction = new RefreshUnitAction("action.refresh");
+ printAction = new PrintAction("action.print");
+ exitAction = new ExitAction("action.exit");
+
+ maskEdgeAction = new MaskAction("action.filter.link", Attribute.class);
+
+ helpAction = new HelpAction("action.help");
+ aboutAction = new AboutAction("action.about");
+ }
+
+ JToolBar createToolbar() {
+ JToolBar bar = new JToolBar();
+ bar.setFloatable(false);
+ bar.add(openUnitAction);
+ bar.add(refreshUnitAction);
+ bar.add(printAction);
+ bar.addSeparator();
+ bar.add(maskEdgeAction);
+ return bar;
+ }
+
+ JMenuBar createMenuBar() {
+ JMenuBar bar = new JMenuBar();
+
+ JMenu fileMenu = new JMenu("File");
+ bar.add(fileMenu);
+ fileMenu.add(openUnitAction);
+ fileMenu.add(refreshUnitAction);
+ fileMenu.addSeparator();
+ fileMenu.add(printAction);
+ fileMenu.addSeparator();
+ fileMenu.add(exitAction);
+
+ JMenu viewMenu = new JMenu("View");
+ bar.add(viewMenu);
+ viewMenu.add(maskEdgeAction);
+
+ JMenu helpMenu = new JMenu("Help");
+ bar.add(helpMenu);
+ helpMenu.add(helpAction);
+ helpMenu.addSeparator();
+ helpMenu.add(aboutAction);
+
+ return bar;
+ }
+
+ GraphPanel<ManagedType<?>> createViewingArea() {
+ GraphPanel<ManagedType<?>> pane = new GraphPanel<ManagedType<?>>();
+ return pane;
+ }
+
+
+ public abstract class BaseAction extends AbstractAction {
+ public BaseAction(String key) {
+ super();
+ putValue(Action.NAME, _loc.get(key + ".name").toString());
+ putValue(Action.SHORT_DESCRIPTION, _loc.get(key + ".tooltip").toString());
+ putValue(Action.LONG_DESCRIPTION, _loc.get(key + ".help").toString());
+ putValue(Action.SMALL_ICON, Images.getIcon(_loc.get(key + ".icon").toString()));
+ putValue(Action.LARGE_ICON_KEY, Images.getIcon(_loc.get(key + ".icon").toString()));
+ }
+ }
+
+ /**
+ * Opens a new persistence domain model to be displayed.
+ *
+ */
+ public class OpenUnitAction extends BaseAction {
+ public OpenUnitAction(String name) {
+ super(name);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ final String unitName = JOptionPane.showInputDialog(MetamodelBrowser.this, "Persistence Unit",
+ "Enter Persistence Unit Name", JOptionPane.PLAIN_MESSAGE);
+
+ final SwingWorker<EntityManagerFactory, Void> task = new SwingWorker<EntityManagerFactory, Void>() {
+ @Override
+ protected EntityManagerFactory doInBackground() throws Exception {
+ firePropertyChange("message", "", "Opening persistence unit " + unitName);
+ Map<String,Object> props = new HashMap<String, Object>();
+ props.put("openjpa.BrokerFactory", "org.apache.openjpa.tools.metamodel.InMemoryBrokerFactory");
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(unitName, props);
+ return emf;
+ }
+ };
+ JProgressBar progressBar = new JProgressBar();
+ JButton cancel = new JButton(new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ task.cancel(true);
+ }
+ });
+ cancel.setText("Abort");
+ progressBar.add(cancel);
+ progressBar.setIndeterminate(true);
+ progressBar.setVisible(true);
+ task.execute();
+ try {
+ EntityManagerFactory emf = task.get();
+ if (task.isCancelled()) {
+ return;
+ }
+ MetamodelView newView = new MetamodelView(emf.getMetamodel());
+ graphView = newView;
+ scrollableView.setViewportView(graphView);
+ repaint();
+ } catch (ExecutionException ex) {
+ new org.apache.openjpa.swing.ErrorDialog(ex.getCause()).setVisible(true);
+ } catch (InterruptedException ie) {
+
+ }
+
+ }
+
+ }
+
+ public class CloseUnitAction extends BaseAction {
+ public CloseUnitAction(String name) {
+ super(name);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ }
+ }
+
+ public class SaveUnitAction extends BaseAction {
+ public SaveUnitAction(String name) {
+ super(name);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ }
+ }
+
+ public class PrintAction extends BaseAction {
+ public PrintAction(String name) {
+ super(name);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ PrinterJob printerJob = PrinterJob.getPrinterJob();
+ PrintableDelegateComponent printable = new PrintableDelegateComponent(MetamodelBrowser.this.graphView, printerJob
+ .getPageFormat(null));
+ printable.setScale(0.5);
+ printerJob.setPrintable(printable);
+ boolean print = printerJob.printDialog();
+ if (print) {
+ try {
+ printerJob.print();
+ } catch (PrinterException e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public class RefreshUnitAction extends BaseAction {
+ public RefreshUnitAction(String name) {
+ super(name);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ }
+ }
+
+ public class ExitAction extends BaseAction {
+ public ExitAction(String name) {
+ super(name);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ }
+ }
+
+ public class MaskAction extends BaseAction {
+ final Class<?> maskType;
+
+ public MaskAction(String name, Class<?> maskType) {
+ super(name);
+ this.maskType = maskType;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ }
+ }
+
+ public class HelpAction extends BaseAction {
+ public HelpAction(String name) {
+ super(name);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ }
+ }
+
+ public class AboutAction extends BaseAction {
+ public AboutAction(String name) {
+ super(name);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ JOptionPane.showMessageDialog(MetamodelBrowser.this, "OpenJPA MetaModel Browser");
+ }
+ }
+}
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelBrowser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelBrowser.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelHelper.java
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelHelper.java?rev=1004775&view=auto
==============================================================================
--- openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelHelper.java (added)
+++ openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelHelper.java Tue Oct 5 19:22:16 2010
@@ -0,0 +1,212 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.openjpa.tools.metamodel;
+
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.SingularAttribute;
+
+/**
+ * Static utility for analyzing persistent metadata model using JPA 2.0.
+ *
+ * @author Pinaki Poddar
+ *
+ */
+public class MetamodelHelper {
+ public static final int ATTR_ID = 0;
+ public static final int ATTR_VERSION = 1;
+ public static final int ATTR_BASIC = 2;
+ public static final int ATTR_SINGULAR_RELATION = 3;
+ public static final int ATTR_PLURAL_RELATION = 4;
+
+ public static <T> List<Attribute<? super T,?>> getAttributes(EntityType<T> type) {
+ List<Attribute<? super T,?>> list = new ArrayList<Attribute<? super T,?>>(type.getAttributes());
+ Collections.sort(list, new AttributeComparator());
+ return list;
+ }
+
+ public static int getAttributeType(Attribute<?, ?> a) {
+ if (a instanceof SingularAttribute) {
+ SingularAttribute<?, ?> sa = (SingularAttribute<?, ?>)a;
+ if (sa.isId()) return ATTR_ID;
+ if (sa.isVersion()) return ATTR_VERSION;
+ if (sa.isAssociation()) return ATTR_SINGULAR_RELATION;
+ if (sa.isCollection()) return ATTR_PLURAL_RELATION;
+ } else {
+ if (a.isAssociation()) return ATTR_SINGULAR_RELATION;
+ if (a.isCollection()) return ATTR_PLURAL_RELATION;
+ }
+ return ATTR_BASIC;
+
+ }
+
+ public static <T> Set<SingularAttribute<? super T, ?>> getIdAttributes(EntityType<T> type) {
+ Set<SingularAttribute<? super T,?>> attrs = type.getSingularAttributes();
+ Set<SingularAttribute<? super T,?>> idAttrs = new HashSet<SingularAttribute<? super T,?>>();
+ for (SingularAttribute<? super T,?> attr : attrs) {
+ if (attr.isId()) {
+ idAttrs.add(attr);
+ }
+ }
+ return idAttrs;
+ }
+
+ /**
+ * Finds the derived target of the given type, if any. Otherwise null.
+ */
+ public static <T> EntityType<?> derivedTarget(EntityType<T> type) {
+ Set<SingularAttribute<? super T,?>> ids = getIdAttributes(type);
+ for (SingularAttribute<? super T,?> id : ids) {
+ EntityType<?> derived = getParentType(id);
+ if (derived != null) {
+ return derived;
+ }
+ }
+ return null;
+ }
+
+ public static EntityType<?> getParentType(SingularAttribute<?,?> id) {
+ if (id.getType() instanceof EntityType) {
+ return (EntityType<?>)id.getType();
+ }
+ return null;
+ }
+
+
+ public static boolean isId(Attribute<?,?> a) {
+ if (a instanceof SingularAttribute)
+ return ((SingularAttribute<?,?>)a).isId();
+ return false;
+ }
+
+ public static boolean isVersion(Attribute<?,?> a) {
+ if (a instanceof SingularAttribute)
+ return ((SingularAttribute<?,?>)a).isVersion();
+ return false;
+ }
+
+ public static Integer getAttributeTypeCode(Attribute<?,?> attr) {
+ if (isId(attr))
+ return 0;
+ if (isVersion(attr))
+ return 1;
+
+ switch (attr.getPersistentAttributeType()) {
+ case BASIC :
+ case EMBEDDED:
+ return 2;
+ case ONE_TO_ONE:
+ case MANY_TO_ONE:
+ return 3;
+ case ONE_TO_MANY:
+ case MANY_TO_MANY:
+ case ELEMENT_COLLECTION: return 4;
+ default: return 5;
+ }
+ }
+ private static Map<Attribute<?,?>, Method> members = new HashMap<Attribute<?,?>, Method>();
+ private static Object[] EMPTY_ARGS = null;
+ private static Class<?>[] EMPTY_CLASSES = null;
+ /**
+ * Gets the value of the given persistent attribute for the given instance.
+ * @param attr
+ * @param instance
+ * @return
+ */
+ public static Object getValue(Attribute<?,?> attr, Object instance) {
+ Member member = attr.getJavaMember();
+ Method getter = null;
+ if (member instanceof Method) {
+ getter = (Method)member;
+ } else if (members.containsKey(attr)) {
+ getter = members.get(attr);
+ } else {
+ getter = getMethod(attr.getDeclaringType().getJavaType(), attr.getName());
+ members.put(attr, getter);
+ }
+ if (getter == null)
+ return null;
+ try {
+ return getter.invoke(instance, EMPTY_ARGS);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ private static Method getMethod(Class<?> type, String p) {
+ try {
+ String getter = "get" + Character.toUpperCase(p.charAt(0))+p.substring(1);
+ return type.getMethod(getter, EMPTY_CLASSES);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+
+ }
+
+
+ /**
+ * Compares EntityType by their dependency of derived targets.
+ *
+ * @author Pinaki Poddar
+ *
+ */
+ public static class EntityComparator implements Comparator<EntityType<?>> {
+ @Override
+ public int compare(EntityType<?> o1, EntityType<?> o2) {
+ if (derivedTarget(o1) == o2)
+ return 1;
+ if (derivedTarget(o2) == o1)
+ return -1;
+ return o1.getName().compareTo(o2.getName());
+ }
+
+ }
+
+
+ /**
+ * Compares attribute by their qualification.
+ * Identity
+ * Version
+ * Basic
+ * Singular association
+ * Plural association
+ *
+ * @author Pinaki Poddar
+ *
+ */
+ public static class AttributeComparator implements Comparator<Attribute<?,?>> {
+ @Override
+ public int compare(Attribute<?, ?> a1, Attribute<?, ?> a2) {
+ Integer t1 = getAttributeTypeCode(a1);
+ Integer t2 = getAttributeTypeCode(a2);
+ if (t1.equals(t2)) {
+ return a1.getName().compareTo(a2.getName());
+ } else {
+ return t1.compareTo(t2);
+ }
+ }
+ }
+}
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelHelper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelUIManager.java
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelUIManager.java?rev=1004775&view=auto
==============================================================================
--- openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelUIManager.java (added)
+++ openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelUIManager.java Tue Oct 5 19:22:16 2010
@@ -0,0 +1,274 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.openjpa.tools.metamodel;
+
+import java.awt.Color;
+import java.util.Enumeration;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.Attribute.PersistentAttributeType;
+import javax.persistence.metamodel.EmbeddableType;
+import javax.persistence.metamodel.ManagedType;
+import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.MappedSuperclassType;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.swing.Icon;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.plaf.FontUIResource;
+
+import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.swing.Images;
+
+
+
+/**
+ * Manages font, color, images for persistent meta-model views.
+ *
+ * @author Pinaki Poddar
+ *
+ */
+@SuppressWarnings("serial")
+public class MetamodelUIManager extends UIManager {
+ private static Localizer _loc = Localizer.forPackage(MetamodelUIManager.class);
+
+ public static final String COLOR_DEFAULT = "color.default";
+ public static final String COLOR_JPA = "color.jpa";
+ public static final String COLOR_JAVA = "color.java";
+ public static final String COLOR_ATTR_ID = "color.attr.id";
+ public static final String COLOR_ATTR_VERSION = "color.attr.version";
+ public static final String COLOR_ATTR_SINGULAR = "color.attr.singular";
+ public static final String COLOR_ATTR_PLURAL = "color.attr.plural";
+ public static final String COLOR_ATTR_BASIC = "color.attr.basic";
+ public static final String COLOR_ATTR_EMBEDDED = "color.attr.embedded";
+ public static final String COLOR_LINK_INHERIT = "color.link.inherit";
+
+ public static final String ICON_ERROR = "icon.error";
+ public static final String ICON_MAPPEDSUPER = "icon.mappedsuper";
+ public static final String ICON_ENTITY = "icon.entity";
+ public static final String ICON_EMBEDDED = "icon.embedded";
+
+ public static final String FONT_DEFAULT = "font.default";
+ public static final String FONT_DEFAULT_SIZE = "font.default.size";
+ public static final String ARROW_SIZE = "arrow.length";
+ public static final String ARROW_ANGLE = "arrow.angle";
+
+
+ private static final String LT = "<span style=\"color:#6D7B8D\"><</span>";
+ private static final String GT = "<span style=\"color:#6D7B8D\">></span>";
+
+ /**
+ * Sets look and feel of the User Interface.
+ * @param fontSize
+ * @throws Exception
+ */
+ public static void setLookAndFeel() throws Exception {
+ setLookAndFeel(getSystemLookAndFeelClassName());
+ UIDefaults defaults = getDefaults();
+ defaults.putDefaults(new Object[] {
+
+ COLOR_DEFAULT, Color.BLACK,
+ COLOR_JPA, Color.BLUE,
+ COLOR_JAVA, Color.DARK_GRAY,
+
+ ICON_MAPPEDSUPER, getIcon(ICON_MAPPEDSUPER),
+ ICON_ENTITY, getIcon(ICON_ENTITY),
+
+ ARROW_SIZE, 10,
+ ARROW_ANGLE, 30,
+ });
+
+ int fontSize = getInt(FONT_DEFAULT_SIZE);
+ if (fontSize == 0) fontSize = 14;
+ Enumeration<Object> keys = defaults.keys();
+
+ while (keys.hasMoreElements()) {
+ Object key = keys.nextElement();
+ if ((key instanceof String) && (((String) key).endsWith(".font"))) {
+ FontUIResource font = (FontUIResource) UIManager.get(key);
+ defaults.put (key, new FontUIResource(font.getFontName(), font.getStyle(), fontSize));
+ }
+ }
+ }
+
+ /**
+ * Gets the color used for a given Class.
+ */
+ public static Color getColor(Class<?> cls) {
+ if (cls == null)
+ return getColor(COLOR_DEFAULT);
+ if (cls.getName().startsWith("java.") || cls.isPrimitive())
+ return getColor(COLOR_JAVA);
+ if (cls.getName().startsWith("javax.persistence."))
+ return getColor(COLOR_JPA);
+ return getColor(COLOR_DEFAULT);
+
+ }
+
+ /**
+ * Gets the color used for the given attribute based on its persistent attribute type.
+ */
+ public static Color getColor(Attribute<?,?> attr) {
+ if (attr instanceof SingularAttribute) {
+ if (((SingularAttribute<?, ?>)attr).isId()) {
+ return getColor(COLOR_ATTR_ID);
+ } else if (((SingularAttribute<?, ?>)attr).isVersion()) {
+ return getColor(COLOR_ATTR_VERSION);
+ }
+ }
+ return getColor(attr.getPersistentAttributeType());
+ }
+
+ /**
+ * Gets the color used for the given persistent attribute type.
+ */
+ public static Color getColor(PersistentAttributeType type) {
+ switch (type) {
+ case BASIC:
+ return getColor(COLOR_ATTR_BASIC);
+ case ELEMENT_COLLECTION:
+ return getColor(COLOR_ATTR_PLURAL);
+ case EMBEDDED:
+ return getColor(COLOR_ATTR_EMBEDDED);
+ case MANY_TO_MANY:
+ return getColor(COLOR_ATTR_PLURAL);
+ case MANY_TO_ONE:
+ return getColor(COLOR_ATTR_SINGULAR);
+ case ONE_TO_MANY:
+ return getColor(COLOR_ATTR_PLURAL);
+ case ONE_TO_ONE:
+ return getColor(COLOR_ATTR_SINGULAR);
+ default:
+ return getColor(COLOR_ATTR_BASIC);
+ }
+ }
+
+ /**
+ * Gets the icon for the given key.
+ */
+ public static Icon getIcon(String key) {
+ Icon icon = getDefaults().getIcon(key);
+ if (icon == null) {
+ String path = _loc.get(key).toString();
+ icon = Images.getIcon(path);
+ put(key, icon);
+ }
+ return icon;
+ }
+
+ /**
+ * Gets the icon for the given managed type based on its category.
+ */
+ public static Icon getIcon(ManagedType<?> type) {
+ if (type instanceof MappedSuperclassType) {
+ return getIcon(ICON_MAPPEDSUPER);
+ } else if (type instanceof EmbeddableType) {
+ return getIcon(ICON_EMBEDDED);
+ } else {
+ return getIcon(ICON_ENTITY);
+ }
+
+ }
+
+ /**
+ * Gets the HTML text for the given class.
+ * The HTML text decorates the simple name of the class in bold and appropriate color.
+ */
+ public static String getHTMLName(Class<?> cls) {
+ return getHTMLName(cls, true);
+ }
+
+ public static String getHTMLName(Attribute<?, ?> attr) {
+ return getHTMLName(attr, true);
+ }
+
+ public static String getHTMLName(Class<?> cls, boolean closeHTMLTag) {
+ String color = "#"+Integer.toHexString(getColor(cls).getRGB()).substring(2,8);
+ String decorated = "<span style=\"font-weight:bold;color:"+color + "\">" + cls.getSimpleName() + "</span>";
+ return closeHTMLTag ? "<HTML>" + decorated + "</HTML>" : decorated;
+ }
+
+ /**
+ * Gets the string styled by HTML tags for the given attribute.
+ * The string contains the type and name of the persistent attribute, where the type is styled
+ * based on its class while the name is styled by its persistent category.
+ */
+ public static String getHTMLName(Attribute<?, ?> attr, boolean closeHTMLTag) {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append(getHTMLName(attr.getJavaType(), false));
+ if (attr instanceof MapAttribute) {
+ MapAttribute<?, ?, ?> mAttr = (MapAttribute<?, ?, ?>) attr;
+ buffer.append(LT)
+ .append(getHTMLName(mAttr.getKeyType().getJavaType(), false))
+ .append(",")
+ .append(getHTMLName(mAttr.getElementType().getJavaType(), false))
+ .append(GT);
+ } else if (attr instanceof PluralAttribute) {
+ PluralAttribute<?, ?, ?> cAttr = (PluralAttribute<?, ?, ?>) attr;
+ buffer.append(LT)
+ .append(getHTMLName(cAttr.getElementType().getJavaType(), false))
+ .append(GT);
+ }
+ buffer.append(" ");
+
+ if (attr instanceof SingularAttribute) {
+ if (((SingularAttribute<?, ?>)attr).isId()) {
+ buffer.append(decorate(attr.getName(), "b"));
+ } else if (((SingularAttribute<?, ?>)attr).isVersion()) {
+ buffer.append(decorate(attr.getName(), "em"));
+ } else {
+ buffer.append(attr.getName());
+ }
+ } else {
+ buffer.append(attr.getName());
+ }
+ return decorate(buffer.toString(), closeHTMLTag ? "HTML" : null);
+ }
+
+ /**
+ * Decorates the given text with the given tag.
+ */
+ public static String decorate(String txt, String tag) {
+ return decorate(txt, tag, null);
+ }
+
+ /**
+ * Decorates the given text with the given tag and given attribute of the tag.
+ */
+ public static String decorate(String txt, String tag, String attr) {
+ return tag == null ? txt : "<" + tag + (attr != null ? " " + attr : "") + ">" + txt + "</" + tag +">";
+ }
+
+ public static String quote(String txt) {
+ return "\"" + txt + "\"";
+ }
+
+
+ /**
+ * Creates a html for the given text styled by the given name-value pairs of styles.
+ * @param text
+ * @param styles even number of name-value pair strings such as "font-weight","bold","text-align","center"
+ * @return
+ */
+ public static String createHTMLLabel(String text, String...styles) {
+ StringBuilder buf = new StringBuilder();
+ for (int i = 0; i < styles.length; i += 2) {
+ if (buf.length() > 0) buf.append(";");
+ buf.append(styles[i]).append(":").append(styles[i+1]);
+ }
+ return decorate(decorate(text, "span", "style=" + quote(buf.toString())), "HTML");
+ }
+
+}
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelUIManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelUIManager.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelView.java
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelView.java?rev=1004775&view=auto
==============================================================================
--- openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelView.java (added)
+++ openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelView.java Tue Oct 5 19:22:16 2010
@@ -0,0 +1,147 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.openjpa.tools.metamodel;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.Attribute.PersistentAttributeType;
+import javax.persistence.metamodel.IdentifiableType;
+import javax.persistence.metamodel.ManagedType;
+import javax.persistence.metamodel.Metamodel;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.swing.BorderFactory;
+
+import org.apache.openjpa.swing.graph.Connectable;
+import org.apache.openjpa.swing.graph.DefaultGraphModel;
+import org.apache.openjpa.swing.graph.GraphModel;
+import org.apache.openjpa.swing.graph.GraphPanel;
+import org.apache.openjpa.swing.graph.NodeViewFactory;
+
+
+/**
+ * Graphical View of a JPA 2.0 Metamodel.
+ * The view is isomorphic to the {@link Metamodel meta-model} defined by JPA 2.0 specification.
+ * Hence the view is organized in terms of corresponding views of {@link EntityTypeView entity}
+ * and their {@link AttributeView attributes}.
+ * <br>
+ *
+ * @author Pinaki Poddar
+ *
+ */
+@SuppressWarnings("serial")
+public class MetamodelView extends GraphPanel<ManagedType<?>> {
+ /**
+ * Creates a visual widget from the given data model.
+ */
+ public MetamodelView(Metamodel model) {
+ super();
+ GraphModel<ManagedType<?>> graphModel = adapt(model);
+ setDefaultNodeFactory(new NodeViewFactory<ManagedType<?>>() {
+ public Connectable<ManagedType<?>> createComponent(ManagedType<?> type, Graphics g) {
+ EntityTypeView<?> view = new EntityTypeView(type, true);
+ view.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
+ return view;
+ }
+ });
+
+ setEdgeRenderer(AttributeView.AttributeLink.class, new AttributeView.AttributeEdgeRenderer());
+ setEdgeRenderer(AttributeView.IdLink.class, new AttributeView.IdLinkRenderer());
+ setEdgeRenderer(AttributeView.InheritenceLink.class, new AttributeView.InheritenceEdgeRenderer());
+
+ // Important: set model after setting node/edge view factories
+ // Because once the model is set, the visual widgets for the nodes of the model
+ // will be created using the currently defined NodeFactory and EdgeRenderes etc.
+ setModel(graphModel);
+ }
+
+ @Override
+ public boolean isValidateRoot() {
+ return true;
+ }
+
+ /**
+ * Adapts the given {@link Metamodel} to a {@linkplain GraphModel}.
+ * Each managed type of the given model becomes a vertex in the graph.
+ * The relations between the entities become {@link MetaModelEdges typed} edges.
+ *
+ * @param model a JPA metamodel
+ * @return a GraphModel with EntityType as vertex and relations as edges.
+ */
+ private GraphModel<ManagedType<?>> adapt(Metamodel model) {
+ if (model == null)
+ return null;
+ GraphModel<ManagedType<?>> graphModel = new DefaultGraphModel<ManagedType<?>>();
+
+ Set<ManagedType<?>> types = model.getManagedTypes();
+ for (ManagedType<?> type : types) {
+ graphModel.addVertex(type);
+ }
+
+ Set<Attribute<?,?>> idAttrs = new HashSet<Attribute<?,?>>();
+ for (ManagedType<?> type : types) {
+ // Derived identity and Supertype links
+ if (type instanceof IdentifiableType) {
+ ManagedType<?> superType = ((IdentifiableType<?>) type).getSupertype();
+ if (superType != null) {
+ graphModel.link(new AttributeView.InheritenceLink(type, superType));
+ }
+ IdentifiableType<?> itype = ((IdentifiableType<?>) type);
+ if (itype.hasSingleIdAttribute()) {
+ if (itype.getIdType() instanceof ManagedType) {
+ SingularAttribute<?, ?> idAttr = itype.getId(itype.getIdType().getJavaType());
+ graphModel.link(new AttributeView.IdLink(type,
+ (ManagedType<?>) itype.getIdType(), idAttr));
+ idAttrs.add(idAttr);
+ }
+ } else {
+ for (SingularAttribute<?, ?> idAttr : itype.getIdClassAttributes()) {
+ if (idAttr.isAssociation()) {
+ graphModel.link(new AttributeView.IdLink(type,
+ (ManagedType<?>) idAttr.getType(), idAttr));
+ idAttrs.add(idAttr);
+ }
+ }
+ }
+ }
+
+ for (Attribute<?, ?> attr : type.getDeclaredAttributes()) {
+ if (idAttrs.contains(attr)) // has been taken care of in the above
+ continue;
+ ManagedType<?> target = null;
+ PersistentAttributeType attrType = attr.getPersistentAttributeType();
+ switch (attrType) {
+ case ONE_TO_ONE:
+ case MANY_TO_ONE:
+ target = model.managedType(attr.getJavaType());
+ graphModel.link(new AttributeView.AttributeLink(type, target, attr));
+ break;
+ case ONE_TO_MANY:
+ case MANY_TO_MANY:
+ target = model.managedType(((PluralAttribute<?,?,?>) attr).getElementType().getJavaType());
+ graphModel.link(new AttributeView.AttributeLink(type, target, attr));
+ break;
+ case BASIC:
+ case ELEMENT_COLLECTION:
+ case EMBEDDED:
+ }
+ }
+ }
+ return graphModel;
+ }
+}
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelView.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/metamodel/MetamodelView.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/arrow_left.jpg
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/arrow_left.jpg?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/arrow_left.jpg
------------------------------------------------------------------------------
svn:mime-type = image/jpeg
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/arrow_right.jpg
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/arrow_right.jpg?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/arrow_right.jpg
------------------------------------------------------------------------------
svn:mime-type = image/jpeg
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/bullet_arrow_down.png
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/bullet_arrow_down.png?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/bullet_arrow_down.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/bullet_arrow_up.png
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/bullet_arrow_up.png?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/bullet_arrow_up.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/cancel.png
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/cancel.png?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/cancel.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/collapseall.gif
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/collapseall.gif?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/collapseall.gif
------------------------------------------------------------------------------
svn:mime-type = image/gif
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/done.png
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/done.png?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/done.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/error.png
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/error.png?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/error.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/expandall.gif
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/expandall.gif?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/expandall.gif
------------------------------------------------------------------------------
svn:mime-type = image/gif
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/help.png
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/help.png?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/help.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/icon_embeddable.gif
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/icon_embeddable.gif?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/icon_embeddable.gif
------------------------------------------------------------------------------
svn:mime-type = image/gif
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/icon_entity.gif
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/icon_entity.gif?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/icon_entity.gif
------------------------------------------------------------------------------
svn:mime-type = image/gif
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/icon_mappedsuper.gif
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/icon_mappedsuper.gif?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/icon_mappedsuper.gif
------------------------------------------------------------------------------
svn:mime-type = image/gif
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/open.png
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/open.png?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/open.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/print.gif
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/print.gif?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/print.gif
------------------------------------------------------------------------------
svn:mime-type = image/gif
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/refresh.png
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/refresh.png?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/refresh.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/save.png
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/save.png?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/save.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/search.jpg
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/search.jpg?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/search.jpg
------------------------------------------------------------------------------
svn:mime-type = image/jpeg
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/start_task.gif
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/images/start_task.gif?rev=1004775&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/images/start_task.gif
------------------------------------------------------------------------------
svn:mime-type = image/gif
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/swing/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/swing/localizer.properties?rev=1004775&view=auto
==============================================================================
--- openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/swing/localizer.properties (added)
+++ openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/swing/localizer.properties Tue Oct 5 19:22:16 2010
@@ -0,0 +1,13 @@
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+resource-not-found: Can not find resource "{0}"
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/swing/localizer.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/swing/localizer.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/tools/metamodel/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/tools/metamodel/localizer.properties?rev=1004775&view=auto
==============================================================================
--- openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/tools/metamodel/localizer.properties (added)
+++ openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/tools/metamodel/localizer.properties Tue Oct 5 19:22:16 2010
@@ -0,0 +1,57 @@
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------------
+# Configuration for MetaModel Viewer
+# -----------------------------------------------------------------------------
+
+resource-not-found: Can not find resource "{0}"
+metamodel.title: OpenJPA MetaModel Viewer
+# -----------------------------------------------------------------------------
+# Icons in the view
+icon.entity:images/icon_entity.gif
+icon.mappedsuper:images/icon_mappedsuper.gif
+icon.embeddable:images/icon_embeddable.gif
+icon.error: images/error.gif
+
+
+# -----------------------------------------------------------------------------
+# Configuring Actions
+#
+# <action>.name : The name of the action used for menu or button
+# <action>.tooltip : The tooltip for the action
+# <action>.help : The help text for the action
+# <action>.icon : The resource path for the icon for toolbar or button
+# -----------------------------------------------------------------------------
+action.open.name:Open...
+action.open.tooltip: "Open a Persistence Unit"
+action.open.help: "Open a Persistence Unit"
+action.open.icon:images/open.png
+
+action.print.name:Print
+action.print.icon:images/print.gif
+action.about.name:About
+action.help.name:Help
+action.help.icon:images/help.png
+
+action.exit.name:Exit
+action.exit.tooltip:Exit MetaModel Viewer
+
+action.save.name:Save
+action.save.tooltip:Save the current Persistence Unit
+action.save.icon:images/save.png
+
+action.refresh.name:Refresh
+action.refresh.tooltip:Refresh the current Persistence Unit
+action.refresh.icon:images/refresh.png
+
+action.filter.entity.name:Filter Classes...
+action.filter.link.name:Filter links...
\ No newline at end of file
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/tools/metamodel/localizer.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/tools/trunk/openjpa-tools/src/main/resources/org/apache/openjpa/tools/metamodel/localizer.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain