16 package net.squiz.matrix.ui;
18 import net.squiz.matrix.matrixtree.*;
19 import net.squiz.matrix.core.*;
20 import net.squiz.matrix.plaf.MatrixLookAndFeel;
23 import java.io.IOException;
24 import net.squiz.matrix.debug.*;
26 import javax.swing.border.*;
28 import java.awt.BorderLayout;
29 import java.awt.event.*;
30 import java.awt.FontMetrics;
40 implements MatrixConstants, KeyListener {
42 private JButton deleteBtn;
43 private JButton cancelBtn;
45 private static Point prevScreenLocation = null;
49 JPanel contentPane =
new JPanel(
new BorderLayout());
50 setContentPane(contentPane);
52 Border border =
new EmptyBorder(1, 1, 1, 1);
53 contentPane.setBorder(border);
55 JPanel midPanel =
new JPanel();
60 if (nodes.length == 1) {
61 Object[] transArgs = {
62 new String(nodes[0].getName())
64 label =
new JLabel(Matrix.translate(
"asset_map_confirm_move_child", transArgs));
66 Object[] transArgs = {
67 new Integer(nodes.length)
69 label =
new JLabel(Matrix.translate(
"asset_map_confirm_move_children", transArgs));
72 label.setFont(MatrixTreeBus.getActiveTree().getFontInUse());
75 contentPane.add(getTopPanel(Matrix.translate(
"asset_map_dialog_delete")), BorderLayout.NORTH);
76 contentPane.add(midPanel, BorderLayout.CENTER);
77 enableDrag(contentPane);
79 JPanel bottomPanel =
new JPanel();
80 final JLabel deleteButton =
new JLabel();
81 deleteButton.setIcon(GUIUtilities.getAssetMapIcon(
"ok.png"));
84 deleteButton.addMouseListener(
new MouseAdapter(){
85 public void mouseClicked(MouseEvent e){
86 setCursor(
new Cursor(Cursor.DEFAULT_CURSOR));
91 public void mouseExited(MouseEvent e) {
92 deleteButton.setIcon(GUIUtilities.getAssetMapIcon(
"ok.png"));
93 setCursor(
new Cursor(Cursor.DEFAULT_CURSOR));
96 public void mouseEntered(MouseEvent e) {
97 deleteButton.setIcon(GUIUtilities.getAssetMapIcon(
"ok_on.png"));
98 setCursor(
new Cursor(Cursor.HAND_CURSOR));
102 deleteButton.setOpaque(
false);
103 bottomPanel.add(deleteButton);
105 JLabel cancelButton =
new JLabel();
106 cancelButton.setIcon(GUIUtilities.getAssetMapIcon(
"cancel.png"));
108 closeOnClick(cancelButton,
"cancel");
109 bottomPanel.add(cancelButton);
113 contentPane.add(bottomPanel, BorderLayout.SOUTH);
118 FontMetrics fm = getFontMetrics(label.getFont());
119 int textWidth = fm.stringWidth(label.getText());
120 setSize(textWidth + 32, 125);
121 addKeyListener(
this);
125 public void dispose() {
126 prevScreenLocation = getPrevLoc();
131 private void btn_pressed(ActionEvent evt) {
136 public void keyTyped(KeyEvent evt) {
139 public void keyPressed(KeyEvent evt) {
140 if(evt.getKeyCode() == evt.VK_ENTER || evt.getKeyCode() == evt.VK_SPACE) {
143 }
else if(evt.getKeyCode() == evt.VK_ESCAPE) {
148 public void keyReleased(KeyEvent evt) {
152 private void delete() {
154 String[] assetids = AssetManager.getAssetsOfType(
"trash_folder");
155 Asset trash = AssetManager.getAsset(assetids[0]);
156 Iterator nodes = trash.getTreeNodes();
158 while (nodes.hasNext()) {
161 MatrixTreeComm.createLink(NewLinkEvent.LINK_TYPE_MOVE,
DeleteDialog.this.nodes, trashNode, 0, 0, null);
178 deleteDialog.toFront();