16 package net.squiz.matrix.assetmap;
18 import net.squiz.matrix.ui.*;
19 import net.squiz.matrix.core.*;
20 import javax.swing.tree.TreePath;
21 import net.squiz.matrix.matrixtree.*;
24 import javax.swing.event.*;
26 import java.awt.event.*;
28 import java.awt.dnd.*;
32 private javax.swing.Timer tabChangerTimer;
33 public final Redocker REDOCK_HANDLER =
new Redocker();
34 private boolean allUndocked =
false;
40 DropTarget dropTarget =
new DropTarget(
this, dropHandler);
42 MouseListener listener =
new MouseAdapter() {
43 public void mouseClicked(MouseEvent evt) {
44 if (evt.getClickCount() == 2) {
45 JTabbedPane source = (JTabbedPane) evt.getSource();
46 View view = (
View) source.getSelectedComponent();
50 if (indexAtLocation(evt.getX(), evt.getY()) == -1)
53 JPanel panel =
new JPanel();
54 panel.setBackground(Color.WHITE);
55 JLabel tabsUndocked =
new JLabel(
"", GUIUtilities.getAssetMapIcon(
"matrix_logo.png"), CENTER);
56 tabsUndocked.setVerticalTextPosition(JLabel.CENTER);
57 tabsUndocked.setHorizontalTextPosition(JLabel.CENTER);
58 tabsUndocked.setVerticalAlignment(JLabel.CENTER);
59 tabsUndocked.setHorizontalAlignment(JLabel.CENTER);
60 tabsUndocked.setBackground(Color.WHITE);
62 int fillerWidth = getWidth();
63 int fillerHeight = ( getHeight() / 3 ) ;
64 Dimension filler =
new Dimension(fillerWidth,fillerHeight);
66 panel.add(
new Box.Filler(filler,filler,filler), BorderLayout.NORTH);
67 panel.add(tabsUndocked, BorderLayout.CENTER);
68 source.setComponentAt(source.getSelectedIndex(), panel);
71 AssetMap.applet.addKeyAndContainerListenerRecursively(udView);
73 udView.setSize(300, 600);
74 GUIUtilities.showInScreenCenter(udView);
76 udView.setExtendedState(Frame.NORMAL);
77 udView.addWindowListener(REDOCK_HANDLER);
78 source.setEnabledAt(source.getSelectedIndex(),
false);
80 for (
int i = 0; i < source.getTabCount(); i++) {
81 if (i != source.getSelectedIndex() && source.isEnabledAt(i)) {
82 source.setSelectedIndex(i);
87 if (i == source.getTabCount() - 1) {
88 source.setSelectedIndex(-1);
97 addMouseListener(listener);
101 public void addView(String name,
View view) {
103 addTab(name, GUIUtilities.getAssetMapIcon(
"tree.png"), view.getViewComponent());
106 public boolean isAllUndocked() {
107 return allUndocked ?
true :
false;
111 class Redocker
extends WindowAdapter {
112 public void windowClosing(WindowEvent evt) {
114 JComponent basicView = view.getViewComponent();
116 JSplitPane splitPane = ((
BasicView)basicView).getSplitPane();
117 splitPane.setDividerLocation(Integer.MAX_VALUE);
119 for (
int i = 0; i < getTabCount(); i++) {
122 if (isEnabledAt(i) ==
false && i != view.getIndex()) {
124 setComponentAt(i, newView);
128 setComponentAt(view.getIndex(), basicView);
129 setEnabledAt(view.getIndex(),
true);
130 setSelectedIndex(view.getIndex());
137 public void stateChanged(ChangeEvent evt) {
140 JTabbedPane pane = (JTabbedPane) evt.getSource();
142 MatrixTree currentTree = view.getTree();
144 for (
int i = 0; i < pane.getTabCount(); i++) {
146 if (!(pane.getComponentAt(i) instanceof
BasicView))
148 MatrixTree tree = ( (
BasicView) ( pane.getComponentAt(i) ) ).getTree();
149 TreePath[] path =
new TreePath[1];
150 path[0] = tree.getCuePath();
151 if (path[0] != null) {
152 currentTree.startCueMode(path);
157 }
catch (ArrayIndexOutOfBoundsException ex) {}
163 private javax.swing.Timer tabChangerTimer;
164 private Point lastMousePt;
167 ActionListener timerListener =
new ActionListener() {
168 public void actionPerformed(ActionEvent evt) {
169 setSelectedIndex(indexAtLocation(lastMousePt.x, lastMousePt.y));
172 tabChangerTimer =
new javax.swing.Timer(1000, timerListener);
173 tabChangerTimer.setRepeats(
false);
176 public void dragOver(DropTargetDragEvent dtde) {
177 lastMousePt = dtde.getLocation();
178 if (indexAtLocation(lastMousePt.x, lastMousePt.y) != -1) {
179 if (!tabChangerTimer.isRunning()) {
180 tabChangerTimer.start();
183 if (tabChangerTimer.isRunning())
184 tabChangerTimer.stop();
188 public void dragEnter(DropTargetDragEvent dtde) {}
189 public void dragExit(DropTargetEvent dte) {}
190 public void drop(DropTargetDropEvent dtde) {}
191 public void dropActionChanged(DropTargetDragEvent dtde) {}