--- /dev/null
+/*
+ * Copyright 2005-2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wamblee.photos.wicket;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.inject.Inject;
+
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.Model;
+import org.wamblee.photos.model.Album;
+import org.wamblee.photos.model.plumbing.AuthorizedPhotos;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: erik
+ * Date: 9/23/13
+ * Time: 8:33 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class CreateFolderPanel extends Panel {
+
+ private static final Logger LOGGER = Logger.getLogger(CreateFolderPanel.class.getName());
+
+ @Inject
+ @AuthorizedPhotos
+ private transient Album _authorized;
+
+ private String _path;
+
+ /**
+ * Upload field.
+ */
+ private TextField _field;
+
+ public CreateFolderPanel(String aId, String aPath) {
+ super(aId);
+
+ _path = aPath;
+
+ Form form = new Form("createFolderForm") {
+ protected void onSubmit() {
+ String folder = _field.getValue();
+ Album album = (Album) _authorized.getEntry(_path);
+ try {
+ album.addAlbum(folder);
+ info("Folder '" + folder + "' created");
+ _field.setModel(new Model());
+ }
+ catch (IOException e) {
+ error("Could not add folder '" + folder + "'");
+ LOGGER.log(Level.INFO, "Could not add folder '" + folder + "'", e);
+ }
+ }
+ };
+ add(form);
+ _field = new TextField("name", new Model());
+ form.add(_field);
+ }
+}