RK 060714 merging
authorrkoenig
Fri, 14 Jul 2006 10:46:22 +0200
changeset 339098d158c58c6c
parent 3389 ab40a40fbc09
child 3391 622bf7fa07ce
RK 060714 merging
src/java/isac/gui/WindowApplicationNEW.java
     1.1 --- a/src/java/isac/gui/WindowApplicationNEW.java	Fri Jul 14 10:44:43 2006 +0200
     1.2 +++ b/src/java/isac/gui/WindowApplicationNEW.java	Fri Jul 14 10:46:22 2006 +0200
     1.3 @@ -490,20 +490,15 @@
     1.4  		worksheetDesktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
     1.5  	}
     1.6  
     1.7 -    /**
     1.8 -     * to set the problem browser visible
     1.9 -     * 
    1.10 -     * @throws
    1.11 -     */
    1.12 -    private void setProblemBrowserVisible() {
    1.13 -    	problem_browser_frame_.setSize(
    1.14 -                IGuiConstants.PROBLEM_BROWSER_MIN_SIZE_X,
    1.15 -                IGuiConstants.PROBLEM_BROWSER_MIN_SIZE_Y);
    1.16 -    	problem_browser_frame_.setLocation(IGuiConstants.PROBLEM_BROWSER_POS_X,
    1.17 -                IGuiConstants.PROBLEM_BROWSER_POS_Y);
    1.18 -
    1.19 -        try {
    1.20 -            IBrowserDialog problem_browser_dialog = dialog_manager_.getProblemDialog();
    1.21 +	/**
    1.22 +	 * Get the Worksheet on top of the others; this may be below knowledge
    1.23 +	 * browsers and other components. Precondition: a Worksheet is a Component
    1.24 +	 * in a JInternalFrame in a JDesktopPane.
    1.25 +	 * 
    1.26 +	 * FIXME.WN050818 search along the gui's tree structure
    1.27 +	 * 
    1.28 +	 * @return The active Worksheet and null if no Worksheet is open
    1.29 +	 */
    1.30  
    1.31  	private Worksheet getActiveWorksheet() {
    1.32  		return last_active_worksheet_;
    1.33 @@ -519,20 +514,12 @@
    1.34  			return last_active_worksheet_.getWorksheetID();
    1.35  	}
    1.36  
    1.37 -    /**
    1.38 -     * creates a new problem browser frame, inserts it to the internal frames
    1.39 -     * and registeres it to the problem browser dialog
    1.40 -     */
    1.41 -    private void generateProblemBrowser() {
    1.42 -        try {
    1.43 -        	IBrowserDialog problem_browser_dialog = dialog_manager_.getProblemDialog();
    1.44 -            problem_browser_frame_ = new BrowserFrame(problem_browser_dialog,
    1.45 -            		"Problem Browser");
    1.46 -            
    1.47 -            addInternalFrame( problem_browser_frame_ );
    1.48 -            
    1.49 -            BrowserFrameRMINEW browser_frame_rmi = new BrowserFrameRMINEW(
    1.50 -                    problem_browser_frame_);
    1.51 +	private void buildSplitPane() {
    1.52 +		splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false);
    1.53 +		splitPane.setRightComponent(worksheetDesktopPane);
    1.54 +		splitPane.setOneTouchExpandable(true);
    1.55 +		splitPane.setDividerLocation(250);
    1.56 +	}
    1.57  
    1.58  	private Point screenCenter() {
    1.59  		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    1.60 @@ -548,42 +535,26 @@
    1.61  		frame.grabFocus();
    1.62  	}
    1.63  
    1.64 -    /**
    1.65 -     * to set the example browser visible
    1.66 -     */
    1.67 -    private void setExampleBrowserVisible() {
    1.68 -    	example_browser_frame_.setSize(
    1.69 -                IGuiConstants.PROBLEM_BROWSER_MIN_SIZE_X,
    1.70 -                IGuiConstants.PROBLEM_BROWSER_MIN_SIZE_Y);
    1.71 -    	example_browser_frame_.setLocation(IGuiConstants.PROBLEM_BROWSER_POS_X,
    1.72 -                IGuiConstants.PROBLEM_BROWSER_POS_Y);
    1.73 +	/**
    1.74 +	 * Get the content Panel.
    1.75 +	 * 
    1.76 +	 * @return ContentPanel
    1.77 +	 */
    1.78 +	public ContentPanel getContentPanel() {
    1.79 +		if (contentPanel == null) {
    1.80 +			this.contentPanel = new ContentPanel(session_id_);
    1.81 +		}
    1.82 +		return contentPanel;
    1.83 +	}
    1.84  
    1.85 -        try {
    1.86 -            IBrowserDialog example_browser_dialog = dialog_manager_.getExampleDialog();
    1.87 -            UserAction action = new UserAction(EUIElement.UI_BROWSER_GET_FOCUS);
    1.88 -            example_browser_dialog.notifyUserAction(action);
    1.89 -        } catch (RemoteException e) {
    1.90 -            e.printStackTrace();
    1.91 -        } catch (DialogProtocolException e) {
    1.92 -            e.printStackTrace();
    1.93 -        }
    1.94 -    }
    1.95 -
    1.96 -    /**
    1.97 -     * creates a new problem browser frame, inserts it to the internal frames
    1.98 -     * and registeres it to the example browser dialog
    1.99 -     */
   1.100 -    private void generateExampleBrowser() {
   1.101 -        try {
   1.102 -        	IBrowserDialog example_browser_dialog = dialog_manager_.getExampleDialog();
   1.103 -            
   1.104 -        	example_browser_frame_ = new BrowserFrame(example_browser_dialog,
   1.105 -            		"Example Browser");
   1.106 -            
   1.107 -            addInternalFrame( example_browser_frame_ );
   1.108 -            
   1.109 -            BrowserFrameRMINEW browser_frame_rmi = new BrowserFrameRMINEW(
   1.110 -                    example_browser_frame_);
   1.111 +	/**
   1.112 +	 * Get the currently used locale.
   1.113 +	 * 
   1.114 +	 * @return currently used locale.
   1.115 +	 */
   1.116 +	public Locale getLocale() {
   1.117 +		return locale;
   1.118 +	}
   1.119  
   1.120  	/**
   1.121  	 * Show the content frame which includes a window that shows the content of
   1.122 @@ -606,19 +577,57 @@
   1.123  
   1.124  	// ----------ActionListener----------------------------------------
   1.125  
   1.126 -    /**
   1.127 -     * to set the method browser visible
   1.128 -     * 
   1.129 -     */
   1.130 -    private void setMethodBrowserVisible() {
   1.131 -    	method_browser_frame_.setSize(
   1.132 -                IGuiConstants.METHOD_BROWSER_MIN_SIZE_X,
   1.133 -                IGuiConstants.METHOD_BROWSER_MIN_SIZE_Y);
   1.134 -    	method_browser_frame_.setLocation(IGuiConstants.METHOD_BROWSER_POS_X,
   1.135 -                IGuiConstants.METHOD_BROWSER_POS_Y);
   1.136 -
   1.137 -        try {
   1.138 -            IBrowserDialog method_browser_dialog = dialog_manager_.getMethodDialog();
   1.139 +	public void actionPerformed(ActionEvent e) {
   1.140 +		if (dynamic_buttons_.containsValue(e.getSource())) {
   1.141 +			System.out.println("----------------");
   1.142 +			System.out.println(getActiveWorksheet());
   1.143 +			getActiveWorksheet().notifyUserAction(
   1.144 +					new UserAction(((IUIAction) dynamic_actions_.get(e
   1.145 +							.getSource())).getAction()));
   1.146 +		}
   1.147 +		if (e.getSource() == problemBrowserButton) {
   1.148 +			if (problem_browser_framain_frame_ == null) {
   1.149 +				generateProblemBrowser();
   1.150 +				setProblemBrowserVisible();
   1.151 +			} else if (!problem_browser_framain_frame_.isVisible()) {
   1.152 +				setProblemBrowserVisible();
   1.153 +			}
   1.154 +		} else if (e.getSource() == newWorksheetButton) {
   1.155 +			// JOptionPane.showMessageDialog(this, "not yet implemented");
   1.156 +			// WN050504...
   1.157 +			try {
   1.158 +				this.openNewWorksheet(this, new Formalization(), "",
   1.159 +						IWorksheetDialog.STARTFROM_NEW);
   1.160 +			} catch (RemoteException e1) {
   1.161 +				e1.printStackTrace();
   1.162 +			}
   1.163 +		} else if (e.getSource() == exampleBrowserButton) {
   1.164 +			if (example_browser_framain_frame_ == null) {
   1.165 +				generateExampleBrowser();
   1.166 +				setExampleBrowserVisible();
   1.167 +			} else if (!example_browser_framain_frame_.isVisible()) {
   1.168 +				setExampleBrowserVisible();
   1.169 +			}
   1.170 +		} else if (e.getSource() == methodBrowserButton) {
   1.171 +			if (method_browser_framain_frame_ == null) {
   1.172 +				generateMethodBrowser();
   1.173 +				setMethodBrowserVisible();
   1.174 +			} else if (!method_browser_framain_frame_.isVisible()) {
   1.175 +				setMethodBrowserVisible();
   1.176 +			}
   1.177 +		} else if (e.getSource() == theoryBrowserButton) {
   1.178 +			if (theory_browser_framain_frame_ == null) {
   1.179 +				generateTheoryBrowser();
   1.180 +				setTheoryBrowserVisible();
   1.181 +			} else if (!theory_browser_framain_frame_.isVisible()) {
   1.182 +				setTheoryBrowserVisible();
   1.183 +			}
   1.184 +		} else if (e.getSource() == tacticsButton) {
   1.185 +			JOptionPane.showMessageDialog(main_frame_, "not yet implemented");
   1.186 +		} else { // invalid source
   1.187 +			logger.error("invalid source for ActionEvent");
   1.188 +		}
   1.189 +	}
   1.190  
   1.191  	/**
   1.192  	 * to set the problem browser visible
   1.193 @@ -631,27 +640,8 @@
   1.194  			IBrowserDialog problem_browser_dialog = dialog_manager_
   1.195  					.getProblemDialog();
   1.196  
   1.197 -        } catch (RemoteException e) {
   1.198 -            e.printStackTrace();
   1.199 -        } catch (DialogProtocolException e) {
   1.200 -            e.printStackTrace();
   1.201 -        }
   1.202 -    }
   1.203 -    
   1.204 -    /**
   1.205 -     * creates a new method browser frame, inserts it to the internal frames
   1.206 -     * and registeres it to the method browser dialog
   1.207 -     */
   1.208 -    private void generateMethodBrowser() {
   1.209 -        try {
   1.210 -        	IBrowserDialog method_browser_dialog = dialog_manager_.getMethodDialog();
   1.211 -            method_browser_frame_ = new BrowserFrame(method_browser_dialog,
   1.212 -            		"Method Browser");
   1.213 -            
   1.214 -            addInternalFrame( method_browser_frame_ );
   1.215 -            
   1.216 -            BrowserFrameRMINEW browser_frame_rmi = new BrowserFrameRMINEW(
   1.217 -                    method_browser_frame_);
   1.218 +			UserAction action = new UserAction(EUIElement.UI_BROWSER_GET_FOCUS);
   1.219 +			problem_browser_dialog.notifyUserAction(action);
   1.220  
   1.221  		} catch (RemoteException e) {
   1.222  			e.printStackTrace();
   1.223 @@ -660,49 +650,26 @@
   1.224  		}
   1.225  	}
   1.226  
   1.227 -        } catch (RemoteException remote_exception) {
   1.228 -            remote_exception.printStackTrace();
   1.229 -        }
   1.230 -    }
   1.231 -    
   1.232 -    /**
   1.233 -     * to set the method browser visible
   1.234 -     * 
   1.235 -     */
   1.236 -    private void setTheoryBrowserVisible() {
   1.237 -    	theory_browser_frame_.setSize(
   1.238 -                IGuiConstants.THEORY_BROWSER_MIN_SIZE_X,
   1.239 -                IGuiConstants.THEORY_BROWSER_MIN_SIZE_Y);
   1.240 -    	theory_browser_frame_.setLocation(IGuiConstants.THEORY_BROWSER_POS_X,
   1.241 -                IGuiConstants.THEORY_BROWSER_POS_Y);
   1.242 +	/**
   1.243 +	 * creates a new problem browser frame, inserts it to the internal frames
   1.244 +	 * and registeres it to the problem browser dialog
   1.245 +	 */
   1.246 +	private void generateProblemBrowser() {
   1.247 +		try {
   1.248 +			IBrowserDialog problem_browser_dialog = dialog_manager_
   1.249 +					.getProblemDialog();
   1.250 +			problem_browser_framain_frame_ = new BrowserFrame(
   1.251 +					problem_browser_dialog, "Problem Browser");
   1.252 +			BrowserFrameRMINEW browser_framain_frame_rmi = new BrowserFrameRMINEW(
   1.253 +					problem_browser_framain_frame_);
   1.254  
   1.255 -        try {
   1.256 -            IBrowserDialog theory_browser_dialog = dialog_manager_.getTheoryDialog();
   1.257 +			problem_browser_dialog
   1.258 +					.registerBrowserFrame(browser_framain_frame_rmi);
   1.259  
   1.260 -             UserAction action = new UserAction(EUIElement.UI_BROWSER_GET_FOCUS);
   1.261 -             theory_browser_dialog.notifyUserAction(action);
   1.262 -
   1.263 -        } catch (RemoteException e) {
   1.264 -            e.printStackTrace();
   1.265 -        } catch (DialogProtocolException e) {
   1.266 -            e.printStackTrace();
   1.267 -        }
   1.268 -    }
   1.269 -    
   1.270 -    /**
   1.271 -     * creates a new theory browser frame, inserts it to the internal frames
   1.272 -     * and registeres it to the theory browser dialog
   1.273 -     */
   1.274 -    private void generateTheoryBrowser() {
   1.275 -        try {
   1.276 -        	IBrowserDialog theory_browser_dialog = dialog_manager_.getTheoryDialog();
   1.277 -            theory_browser_frame_ = new BrowserFrame(theory_browser_dialog,
   1.278 -            		"Theory Browser");
   1.279 -            
   1.280 -            addInternalFrame( theory_browser_frame_ );
   1.281 -            
   1.282 -            BrowserFrameRMINEW browser_frame_rmi = new BrowserFrameRMINEW(
   1.283 -                    theory_browser_frame_);
   1.284 +		} catch (RemoteException remote_exception) {
   1.285 +			remote_exception.printStackTrace();
   1.286 +		}
   1.287 +	}
   1.288  
   1.289  	/**
   1.290  	 * to set the example browser visible