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.SharedFolderPlugin;
24:
25: import javax.swing.*;
26: import java.awt.event.ActionEvent;
27:
28: public class CreateFolderAction extends PerformableAction {
29: private SharedFolderPlugin plugin;
30: private JTable table;
31: private boolean history;
32:
33: public CreateFolderAction(SharedFolderPlugin plugin, JTable table,
34: boolean history) {
35: this .plugin = plugin;
36: this .table = table;
37: this .history = history;
38:
39: putValue(Action.SMALL_ICON, plugin
40: .getImageIcon("actions/createfolder.png"));
41: putValue(Action.SHORT_DESCRIPTION, plugin
42: .tr("tip.createFolder"));
43: }
44:
45: public boolean isPerformable() {
46: FolderTableModel model = (FolderTableModel) table.getModel();
47: return !history && model.getCurrentFolder().isWritable();
48: }
49:
50: public void actionPerformed(ActionEvent ae) {
51: if (!isPerformable())
52: return;
53:
54: FolderTableModel model = (FolderTableModel) table.getModel();
55: String name = DialogBox.input(plugin.tr("tip.createFolder"),
56: plugin.tr("msg.enterFolderName"));
57: if (name == null || name.length() == 0)
58: return;
59:
60: try {
61: plugin.createFolder(model.getCurrentFolder().getId(), name);
62: new RefreshAction(plugin, table, history)
63: .actionPerformed(ae);
64: } catch (Exception e) {
65: DialogBox.error(e.getMessage());
66: e.printStackTrace();
67: }
68: }
69: }
|