001: /*
002: * Splitter.java Copyright (c) 2006,07 Swaroop Belur
003: *
004: * This program is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU General Public License
006: * as published by the Free Software Foundation; either version 2
007: * of the License, or (at your option) any later version.
008:
009: * This program is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013:
014: * You should have received a copy of the GNU General Public License
015: * along with this program; if not, write to the Free Software
016: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
017: *
018: */
019:
020: package net.sf.jdec.ui.core;
021:
022: import java.awt.Component;
023: import java.awt.Dimension;
024: import java.util.ArrayList;
025:
026: import javax.swing.JFrame;
027: import javax.swing.JSplitPane;
028: import javax.swing.JTabbedPane;
029:
030: import net.sf.jdec.ui.main.UILauncher;
031:
032: /**
033: *@author swaroop belur
034: */
035: public class Splitter extends UIObject {
036:
037: public JSplitPane getSplitPlane() {
038: return splitPlane;
039: }
040:
041: JSplitPane splitPlane = null;
042:
043: public void setDesc(java.lang.String desc) {
044: this .whatAmI = desc;
045: }
046:
047: public Splitter(FileInfoFrame frame, JdecStatusFrame statusFrame,
048: JTabbedPane tabs, JTabbedPane outputframe,
049: Console consoleFrame) {
050: createSplitter(frame, statusFrame, tabs, outputframe,
051: consoleFrame);
052: }
053:
054: JSplitPane jsp1;
055: FileInfoFrame frame = null;
056: Component FileInfoComponent = null;
057: Component c1;
058: JdecStatusFrame jdecstatusFrame = null;
059: JTabbedPane lefttabs = null;
060: Console splitPaneConsoleFrame = null;
061:
062: public void resetInfoFrame(FileInfoFrame newframe) {
063: //frame=newframe;
064: FileInfoComponent = frame.getDetails();
065: //c1=FileInfoComponent;
066: frame.getModel().getValueAt(0, 1);
067: //frame.getModel().setValueAt("Dummy Value",0,1);
068: jsp1.remove(c1);
069: FileInfoComponent.setSize(c1.getWidth(), c1.getHeight());
070: c1 = FileInfoComponent;
071: jsp1.add(c1);
072: JFrame mainFrame = UILauncher.getMainFrame();
073: mainFrame.repaint();
074: }
075:
076: public Splitter createSplitter(FileInfoFrame frame,
077: JdecStatusFrame statusFrame, JTabbedPane tabs,
078: JTabbedPane outputframe, Console consoleFrame) {
079: //splitPlane
080: this .frame = frame;
081: c1 = frame.getDetails();
082: //FileInfoComponent=c1;
083: Component c2 = statusFrame.getStatus();
084: splitPaneConsoleFrame = consoleFrame;
085: lefttabs = tabs;
086: jdecstatusFrame = statusFrame;
087: //Dimension d=c1.getToolkit().getScreenSize();
088: //c1.setSize(100, 100);
089: //c1.setSize(100, 100);
090: jsp1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, c1, null); // Removed Status frame
091: c1.setSize(jsp1.getWidth() + 20, jsp1.getHeight() + 75);
092: jsp1.setDividerSize(8);
093: jsp1.setContinuousLayout(true);
094: Component c3 = tabs;
095: Component c33 = new JdecTree();
096: Dimension d = jsp1.getSize();
097:
098: jsp1.setMinimumSize(new Dimension((int) d.getWidth() + 20,
099: (int) d.getHeight() + 50));
100: d = jsp1.getSize();
101:
102: /*JTabbedPane drives=new JTabbedPane(SwingConstants.BOTTOM);
103: drives.addTab("Dir", treeFrame);
104: drives.addTab("Jar",new JLabel("Jar File Viewer..."));
105: drives.doLayout();
106: drives.validate();
107: drives.setEnabled(true);
108: drives.setVisible(true);
109: drives.setSelectedIndex(0);*/
110: /*JFrame tabs=new JFrame();
111: tabs.setSize(300,300);
112: tabs.getContentPane().setLayout(new GridLayout(2,1));
113: tabs.getContentPane().add(drives);
114: tabs.setVisible(true);*/
115:
116: JSplitPane spLeft = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
117: jsp1, c3);
118: jsp1.setToolTipText("Drag To Increase Visbility");
119:
120: c3.setSize(0, 0);
121:
122: jsp1.setMinimumSize(new Dimension((int) c3.getMinimumSize()
123: .getWidth(), (int) c3.getMinimumSize().getHeight()));
124:
125: Component c4 = outputframe;
126: Component c5 = consoleFrame.getComponent();
127: spLeft.setContinuousLayout(true);
128: alloutputFrames = c4;
129: consoleSplitFrame = c5;
130: spRight = new JSplitPane(JSplitPane.VERTICAL_SPLIT, c4, c5);
131: //ref.getLeftSplitPane().setSize(ref.getLeftSplitPane().getWidth(),c4.getHeight()+75);
132: //c4.setSize(w, c4.getHeight()+75);
133: //right.setDividerSize(8);
134: spRight.setContinuousLayout(true);
135: spRight.setOrientation(0);
136: spRight.setDividerSize(5);
137: spRight.setOneTouchExpandable(true);
138: spRight.setLastDividerLocation(1);
139: spRight.setResizeWeight(0.8);
140: spRight.setBounds(253, 1, 752, 631);
141: spRight.setMinimumSize(new Dimension(spRight.getWidth() - 75,
142: spRight.getHeight()));
143:
144: //spRight = new JSplitPane(JSplitPane.VERTICAL_SPLIT, c4, c5);
145: c4.setSize(spRight.getWidth(), c4.getHeight() + 75);
146: //spRight.setDividerSize(1);
147: //spRight.setContinuousLayout(true);
148: spLeftPane = spLeft;
149: //spRight.setMinimumSize(new Dimension(spRight.getWidth()-75,spRight.getHeight()));
150: //spRight.setDividerLocation(0.7);
151: splitPlane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
152: spLeft, spRight);
153: spLeft.setToolTipText("Drag To Increase Visibility");
154: splitPlane.setContinuousLayout(true);
155: splitPlane.setOneTouchExpandable(true);
156: splitPlane.setAutoscrolls(true);
157:
158: return this ;
159: }
160:
161: private JSplitPane spLeftPane = null;
162:
163: public JSplitPane getLeftSplitPane() {
164: return spLeftPane;
165: }
166:
167: public void setSpRight(JSplitPane spRight) {
168: this .spRight = spRight;
169: }
170:
171: private JSplitPane spRight = null;
172:
173: public JSplitPane getRightSplitPane() {
174: return spRight;
175: }
176:
177: private Component consoleSplitFrame = null;
178:
179: public Component getconsoleFrameComponent() {
180: return consoleSplitFrame;
181: }
182:
183: private Component alloutputFrames = null;
184:
185: public Component getOutputTabFrameComponent() {
186: return alloutputFrames;
187: }
188:
189: public Splitter resetRightSplitPane(java.lang.String action) {
190: if (action == null)
191: return null;
192: if (action.equals("show")) {
193:
194: return createSplitter(frame, jdecstatusFrame, lefttabs,
195: (JTabbedPane) alloutputFrames,
196: splitPaneConsoleFrame);
197: //spRight = new JSplitPane(JSplitPane.VERTICAL_SPLIT, getOutputTabFrameComponent(), getconsoleFrameComponent());
198: } else if (action.equals("hide")) {
199: spRight.remove(1);
200: spRight.revalidate();
201: //spRight = new JSplitPane(JSplitPane.VERTICAL_SPLIT, getOutputTabFrameComponent(), null);
202: }
203: //splitPlane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,spLeftPane,spRight);
204:
205: return null;
206:
207: }
208:
209: private void createOtherSplitters() {
210:
211: // Without Details
212:
213: }
214:
215: public void recreateSplitter(ArrayList currentList) {
216:
217: if (currentList != null && currentList.size() > 0) {
218:
219: FileInfoFrame info = null;
220: JdecStatusFrame status = null;
221: JTabbedPane tabs = null;
222: Console console = null;
223:
224: for (int s = 0; s < currentList.size(); s++) {
225: Object o = currentList.get(s);
226: if (o instanceof FileInfoFrame) {
227: info = (FileInfoFrame) o;
228: } else if (o instanceof JdecStatusFrame) {
229: status = (JdecStatusFrame) o;
230: } else if (o instanceof JdecTree) {
231: tabs = (JTabbedPane) o;
232: } else if (o instanceof Console) {
233: console = (Console) o;
234: }
235:
236: }
237: // if(info!=null)
238:
239: }
240:
241: }
242:
243: }
|