From 0ee348e2b6e82aab05df9ef7d2d37a7e038abd20 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Tue, 15 May 2012 15:29:46 +0000 Subject: [PATCH] refs #14 Added ToolBar to JExtDesktopPane and created new About window. --- resources/images/Cascade16.png | Bin 0 -> 535 bytes resources/images/TileHorizontal16.png | Bin 0 -> 422 bytes resources/images/TileVertical16.png | Bin 0 -> 369 bytes src/eva2/client/EvAClient.java | 189 ++++++--------- src/eva2/gui/AboutDialog.java | 108 +++++++++ src/eva2/gui/EvATabbedFrameMaker.java | 2 +- src/eva2/gui/ExtDesktopManager.java | 6 +- src/eva2/gui/JDocFrame.java | 5 +- src/eva2/gui/JExtDesktopPane.java | 134 ++++------ src/eva2/gui/JExtDesktopPaneToolBar.java | 63 +++++ src/eva2/gui/JTextoutputFrame.java | 255 ++++++++++---------- src/eva2/gui/JTextoutputFrameInterface.java | 17 +- src/eva2/gui/TagEditor.java | 6 - src/eva2/tools/ToolBoxGui.java | 5 +- 14 files changed, 426 insertions(+), 364 deletions(-) create mode 100644 resources/images/Cascade16.png create mode 100644 resources/images/TileHorizontal16.png create mode 100644 resources/images/TileVertical16.png create mode 100644 src/eva2/gui/AboutDialog.java create mode 100644 src/eva2/gui/JExtDesktopPaneToolBar.java diff --git a/resources/images/Cascade16.png b/resources/images/Cascade16.png new file mode 100644 index 0000000000000000000000000000000000000000..db4511144eb0c2b27a29dc9384d53844494cef52 GIT binary patch literal 535 zcmV+y0_gpTP)2T?Dsw(ZNx0Q=CPR>LM;8{u?eT7DUiRClSF>2RG-UwzMH6z4Kk#w3R06 zgK){+z3+bSeHWH2UR}ln&nqbW7MwBEU0F)U%tH6P(8&jdSxCyKJ)yy9L2!nhi-){a z$`@-3G?c_}ybo)qPjH=TxPT_$943j-IjWmPG$b&R=!b1raI&({K9Pl%K?w%`K_WbQ znHv*u8w!@-*gSuR=hh;7Vdx|hp^}yD$&!$=xj^~&v>iB34adv#G^4;GWf%++*}Z(s zi}oBTY|M^g>r5gOGqHX9PK`s4i1x~(LywlmX_V*)sHTmQgs4H7$_x^2uQPg^rcDo+ zB%mOAtfQ_jPQ>WR;;(RtL}+VT-RUq=yuQ3ZMO+L<7}GN|&`t=iR=FSAzs~iUM#ppt zE18UJBkQ`gqI$HtPGc&yclFdXoBP9HA`TfLzykpqME3CJO@Drr%RY(GB1u`6->fhj zf@*bzBA^aPtYVAA5HS8|qDgmw5y20SiR6yOlR1~%kSglWY$mIEhtDI%U@pu01-?@m5{AQFX z*|*NYHy^?`A)o|M@RVyY$?UVRC13R#Y&i#?|pA>6LkhUH~2Y8M=*S#ttS1Q(J-YnK#j1dP$J z!KV!B%P^|niP&eDl!#85X0@I+)ZDBTQBIQ0EwIn7!ie$368sgnjOll?Z zS1iLwe7xUx^2y|aIrT(z QOaK4?07*qoM6N<$g3@}odH?_b literal 0 HcmV?d00001 diff --git a/resources/images/TileVertical16.png b/resources/images/TileVertical16.png new file mode 100644 index 0000000000000000000000000000000000000000..053153fa0af817baa137271dca2fdd1756e11cce GIT binary patch literal 369 zcmV-%0gnEOP)|abD?{ON=oVES5RcO$fx1;p@CF5Tc32Qpxwm$DyEZ@AvUCT3zV9#OkeHL()0b1E* zAIi!Ai>pCLYKXd_EL*qJ$J=_R0F~@uwaen frameList = JEFrameRegister.getInstance().getFrameList(); - int frameIndex = 1; - for (JEFrame frame : frameList) { - - JMenuItem act = new JMenuItem(frameIndex + ". " + frame.getTitle()); - final JInternalFrame selectedFrame = frame; - - act.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - if (!selectedFrame.isFocusOwner()) { - //selectedFrame..setExtendedState(JFrame.NORMAL); - selectedFrame.setVisible(false); - // it seems to be quite a fuss to bring something to the front and actually mean it... - selectedFrame.setVisible(true); - // this seems useless - selectedFrame.toFront(); - // this seems useless too - selectedFrame.requestFocus(); - } - } - }); - - if (curMenu.getItemCount() >= maxWindowMenuLength) { - JExtMenu subMenu = new JExtMenu("&More..."); - curMenu.add(new JSeparator()); - curMenu.add(subMenu); - curMenu = subMenu; - } - curMenu.add(act); - - /* Next frame index */ - frameIndex++; - } - String[] commonPrefixes = JEFrameRegister.getInstance().getCommonPrefixes(10); - if (commonPrefixes.length > 0) { - menuWindow.add(new JSeparator()); - } - for (int i = 0; i < commonPrefixes.length; i++) { - final String prefix = commonPrefixes[i]; - JMenuItem act = new JMenuItem("Close all of " + prefix + "..."); - act.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent event) { - JEFrameRegister.getInstance().closeAllByPrefix(prefix); - } - }); - menuWindow.add(act); - } - - } - - public void menuCanceled(MenuEvent e) { - } - - public void menuDeselected(MenuEvent e) { - } - }); - menuSelHosts = new JExtMenu("&Select Hosts"); menuSelHosts.setToolTipText("Select a host for the server application"); menuSelHosts.add(actHost); @@ -851,9 +805,9 @@ public class EvAClient implements RemoteStateListener, Serializable { menuSelHosts.add(actKillHost); menuSelHosts.add(actKillAllHosts); - menuAbout = new JExtMenu("&About"); - menuAbout.add(actAbout); - menuAbout.add(actLicense); + menuHelp = new JExtMenu("&Help"); + menuHelp.add(actAbout); + menuHelp.add(actLicense); menuOptions = new JExtMenu("&Options"); menuOptions.add(menuSelHosts); @@ -864,11 +818,8 @@ public class EvAClient implements RemoteStateListener, Serializable { } menuBar.add(menuOptions); - menuBar.add(menuWindow); - menuBar.add(menuAbout); - menuBar.add(((JExtDesktopPane) desktopPane).getWindowMenu()); - + menuBar.add(menuHelp); } @@ -897,9 +848,9 @@ public class EvAClient implements RemoteStateListener, Serializable { comAdapter.setRunLocally(false); } if (selectedModule == null) { // show a dialog and ask for a module - String[] ModuleNameList = comAdapter.getModuleNameList(); - if (ModuleNameList == null) { - JOptionPane.showMessageDialog(configurationPane, "No modules available on " + comAdapter.getHostName(), EvAInfo.infoTitle, 1); + String[] moduleNameList = comAdapter.getModuleNameList(); + if (moduleNameList == null) { + JOptionPane.showMessageDialog(mainFrame, "No modules available on " + comAdapter.getHostName(), EvAInfo.infoTitle, 1); } else { String lastModule = null; @@ -911,16 +862,16 @@ public class EvAClient implements RemoteStateListener, Serializable { } if (lastModule == null) { - lastModule = ModuleNameList[0]; + lastModule = moduleNameList[0]; LOGGER.log(Level.INFO, "Defaulting to module: {0}", lastModule); } - selectedModule = (String) JOptionPane.showInputDialog(configurationPane, + selectedModule = (String) JOptionPane.showInputDialog(mainFrame, "Which module do you want \n to load on host: " + comAdapter.getHostName() + " ?", "Load optimization module on host", JOptionPane.QUESTION_MESSAGE, null, - ModuleNameList, + moduleNameList, lastModule); } } @@ -1028,13 +979,21 @@ public class EvAClient implements RemoteStateListener, Serializable { configurationPane.setVisible(false); configurationPane.removeAll(); - JComponent tree = null; + GridBagConstraints gbConstraints = new GridBagConstraints(); + + /* ToDo: Find a way to properly add the TreeView to the GOPanel */ if (withTreeView && (newModuleAdapter instanceof AbstractModuleAdapter)) { + JComponent tree = null; tree = getEvATreeView(frameMaker.getGOPanel(), "GOParameters", ((AbstractModuleAdapter) newModuleAdapter).getGOParameters()); - configurationPane.add(tree, BorderLayout.LINE_START); + gbConstraints.gridx = 0; + gbConstraints.gridy = 0; + gbConstraints.fill = GridBagConstraints.BOTH; + gbConstraints.weightx = 1.0; + gbConstraints.weighty = 1.0; + configurationPane.add(tree, gbConstraints); } - GridBagConstraints gbConstraints = new GridBagConstraints(); + gbConstraints.weightx = 1.0; gbConstraints.weighty = 0.0; gbConstraints.gridx = 0; @@ -1048,7 +1007,7 @@ public class EvAClient implements RemoteStateListener, Serializable { gbConstraints2.gridx = 0; gbConstraints2.gridy = 0; gbConstraints2.fill = GridBagConstraints.VERTICAL; - gbConstraints2.gridheight = GridBagConstraints.REMAINDER; + //gbConstraints2.gridheight = GridBagConstraints.REMAINDER; gbConstraints2.weighty = 1.0; configurationPane.add(moduleContainer, gbConstraints2); configurationPane.validate(); @@ -1126,20 +1085,10 @@ public class EvAClient implements RemoteStateListener, Serializable { } private void showAboutDialog() { - StringBuilder aboutMessage = new StringBuilder(); - aboutMessage.append(EvAInfo.productName); - aboutMessage.append(" - "); - aboutMessage.append(EvAInfo.productLongName); - aboutMessage.append("\nUniversity of T\u00FCbingen, T\u00FCbingen, Germany\nChair for Cognitive Systems\n"); - aboutMessage.append("Dr. M. Kronfeld, H. Planatscher, M. de Paly, Dr. A. Dr\u00E4ger,\n"); - aboutMessage.append("Dr. F. Streichert, Dr. H. Ulmer and Prof. Dr. A. Zell \nCoypright \u00A9 "); - aboutMessage.append(EvAInfo.copyrightYear); - aboutMessage.append("\nVersion "); - aboutMessage.append(EvAInfo.getVersion()); - aboutMessage.append("\nSee: "); - aboutMessage.append(EvAInfo.url); - - JOptionPane.showMessageDialog(configurationPane, aboutMessage, EvAInfo.infoTitle, 1); + AboutDialog aboutDialog = new AboutDialog(mainFrame); + aboutDialog.setLocationRelativeTo(mainFrame); + aboutDialog.setVisible(true); + aboutDialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); } private void showLicense() { @@ -1258,7 +1207,7 @@ final class SplashScreen extends Frame { JWindow splashWindow = new JWindow(this); BasicResourceLoader loader = BasicResourceLoader.instance(); byte[] bytes = loader.getBytesFromResourceLocation(imgLocation, true); - ImageIcon ii = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)); + ImageIcon ii = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)); JLabel splashLabel = new JLabel(ii); splashWindow.add(splashLabel); diff --git a/src/eva2/gui/AboutDialog.java b/src/eva2/gui/AboutDialog.java new file mode 100644 index 00000000..6acc512d --- /dev/null +++ b/src/eva2/gui/AboutDialog.java @@ -0,0 +1,108 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package eva2.gui; + +import com.sun.javaws.ui.JavawsSysRun; +import eva2.EvAInfo; +import eva2.tools.BasicResourceLoader; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.*; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; + +/** + * + * @author becker + */ +public class AboutDialog extends JDialog { + private JLabel imageLabel; + private JEditorPane infoEditorPane; + private JTextArea aboutTextArea; + + public AboutDialog(Frame parent) { + super(parent); + initComponents(); + } + + private void initComponents() { + setTitle("About"); + setLayout(new GridBagLayout()); + GridBagConstraints gbConstraints = new GridBagConstraints(); + + setSize(new Dimension(470, 600)); + setResizable(false); + + /* Load EvA2 Image */ + BasicResourceLoader loader = BasicResourceLoader.instance(); + byte[] bytes = loader.getBytesFromResourceLocation(eva2.EvAInfo.splashLocation, true); + ImageIcon imageIcon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)); + + /* Create a new JLabel with the image */ + imageLabel = new JLabel(imageIcon); + + gbConstraints.gridx = 0; + gbConstraints.gridy = 0; + gbConstraints.ipady = 10; + gbConstraints.insets = new Insets(10, 10, 0, 10); + gbConstraints.anchor = GridBagConstraints.PAGE_START; + add(imageLabel, gbConstraints); + + String infoMessage = "" + +"

