001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014: //
015: //All Rights Reserved.
016: package org.columba.mail.gui.frame.util;
017:
018: import javax.swing.JComponent;
019: import javax.swing.JSplitPane;
020:
021: public class SplitPane extends JSplitPane {
022: public JSplitPane splitPane = new JSplitPane();
023: JComponent header;
024: JComponent message;
025: JComponent attachment;
026: boolean hide = false;
027: int last = 0;
028: int lastAttach = 0;
029:
030: public SplitPane() {
031: super ();
032: }
033:
034: public SplitPane(JComponent header, JComponent message,
035: JComponent attachment) {
036: super ();
037: this .header = header;
038: this .message = message;
039: this .attachment = attachment;
040:
041: setBorder(null);
042: splitPane.setBorder(null);
043:
044: //splitPane.setDividerSize(1);
045: //setDividerSize(5);
046: splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
047: setOrientation(JSplitPane.VERTICAL_SPLIT);
048:
049: setDividerLocation(0.75);
050:
051: // this has to be set by themes
052: //setDividerSize( 5 );
053: setResizeWeight(0.25);
054:
055: splitPane.setDividerLocation(0.9);
056: splitPane.setResizeWeight(0.9);
057:
058: // this has to be set by themes
059: //splitPane.setDividerSize( 5 );
060: add(header, JSplitPane.TOP);
061: add(splitPane, JSplitPane.BOTTOM);
062: splitPane.add(message, JSplitPane.TOP);
063: splitPane.add(attachment, JSplitPane.BOTTOM);
064:
065: //splitPane.resetToPreferredSizes();
066: //hideAttachmentViewer();
067: }
068:
069: public void hideAttachmentViewer() {
070: if (hide == true) {
071: return;
072: }
073:
074: last = getDividerLocation();
075: lastAttach = splitPane.getDividerLocation();
076:
077: remove(splitPane);
078: remove(header);
079:
080: add(header, JSplitPane.TOP);
081: add(message, JSplitPane.BOTTOM);
082:
083: hide = true;
084:
085: setDividerLocation(last);
086: }
087:
088: public void showAttachmentViewer() {
089: if (hide == false) {
090: return;
091: }
092:
093: last = getDividerLocation();
094:
095: remove(header);
096: remove(message);
097:
098: splitPane.add(message, JSplitPane.TOP);
099: splitPane.add(attachment, JSplitPane.BOTTOM);
100:
101: add(header, JSplitPane.TOP);
102: add(splitPane, JSplitPane.BOTTOM);
103:
104: setDividerLocation(last);
105: splitPane.setDividerLocation(lastAttach);
106:
107: hide = false;
108: }
109: }
|