Author: ldywicki Date: Sun Feb 19 20:13:16 2012 New Revision: 1291052 URL: http://svn.apache.org/viewvc?rev=1291052&view=rev Log: Refactor of osgi/core module: - restructured list of bundles with new icons instead of labels - separate links for every operation instead of annonymous classes inside BundleActionsPanel - first translations
Added: karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/ karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/RefreshLink.java karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/ResolveLink.java karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/StartLink.java karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/StopLink.java karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/UninstallLink.java karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/UpdateLink.java karaf/webconsole/trunk/osgi/core/src/main/resources/org/apache/karaf/webconsole/osgi/core/package.properties Removed: karaf/webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/page/SecuredPage.properties karaf/webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/page/SecuredPage_fr.properties Modified: karaf/webconsole/trunk/core/src/main/java/org/apache/karaf/webconsole/core/table/ActionsPanel.java karaf/webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/table/ActionsPanel.html karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/BundleActionsPanel.java karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/BundlePage.java karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/DecorationPanel.java karaf/webconsole/trunk/osgi/core/src/main/resources/org/apache/karaf/webconsole/osgi/core/bundle/list/BundlePage.html Modified: karaf/webconsole/trunk/core/src/main/java/org/apache/karaf/webconsole/core/table/ActionsPanel.java URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/core/src/main/java/org/apache/karaf/webconsole/core/table/ActionsPanel.java?rev=1291052&r1=1291051&r2=1291052&view=diff ============================================================================== --- karaf/webconsole/trunk/core/src/main/java/org/apache/karaf/webconsole/core/table/ActionsPanel.java (original) +++ karaf/webconsole/trunk/core/src/main/java/org/apache/karaf/webconsole/core/table/ActionsPanel.java Sun Feb 19 20:13:16 2012 @@ -64,4 +64,13 @@ public class ActionsPanel<T> extends Pan return Collections.emptyList(); } + /** + * Gets model + * + * @return model + */ + @SuppressWarnings("unchecked") + public final IModel<T> getModel() { + return (IModel<T>) getDefaultModel(); + } } Modified: karaf/webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/table/ActionsPanel.html URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/table/ActionsPanel.html?rev=1291052&r1=1291051&r2=1291052&view=diff ============================================================================== --- karaf/webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/table/ActionsPanel.html (original) +++ karaf/webconsole/trunk/core/src/main/resources/org/apache/karaf/webconsole/core/table/ActionsPanel.html Sun Feb 19 20:13:16 2012 @@ -20,7 +20,7 @@ <ul> <li wicket:id="actions"> <a wicket:id="action"> - <span wicket:id="label">label</span> + <span wicket:id="label"></span> </a> </li> </ul> Modified: karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/BundleActionsPanel.java URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/BundleActionsPanel.java?rev=1291052&r1=1291051&r2=1291052&view=diff ============================================================================== --- karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/BundleActionsPanel.java (original) +++ karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/BundleActionsPanel.java Sun Feb 19 20:13:16 2012 @@ -21,19 +21,19 @@ import java.util.List; import org.apache.karaf.webconsole.core.table.ActionsPanel; import org.apache.karaf.webconsole.osgi.core.bundle.SingleBundlePage; +import org.apache.karaf.webconsole.osgi.core.bundle.list.link.RefreshLink; +import org.apache.karaf.webconsole.osgi.core.bundle.list.link.ResolveLink; +import org.apache.karaf.webconsole.osgi.core.bundle.list.link.StartLink; +import org.apache.karaf.webconsole.osgi.core.bundle.list.link.StopLink; +import org.apache.karaf.webconsole.osgi.core.bundle.list.link.UninstallLink; +import org.apache.karaf.webconsole.osgi.core.bundle.list.link.UpdateLink; import org.apache.karaf.webconsole.osgi.core.shared.State; import org.apache.karaf.webconsole.osgi.core.spi.IActionProvider; -import org.apache.wicket.PageParameters; -import org.apache.wicket.RequestCycle; -import org.apache.wicket.Session; +import org.apache.wicket.behavior.SimpleAttributeModifier; import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.link.BookmarkablePageLink; import org.apache.wicket.markup.html.link.Link; import org.apache.wicket.model.IModel; -import org.ops4j.pax.wicket.api.PaxWicketBean; import org.osgi.framework.Bundle; -import org.osgi.framework.BundleException; -import org.osgi.service.packageadmin.PackageAdmin; /** * Action panel for bundles list. @@ -41,8 +41,7 @@ import org.osgi.service.packageadmin.Pac @SuppressWarnings("rawtypes") public class BundleActionsPanel extends ActionsPanel<Bundle> { - @PaxWicketBean(name = "packageAdmin") - private PackageAdmin admin; + private static final long serialVersionUID = 1L; public BundleActionsPanel(String componentId, final IModel<Bundle> model, List<IActionProvider> actionProviders) { super(componentId, model); @@ -59,14 +58,11 @@ public class BundleActionsPanel extends @Override protected List<Link> getLinks(Bundle object, String linkId, String labelId) { - PageParameters params = new PageParameters(); - params.put("bundleId", object.getBundleId()); - List<Link> links = new ArrayList<Link>(); // details link - Link link = new BookmarkablePageLink<SingleBundlePage>(linkId, SingleBundlePage.class, params); - link.add(new Label("label", "Details")); + Link link = SingleBundlePage.createLink(linkId, object); + link.add(new Label("label", "").add(new SimpleAttributeModifier("class", "icon-info-sign"))); links.add(link); @@ -75,90 +71,54 @@ public class BundleActionsPanel extends links.add(createStopLink(linkId, labelId)); break; case INSTALLED: + // here we do not have break, because start operation will try to + // resolve imports too + links.add(createResolveLink(linkId, labelId)); case RESOLVED: links.add(createStartLink(linkId, labelId)); } links.add(createRefreshLink(linkId, labelId)); + links.add(createUpdateLink(linkId, labelId)); links.add(createUninstallLink(linkId, labelId)); return links; } private Link createUninstallLink(String linkId, String labelId) { - Link link = new Link(linkId) { - @Override - public void onClick() { - Bundle bundle = (Bundle) BundleActionsPanel.this.getDefaultModelObject(); - - try { - bundle.uninstall(); - - Session.get().info("Bundle " + bundle.getSymbolicName() + " uninstalled"); - RequestCycle.get().setResponsePage(BundlePage.class); - } catch (BundleException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - }; - link.add(new Label(labelId, "Uninstall")); + Link link = new UninstallLink(linkId, getModel()); + link.add(new Label(labelId, "").add(new SimpleAttributeModifier("class", "icon-eject"))); return link; } private Link createRefreshLink(String linkId, String labelId) { - Link link = new Link(linkId) { - @Override - public void onClick() { - Bundle bundle = (Bundle) BundleActionsPanel.this.getDefaultModelObject(); + Link link = new RefreshLink(linkId, getModel()); + link.add(new Label(labelId, "").add(new SimpleAttributeModifier("class", "icon-refresh"))); + return link; + } - admin.refreshPackages(new Bundle[] {bundle}); - Session.get().info("Bundle " + bundle.getSymbolicName() + " refreshed"); - RequestCycle.get().setResponsePage(BundlePage.class); - } - - }; - link.add(new Label(labelId, "Refresh")); + private Link createUpdateLink(String linkId, String labelId) { + Link link = new UpdateLink(linkId, getModel()); + //link.add(new SimpleAttributeModifier("title", getLocalizer().getString("bundle.update.link", this, getModel()))); + link.add(new Label(labelId, "").add(new SimpleAttributeModifier("class", "icon-retweet"))); return link; } - private Link createStartLink(String linkId, String labelId) { - Link link = new Link(linkId) { - @Override - public void onClick() { - Bundle bundle = (Bundle) BundleActionsPanel.this.getDefaultModelObject(); + private Link createResolveLink(String linkId, String labelId) { + Link link = new ResolveLink(linkId, getModel()); + link.add(new Label(labelId, "").add(new SimpleAttributeModifier("class", "icon-step-forward"))); + return link; + } - try { - bundle.start(); - Session.get().info("Bundle " + bundle.getSymbolicName() + " started"); - RequestCycle.get().setResponsePage(BundlePage.class); - } catch (BundleException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - }; - link.add(new Label(labelId, "Start")); + private Link createStartLink(String linkId, String labelId) { + Link link = new StartLink(linkId, getModel()); + link.add(new Label(labelId, "").add(new SimpleAttributeModifier("class", "icon-play"))); return link; } private Link createStopLink(String linkId, String labelId) { - Link link = new Link(linkId) { - public void onClick() { - Bundle bundle = (Bundle) BundleActionsPanel.this.getDefaultModelObject(); - try { - bundle.stop(); - Session.get().info("Bundle " + bundle.getSymbolicName() + " stopped"); - RequestCycle.get().setResponsePage(BundlePage.class); - } catch (BundleException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }; - link.add(new Label(labelId, "Stop")); + Link link = new StopLink(linkId, getModel()); + link.add(new Label(labelId, "").add(new SimpleAttributeModifier("class", "icon-pause"))); return link; } } Modified: karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/BundlePage.java URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/BundlePage.java?rev=1291052&r1=1291051&r2=1291052&view=diff ============================================================================== --- karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/BundlePage.java (original) +++ karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/BundlePage.java Sun Feb 19 20:13:16 2012 @@ -44,6 +44,9 @@ import org.ops4j.pax.wicket.api.PaxWicke import org.osgi.framework.Bundle; import org.osgi.service.startlevel.StartLevel; +/** + * Bundle list page. + */ @PaxWicketMountPoint(mountPoint = "/osgi/bundle") public class BundlePage extends OsgiPage { @@ -62,18 +65,24 @@ public class BundlePage extends OsgiPage public BundlePage() { List<IColumn<Bundle>> columns = new ArrayList<IColumn<Bundle>>(); columns.add(new AbstractColumn<Bundle>(of("")) { + private static final long serialVersionUID = 1L; + public void populateItem(Item<ICellPopulator<Bundle>> cellItem, final String componentId, final IModel<Bundle> rowModel) { cellItem.add(new DecorationPanel(componentId, rowModel, decorationProviders)); } }); columns.add(new PropertyColumnExt<Bundle>("Bundle Id", "bundleId")); columns.add(new AbstractColumn<Bundle>(of("State")) { + private static final long serialVersionUID = 1L; + public void populateItem(Item<ICellPopulator<Bundle>> cellItem, final String componentId, final IModel<Bundle> rowModel) { cellItem.add(new Label(componentId, State.of(rowModel.getObject().getState()).name())); } }); columns.add(new AbstractColumn<Bundle>(of("Start level")) { + private static final long serialVersionUID = 1L; + public void populateItem(Item<ICellPopulator<Bundle>> cellItem, final String componentId, final IModel<Bundle> rowModel) { cellItem.add(new Label(componentId, of(startLevel.getBundleStartLevel(rowModel.getObject())))); } @@ -87,6 +96,8 @@ public class BundlePage extends OsgiPage columns.add(new PropertyColumnExt<Bundle>("Name", "symbolicName")); columns.add(new PropertyColumnExt<Bundle>("Version", "version.toString")); columns.add(new AbstractColumn<Bundle>(Model.of("Operations")) { + private static final long serialVersionUID = 1L; + public void populateItem(Item<ICellPopulator<Bundle>> cellItem, final String componentId, final IModel<Bundle> rowModel) { cellItem.add(new BundleActionsPanel(componentId, rowModel, actionProviders)); } Modified: karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/DecorationPanel.java URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/DecorationPanel.java?rev=1291052&r1=1291051&r2=1291052&view=diff ============================================================================== --- karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/DecorationPanel.java (original) +++ karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/DecorationPanel.java Sun Feb 19 20:13:16 2012 @@ -30,6 +30,8 @@ import org.osgi.framework.Bundle; public class DecorationPanel extends Panel { + private static final long serialVersionUID = 1L; + public DecorationPanel(String id, IModel<Bundle> model, List<IDecorationProvider> decorationProviders) { super(id, model); Added: karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/RefreshLink.java URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/RefreshLink.java?rev=1291052&view=auto ============================================================================== --- karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/RefreshLink.java (added) +++ karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/RefreshLink.java Sun Feb 19 20:13:16 2012 @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.karaf.webconsole.osgi.core.bundle.list.link; + +import org.apache.karaf.webconsole.osgi.core.bundle.list.BundlePage; +import org.apache.wicket.RequestCycle; +import org.apache.wicket.Session; +import org.apache.wicket.authorization.Action; +import org.apache.wicket.authorization.strategies.role.annotations.AuthorizeAction; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; +import org.ops4j.pax.wicket.api.PaxWicketBean; +import org.osgi.framework.Bundle; +import org.osgi.service.packageadmin.PackageAdmin; + +/** + * Bundle refresh link. + */ +@AuthorizeAction(action = Action.RENDER, roles = {"admin"}) +public class RefreshLink extends Link<Bundle> { + + private static final long serialVersionUID = 1L; + + @PaxWicketBean(name = "packageAdmin") + private PackageAdmin admin; + + public RefreshLink(String id, IModel<Bundle> model) { + super(id, model); + } + + @Override + public void onClick() { + Bundle bundle = getModelObject(); + + try { + admin.refreshPackages(new Bundle[] { bundle }); + Session.get().info(getLocalizer().getString("bundle.refresh", this, getModel())); + } catch (Exception e) { + Session.get().info(getLocalizer().getString("bundle.refresh.fail", this, Model.of(e))); + } + RequestCycle.get().setResponsePage(BundlePage.class); + } + +} Added: karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/ResolveLink.java URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/ResolveLink.java?rev=1291052&view=auto ============================================================================== --- karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/ResolveLink.java (added) +++ karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/ResolveLink.java Sun Feb 19 20:13:16 2012 @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.karaf.webconsole.osgi.core.bundle.list.link; + +import org.apache.karaf.webconsole.osgi.core.bundle.list.BundlePage; +import org.apache.wicket.RequestCycle; +import org.apache.wicket.Session; +import org.apache.wicket.authorization.Action; +import org.apache.wicket.authorization.strategies.role.annotations.AuthorizeAction; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; +import org.ops4j.pax.wicket.api.PaxWicketBean; +import org.osgi.framework.Bundle; +import org.osgi.service.packageadmin.PackageAdmin; + +/** + * Bundle resolve link. + */ +@AuthorizeAction(action = Action.RENDER, roles = {"admin"}) +public class ResolveLink extends Link<Bundle> { + + private static final long serialVersionUID = 1L; + + @PaxWicketBean(name = "packageAdmin") + private PackageAdmin admin; + + public ResolveLink(String id, IModel<Bundle> model) { + super(id, model); + } + + @Override + public void onClick() { + Bundle bundle = getModelObject(); + + try { + admin.resolveBundles(new Bundle[] { bundle }); + Session.get().info(getLocalizer().getString("bundle.resolve", this, getModel())); + } catch (Exception e) { + Session.get().info(getLocalizer().getString("bundle.resolve.fail", this, Model.of(e))); + } + RequestCycle.get().setResponsePage(BundlePage.class); + } +} Added: karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/StartLink.java URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/StartLink.java?rev=1291052&view=auto ============================================================================== --- karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/StartLink.java (added) +++ karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/StartLink.java Sun Feb 19 20:13:16 2012 @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.karaf.webconsole.osgi.core.bundle.list.link; + +import org.apache.karaf.webconsole.osgi.core.bundle.list.BundlePage; +import org.apache.wicket.RequestCycle; +import org.apache.wicket.Session; +import org.apache.wicket.authorization.Action; +import org.apache.wicket.authorization.strategies.role.annotations.AuthorizeAction; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleException; + +/** + * Bundle start link. + */ +@AuthorizeAction(action = Action.RENDER, roles = {"admin"}) +public class StartLink extends Link<Bundle> { + + private static final long serialVersionUID = 1L; + + public StartLink(String id, IModel<Bundle> model) { + super(id, model);} + + @Override + public void onClick() { + Bundle bundle = getModelObject(); + + try { + bundle.start(); + Session.get().info(getLocalizer().getString("bundle.start", this, getModel())); + } catch (BundleException e) { + Session.get().error(getLocalizer().getString("bundle.start.fail", this, Model.of(e))); + } + RequestCycle.get().setResponsePage(BundlePage.class); + } + +} Added: karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/StopLink.java URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/StopLink.java?rev=1291052&view=auto ============================================================================== --- karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/StopLink.java (added) +++ karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/StopLink.java Sun Feb 19 20:13:16 2012 @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.karaf.webconsole.osgi.core.bundle.list.link; + +import org.apache.karaf.webconsole.osgi.core.bundle.list.BundlePage; +import org.apache.wicket.RequestCycle; +import org.apache.wicket.Session; +import org.apache.wicket.authorization.Action; +import org.apache.wicket.authorization.strategies.role.annotations.AuthorizeAction; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleException; + +/** + * Bundle stop link. + */ +@AuthorizeAction(action = Action.RENDER, roles = {"admin"}) +public class StopLink extends Link<Bundle> { + + private static final long serialVersionUID = 1L; + + public StopLink(String id, IModel<Bundle> model) { + super(id, model);} + + @Override + public void onClick() { + Bundle bundle = getModelObject(); + + try { + bundle.stop(); + Session.get().info(getLocalizer().getString("bundle.stop", this, getModel())); + } catch (BundleException e) { + Session.get().error(getLocalizer().getString("bundle.stop.fail", this, Model.of(e))); + } + RequestCycle.get().setResponsePage(BundlePage.class); + } + +} Added: karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/UninstallLink.java URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/UninstallLink.java?rev=1291052&view=auto ============================================================================== --- karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/UninstallLink.java (added) +++ karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/UninstallLink.java Sun Feb 19 20:13:16 2012 @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.karaf.webconsole.osgi.core.bundle.list.link; + +import org.apache.karaf.webconsole.osgi.core.bundle.list.BundlePage; +import org.apache.wicket.RequestCycle; +import org.apache.wicket.Session; +import org.apache.wicket.authorization.Action; +import org.apache.wicket.authorization.strategies.role.annotations.AuthorizeAction; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleException; + +/** + * Bundle uninstallation link. + */ +@AuthorizeAction(action = Action.RENDER, roles = {"admin"}) +public class UninstallLink extends Link<Bundle> { + + private static final long serialVersionUID = 1L; + + public UninstallLink(String id, IModel<Bundle> model) { + super(id, model);} + + @Override + public void onClick() { + Bundle bundle = getModelObject(); + + try { + bundle.uninstall(); + Session.get().info(getLocalizer().getString("bundle.uninstall", this, getModel())); + } catch (BundleException e) { + Session.get().error(getLocalizer().getString("bundle.uninstall.fail", this, Model.of(e))); + } + RequestCycle.get().setResponsePage(BundlePage.class); + } + +} Added: karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/UpdateLink.java URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/UpdateLink.java?rev=1291052&view=auto ============================================================================== --- karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/UpdateLink.java (added) +++ karaf/webconsole/trunk/osgi/core/src/main/java/org/apache/karaf/webconsole/osgi/core/bundle/list/link/UpdateLink.java Sun Feb 19 20:13:16 2012 @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.karaf.webconsole.osgi.core.bundle.list.link; + +import org.apache.karaf.webconsole.osgi.core.bundle.list.BundlePage; +import org.apache.wicket.RequestCycle; +import org.apache.wicket.Session; +import org.apache.wicket.authorization.Action; +import org.apache.wicket.authorization.strategies.role.annotations.AuthorizeAction; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleException; + +/** + * Bundle update link. + */ +@AuthorizeAction(action = Action.RENDER, roles = {"admin"}) +public class UpdateLink extends Link<Bundle> { + + private static final long serialVersionUID = 1L; + + public UpdateLink(String id, IModel<Bundle> model) { + super(id, model); + } + + @Override + public void onClick() { + Bundle bundle = getModelObject(); + + try { + bundle.update(); + Session.get().info(getLocalizer().getString("bundle.update", this, getModel())); + } catch (BundleException e) { + Session.get().error(getLocalizer().getString("bundle.update.fail", this, Model.of(e))); + } + RequestCycle.get().setResponsePage(BundlePage.class); + } + +} Modified: karaf/webconsole/trunk/osgi/core/src/main/resources/org/apache/karaf/webconsole/osgi/core/bundle/list/BundlePage.html URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/osgi/core/src/main/resources/org/apache/karaf/webconsole/osgi/core/bundle/list/BundlePage.html?rev=1291052&r1=1291051&r2=1291052&view=diff ============================================================================== --- karaf/webconsole/trunk/osgi/core/src/main/resources/org/apache/karaf/webconsole/osgi/core/bundle/list/BundlePage.html (original) +++ karaf/webconsole/trunk/osgi/core/src/main/resources/org/apache/karaf/webconsole/osgi/core/bundle/list/BundlePage.html Sun Feb 19 20:13:16 2012 @@ -17,12 +17,12 @@ --> <wicket:extend xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"> <div class="row-fluid"> - <h1 class="pull-left">Bundles</h1> + <h1 class="pull-left"><wicket:message key="bundle" /></h1> <div class="btn-group pull-right"> <a class="btn btn-primary" wicket:id="install"> <i class="icon-plus icon-white"></i> - Install bundle + <wicket:message key="bundle.install" /> </a> </div> </div> Added: karaf/webconsole/trunk/osgi/core/src/main/resources/org/apache/karaf/webconsole/osgi/core/package.properties URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/osgi/core/src/main/resources/org/apache/karaf/webconsole/osgi/core/package.properties?rev=1291052&view=auto ============================================================================== --- karaf/webconsole/trunk/osgi/core/src/main/resources/org/apache/karaf/webconsole/osgi/core/package.properties (added) +++ karaf/webconsole/trunk/osgi/core/src/main/resources/org/apache/karaf/webconsole/osgi/core/package.properties Sun Feb 19 20:13:16 2012 @@ -0,0 +1,35 @@ + # Licensed to the Apache Software Foundation (ASF) under one or more + # contributor license agreements. See the NOTICE file distributed with + # this work for additional information regarding copyright ownership. + # The ASF licenses this file to You 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. + +bundle Bundle +bundle.install Install new bundle + +bundle.start Bundle $\{symbolicName\} ($\{bundleId\}) started +bundle.start.fail Can not start bundle, exception occured ${message} + +bundle.stop Bundle $\{symbolicName\} ($\{bundleId\}) stopped +bundle.stop.fail Can not stop bundle, exception occured ${message} + +bundle.update Bundle $\{symbolicName\} ($\{bundleId\}) updated +bundle.update.fail Can not update bundle: ${message} + +bundle.uninstall Bundle $\{symbolicName\} ($\{bundleId\}) uninstalled +bundle.uninstall.fail Can not uninstall bundle, exception occured ${message} + +bundle.refresh Bundle $\{symbolicName\} ($\{bundleId\}) refreshed +bundle.refresh.fail Bundle refresh fail: ${message} + +bundle.resolve Bundle $\{symbolicName\} ($\{bundleId\}) resolved +bundle.resolve.fail Bundle resolving error: ${message} \ No newline at end of file