2 * Copyright 2005-2011 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.photos.wicket;
18 import java.io.IOException;
19 import java.util.logging.Level;
20 import java.util.logging.Logger;
21 import javax.inject.Inject;
23 import org.apache.wicket.markup.html.form.Form;
24 import org.apache.wicket.markup.html.form.TextField;
25 import org.apache.wicket.markup.html.panel.Panel;
26 import org.apache.wicket.model.Model;
27 import org.wamblee.photos.model.Album;
28 import org.wamblee.photos.model.plumbing.AuthorizedPhotos;
31 * Created with IntelliJ IDEA.
35 * To change this template use File | Settings | File Templates.
37 public class CreateFolderPanel extends Panel {
39 private static final Logger LOGGER = Logger.getLogger(CreateFolderPanel.class.getName());
43 private transient Album _authorized;
50 private TextField _field;
52 public CreateFolderPanel(String aId, String aPath) {
57 Form form = new Form("createFolderForm") {
58 protected void onSubmit() {
59 String folder = _field.getValue();
60 Album album = (Album) _authorized.getEntry(_path);
62 album.addAlbum(folder);
63 info("Folder '" + folder + "' created");
64 _field.setModel(new Model());
66 catch (IOException e) {
67 error("Could not add folder '" + folder + "'");
68 LOGGER.log(Level.INFO, "Could not add folder '" + folder + "'", e);
73 _field = new TextField("name", new Model());