2
0
Fork 0

Added i18n lib and added paging on mongo and meta backends.

This commit is contained in:
Willem Cazander 2012-05-08 04:38:07 +02:00
parent fe5842768f
commit efcbdbd519
45 changed files with 1767 additions and 28 deletions

View file

@ -30,7 +30,7 @@
<groupId>net.forwardfire.vasc.demo</groupId>
<artifactId>vasc-demo-tech-web</artifactId>
<version>${project.version}</version>
<type>war</type>
<!-- <type>war</type> -->
</dependency>
<dependency>
<groupId>net.forwardfire.vasc</groupId>
@ -67,6 +67,16 @@
<artifactId>vasc-backend-jdbc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc.lib</groupId>
<artifactId>vasc-lib-i18n</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc.test</groupId>
<artifactId>vasc-test-i18n</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jdesktop.bsaf</groupId>
<artifactId>bsaf</artifactId>

View file

@ -53,7 +53,6 @@ public class TechUI extends SingleFrameApplication {
static public void main(String[] args) {
Application.launch(TechUI.class, args);
}
/**

View file

@ -27,6 +27,17 @@ import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.ResourceBundle;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
@ -47,6 +58,8 @@ import net.forwardfire.vasc.demo.tech.ui.VascManager;
import net.forwardfire.vasc.frontends.swing.SwingPanelIntegration;
import net.forwardfire.vasc.frontends.swing.SwingPanelTabbed;
import net.forwardfire.vasc.impl.DefaultVascFactory;
import net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle_en;
import net.forwardfire.vasc.test.i18n.VascBundleCheckEntryKeys;
public class JMainPanel extends JPanel {
@ -123,7 +136,7 @@ public class JMainPanel extends JPanel {
if (vascNode != null) {
if (vascNode.type == VascTreeNodeType.ENTRY) {
VascEntry ee = vascManager.getVascController().getVascEntryController().getVascEntryById(vascNode.id).clone();
DefaultVascFactory.fillVascEntryFrontend(ee, vascManager.getVascController(), DefaultVascFactory.getDefaultVascFrontendData(null));
DefaultVascFactory.fillVascEntryFrontend(ee, vascManager.getVascController(), DefaultVascFactory.getDefaultVascFrontendData("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle",new Locale("en")));
spi.createNewVascView(ee);
}
}
@ -260,10 +273,85 @@ public class JMainPanel extends JPanel {
root.add(entries);
SwingUtilities.updateComponentTreeUI(vascTree);
// todo move
Map<String,String> keys = new HashMap<String,String>(300);
VascBundleCheckEntryKeys checker = new VascBundleCheckEntryKeys(ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle"));
for (String veId:vascManager.getVascController().getVascEntryController().getVascEntryIds()) {
VascEntry ve = vascManager.getVascController().getVascEntryController().getVascEntryById(veId);
keys.putAll(checker.generateMissingKeys(ve));
}
if (keys.isEmpty()==false) {
Properties p = new Properties();
File dataDir = new File("auto/data");
if (dataDir.exists()==false) {
dataDir.mkdirs();
}
File resourceFile = new File("auto/data/vasc-bundle.properties");
if (resourceFile.exists()) {
readPropertiesFile(p,resourceFile);
}
for (String key:keys.keySet()) {
p.put(key, keys.get(key));
}
writePropertiesFile(p,resourceFile);
new RootApplicationBundle_en().reload();
RootApplicationBundle_en.clearCache();
}
}
public JTabbedPane getTabPane() {
return tabPane;
}
protected void writePropertiesFile(Properties p,File file) {
try {
writePropertiesStream(p,new FileOutputStream(file));
} catch (Exception e) {
throw new RuntimeException("Could not load resource file error: "+e.getMessage(),e);
}
}
protected void readPropertiesFile(Properties p,File file) {
try {
readPropertiesStream(p,new FileInputStream(file));
} catch (Exception e) {
throw new RuntimeException("Could not load resource file error: "+e.getMessage(),e);
}
}
protected void writePropertiesStream(Properties p,OutputStream out) {
try {
p.store(out, "Saved by vasc auto i18n.");
} catch (Exception e) {
throw new RuntimeException("Could not load properties error: "+e.getMessage(),e);
} finally {
if (out!=null) {
try {
out.close();
} catch (IOException e) {
}
}
}
}
protected void readPropertiesStream(Properties p,InputStream in) {
try {
p.load(in);
} catch (Exception e) {
throw new RuntimeException("Could not load properties error: "+e.getMessage(),e);
} finally {
if (in!=null) {
try {
in.close();
} catch (IOException e) {
}
}
}
}
}

View file

@ -0,0 +1,8 @@
# bundle list to merge and load
bundle1.uri=net.forwardfire.vasc.demo.tech.ui.resources.TechUI
bundle2.uri=auto/data/vasc-bundle.properties
bundle2.type=FILE
bundle2.optional=true

View file

@ -21,12 +21,12 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>

View file

@ -25,7 +25,6 @@ package net.forwardfire.vasc.demo.tech.web.beans;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.faces.context.FacesContext;
@ -60,10 +59,7 @@ public class VascFacesController extends AbstractJSFVascFacesControllerBase {
@Override
public VascFrontendData getNewVascFrontendData() {
Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
// MergedResourceBundle bundle = new MergedResourceBundle();
// bundle.addDataBundle(ResourceBundle.getBundle(getResourceBundleWEB(), locale));
VascFrontendData vascFrontendData = DefaultVascFactory.getDefaultVascFrontendData(ResourceBundle.getBundle("net/forwardfire/vasc/demo/tech/ui/resources/TechUI"));
VascFrontendData vascFrontendData = DefaultVascFactory.getDefaultVascFrontendData("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle",locale);
vascFrontendData.addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() {
private static final long serialVersionUID = 1L;
public VascFrontendEventType[] getEventTypes() {

View file

@ -158,6 +158,7 @@
<param-value>vasc-demo-tech</param-value>
</context-param>
<!-- Making the RichFaces skin spread to standard HTML controls -->
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
@ -188,12 +189,10 @@
<param-name>templateFile</param-name>
<param-value>/jsp/includes/vasc-template.jsf</param-value>
</init-param>
<!--
<init-param>
<param-name>resourceBundle</param-name>
<param-value>net/forwardfire/logstats/resources/i18n/LogstatsBundleWAR</param-value>
<param-value>net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle</param-value>
</init-param>
-->
</filter>
<filter-mapping>