From e12aa79fc9e2db91f2db165dd046f9fc174b2c2f Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Wed, 25 Sep 2013 23:32:14 +0200 Subject: [PATCH 1/1] Create folder panel (forgot to add). --- .../photos/wicket/CreateFolderPanel.html | 26 +++++++ .../photos/wicket/CreateFolderPanel.java | 76 +++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 src/main/java/org/wamblee/photos/wicket/CreateFolderPanel.html create mode 100644 src/main/java/org/wamblee/photos/wicket/CreateFolderPanel.java diff --git a/src/main/java/org/wamblee/photos/wicket/CreateFolderPanel.html b/src/main/java/org/wamblee/photos/wicket/CreateFolderPanel.html new file mode 100644 index 0000000..c1e5aa2 --- /dev/null +++ b/src/main/java/org/wamblee/photos/wicket/CreateFolderPanel.html @@ -0,0 +1,26 @@ + + + Wicket Quickstart Archetype Homepage + + + + +
+ + + + + + + +
+ + + +
+
+
+ + + diff --git a/src/main/java/org/wamblee/photos/wicket/CreateFolderPanel.java b/src/main/java/org/wamblee/photos/wicket/CreateFolderPanel.java new file mode 100644 index 0000000..547d809 --- /dev/null +++ b/src/main/java/org/wamblee/photos/wicket/CreateFolderPanel.java @@ -0,0 +1,76 @@ +/* + * 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); + } +} -- 2.31.1