org.argeo.server.ads.server,\
org.springframework.osgi.web.extender,\
-org.argeo.security.ui.initialPerspective=org.argeo.osgi.ui.explorer.perspective
-#org.argeo.security.ui.initialPerspective=org.argeo.jcr.ui.explorer.perspective
+#Choose initial perspective
+#org.argeo.security.ui.initialPerspective=org.argeo.osgi.ui.explorer.perspective
+org.argeo.security.ui.initialPerspective=org.argeo.jcr.ui.explorer.perspective
log4j.configuration=file:../../log4j.properties
+
+# Note default URL to access the webapp
+# http://localhost:7070/org.argeo.rap.webapp/node
\ No newline at end of file
--- /dev/null
+argeo.osgi.start=\
+org.springframework.osgi.extender,\
+org.argeo.node.repofactory.jackrabbit,\
+org.argeo.node.repo.jackrabbit,\
+org.argeo.security.dao.ldap,\
+org.argeo.security.services,\
+org.argeo.security.equinox,\
+org.eclipse.core.runtime,\
+org.eclipse.equinox.common,\
+org.eclipse.equinox.http.registry,\
+org.eclipse.equinox.launcher,\
+org.argeo.dep.osgi.catalina.start,\
+org.argeo.jackrabbit.webapp,\
+org.argeo.server.rap.webapp,\
+org.argeo.server.ads.server,\
+org.argeo.demo.i18n,\
+org.springframework.osgi.web.extender,\
+
+
+#Choose initial perspective
+org.argeo.security.ui.initialPerspective=org.argeo.demo.i18n.perspective
+
+log4j.configuration=file:../../log4j.properties
+
+# Note default URL to access the webapp
+# http://localhost:7070/org.argeo.rap.webapp/node
\ No newline at end of file
--- /dev/null
+log4j.rootLogger=WARN, development
+
+## Levels
+log4j.logger.org.argeo=DEBUG
+
+log4j.logger.org.apache.catalina=INFO
+log4j.logger.org.apache.coyote=INFO
+log4j.logger.org.apache.directory.server=ERROR
+log4j.logger.org.apache.jackrabbit.core.query.lucene=ERROR
+
+## Appenders
+# console is set to be a ConsoleAppender.
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+
+# console uses PatternLayout.
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c - [%t]%n
+
+# development appender (slow!)
+log4j.appender.development=org.apache.log4j.ConsoleAppender
+log4j.appender.development.layout=org.apache.log4j.PatternLayout
+log4j.appender.development.layout.ConversionPattern=%d{HH:mm:ss} [%16.16t] %5p %m (%F:%L) %c%n
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.argeo.demo.i18n</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
\ No newline at end of file
--- /dev/null
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Internationalization Demo
+Bundle-SymbolicName: org.argeo.demo.i18n;singleton:=true
+Bundle-Version: 0.3.4.SNAPSHOT
+Bundle-Activator: org.argeo.demo.i18n.I18nDemoPlugin
+Bundle-Localization: org.argeo.demo.i18n.messages
+Bundle-Vendor: Argeo
+Require-Bundle: org.eclipse.ui;resolution:=optional,
+ org.eclipse.core.runtime;resolution:=optional,
+ org.eclipse.rap.ui;resolution:=optional,
+ org.eclipse.rap.ui.workbench;resolution:=optional
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Import-Package: org.apache.commons.io,
+ org.apache.commons.logging,
+ org.argeo,
+ org.argeo.eclipse.spring,
+ org.argeo.eclipse.ui,
+ org.eclipse.ui.forms,
+ org.eclipse.ui.forms.editor,
+ org.eclipse.ui.forms.widgets
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+</beans>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
+ xmlns:p="http://www.springframework.org/schema/p"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
+
+ <bean id="simpleMultitabEditor" class="org.argeo.demo.i18n.editors.SimpleMultitabEditor"
+ scope="prototype">
+ </bean>
+</beans>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+ xmlns:osgi="http://www.springframework.org/schema/osgi"\r
+ xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
+ http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+ http://www.springframework.org/schema/beans \r
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
+ osgi:default-timeout="30000">\r
+\r
+</beans:beans>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <!-- Views -->
+ <bean id="simpleTreeView" class="org.argeo.demo.i18n.views.SimpleTreeView"
+ scope="prototype">
+ </bean>
+</beans>
--- /dev/null
+source.. = src/main/java/,\
+ src/main/resources
+output.. = target/classes/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
--- /dev/null
+
+## commands label
+
+## View labels
+
+## Editor labels
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <!-- Perspectives -->
+ <extension
+ point="org.eclipse.ui.perspectives">
+ <perspective
+ class="org.argeo.demo.i18n.I18nDemoPerspective"
+ icon="icons/i18n.gif"
+ id="org.argeo.demo.i18n.perspective"
+ name="Internationalization simple demo">
+ </perspective>
+ </extension>
+ <!-- Views -->
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ class="org.argeo.eclipse.spring.SpringExtensionFactory"
+ icon="icons/browser.gif"
+ id="org.argeo.demo.i18n.simpleTreeView"
+ name="Internationalized tree view">
+ </view>
+ </extension>
+ <!-- Editors -->
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ class="org.argeo.eclipse.spring.SpringExtensionFactory"
+ id="org.argeo.demo.i18n.simpleMultitabEditor"
+ name="Simple multitab editor"
+ icon="icons/i18n.gif"
+ default="false">
+ </editor>
+ </extension>
+ <!-- Commands -->
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+ id="org.argeo.jcr.ui.explorer.openGenericNodeEditor"
+ name="Open generic node Editor">
+ <commandParameter
+ id="org.argeo.jcr.ui.explorer.nodePath"
+ name="Node path">
+ </commandParameter>
+ </command>
+ </extension>
+
+ <!-- Menus -->
+ <extension point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.argeo.demo.i18n.simpleTreeView">
+ </menuContribution>
+ </extension>
+
+ <!-- Core expression definition -->
+ <extension
+ point="org.eclipse.core.expressions.definitions">
+ <definition
+ id="expression.onlyOneItemSelected">
+ <with
+ variable="activeMenuSelection">
+ <count
+ value="1">
+ </count>
+ </with>
+ </definition>
+ </extension>
+
+ <!-- Activities -->
+ <extension
+ point="org.eclipse.ui.activities">
+ <activity
+ description="Only for admins"
+ id="org.argeo.jcr.ui.explorer.adminActivity"
+ name="Admin">
+ <enabledWhen>
+ <with variable="roles">
+ <iterate ifEmpty="false" operator="or">
+ <equals value="ROLE_ADMIN" />
+ </iterate>
+ </with>
+ </enabledWhen>
+ </activity>
+ <!-- TODO: find a way to exclude evrything -->
+ <activityPatternBinding
+ activityId="org.argeo.jcr.ui.explorer.adminActivity"
+ isEqualityPattern="true"
+ pattern="org.argeo.jcr.ui.explorer/org.argeo.jcr.ui.explorer.perspective">
+ </activityPatternBinding>
+ </extension>
+</plugin>
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.argeo.commons.demo</groupId>
+ <version>0.3.4-SNAPSHOT</version>
+ <artifactId>plugins</artifactId>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>org.argeo.demo.i18n</artifactId>
+ <name>Commons internationalization Demo</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.argeo.commons.eclipse</groupId>
+ <artifactId>org.argeo.eclipse.dep.common</artifactId>
+ <version>0.3.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.argeo.commons.eclipse</groupId>
+ <artifactId>org.argeo.eclipse.ui</artifactId>
+ <version>0.3.4-SNAPSHOT</version>
+ </dependency>
+
+ <!-- RCP only dependency, needed at compile time -->
+ <dependency>
+ <groupId>org.argeo.commons.eclipse</groupId>
+ <artifactId>org.argeo.eclipse.dep.rcp</artifactId>
+ <version>0.3.4-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.argeo.commons.eclipse</groupId>
+ <artifactId>org.argeo.eclipse.ui.rcp</artifactId>
+ <version>0.3.4-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+package org.argeo.demo.i18n;
+
+/** Constants used across the application. */
+public interface I18nDemoConstants {
+ public final static String PARAM_REPOSITORY_URI = "org.argeo.jcr.ui.explorer.repositoryUri";
+
+ /*
+ * MISCEALLENEOUS
+ */
+ public final static String DATE_TIME_FORMAT = "dd/MM/yyyy, HH:mm";
+
+ public final static String PARAM_PATH = "org.argeo.jcr.ui.explorer.nodePath";
+
+}
--- /dev/null
+package org.argeo.demo.i18n;
+
+import org.argeo.demo.i18n.views.SimpleTreeView;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+/** Base perspective for JcrExplorer browser */
+public class I18nDemoPerspective implements IPerspectiveFactory {
+
+ public void createInitialLayout(IPageLayout layout) {
+ layout.setEditorAreaVisible(true);
+
+ IFolderLayout upperLeft = layout.createFolder(I18nDemoPlugin.ID
+ + ".upperLeft", IPageLayout.LEFT, 0.4f, layout.getEditorArea());
+ upperLeft.addView(SimpleTreeView.ID);
+ }
+}
--- /dev/null
+package org.argeo.demo.i18n;
+
+import java.util.ResourceBundle;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class I18nDemoPlugin extends AbstractUIPlugin {
+ private final static Log log = LogFactory.getLog(I18nDemoPlugin.class);
+ private ResourceBundle messages;
+
+ // The plug-in ID
+ public static final String ID = "org.argeo.demo.i18n"; //$NON-NLS-1$
+
+ // The shared instance
+ private static I18nDemoPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public I18nDemoPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+ * )
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ messages = ResourceBundle.getBundle("org.argeo.demo.i18n.messages");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+ * )
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static I18nDemoPlugin getDefault() {
+ return plugin;
+ }
+
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(ID, path);
+ }
+
+ /** Returns the internationalized label for the given key */
+ public static String getMessage(String key) {
+ try {
+ return getDefault().messages.getString(key);
+ } catch (NullPointerException npe) {
+ log.warn(key + " not found.");
+ return key;
+ }
+ }
+
+ /**
+ * Gives access to the internationalization message bundle. Returns null in
+ * case the ClientUiPlugin is not started (for JUnit tests, by instance)
+ */
+ public static ResourceBundle getMessagesBundle() {
+ if (getDefault() != null)
+ // To avoid NPE
+ return getDefault().messages;
+ else
+ return null;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.argeo.demo.i18n.editors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.demo.i18n.I18nDemoPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.AbstractFormPart;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+/**
+ * Offers two main sections : one to display a text area with a summary of all
+ * variations between a version and its predecessor and one tree view that
+ * enable browsing
+ * */
+public class MultiSectionPage extends FormPage {
+ private final static Log log = LogFactory
+ .getLog(MultiSectionPage.class);
+
+ // this page UI components
+ private FormToolkit tk;
+
+ public MultiSectionPage(FormEditor editor, String title) {
+ super(editor, "MultiSectionPage", title);
+ }
+
+ protected void createFormContent(IManagedForm managedForm) {
+ ScrolledForm form = managedForm.getForm();
+ tk = managedForm.getToolkit();
+ GridLayout twt = new GridLayout(1, false);
+ twt.marginWidth = twt.marginHeight = 5;
+ Composite body = form.getBody();
+ body.setLayout(twt);
+
+
+ createHistorySection(form.getBody());
+ createTreeSection(form.getBody());
+ }
+
+ protected void createTreeSection(Composite parent) {
+ // Section Layout & MetaData
+ Section section = tk.createSection(parent, Section.TWISTIE);
+ section.setLayoutData(new GridData(GridData.FILL_BOTH));
+ section.setText(I18nDemoPlugin.getMessage("MultiSelectionPage.DescriptionSectionTitle"));
+
+ // Section Body
+ Composite body = tk.createComposite(section, SWT.FILL);
+ // WARNING : 2 following lines are compulsory or body won't be
+ // displayed.
+ body.setLayout(new GridLayout());
+ section.setClient(body);
+
+ body.setLayoutData(new GridData(GridData.FILL_BOTH));
+ section.setExpanded(true);
+ }
+
+
+ protected void createHistorySection(Composite parent) {
+
+ // Section Layout
+ Section section = tk.createSection(parent, Section.TWISTIE);
+ section.setLayoutData(new GridData(TableWrapData.FILL_GRAB));
+ TableWrapLayout twt = new TableWrapLayout();
+ section.setLayout(twt);
+
+ // Set title of the section
+ section.setText(I18nDemoPlugin
+ .getMessage("MultiSelectionPage.DetailsSectionTitle"));
+
+ final Text styledText = tk.createText(section, "", SWT.FULL_SELECTION
+ | SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
+ styledText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ section.setClient(styledText);
+ styledText.setEditable(false);
+ section.setExpanded(false);
+
+ AbstractFormPart part = new AbstractFormPart() {
+ public void commit(boolean onSave) {
+ }
+
+ public void refresh() {
+ super.refresh();
+ }
+ };
+ getManagedForm().addPart(part);
+ }
+
+ @Override
+ public void setActive(boolean active) {
+ super.setActive(active);
+ }
+}
--- /dev/null
+package org.argeo.demo.i18n.editors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.ArgeoException;
+import org.argeo.demo.i18n.I18nDemoPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.editor.FormEditor;
+
+/**
+ *
+ * Container for the node editor page. At creation time, it takes a JCR Node
+ * that cannot be changed afterwards.
+ *
+ */
+public class SimpleMultitabEditor extends FormEditor {
+
+ private final static Log log = LogFactory
+ .getLog(SimpleMultitabEditor.class);
+ public final static String ID = I18nDemoPlugin.ID + ".simpleMultitabEditor";
+
+ private SimplePage simplePage;
+ private MultiSectionPage multiSectionPage;
+
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
+ super.init(site, input);
+ this.setPartName("Internationalize editor part name");
+ }
+
+ @Override
+ protected void addPages() {
+ try {
+ simplePage = new SimplePage(this,
+ I18nDemoPlugin
+ .getMessage("SimpleMultitabEditor.SimplePageTitle"));
+ addPage(simplePage);
+
+ multiSectionPage = new MultiSectionPage(
+ this,
+ I18nDemoPlugin
+ .getMessage("SimpleMultitabEditor.MultiSectionPageTitle"));
+ addPage(multiSectionPage);
+
+ } catch (PartInitException e) {
+ throw new ArgeoException("Not able to add an empty page ", e);
+ }
+ }
+
+ @Override
+ public void doSaveAs() {
+ // unused compulsory method
+ }
+
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ try {
+ // Automatically commit all pages of the editor
+ commitPages(true);
+ firePropertyChange(PROP_DIRTY);
+ } catch (Exception e) {
+ throw new ArgeoException("Error while saving node", e);
+ }
+
+ }
+
+ @Override
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+}
--- /dev/null
+package org.argeo.demo.i18n.editors;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+/**
+ * An editor input based the object name.
+ * */
+
+public class SimpleMultitabEditorInput implements IEditorInput {
+
+ private final String name;
+
+ public SimpleMultitabEditorInput(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ return null;
+ }
+
+ public boolean exists() {
+ return true;
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return null;
+ }
+
+ public IPersistableElement getPersistable() {
+ return null;
+ }
+
+ /**
+ * equals method based on the name
+ */
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+
+ SimpleMultitabEditorInput other = (SimpleMultitabEditorInput) obj;
+ if (!getName().equals(other.getName()))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String getToolTipText() {
+ return name;
+ }
+}
--- /dev/null
+package org.argeo.demo.i18n.editors;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.forms.AbstractFormPart;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * Main node editor page. Lists all properties of the current node and enable
+ * access and editing for some of them.
+ */
+
+public class SimplePage extends FormPage {
+ private final static Log log = LogFactory.getLog(SimplePage.class);
+
+ // Utils
+ // protected DateFormat timeFormatter = new
+ // SimpleDateFormat(DATE_TIME_FORMAT);
+
+ // This page widgets
+ private FormToolkit tk;
+ private List<Control> modifyableProperties = new ArrayList<Control>();
+
+ public SimplePage(FormEditor editor, String title) {
+ super(editor, "id", title);
+ }
+
+ protected void createFormContent(IManagedForm managedForm) {
+ tk = managedForm.getToolkit();
+ ScrolledForm form = managedForm.getForm();
+ GridLayout twt = new GridLayout(3, false);
+ twt.marginWidth = twt.marginHeight = 5;
+
+ form.getBody().setLayout(twt);
+ createPropertiesPart(form.getBody());
+ }
+
+ private void createPropertiesPart(Composite parent) {
+ // Initializes form part
+ tk.createLabel(parent, "Implement something");
+ AbstractFormPart part = new AbstractFormPart() {
+ public void commit(boolean onSave) {
+ if (onSave) {
+
+ // We only commit when onSave = true,
+ // thus it is still possible to save after a tab
+ // change.
+ super.commit(onSave);
+ }
+ }
+ };
+
+ getManagedForm().addPart(part);
+
+ }
+
+ //
+ // LISTENERS
+ //
+
+ private class ModifiedFieldListener implements ModifyListener {
+
+ private AbstractFormPart formPart;
+
+ public ModifiedFieldListener(AbstractFormPart generalPart) {
+ this.formPart = generalPart;
+ }
+
+ public void modifyText(ModifyEvent e) {
+ formPart.markDirty();
+ }
+ }
+
+}
--- /dev/null
+package org.argeo.demo.i18n.model;
+
+import org.argeo.eclipse.ui.TreeParent;
+
+public class Place extends TreeParent {
+
+ private String description;
+ private String address;
+
+ public Place(String name, String description, String address) {
+ super(name);
+ this.description = description;
+ this.address = address;
+ }
+
+ public void setAddress(String adress) {
+ this.address = adress;
+ }
+
+ public String getAdress() {
+ return address;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+}
--- /dev/null
+package org.argeo.demo.i18n.providers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.argeo.demo.i18n.model.Place;
+import org.argeo.eclipse.ui.TreeParent;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Implementation of the {@code ITreeContentProvider} to display multiple
+ * repository environment in a tree like structure
+ *
+ */
+public class SimpleContentProvider implements ITreeContentProvider {
+ // private final static Log log =
+ // LogFactory.getLog(SimpleContentProvider.class);
+
+ public SimpleContentProvider() {
+ }
+
+ /**
+ * Sends back the first level of the Tree. Independent from inputElement
+ * that can be null. Values are hard coded here.
+ */
+ public Object[] getElements(Object inputElement) {
+ List<Object> objs = new ArrayList<Object>();
+ objs.add(new Place("Home", "My house, my family",
+ "12 rue du bac, Paris"));
+ objs.add(new Place("Office", "Where I work",
+ "100 av des champs Elysées"));
+ objs.add(new Place("School",
+ "The place where the children spend their days",
+ "103 Avenue montaigne, Paris"));
+ return objs.toArray();
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof TreeParent)
+ return ((TreeParent) parentElement).getChildren();
+ else {
+ return new Object[0];
+ }
+ }
+
+ public Object getParent(Object element) {
+ if (element instanceof TreeParent) {
+ return ((TreeParent) element).getParent();
+ } else
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ if (element instanceof TreeParent) {
+ TreeParent tp = (TreeParent) element;
+ return tp.hasChildren();
+ }
+ return false;
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+}
--- /dev/null
+package org.argeo.demo.i18n.providers;
+
+import org.argeo.demo.i18n.model.Place;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+public class SimpleLabelProvider extends ColumnLabelProvider {
+ public String getText(Object element) {
+ if (element instanceof Place) {
+ Place place = (Place) element;
+ return place.getName();
+ } else
+ return element.toString();
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ return null;
+ }
+}
--- /dev/null
+package org.argeo.demo.i18n.utils;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.ArgeoException;
+import org.argeo.demo.i18n.I18nDemoPlugin;
+import org.argeo.demo.i18n.editors.SimpleMultitabEditor;
+import org.argeo.demo.i18n.editors.SimpleMultitabEditorInput;
+import org.argeo.eclipse.ui.TreeParent;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * Centralizes the management of double click on a NodeTreeViewer
+ */
+public class GenericDoubleClickListener implements IDoubleClickListener {
+
+ private final static Log log = LogFactory
+ .getLog(GenericDoubleClickListener.class);
+
+ private TreeViewer treeViewer;
+
+ public GenericDoubleClickListener(TreeViewer treeViewer) {
+ this.treeViewer = treeViewer;
+ }
+
+ public void doubleClick(DoubleClickEvent event) {
+ Object obj = ((IStructuredSelection) event.getSelection())
+ .getFirstElement();
+ if (obj instanceof TreeParent) {
+ try {
+ TreeParent tp = (TreeParent) obj;
+ // open an editor
+ SimpleMultitabEditorInput smei = new SimpleMultitabEditorInput(
+ tp.getName());
+ I18nDemoPlugin.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage()
+ .openEditor(smei, SimpleMultitabEditor.ID);
+ } catch (PartInitException pie) {
+ throw new ArgeoException(
+ "Unexpected exception while opening node editor", pie);
+ }
+ }
+ // else do nothing
+ }
+}
--- /dev/null
+package org.argeo.demo.i18n.views;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.demo.i18n.I18nDemoPlugin;
+import org.argeo.demo.i18n.providers.SimpleContentProvider;
+import org.argeo.demo.i18n.providers.SimpleLabelProvider;
+import org.argeo.demo.i18n.utils.GenericDoubleClickListener;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * Basic View to display a tree with internationalized labels
+ */
+
+public class SimpleTreeView extends ViewPart {
+ private final static Log log = LogFactory.getLog(SimpleTreeView.class);
+
+ public final static String ID = I18nDemoPlugin.ID + ".simpleTreeView";
+
+ // This page widgets
+ private TreeViewer treeViewer;
+ private SimpleContentProvider treeContentProvider;
+
+ @Override
+ public void createPartControl(Composite parent) {
+ parent.setLayout(new FillLayout());
+
+ // Creates the tree
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout gl = new GridLayout(1, false);
+ composite.setLayout(gl);
+
+ // tree viewer
+ treeContentProvider = new SimpleContentProvider();
+ treeViewer = createTreeViewer(composite, treeContentProvider);
+
+ // context menu : it is completely defined in the plugin.xml file.
+ MenuManager menuManager = new MenuManager();
+ Menu menu = menuManager.createContextMenu(treeViewer.getTree());
+ treeViewer.getTree().setMenu(menu);
+ getSite().registerContextMenu(menuManager, treeViewer);
+
+ getSite().setSelectionProvider(treeViewer);
+
+ treeViewer.setInput(getViewSite());
+ }
+
+ protected TreeViewer createTreeViewer(Composite parent,
+ final ITreeContentProvider treeContentProvider) {
+
+ final TreeViewer tmpTreeViewer = new TreeViewer(parent, SWT.MULTI);
+
+ tmpTreeViewer.getTree().setLayoutData(
+ new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ tmpTreeViewer.setContentProvider(treeContentProvider);
+ tmpTreeViewer.setLabelProvider(new SimpleLabelProvider());
+ tmpTreeViewer
+ .addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ // something can be done here
+ }
+ });
+
+ tmpTreeViewer.addDoubleClickListener(new GenericDoubleClickListener(
+ tmpTreeViewer));
+ return tmpTreeViewer;
+ }
+
+ @Override
+ public void setFocus() {
+ // Do nothing for the time being.
+
+ }
+
+}
--- /dev/null
+## English_US labels for Argeo Internationalization demo application
+
+## Generic labels
+
+## Errors & warnings
+
+## Commands
+
+## Editor
+SimpleMultitabEditor.MultiSectionPageTitle=More information
+SimpleMultitabEditor.SimplePageTitle=Base information
+## Pages
+MultiSelectionPage.DescriptionSectionTitle=Description
+MultiSelectionPage.DetailsSectionTitle=Details
+
+
+## Dummy ones
+testLbl=Internationalizations of messages seems to work properly.
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.argeo.commons</groupId>
+ <version>0.3.4-SNAPSHOT</version>
+ <artifactId>demo</artifactId>
+ <relativePath>..</relativePath>
+ </parent>
+ <groupId>org.argeo.commons.demo</groupId>
+ <artifactId>plugins</artifactId>
+ <name>Commons Demo Eclipse Plugins</name>
+ <packaging>pom</packaging>
+ <modules>
+ <module>org.argeo.demo.i18n</module>
+ </modules>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <directory>.</directory>
+ <includes>
+ <include>plugin.xml</include>
+ <include>META-INF/**</include>
+ <include>icons/**</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <configuration>
+ <!-- Prevents source jars to contain misleading data -->
+ <excludes>
+ <exclude>plugin.xml</exclude>
+ <exclude>META-INF/MANIFEST.MF</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.argeo.commons</groupId>
+ <version>0.3.4-SNAPSHOT</version>
+ <artifactId>argeo-commons</artifactId>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>demo</artifactId>
+ <name>Commons Demo</name>
+ <packaging>pom</packaging>
+ <modules>
+ <module>plugins</module>
+ </modules>
+</project>
\ No newline at end of file
<module>server</module>
<module>eclipse</module>
<module>security</module>
+ <module>demo</module>
<module>doc</module>
<module>sandbox</module>
</modules>