diff options
Diffstat (limited to 'vaadin-app/src')
| -rw-r--r-- | vaadin-app/src/Application.properties | 2 | ||||
| -rw-r--r-- | vaadin-app/src/ch/asynk/helloworld/Context.java | 55 | ||||
| -rw-r--r-- | vaadin-app/src/ch/asynk/helloworld/DataMappingLayout.java | 170 | ||||
| -rw-r--r-- | vaadin-app/src/ch/asynk/helloworld/EndLayout.java | 31 | ||||
| -rw-r--r-- | vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java | 42 | ||||
| -rw-r--r-- | vaadin-app/src/ch/asynk/helloworld/LayoutLayout.java | 109 | ||||
| -rw-r--r-- | vaadin-app/src/ch/asynk/helloworld/MainLayout.java | 75 | ||||
| -rw-r--r-- | vaadin-app/src/ch/asynk/helloworld/Resources.java | 9 | 
8 files changed, 0 insertions, 493 deletions
diff --git a/vaadin-app/src/Application.properties b/vaadin-app/src/Application.properties deleted file mode 100644 index e5b8c95..0000000 --- a/vaadin-app/src/Application.properties +++ /dev/null @@ -1,2 +0,0 @@ -hello.next=Ô -hello.world=WoRlD diff --git a/vaadin-app/src/ch/asynk/helloworld/Context.java b/vaadin-app/src/ch/asynk/helloworld/Context.java deleted file mode 100644 index c59016d..0000000 --- a/vaadin-app/src/ch/asynk/helloworld/Context.java +++ /dev/null @@ -1,55 +0,0 @@ -package ch.asynk.helloworld; - -import java.util.Properties; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class Context { -    // -	private static final long serialVersionUID = 1L; -    // -    private Logger log = Logger.getLogger("ch.asynk"); -    public Logger getLogger() { -        return log; -    } -    // -    private Properties props = null; -    public Properties getProps() { -        return props; -    } -    // -    private HelloWorldApp app = null; -    public HelloWorldApp getApp() { -        return app; -    } -    // -    public Context(HelloWorldApp application) { -        app = application; -        initProps(); -    } -    // -    private void initProps() { -        props = new Properties(); -        // -        String properties_file = "Application.properties"; -        log.info("doing stuff : "); -        java.io.InputStream is = null; -        try { -            is = HelloWorldApp.class.getClassLoader().getResourceAsStream(properties_file); -        } -        catch(java.lang.Exception x) { -            log.log(Level.SEVERE,"Error loading "+properties_file+"' properties",x); -            return; -        } -        if (is!=null) { -            try { -                props.load(is); -            } -            catch (java.io.IOException e) { -                log.log(Level.SEVERE,"Error reading properties '"+properties_file+"' ",e); -            } -        } else { -            log.warning("'"+properties_file+"' file not found"); -        } -    } -} diff --git a/vaadin-app/src/ch/asynk/helloworld/DataMappingLayout.java b/vaadin-app/src/ch/asynk/helloworld/DataMappingLayout.java deleted file mode 100644 index 42801d8..0000000 --- a/vaadin-app/src/ch/asynk/helloworld/DataMappingLayout.java +++ /dev/null @@ -1,170 +0,0 @@ -package ch.asynk.helloworld; - -import com.vaadin.terminal.UserError; -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.util.ObjectProperty; -import com.vaadin.data.Validator; -import com.vaadin.data.validator.DoubleValidator; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.AbstractComponent; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.FormLayout; -import com.vaadin.ui.Panel; -import com.vaadin.ui.Label; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.TextField; - -public class DataMappingLayout extends VerticalLayout { -    // -    private static final long serialVersionUID = 1L; -    // -    private Context ctx = null; - -    public DataMappingLayout(Context context) { -        ctx = context; -        // -        final AbstractComponent pa = buildPanel(); -        pa.setWidth(600,UNITS_PIXELS); -        pa.setHeight(400,UNITS_PIXELS); -        addComponent(pa); -        setComponentAlignment(pa, Alignment.MIDDLE_CENTER); -        // -    } -    // -    private AbstractComponent buildPanel() { -        Panel panel = new Panel("Data Mapping Layout"); -        FormLayout layout = new FormLayout(); -        panel.setContent(layout); -        // -        final TextField tf1 = new TextField("Property.ValueChangeListener"); -        tf1.setImmediate(true); -        layout.addComponent(tf1); -        final Label lb1 = new Label(); -        lb1.setCaption("The Value"); -        layout.addComponent(lb1); -        tf1.addListener( new Property.ValueChangeListener() { -            private static final long serialVersionUID = 1L; -            @Override -            public void valueChange(ValueChangeEvent event) { -                String value = (String) tf1.getValue(); -                lb1.setValue(value); -            } -        }); -        // -        Double trouble = 66.6; -        final ObjectProperty<Double> property = new ObjectProperty<Double>(trouble); -        final TextField tf2 = new TextField("ObjectProperty + Validator", property); -        tf2.setImmediate(true); -        tf2.addValidator( new DoubleValidator("It should be a double") ); -        //tf2.setValidationVisible(false);    // nothing will happen -        layout.addComponent(tf2); -        final Label lb2 = new Label(property); -        lb2.setCaption("The Value"); -        layout.addComponent(lb2); -        // -        final TextField tf3 = new TextField("No spaces"); -        layout.addComponent(tf3); -        tf3.setComponentError(null); // (actually the default) -        final Button b1 = new Button("Ok!"); -        layout.addComponent(b1); -        b1.addListener(new Button.ClickListener() { -            private static final long serialVersionUID = 1L; -            @Override -            public void buttonClick(ClickEvent event) { -                if (! ((String) tf3.getValue()).matches("^\\w*$")) { -                    tf3.setComponentError(new UserError("Must be letters and numbers")); -                } else { -                    tf3.setComponentError(null); -                } -            } -        }); -        // -        // final Validator intValidator = new Validator() { ... } -        class MyIntValidator implements Validator { -            private static final long serialVersionUID = 1L; -            public boolean isValid(Object value) { -                if (value == null || !(value instanceof String)) { -                    return false; -                } -                return ((String) value).matches("[1-9][0-9]{4}"); -            } -            public void validate(Object value) throws InvalidValueException { -                if (!isValid(value)) { -                    if (value != null && value.toString().startsWith("0")) { -                        throw new InvalidValueException("Must not start with a zero."); -                    } else { -                        throw new InvalidValueException("Must be a number 10000-99999."); -                    } -                } -            } -        }; -        final TextField tf5 = new TextField("MyIntValidator"); -        tf5.addValidator(new MyIntValidator()); -        tf5.setImmediate(true); -        layout.addComponent(tf5); -        // -        class IntegerObjectProperty implements Property { -            private static final long serialVersionUID = 1L; -            Integer data = 0; -            boolean readOnly = false; -            public Class<?> getType() { -                return Integer.class; -            } -            public Object getValue() { -                return data; -            } -            public boolean isReadOnly() { -                return readOnly; -            } -            public void setReadOnly(boolean newStatus) { -                readOnly = newStatus; -            } -            public void setValue(Object newValue) throws ReadOnlyException, ConversionException { -                if (readOnly) -                    throw new ReadOnlyException(); -                if (newValue instanceof Integer) -                    data = (Integer) newValue; -                else if (newValue instanceof String) -                    try { -                        data = Integer.parseInt((String) newValue, 16); -                    } catch (NumberFormatException e) { -                        throw new ConversionException("Must be an integer (from property)"); -                    } -                else -                    throw new ConversionException("Unknown entry type (from property)"); -            } -            @Override -            public String toString() { -                return Integer.toHexString(data)+" (hex)"; -            } -        }; -        final IntegerObjectProperty intProperty = new IntegerObjectProperty(); -        intProperty.setValue(666); -        final TextField tf4 = new TextField("MyObjectProperty",intProperty); -        tf4.setImmediate(true); -        tf4.setErrorHandler(new ComponentErrorHandler() { -            private static final long serialVersionUID = 1L; -            @Override -            public boolean handleComponentError(ComponentErrorEvent event) { -                tf4.setComponentError(new UserError("Must be an integer (from handler)")); -                return true; -            } -        }); -        layout.addComponent(tf4); -        // -        Button nextButton = new Button("next layout"); -        nextButton.setDescription("Go to next layout"); -        layout.addComponent(nextButton ); -        nextButton.addListener( new Button.ClickListener() { -            private static final long serialVersionUID = 1L; -            @Override -            public void buttonClick(ClickEvent event) { -                getApplication().getMainWindow().setContent( new LayoutLayout(ctx) ); -            } -        }); -        // -        return panel; -    } -} diff --git a/vaadin-app/src/ch/asynk/helloworld/EndLayout.java b/vaadin-app/src/ch/asynk/helloworld/EndLayout.java deleted file mode 100644 index 2b5c15f..0000000 --- a/vaadin-app/src/ch/asynk/helloworld/EndLayout.java +++ /dev/null @@ -1,31 +0,0 @@ -package ch.asynk.helloworld; - -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; - -public class EndLayout extends VerticalLayout { -    // -    private static final long serialVersionUID = 1L; -    // -    private Context ctx = null; - -    public EndLayout(Context context) { -        ctx = context; -        // -        final Label lb1 = new Label(); -        lb1.setCaption("That's all folks"); -        addComponent(lb1); -        // -        Button closeButton = new Button("close the application"); -        closeButton.setDescription("This will close the application"); -        addComponent(closeButton ); -        closeButton.addListener( new Button.ClickListener() { -            @Override -            public void buttonClick(ClickEvent event) { -                getApplication().getMainWindow().getApplication().close(); -            } -        }); -    } -}; diff --git a/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java b/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java deleted file mode 100644 index d5e3091..0000000 --- a/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java +++ /dev/null @@ -1,42 +0,0 @@ -package ch.asynk.helloworld; - -import com.vaadin.Application; -import com.vaadin.terminal.Terminal; -import com.vaadin.terminal.Sizeable; -import com.vaadin.ui.Window; - -public class HelloWorldApp extends Application { -    // -    private static final long serialVersionUID = 1L; -    // -    private Context ctx = null; -    public Context getCtx() { -        return ctx; -    } -    // -    @Override -    public void init() { -        ctx = new Context(this); -        setTheme("asynk"); -        final Window mainWindow = new Window("Hello World Application"); -        mainWindow.setWidth(900,Sizeable.UNITS_PIXELS); -        setMainWindow(mainWindow); -        mainWindow.setContent( new MainLayout(ctx) ); -        setLogoutURL("http://asynk.ch"); -        ctx.getLogger().warning("hell : "+ctx.getProps().getProperty("hello.next")+" "+ctx.getProps().getProperty("hello.world")); -    } - -    public void notifyError(String title, String msg){ -        getMainWindow().showNotification(title,msg,Window.Notification.TYPE_ERROR_MESSAGE); -    } - -    @Override -    public void terminalError(Terminal.ErrorEvent event) { -        // Call the default implementation. -        super.terminalError(event); -        // Some custom behaviour. -        if (getMainWindow() != null) { -            getMainWindow().showNotification("An unchecked exception occured!", event.getThrowable().toString(), Window.Notification.TYPE_ERROR_MESSAGE); -        } -    } -} diff --git a/vaadin-app/src/ch/asynk/helloworld/LayoutLayout.java b/vaadin-app/src/ch/asynk/helloworld/LayoutLayout.java deleted file mode 100644 index 6ebb1e3..0000000 --- a/vaadin-app/src/ch/asynk/helloworld/LayoutLayout.java +++ /dev/null @@ -1,109 +0,0 @@ -package ch.asynk.helloworld; - -import com.vaadin.ui.Alignment; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.AbstractComponent; -import com.vaadin.ui.Panel; -import com.vaadin.ui.Label; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.ListSelect; - -public class LayoutLayout extends VerticalLayout { -    // -    private static final long serialVersionUID = 1L; -    // -    private Context ctx = null; - -    public LayoutLayout(Context context) { -        ctx = context; -        // -        final AbstractComponent topComponent = buildTopComponent(); -        topComponent.setWidth(500,UNITS_PIXELS); -        topComponent.setHeight(400,UNITS_PIXELS); -        addComponent(topComponent); -        setComponentAlignment(topComponent, Alignment.MIDDLE_CENTER); -        // -        final AbstractComponent grid = buildGrid(); -        grid.setSizeFull(); -        addComponent(grid); -        // -        Button nextButton = new Button("next layout"); -        nextButton.setDescription("Go to next layout"); -        addComponent(nextButton ); -        nextButton.addListener( new Button.ClickListener() { -            @Override -            public void buttonClick(ClickEvent event) { -                getApplication().getMainWindow().setContent( new EndLayout(ctx) ); -            } -        }); -    } - -    private AbstractComponent buildTopComponent() { - -        Panel panel = new Panel("Panel 1"); -        VerticalLayout layout = (VerticalLayout) panel.getContent(); -        layout.setMargin(true); -        layout.setSpacing(true); -        layout.setHeight(100,UNITS_PERCENTAGE); -        // -        float width  = 90; -        float height = 100; -        // -        ListSelect receptionList = new ListSelect("List 1"); -        receptionList.setWidth(width, UNITS_PERCENTAGE); -        receptionList.setHeight(height, UNITS_PERCENTAGE); -        layout.addComponent(receptionList); -        // -        ListSelect splitList = new ListSelect("List 2"); -        splitList.setWidth(width, UNITS_PERCENTAGE); -        splitList.setHeight(height, UNITS_PERCENTAGE); -        layout.addComponent(splitList); -        // -        ListSelect ctrlList = new ListSelect("Liste 3"); -        ctrlList.setWidth(width, UNITS_PERCENTAGE); -        ctrlList.setHeight(height, UNITS_PERCENTAGE); -        layout.addComponent(ctrlList); -        // -        Button goButton = new Button("Select"); -        goButton.setHeight(height, UNITS_PERCENTAGE); -        layout.addComponent(goButton); -        // -        layout.setExpandRatio(receptionList,3.0f); -        layout.setExpandRatio(splitList,3.0f); -        layout.setExpandRatio(ctrlList,3.0f); -        layout.setExpandRatio(goButton,1.0f); -        layout.setComponentAlignment(goButton, Alignment.MIDDLE_CENTER); -        // -        return panel; -    } - -    private AbstractComponent buildGrid() { -        Panel panel = new Panel("Grid Panel"); -        VerticalLayout layout = (VerticalLayout) panel.getContent(); -        layout.setMargin(true); -        layout.setSpacing(true); -        layout.setHeight(100,UNITS_PERCENTAGE); -        // -        GridLayout grid = new GridLayout(3, 3); -        grid.setSizeFull(); -        grid.addStyleName("mygrid"); -        // excess space usage -        //grid.setColumnExpandRatio(1, 1); -        //grid.setColumnExpandRatio(2, 5); -        //grid.setRowExpandRatio(1, 1); -        Button b0 = new Button("[0;0] [0;2]"); -        b0.setSizeFull(); -        grid.addComponent(b0,0,0,0,2); -        final Panel p2 = new Panel("Panel 2"); -        p2.setSizeFull(); -        grid.addComponent(p2,1,0,2,1); -        Button b1 = new Button("[1;2] [2;2]"); -        b1.setSizeFull(); -        grid.addComponent(b1,1,2,2,2); -        panel.setContent(grid); -        // -        return panel; -    } -} diff --git a/vaadin-app/src/ch/asynk/helloworld/MainLayout.java b/vaadin-app/src/ch/asynk/helloworld/MainLayout.java deleted file mode 100644 index d4481c1..0000000 --- a/vaadin-app/src/ch/asynk/helloworld/MainLayout.java +++ /dev/null @@ -1,75 +0,0 @@ -package ch.asynk.helloworld; - -import java.util.Date; - -import com.vaadin.terminal.UserError; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.AbstractComponent; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.Panel; -import com.vaadin.ui.Label; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Window.Notification; - -public class MainLayout extends VerticalLayout { -    // -    private static final long serialVersionUID = 1L; -    // -    private Context ctx = null; - -    public MainLayout(Context context) { -        ctx = context; -        // -        final AbstractComponent pa = buildPanel(); -        pa.setWidth(250,UNITS_PIXELS); -        pa.setHeight(300,UNITS_PIXELS); -        addComponent(pa); -        setComponentAlignment(pa, Alignment.MIDDLE_CENTER); -        // -    } - -    private AbstractComponent buildPanel() { -        Panel panel = new Panel("Main Layout"); -        VerticalLayout layout = (VerticalLayout) panel.getContent(); -        layout.setMargin(true); -        layout.setSpacing(true); -        layout.setHeight(100,UNITS_PERCENTAGE); -        // -        Label label = new Label("Hello world"); -        layout.addComponent(label); -        // -        Button clockBtn = new Button("What is the time?"); -        layout.addComponent( clockBtn ); -        clockBtn.setIcon(Resources.clockIcon); -        clockBtn.addListener( new Button.ClickListener() { -            private static final long serialVersionUID = 1L; -            @Override -            public void buttonClick(ClickEvent event) { -                ctx.getApp().notifyError("The time is " + new Date(), "<i>italic</i> <b>bold</b> description"); -                event.getButton().setComponentError( new UserError("Stop pressing this button !!") ); -            } -        }); -        /// -        layout.addComponent( new Button("throw an exception", new Button.ClickListener() { -            private static final long serialVersionUID = 1L; -            @Override -            public void buttonClick(ClickEvent event) { -                throw new RuntimeException("Wahou !! : exception"); -            } -        })); -        // -        Button nextButton = new Button("next layout"); -        nextButton.setDescription("Go to next layout"); -        layout.addComponent(nextButton ); -        nextButton.addListener( new Button.ClickListener() { -            private static final long serialVersionUID = 1L; -            @Override -            public void buttonClick(ClickEvent event) { -                ctx.getApp().getMainWindow().setContent( new DataMappingLayout(ctx) ); -            } -        }); -        // -        return panel; -    } -} diff --git a/vaadin-app/src/ch/asynk/helloworld/Resources.java b/vaadin-app/src/ch/asynk/helloworld/Resources.java deleted file mode 100644 index dcf0449..0000000 --- a/vaadin-app/src/ch/asynk/helloworld/Resources.java +++ /dev/null @@ -1,9 +0,0 @@ -package ch.asynk.helloworld; - -import com.vaadin.terminal.ThemeResource; - -public class Resources { - -	private static final long serialVersionUID = 1L; -    public static final ThemeResource clockIcon = new ThemeResource("icons/clock.png"); -}  | 
