/
NewAlbumDialog.java
207 lines (175 loc) · 7.17 KB
/
NewAlbumDialog.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*
* Gallery Remote - a File Upload Utility for Gallery
*
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2001 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.gallery.GalleryRemote;
import com.gallery.GalleryRemote.model.Album;
import com.gallery.GalleryRemote.model.Gallery;
import com.gallery.GalleryRemote.util.DialogUtil;
import com.gallery.GalleryRemote.util.GRI18n;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;
/**
* Description of the Class
*
* @author paour
* @created October 18, 2002
*/
public class NewAlbumDialog extends JDialog
implements ActionListener {
public final static String MODULE = "NewAlbum";
Gallery gallery = null;
Album defaultAlbum = null;
Album newAlbum = null;
Album parentAlbum = null;
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JTextField jTitle = new JTextField();
JTextField jName = new JTextField();
JTextArea jDescription = new JTextArea();
JLabel jLabel1 = new JLabel();
JLabel jGalleryName = new JLabel();
JComboBox jAlbum = null;
JPanel jPanel2 = new JPanel();
JButton jOk = new JButton();
JButton jCancel = new JButton();
GridLayout gridLayout1 = new GridLayout();
/**
* Constructor for the NewAlbumDialog object
*
* @param owner Description of Parameter
* @param gallery Description of Parameter
* @param defaultAlbum Description of Parameter
*/
public NewAlbumDialog(Frame owner, Gallery gallery, Album defaultAlbum) {
super(owner, true);
this.gallery = gallery;
this.defaultAlbum = defaultAlbum;
jbInit();
pack();
DialogUtil.center(this, owner);
setVisible(true);
}
private void jbInit() {
this.getContentPane().setLayout(new GridBagLayout());
this.setModal(true);
this.setTitle(GRI18n.getString(MODULE, "title"));
Vector albums = new Vector(gallery.getFlatAlbumList());
//rootAlbum = new Album(gallery);
//rootAlbum.setSuppressEvents(true);
//rootAlbum.setTitle(GRI18n.getString(MODULE, "rootAlbmTitle"));
//rootAlbum.setName("root.root");
//albums.add(0, rootAlbum);
jAlbum = new JComboBox(albums);
jAlbum.setFont(UIManager.getFont("Label.font"));
if (defaultAlbum == null) {
jAlbum.setSelectedItem(gallery.getRoot());
} else {
jAlbum.setSelectedItem(defaultAlbum);
}
jCancel.setText(GRI18n.getString("Common", "cancel"));
jCancel.setActionCommand("Cancel");
jDescription.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.white, Color.lightGray, Color.darkGray, Color.gray));
jDescription.setLineWrap(true);
jDescription.setRows(2);
jAlbum.setFont(UIManager.getFont("Label.font"));
jGalleryName.setText(GRI18n.getString(MODULE, "createAlbm", new String[] { gallery.toString() }));
jName.setFont(UIManager.getFont("Label.font"));
jName.setToolTipText(GRI18n.getString(MODULE, "albmNameTip"));
jOk.setText(GRI18n.getString("Common", "OK"));
jOk.setActionCommand("OK");
jTitle.setFont(UIManager.getFont("Label.font"));
gridLayout1.setColumns(2);
gridLayout1.setHgap(5);
jLabel2.setText(GRI18n.getString(MODULE, "parentAlbm"));
jLabel3.setText(GRI18n.getString(MODULE, "albmTitle"));
jLabel4.setText(GRI18n.getString(MODULE, "albmName"));
jLabel5.setText(GRI18n.getString(MODULE, "albmDesc"));
jPanel2.setLayout(gridLayout1);
this.getContentPane().add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 4));
this.getContentPane().add(jLabel3, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 5, 0, 5), 0, 4));
this.getContentPane().add(jLabel4, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 5, 0, 5), 0, 4));
this.getContentPane().add(jLabel5, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0
, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 3));
this.getContentPane().add(jTitle, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 5), 0, 0));
this.getContentPane().add(jName, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 5), 0, 0));
this.getContentPane().add(jDescription, new GridBagConstraints(1, 4, 1, 1, 1.0, 1.0
, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
this.getContentPane().add(jGalleryName, new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0
, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
this.getContentPane().add(jAlbum, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 5), 0, 0));
this.getContentPane().add(jPanel2, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0
, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
jPanel2.add(jCancel, null);
jPanel2.add(jOk, null);
jOk.addActionListener(this);
jCancel.addActionListener(this);
getRootPane().setDefaultButton(jOk);
}
/**
* Description of the Method
*
* @param e Description of Parameter
*/
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
Log.log(Log.LEVEL_INFO, MODULE, "Command selected " + command);
if (command.equals("Cancel")) {
setVisible(false);
} else if (command.equals("OK")) {
newAlbum = new Album(gallery);
//newAlbum.setSuppressEvents(true);
newAlbum.setName(jName.getText());
newAlbum.setTitle(jTitle.getText());
newAlbum.setCaption(jDescription.getText());
//newAlbum.setSuppressEvents(false);
parentAlbum = (Album) jAlbum.getSelectedItem();
parentAlbum.getGallery().insertNodeInto(newAlbum, parentAlbum, parentAlbum.getChildCount());
//if (selectedAlbum == rootAlbum) {
// Log.log(Log.LEVEL_TRACE, MODULE, "Selected root album");
// a.setParentAlbum(null);
//} else {
//selectedAlbum.add(newAlbum);
//}
//newAlbumName = gallery.doNewAlbum(newAlbum, GalleryRemote._().getCore().getMainStatusUpdate());
//if (newAlbumName == null) {
// newAlbumName = jName.getText();
//}
setVisible(false);
}
}
public Album getNewAlbum() {
return newAlbum;
}
public Album getParentAlbum() {
return parentAlbum;
}
}