Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 620 → Rev 621

/sun/xmleditor/trunk/src/gui/GUI.java
4,10 → 4,10
* Coded by: Group 5, software practice summer 2003
* University of Bielefeld, Germany
*
* @version $Revision: 1.71 $
* @version $Revision: 1.72 $
*
* Last modification: $Date: 2003/07/18 13:57:19 $
* $Id: GUI.java,v 1.71 2003/07/18 13:57:19 cstollen Exp $
* Last modification: $Date: 2003/07/18 14:07:02 $
* $Id: GUI.java,v 1.72 2003/07/18 14:07:02 cstollen Exp $
*/
 
package src.gui;
47,10 → 47,10
/**
* @author group 5
*
* @version $Revision: 1.71 $ Last modification: $Date: 2003/07/18 13:57:19 $
* @version $Revision: 1.72 $ Last modification: $Date: 2003/07/18 14:07:02 $
*/
public class GUI
extends JFrame implements GuiInterface,WindowListener { // implements ActionListener, ComponentListener, WindowListener
extends JFrame implements GuiInterface,WindowListener {
 
//added 11/07/03 Sascha W.; testing with plugins - generate plugin-dependend menu
61,11 → 61,11
private JMenuItem exit;
private JMenuItem open;
/* Added 230603 S. McSporran -> Menu buttons for save options. */
/* Menu buttons for save options. */
private JMenuItem save;
private JMenuItem saveAs;
/* Added 100703 S. McSporran -> Menu buttons for validation options. */
/* Menu buttons for validation and grammar setting functions. */
private JMenuItem validate;
private JMenuItem setNewDTD;
private JMenuItem setNewSchema;
136,7 → 136,7
splitter.setTopComponent(pluginPanel);
splitter.setDividerLocation(400);
splitter.setOneTouchExpandable(true);
//added 14.07.03 Sascha W. for better display
 
splitter.setContinuousLayout(true);
splitter.setResizeWeight(1.0); //so the logPanel holds its height
 
171,24 → 171,31
}
 
/**
* creates the file menu
* <code>createFileMenu</code> creates the program's standard menu for file
* operations like 'load' or 'save'.
*
* @return The <code>JMenu</code> object that represents the created menu.
*
* author Group 5
*
* Last revision: 18-Jul-2003
*/
private JMenu createFileMenu()
{
private JMenu createFileMenu() {
 
JMenu file = new JMenu("File");
open = new JMenuItem("Open XML file");
/* Added 080703 S. McSporran -> Shortkey for open function. */
/* Shortkey for open function. */
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK));
/* Added 030703 S. McSporran -> Help text for open function. */
/* Help text for open function. */
open.setToolTipText("click to open a file");
open.addActionListener(docManager);
file.add(open);
neweeDoc = new JMenuItem("New document");
/* Added 040703 S. McSporran -> Help text for new document function. */
/* Help text for new document function. */
neweeDoc.setToolTipText("click to create a new document");
/* Added 080703 S. McSporran -> Shortkey for open function. */
/* Shortkey for open function. */
neweeDoc.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK));
neweeDoc.addActionListener(docManager);
file.add(neweeDoc);
195,19 → 202,19
file.addSeparator();
 
/* Added 230603 S. McSporran -> Button for save option. */
/* Button for save option. */
save = new JMenuItem("Save document");
/* Added 080703 S. McSporran -> Help text for save function. */
/* Help text for save function. */
save.setToolTipText("click to save the actual document");
/* Added 080703 S. McSporran -> Shortkey for save function. */
/* Shortkey for save function. */
save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, Event.CTRL_MASK));
save.addActionListener(docManager);
file.add(save);
saveAs = new JMenuItem("Save document as");
/* Added 080703 S. McSporran -> Help text for save as ... function. */
/* Help text for save as ... function. */
saveAs.setToolTipText("click to save the actual document as ...");
/* Added 080703 S. McSporran -> Shortkey for save as ... function. */
/* Shortkey for save as ... function. */
saveAs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK));
saveAs.addActionListener(docManager);
file.add(saveAs);
215,13 → 222,11
file.addSeparator();
 
