mirror of https://github.com/apache/openjpa.git
Image management
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@951464 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7b14267281
commit
c3563ec823
|
@ -88,7 +88,7 @@ public class PowerPointViewer extends JPanel {
|
|||
private JPanel createNavigationButtons() {
|
||||
JPanel buttons = new JPanel();
|
||||
_navButtons = new JButton[Math.min(MAX_BUTTONS, _total)];
|
||||
_prev = new JButton(Images.BACK);
|
||||
_prev = new RoundButton(Images.BACK);
|
||||
buttons.add(_prev);
|
||||
_prev.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -110,7 +110,7 @@ public class PowerPointViewer extends JPanel {
|
|||
});
|
||||
}
|
||||
int slideIndex = i + 2;
|
||||
_navButtons[i] = new JButton(""+slideIndex);
|
||||
_navButtons[i] = new JButton(String.format("%02d", slideIndex));
|
||||
buttons.add(_navButtons[i]);
|
||||
_navButtons[i].putClientProperty(SLIDE_INDEX, i+1);
|
||||
_navButtons[i].addActionListener(new ActionListener() {
|
||||
|
@ -121,7 +121,7 @@ public class PowerPointViewer extends JPanel {
|
|||
}
|
||||
});
|
||||
}
|
||||
_next = new JButton(Images.NEXT);
|
||||
_next = new RoundButton(Images.NEXT);
|
||||
buttons.add(Box.createHorizontalGlue());
|
||||
buttons.add(_next);
|
||||
_next.addActionListener(new ActionListener() {
|
||||
|
@ -180,7 +180,7 @@ public class PowerPointViewer extends JPanel {
|
|||
|
||||
for (int i = 0; i < _navButtons.length; i++) {
|
||||
int slideIndex = index+i+2;
|
||||
_navButtons[i].setText(""+ slideIndex);
|
||||
_navButtons[i].setText(String.format("%02d", slideIndex));
|
||||
_navButtons[i].putClientProperty(SLIDE_INDEX, (index+i+1));
|
||||
}
|
||||
}
|
||||
|
@ -229,22 +229,4 @@ public class PowerPointViewer extends JPanel {
|
|||
return imgURL;
|
||||
}
|
||||
|
||||
// private ImageIcon createImageIcon(String path) {
|
||||
// if (path == null)
|
||||
// return null;
|
||||
// URL imgURL = Thread.currentThread().getContextClassLoader().getResource(path);
|
||||
// if (imgURL != null) {
|
||||
// return new ImageIcon(imgURL);
|
||||
// } else {
|
||||
// imgURL = Images.class.getResource(path);
|
||||
// if (imgURL != null) {
|
||||
// return new ImageIcon(imgURL);
|
||||
// } else {
|
||||
// System.err.println("Couldn't find file: " + path);
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import jpa.tools.swing.EntityDataModel;
|
|||
import jpa.tools.swing.EntityTable;
|
||||
import jpa.tools.swing.EntityTableView;
|
||||
import jpa.tools.swing.ErrorDialog;
|
||||
import jpa.tools.swing.RoundButton;
|
||||
import openbook.client.Demo.ShowCodeAction;
|
||||
import openbook.domain.Author;
|
||||
import openbook.domain.Book;
|
||||
|
@ -179,7 +180,7 @@ public final class BuyBookPage extends JPanel {
|
|||
layout.setHorizontalGroup(hGroup);
|
||||
layout.setVerticalGroup(vGroup);
|
||||
|
||||
JButton searchButton = new JButton("Search", Images.START);
|
||||
JButton searchButton = new JButton("Search", Images.SEARCH);
|
||||
searchButton.setHorizontalTextPosition(SwingConstants.LEADING);
|
||||
ShowCodeAction showCode = Demo.getInstance().new ShowCodeAction();
|
||||
showCode.setPage("Dynamic Query", "openbook/server/OpenBookServiceImpl.java.html#buildQuery");
|
||||
|
@ -331,7 +332,7 @@ public final class BuyBookPage extends JPanel {
|
|||
|
||||
JPanel buttonPanel = new JPanel();
|
||||
buttonPanel.add(Box.createHorizontalGlue());
|
||||
_addToCart = new JButton("Add to Cart", Images.getIcon("images/Add2Cart.jpg", true));
|
||||
_addToCart = new JButton("Add to Cart", Images.CART);
|
||||
_addToCart.setEnabled(false);
|
||||
buttonPanel.add(_addToCart);
|
||||
buttonPanel.add(Box.createHorizontalGlue());
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
|
@ -107,7 +108,6 @@ public class Demo extends JFrame {
|
|||
private SQLLogger _sqlListener;
|
||||
private SourceCodeBrowser _sourceBrowser;
|
||||
private static Demo _instance;
|
||||
public static final Icon LOGO = Images.getIcon("images/OpenBooks.jpg");
|
||||
private static final String SRC_ROOT = "source/";
|
||||
|
||||
/**
|
||||
|
@ -157,18 +157,18 @@ public class Demo extends JFrame {
|
|||
private Demo() {
|
||||
Thread.currentThread().setUncaughtExceptionHandler(new ErrorHandler());
|
||||
_config = PropertyHelper.load(System.getProperty("openbook.client.config", "demo.properties"));
|
||||
setIconImage(((ImageIcon)LOGO).getImage());
|
||||
setIconImage(((ImageIcon)Images.LOGO_OPENBOOKS).getImage());
|
||||
setTitle("OpenBooks: A Sample JPA 2.0 Application");
|
||||
|
||||
_root = new WelcomeAction("OpenBooks", "images/OpenBooks.jpg", "OpenBooks");
|
||||
_about = new AboutAction("About OpenBooks", "images/OpenBooks.jpg", "About OpenBooks");
|
||||
_buyBook = new BuyBookAction("Buy", "images/Add2Cart.jpg", "Browse and Buy Books");
|
||||
_deliver = new DeliveryAction("Deliver", "images/Deliver.jpg", "Deliver Pending Orders");
|
||||
_supply = new SupplyAction("Supply", "images/Supply.jpg", "Supply Books");
|
||||
_viewConfig = new ViewConfigAction("Configuration", "images/browse.png", "View Configuration");
|
||||
_viewDomain = new ViewDomainAction("Domain", "images/DomainModel.jpg", "View Domain Model");
|
||||
_viewSource = new ViewSourceAction("Source", "images/SourceCode.jpg", "View Source Code");
|
||||
_viewQuery = new ViewQueryCacheAction("Query", "images/DataModel.jpg", "View Queries");
|
||||
_root = new WelcomeAction("OpenBooks", Images.LOGO_OPENBOOKS, "OpenBooks");
|
||||
_about = new AboutAction("About OpenBooks", Images.LOGO_OPENBOOKS, "About OpenBooks");
|
||||
_buyBook = new BuyBookAction("Buy", Images.BUY, "Browse and Buy Books");
|
||||
_deliver = new DeliveryAction("Deliver", Images.DELIVERY, "Deliver Pending Orders");
|
||||
_supply = new SupplyAction("Supply", Images.SUPPLY, "Supply Books");
|
||||
_viewConfig = new ViewConfigAction("Unit", Images.VIEW_UNIT, "View Configuration");
|
||||
_viewDomain = new ViewDomainAction("Domain", Images.VIEW_DOMAIN, "View Domain Model");
|
||||
_viewSource = new ViewSourceAction("Source", Images.VIEW_CODE, "View Source Code");
|
||||
_viewQuery = new ViewQueryCacheAction("Query", Images.VIEW_QUERY, "View Queries");
|
||||
|
||||
_toolBar = createToolBar();
|
||||
_navigator = createNavigator();
|
||||
|
@ -304,10 +304,6 @@ public class Demo extends JFrame {
|
|||
*
|
||||
*/
|
||||
public abstract class OpenBookAction extends AbstractAction {
|
||||
public OpenBookAction(String name, String iconLocation, String tooltip) {
|
||||
this(name, Images.getIcon(iconLocation, true), tooltip);
|
||||
}
|
||||
|
||||
public OpenBookAction(String name, Icon icon, String tooltip) {
|
||||
putValue(Action.NAME, name);
|
||||
putValue(Action.SHORT_DESCRIPTION, tooltip);
|
||||
|
@ -317,8 +313,8 @@ public class Demo extends JFrame {
|
|||
|
||||
public class BuyBookAction extends OpenBookAction {
|
||||
BuyBookPage _buyBookPage;
|
||||
public BuyBookAction(String name, String iconLocation, String tooltip) {
|
||||
super(name, iconLocation, tooltip);
|
||||
public BuyBookAction(String name, Icon icon, String tooltip) {
|
||||
super(name, icon, tooltip);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -332,8 +328,8 @@ public class Demo extends JFrame {
|
|||
}
|
||||
public class DeliveryAction extends OpenBookAction {
|
||||
DeliveryPage _deliveryPage;
|
||||
public DeliveryAction(String name, String iconLocation, String tooltip) {
|
||||
super(name, iconLocation, tooltip);
|
||||
public DeliveryAction(String name, Icon icon, String tooltip) {
|
||||
super(name, icon, tooltip);
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (_deliveryPage == null) {
|
||||
|
@ -347,8 +343,8 @@ public class Demo extends JFrame {
|
|||
|
||||
public class SupplyAction extends OpenBookAction {
|
||||
SupplyPage _supplyPage;
|
||||
public SupplyAction(String name, String iconLocation, String tooltip) {
|
||||
super(name, iconLocation, tooltip);
|
||||
public SupplyAction(String name, Icon icon, String tooltip) {
|
||||
super(name, icon, tooltip);
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (_supplyPage == null) {
|
||||
|
@ -362,8 +358,8 @@ public class Demo extends JFrame {
|
|||
|
||||
public class ViewConfigAction extends OpenBookAction {
|
||||
ConfigurationViewer _configView;
|
||||
public ViewConfigAction(String name, String iconLocation, String tooltip) {
|
||||
super(name, iconLocation, tooltip);
|
||||
public ViewConfigAction(String name, Icon icon, String tooltip) {
|
||||
super(name, icon, tooltip);
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (_configView == null) {
|
||||
|
@ -379,8 +375,8 @@ public class Demo extends JFrame {
|
|||
public class ViewDomainAction extends OpenBookAction {
|
||||
MetamodelView _domainView;
|
||||
AttributeLegendView _legends;
|
||||
public ViewDomainAction(String name, String iconLocation, String tooltip) {
|
||||
super(name, iconLocation, tooltip);
|
||||
public ViewDomainAction(String name, Icon icon, String tooltip) {
|
||||
super(name, icon, tooltip);
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (_domainView == null) {
|
||||
|
@ -394,8 +390,8 @@ public class Demo extends JFrame {
|
|||
}
|
||||
|
||||
public class ViewDataAction extends OpenBookAction {
|
||||
public ViewDataAction(String name, String iconLocation, String tooltip) {
|
||||
super(name, iconLocation, tooltip);
|
||||
public ViewDataAction(String name, Icon icon, String tooltip) {
|
||||
super(name, icon, tooltip);
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showTab(_tabbedPane, "Buy Books", null);
|
||||
|
@ -405,8 +401,8 @@ public class Demo extends JFrame {
|
|||
|
||||
public class ViewQueryCacheAction extends OpenBookAction {
|
||||
PreparedQueryViewer _queryView;
|
||||
public ViewQueryCacheAction(String name, String iconLocation, String tooltip) {
|
||||
super(name, iconLocation, tooltip);
|
||||
public ViewQueryCacheAction(String name, Icon icon, String tooltip) {
|
||||
super(name, icon, tooltip);
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (_queryView == null) {
|
||||
|
@ -419,8 +415,8 @@ public class Demo extends JFrame {
|
|||
}
|
||||
|
||||
public class ViewSourceAction extends OpenBookAction {
|
||||
public ViewSourceAction(String name, String iconLocation, String tooltip) {
|
||||
super(name, iconLocation, tooltip);
|
||||
public ViewSourceAction(String name, Icon icon, String tooltip) {
|
||||
super(name, icon, tooltip);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -437,7 +433,7 @@ public class Demo extends JFrame {
|
|||
private String _page;
|
||||
|
||||
public ShowCodeAction() {
|
||||
super("Show Code", Images.JAVA, "View Java Source Code");
|
||||
super("View Code", Images.VIEW_CODE, "View Java Source Code");
|
||||
}
|
||||
|
||||
public void setPage(String key, String page) {
|
||||
|
@ -458,11 +454,11 @@ public class Demo extends JFrame {
|
|||
*/
|
||||
public class WelcomeAction extends OpenBookAction {
|
||||
PowerPointViewer _powerpoint;
|
||||
JLabel _logoLabel = new JLabel(LOGO);
|
||||
JLabel _logoLabel = new JLabel(Images.LOGO_OPENBOOKS);
|
||||
boolean _showPresentation = true;
|
||||
|
||||
public WelcomeAction(String name, String iconLocation, String tooltip) {
|
||||
super(name, iconLocation, tooltip);
|
||||
public WelcomeAction(String name, Icon icon, String tooltip) {
|
||||
super(name, icon, tooltip);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -501,13 +497,13 @@ public class Demo extends JFrame {
|
|||
public class AboutAction extends OpenBookAction {
|
||||
AboutDialog _dialog;
|
||||
|
||||
public AboutAction(String name, String iconLocation, String tooltip) {
|
||||
super(name, iconLocation, tooltip);
|
||||
public AboutAction(String name, Icon icon, String tooltip) {
|
||||
super(name, icon, tooltip);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (_dialog == null) {
|
||||
_dialog = new AboutDialog(LOGO);
|
||||
_dialog = new AboutDialog(Images.LOGO_OPENBOOKS);
|
||||
SwingHelper.position(_dialog, Demo.this);
|
||||
}
|
||||
_dialog.setVisible(true);
|
||||
|
@ -591,7 +587,7 @@ public class Demo extends JFrame {
|
|||
*/
|
||||
private JTree createNavigator() {
|
||||
ActionTreeNode root = new ActionTreeNode(_root);
|
||||
DefaultMutableTreeNode app = new DefaultMutableTreeNode("Application WorkFlows");
|
||||
DefaultMutableTreeNode app = new DefaultMutableTreeNode("WorkFlows");
|
||||
DefaultMutableTreeNode views = new DefaultMutableTreeNode("Views");
|
||||
root.add(app);
|
||||
root.add(views);
|
||||
|
@ -620,6 +616,10 @@ public class Demo extends JFrame {
|
|||
});
|
||||
tree.setCellRenderer(new TypedTreeCellRenderer());
|
||||
|
||||
for (int i = 0; i < tree.getRowCount(); i++) {
|
||||
tree.expandRow(i);
|
||||
}
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
|
@ -655,16 +655,19 @@ public class Demo extends JFrame {
|
|||
setLayout(new BorderLayout());
|
||||
JButton button = new JButton("<html>"
|
||||
+ "<b>OpenBooks</b> "
|
||||
+ "<br> using OpenJPA version " + OpenJPAVersion.MAJOR_RELEASE + "." + OpenJPAVersion.MINOR_RELEASE
|
||||
+ "<p>"
|
||||
+ "<br> by JPA Team, SWG"
|
||||
+ "<br>IBM Corporation"
|
||||
+ "<br> IBM Corporation"
|
||||
+ "<p>"
|
||||
+ "</html>");
|
||||
button.setIcon(logo);
|
||||
button.setHorizontalTextPosition(SwingConstants.RIGHT);
|
||||
button.setIconTextGap(4);
|
||||
button.setEnabled(true);
|
||||
button.setBorderPainted(false);
|
||||
JLabel openJPALogo = new JLabel(Images.getIcon("images/openjpa-logo-small.png"));
|
||||
JLabel openJPALogo = new JLabel(Images.LOGO_OPENJPA);
|
||||
String version = "Version " + OpenJPAVersion.MAJOR_RELEASE + "." + OpenJPAVersion.MINOR_RELEASE;
|
||||
openJPALogo.setBorder(BorderFactory.createTitledBorder(version));
|
||||
openJPALogo.setBackground(Color.BLACK);
|
||||
|
||||
add(button, BorderLayout.CENTER);
|
||||
|
|
|
@ -21,8 +21,15 @@ import java.util.Map;
|
|||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import openbook.client.Demo.SupplyAction;
|
||||
import openbook.client.Demo.ViewConfigAction;
|
||||
import openbook.client.Demo.ViewDomainAction;
|
||||
import openbook.client.Demo.ViewQueryCacheAction;
|
||||
import openbook.client.Demo.ViewSourceAction;
|
||||
|
||||
/**
|
||||
* Utility to load and cache images.
|
||||
* Maintains a list of <em>known</em> images.
|
||||
*
|
||||
* @author Pinaki Poddar
|
||||
*
|
||||
|
@ -30,15 +37,27 @@ import javax.swing.ImageIcon;
|
|||
public class Images {
|
||||
|
||||
private static Map<String, Icon> images = new HashMap<String, Icon>();
|
||||
public static Icon NEXT = getIcon("images/nav_forward.gif");
|
||||
public static Icon BACK = getIcon("images/nav_backward.gif");
|
||||
|
||||
public static Icon NEXT = getIcon("images/arrow_right.jpg", 24, -1);
|
||||
public static Icon BACK = getIcon("images/arrow_left.jpg", 24, -1);
|
||||
public static Icon DONE = getIcon("images/done.png");
|
||||
public static Icon CANCEL = getIcon("images/cancel.png");
|
||||
public static Icon ERROR = getIcon("images/error.png");
|
||||
public static Icon BROWSE = getIcon("images/browse.png");
|
||||
public static Icon START = getIcon("images/start_task.gif");
|
||||
public static Icon MONITOR = getIcon("images/console_view.gif");
|
||||
public static Icon JAVA = getIcon("images/SourceCode.jpg", true);
|
||||
|
||||
public static final Icon BUY = Images.getIcon("images/buy.jpg", 32, -1);
|
||||
public static final Icon DELIVERY = Images.getIcon("images/delivery.jpg", 32, -1);
|
||||
public static final Icon SUPPLY = Images.getIcon("images/supply.jpg", 32, -1);
|
||||
public static final Icon SEARCH = Images.getIcon("images/search.jpg", 24, -1);
|
||||
public static final Icon CART = Images.getIcon("images/cart.jpg", 24, -1);
|
||||
|
||||
public static Icon VIEW_UNIT = Images.getIcon("images/view_unit.jpg", 32, -1);
|
||||
public static Icon VIEW_DOMAIN = Images.getIcon("images/view_domain.jpg", 32, -1);
|
||||
public static Icon VIEW_CODE = Images.getIcon("images/view_code.jpg", 32, -1);
|
||||
public static Icon VIEW_QUERY = Images.getIcon("images/view_query.jpg", 32, -1);
|
||||
|
||||
public static final Icon LOGO_OPENBOOKS = Images.getIcon("images/OpenBooks.jpg", 32, -1);
|
||||
public static final Icon LOGO_OPENJPA = Images.getIcon("images/openjpa-logo-small.png");
|
||||
|
||||
|
||||
public static Icon getIcon(String name) {
|
||||
Icon icon = images.get(name);
|
||||
|
|
Loading…
Reference in New Issue