Skip to content

Commit

Permalink
Change single page design, now module links are displayed as tabs. Ad…
Browse files Browse the repository at this point in the history
…d karaf logo in header, next to WebConsole text.

git-svn-id: https://svn.apache.org/repos/asf/karaf/webconsole/trunk@1242787 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
splatch committed Feb 10, 2012
1 parent fa3900a commit 8c0299b
Show file tree
Hide file tree
Showing 26 changed files with 375 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public class DefaultBrandProvider implements BrandProvider, Serializable /* for
private static final long serialVersionUID = 1L;

public Image getHeaderImage(String imageId) {
Image image = new Image(imageId, new ResourceReference(BasePage.class, "images/karaf-logo.png"));
image.add(new SimpleAttributeModifier("width", "150"));
image.add(new SimpleAttributeModifier("height", "70"));
Image image = new Image(imageId, new ResourceReference(BasePage.class, "images/karaf-logo-min.png"));
image.add(new SimpleAttributeModifier("width", "148"));
image.add(new SimpleAttributeModifier("height", "40"));
image.add(new SimpleAttributeModifier("alt", "Karaf logo"));
image.add(new SimpleAttributeModifier("title", "Karaf logo"));
return image;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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.conventer;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.Locale;

import org.apache.wicket.util.convert.converters.AbstractConverter;

/**
* URI converter.
*/
public class URIConverter extends AbstractConverter {

private static final long serialVersionUID = 1L;

public Object convertToObject(String value, Locale locale) {
try {
return new URI(value);
} catch (URISyntaxException e) {
throw newConversionException("Illegal syntax: " + e.getReason(), value, locale);
} catch (IllegalArgumentException e) {
throw newConversionException("Invalid argument: " + e.getMessage(), value, locale);
}
}

@Override
protected Class<?> getTargetType() {
return URI.class;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.conventer;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;

import org.apache.wicket.util.convert.IConverter;
import org.apache.wicket.util.convert.converters.AbstractConverter;

/**
* URI converter.
*/
public class URLConverter extends AbstractConverter implements IConverter {

private static final long serialVersionUID = 1L;

public Object convertToObject(String value, Locale locale) {
try {
return new URL(value);
} catch (MalformedURLException e) {
throw newConversionException("Invalid syntax " + e.getMessage(), value, locale);
}
}

@Override
protected Class<?> getTargetType() {
return URL.class;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.conventer;

import java.net.URI;
import java.net.URL;

import org.apache.wicket.util.convert.ConverterLocator;

/**
* An extension of wicket base {@link ConverterLocator} which supports common
* types used in Java.
*/
public class WebConsoleConverterLocator extends ConverterLocator {

private static final long serialVersionUID = 1L;

public WebConsoleConverterLocator() {
set(URI.class, new URIConverter());
set(URL.class, new URLConverter());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,47 @@
*/
package org.apache.karaf.webconsole.core.form;

import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.border.Border;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

public class LabelBorder extends Border {

private static final long serialVersionUID = 1L;
private final FormComponent<?> component;

public LabelBorder(String id, IModel<?> model) {
super(id, model);
public LabelBorder(String id, String fieldLabel, FormComponent<?> component) {
this(id, Model.of(fieldLabel), component);
}

public LabelBorder(String id) {
public LabelBorder(String id, IModel<?> fieldLabel, FormComponent<?> component) {
super(id);
this.component = component;
getBodyContainer().add(component);

add(new Label("label", fieldLabel).setRenderBodyOnly(true));
add(new Label("help", ""));
add(new Label("error", ""));
}

public void setHelp(String message) {
addOrReplace(new Label("help", message));
}

public void setHelp(IModel<?> message) {
addOrReplace(new Label("help", message));
}

@Override
protected void onBeforeRender() {
super.onBeforeRender();

if (component.getFeedbackMessage() != null) {
addOrReplace(new Label("error", "" + component.getFeedbackMessage().getMessage()));
add(new AttributeAppender("class", Model.of("error"), " "));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.util.Map;

import org.apache.wicket.Component;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.CompoundPropertyModel;
Expand Down Expand Up @@ -50,9 +50,11 @@ public MapEditForm(String id, CompoundPropertyModel<Map<K, V>> model) {

@SuppressWarnings("unchecked")
protected Component populateItem(String componentId, K key, IModel<V> value) {
LabelBorder border = new LabelBorder(componentId);
border.add(new Label("label", "" + key));
border.add(new TextField<V>("value", value, (Class<V>) value.getObject().getClass()));
FormComponent<V> field = new TextField<V>("value", value, (Class<V>) value.getObject().getClass());
LabelBorder border = new LabelBorder(componentId, ""+ key, field);
// border.add(new Label("label", "" + key));
// border.add();
border.setHelp("Value for " + key);
return border;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
*/
package org.apache.karaf.webconsole.core.internal;

import org.apache.karaf.webconsole.core.conventer.WebConsoleConverterLocator;
import org.apache.karaf.webconsole.core.dashboard.DashboardPage;
import org.apache.karaf.webconsole.core.page.LoginPage;
import org.apache.karaf.webconsole.core.security.HierarchicalRoleCheckingStrategy;
import org.apache.karaf.webconsole.core.security.KarafJaasWebSession;
import org.apache.wicket.IConverterLocator;
import org.apache.wicket.authentication.AuthenticatedWebApplication;
import org.apache.wicket.authentication.AuthenticatedWebSession;
import org.apache.wicket.authorization.strategies.role.RoleAuthorizationStrategy;
Expand Down Expand Up @@ -51,6 +53,11 @@ protected void init() {
getMarkupSettings().setStripWicketTags(true);
}

@Override
protected IConverterLocator newConverterLocator() {
return new WebConsoleConverterLocator();
}

/**
* @see org.apache.wicket.Application#getHomePage()
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
*/
public class ExtendableConsoleTabProvider implements ConsoleTabProvider {

private static final long serialVersionUID = 1L;

private Collection<NavigationProvider> extensions;
private ConsoleTabProvider base;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
*/
public class ExtendableSidebarProvider implements SidebarProvider {

private static final long serialVersionUID = 1L;

private Collection<NavigationProvider> navigationProviders;
private Collection<WidgetProvider> widgetProviders;
private SidebarProvider base;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.karaf.webconsole.core.navigation;

import java.io.Serializable;
import java.util.List;

import org.apache.wicket.Page;
Expand All @@ -26,7 +25,7 @@
* Base extension point in console. Allow suppliers to ship new navigation
* elements which points to new wicket pages.
*/
public interface NavigationProvider extends Serializable {
public interface NavigationProvider {

/**
* Return list of links to pages to add in navigation.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* 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.navigation.markup;

import java.util.List;
Expand All @@ -11,6 +27,9 @@
import org.apache.wicket.model.IModel;
import org.ops4j.pax.wicket.api.PaxWicketBean;

/**
* Top panel displayed to non authorized users.
*/
public class AnonymousTopPanel extends Panel {

private static final long serialVersionUID = 1L;
Expand All @@ -22,9 +41,8 @@ public AnonymousTopPanel(String id, IModel<List<Locale>> locales) {
super(id, locales);

Link<DashboardPage> homeLink = new BookmarkablePageLink<DashboardPage>("homeLink", DashboardPage.class);
//homeLink.add(brandProvider.getHeaderImage("logo"));
add(homeLink);
add(brandProvider.getHeaderImage("logo"));
add(homeLink);
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* 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.navigation.markup;

import java.util.List;
Expand All @@ -13,6 +29,9 @@
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;

/**
* Top panel which allows to switch session language.
*/
public class LanguageTopPanel extends AnonymousTopPanel {

private static final long serialVersionUID = 1L;
Expand Down
Loading

0 comments on commit 8c0299b

Please sign in to comment.