Add Locale for FeaturesPage, french and english flags in BasePage
git-svn-id: https://svn.apache.org/repos/asf/karaf/sandbox/pieber/karaf-webconsole/trunk@1157784 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/core/src/main/java/org/apache/karaf/webconsole/core/BasePage.java b/core/src/main/java/org/apache/karaf/webconsole/core/BasePage.java
index d15c0b5..ca9e3fd 100644
--- a/core/src/main/java/org/apache/karaf/webconsole/core/BasePage.java
+++ b/core/src/main/java/org/apache/karaf/webconsole/core/BasePage.java
@@ -1,15 +1,20 @@
package org.apache.karaf.webconsole.core;
-import java.util.Collections;
-import java.util.List;
-
import org.apache.wicket.ResourceReference;
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.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.link.PageLink;
import org.apache.wicket.model.util.ListModel;
import org.ops4j.pax.wicket.api.PaxWicketBean;
+import sun.awt.util.IdentityLinkedList;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
public class BasePage extends WebPage {
@@ -24,6 +29,27 @@
add(new Image("karafLogo", new ResourceReference(BasePage.class, "images/karaf-logo.png")));
+ Link linkFr = new Link("goFrench") {
+ @Override
+ public void onClick() {
+ getSession().setLocale(Locale.FRANCE);
+ }
+ };
+
+ Link linkEn = new Link("goEnglish") {
+ @Override
+ public void onClick() {
+ getSession().setLocale(Locale.ENGLISH);
+ }
+ };
+
+
+ add(linkFr);
+ linkFr.add(new Image("frenchFlag", new ResourceReference(BasePage.class, "images/french-flag.jpeg")));
+
+ add(linkEn);
+ linkEn.add(new Image("englishFlag", new ResourceReference(BasePage.class, "images/english-flag.jpeg")));
+
add(new NavigationPanel("navigationPanel", new ListModel<ConsoleTab>(tabs)));
List<Class> subPages = getSubPages();
diff --git a/core/src/main/java/org/apache/karaf/webconsole/core/BasePage2.java b/core/src/main/java/org/apache/karaf/webconsole/core/BasePage2.java
new file mode 100644
index 0000000..7f010ec
--- /dev/null
+++ b/core/src/main/java/org/apache/karaf/webconsole/core/BasePage2.java
@@ -0,0 +1,69 @@
+package org.apache.karaf.webconsole.core;
+
+import org.apache.wicket.ResourceReference;
+import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
+import org.apache.wicket.extensions.markup.html.tabs.TabbedPanel;
+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.link.PageLink;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.Model;
+import org.ops4j.pax.wicket.api.PaxWicketBean;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+public class BasePage2 extends WebPage {
+
+ @PaxWicketBean(name = "tabs")
+ private List<ConsoleTab> tabs;
+
+ public BasePage2() {
+ add(CSSPackageResource.getHeaderContribution(BasePage2.class, "style.css"));
+ add(CSSPackageResource.getHeaderContribution(BasePage2.class, "grid.css"));
+
+ add(new Label("footer", "Apache Karaf Console"));
+
+ add(new Image("karafLogo", new ResourceReference(BasePage2.class, "images/karaf-logo.png")));
+
+ add(new ListView<ConsoleTab>("tabs", tabs) {
+ @Override
+ protected void populateItem(ListItem<ConsoleTab> item) {
+ final ConsoleTab tab = item.getModelObject();
+ item.add(new PageLink("moduleLink", tab.getModuleHomePage()).add(new Label("moduleLabel", tab.getLabel())));
+
+ List<String> subItems = new LinkedList<String>(tab.getItems().keySet());
+ item.add(new ListView<String>("topLinks", subItems) {
+ @Override
+ protected void populateItem(ListItem<String> item) {
+ String subItem = item.getModelObject();
+ item.add(new PageLink("topLink", tab.getItems().get(subItem)).add(new Label("linkLabel", subItem)));
+ }
+ });
+ }
+ });
+
+ List tabPanels = new ArrayList();
+ tabPanels.add(new AbstractTab(new Model("first tab")) {
+ public Panel getPanel(String panelId) {
+ return new TabPanel1(panelId);
+ }
+ });
+
+ add(new TabbedPanel("tabPanels", tabPanels));
+
+ }
+
+
+ class TabPanel1 extends Panel {
+ public TabPanel1(String id) {
+ super(id);
+ }
+ }
+
+}
diff --git a/core/src/main/resources/org/apache/karaf/webconsole/core/BasePage.html b/core/src/main/resources/org/apache/karaf/webconsole/core/BasePage.html
index 0dce6da..0e4d868 100644
--- a/core/src/main/resources/org/apache/karaf/webconsole/core/BasePage.html
+++ b/core/src/main/resources/org/apache/karaf/webconsole/core/BasePage.html
@@ -13,20 +13,30 @@
</div>
<div class="grid_9">
<h3>Administration console</h3>
+ <a href="#" wicket:id="goFrench">
+ <img wicket:id="frenchFlag" alt="french flag" height="14" width="20" />
+ </a>
+ <a href="#" wicket:id="goEnglish">
+ <img wicket:id="englishFlag" alt="english flag" height="14" width="20" />
+ </a>
</div>
+
<div class="clear"></div>
<div class="grid_12">
<div wicket:id="navigationPanel">Navigation goes here</div>
</div>
+
<div class="clear"></div>
<div class="grid_3">
<div wicket:id="sidebar">Sidebar goes here</div>
</div>
- <div class="grid_9" wicket:id="content">
+
+ <div class="grid_9">
<wicket:child />
</div>
+
<div class="clear"></div>
<div class="grid_12">
diff --git a/core/src/main/resources/org/apache/karaf/webconsole/BasePage.html b/core/src/main/resources/org/apache/karaf/webconsole/core/BasePage2.html
similarity index 100%
rename from core/src/main/resources/org/apache/karaf/webconsole/BasePage.html
rename to core/src/main/resources/org/apache/karaf/webconsole/core/BasePage2.html
diff --git a/core/src/main/resources/org/apache/karaf/webconsole/core/images/english-flag.jpeg b/core/src/main/resources/org/apache/karaf/webconsole/core/images/english-flag.jpeg
new file mode 100644
index 0000000..27bb7b1
--- /dev/null
+++ b/core/src/main/resources/org/apache/karaf/webconsole/core/images/english-flag.jpeg
Binary files differ
diff --git a/core/src/main/resources/org/apache/karaf/webconsole/core/images/french-flag.jpeg b/core/src/main/resources/org/apache/karaf/webconsole/core/images/french-flag.jpeg
new file mode 100644
index 0000000..0c72cef
--- /dev/null
+++ b/core/src/main/resources/org/apache/karaf/webconsole/core/images/french-flag.jpeg
Binary files differ
diff --git a/core/src/main/resources/org/apache/karaf/webconsole/core/images/french-flag.png b/core/src/main/resources/org/apache/karaf/webconsole/core/images/french-flag.png
new file mode 100644
index 0000000..d254d17
--- /dev/null
+++ b/core/src/main/resources/org/apache/karaf/webconsole/core/images/french-flag.png
Binary files differ
diff --git a/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/FeaturesConsoleTab.java b/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/FeaturesConsoleTab.java
index 7822fc7..2ac1207 100644
--- a/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/FeaturesConsoleTab.java
+++ b/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/FeaturesConsoleTab.java
@@ -17,6 +17,7 @@
return FeaturesPage.class;
}
+ //new ResourceModel("features.console.list").getObject().toString()
public Map<String, Class> getItems() {
Map<String, Class> features = new HashMap<String, Class>();
features.put("Features list", FeaturesPage.class);
diff --git a/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/FeaturesPage.java b/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/FeaturesPage.java
index 12efe33..2f04775 100644
--- a/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/FeaturesPage.java
+++ b/osgi/src/main/java/org/apache/karaf/webconsole/osgi/internal/FeaturesPage.java
@@ -10,6 +10,7 @@
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
+import org.apache.wicket.model.StringResourceModel;
import org.ops4j.pax.wicket.api.PaxWicketBean;
import java.util.*;
@@ -45,37 +46,18 @@
}
}
-/* add(new ListView<ExtendedFeature>("features", model) {
- @Override
- protected void populateItem(ListItem<ExtendedFeature> item) {
- final ExtendedFeature feature = item.getModelObject();
- item.add(new Label("state", feature.getState().toString()));
- item.add(new Label("version", feature.getVersion()));
- item.add(new Label("name", feature.getName()));
- item.add(new Label("repository", feature.getRepository()));
- item.add(new Label("description", feature.getDescription()));
-
- item.add(new Link("featuresDetailsPageLink") {
- @Override
- public void onClick() {
- PageParameters params = new PageParameters();
- params.put("featureId", feature.getId());
- }
- });
- }
- });*/
+ IModel state = Model.of("state");
+ IModel version = Model.of("version");
+ IModel name = Model.of("name");
+ IModel repository = Model.of("repository");
+ IModel description = Model.of("description");
List<IColumn<ExtendedFeature>> columns = new ArrayList<IColumn<ExtendedFeature>>();
- columns.add(new PropertyColumn<ExtendedFeature>(Model.of("state"), "state",
- "state"));
- columns.add(new PropertyColumn<ExtendedFeature>(Model.of("version"), "version",
- "version"));
- columns.add(new PropertyColumn<ExtendedFeature>(Model.of("name"), "name",
- "name"));
- columns.add(new PropertyColumn<ExtendedFeature>(Model.of("repository"), "repository",
- "repository"));
- columns.add(new PropertyColumn<ExtendedFeature>(Model.of("description"), "description",
- "description"));
+ columns.add(new PropertyColumn<ExtendedFeature>(new StringResourceModel("table.state",this,state),"state","state"));
+ columns.add(new PropertyColumn<ExtendedFeature>(new StringResourceModel("table.version",this,version),"version","version"));
+ columns.add(new PropertyColumn<ExtendedFeature>(new StringResourceModel("table.name",this,state),"name","name"));
+ columns.add(new PropertyColumn<ExtendedFeature>(new StringResourceModel("table.repository",this,repository),"repository","repository"));
+ columns.add(new PropertyColumn<ExtendedFeature>(new StringResourceModel("table.description",this,description),"description","description"));
add(new DefaultDataTable<ExtendedFeature>("features", columns,
new FeaturesProvider(model), 20));
diff --git a/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/FeaturesPage.properties b/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/FeaturesPage.properties
new file mode 100644
index 0000000..32f14cb
--- /dev/null
+++ b/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/FeaturesPage.properties
@@ -0,0 +1,6 @@
+# Features properties
+table.state = state
+table.name = Name
+table.version = Version
+table.repository = Repository
+table.description = Description
\ No newline at end of file
diff --git a/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/FeaturesPage_fr.properties b/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/FeaturesPage_fr.properties
new file mode 100644
index 0000000..32f7612
--- /dev/null
+++ b/osgi/src/main/resources/org/apache/karaf/webconsole/osgi/internal/FeaturesPage_fr.properties
@@ -0,0 +1,6 @@
+# Proprits des Features
+table.state = Etat
+table.name = Nom
+table.version = Version
+table.repository = Repertoire
+table.description = Description
\ No newline at end of file