Author: ldywicki Date: Mon Aug 22 15:24:28 2011 New Revision: 1160301 URL: http://svn.apache.org/viewvc?rev=1160301&view=rev Log: Refactor configurations subpage. Added remove operation support for configurations
Added: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationRemovePage.java karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/AbstractConfigurationModel.java karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ConfigurationModel.java karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ConfigurationNotFoundException.java karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ConfigurationsModel.java karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ConfigurationRemoveForm.java karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ConfigurationsActionPanel.java - copied, changed from r1160300, karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsActionPanel.java karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ConfigurationstDataTable.java karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/FactoryPidItem.java karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationRemovePage.html - copied, changed from r1160300, karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsPage.html Removed: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsActionPanel.java Modified: karaf/sandbox/pieber/karaf-webconsole/trunk/core/src/main/java/org/apache/karaf/webconsole/core/BasePage.java karaf/sandbox/pieber/karaf-webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/BasePage.html karaf/sandbox/pieber/karaf-webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/SidebarPage.html karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationEditPage.java karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationProvider.java karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsPage.java karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationEditPage.html karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsPage.html karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/configurations.css Modified: karaf/sandbox/pieber/karaf-webconsole/trunk/core/src/main/java/org/apache/karaf/webconsole/core/BasePage.java URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/core/src/main/java/org/apache/karaf/webconsole/core/BasePage.java?rev=1160301&r1=1160300&r2=1160301&view=diff ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/core/src/main/java/org/apache/karaf/webconsole/core/BasePage.java (original) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/core/src/main/java/org/apache/karaf/webconsole/core/BasePage.java Mon Aug 22 15:24:28 2011 @@ -8,12 +8,11 @@ import org.apache.karaf.webconsole.core. import org.apache.karaf.webconsole.core.internal.LanguagePanel; import org.apache.karaf.webconsole.core.navigation.ConsoleTab; import org.apache.karaf.webconsole.core.navigation.markup.NavigationPanel; -import org.apache.wicket.ResourceReference; import org.apache.wicket.behavior.IBehavior; import org.apache.wicket.markup.html.CSSPackageResource; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.image.Image; +import org.apache.wicket.markup.html.panel.FeedbackPanel; import org.apache.wicket.model.IModel; import org.apache.wicket.model.util.ListModel; import org.ops4j.pax.wicket.api.PaxWicketBean; @@ -44,6 +43,12 @@ public class BasePage extends WebPage { for (IBehavior behavior : brandProvider.getBehaviors()) { add(behavior); } + + add(new FeedbackPanel("feedback")); + } + + public void get() { + } } Modified: karaf/sandbox/pieber/karaf-webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/BasePage.html URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/BasePage.html?rev=1160301&r1=1160300&r2=1160301&view=diff ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/BasePage.html (original) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/BasePage.html Mon Aug 22 15:24:28 2011 @@ -24,6 +24,7 @@ <div class="clear"></div> <div class="grid_12"> + <span wicket:id="feedback">Feedback stuff</span> <wicket:child /> </div> <div class="clear"></div> Modified: karaf/sandbox/pieber/karaf-webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/SidebarPage.html URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/SidebarPage.html?rev=1160301&r1=1160300&r2=1160301&view=diff ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/SidebarPage.html (original) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/SidebarPage.html Mon Aug 22 15:24:28 2011 @@ -28,6 +28,7 @@ <div wicket:id="sidebar">Sidebar goes here</div> </div> <div class="grid_9"> + <span wicket:id="feedback">Feedback stuff</span> <wicket:child /> </div> <div class="clear"></div> Modified: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationEditPage.java URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationEditPage.java?rev=1160301&r1=1160300&r2=1160301&view=diff ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationEditPage.java (original) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationEditPage.java Mon Aug 22 15:24:28 2011 @@ -11,12 +11,16 @@ import java.util.Map; import java.util.Map.Entry; import org.apache.karaf.webconsole.osgi.internal.OsgiPage; +import org.apache.karaf.webconsole.osgi.internal.configuration.model.ConfigurationModel; import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.form.IFormSubmittingComponent; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.list.ListItem; import org.apache.wicket.markup.html.list.ListView; +import org.apache.wicket.model.CompoundPropertyModel; import org.apache.wicket.model.Model; import org.apache.wicket.model.util.ListModel; import org.ops4j.pax.wicket.api.PaxWicketBean; @@ -27,9 +31,10 @@ public class ConfigurationEditPage exten @PaxWicketBean(name = "configurationAdmin") private ConfigurationAdmin configurationAdmin; + private String pid; public ConfigurationEditPage(PageParameters params) { - String pid = params.getString("pid"); + pid = params.getString("pid"); add(new Label("pid", pid)); @@ -42,9 +47,17 @@ public class ConfigurationEditPage exten } private Form form(Configuration configuration) { - Form<Configuration> form = new Form<Configuration>("edit"); + CompoundPropertyModel<Configuration> model = new CompoundPropertyModel<Configuration>(null); + model.setChainedModel(new ConfigurationModel(pid, configurationAdmin)); - form.add(new TextField<String>("pid", Model.of(configuration.getPid())) { + Form<Configuration> form = new Form<Configuration>("edit", model) { + @Override + public void process(IFormSubmittingComponent submittingComponent) { + System.out.println("--> " + getModelObject()); + } + }; + + form.add(new TextField<String>("pid") { @Override public boolean isEnabled() { return false; @@ -52,6 +65,8 @@ public class ConfigurationEditPage exten }); Dictionary<String, Serializable> properties = configuration.getProperties(); + properties.get("service.pid"); + properties.get("service.factory"); Map<String, Serializable> map = new LinkedHashMap<String, Serializable>(); Enumeration<String> keys = properties.keys(); @@ -67,8 +82,13 @@ public class ConfigurationEditPage exten item.add(new Label("key", item.getModelObject().getKey())); item.add(new TextField<String>("value", new Model(item.getModelObject().getValue()))); } + @Override + public boolean getReuseItems() { + return true; + } }); + form.add(new Button("submit")); return form; } Modified: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationProvider.java URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationProvider.java?rev=1160301&r1=1160300&r2=1160301&view=diff ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationProvider.java (original) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationProvider.java Mon Aug 22 15:24:28 2011 @@ -1,19 +1,33 @@ package org.apache.karaf.webconsole.osgi.internal.configuration; +import java.io.IOException; import java.util.Arrays; import java.util.Iterator; +import org.apache.karaf.webconsole.osgi.internal.configuration.model.ConfigurationModel; import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider; import org.apache.wicket.model.CompoundPropertyModel; import org.apache.wicket.model.IModel; +import org.osgi.framework.InvalidSyntaxException; import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; public class ConfigurationProvider extends SortableDataProvider<Configuration> { - private final Configuration[] configurations; + private Configuration[] configurations = new Configuration[0]; + private final ConfigurationAdmin configurationAdmin; - public ConfigurationProvider(Configuration[] configurations) { - this.configurations = configurations; + public ConfigurationProvider(ConfigurationAdmin configurationAdmin) { + this.configurationAdmin = configurationAdmin; + try { + this.configurations = configurationAdmin.listConfigurations(null); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvalidSyntaxException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } public Iterator<? extends Configuration> iterator(int arg0, int arg1) { @@ -21,7 +35,7 @@ public class ConfigurationProvider exten } public IModel<Configuration> model(Configuration arg0) { - return new CompoundPropertyModel<Configuration>(arg0); + return new ConfigurationModel(arg0.getPid(), configurationAdmin); } public int size() { Added: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationRemovePage.java URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationRemovePage.java?rev=1160301&view=auto ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationRemovePage.java (added) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationRemovePage.java Mon Aug 22 15:24:28 2011 @@ -0,0 +1,29 @@ +package org.apache.karaf.webconsole.osgi.internal.configuration; + +import org.apache.karaf.webconsole.osgi.internal.OsgiPage; +import org.apache.karaf.webconsole.osgi.internal.configuration.model.ConfigurationModel; +import org.apache.karaf.webconsole.osgi.internal.configuration.view.ConfigurationRemoveForm; +import org.apache.wicket.PageParameters; +import org.apache.wicket.markup.html.basic.Label; +import org.ops4j.pax.wicket.api.PaxWicketBean; +import org.ops4j.pax.wicket.api.PaxWicketMountPoint; +import org.osgi.service.cm.ConfigurationAdmin; + +/** + * Configuration remove page. + */ +@PaxWicketMountPoint(mountPoint = "/osgi/configuration/remove") +public class ConfigurationRemovePage extends OsgiPage { + + @PaxWicketBean(name = "configurationAdmin") + private ConfigurationAdmin configurationAdmin; + private String pid; + + public ConfigurationRemovePage(PageParameters params) { + pid = params.getString("pid"); + + add(new Label("pid", pid)); + add(new ConfigurationRemoveForm("remove", new ConfigurationModel(pid, configurationAdmin))); + } + +} Modified: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsPage.java URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsPage.java?rev=1160301&r1=1160300&r2=1160301&view=diff ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsPage.java (original) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsPage.java Mon Aug 22 15:24:28 2011 @@ -1,23 +1,9 @@ package org.apache.karaf.webconsole.osgi.internal.configuration; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - import org.apache.karaf.webconsole.osgi.internal.OsgiPage; -import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; -import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn; -import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable; -import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; -import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn; +import org.apache.karaf.webconsole.osgi.internal.configuration.view.ConfigurationstDataTable; import org.apache.wicket.markup.html.CSSPackageResource; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.repeater.Item; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.Model; import org.ops4j.pax.wicket.api.PaxWicketBean; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.service.cm.Configuration; import org.osgi.service.cm.ConfigurationAdmin; public class ConfigurationsPage extends OsgiPage { @@ -28,33 +14,8 @@ public class ConfigurationsPage extends public ConfigurationsPage() { add(CSSPackageResource.getHeaderContribution(ConfigurationsPage.class, "configurations.css")); - Configuration[] configurations = new Configuration[0]; - try { - configurations = configurationAdmin.listConfigurations(null); - } catch (IOException e) { - } catch (InvalidSyntaxException e) { - e.printStackTrace(); - } - final boolean empty = configurations.length == 0; - - IModel<String> pid = Model.of("pid"); - - List<IColumn<Configuration>> columns = new ArrayList<IColumn<Configuration>>(); - columns.add(new PropertyColumn<Configuration>(pid, "pid")); - columns.add(new AbstractColumn<Configuration>(Model.of("operations")) { - public void populateItem(Item<ICellPopulator<Configuration>> cellItem, String componentId, IModel<Configuration> model) { - cellItem.add(new ConfigurationsActionPanel(componentId, model)); - } - }); - - add(new DefaultDataTable<Configuration>("configurations", columns, new ConfigurationProvider(configurations), 20)); - - add(new Label("noData", "No configuration found. " + (configurationAdmin == null ? "Configuration Admin not found" : "")) { - @Override - public boolean isVisible() { - return empty; - } - }); + add(new ConfigurationstDataTable("configurations", new ConfigurationProvider(configurationAdmin), 20)); + } } Added: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/AbstractConfigurationModel.java URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/AbstractConfigurationModel.java?rev=1160301&view=auto ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/AbstractConfigurationModel.java (added) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/AbstractConfigurationModel.java Mon Aug 22 15:24:28 2011 @@ -0,0 +1,20 @@ +package org.apache.karaf.webconsole.osgi.internal.configuration.model; + +import org.apache.wicket.model.LoadableDetachableModel; +import org.osgi.service.cm.ConfigurationAdmin; + +/** + * Base class for configuration models. + */ +public abstract class AbstractConfigurationModel<T> extends LoadableDetachableModel<T> { + + /** + * Configuration admin. + */ + protected ConfigurationAdmin configurationAdmin; + + public AbstractConfigurationModel(ConfigurationAdmin configurationAdmin) { + this.configurationAdmin = configurationAdmin; + } + +} \ No newline at end of file Added: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ConfigurationModel.java URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ConfigurationModel.java?rev=1160301&view=auto ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ConfigurationModel.java (added) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ConfigurationModel.java Mon Aug 22 15:24:28 2011 @@ -0,0 +1,26 @@ +package org.apache.karaf.webconsole.osgi.internal.configuration.model; + +import java.io.IOException; + +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; + +public class ConfigurationModel extends AbstractConfigurationModel<Configuration> { + + private String pid; + + public ConfigurationModel(String pid, ConfigurationAdmin configurationAdmin) { + super(configurationAdmin); + this.pid = pid; + } + + @Override + protected Configuration load() { + try { + return configurationAdmin.getConfiguration(pid); + } catch (IOException e) { + throw new ConfigurationNotFoundException(pid, e); + } + } + +} Added: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ConfigurationNotFoundException.java URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ConfigurationNotFoundException.java?rev=1160301&view=auto ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ConfigurationNotFoundException.java (added) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ConfigurationNotFoundException.java Mon Aug 22 15:24:28 2011 @@ -0,0 +1,12 @@ +package org.apache.karaf.webconsole.osgi.internal.configuration.model; + +public class ConfigurationNotFoundException extends RuntimeException { + + public ConfigurationNotFoundException(String pid) { + super(pid); + } + + public ConfigurationNotFoundException(String pid, Throwable cause) { + super(pid, cause); + } +} Added: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ConfigurationsModel.java URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ConfigurationsModel.java?rev=1160301&view=auto ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ConfigurationsModel.java (added) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/model/ConfigurationsModel.java Mon Aug 22 15:24:28 2011 @@ -0,0 +1,21 @@ +package org.apache.karaf.webconsole.osgi.internal.configuration.model; + +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; + +public class ConfigurationsModel extends AbstractConfigurationModel<Configuration[]> { + + public ConfigurationsModel(ConfigurationAdmin configurationAdmin) { + super(configurationAdmin); + } + + @Override + protected Configuration[] load() { + try { + return configurationAdmin.listConfigurations(null); + } catch (Exception e) { + throw new ConfigurationNotFoundException(null, e); + } + } + +} Added: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ConfigurationRemoveForm.java URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ConfigurationRemoveForm.java?rev=1160301&view=auto ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ConfigurationRemoveForm.java (added) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ConfigurationRemoveForm.java Mon Aug 22 15:24:28 2011 @@ -0,0 +1,38 @@ +package org.apache.karaf.webconsole.osgi.internal.configuration.view; + +import java.io.IOException; + +import org.apache.karaf.webconsole.osgi.internal.configuration.ConfigurationsPage; +import org.apache.karaf.webconsole.osgi.internal.configuration.model.ConfigurationNotFoundException; +import org.apache.wicket.markup.html.form.Button; +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.form.IFormSubmittingComponent; +import org.apache.wicket.model.IModel; +import org.osgi.service.cm.Configuration; + +/** + * Simple form responsible for removal of the configuration. + */ +public class ConfigurationRemoveForm extends Form<Configuration> { + + public ConfigurationRemoveForm(String id, IModel<Configuration> model) { + super(id, model); + + add(new Button("submit")); + } + + @Override + public void process(IFormSubmittingComponent submittingComponent) { + try { + Configuration cfg = getModelObject(); + String pid = cfg.getPid(); + cfg.delete(); + + getSession().info("Configuration " + pid + " was removed"); + getRequestCycle().setResponsePage(ConfigurationsPage.class); + } catch (IOException e) { + throw new ConfigurationNotFoundException(getModelObject().getPid(), e); + } + } + +} \ No newline at end of file Copied: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ConfigurationsActionPanel.java (from r1160300, karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsActionPanel.java) URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ConfigurationsActionPanel.java?p2=karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ConfigurationsActionPanel.java&p1=karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsActionPanel.java&r1=1160300&r2=1160301&rev=1160301&view=diff ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsActionPanel.java (original) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ConfigurationsActionPanel.java Mon Aug 22 15:24:28 2011 @@ -1,9 +1,11 @@ -package org.apache.karaf.webconsole.osgi.internal.configuration; +package org.apache.karaf.webconsole.osgi.internal.configuration.view; import java.util.Arrays; import java.util.List; import org.apache.karaf.webconsole.core.table.ActionsPanel; +import org.apache.karaf.webconsole.osgi.internal.configuration.ConfigurationEditPage; +import org.apache.karaf.webconsole.osgi.internal.configuration.ConfigurationRemovePage; import org.apache.wicket.PageParameters; import org.apache.wicket.behavior.SimpleAttributeModifier; import org.apache.wicket.markup.html.basic.Label; @@ -24,15 +26,12 @@ class ConfigurationsActionPanel extends PageParameters params = new PageParameters(); params.put("pid", object.getPid()); - Link removeLink = new Link(id) { - @Override - public void onClick() { - } - }; + Link removeLink = new BookmarkablePageLink<ConfigurationEditPage>(id, ConfigurationRemovePage.class, params); removeLink.add(new SimpleAttributeModifier("class", "remove")); removeLink.add(new Label("label", "remove")); Link editLink = new BookmarkablePageLink<ConfigurationEditPage>(id, ConfigurationEditPage.class, params); + removeLink.add(new SimpleAttributeModifier("class", "edit")); editLink.add(new Label("label", "edit")); return Arrays.asList(editLink, removeLink); Added: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ConfigurationstDataTable.java URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ConfigurationstDataTable.java?rev=1160301&view=auto ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ConfigurationstDataTable.java (added) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/ConfigurationstDataTable.java Mon Aug 22 15:24:28 2011 @@ -0,0 +1,43 @@ +package org.apache.karaf.webconsole.osgi.internal.configuration.view; + +import java.util.Arrays; +import java.util.List; + +import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; +import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn; +import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable; +import org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider; +import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn; +import org.apache.wicket.markup.repeater.Item; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; +import org.osgi.service.cm.Configuration; + +public class ConfigurationstDataTable extends DefaultDataTable<Configuration> { + + @SuppressWarnings({"rawtypes", "unchecked"}) + private static List COLUMNS = Arrays.asList( + new PropertyColumn<Configuration>(Model.of("pid"), "pid"), + new AbstractColumn<Configuration>(Model.of("operations")) { + public void populateItem(Item<ICellPopulator<Configuration>> cellItem, String componentId, IModel<Configuration> model) { + cellItem.add(new ConfigurationsActionPanel(componentId, model)); + } + } + ); + + public ConfigurationstDataTable(String id, ISortableDataProvider<Configuration> dataProvider, int rowsPerPage) { + super(id, COLUMNS, dataProvider, rowsPerPage); + } + + @Override + protected Item<Configuration> newRowItem(String id, int index, + IModel<Configuration> model) { + Configuration cfg = model.getObject(); + + if (cfg.getFactoryPid() != null) { + return new FactoryPidItem(id, index, model); + } + + return super.newRowItem(id, index, model); + } +} \ No newline at end of file Added: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/FactoryPidItem.java URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/FactoryPidItem.java?rev=1160301&view=auto ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/FactoryPidItem.java (added) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/configuration/view/FactoryPidItem.java Mon Aug 22 15:24:28 2011 @@ -0,0 +1,21 @@ +package org.apache.karaf.webconsole.osgi.internal.configuration.view; + +import org.apache.wicket.markup.ComponentTag; +import org.apache.wicket.markup.repeater.OddEvenItem; +import org.apache.wicket.model.IModel; +import org.osgi.service.cm.Configuration; + +public class FactoryPidItem extends OddEvenItem<Configuration> { + + public FactoryPidItem(String id, int index, IModel<Configuration> model) { + super(id, index, model); + } + + @Override + protected void onComponentTag(ComponentTag tag) { + super.onComponentTag(tag); + + tag.append("class", "factory", " "); + } + +} Modified: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationEditPage.html URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationEditPage.html?rev=1160301&r1=1160300&r2=1160301&view=diff ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationEditPage.html (original) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationEditPage.html Mon Aug 22 15:24:28 2011 @@ -12,7 +12,7 @@ <form wicket:id="edit"> <input type="text" wicket:id="pid" style="width: 100%" /> - <ul> + <ul style="list-style-type: none;"> <li wicket:id="properties"> <div class="grid_9"> <div class="grid_9"> @@ -22,6 +22,8 @@ </div> </li> </ul> + + <input type="submit" wicket:id="submit" value="Confirm" /> </form> </wicket:extend> </body> Copied: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationRemovePage.html (from r1160300, karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsPage.html) URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationRemovePage.html?p2=karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationRemovePage.html&p1=karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsPage.html&r1=1160300&r2=1160301&rev=1160301&view=diff ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsPage.html (original) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationRemovePage.html Mon Aug 22 15:24:28 2011 @@ -7,13 +7,12 @@ <body> <wicket:extend> - <h1>Configurations</h1> + <h1>Confirm removal of <span wicket:id="pid">org.apache.felix.filemount</span> configuration</h1> - <table wicket:id="configurations" class="dataview" /> - - <wicket:enclosure> - <span wicket:id="noData">Info goes here</span> - </wicket:enclosure> + <form wicket:id="remove"> + Are you sure want to delete this configuration? + <input type="submit" wicket:id="submit" value="Confirm" /> + </form> </wicket:extend> </body> </html> Modified: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsPage.html URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsPage.html?rev=1160301&r1=1160300&r2=1160301&view=diff ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsPage.html (original) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/ConfigurationsPage.html Mon Aug 22 15:24:28 2011 @@ -11,9 +11,6 @@ <table wicket:id="configurations" class="dataview" /> - <wicket:enclosure> - <span wicket:id="noData">Info goes here</span> - </wicket:enclosure> </wicket:extend> </body> </html> Modified: karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/configurations.css URL: http://svn.apache.org/viewvc/karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/configurations.css?rev=1160301&r1=1160300&r2=1160301&view=diff ============================================================================== --- karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/configurations.css (original) +++ karaf/sandbox/pieber/karaf-webconsole/trunk/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/configuration/configurations.css Mon Aug 22 15:24:28 2011 @@ -1,3 +1,7 @@ a.remove { color: red; +} + +.factory { + font-weight: bolder; } \ No newline at end of file