exit = new JMenuItem("Exit");
/* Added 030703 S. McSporran -> Help text for exit function. */
/* Help text for exit function. */
exit.setToolTipText("click to leave the program");
exit.addActionListener(otherGUIListener);
file.add(exit);
 
//TODO complete Menu
 
return file;
}
 
236,8 → 241,8
*
* Last Revision: 15-Jul-2003 by Sascha W.
*/
private JMenu createPluginMenu()
{
private JMenu createPluginMenu() {
pluginMenu = new JMenu("plugin");
/* menu doesn't provide any functions, so disable it */
pluginMenu.setEnabled(false);
246,20 → 251,20
// TODO JavaDoc-comments
private JMenu createDocumentMenu()
{
private JMenu createDocumentMenu() {
JMenu document = new JMenu("Document");
validate = new JMenuItem("Validate document");
/* Added 030703 S. McSporran -> Help text for validate function. */
/* Help text for validate function. */
validate.setToolTipText("click to validate the active document");
/* Added 080703 S. McSporran -> Shortkey for validation function. */
/* Shortkey for validation function. */
validate.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK));
/* Register validation button events with docManager. */
validate.addActionListener(docManager);
document.add(validate);
/* Added 100703 S. McSporran -> Menu item for changing a document's DTD. */
/* Menu item for changing a document's DTD. */
setNewDTD = new JMenuItem("Set DTD");
/* Help text for 'Set DTD' function. */
setNewDTD.setToolTipText("click to change the document's DTD");
267,7 → 272,7
setNewDTD.addActionListener(docManager);
document.add(setNewDTD);
 
/* Added 140703 S. McSporran -> Menu item for changing a document's schema. */
/* Menu item for changing a document's schema. */
setNewSchema = new JMenuItem("Set XML schema");
/* Help text for 'Set XML schema' function. */
setNewSchema.setToolTipText("click to change the document's XML schema");
276,9 → 281,9
document.add(setNewSchema);
closeActDoc = new JMenuItem("Close active document");
/* Added 070703 S. McSporran -> Help text for close document. */
/* Help text for close document. */
closeActDoc.setToolTipText("click to close the active document");
/* Added 080703 S. McSporran -> Shortkey for close active document function. */
/* Shortkey for close active document function. */
closeActDoc.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK));
/* Register close active document button events with docManager. */
closeActDoc.addActionListener(docManager);
307,7 → 312,6
}
// ==============================================================================
/**
* <code>MakeMenu</code> makes the menu bar.
*/
318,9 → 322,7
myMenuBar.add(createDocumentMenu());
myMenuBar.add(createViewMenu());
myMenuBar.add(createPluginMenu());
// remove it in finale version =================================================
myMenuBar.add(createTestMenu());
// ==============================================================================
setJMenuBar(myMenuBar);
show();
}
340,19 → 342,16
* author Sascha Walkenhorst
*/
public void setTitleFileName(String fileName) {
setTitle("XML Editor" + " - File: " + fileName);
}
public void setTreeVisible(boolean bool)
{
public void setTreeVisible(boolean bool) {
guiTree.setVisible(bool);
}
 
//= Test Menu = remove it in finale version ===================================
// @author Y.Klassen, V.Zudova
 
private JMenu createTestMenu()
{
private JMenu createTestMenu() {
JMenu testMenu = new JMenu("Test");
testMenu.add(createStatusPanelTestMenu());
testMenu.add(createLogPanelTestMenu());
467,44 → 466,42
}
);
 
item = menu.add("Add Error Message");
item.addActionListener(new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
logPanel.log(LogPanel.TYPE_ERROR,
item = menu.add("Add Error Message");
item.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
logPanel.log(LogPanel.TYPE_ERROR,
(new java.util.Date()).toString());
}
}
);
 
/* added 030703 -> Test for warning message. */
item = menu.add("Add Warning Message");
item.addActionListener(new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
logPanel.log(LogPanel.TYPE_WARNING,
(new java.util.Date()).toString());
item.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
logPanel.log(LogPanel.TYPE_WARNING, (new java.util.Date()).toString());
}
}
);
}
);
 
item = menu.add("Clear");
item.addActionListener(new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
logPanel.clear();
}
item = menu.add("Clear");
item.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
logPanel.clear();
}
}
);
);
 
