Permalink
Browse files

KARAF-1784 Provide additional actions for blueprint-enabled bundles

Signed-off-by: Lukasz Dywicki <luke@code-house.org>

git-svn-id: https://svn.apache.org/repos/asf/karaf/webconsole/trunk@1379103 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent e48a9d6 commit 00bd37be32f1b87ae64147ffdf7450f964ddab5a @splatch splatch committed Aug 30, 2012
@@ -0,0 +1,32 @@
+/*
+ * 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.core.panel;
+
+import org.apache.wicket.markup.html.panel.Panel;
+
+/**
+ * Simple panel with one link inside.
+ */
+public class SingleLinkPanel extends Panel {
+
+ private static final long serialVersionUID = 1L;
+
+ public SingleLinkPanel(String id) {
+ super(id);
+ }
+
+}
@@ -22,6 +22,7 @@
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.protocol.http.RequestUtils;
import org.apache.wicket.request.cycle.RequestCycle;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
/**
* Utility class to create links.
@@ -39,9 +40,25 @@
* @param page Page class to link.
* @return Bookmarkable link.
*/
- @SuppressWarnings({"rawtypes", "unchecked"})
public static <T extends Page> Link<Page> createPageLink(String linkId, String labelId, String label, Class<T> page) {
- Link link = new BookmarkablePageLink<T>(linkId, page);
+ return createPageLink(linkId, labelId, label, page, new PageParameters());
+ }
+
+ /**
+ * Creates bookmarkable page link with given page class and parameters.
+ *
+ * @param <T> Type of page.
+ *
+ * @param linkId Link element id.
+ * @param labelId Inner link element label.
+ * @param label Text label.
+ * @param page Page class to link.
+ * @param params Page parameters.
+ * @return Bookmarkable link.
+ */
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public static <T extends Page> Link<Page> createPageLink(String linkId, String labelId, String label, Class<T> page, PageParameters params) {
+ Link link = new BookmarkablePageLink<T>(linkId, page, params);
link.add(new Label(labelId, label));
return link;
}
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<wicket:panel xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+ <a wicket:id="link">
+ <span wicket:id="label" />
+ </a>
+ <wicket:child />
+</wicket:panel>
@@ -0,0 +1,50 @@
+/*
+ * 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.blueprint.bundle;
+
+import org.apache.karaf.webconsole.core.panel.SingleLinkPanel;
+import org.apache.karaf.webconsole.core.util.LinkUtils;
+import org.apache.karaf.webconsole.osgi.blueprint.IBlueprintBundleStateTracker;
+import org.apache.karaf.webconsole.osgi.blueprint.details.DetailsPage;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.ops4j.pax.wicket.api.PaxWicketBean;
+import org.osgi.framework.Bundle;
+
+public class BlueprintActionPanel extends SingleLinkPanel {
+
+ private static final long serialVersionUID = 1L;
+
+ @PaxWicketBean(name = "tracker")
+ private IBlueprintBundleStateTracker tracker;
+
+ public BlueprintActionPanel(String componentId, IModel<Bundle> model) {
+ super(componentId);
+ setDefaultModel(model);
+
+ Bundle bundle = model.getObject();
+ if (tracker.getState(model.getObject()) == null) {
+ setVisible(false);
+ return;
+ }
+
+ PageParameters params = new PageParameters();
+ params.add("bundleId", bundle.getBundleId());
+ add(LinkUtils.createPageLink("link", "label", "Manage blueprint", DetailsPage.class, params));
+ }
+
+}
@@ -16,32 +16,18 @@
*/
package org.apache.karaf.webconsole.osgi.blueprint.bundle;
-import org.apache.karaf.webconsole.osgi.blueprint.IBlueprintBundleStateTracker;
-import org.apache.karaf.webconsole.osgi.blueprint.details.DetailsPage;
+import org.apache.karaf.webconsole.osgi.core.shared.BundleModel;
import org.apache.karaf.webconsole.osgi.core.spi.IActionProvider;
import org.apache.wicket.Component;
-import org.apache.wicket.markup.html.link.BookmarkablePageLink;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.osgi.framework.Bundle;
/**
* Action provider for blueprint.
*/
public class BlueprintActionProvider implements IActionProvider {
- private IBlueprintBundleStateTracker tracker;
-
- public BlueprintActionProvider(IBlueprintBundleStateTracker tracker) {
- this.tracker = tracker;
- }
-
- public Component create(String componentId, Bundle model) {
- PageParameters params = new PageParameters();
- params.add("bundleId", model.getBundleId());
- BookmarkablePageLink link = new BookmarkablePageLink(componentId, DetailsPage.class, params);
- link.setModel(Model.of("Blueprint"));
- return link;
+ public Component create(String componentId, Bundle bundle) {
+ return new BlueprintActionPanel(componentId, new BundleModel(bundle));
}
}
@@ -46,8 +46,8 @@ public DetailsPage(PageParameters params) {
IModel<List<ComponentMetadata>> model = new MetadataModel(context, params.get("bundleId").toInt());
add(new ListView<ComponentMetadata>("components", model) {
+
@Override
- @SuppressWarnings("unchecked")
protected void populateItem(ListItem<ComponentMetadata> item) {
ComponentMetadata metadata = item.getModelObject();
item.add(new Label("componentId", metadata.getId()));

0 comments on commit 00bd37b

Please sign in to comment.