1.1 --- a/src/java/isac/gui/WindowApplication.java Sat Aug 20 21:20:16 2005 +0200
1.2 +++ b/src/java/isac/gui/WindowApplication.java Sun Aug 21 13:53:55 2005 +0200
1.3 @@ -72,6 +72,8 @@
1.4 // private JInternalFrame tryRefineFrame;
1.5
1.6 private JInternalFrame activeFrame;
1.7 +
1.8 + private Worksheet last_active_worksheet_;
1.9
1.10 /** login dialoge */
1.11 private LoginScreen loginScreen;
1.12 @@ -403,10 +405,37 @@
1.13 internalFrame.pack();
1.14 internalFrame.setVisible(true);
1.15 this.addInternalFrame(internalFrame);
1.16 -
1.17 }
1.18
1.19 - private JInternalFrame createInternalFrame(String title, boolean resizable,
1.20 + /**
1.21 + * FIXME getWorksheetOutofJInternalFrame
1.22 + * This is a rally big hack within isac and this method should not be necessary!!!
1.23 + * It returns the Worksheet within a weird structure of java container objects.
1.24 + *
1.25 + * If you want to use this funktion be shure what you do.
1.26 + *
1.27 + * @author Johannes Loinig,
1.28 + * @param internalFrame which holds the worksheet
1.29 + * @return Worksheet
1.30 + */
1.31 + private Worksheet getWorksheetOutofJInternalFrame(JInternalFrame internalFrame) {
1.32 + try {
1.33 + if(internalFrame.getTitle().equals("Worksheet") == false) {
1.34 + throw new ClassCastException();
1.35 + }
1.36 + return (Worksheet) ((JInternalFrame)((JDesktopPane)internalFrame.getContentPane().getComponent(0)).getComponent(0)).getContentPane().getComponent(0);
1.37 + } catch (ClassCastException class_cast_exception) {
1.38 + System.out.println("If you can read this something goes really wrong within a "+
1.39 + "big hack in ISAC. Maybe somewon has changed the internal structore "+
1.40 + "near the Worksheet GUI. Check this out!! The WindowApplication will be "+
1.41 + "terminated now!!!");
1.42 + class_cast_exception.printStackTrace();
1.43 + System.exit(1);
1.44 + return null;
1.45 + }
1.46 + }
1.47 +
1.48 + private JInternalFrame createInternalFrame(String title, boolean resizable,
1.49 boolean closable, boolean maximizable, boolean iconifiable) {
1.50 JInternalFrame internalFrame = new JInternalFrame(title, resizable,
1.51 closable, maximizable, iconifiable);
1.52 @@ -422,6 +451,8 @@
1.53 public void activateFrame(JInternalFrame jif) {
1.54 super.activateFrame(jif);
1.55 activeFrame = jif;
1.56 + if(jif.getTitle().equals("Worksheet"))
1.57 + last_active_worksheet_ = getWorksheetOutofJInternalFrame(jif);
1.58 }
1.59 });
1.60 // "ghost frame" dragging; very fast but weired for some user
1.61 @@ -437,39 +468,41 @@
1.62 *
1.63 * @return The active Worksheet and null if no Worksheet is open
1.64 */
1.65 - public Worksheet getActiveWorksheet() {
1.66 - Component comp;
1.67 - if (activeFrame != null) {
1.68 - JDesktopPane pane = ((JDesktopPane) activeFrame.getContentPane()
1.69 - .getComponent(0));
1.70 - for (int i = 0; i < pane.getComponentCount(); i++) {
1.71 - try {
1.72 - JInternalFrame frame = (JInternalFrame) pane
1.73 - .getComponent(i);
1.74 - for (int j = 0; j < frame.getComponentCount(); j++) {
1.75 - comp = frame.getContentPane().getComponent(j);
1.76 - if (comp instanceof Worksheet) {
1.77 - return (Worksheet) comp;
1.78 - }
1.79 - }
1.80 - } catch (ClassCastException e) {
1.81 - }
1.82 - }
1.83 - }
1.84 + private Worksheet getActiveWorksheet() {
1.85 + return last_active_worksheet_;
1.86 +// Component comp;
1.87 +// if (activeFrame != null) {
1.88 +// System.out.println(activeFrame);
1.89 +// JDesktopPane pane = ((JDesktopPane) activeFrame.getContentPane()
1.90 +// .getComponent(0));
1.91 +// for (int i = 0; i < pane.getComponentCount(); i++) {
1.92 +// try {
1.93 +// JInternalFrame frame = (JInternalFrame) pane
1.94 +// .getComponent(i);
1.95 +// for (int j = 0; j < frame.getComponentCount(); j++) {
1.96 +// comp = frame.getContentPane().getComponent(j);
1.97 +// if (comp instanceof Worksheet) {
1.98 +// return (Worksheet) comp;
1.99 +// }
1.100 +// }
1.101 +// } catch (ClassCastException e) {
1.102 +// }
1.103 +// }
1.104 +// }
1.105 +// return null;
1.106 // ((JInternalFrame) ((JDesktopPane) activeFrame.getContentPane()
1.107 // .getComponent(0)).getComponent(0)).getContentPane()
1.108 // .getComponent(0);
1.109 - return null;
1.110 }
1.111
1.112 /**
1.113 * @return the id of the topmost Worksheet or null if there is none.
1.114 */
1.115 public String getActiveWSDID() {
1.116 - if (getActiveWorksheet() == null)
1.117 + if (last_active_worksheet_ == null)
1.118 return null;
1.119 else
1.120 - return getActiveWorksheet().getWorksheetID();
1.121 + return last_active_worksheet_.getWorksheetID();
1.122 }
1.123
1.124 private void buildSplitPane() {