01: /*
02: * Lucane - a collaborative platform
03: * Copyright (C) 2005 Vincent Fiack <vfiack@mail15.com>
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: */
19: package org.lucane.applications.sharedfolder.gui.actions;
20:
21: import org.lucane.client.widgets.DialogBox;
22: import org.lucane.applications.sharedfolder.gui.FolderTableModel;
23: import org.lucane.applications.sharedfolder.model.FolderInfo;
24: import org.lucane.applications.sharedfolder.SharedFolderPlugin;
25:
26: import javax.swing.*;
27: import java.awt.event.ActionEvent;
28: import java.util.ArrayList;
29:
30: public class OpenParentAction extends PerformableAction {
31: private SharedFolderPlugin plugin;
32: private JTable table;
33: private boolean history;
34:
35: public OpenParentAction(SharedFolderPlugin plugin, JTable table,
36: boolean history) {
37: this .plugin = plugin;
38: this .table = table;
39: this .history = history;
40:
41: putValue(Action.SMALL_ICON, plugin
42: .getImageIcon("actions/openparent.png"));
43: putValue(Action.SHORT_DESCRIPTION, plugin.tr("tip.openParent"));
44: }
45:
46: public boolean isPerformable() {
47: FolderTableModel model = (FolderTableModel) table.getModel();
48: FolderInfo current = model.getCurrentFolder();
49: if (history || current == null
50: || current.getId() == FolderInfo.ROOT_ID)
51: return false;
52:
53: return true;
54: }
55:
56: public void actionPerformed(ActionEvent ae) {
57: if (!isPerformable())
58: return;
59:
60: FolderTableModel model = (FolderTableModel) table.getModel();
61: FolderInfo current = model.getCurrentFolder();
62:
63: ArrayList items = new ArrayList();
64: try {
65: items.addAll(plugin.listFolders(current.getParentId()));
66: items.addAll(plugin.listFiles(current.getParentId()));
67: model.setItems(plugin.getFolder(current.getParentId()),
68: items);
69: } catch (Exception e) {
70: DialogBox.error(e.getMessage());
71: e.printStackTrace();
72: }
73:
74: }
75: }
|