Added ToolBar to JExtDesktopPane and created new About window.
This commit is contained in:
Fabian Becker 2012-05-15 15:29:46 +00:00
parent d9b47eab9b
commit 0ee348e2b6
14 changed files with 426 additions and 364 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

View File

@ -1,21 +1,20 @@
package eva2.client;
/*
* Title: EvA2
* Title: EvA2
* Description: The main client class of the EvA framework.
* Copyright: Copyright (c) 2008
* Copyright: Copyright (c) 2008
* Company: University of Tuebingen, Computer
* Architecture
*
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
* @version: $Revision: 322 $ $Date: 2007-12-11 17:24:07 +0100 (Tue, 11 Dec 2007)$
* @version: $Revision: 322 $ $Date: 2007-12-11 17:24:07 +0100 (Tue, 11 Dec 2007)$
* $Author: mkron $
*/
import eva2.EvAInfo;
import eva2.gui.*;
import eva2.server.EvAServer;
import eva2.server.go.InterfaceGOParameters;
import eva2.server.go.strategies.GradientDescentAlgorithm;
import eva2.server.modules.AbstractModuleAdapter;
import eva2.server.modules.GOParameters;
import eva2.server.modules.GenericModuleAdapter;
@ -23,11 +22,14 @@ import eva2.server.modules.ModuleAdapter;
import eva2.server.stat.AbstractStatistics;
import eva2.server.stat.InterfaceStatisticsListener;
import eva2.server.stat.InterfaceStatisticsParameter;
import eva2.tools.*;
import eva2.tools.BasicResourceLoader;
import eva2.tools.EVAERROR;
import eva2.tools.ReflectPackage;
import eva2.tools.StringTools;
import eva2.tools.jproxy.RemoteStateListener;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.io.Serializable;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@ -49,9 +51,10 @@ public class EvAClient implements RemoteStateListener, Serializable {
* Generated serial version identifier.
*/
private static final long serialVersionUID = 8232856334379977970L;
private final int splashScreenTime = 1500;
private final int splashScreenTime = 2500;
private final int maxWindowMenuLength = 30;
private boolean clientInited = false;
private JExtDesktopPaneToolBar desktopToolBar;
private JDesktopPane desktopPane;
private JFrame mainFrame;
private JPanel configurationPane;
@ -60,10 +63,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
private EvAComAdapter comAdapter;
private transient JMenuBar menuBar;
private transient JExtMenu menuAbout;
private transient JExtMenu menuHelp;
private transient JExtMenu menuSelHosts;
private transient JExtMenu menuModule;
private transient JExtMenu menuWindow;
private transient JExtMenu menuOptions;
private transient JProgressBar progressBar;
@ -379,18 +381,35 @@ public class EvAClient implements RemoteStateListener, Serializable {
/* Set Look and Feel */
try {
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ex) {
LOGGER.log(Level.INFO, "Could not set Look&Feel", ex);
}
mainFrame = new JFrame(EvAInfo.productName + " Workbench");
/* Create main frame with GridBagLayout */
mainFrame = new JFrame(EvAInfo.productName);
mainFrame.setLayout(new GridBagLayout());
mainFrame.setMinimumSize(new Dimension(800, 600));
desktopPane = new JExtDesktopPane();
/* Creates the desktopPane for Plot/Text Output */
desktopPane = new JExtDesktopPane();
JEFrameRegister.getInstance().setDesktopPane(desktopPane);
horizontalSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);
/* Creates desktopPane ToolBar to show tiling buttons */
desktopToolBar = new JExtDesktopPaneToolBar((JExtDesktopPane) desktopPane);
/* Pane to hold ToolBar + DesktopPane */
JPanel desktopPanel = new JPanel(new GridBagLayout());
GridBagConstraints desktopConst = new GridBagConstraints();
desktopConst.gridx = 0;
desktopConst.gridy = 0;
desktopConst.fill = GridBagConstraints.HORIZONTAL;
desktopConst.weightx = 1.0;
desktopPanel.add(desktopToolBar, desktopConst);
desktopConst.gridy = 1;
desktopConst.fill = GridBagConstraints.BOTH;
desktopConst.weighty = 1.0;
desktopPanel.add(desktopPane, desktopConst);
BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
// TODO: use setIconImages (for better support of multiple icons when changing programs etc.)
@ -428,10 +447,14 @@ public class EvAClient implements RemoteStateListener, Serializable {
gbConstraints.gridheight = GridBagConstraints.RELATIVE;
mainFrame.add(configurationPane, gbConstraints);
/* SplitPane for desktopPane and loggingPanel */
horizontalSplit.setTopComponent(desktopPane);
/* SplitPane for desktopPanel and loggingPanel */
horizontalSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);
horizontalSplit.setTopComponent(desktopPanel);
horizontalSplit.setBottomComponent(logPanel);
horizontalSplit.setDividerLocation(0.25);
horizontalSplit.setDividerLocation(0.25);
horizontalSplit.setDividerSize(8);
horizontalSplit.setOneTouchExpandable(true);
horizontalSplit.setResizeWeight(1.0);
horizontalSplit.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1));
horizontalSplit.setContinuousLayout(true);
/* Add horizontal split pane at 1,1 */
@ -682,7 +705,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
}
};
actAbout = new ExtAction("&About...", "Product Information",
actAbout = new ExtAction("&About", "Product Information",
KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) {
@Override
@ -691,7 +714,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
showAboutDialog();
}
};
actLicense = new ExtAction("&License...", "View License",
actLicense = new ExtAction("&License", "View License",
KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) {
@Override
@ -774,75 +797,6 @@ public class EvAClient implements RemoteStateListener, Serializable {
menuModule = new JExtMenu("&Module");
menuModule.add(actModuleLoad);
menuWindow = new JExtMenu("&Window");
menuWindow.addMenuListener(new MenuListener() {
@Override
public void menuSelected(final MenuEvent event) {
menuWindow.removeAll();
JExtMenu curMenu = menuWindow;
List<JEFrame> 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);

View File

@ -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 = "<html><head></head><body>"
+"<p>EvA2 (an Evolutionary Algorithms framework, revised version 2) is a comprehensive heuristic optimization framework with emphasis on Evolutionary Algorithms implemented in Java™.</p>"
+"<p>For more information, please visit the <a href=\"http://www.cogsys.cs.uni-tuebingen.de/software/JavaEvA/\">EvA2 Homepage</a>.</p>"
+"</body></html>";
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);
}
}

View File

@ -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);

View File

@ -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;

View File

@ -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;
/**
*
*/

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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());
}
}
}

View File

@ -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);
}

View File

@ -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
*==========================================================================*/
/**
*
*/

View File

@ -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;
}