EvA2 (an Evolutionary Algorithms framework, revised version 2) is a comprehensive heuristic optimization framework with emphasis on Evolutionary Algorithms implemented in Java™.

" ++"

For more information, please visit the EvA2 Homepage.

" ++""; + + infoEditorPane = new JEditorPane("text/html", infoMessage); + infoEditorPane.setEditable(false); + infoEditorPane.setOpaque(false); + infoEditorPane.addHyperlinkListener(new HyperlinkListener() { + + public void hyperlinkUpdate(HyperlinkEvent hle) { + if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) { + java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); + + if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) { + //java.net.URI uri = new java.net.URI(hle.getURL().toString()); + //desktop.browse(uri); + } + } + } + }); + gbConstraints.gridy++; + gbConstraints.anchor = GridBagConstraints.CENTER; + gbConstraints.fill = GridBagConstraints.HORIZONTAL; + gbConstraints.weightx = 1.0; + add(infoEditorPane, gbConstraints); + + aboutTextArea = new JTextArea(); + aboutTextArea.setEditable(false); + aboutTextArea.setRows(8); + + gbConstraints.gridy++; + gbConstraints.weighty = 1.0; + gbConstraints.fill = GridBagConstraints.BOTH; + add(new JScrollPane(aboutTextArea), gbConstraints); + + JButton closeButton = new JButton("Close"); + closeButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + AboutDialog.this.dispose(); + } + + }); + gbConstraints.gridy++; + gbConstraints.fill = GridBagConstraints.NONE; + gbConstraints.weighty = 0.0; + gbConstraints.insets = new Insets(10, 10, 10, 10); + add(closeButton, gbConstraints); + } +} diff --git a/src/eva2/gui/EvATabbedFrameMaker.java b/src/eva2/gui/EvATabbedFrameMaker.java index 3cfa16fd..a5c40d67 100644 --- a/src/eva2/gui/EvATabbedFrameMaker.java +++ b/src/eva2/gui/EvATabbedFrameMaker.java @@ -62,7 +62,7 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN tabbedPane = new JTabbedPane(); tabbedPane.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1)); - //tabbedPane.setUI(new eva2.gui.utils.CustomTabbedPaneUI()); + tabbedPane.setUI(new eva2.gui.utils.CustomTabbedPaneUI()); tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); diff --git a/src/eva2/gui/ExtDesktopManager.java b/src/eva2/gui/ExtDesktopManager.java index 1084673c..67b57b12 100644 --- a/src/eva2/gui/ExtDesktopManager.java +++ b/src/eva2/gui/ExtDesktopManager.java @@ -56,9 +56,9 @@ public class ExtDesktopManager extends DefaultDesktopManager { super.closeFrame(internalFrame); int index = ((Integer) internalFrame.getClientProperty(INDEX)).intValue() + WINDOW_LIST_START - 1; int i; - desktop.m_mnuWindow.remove(index); - for (i = index; i < Math.min(WINDOW_LIST_START + 9, desktop.m_mnuWindow.getItemCount()); i++) { - JMenuItem m = desktop.m_mnuWindow.getItem(i); + desktop.getWindowMenu().remove(index); + for (i = index; i < Math.min(WINDOW_LIST_START + 9, desktop.getWindowMenu().getItemCount()); i++) { + JMenuItem m = desktop.getWindowMenu().getItem(i); JInternalFrame frame = (JInternalFrame) m.getClientProperty(FRAME); frame.putClientProperty(INDEX, new Integer(((Integer) frame.getClientProperty(INDEX)).intValue() - 1)); int winIndex = i - WINDOW_LIST_START + 1; diff --git a/src/eva2/gui/JDocFrame.java b/src/eva2/gui/JDocFrame.java index 6742e532..0f6474eb 100644 --- a/src/eva2/gui/JDocFrame.java +++ b/src/eva2/gui/JDocFrame.java @@ -9,13 +9,10 @@ package eva2.gui; * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ * $Author: streiche $ */ -/*==========================================================================* - * IMPORTS - *==========================================================================*/ +import java.io.File; import javax.swing.JInternalFrame; import javax.swing.JMenu; import javax.swing.JToolBar; -import java.io.File; /** * */ diff --git a/src/eva2/gui/JExtDesktopPane.java b/src/eva2/gui/JExtDesktopPane.java index 0ce38a7d..8ea2be3e 100644 --- a/src/eva2/gui/JExtDesktopPane.java +++ b/src/eva2/gui/JExtDesktopPane.java @@ -1,14 +1,11 @@ package eva2.gui; /* - * Title: EvA2 - * Description: - * Copyright: Copyright (c) 2003 - * Company: University of Tuebingen, Computer Architecture - * @author Holger Ulmer, Felix Streichert, Hannes Planatscher - * @version: $Revision: 10 $ - * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ - * $Author: streiche $ + * Title: EvA2 Description: Copyright: Copyright (c) 2003 Company: University of Tuebingen, Computer + * Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher @version: $Revision: 10 $ + * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ $Author: streiche $ */ + +import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.Event; @@ -24,14 +21,12 @@ import javax.swing.*; */ public class JExtDesktopPane extends JDesktopPane { - private ActionListener m_actMenuFrame; - private ExtDesktopManager m_manager; - public JExtMenu m_mnuWindow; + private ActionListener actMenuFrame; + private ExtDesktopManager desktopManager; + private JExtMenu windowMenu; private ExtAction actWindowTileVert; private ExtAction actWindowTileHorz; private ExtAction actWindowOverlap; - private ExtAction actWindowArrangeIcons; - private ExtAction actWindowList; public final static int WINDOW_TILEVERT = 0; public final static int WINDOW_TILEHORZ = 1; public final static int WINDOW_OVERLAP = 2; @@ -44,76 +39,58 @@ public class JExtDesktopPane extends JDesktopPane { */ public JExtDesktopPane() { super(); - m_mnuWindow = new JExtMenu("&Windows"); - m_manager = new ExtDesktopManager(this); - setDesktopManager(m_manager); + + windowMenu = new JExtMenu("&Windows"); + desktopManager = new ExtDesktopManager(this); + setDesktopManager(desktopManager); - m_actMenuFrame = new ActionListener() { + actMenuFrame = new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (!(e.getSource() instanceof JMenuItem)) { + @Override + public void actionPerformed(final ActionEvent event) { + if (!(event.getSource() instanceof JMenuItem)) { return; } - JInternalFrame frame = (JInternalFrame) ((JMenuItem) e.getSource()).getClientProperty(ExtDesktopManager.FRAME); + JInternalFrame frame = (JInternalFrame) ((JMenuItem) event.getSource()).getClientProperty(ExtDesktopManager.FRAME); selectFrame(frame); } }; - m_mnuWindow.add(actWindowTileVert = new ExtAction("&Nebeneinander", "Ordnet die Fenster nebeneinander an") { + windowMenu.add(actWindowTileVert = new ExtAction("Tile &Vertically", "Tiles all windows vertically") { - public void actionPerformed(ActionEvent e) { + @Override + public void actionPerformed(final ActionEvent event) { tileWindows(SwingConstants.HORIZONTAL); } }); - m_mnuWindow.add(actWindowTileHorz = new ExtAction("&Untereinander", "Ordnet die Fenster untereinander an") { + windowMenu.add(actWindowTileHorz = new ExtAction("Tile &Horizontally", "Tiles all windows horizontically") { - public void actionPerformed(ActionEvent e) { + @Override + public void actionPerformed(final ActionEvent event) { tileWindows(SwingConstants.VERTICAL); } }); - m_mnuWindow.add(actWindowOverlap = new ExtAction("Ü&berlappend", "Ordnet die Fenster Überlappend an") { + windowMenu.add(actWindowOverlap = new ExtAction("&Cascade Windows", "Cascades all visible windows") { - public void actionPerformed(ActionEvent e) { + @Override + public void actionPerformed(final ActionEvent event) { overlapWindows(); } }); - m_mnuWindow.add(actWindowArrangeIcons = new ExtAction("&Symbole anordnen", "Ordnet die Symbole auf dem Desktop an") { - - public void actionPerformed(ActionEvent e) { - } - }); - - m_mnuWindow.add(actWindowList = new ExtAction("Fenster&liste...", "Zeigt eine Liste aller Fenster an", KeyStroke.getKeyStroke(KeyEvent.VK_0, Event.ALT_MASK)) { - - public void actionPerformed(ActionEvent e) { - Vector l = new Vector(); - JInternalFrame frames[] = getAllFrames(); - - for (int i = 0; i < frames.length; i++) { - l.add(frames[i].getTitle()); - } - - JList list = new JList(l); - list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - JScrollPane pane = new JScrollPane(list); - pane.setPreferredSize(new Dimension(pane.getPreferredSize().width, 150)); - - if (JOptionPane.showOptionDialog(JExtDesktopPane.this, pane, "Fenster auswählen", JOptionPane.OK_CANCEL_OPTION, - JOptionPane.PLAIN_MESSAGE, null, null, null) == JOptionPane.OK_OPTION) { - if (list.getSelectedIndex() != -1) { - selectFrame(frames[list.getSelectedIndex()]); - } - } - } - }); - - m_mnuWindow.addSeparator(); - m_manager.WINDOW_LIST_START = 6; + windowMenu.addSeparator(); + desktopManager.WINDOW_LIST_START = 4; } + /** + * Method to access the window actions. + * + * @deprecated + * @param action The desired action (use JExtDesktopPane constants). Default is null + * @return The ExtAction + */ public ExtAction getWindowAction(int action) { switch (action) { case WINDOW_TILEVERT: @@ -122,10 +99,6 @@ public class JExtDesktopPane extends JDesktopPane { return actWindowTileHorz; case WINDOW_OVERLAP: return actWindowOverlap; - case WINDOW_ARRANGEICONS: - return actWindowArrangeIcons; - case WINDOW_LIST: - return actWindowList; } return null; } @@ -264,41 +237,26 @@ public class JExtDesktopPane extends JDesktopPane { public void addImpl(Component comp, Object constraints, int index) { super.addImpl(comp, constraints, index); //System.out.println("JExtDesktopPane.addImpl"); - if (comp instanceof JDocFrame) { - JDocFrame f = (JDocFrame) comp; - int frameIndex = m_mnuWindow.getItemCount() - m_manager.WINDOW_LIST_START + 1; - if (f.getClientProperty(ExtDesktopManager.INDEX) != null) { + if (comp instanceof JInternalFrame) { + JInternalFrame docFrame = (JInternalFrame) comp; + int frameIndex = windowMenu.getItemCount() - desktopManager.WINDOW_LIST_START + 1; + if (docFrame.getClientProperty(ExtDesktopManager.INDEX) != null) { return; } - f.putClientProperty(ExtDesktopManager.INDEX, new Integer(frameIndex)); - JMenuItem m = new JMenuItem((frameIndex < 10 ? frameIndex + " " : "") + f.getTitle()); + docFrame.putClientProperty(ExtDesktopManager.INDEX, new Integer(frameIndex)); + JMenuItem m = new JMenuItem((frameIndex < 10 ? frameIndex + " " : "") + docFrame.getTitle()); if (frameIndex < 10) { m.setMnemonic((char) (0x30 + frameIndex)); m.setAccelerator(KeyStroke.getKeyStroke(0x30 + frameIndex, Event.ALT_MASK)); } - m.setToolTipText("Shows the window " + f.getTitle() + " an"); - m.putClientProperty(ExtDesktopManager.FRAME, f); - m.addActionListener(m_actMenuFrame); - m_mnuWindow.add(m); + m.setToolTipText("Shows the window " + docFrame.getTitle()); + m.putClientProperty(ExtDesktopManager.FRAME, docFrame); + m.addActionListener(actMenuFrame); + windowMenu.add(m); } -// if(comp instanceof Plot){ -// Plot f = (Plot)comp; -// int frameIndex = m_mnuWindow.getItemCount() - m_manager.WINDOW_LIST_START + 1; -// if(f.getClientProperty(ExtDesktopManager.INDEX) != null) return; -// f.putClientProperty(ExtDesktopManager.INDEX, new Integer(frameIndex)); -// JMenuItem m = new JMenuItem((frameIndex < 10 ? frameIndex + " " : "") + f.getTitle()); -// if(frameIndex < 10){ -// m.setMnemonic((char)(0x30 + frameIndex)); -// m.setAccelerator(KeyStroke.getKeyStroke(0x30 + frameIndex, Event.ALT_MASK)); -// } -// m.setToolTipText("Shows the window " + f.getTitle() + " an"); -// m.putClientProperty(ExtDesktopManager.FRAME, f); -// m.addActionListener(m_actMenuFrame); -// m_mnuWindow.add(m); -// } } public JMenu getWindowMenu() { - return m_mnuWindow; + return windowMenu; } } \ No newline at end of file diff --git a/src/eva2/gui/JExtDesktopPaneToolBar.java b/src/eva2/gui/JExtDesktopPaneToolBar.java new file mode 100644 index 00000000..2f48f59e --- /dev/null +++ b/src/eva2/gui/JExtDesktopPaneToolBar.java @@ -0,0 +1,63 @@ +package eva2.gui; + +import javax.swing.JToolBar; +import eva2.tools.ToolBoxGui; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JDesktopPane; +import javax.swing.SwingConstants; + +/** + * + * @author becker + */ +public class JExtDesktopPaneToolBar extends JToolBar { + + private JExtDesktopPane desktopPane; + + public JExtDesktopPaneToolBar(JExtDesktopPane desktopPane) { + this.desktopPane = desktopPane; + + initComponents(); + } + + private void initComponents() { + /* We don't want the ToolBar to be draggable */ + setFloatable(false); + + /* Add Buttons to tile the desktopPane */ + JButton verticalButton = ToolBoxGui.createIconifiedButton("resources/images/TileVertical16.png", "Tile vertically", false); + verticalButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + desktopPane.tileWindows(SwingConstants.VERTICAL); + } + + }); + add(verticalButton); + + JButton horizontalButton = ToolBoxGui.createIconifiedButton("resources/images/TileHorizontal16.png", "Tile horizontally", false); + horizontalButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + desktopPane.tileWindows(SwingConstants.HORIZONTAL); + } + + }); + add(horizontalButton); + + JButton cascadeButton = ToolBoxGui.createIconifiedButton("resources/images/Cascade16.png", "Cascade windows", false); + cascadeButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + desktopPane.overlapWindows(); + } + + }); + add(cascadeButton); + } +} diff --git a/src/eva2/gui/JTextoutputFrame.java b/src/eva2/gui/JTextoutputFrame.java index 271cf379..d39537f5 100644 --- a/src/eva2/gui/JTextoutputFrame.java +++ b/src/eva2/gui/JTextoutputFrame.java @@ -1,14 +1,10 @@ package eva2.gui; /* - * Title: EvA2 - * Description: - * Copyright: Copyright (c) 2003 - * Company: University of Tuebingen, Computer Architecture - * @author Holger Ulmer, Felix Streichert, Hannes Planatscher - * @version: $Revision: 255 $ - * $Date: 2007-11-15 14:58:12 +0100 (Thu, 15 Nov 2007) $ - * $Author: mkron $ + * Title: EvA2 Description: Copyright: Copyright (c) 2003 Company: University of Tuebingen, Computer + * Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher @version: $Revision: 255 + * $ $Date: 2007-11-15 14:58:12 +0100 (Thu, 15 Nov 2007) $ $Author: mkron $ */ + import eva2.EvAInfo; import eva2.server.go.tools.FileTools; import eva2.tools.BasicResourceLoader; @@ -26,156 +22,153 @@ import javax.swing.event.InternalFrameEvent; * */ public class JTextoutputFrame implements JTextoutputFrameInterface, ActionListener, Serializable { + private JMenuItem clearItem, saveItem; - public static boolean TRACE = false; protected String frameTitle = "undefined"; private transient JTextArea textArea = null; private final JInternalFrame frame; private JPopupMenu popup; - /** - * - */ - public JTextoutputFrame(String title) { - if (TRACE) System.out.println("JTextoutputFrame Constructor"); - frameTitle = title; - frame = new JEFrame(frameTitle); - textArea = null; - } - /** - * - */ - public void print(String text) { - //System.out.println("Print:"+Text); - if (textArea == null) { - createFrame(); - } - textArea.append(text); - textArea.repaint(); - } - public void println(String txt) { - print(txt+'\n'); - } + /** + * + */ + public JTextoutputFrame(String title) { + frameTitle = title; + frame = new JEFrame(frameTitle); + textArea = null; + } - public void setShow(boolean bShow) { - if (frame.isVisible() != bShow) { - if (frame.isVisible()) { - frame.dispose(); - textArea.setText(null); - } else { - if (textArea == null) createFrame(); - else frame.setVisible(true); - frame.setEnabled(true); - } - } - } + /** + * + */ + public void print(String text) { + if (textArea == null) { + createFrame(); + } + textArea.append(text); + textArea.repaint(); + } - /** - * - */ - private void createFrame() { - if (TRACE) System.out.println("JTextoutputFrame createFrame"); - textArea = new JTextArea(10,80); - textArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - textArea.setLineWrap(true); - textArea.setWrapStyleWord(true); - textArea.setEditable(false); - textArea.setCaretPosition(0); + public void println(String txt) { + print(txt + '\n'); + } - BasicResourceLoader loader = BasicResourceLoader.instance(); - byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true); - //frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes)); - - frame.addInternalFrameListener(new InternalFrameAdapter() { + public void setShow(boolean bShow) { + if (frame.isVisible() != bShow) { + if (frame.isVisible()) { + frame.dispose(); + textArea.setText(null); + } else { + if (textArea == null) { + createFrame(); + } else { + frame.setVisible(true); + } + frame.setEnabled(true); + } + } + } + + /** + * + */ + private void createFrame() { + textArea = new JTextArea(10, 80); + textArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + textArea.setLineWrap(true); + textArea.setWrapStyleWord(true); + textArea.setEditable(false); + textArea.setCaretPosition(0); + + BasicResourceLoader loader = BasicResourceLoader.instance(); + byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true); + + frame.addInternalFrameListener(new InternalFrameAdapter() { @Override - public void internalFrameClosing(InternalFrameEvent e) { - super.internalFrameClosing(e); + public void internalFrameClosing(final InternalFrameEvent event) { + super.internalFrameClosing(event); frame.dispose(); - frame.setEnabled(false); + frame.setEnabled(false); } - }); - frame.getContentPane().setLayout(new BorderLayout()); - //frame.getContentPane().add(new JScrollPane(m_TextArea), BorderLayout.CENTER); - final JScrollPane scrollpane = new JScrollPane(textArea); - frame.getContentPane().add(scrollpane, BorderLayout.CENTER); - scrollpane.getViewport().addChangeListener(new ChangeListener() { - private int lastHeight; - // - public void stateChanged(ChangeEvent e) { - JViewport viewport = (JViewport)e.getSource(); - int Height = viewport.getViewSize().height; - if (Height != lastHeight) { - lastHeight = Height; - int x = Height - viewport.getExtentSize().height; - viewport.setViewPosition(new Point(0, x)); - } - } - }); - makePopupMenu(); - frame.pack(); - frame.setSize(800, 400); - frame.setVisible(true); -// frame.setState(Frame.ICONIFIED); - } + }); + frame.getContentPane().setLayout(new BorderLayout()); + final JScrollPane scrollpane = new JScrollPane(textArea); + frame.getContentPane().add(scrollpane, BorderLayout.CENTER); + scrollpane.getViewport().addChangeListener(new ChangeListener() { + private int lastHeight; + // - void makePopupMenu() { - //Create the popup menu. - popup = new JPopupMenu(); - clearItem = new JMenuItem("Clear"); - clearItem.addActionListener(this); - popup.add(clearItem); - saveItem = new JMenuItem("Save as..."); - saveItem.addActionListener(this); - popup.add(saveItem); -// menuItem = new JMenuItem("Refine Multiruns"); -// menuItem.addActionListener(this); -// popup.add(menuItem); + public void stateChanged(ChangeEvent e) { + JViewport viewport = (JViewport) e.getSource(); + int Height = viewport.getViewSize().height; + if (Height != lastHeight) { + lastHeight = Height; + int x = Height - viewport.getExtentSize().height; + viewport.setViewPosition(new Point(0, x)); + } + } + }); + makePopupMenu(); + frame.pack(); + frame.setSize(800, 400); + frame.setVisible(true); + } - //Add listener to components that can bring up popup menus. - MouseListener popupListener = new PopupListener(popup); -// frame.addMouseListener(popupListener); - textArea.addMouseListener(popupListener); -// menuBar.addMouseListener(popupListener); + void makePopupMenu() { + //Create the popup menu. + popup = new JPopupMenu(); + clearItem = new JMenuItem("Clear"); + clearItem.addActionListener(this); + popup.add(clearItem); + saveItem = new JMenuItem("Save as..."); + saveItem.addActionListener(this); + popup.add(saveItem); + //Add listener to components that can bring up popup menus. + MouseListener popupListener = new PopupListener(popup); + textArea.addMouseListener(popupListener); + } - } - - public void actionPerformed(ActionEvent e) { - JMenuItem src = (JMenuItem)e.getSource(); - if (src == clearItem) { - textArea.setText(null); - } else if (src == saveItem) { - FileTools.saveObjectWithFileChooser(frame, textArea.getText()); + public void actionPerformed(ActionEvent e) { + JMenuItem src = (JMenuItem) e.getSource(); + if (src == clearItem) { + textArea.setText(null); + } else if (src == saveItem) { + FileTools.saveObjectWithFileChooser(frame, textArea.getText()); // File outfile = FileTools.writeString("TextOutput.txt", m_TextArea.getText()); - } else System.err.println("Unknown popup component (JTextoutputFrame)!"); - } + } else { + System.err.println("Unknown popup component (JTextoutputFrame)!"); + } + } } /** * A popup listener opening a popup menu on right clicks. - * + * * @author mkron */ class PopupListener extends MouseAdapter { - JPopupMenu popup; - public PopupListener(JPopupMenu pm) { - popup = pm; - } - public void mousePressed(MouseEvent e) { - maybeShowPopup(e); - } + JPopupMenu popup; - public void mouseReleased(MouseEvent e) { - maybeShowPopup(e); - } + public PopupListener(JPopupMenu pm) { + popup = pm; + } - private void maybeShowPopup(MouseEvent e) { - if (e.isPopupTrigger()) { - popup.show(e.getComponent(), - e.getX(), e.getY()); - } - } + public void mousePressed(MouseEvent e) { + maybeShowPopup(e); + } + + public void mouseReleased(MouseEvent e) { + maybeShowPopup(e); + } + + private void maybeShowPopup(MouseEvent e) { + if (e.isPopupTrigger()) { + popup.show(e.getComponent(), + e.getX(), e.getY()); + } + } } \ No newline at end of file diff --git a/src/eva2/gui/JTextoutputFrameInterface.java b/src/eva2/gui/JTextoutputFrameInterface.java index 4f72ac18..a640a124 100644 --- a/src/eva2/gui/JTextoutputFrameInterface.java +++ b/src/eva2/gui/JTextoutputFrameInterface.java @@ -12,15 +12,12 @@ import eva2.server.stat.InterfaceTextListener; * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ * $Author: streiche $ */ -/*==========================================================================* - * IMPORTS - *==========================================================================*/ -/*==========================================================================* -* INTERFACE DECLARATION -*==========================================================================*/ -/** - * - */ public interface JTextoutputFrameInterface extends InterfaceTextListener { - public void setShow(boolean bShow); + + /** + * Set the show property to define whether the Output Frame should be shown. + * + * @param bShow Whether the frame should be shown or not + */ + void setShow(boolean bShow); } \ No newline at end of file diff --git a/src/eva2/gui/TagEditor.java b/src/eva2/gui/TagEditor.java index 77f70261..e890de08 100644 --- a/src/eva2/gui/TagEditor.java +++ b/src/eva2/gui/TagEditor.java @@ -9,9 +9,6 @@ package eva2.gui; * $Date: 2006-12-18 16:32:23 +0100 (Mon, 18 Dec 2006) $ * $Author: marcekro $ */ -/*==========================================================================* - * IMPORTS - *==========================================================================*/ import java.awt.BorderLayout; import java.awt.Toolkit; @@ -26,9 +23,6 @@ import eva2.EvAInfo; import eva2.tools.BasicResourceLoader; import eva2.tools.SelectedTag; import eva2.tools.Tag; -/*==========================================================================* -* CLASS DECLARATION -*==========================================================================*/ /** * */ diff --git a/src/eva2/tools/ToolBoxGui.java b/src/eva2/tools/ToolBoxGui.java index 2b73416b..773fd756 100644 --- a/src/eva2/tools/ToolBoxGui.java +++ b/src/eva2/tools/ToolBoxGui.java @@ -64,8 +64,11 @@ public class ToolBoxGui { bytes = BasicResourceLoader.instance().getBytesFromResourceLocation(iconSrc, false); if (bytes == null) { newButton = new JButton(title); - } else { + } else if (withTitle) { newButton = new JButton(title, new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes))); + } else { + newButton = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes))); + newButton.setToolTipText(title); } return newButton; }