return menu;
}
 
private JMenu createImagePluginTestMenu()
{
private JMenu createImagePluginTestMenu() {
JMenu menu = new JMenu("Image Plugin");
JMenuItem item;
 
520,50 → 517,59
return menu;
}
 
//==========================================================================================
 
/**
* This method sets the links to the <code>ActionListener</code>s
* of the existing classes.
*
* author hjokusch
*/
public void setInterfaces(ActionListener otherGuiThings,
/**
* This method sets the links to the <code>ActionListener</code>s
* of the existing classes.
*
* author hjokusch
*/
public void setInterfaces(ActionListener otherGuiThings,
ActionListener duocManager, ActionListener updateViewListenerParam,
ChangeListener chList,DocumentManagerInterface docManInt /*,ActionListener validator*/)
{
ChangeListener chList,DocumentManagerInterface docManInt) {
otherGUIListener= otherGuiThings;
docManager= duocManager;
updateViewListener = updateViewListenerParam;
docManagerCL = chList;
docMaster= docManInt;
//validatorListener= validator;
makeMenu();
}
 
//===========================================================================================
 
// TODO JavaDoc-comments
public boolean quitConfirmed()
{
/**
* <code>quitConfirmed</code> asks the user if he/she wants to leave the program.
*
* @return A <code>boolean</code> value indicating if the exit procedure has been confirmed.
* <code>true<code> if user confirms, <code>false<code> otherwise.
*
* author Group 5
*
* Last revision: 18-Jul-2003 by S. McSporran
*/
private boolean quitConfirmed() {
JFrame frame = new JFrame();
/* Create the button labels for the dialog. */
String s1 = "Quit";
String s2 = "Cancel";
Object[] options = {s1, s2};
/* Show the dialog with 'Quit' and 'Cancel' text instead of 'yes' and 'no'. */
int n = JOptionPane.showOptionDialog(frame,
"Do you really want to quit?",
"Quit Confirmation",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
s1);
if (n == JOptionPane.YES_OPTION)
{
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
null, options, s1);
/* Return 'true' if the user clicked 'Quit'. */
if (n == JOptionPane.YES_OPTION) {
return true;
}
else
{
/* Return 'false' if the user clicked 'Cancel' or closed the dialog. */
else {
return false;
}
}
595,7 → 601,7
}
/**
* Returns the current file.
* Returns the name of file currently opened.
*
* @return The current file.
*/
630,7 → 636,6
return pluginTabbedPanel;
}
 
 
/**
* Sets the panel object the plugins will use to draw their content.
*
642,8 → 647,7
 
pluginTabbedPanel.setComponentAt(pluginTabbedPanel.getSelectedIndex(), newPanel);
}
/**
* Sets the menu object the plugins will need for user interactions. This method
* provides own menus of plugins. The <code>JMenu</code> must be created in the
679,7 → 683,7
public int getDivider() {
return splitterMain.getDividerLocation();
}
/**
* Sets the position of the divider.
*/
687,52 → 691,6
splitterMain.setDividerLocation(position);
}
 
//==============================================================================
// methods required by ComponentListener:
/* //removed 240603 Sascha W. cause no need <-> new controller
public void componentMoved(ComponentEvent e) {
//repaint();
}
 
//Sascha Walkenhorst wrote:
// it should be nice to see how the properties of the components change
// if the window is resized, but it doesn't work with "repaint"... (?)
public void componentResized(ComponentEvent e) {
//repaint();
}
 
public void componentHidden(ComponentEvent e) {}
 
public void componentShown(ComponentEvent e) {}
*/
 
//==============================================================================
// methods required by ActionListener:
/* //removed 240603 Sascha W. cause no need <-> new controller
public void actionPerformed(ActionEvent event)
{
// exit
if (event.getSource()==exit)
{
}
 
// open file
if (event.getSource() == open)
{
}
 
/* added 230603 S. McSporran */
/* if (event.getSource() == save) {
ActionEvent ownEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
"GUI selection: save document");
}
}
*/
 
//==============================================================================
// methods required by WindowListener:
 
/**
* windowClosing takes <code>WindowEvent</code>s and starts the
* appropiate actions.