incubator-kalumet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject svn commit: r1205585 [15/23] - in /incubator/kalumet/trunk: ./ console/ console/src/main/java/org/apache/kalumet/console/app/ console/src/main/resources/org/apache/kalumet/console/app/templates/
Date Wed, 23 Nov 2011 20:52:25 GMT
Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/JournalPane.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/JournalPane.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/JournalPane.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/JournalPane.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,331 @@
+/*
+ * 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.kalumet.console.app;
+
+import java.util.Iterator;
+
+import nextapp.echo2.app.Button;
+import nextapp.echo2.app.Column;
+import nextapp.echo2.app.ContentPane;
+import nextapp.echo2.app.Extent;
+import nextapp.echo2.app.Grid;
+import nextapp.echo2.app.Insets;
+import nextapp.echo2.app.Label;
+import nextapp.echo2.app.Row;
+import nextapp.echo2.app.SelectField;
+import nextapp.echo2.app.TextField;
+import nextapp.echo2.app.event.ActionEvent;
+import nextapp.echo2.app.event.ActionListener;
+
+import org.apache.commons.collections.iterators.ReverseListIterator;
+import org.apache.commons.lang.StringUtils;
+import org.apache.kalumet.console.configuration.ConfigurationManager;
+import org.apache.kalumet.model.log.Event;
+import org.apache.kalumet.model.log.Journal;
+
+/**
+ * Environment journal pane.
+ */
+public class JournalPane extends ContentPane {
+
+    private EnvironmentWindow parent;
+    private TextField filterField;
+    private SelectField rowLimitField;
+    private TextField newEventField;
+    private Grid journalGrid;
+    private Grid currentGrid;
+
+    // row limit
+    private ActionListener rowLimit = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            JournalPane.this.update();
+        }
+    };
+    // filter
+    private ActionListener filter = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            JournalPane.this.update();
+        }
+    };
+    // create
+    private ActionListener create = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            // check if the user has the environment lock
+            if (!getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // get the event message
+            String eventMessage = newEventField.getText();
+            // check field
+            if (eventMessage == null || eventMessage.trim().length() < 1) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("journal.mandatory"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // add the message
+            parent.getChangeEvents().add(eventMessage);
+            // update the pane
+            update();
+        }
+    };
+    // purge
+    private ActionListener purge = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            // check if the user has the environment lock
+            if (!getEnvironmentWindow().getEnvironment().getLock().equals(KalumetConsoleApplication.getApplication().getUserid())) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("environment.locked"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // check if the user can do it
+            if (!getEnvironmentWindow().adminPermission) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("action.restricted"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // create a confirm window
+            KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ConfirmWindow(new ActionListener() {
+                public void actionPerformed(ActionEvent event) {
+                    // create a new empty journal
+                    Journal journal = new Journal();
+                    try {
+                        journal.writeXMLFile(ConfigurationManager.getEnvironmentJournalFile(parent.getEnvironmentName()));
+                    } catch (Exception e) {
+                        KalumetConsoleApplication.getApplication().getLogPane().addError(Messages.getString("journal.write") + ": " + e.getMessage(), getEnvironmentWindow().getEnvironmentName());
+                        return;
+                    }
+                    // update the pane
+                    update();
+                }
+            }));
+
+        }
+    };
+    // delete
+    private ActionListener delete = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            // create a confirm window
+            KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ConfirmWindow(new ActionListener() {
+                public void actionPerformed(ActionEvent event) {
+
+                    // get the index
+                    int index = new Integer(event.getActionCommand()).intValue();
+                    if (index == -1) {
+                        return;
+                    }
+                    // remove
+                    parent.getChangeEvents().remove(index);
+                    // update the pane
+                    update();
+                }
+            }));
+        }
+    };
+
+    /**
+     * Create a new <code>JournalPane</code>
+     *
+     * @param parent the parent <code>EnvironmentWindow</code>.
+     */
+    public JournalPane(EnvironmentWindow parent) {
+        super();
+        setStyleName("tab.content");
+
+        // update parent
+        this.parent = parent;
+
+        // column layout
+        Column content = new Column();
+        content.setCellSpacing(new Extent(2));
+        add(content);
+
+        // add filter layout grid
+        Grid filterGrid = new Grid(2);
+        filterGrid.setStyleName("default");
+        content.add(filterGrid);
+
+        // add row limit field
+        Label rowLimitLabel = new Label(Messages.getString("rows"));
+        rowLimitLabel.setStyleName("default");
+        filterGrid.add(rowLimitLabel);
+        String[] labels = new String[]{"10", "25", "50", "100", "200", Messages.getString("all")};
+        rowLimitField = new SelectField(labels);
+        rowLimitField.setStyleName("default");
+        rowLimitField.setSelectedIndex(0);
+        rowLimitField.addActionListener(rowLimit);
+        filterGrid.add(rowLimitField);
+
+        // add filter field
+        Label filterLabel = new Label(Messages.getString("filter"));
+        filterLabel.setStyleName("default");
+        filterGrid.add(filterLabel);
+        Row filterRow = new Row();
+        filterGrid.add(filterRow);
+        filterField = new TextField();
+        filterField.setStyleName("default");
+        filterField.addActionListener(filter);
+        filterRow.add(filterField);
+        Button filterApplyButton = new Button(Styles.ACCEPT);
+        filterApplyButton.setStyleName("default");
+        filterApplyButton.addActionListener(filter);
+        filterRow.add(filterApplyButton);
+
+        // add purge button
+        if (getEnvironmentWindow().adminPermission) {
+            Row purgeRow = new Row();
+            content.add(purgeRow);
+            Button purgeButton = new Button(Messages.getString("purge"), Styles.DELETE);
+            purgeButton.addActionListener(purge);
+            purgeRow.add(purgeButton);
+        }
+
+        // add journal log grid
+        journalGrid = new Grid(4);
+        journalGrid.setStyleName("border.grid");
+        content.add(journalGrid);
+
+        // add the current log grid
+        currentGrid = new Grid(2);
+        currentGrid.setStyleName("border.grid");
+        currentGrid.setColumnWidth(0, new Extent(50, Extent.PX));
+        content.add(currentGrid);
+
+        // update the pane
+        update();
+    }
+
+    /**
+     * Update the pane
+     */
+    public void update() {
+        // update journal log grid
+        // remove all log grid children
+        journalGrid.removeAll();
+        // add log grid header
+        Label dateHeader = new Label(Messages.getString("date"));
+        dateHeader.setStyleName("grid.header");
+        journalGrid.add(dateHeader);
+        Label severityHeader = new Label(Messages.getString("severity"));
+        severityHeader.setStyleName("grid.header");
+        journalGrid.add(severityHeader);
+        Label authorHeader = new Label(Messages.getString("author"));
+        authorHeader.setStyleName("grid.header");
+        journalGrid.add(authorHeader);
+        Label messageHeader = new Label(Messages.getString("message"));
+        messageHeader.setStyleName("grid.header");
+        journalGrid.add(messageHeader);
+        // load the journal log
+        Journal journal = null;
+        try {
+            journal = ConfigurationManager.loadEnvironmentJournal(parent.getEnvironmentName());
+        } catch (Exception e) {
+            KalumetConsoleApplication.getApplication().getLogPane().addError(Messages.getString("journal.read") + ": " + e.getMessage());
+            return;
+        }
+        // get the limit
+        int rowLimit = -1;
+        if (rowLimitField.getSelectedIndex() == 0) {
+            rowLimit = 10;
+        }
+        if (rowLimitField.getSelectedIndex() == 1) {
+            rowLimit = 25;
+        }
+        if (rowLimitField.getSelectedIndex() == 2) {
+            rowLimit = 50;
+        }
+        if (rowLimitField.getSelectedIndex() == 3) {
+            rowLimit = 100;
+        }
+        if (rowLimitField.getSelectedIndex() == 4) {
+            rowLimit = 200;
+        }
+        int index = 0;
+        for (ReverseListIterator eventIterator = new ReverseListIterator(journal.getEvents()); eventIterator.hasNext(); ) {
+            Event event = (Event) eventIterator.next();
+            if (filterField.getText() == null
+                    || filterField.getText().trim().length() < 1
+                    || (filterField.getText() != null && (StringUtils.containsIgnoreCase(event.getDate(), filterField.getText()) || StringUtils.containsIgnoreCase(event.getSeverity(), filterField.getText())
+                    || StringUtils.containsIgnoreCase(event.getAuthor(), filterField.getText()) || StringUtils.containsIgnoreCase(event.getContent(), filterField.getText())))) {
+                Label eventDate = new Label(event.getDate());
+                eventDate.setStyleName("default");
+                journalGrid.add(eventDate);
+                Label eventSeverity = new Label(event.getSeverity());
+                eventSeverity.setStyleName("default");
+                journalGrid.add(eventSeverity);
+                Label eventAuthor = new Label(event.getAuthor());
+                eventAuthor.setStyleName("default");
+                journalGrid.add(eventAuthor);
+                Label eventContent = new Label(event.getContent());
+                eventContent.setStyleName("default");
+                journalGrid.add(eventContent);
+            }
+            if (rowLimit != -1 && index >= rowLimit) {
+                break;
+            }
+            index++;
+        }
+        // update the current log grid
+        // remove all current log grid children
+        currentGrid.removeAll();
+        // add current log grid header
+        Label currentEventAction = new Label(" ");
+        currentEventAction.setStyleName("grid.header");
+        currentGrid.add(currentEventAction);
+        Label currentEventContent = new Label(Messages.getString("message"));
+        currentEventContent.setStyleName("grid.header");
+        currentGrid.add(currentEventContent);
+        // add new event row
+        Row row = new Row();
+        row.setInsets(new Insets(2));
+        row.setCellSpacing(new Extent(2));
+        currentGrid.add(row);
+        Button createButton = new Button(Styles.ADD);
+        createButton.addActionListener(create);
+        row.add(createButton);
+        newEventField = new TextField();
+        newEventField.setStyleName("default");
+        newEventField.setWidth(new Extent(500, Extent.PX));
+        currentGrid.add(newEventField);
+        // add current event
+        for (Iterator currentEventIterator = new ReverseListIterator(parent.getChangeEvents()); currentEventIterator.hasNext(); ) {
+            String message = (String) currentEventIterator.next();
+            // row
+            Row currentRow = new Row();
+            currentRow.setCellSpacing(new Extent(2));
+            currentRow.setInsets(new Insets(2));
+            currentGrid.add(row);
+            // delete
+            Button deleteButton = new Button(Styles.DELETE);
+            deleteButton.setToolTipText(Messages.getString("delete"));
+            deleteButton.setActionCommand(new Integer(parent.getChangeEvents().indexOf(message)).toString());
+            deleteButton.addActionListener(delete);
+            currentRow.add(deleteButton);
+            // message field
+            TextField messageField = new TextField();
+            messageField.setStyleName("default");
+            messageField.setWidth(new Extent(100, Extent.PERCENT));
+            messageField.setId("journalmessage_" + parent.getEnvironmentName() + "_" + parent.getChangeEvents().indexOf(message));
+            messageField.setText(message);
+            currentGrid.add(messageField);
+        }
+    }
+
+    public EnvironmentWindow getEnvironmentWindow() {
+        return parent;
+    }
+
+}
\ No newline at end of file

Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/KalumetConsoleApplication.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/KalumetConsoleApplication.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/KalumetConsoleApplication.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/KalumetConsoleApplication.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,189 @@
+/*
+ * 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.kalumet.console.app;
+
+import nextapp.echo2.app.ApplicationInstance;
+import nextapp.echo2.app.TaskQueueHandle;
+import nextapp.echo2.app.Window;
+import nextapp.echo2.webcontainer.ContainerContext;
+import org.apache.kalumet.console.configuration.ConfigurationManager;
+import org.apache.kalumet.console.utils.LdapUtils;
+import org.apache.kalumet.console.utils.StackTraceUtils;
+import org.apache.kalumet.model.Kalumet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This is the Kalumet Console Echo2 application.
+ */
+public class KalumetConsoleApplication extends ApplicationInstance {
+
+    private final static transient Logger LOGGER = LoggerFactory.getLogger(KalumetConsoleApplication.class);
+
+    // the user logged in
+    private String userid;
+    // the environments pane of the current user
+    private EnvironmentsPane environmentsPane;
+    // the log pane of the current user
+    private LogPane logPane;
+    // the current copy object
+    private Object copyComponent = null;
+    // the task queue handle to manage asynchronous task
+    private TaskQueueHandle taskQueue;
+
+    // define the async update interval (60 sec.).
+    private final static int ASYNC_UPDATE_INTERVAL = 60000;
+
+    /**
+     * Convenience method to return the active Kalumet Console application as
+     * <code>KalumetConsoleApplication</code>.
+     *
+     * @return the active <code>KalumetConsoleApplication</code>.
+     */
+    public static KalumetConsoleApplication getApplication() {
+        return (KalumetConsoleApplication) getActive();
+    }
+
+    public String getUserid() {
+        return this.userid;
+    }
+
+    public void setEnvironmentsPane(EnvironmentsPane environmentsPane) {
+        this.environmentsPane = environmentsPane;
+    }
+
+    public EnvironmentsPane getEnvironmentsPane() {
+        return this.environmentsPane;
+    }
+
+    public void setLogPane(LogPane logPane) {
+        this.logPane = logPane;
+    }
+
+    public LogPane getLogPane() {
+        return this.logPane;
+    }
+
+    public void setCopyComponent(Object copyComponent) {
+        this.copyComponent = copyComponent;
+    }
+
+    public Object getCopyComponent() {
+        return this.copyComponent;
+    }
+
+    public TaskQueueHandle getTaskQueue() {
+        return this.taskQueue;
+    }
+
+    /**
+     * Authenticate an user into Kalumet Console and display the main screen if success.
+     *
+     * @param userid   the user name.
+     * @param password the user password.
+     * @return true if the user is identified, false else.
+     */
+    public boolean connect(String userid, String password) {
+        // check the userid and password
+        if (userid == null || userid.trim().length() < 1 || password == null || password.trim().length() < 1) {
+            KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ErrorWindow(Messages.getString("error.authentication"), Messages.getString("error.authentication.badpassword")));
+            return false;
+        }
+        // load the Kalumet configuration
+        Kalumet kalumet = null;
+        try {
+            kalumet = ConfigurationManager.loadStore();
+        } catch (Exception e) {
+            KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ErrorWindow(Messages.getString("db.read"), e.getMessage() + "\n\n" + StackTraceUtils.toString(e.getStackTrace())));
+            return false;
+        }
+
+        try {
+            boolean authenticated = false;
+            if (userid.equals("admin")) {
+                // if the user is the admin look for the authentication is Kalumet only
+                if (kalumet.getSecurity().identifyUser(userid, password)) {
+                    authenticated = true;
+                }
+            } else {
+                // it's a "normal" user, check if I need to use a LDAP or not
+                if (kalumet.getProperty("LdapAuthentication").getValue().equals("true")) {
+                    // bind on a LDAP
+                    if (LdapUtils.bind(userid, password)) {
+                        authenticated = true;
+                    }
+                } else {
+                    // use Kalumet internal authentication
+                    if (kalumet.getSecurity().identifyUser(userid, password)) {
+                        authenticated = true;
+                    }
+                }
+            }
+            if (authenticated) {
+                // store the userid
+                this.userid = userid;
+                // display the main screen
+                this.getDefaultWindow().setContent(new MainScreen());
+                // init the application task handler
+                this.taskQueue = this.createTaskQueue();
+                // define the async update interval
+                ContainerContext containerContext = (ContainerContext) getContextProperty(ContainerContext.CONTEXT_PROPERTY_NAME);
+                containerContext.setTaskQueueCallbackInterval(this.taskQueue, ASYNC_UPDATE_INTERVAL);
+                // the user is authenticated
+                return true;
+            }
+        } catch (Exception e) {
+            KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ErrorWindow(Messages.getString("error.authentication"), e.getMessage() + "\n\n" + StackTraceUtils.toString(e.getStackTrace())));
+            return false;
+        }
+        KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ErrorWindow(Messages.getString("error.authentication"), Messages.getString("error.authentication.badpassword")));
+        return false;
+    }
+
+    /**
+     * Disconnect the session and display the authentication screen.
+     */
+    public void disconnect() {
+        this.userid = null;
+        this.copyComponent = null;
+        // delete the application task queue
+        this.removeTaskQueue(this.taskQueue);
+        getDefaultWindow().setContent(new LoginScreen());
+    }
+
+    /**
+     * Initializes the Kalumet Console window.
+     *
+     * @return the login screen.
+     */
+    public Window init() {
+        // load the default style sheet
+        setStyleSheet(Styles.DEFAULT_STYLE_SHEET);
+
+        // create the main window
+        Window window = new Window();
+        window.setTitle(Messages.getString("kalumet.console"));
+
+        // load the login screen into the window
+        window.setContent(new LoginScreen());
+
+        return window;
+    }
+
+}

Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/KalumetConsoleServlet.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/KalumetConsoleServlet.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/KalumetConsoleServlet.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/KalumetConsoleServlet.java Wed Nov 23 20:52:16 2011
@@ -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.kalumet.console.app;
+
+import nextapp.echo2.app.ApplicationInstance;
+import nextapp.echo2.webcontainer.WebContainerServlet;
+
+/**
+ * This is the echo-specific of a HttpServlet. This servlet is responsible for
+ * processing all requests from the client-side Echo engine, including rendering
+ * the initial HTML page, handling XML sync services, and sending graphic
+ * images to the client. All such client interaction work is done behind the scene.
+ */
+public class KalumetConsoleServlet extends WebContainerServlet {
+
+    public ApplicationInstance newApplicationInstance() {
+        return new KalumetConsoleApplication();
+    }
+
+}

Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/LogPane.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/LogPane.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/LogPane.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/LogPane.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,164 @@
+/*
+ * 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.kalumet.console.app;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import nextapp.echo2.app.ContentPane;
+import nextapp.echo2.app.Extent;
+import nextapp.echo2.app.Grid;
+import nextapp.echo2.app.Label;
+import nextapp.echo2.app.SplitPane;
+
+/**
+ * Log <code>ContentPane</code>.
+ */
+public class LogPane extends ContentPane {
+
+    private Grid mainGrid;
+
+    /**
+     * Create a new <code>LogPane</code>.
+     */
+    public LogPane() {
+        super();
+
+        // define a title pane
+        SplitPane titlePane = new SplitPane(SplitPane.ORIENTATION_VERTICAL_TOP_BOTTOM, new Extent(20));
+        titlePane.setResizable(false);
+        add(titlePane);
+        Label titleLabel = new Label(Messages.getString("log"));
+        titleLabel.setStyleName("log");
+        titlePane.add(titleLabel);
+
+        // define the main pane
+        mainGrid = new Grid(4);
+        mainGrid.setStyleName("log");
+        mainGrid.setColumnWidth(0, new Extent(10, Extent.PX));
+        mainGrid.setColumnWidth(1, new Extent(10, Extent.PERCENT));
+        mainGrid.setColumnWidth(2, new Extent(10, Extent.PERCENT));
+        mainGrid.setColumnWidth(3, new Extent(80, Extent.PERCENT));
+        titlePane.add(mainGrid);
+    }
+
+    /**
+     * Add a generic event into the log pane.
+     *
+     * @param message the event message.
+     * @param scope   the event scope.
+     */
+    private void addEvent(String message, String scope) {
+        SimpleDateFormat dateFormatter = new SimpleDateFormat("MM/dd/yyyy HH:mm");
+        Label dateLabel = new Label(dateFormatter.format(new Date()));
+        dateLabel.setStyleName("default");
+        mainGrid.add(dateLabel, 1);
+        Label scopeLabel = new Label(scope);
+        scopeLabel.setStyleName("default");
+        mainGrid.add(scopeLabel, 2);
+        Label messageLabel = new Label(message);
+        messageLabel.setStyleName("default");
+        mainGrid.add(messageLabel, 3);
+    }
+
+    /**
+     * Add a confirmation message on a given scope.
+     *
+     * @param message the confirmation message.
+     * @param scope   the confirmation scope.
+     */
+    public void addConfirm(String message, String scope) {
+        Label iconLabel = new Label(Styles.ACCEPT);
+        mainGrid.add(iconLabel, 0);
+        addEvent(message, scope);
+    }
+
+    /**
+     * Add a confirmation message.
+     *
+     * @param message
+     */
+    public void addConfirm(String message) {
+        this.addConfirm(message, "");
+    }
+
+    /**
+     * Add an info into the log pane on a given scope.
+     *
+     * @param message the info message.
+     * @param scope   the info scope.
+     */
+    public void addInfo(String message, String scope) {
+        Label iconLabel = new Label(Styles.INFORMATION);
+        mainGrid.add(iconLabel, 0);
+        addEvent(message, scope);
+    }
+
+    /**
+     * Add an info into the log pane.
+     *
+     * @param message the info message.
+     */
+    public void addInfo(String message) {
+        this.addInfo(message, "");
+    }
+
+    /**
+     * Add a warning into the log pane on a given scope.
+     *
+     * @param message the warning message.
+     * @param scope   the warning scope.
+     */
+    public void addWarning(String message, String scope) {
+        Label iconLabel = new Label(Styles.ERROR);
+        mainGrid.add(iconLabel, 0);
+        addEvent(message, scope);
+    }
+
+    /**
+     * Add a warning into the log pane.
+     *
+     * @param message the warning message.
+     */
+    public void addWarning(String message) {
+        this.addWarning(message, "");
+    }
+
+    /**
+     * Add an error into the log pane on a given scope.
+     *
+     * @param message the error message.
+     * @param scope   the error scope.
+     */
+    public void addError(String message, String scope) {
+        Label iconLabel = new Label(Styles.EXCLAMATION);
+        mainGrid.add(iconLabel, 0);
+        addEvent(message, scope);
+    }
+
+    /**
+     * Add an error into the log pane.
+     *
+     * @param message the error message.
+     */
+    public void addError(String message) {
+        this.addError(message, "");
+    }
+
+}
\ No newline at end of file

Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/LogViewerPane.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/LogViewerPane.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/LogViewerPane.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/LogViewerPane.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,116 @@
+/*
+ * 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.kalumet.console.app;
+
+import java.util.Iterator;
+
+import nextapp.echo2.app.Button;
+import nextapp.echo2.app.ContentPane;
+import nextapp.echo2.app.Grid;
+import nextapp.echo2.app.Label;
+import nextapp.echo2.app.event.ActionEvent;
+import nextapp.echo2.app.event.ActionListener;
+import org.apache.kalumet.model.LogFile;
+
+/**
+ * Environment log viewer pane.
+ */
+public class LogViewerPane extends ContentPane {
+
+    private EnvironmentWindow parent;
+    private Grid grid;
+
+    // view
+    private ActionListener view = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            String logFileName = event.getActionCommand();
+            // looking for the log file
+            LogFile logFile = parent.getEnvironment().getLogFile(logFileName);
+            if (logFile == null) {
+                KalumetConsoleApplication.getApplication().getLogPane().addError(Messages.getString("logfile.notfound"), parent.getEnvironmentName());
+                return;
+            }
+            // define which agent to use
+            String agentId;
+            if (logFile.getAgent() != null && logFile.getAgent().trim().length() > 0) {
+                agentId = logFile.getAgent();
+            } else {
+                agentId = parent.getEnvironment().getAgent();
+            }
+            // open a view file window
+            KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ViewFileWindow(logFile.getPath(), agentId));
+        }
+    };
+
+    /**
+     * Create a new <code>LogViewerPane</code>.
+     *
+     * @param parent the parent <code>EnvironmentWindow</code>.
+     */
+    public LogViewerPane(EnvironmentWindow parent) {
+        super();
+        this.setStyleName("tab.content");
+
+        // update the parent
+        this.parent = parent;
+
+        grid = new Grid(3);
+        grid.setStyleName("border.grid");
+        add(grid);
+
+        // update the pane
+        update();
+    }
+
+    /**
+     * Update the pane.
+     */
+    public void update() {
+        grid.removeAll();
+        // add grid headers
+        // name header
+        Label nameHeader = new Label(Messages.getString("name"));
+        nameHeader.setStyleName("grid.header");
+        grid.add(nameHeader);
+        // path header
+        Label pathHeader = new Label(Messages.getString("path"));
+        pathHeader.setStyleName("grid.header");
+        grid.add(pathHeader);
+        // agent header
+        Label agentHeader = new Label(Messages.getString("agent"));
+        agentHeader.setStyleName("grid.header");
+        grid.add(agentHeader);
+        // iterator in the log pane
+        for (Iterator logFileIterator = parent.getEnvironment().getLogFiles().iterator(); logFileIterator.hasNext(); ) {
+            LogFile logFile = (LogFile) logFileIterator.next();
+            // name
+            Button name = new Button(logFile.getName());
+            name.setActionCommand(logFile.getName());
+            name.addActionListener(view);
+            grid.add(name);
+            // path
+            Label path = new Label(logFile.getPath());
+            grid.add(path);
+            // agent
+            Label agent = new Label(logFile.getAgent());
+            grid.add(agent);
+        }
+    }
+
+}
\ No newline at end of file

Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/LoginScreen.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/LoginScreen.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/LoginScreen.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/LoginScreen.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,163 @@
+/*
+ * 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.kalumet.console.app;
+
+import nextapp.echo2.app.Button;
+import nextapp.echo2.app.ContentPane;
+import nextapp.echo2.app.Extent;
+import nextapp.echo2.app.Grid;
+import nextapp.echo2.app.Label;
+import nextapp.echo2.app.PasswordField;
+import nextapp.echo2.app.Row;
+import nextapp.echo2.app.SplitPane;
+import nextapp.echo2.app.TextField;
+import nextapp.echo2.app.WindowPane;
+import nextapp.echo2.app.event.ActionEvent;
+import nextapp.echo2.app.event.ActionListener;
+
+/**
+ * Login screen <code>ContentPane</code>.
+ */
+public class LoginScreen extends ContentPane {
+
+    private TextField usernameField;
+    private PasswordField passwordField;
+
+    // the menu listener
+    private ActionListener aboutButtonActionListener = new ActionListener() {
+
+        public void actionPerformed(ActionEvent event) {
+            if (KalumetConsoleApplication.getApplication().getDefaultWindow().getComponent("about") == null) {
+                KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new AboutWindow());
+            }
+        }
+
+    };
+
+    /**
+     * Create a new <code>LoginScreen</code>.
+     */
+    public LoginScreen() {
+        super();
+
+        // define a title pane
+        SplitPane titlePane = new SplitPane(SplitPane.ORIENTATION_VERTICAL_TOP_BOTTOM, new Extent(30, Extent.PX));
+        titlePane.setResizable(false);
+        add(titlePane);
+        Label titleLabel = new Label(Messages.getString("kalumet.console"));
+        titleLabel.setStyleName("title");
+        titlePane.add(titleLabel);
+
+        // create a menu pane
+        SplitPane menuPane = new SplitPane(SplitPane.ORIENTATION_VERTICAL, new Extent(26));
+        menuPane.setResizable(false);
+        titlePane.add(menuPane);
+
+        // create the menu row
+        Row menuRow = new Row();
+        menuRow.setStyleName("menu");
+        menuPane.add(menuRow);
+        Button aboutButton = new Button(Messages.getString("about"), Styles.INFORMATION);
+        aboutButton.setStyleName("default");
+        aboutButton.addActionListener(aboutButtonActionListener);
+        menuRow.add(aboutButton);
+
+        // create the split central pane
+        SplitPane mainPane = new SplitPane(SplitPane.ORIENTATION_HORIZONTAL_LEFT_RIGHT, new Extent(200, Extent.PX));
+        menuPane.add(mainPane);
+        ContentPane leftPane = new ContentPane();
+        leftPane.setStyleName("left");
+        mainPane.add(leftPane);
+        ContentPane centralPane = new ContentPane();
+        centralPane.setStyleName("central");
+        mainPane.add(centralPane);
+
+        // create a new window for login fields
+        WindowPane loginWindow = new WindowPane();
+        loginWindow.setStyleName("login");
+        loginWindow.setTitle(Messages.getString("login"));
+        loginWindow.setIcon(Styles.USER);
+        loginWindow.setDefaultCloseOperation(WindowPane.DO_NOTHING_ON_CLOSE);
+        add(loginWindow);
+
+        SplitPane splitPane = new SplitPane(SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent(32));
+        loginWindow.add(splitPane);
+
+        Row controlRow = new Row();
+        controlRow.setStyleName("control");
+        splitPane.add(controlRow);
+
+        Button button = new Button(Messages.getString("continue"), Styles.ACCEPT);
+        button.setStyleName("control");
+        button.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                processLogin();
+            }
+        });
+        controlRow.add(button);
+
+        Grid layoutGrid = new Grid();
+        layoutGrid.setStyleName("login");
+        splitPane.add(layoutGrid);
+
+        Label label = new Label(Messages.getString("username"));
+        label.setStyleName("default");
+        layoutGrid.add(label);
+
+        usernameField = new TextField();
+        usernameField.setStyleName("default");
+        usernameField.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                KalumetConsoleApplication.getApplication().setFocusedComponent(passwordField);
+            }
+        });
+        layoutGrid.add(usernameField);
+
+        label = new Label(Messages.getString("password"));
+        label.setStyleName("default");
+        layoutGrid.add(label);
+
+        passwordField = new PasswordField();
+        passwordField.setStyleName("default");
+        layoutGrid.add(passwordField);
+        passwordField.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                processLogin();
+            }
+        });
+
+        KalumetConsoleApplication.getApplication().setFocusedComponent(usernameField);
+    }
+
+    /**
+     * Process a user log-in request
+     */
+    private void processLogin() {
+
+        String userid = usernameField.getText();
+        String password = passwordField.getText();
+
+        usernameField.setText("");
+        passwordField.setText("");
+        KalumetConsoleApplication.getApplication().setFocusedComponent(usernameField);
+
+        KalumetConsoleApplication.getApplication().connect(userid, password);
+    }
+
+}
\ No newline at end of file

Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/MainScreen.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/MainScreen.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/MainScreen.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/MainScreen.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,205 @@
+/*
+ * 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.kalumet.console.app;
+
+import nextapp.echo2.app.Button;
+import nextapp.echo2.app.ContentPane;
+import nextapp.echo2.app.Extent;
+import nextapp.echo2.app.Label;
+import nextapp.echo2.app.Row;
+import nextapp.echo2.app.SplitPane;
+import nextapp.echo2.app.event.ActionEvent;
+import nextapp.echo2.app.event.ActionListener;
+
+/**
+ * Main screen <code>ContentPane</code>.
+ */
+public class MainScreen extends ContentPane {
+
+    // general constants
+    public static String[] LABELS = new String[]{Messages.getString("yes"), Messages.getString("no")};
+
+    /**
+     * Create a new <code>MainScreen</code>.
+     */
+    public MainScreen() {
+        super();
+
+        // define the title pane
+        SplitPane titlePane = new SplitPane(SplitPane.ORIENTATION_VERTICAL_TOP_BOTTOM, new Extent(30, Extent.PX));
+        titlePane.setResizable(false);
+        add(titlePane);
+        Label titleLabel = new Label(Messages.getString("kalumet.console"));
+        titleLabel.setStyleName("title");
+        titlePane.add(titleLabel);
+
+        // create the menu pane
+        SplitPane menuPane = new SplitPane(SplitPane.ORIENTATION_VERTICAL, new Extent(26));
+        menuPane.setResizable(false);
+        titlePane.add(menuPane);
+        Row menuRow = new Row();
+        menuRow.setStyleName("menu");
+        menuPane.add(menuRow);
+        // new environment menu option
+        Button newEnvironmentButton = new Button(Messages.getString("environment.add"), Styles.APPLICATION_ADD);
+        newEnvironmentButton.setStyleName("default");
+        newEnvironmentButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                // display a new environment window
+                KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new EnvironmentWindow(null));
+            }
+        });
+        menuRow.add(newEnvironmentButton);
+        // refresh menu option
+        Button refreshButton = new Button(Messages.getString("reload"), Styles.DATABASE_REFRESH);
+        refreshButton.setStyleName("default");
+        refreshButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                // refresh the environments pane
+                KalumetConsoleApplication.getApplication().getLogPane().addInfo(Messages.getString("configuration") + " " + Messages.getString("reloaded"));
+                KalumetConsoleApplication.getApplication().getEnvironmentsPane().update();
+            }
+        });
+        menuRow.add(refreshButton);
+        // add admin menu options
+        if (KalumetConsoleApplication.getApplication().getUserid().equals("admin")) {
+            // configuration menu option
+            Button configurationButton = new Button(Messages.getString("configuration"), Styles.COMPUTER_EDIT);
+            configurationButton.setStyleName("default");
+            configurationButton.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent event) {
+                    // display the configuration window
+                    if (KalumetConsoleApplication.getApplication().getDefaultWindow().getComponent("configurationwindow") == null) {
+                        KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new AdminConfigurationWindow());
+                    }
+                }
+            });
+            menuRow.add(configurationButton);
+            // agents menu option
+            Button agentButton = new Button(Messages.getString("agents"), Styles.COG);
+            agentButton.setStyleName("default");
+            agentButton.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent event) {
+                    // display the agents window
+                    if (KalumetConsoleApplication.getApplication().getDefaultWindow().getComponent("agentswindow") == null) {
+                        KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new AdminAgentsWindow());
+                    }
+                }
+            });
+            menuRow.add(agentButton);
+            // users menu option
+            Button usersButton = new Button(Messages.getString("users"), Styles.USER);
+            usersButton.setStyleName("default");
+            usersButton.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent event) {
+                    // display the users window
+                    if (KalumetConsoleApplication.getApplication().getDefaultWindow().getComponent("userswindow") == null) {
+                        KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new AdminUsersWindow());
+                    }
+                }
+            });
+            menuRow.add(usersButton);
+            // groups menu option
+            Button groupsButton = new Button(Messages.getString("groups"), Styles.GROUP);
+            groupsButton.setStyleName("default");
+            groupsButton.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent event) {
+                    // display the groups window
+                    if (KalumetConsoleApplication.getApplication().getDefaultWindow().getComponent("groupswindow") == null) {
+                        KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new AdminGroupsWindow());
+                    }
+                }
+            });
+            menuRow.add(groupsButton);
+        }
+        // stats menu option
+        Button statsButton = new Button(Messages.getString("stats"), Styles.CHART_BAR);
+        statsButton.setStyleName("default");
+        statsButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                // display the stats window
+                if (KalumetConsoleApplication.getApplication().getDefaultWindow().getComponent("statswindow") == null) {
+                    KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new StatsWindow());
+                }
+            }
+        });
+        menuRow.add(statsButton);
+        // preference menu option
+        Button preferenceButton = new Button(Messages.getString("preferences"), Styles.WRENCH);
+        preferenceButton.setStyleName("default");
+        preferenceButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                // display the preferences window
+                if (KalumetConsoleApplication.getApplication().getDefaultWindow().getComponent("preferenceswindow") == null) {
+                    KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new PreferencesWindow());
+                }
+            }
+        });
+        menuRow.add(preferenceButton);
+        // about menu option
+        Button aboutButton = new Button(Messages.getString("about"), Styles.INFORMATION);
+        aboutButton.setStyleName("default");
+        aboutButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                // display the about window
+                if (KalumetConsoleApplication.getApplication().getDefaultWindow().getComponent("aboutwindow") == null) {
+                    KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new AboutWindow());
+                }
+            }
+        });
+        menuRow.add(aboutButton);
+        // disconnect menu option
+        Button disconnectButton = new Button(Messages.getString("disconnect"), Styles.DISCONNECT);
+        disconnectButton.setStyleName("default");
+        disconnectButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                // disconnect the user
+                KalumetConsoleApplication.getApplication().disconnect();
+            }
+        });
+        menuRow.add(disconnectButton);
+
+        // create the split central pane
+        SplitPane mainPane = new SplitPane(SplitPane.ORIENTATION_HORIZONTAL_LEFT_RIGHT, new Extent(200, Extent.PX));
+        mainPane.setStyleName("default");
+        menuPane.add(mainPane);
+        // add the left environments pane
+        EnvironmentsPane environmentsPane = new EnvironmentsPane();
+        KalumetConsoleApplication.getApplication().setEnvironmentsPane(environmentsPane);
+        mainPane.add(environmentsPane);
+
+        // add a split central pane
+        SplitPane centralPane = new SplitPane(SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent(100, Extent.PX));
+        centralPane.setStyleName("default");
+        mainPane.add(centralPane);
+
+        // add the log pane and register in the WAD application
+        LogPane logPane = new LogPane();
+        KalumetConsoleApplication.getApplication().setLogPane(logPane);
+        centralPane.add(logPane);
+        // add an info in the log pane
+        logPane.addInfo(Messages.getString("welcome") + " " + KalumetConsoleApplication.getApplication().getUserid());
+
+        // add the workspace pane
+        ContentPane workspacePane = new ContentPane();
+        workspacePane.setStyleName("central");
+        centralPane.add(workspacePane);
+    }
+
+}
\ No newline at end of file

Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/Messages.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/Messages.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/Messages.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/Messages.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,95 @@
+/*
+ * 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.kalumet.console.app;
+
+import java.text.DateFormat;
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import nextapp.echo2.app.ApplicationInstance;
+
+/**
+ * A utility class that provides resources for obtaining localized messages.
+ */
+public class Messages {
+
+    private static final String BUNDLE_NAME = "org.apache.kalumet.console.app.resources.locales.Messages";
+
+    // a map which contains DateFormat objects for various locales.
+    private static final Map DATE_FORMAT_MEDIUM_MAP = new HashMap();
+
+    /**
+     * Formats a date with the specified locale.
+     *
+     * @param date the date to be formatted.
+     * @return a localized String representation of the date.
+     */
+    public static final String formatDateTimeMedium(Date date) {
+        Locale locale = ApplicationInstance.getActive().getLocale();
+        DateFormat df = (DateFormat) DATE_FORMAT_MEDIUM_MAP.get(locale);
+        if (df == null) {
+            df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, locale);
+            DATE_FORMAT_MEDIUM_MAP.put(locale, df);
+        }
+        return date == null ? null : df.format(date);
+    }
+
+    /**
+     * Returns a localized formatted message. This method conveniently wraps a
+     * call to a MessageFormat object.
+     *
+     * @param key       the key of the message to be returned.
+     * @param arguments an array of arguments to be inserted into the message.
+     */
+    public static String getFormattedString(String key, Object[] arguments) {
+        Locale locale = ApplicationInstance.getActive().getLocale();
+        String template = getString(key);
+        MessageFormat messageFormat = new MessageFormat(template);
+        messageFormat.setLocale(locale);
+        return messageFormat.format(arguments, new StringBuffer(), null).toString();
+    }
+
+    /**
+     * Returns localized text.
+     *
+     * @param key the key of the text to be returned.
+     * @return the appropriate localized text (if the key is not defined, the string "!key!" is returned).
+     */
+    public static String getString(String key) {
+        try {
+            Locale locale = ApplicationInstance.getActive().getLocale();
+            ResourceBundle resource = ResourceBundle.getBundle(BUNDLE_NAME, locale);
+            return resource.getString(key);
+        } catch (MissingResourceException e) {
+            return '!' + key + '!';
+        }
+    }
+
+    /**
+     * Non-instantiable class.
+     */
+    private Messages() {
+    }
+
+}



Mime
View raw message