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 [17/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/NotifiersPane.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/NotifiersPane.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/NotifiersPane.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/NotifiersPane.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,492 @@
+/*
+ * 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 nextapp.echo2.app.list.DefaultListModel;
+import org.apache.kalumet.model.Destination;
+import org.apache.kalumet.model.Email;
+
+/**
+ * Environment notifiers pane.
+ */
+public class NotifiersPane extends ContentPane {
+
+    private EnvironmentWindow parent;
+    private TextField countDownField;
+    private SelectField scopeField;
+    private Grid grid;
+    private TextField newDestinationField;
+
+    // scope select
+    private ActionListener scopeSelect = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            update();
+        }
+    };
+    // edit destination
+    private ActionListener editDestination = 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;
+            }
+            // get the destination address
+            String destinationAddress = event.getActionCommand();
+            // get field
+            TextField destinationAddressField = (TextField) NotifiersPane.this.getComponent("notifierdestination_" + parent.getEnvironmentName() + "_" + (String) scopeField.getSelectedItem() + "_" + destinationAddress);
+            String destinationAddressFieldValue = destinationAddressField.getText();
+            // check the field value
+            if (destinationAddressFieldValue == null || destinationAddressFieldValue.trim().length() < 1) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("notifier.destination.mandatory"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // if the user change the destination address, check if the address is
+            // not already in use
+            if (!destinationAddress.equals(destinationAddressFieldValue)) {
+                if (parent.getEnvironment().getNotifiers().getNotifier((String) scopeField.getSelectedItem()).getDestination(destinationAddressFieldValue) != null) {
+                    KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("notifier.destination.exists"), getEnvironmentWindow().getEnvironmentName());
+                    return;
+                }
+            }
+            // looking for the destination object
+            Destination destination = parent.getEnvironment().getNotifiers().getNotifier((String) scopeField.getSelectedItem()).getDestination(destinationAddress);
+            if (destination == null) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("notifier.destination.notfound"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // add a change event
+            parent.getChangeEvents().add("Change notifier destination to " + destination.getAddress());
+            // update the destination address object
+            destination.setAddress(destinationAddressFieldValue);
+            // change the updated flag
+            parent.setUpdated(true);
+            // update the journal log tab pane
+            parent.updateJournalPane();
+            // update only the tab
+            update();
+        }
+    };
+    // create destination
+    private ActionListener createDestination = 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;
+            }
+            // get the new destination address field value
+            String newDestinationAddressFieldValue = newDestinationField.getText();
+            // check mandatory field
+            if (newDestinationAddressFieldValue == null || newDestinationAddressFieldValue.trim().length() < 1) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("notifier.destination.mandatory"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // create a new destination object
+            Destination destination = new Destination();
+            destination.setAddress(newDestinationAddressFieldValue);
+            // add the destination
+            try {
+                parent.getEnvironment().getNotifiers().getNotifier((String) scopeField.getSelectedItem()).addDestination(destination);
+            } catch (Exception e) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("notifier.destination.exists"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // add a change event
+            parent.getChangeEvents().add("Create notifier destination " + destination.getAddress());
+            // change the updated flag
+            parent.setUpdated(true);
+            // update the journal log tab pane
+            parent.updateJournalPane();
+            // update only the tab
+            update();
+        }
+    };
+    // delete destination
+    private ActionListener deleteDestination = 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;
+            }
+            // get the destination address
+            String destinationAddress = event.getActionCommand();
+            // looking for the destination object
+            final Destination destination = parent.getEnvironment().getNotifiers().getNotifier((String) scopeField.getSelectedItem()).getDestination(destinationAddress);
+            if (destination == null) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("notifier.destination.notfound"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // display confirm window
+            KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ConfirmWindow(new ActionListener() {
+                public void actionPerformed(ActionEvent event) {
+                    // remove the destination
+                    parent.getEnvironment().getNotifiers().getNotifier((String) scopeField.getSelectedItem()).getDestinations().remove(destination);
+                    // add a change event
+                    parent.getChangeEvents().add("Delete notifier destination " + destination.getAddress());
+                    // change the updated flag
+                    parent.setUpdated(true);
+                    // update the journal log tab pane
+                    parent.updateJournalPane();
+                    // update only the tab
+                    update();
+                }
+            }));
+        }
+    };
+    // delete notifier
+    private ActionListener deleteNotifier = 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;
+            }
+            // looking for the notifier object
+            final Email notifier = parent.getEnvironment().getNotifiers().getNotifier((String) scopeField.getSelectedItem());
+            if (notifier == null) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("notifier.notfound"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // display confirm window
+            KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ConfirmWindow(new ActionListener() {
+                public void actionPerformed(ActionEvent event) {
+                    // remove the notifier object
+                    parent.getEnvironment().getNotifiers().getNotifiers().remove(notifier);
+                    // add a change event
+                    parent.getChangeEvents().add("Delete notifier " + notifier.getMailhost());
+                    // change the updated flag
+                    parent.setUpdated(true);
+                    // update the journal log tab pane
+                    parent.updateJournalPane();
+                    // update the pane
+                    update();
+                }
+            }));
+        }
+    };
+    // edit notifier
+    private ActionListener editNotifier = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            if (KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().getComponent("notifierwindow_" + parent.getEnvironmentName() + "_" + event.getActionCommand()) == null) {
+                KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new NotifierWindow(NotifiersPane.this, (String) scopeField.getSelectedItem()));
+            }
+        }
+    };
+    // create notifier
+    private ActionListener createNotifier = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new NotifierWindow(NotifiersPane.this, null));
+        }
+    };
+    // copy notifier
+    private ActionListener copyNotifier = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            // looking for the notifier object
+            Email notifier = parent.getEnvironment().getNotifiers().getNotifier((String) scopeField.getSelectedItem());
+            if (notifier == null) {
+                return;
+            }
+            try {
+                KalumetConsoleApplication.getApplication().setCopyComponent(notifier.clone());
+            } catch (Exception e) {
+                return;
+            }
+        }
+    };
+    // copy destination
+    private ActionListener copyDestination = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            // looking for the destination object
+            Destination destination = parent.getEnvironment().getNotifiers().getNotifier((String) scopeField.getSelectedItem()).getDestination(event.getActionCommand());
+            if (destination == null) {
+                return;
+            }
+            try {
+                KalumetConsoleApplication.getApplication().setCopyComponent(destination.clone());
+            } catch (Exception e) {
+                return;
+            }
+        }
+    };
+    // paste destination
+    private ActionListener pasteDestination = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+            // check the copy object
+            if (copy == null || !(copy instanceof Destination)) {
+                return;
+            }
+            // update the new fields
+            newDestinationField.setText(((Destination) copy).getAddress());
+        }
+    };
+
+    /**
+     * Create a new <code>NotifiersPane</code>.
+     *
+     * @param parent the parent <code>EnvironmentWindow</code>.
+     */
+    public NotifiersPane(EnvironmentWindow parent) {
+        super();
+        setStyleName("tab.content");
+
+        // update parent
+        this.parent = parent;
+
+        // column layout
+        Column content = new Column();
+        content.setInsets(new Insets(2));
+        content.setCellSpacing(new Extent(2));
+        add(content);
+
+        // general grid
+        Grid generalGrid = new Grid(2);
+        generalGrid.setStyleName("default");
+        generalGrid.setWidth(new Extent(100, Extent.PERCENT));
+        generalGrid.setColumnWidth(0, new Extent(20, Extent.PERCENT));
+        generalGrid.setColumnWidth(1, new Extent(80, Extent.PERCENT));
+        content.add(generalGrid);
+
+        // countdown field
+        Label countDownLabel = new Label(Messages.getString("countdown"));
+        countDownLabel.setStyleName("default");
+        generalGrid.add(countDownLabel);
+        countDownField = new TextField();
+        countDownField.setStyleName("default");
+        countDownField.setWidth(new Extent(50, Extent.EX));
+        generalGrid.add(countDownField);
+
+        // scope row
+        Row scopeRow = new Row();
+        scopeRow.setInsets(new Insets(2));
+        scopeRow.setCellSpacing(new Extent(4));
+        content.add(scopeRow);
+        // scope select field
+        scopeField = new SelectField();
+        scopeField.setStyleName("default");
+        scopeField.setWidth(new Extent(50, Extent.EX));
+        scopeField.addActionListener(scopeSelect);
+        scopeRow.add(scopeField);
+        DefaultListModel scopeListModel = (DefaultListModel) scopeField.getModel();
+        scopeListModel.removeAll();
+        // add notifiers in the scope select field
+        for (Iterator notifierIterator = parent.getEnvironment().getNotifiers().getNotifiers().iterator(); notifierIterator.hasNext(); ) {
+            Email email = (Email) notifierIterator.next();
+            scopeListModel.add(email.getMailhost());
+        }
+        if (scopeListModel.size() > 0) {
+            scopeField.setSelectedIndex(0);
+        }
+
+        // copy notifier button
+        Button copyNotifierButton = new Button(Styles.PAGE_COPY);
+        copyNotifierButton.setToolTipText(Messages.getString("copy"));
+        copyNotifierButton.addActionListener(copyNotifier);
+        scopeRow.add(copyNotifierButton);
+        // edit notifier button
+        Button editNotifierButton = new Button(Styles.ACCEPT);
+        editNotifierButton.setToolTipText(Messages.getString("edit"));
+        editNotifierButton.addActionListener(editNotifier);
+        scopeRow.add(editNotifierButton);
+        if (getEnvironmentWindow().adminPermission) {
+            // delete
+            Button deleteNotifierButton = new Button(Styles.DELETE);
+            deleteNotifierButton.setToolTipText(Messages.getString("delete"));
+            deleteNotifierButton.addActionListener(deleteNotifier);
+            scopeRow.add(deleteNotifierButton);
+            // add
+            Button createNotifierButton = new Button(Styles.ADD);
+            createNotifierButton.setToolTipText(Messages.getString("notifier.add"));
+            createNotifierButton.addActionListener(createNotifier);
+            scopeRow.add(createNotifierButton);
+        }
+
+        // add the destinations grid
+        grid = new Grid(2);
+        grid.setStyleName("border.grid");
+        grid.setColumnWidth(0, new Extent(50, Extent.PX));
+        grid.setColumnWidth(1, new Extent(100, Extent.PERCENT));
+        content.add(grid);
+
+        // update the pane
+        update();
+    }
+
+    /**
+     * Update the pane.
+     */
+    public void update() {
+        // update the count down field
+        countDownField.setText(new Integer(parent.getEnvironment().getNotifiers().getCountdown()).toString());
+
+        // update the scope select field
+        String notifierMailhost = null;
+        DefaultListModel scopeListModel = (DefaultListModel) scopeField.getModel();
+        if (scopeListModel.size() > 0) {
+            notifierMailhost = (String) scopeField.getSelectedItem();
+        }
+        scopeListModel.removeAll();
+        int scopeIndex = 0;
+        int found = -1;
+        for (Iterator notifierIterator = parent.getEnvironment().getNotifiers().getNotifiers().iterator(); notifierIterator.hasNext(); ) {
+            Email notifier = (Email) notifierIterator.next();
+            scopeListModel.add(notifier.getMailhost());
+            if (notifier.getMailhost().equals(notifierMailhost)) {
+                found = scopeIndex;
+            }
+            scopeIndex++;
+        }
+
+        // remove all destinations grid children
+        grid.removeAll();
+        // check if at least one notifier is present
+        if (scopeListModel.size() < 1) {
+            return;
+        }
+        if (found == -1) {
+            scopeField.setSelectedIndex(0);
+        } else {
+            scopeField.setSelectedIndex(found);
+        }
+        // update the notifier from the scope (in case of deletion)
+        notifierMailhost = (String) scopeField.getSelectedItem();
+
+        // add destinations grid header
+        Label destinationActionHeader = new Label(" ");
+        destinationActionHeader.setStyleName("grid.header");
+        grid.add(destinationActionHeader);
+        Label destinationAddressHeader = new Label(Messages.getString("destination"));
+        destinationAddressHeader.setStyleName("grid.header");
+        grid.add(destinationAddressHeader);
+        // add the destinations e-mails
+        for (Iterator destinationIterator = parent.getEnvironment().getNotifiers().getNotifier(notifierMailhost).getDestinations().iterator(); destinationIterator.hasNext(); ) {
+            Destination destination = (Destination) destinationIterator.next();
+            // row
+            Row row = new Row();
+            row.setInsets(new Insets(2));
+            row.setCellSpacing(new Extent(2));
+            grid.add(row);
+            // copy
+            Button copyButton = new Button(Styles.PAGE_COPY);
+            copyButton.setToolTipText(Messages.getString("copy"));
+            copyButton.setActionCommand(destination.getAddress());
+            copyButton.addActionListener(copyDestination);
+            row.add(copyButton);
+            if (getEnvironmentWindow().adminPermission) {
+                // edit
+                Button editButton = new Button(Styles.ACCEPT);
+                editButton.setToolTipText(Messages.getString("apply"));
+                editButton.setActionCommand(destination.getAddress());
+                editButton.addActionListener(editDestination);
+                row.add(editButton);
+                // delete
+                Button deleteButton = new Button(Styles.DELETE);
+                deleteButton.setToolTipText(Messages.getString("delete"));
+                deleteButton.setActionCommand(destination.getAddress());
+                deleteButton.addActionListener(deleteDestination);
+                row.add(deleteButton);
+            }
+            // destination
+            TextField destinationAddress = new TextField();
+            destinationAddress.setId("notifierdestination_" + parent.getEnvironmentName() + "_" + notifierMailhost + "_" + destination.getAddress());
+            destinationAddress.setText(destination.getAddress());
+            destinationAddress.setStyleName("default");
+            destinationAddress.setWidth(new Extent(100, Extent.PERCENT));
+            grid.add(destinationAddress);
+        }
+        // add create destination row in the destinations grid
+        if (getEnvironmentWindow().adminPermission) {
+            // row
+            Row row = new Row();
+            row.setInsets(new Insets(2));
+            row.setCellSpacing(new Extent(2));
+            grid.add(row);
+            // paste
+            Button pasteButton = new Button(Styles.PAGE_PASTE);
+            pasteButton.setToolTipText(Messages.getString("paste"));
+            pasteButton.addActionListener(pasteDestination);
+            row.add(pasteButton);
+            // add
+            Button addButton = new Button(Styles.ADD);
+            addButton.setToolTipText(Messages.getString("destination.add"));
+            addButton.addActionListener(createDestination);
+            row.add(addButton);
+            // destination
+            newDestinationField = new TextField();
+            newDestinationField.setStyleName("default");
+            newDestinationField.setWidth(new Extent(100, Extent.PERCENT));
+            grid.add(newDestinationField);
+        }
+    }
+
+    /**
+     * Get the parent <code>EnvironmentWindow</code>.
+     *
+     * @return the parent <code>EnvironmentWindow</code>.
+     */
+    public EnvironmentWindow getEnvironmentWindow() {
+        return parent;
+    }
+
+    /**
+     * Get the count down <code>TextField</code>.
+     *
+     * @return the count down <code>TextField</code>.
+     */
+    public TextField getCountDownField() {
+        return this.countDownField;
+    }
+
+}
\ No newline at end of file

Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/PreferencesWindow.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/PreferencesWindow.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/PreferencesWindow.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/PreferencesWindow.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,291 @@
+/*
+ * 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.Extent;
+import nextapp.echo2.app.Grid;
+import nextapp.echo2.app.Insets;
+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;
+import nextapp.echo2.app.layout.SplitPaneLayoutData;
+import org.apache.kalumet.console.configuration.ConfigurationManager;
+import org.apache.kalumet.model.Group;
+import org.apache.kalumet.model.Kalumet;
+import org.apache.kalumet.model.User;
+
+/**
+ * Preferences window.
+ */
+public class PreferencesWindow extends WindowPane {
+
+    // attributes
+    private TextField userIdField;
+    private TextField userNameField;
+    private TextField userEmailField;
+    private PasswordField userPasswordField;
+    private PasswordField userConfirmPasswordField;
+
+    // close button action listener
+    private ActionListener closeButtonActionListener = new ActionListener() {
+
+        public void actionPerformed(ActionEvent event) {
+            PreferencesWindow.this.userClose();
+        }
+
+    };
+    // refresh button action listener
+    private ActionListener refreshButtonActionListener = new ActionListener() {
+
+        public void actionPerformed(ActionEvent event) {
+            // load Kalumet configuration
+            Kalumet kalumet = null;
+            try {
+                kalumet = ConfigurationManager.loadStore();
+            } catch (Exception e) {
+                KalumetConsoleApplication.getApplication().getLogPane().addError(Messages.getString("db.read") + ": " + e.getMessage());
+                return;
+            }
+            User user = kalumet.getSecurity().getUser(KalumetConsoleApplication.getApplication().getUserid());
+            if (user == null) {
+                KalumetConsoleApplication.getApplication().getLogPane().addError(Messages.getString("error.user.notfound"));
+                return;
+            }
+            userIdField.setText(user.getId());
+            userNameField.setText(user.getName());
+            userEmailField.setText(user.getEmail());
+            userPasswordField.setText(null);
+            userConfirmPasswordField.setText(null);
+        }
+
+    };
+    // save button action listener
+    private ActionListener saveButtonActionListener = new ActionListener() {
+
+        public void actionPerformed(ActionEvent event) {
+            String userId = userIdField.getText().trim();
+            String userName = userNameField.getText().trim();
+            String userEmail = userEmailField.getText().trim();
+            String userPassword = userPasswordField.getText();
+            String userConfirmPassword = userConfirmPasswordField.getText();
+            Kalumet kalumet = null;
+            try {
+                kalumet = ConfigurationManager.loadStore();
+            } catch (Exception e) {
+                KalumetConsoleApplication.getApplication().getLogPane().addError(Messages.getString("db.read") + ": " + e.getMessage());
+                return;
+            }
+            User user = kalumet.getSecurity().getUser(KalumetConsoleApplication.getApplication().getUserid());
+            if (user == null) {
+                KalumetConsoleApplication.getApplication().getLogPane().addError(Messages.getString("error.user.notfound"));
+                return;
+            }
+            if (userId.length() < 1) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("preferences.warn.username"));
+                return;
+            }
+            if (userPassword.length() > 0 && !userPassword.equals(userConfirmPassword)) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("preferences.warn.password"));
+                return;
+            }
+            if (!userId.equals(KalumetConsoleApplication.getApplication().getUserid()) && KalumetConsoleApplication.getApplication().getUserid().equals("admin")) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("preferences.warn.admin"));
+                return;
+            }
+            if (userPassword.length() > 0) {
+                try {
+                    user.setPassword(User.md5PasswordCrypt(userPassword));
+                } catch (Exception e) {
+                    KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("preferences.warn.crypt") + ": " + e.getMessage());
+                    return;
+                }
+            }
+            user.setEmail(userEmail);
+            user.setName(userName);
+            if (!userId.equals(KalumetConsoleApplication.getApplication().getUserid())) {
+                // update user group
+                for (Iterator userGroupIterator = kalumet.getSecurity().getUserGroups(user.getId()).iterator(); userGroupIterator.hasNext(); ) {
+                    Group group = (Group) userGroupIterator.next();
+                    for (Iterator userIterator = group.getUsers().iterator(); userIterator.hasNext(); ) {
+                        User current = (User) userIterator.next();
+                        current.setId(userId);
+                    }
+                }
+                // update the main user
+                user.setId(userId);
+                try {
+                    ConfigurationManager.writeStore(kalumet);
+                } catch (Exception e) {
+                    KalumetConsoleApplication.getApplication().getLogPane().addError(Messages.getString("db.write") + ": " + e.getMessage());
+                    return;
+                }
+                KalumetConsoleApplication.getApplication().disconnect();
+                return;
+            }
+            try {
+                ConfigurationManager.writeStore(kalumet);
+            } catch (Exception e) {
+                KalumetConsoleApplication.getApplication().getLogPane().addError(Messages.getString("db.write") + ": " + e.getMessage());
+                return;
+            }
+            KalumetConsoleApplication.getApplication().getLogPane().addConfirm(Messages.getString("preferences.saved"));
+        }
+
+    };
+
+    /**
+     * Create a new <code>PreferencesWindow</code>.
+     */
+    public PreferencesWindow() {
+        super();
+
+        // load Kalumet configuration
+        Kalumet kalumet = null;
+        try {
+            kalumet = ConfigurationManager.loadStore();
+        } catch (Exception e) {
+            KalumetConsoleApplication.getApplication().getLogPane().addError(Messages.getString("db.read") + ": " + e.getMessage());
+            return;
+        }
+
+        // identify the user
+        User user = kalumet.getSecurity().getUser(KalumetConsoleApplication.getApplication().getUserid());
+        if (user == null) {
+            KalumetConsoleApplication.getApplication().getLogPane().addError(Messages.getString("error.user.notfound"));
+            return;
+        }
+
+        setTitle(Messages.getString("preferences"));
+        setIcon(Styles.WRENCH);
+        setStyleName("preferences");
+        setModal(false);
+        setId("preferenceswindow");
+        setDefaultCloseOperation(WindowPane.DISPOSE_ON_CLOSE);
+
+        // create a split pane for the control buttons
+        SplitPane splitPane = new SplitPane(SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent(32));
+        add(splitPane);
+
+        // add the control pane
+        Row controlRow = new Row();
+        controlRow.setStyleName("control");
+        splitPane.add(controlRow);
+        // add the refresh button
+        Button refreshButton = new Button(Messages.getString("reload"), Styles.DATABASE_REFRESH);
+        refreshButton.addActionListener(refreshButtonActionListener);
+        refreshButton.setStyleName("control");
+        controlRow.add(refreshButton);
+        // add the save button
+        Button saveButton = new Button(Messages.getString("save"), Styles.DATABASE_SAVE);
+        saveButton.addActionListener(saveButtonActionListener);
+        saveButton.setStyleName("control");
+        controlRow.add(saveButton);
+        // add the close button
+        Button closeButton = new Button(Messages.getString("close"), Styles.CROSS);
+        closeButton.addActionListener(closeButtonActionListener);
+        closeButton.setStyleName("control");
+        controlRow.add(closeButton);
+
+        // define a grid layout
+        Grid layoutGrid = new Grid(2);
+        layoutGrid.setStyleName("default");
+        SplitPaneLayoutData layoutData = new SplitPaneLayoutData();
+        layoutData.setInsets(new Insets(4));
+        layoutGrid.setLayoutData(layoutData);
+        layoutGrid.setWidth(new Extent(100, Extent.PERCENT));
+        layoutGrid.setColumnWidth(0, new Extent(15, Extent.PERCENT));
+        layoutGrid.setColumnWidth(1, new Extent(85, Extent.PERCENT));
+        splitPane.add(layoutGrid);
+
+        // create the user id field
+        Label idLabel = new Label(Messages.getString("username"));
+        idLabel.setStyleName("grid.cell");
+        layoutGrid.add(idLabel);
+        userIdField = new TextField();
+        userIdField.setText(user.getId());
+        userIdField.setStyleName("default");
+        userIdField.setWidth(new Extent(100, Extent.PERCENT));
+        if (KalumetConsoleApplication.getApplication().getUserid().equals("admin")) {
+            userIdField.setEnabled(false);
+        }
+        layoutGrid.add(userIdField);
+
+        // create the user name field
+        Label nameLabel = new Label(Messages.getString("name"));
+        nameLabel.setStyleName("grid.cell");
+        layoutGrid.add(nameLabel);
+        userNameField = new TextField();
+        userNameField.setText(user.getName());
+        userNameField.setStyleName("default");
+        userNameField.setWidth(new Extent(100, Extent.PERCENT));
+        layoutGrid.add(userNameField);
+
+        // create the user e-mail field
+        Label emailLabel = new Label(Messages.getString("email"));
+        emailLabel.setStyleName("grid.cell");
+        layoutGrid.add(emailLabel);
+        userEmailField = new TextField();
+        userEmailField.setText(user.getEmail());
+        userEmailField.setStyleName("default");
+        userEmailField.setWidth(new Extent(100, Extent.PERCENT));
+        layoutGrid.add(userEmailField);
+
+        // create the user password field
+        Label passwordLabel = new Label(Messages.getString("password"));
+        passwordLabel.setStyleName("grid.cell");
+        layoutGrid.add(passwordLabel);
+        userPasswordField = new PasswordField();
+        userPasswordField.setStyleName("default");
+        userPasswordField.setWidth(new Extent(100, Extent.PERCENT));
+        layoutGrid.add(userPasswordField);
+
+        // create the user confirm password field
+        Label passwordConfirmLabel = new Label(Messages.getString("confirm"));
+        passwordConfirmLabel.setStyleName("grid.cell");
+        layoutGrid.add(passwordConfirmLabel);
+        userConfirmPasswordField = new PasswordField();
+        userConfirmPasswordField.setStyleName("default");
+        userConfirmPasswordField.setWidth(new Extent(100, Extent.PERCENT));
+        layoutGrid.add(userConfirmPasswordField);
+
+        // display user groups
+        Label userGroupLabel = new Label(Messages.getString("groups"));
+        userGroupLabel.setStyleName("grid.cell");
+        layoutGrid.add(userGroupLabel);
+        Column groupsColumn = new Column();
+        groupsColumn.setStyleName("grid.action");
+        layoutGrid.add(groupsColumn);
+        for (Iterator userGroupIterator = kalumet.getSecurity().getUserGroups(user.getId()).iterator(); userGroupIterator.hasNext(); ) {
+            Group group = (Group) userGroupIterator.next();
+            Label groupLabel = new Label(group.getName());
+            groupLabel.setStyleName("default");
+            groupsColumn.add(groupLabel);
+        }
+    }
+
+}
\ No newline at end of file

Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/PublishReleaseWindow.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/PublishReleaseWindow.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/PublishReleaseWindow.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/PublishReleaseWindow.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,473 @@
+/*
+ * 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 java.util.LinkedList;
+
+import nextapp.echo2.app.Button;
+import nextapp.echo2.app.CheckBox;
+import nextapp.echo2.app.Column;
+import nextapp.echo2.app.Extent;
+import nextapp.echo2.app.Insets;
+import nextapp.echo2.app.Label;
+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;
+import org.apache.commons.vfs.FileObject;
+import org.apache.kalumet.FileManipulator;
+import org.apache.kalumet.model.*;
+import org.apache.kalumet.utils.VariableUtils;
+
+/**
+ * Define an application checkbox.
+ */
+class ApplicationCheckBox extends CheckBox {
+
+    private String serverName;
+    private String applicationName;
+
+    public ApplicationCheckBox(String serverName, String applicationName) {
+        super(applicationName);
+        this.serverName = serverName;
+        this.applicationName = applicationName;
+    }
+
+    public String getServerName() {
+        return this.serverName;
+    }
+
+    public String getApplicationName() {
+        return this.applicationName;
+    }
+
+}
+
+/**
+ * Define an application archive checkbox.
+ */
+class ArchiveCheckBox extends CheckBox {
+
+    private String serverName;
+    private String applicationName;
+    private String archiveName;
+
+    public ArchiveCheckBox(String serverName, String applicationName, String archiveName) {
+        super(archiveName);
+        this.serverName = serverName;
+        this.applicationName = applicationName;
+        this.archiveName = archiveName;
+    }
+
+    public String getServerName() {
+        return this.serverName;
+    }
+
+    public String getApplicationName() {
+        return this.applicationName;
+    }
+
+    public String getArchiveName() {
+        return this.archiveName;
+    }
+
+}
+
+/**
+ * Define an application configuration file checkbox.
+ */
+class ConfigurationFileCheckBox extends CheckBox {
+
+    private String serverName;
+    private String applicationName;
+    private String configurationFileName;
+
+    public ConfigurationFileCheckBox(String serverName, String applicationName, String configurationFileName) {
+        super(configurationFileName);
+        this.serverName = serverName;
+        this.applicationName = applicationName;
+        this.configurationFileName = configurationFileName;
+    }
+
+    public String getServerName() {
+        return this.serverName;
+    }
+
+    public String getApplicationName() {
+        return this.applicationName;
+    }
+
+    public String getConfigurationFileName() {
+        return this.configurationFileName;
+    }
+
+}
+
+/**
+ * Define an application SQL script checkbox.
+ */
+class SqlScriptCheckBox extends CheckBox {
+
+    private String serverName;
+    private String applicationName;
+    private String databaseName;
+    private String sqlScriptName;
+
+    public SqlScriptCheckBox(String serverName, String applicationName, String databaseName, String sqlScriptName) {
+        super(sqlScriptName);
+        this.serverName = serverName;
+        this.applicationName = applicationName;
+        this.databaseName = databaseName;
+        this.sqlScriptName = sqlScriptName;
+    }
+
+    public String getServerName() {
+        return this.serverName;
+    }
+
+    public String getApplicationName() {
+        return this.applicationName;
+    }
+
+    public String getDatabaseName() {
+        return this.databaseName;
+    }
+
+    public String getSqlScriptName() {
+        return this.sqlScriptName;
+    }
+
+}
+
+/**
+ * Define a software checkbox.
+ */
+class SoftwareCheckBox extends CheckBox {
+
+    private String softwareName;
+
+    public SoftwareCheckBox(String softwareName) {
+        super(softwareName);
+        this.softwareName = softwareName;
+    }
+
+    public String getSoftwareName() {
+        return this.softwareName;
+    }
+
+}
+
+/**
+ * Environment publish release window.
+ */
+public class PublishReleaseWindow extends WindowPane {
+
+    private EnvironmentWindow parent;
+    private TextField baseLocationField;
+    private TextField applicationLocationField;
+    private LinkedList applicationCheckBoxes = new LinkedList();
+    private TextField archiveLocationField;
+    private LinkedList archiveCheckBoxes = new LinkedList();
+    private TextField configurationFileLocationField;
+    private LinkedList configurationFileCheckBoxes = new LinkedList();
+    private TextField sqlScriptLocationField;
+    private LinkedList sqlScriptCheckBoxes = new LinkedList();
+    private TextField softwareLocationField;
+    private LinkedList softwareCheckBoxes = new LinkedList();
+
+    // close
+    private ActionListener close = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            PublishReleaseWindow.this.userClose();
+        }
+    };
+    // publish
+    private ActionListener publish = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            // get the locations
+            String baseLocation = baseLocationField.getText();
+            String applicationLocation = applicationLocationField.getText();
+            String archiveLocation = archiveLocationField.getText();
+            String configurationFileLocation = configurationFileLocationField.getText();
+            String sqlScriptLocation = sqlScriptLocationField.getText();
+            String softwareLocation = softwareLocationField.getText();
+            // check the locations
+            if (baseLocation == null || baseLocation.trim().length() < 1 || applicationLocation == null || applicationLocation.trim().length() < 1 || archiveLocation == null || archiveLocation.trim().length() < 1 || configurationFileLocation == null
+                    || configurationFileLocation.trim().length() < 1 || sqlScriptLocation == null || sqlScriptLocation.trim().length() < 1 || softwareLocation == null || softwareLocation.trim().length() < 1) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("publish.mandatory"), parent.getEnvironmentName());
+                return;
+            }
+            // update the environment location
+            parent.getEnvironment().setReleaseLocation(baseLocation);
+            parent.setUpdated(true);
+            try {
+                // init file manipulator
+                FileManipulator fileManipulator = FileManipulator.getInstance();
+                // iterate in the application checkboxes
+                for (Iterator applicationCheckBoxIterator = applicationCheckBoxes.iterator(); applicationCheckBoxIterator.hasNext(); ) {
+                    ApplicationCheckBox checkBox = (ApplicationCheckBox) applicationCheckBoxIterator.next();
+                    if (checkBox.isSelected()) {
+                        J2EEApplication application = parent.getEnvironment().getJ2EEApplicationServers().getJ2EEApplicationServer(checkBox.getServerName()).getJ2EEApplication(checkBox.getApplicationName());
+                        String applicationUri = VariableUtils.replace(application.getUri(), parent.getEnvironment().getVariables());
+                        FileObject file = fileManipulator.resolveFile(applicationUri);
+                        String fileName = file.getName().getBaseName();
+                        fileManipulator.copy(applicationUri, baseLocation + "/" + applicationLocation + "/" + fileName);
+                    }
+                }
+                // iterate in the archive checkboxes
+                for (Iterator archiveCheckBoxIterator = archiveCheckBoxes.iterator(); archiveCheckBoxIterator.hasNext(); ) {
+                    ArchiveCheckBox checkBox = (ArchiveCheckBox) archiveCheckBoxIterator.next();
+                    if (checkBox.isSelected()) {
+                        J2EEApplication application = parent.getEnvironment().getJ2EEApplicationServers().getJ2EEApplicationServer(checkBox.getServerName()).getJ2EEApplication(checkBox.getApplicationName());
+                        Archive archive = application.getArchive(checkBox.getArchiveName());
+                        String archiveUri;
+                        if (FileManipulator.protocolExists(archive.getUri())) {
+                            archiveUri = VariableUtils.replace(archive.getUri(), parent.getEnvironment().getVariables());
+                        } else {
+                            archiveUri = FileManipulator.format(VariableUtils.replace(application.getUri(), parent.getEnvironment().getVariables()) + "!/" + VariableUtils.replace(archive.getUri(), parent.getEnvironment().getVariables()));
+                        }
+                        FileObject file = fileManipulator.resolveFile(archiveUri);
+                        String fileName = file.getName().getBaseName();
+                        fileManipulator.copy(archiveUri, baseLocation + "/" + archiveLocation + "/" + fileName);
+                    }
+                }
+                // iterate in the configuration file checkboxes
+                for (Iterator configurationFileCheckBoxIterator = configurationFileCheckBoxes.iterator(); configurationFileCheckBoxIterator.hasNext(); ) {
+                    ConfigurationFileCheckBox checkBox = (ConfigurationFileCheckBox) configurationFileCheckBoxIterator.next();
+                    if (checkBox.isSelected()) {
+                        J2EEApplication application = parent.getEnvironment().getJ2EEApplicationServers().getJ2EEApplicationServer(checkBox.getServerName()).getJ2EEApplication(checkBox.getApplicationName());
+                        ConfigurationFile configurationFile = application.getConfigurationFile(checkBox.getConfigurationFileName());
+                        String configurationFileUri;
+                        if (FileManipulator.protocolExists(configurationFile.getUri())) {
+                            configurationFileUri = VariableUtils.replace(configurationFile.getUri(), parent.getEnvironment().getVariables());
+                        } else {
+                            configurationFileUri = FileManipulator.format(VariableUtils.replace(application.getUri(), parent.getEnvironment().getVariables()) + "!/" + VariableUtils.replace(configurationFile.getUri(), parent.getEnvironment().getVariables()));
+                        }
+                        fileManipulator.copy(configurationFileUri, baseLocation + "/" + configurationFileLocation + "/" + configurationFile.getName());
+                    }
+                }
+                // iterate in the SQL script checkboxes
+                for (Iterator sqlScriptCheckBoxIterator = sqlScriptCheckBoxes.iterator(); sqlScriptCheckBoxIterator.hasNext(); ) {
+                    SqlScriptCheckBox checkBox = (SqlScriptCheckBox) sqlScriptCheckBoxIterator.next();
+                    if (checkBox.isSelected()) {
+                        J2EEApplication application = parent.getEnvironment().getJ2EEApplicationServers().getJ2EEApplicationServer(checkBox.getServerName()).getJ2EEApplication(checkBox.getApplicationName());
+                        Database database = application.getDatabase(checkBox.getDatabaseName());
+                        SqlScript sqlScript = database.getSqlScript(checkBox.getSqlScriptName());
+                        String sqlScriptUri;
+                        if (FileManipulator.protocolExists(sqlScript.getUri())) {
+                            sqlScriptUri = VariableUtils.replace(sqlScript.getUri(), parent.getEnvironment().getVariables());
+                        } else {
+                            sqlScriptUri = FileManipulator.format(VariableUtils.replace(application.getUri(), parent.getEnvironment().getVariables()) + "!/" + VariableUtils.replace(sqlScript.getUri(), parent.getEnvironment().getVariables()));
+                        }
+                        fileManipulator.copy(sqlScriptUri, baseLocation + "/" + sqlScriptLocation + "/" + sqlScript.getName());
+                    }
+                }
+                // iterate in the external checkboxes
+                for (Iterator externalCheckBoxIterator = softwareCheckBoxes.iterator(); externalCheckBoxIterator.hasNext(); ) {
+                    SoftwareCheckBox checkBox = (SoftwareCheckBox) externalCheckBoxIterator.next();
+                    if (checkBox.isSelected()) {
+                        Software software = parent.getEnvironment().getSoftware(checkBox.getSoftwareName());
+                        String softwareUri = VariableUtils.replace(software.getUri(), parent.getEnvironment().getVariables());
+                        FileObject file = fileManipulator.resolveFile(softwareUri);
+                        String fileName = file.getName().getBaseName();
+                        fileManipulator.copy(softwareUri, baseLocation + "/" + softwareLocation + "/" + fileName);
+                    }
+                }
+            } catch (Exception e) {
+                KalumetConsoleApplication.getApplication().getLogPane().addError(Messages.getString("release.error") + ": " + e.getMessage(), parent.getEnvironmentName());
+                return;
+            }
+            KalumetConsoleApplication.getApplication().getLogPane().addConfirm(Messages.getString("release.published"));
+        }
+    };
+
+    /**
+     * Create a new <code>PublishReleaseWindow</code>.
+     *
+     * @param parent the parent <code>EnvironmentWindow</code>.
+     */
+    public PublishReleaseWindow(EnvironmentWindow parent) {
+        super();
+
+        // update parent
+        this.parent = parent;
+
+        setTitle(parent.getEnvironmentName() + " " + Messages.getString("release"));
+        setId("publishreleasewindow_" + parent.getEnvironmentName());
+        setModal(false);
+        setStyleName("default");
+        setWidth(new Extent(600));
+        setHeight(new Extent(600));
+        setDefaultCloseOperation(WindowPane.DISPOSE_ON_CLOSE);
+
+        // create a split pane for the control button
+        SplitPane splitPane = new SplitPane(SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent(32));
+        add(splitPane);
+
+        // add the control pane
+        Row controlRow = new Row();
+        controlRow.setStyleName("control");
+        splitPane.add(controlRow);
+        // add the close button
+        Button closeButton = new Button(Messages.getString("close"), Styles.CROSS);
+        closeButton.setStyleName("control");
+        closeButton.addActionListener(close);
+        controlRow.add(closeButton);
+        // add the publish button
+        Button publishButton = new Button(Messages.getString("publish"), Styles.ACCEPT);
+        publishButton.setStyleName("control");
+        publishButton.addActionListener(publish);
+        controlRow.add(publishButton);
+
+        // create the main column
+        Column column = new Column();
+        column.setStyleName("default");
+        column.setCellSpacing(new Extent(2));
+        column.setInsets(new Insets(2));
+        splitPane.add(column);
+
+        // add base location
+        Label baseLocationLabel = new Label(Messages.getString("release.location"));
+        column.add(baseLocationLabel);
+        baseLocationField = new TextField();
+        baseLocationField.setStyleName("default");
+        baseLocationField.setWidth(new Extent(100, Extent.PERCENT));
+        baseLocationField.setText(parent.getEnvironment().getReleaseLocation());
+        column.add(baseLocationField);
+
+        // add applications
+        Label applicationsHeader = new Label(Messages.getString("applications"));
+        column.add(applicationsHeader);
+        // add applications location
+        applicationLocationField = new TextField();
+        applicationLocationField.setStyleName("default");
+        applicationLocationField.setWidth(new Extent(100, Extent.PERCENT));
+        applicationLocationField.setText("/applications");
+        column.add(applicationLocationField);
+        // add applications checkbox
+        for (Iterator applicationServerIterator = parent.getEnvironment().getJ2EEApplicationServers().getJ2EEApplicationServers().iterator(); applicationServerIterator.hasNext(); ) {
+            J2EEApplicationServer applicationServer = (J2EEApplicationServer) applicationServerIterator.next();
+            for (Iterator applicationIterator = applicationServer.getJ2EEApplications().iterator(); applicationIterator.hasNext(); ) {
+                J2EEApplication application = (J2EEApplication) applicationIterator.next();
+                ApplicationCheckBox checkBox = new ApplicationCheckBox(applicationServer.getName(), application.getName());
+                checkBox.setStyleName("default");
+                applicationCheckBoxes.add(checkBox);
+                column.add(checkBox);
+            }
+        }
+
+        // add archives
+        Label archivesHeader = new Label(Messages.getString("archives"));
+        column.add(archivesHeader);
+        // add archives location
+        archiveLocationField = new TextField();
+        archiveLocationField.setStyleName("default");
+        archiveLocationField.setWidth(new Extent(100, Extent.PERCENT));
+        archiveLocationField.setText("/archives");
+        column.add(archiveLocationField);
+        // add archives checkbox
+        for (Iterator applicationServerIterator = parent.getEnvironment().getJ2EEApplicationServers().getJ2EEApplicationServers().iterator(); applicationServerIterator.hasNext(); ) {
+            J2EEApplicationServer applicationServer = (J2EEApplicationServer) applicationServerIterator.next();
+            for (Iterator applicationIterator = applicationServer.getJ2EEApplications().iterator(); applicationIterator.hasNext(); ) {
+                J2EEApplication application = (J2EEApplication) applicationIterator.next();
+                for (Iterator archiveIterator = application.getArchives().iterator(); archiveIterator.hasNext(); ) {
+                    Archive archive = (Archive) archiveIterator.next();
+                    ArchiveCheckBox checkBox = new ArchiveCheckBox(applicationServer.getName(), application.getName(), archive.getName());
+                    checkBox.setStyleName("default");
+                    archiveCheckBoxes.add(checkBox);
+                    column.add(checkBox);
+                }
+            }
+        }
+
+        // add configuration files
+        Label configurationFilesHeader = new Label(Messages.getString("configurationfiles"));
+        column.add(configurationFilesHeader);
+        // add configuration files location
+        configurationFileLocationField = new TextField();
+        configurationFileLocationField.setStyleName("default");
+        configurationFileLocationField.setWidth(new Extent(100, Extent.PERCENT));
+        configurationFileLocationField.setText("/config");
+        column.add(configurationFileLocationField);
+        // add configuration files checkbox
+        for (Iterator applicationServerIterator = parent.getEnvironment().getJ2EEApplicationServers().getJ2EEApplicationServers().iterator(); applicationServerIterator.hasNext(); ) {
+            J2EEApplicationServer applicationServer = (J2EEApplicationServer) applicationServerIterator.next();
+            for (Iterator applicationIterator = applicationServer.getJ2EEApplications().iterator(); applicationIterator.hasNext(); ) {
+                J2EEApplication application = (J2EEApplication) applicationIterator.next();
+                for (Iterator configurationFileIterator = application.getConfigurationFiles().iterator(); configurationFileIterator.hasNext(); ) {
+                    ConfigurationFile configurationFile = (ConfigurationFile) configurationFileIterator.next();
+                    ConfigurationFileCheckBox checkBox = new ConfigurationFileCheckBox(applicationServer.getName(), application.getName(), configurationFile.getName());
+                    checkBox.setStyleName("default");
+                    configurationFileCheckBoxes.add(checkBox);
+                    column.add(checkBox);
+                }
+            }
+        }
+
+        // add SQL scripts
+        Label sqlScriptsHeader = new Label(Messages.getString("sql.scripts"));
+        column.add(sqlScriptsHeader);
+        // add SQL scripts location
+        sqlScriptLocationField = new TextField();
+        sqlScriptLocationField.setStyleName("default");
+        sqlScriptLocationField.setWidth(new Extent(100, Extent.PERCENT));
+        sqlScriptLocationField.setText("/sql");
+        column.add(sqlScriptLocationField);
+        // add SQL scripts checkbox
+        for (Iterator applicationServerIterator = parent.getEnvironment().getJ2EEApplicationServers().getJ2EEApplicationServers().iterator(); applicationServerIterator.hasNext(); ) {
+            J2EEApplicationServer applicationServer = (J2EEApplicationServer) applicationServerIterator.next();
+            for (Iterator applicationIterator = applicationServer.getJ2EEApplications().iterator(); applicationIterator.hasNext(); ) {
+                J2EEApplication application = (J2EEApplication) applicationIterator.next();
+                for (Iterator databaseIterator = application.getDatabases().iterator(); databaseIterator.hasNext(); ) {
+                    Database database = (Database) databaseIterator.next();
+                    for (Iterator sqlScriptIterator = database.getSqlScripts().iterator(); sqlScriptIterator.hasNext(); ) {
+                        SqlScript sqlScript = (SqlScript) sqlScriptIterator.next();
+                        SqlScriptCheckBox checkBox = new SqlScriptCheckBox(applicationServer.getName(), application.getName(), database.getName(), sqlScript.getName());
+                        checkBox.setStyleName("default");
+                        sqlScriptCheckBoxes.add(checkBox);
+                        column.add(checkBox);
+                    }
+                }
+            }
+        }
+
+        // add external softwares
+        Label softwaresHeader = new Label(Messages.getString("softwares"));
+        column.add(softwaresHeader);
+        // add external softwares location
+        softwareLocationField = new TextField();
+        softwareLocationField.setStyleName("default");
+        softwareLocationField.setWidth(new Extent(100, Extent.PERCENT));
+        softwareLocationField.setText("/contrib");
+        column.add(softwareLocationField);
+        // add software checkbox
+        for (Iterator softwareIterator = parent.getEnvironment().getSoftwares().iterator(); softwareIterator.hasNext(); ) {
+            Software software = (Software) softwareIterator.next();
+            SoftwareCheckBox checkBox = new SoftwareCheckBox(software.getName());
+            checkBox.setStyleName("default");
+            softwareCheckBoxes.add(checkBox);
+            column.add(checkBox);
+        }
+
+    }
+
+}
\ No newline at end of file

Added: incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/PublisherWindow.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/PublisherWindow.java?rev=1205585&view=auto
==============================================================================
--- incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/PublisherWindow.java (added)
+++ incubator/kalumet/trunk/console/src/main/java/org/apache/kalumet/console/app/PublisherWindow.java Wed Nov 23 20:52:16 2011
@@ -0,0 +1,534 @@
+/*
+ * 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.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.SplitPane;
+import nextapp.echo2.app.TextField;
+import nextapp.echo2.app.WindowPane;
+import nextapp.echo2.app.event.ActionEvent;
+import nextapp.echo2.app.event.ActionListener;
+import nextapp.echo2.extras.app.TabPane;
+import nextapp.echo2.extras.app.layout.TabPaneLayoutData;
+import org.apache.kalumet.model.Destination;
+import org.apache.kalumet.model.Email;
+
+/**
+ * Email publisher window.
+ */
+public class PublisherWindow extends WindowPane {
+
+    private String mailhost;
+    private Email email;
+    private PublishersPane parent;
+    private TextField mailhostField;
+    private TextField fromField;
+    private Grid destinationsGrid;
+    private TextField newDestinationField;
+
+    // close
+    private ActionListener close = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            PublisherWindow.this.userClose();
+        }
+    };
+    // refresh
+    private ActionListener refresh = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            // looking for the original email publisher object
+            email = parent.getEnvironmentWindow().getEnvironment().getPublisher(mailhost);
+            if (email == null) {
+                email = new Email();
+            }
+            // update the window
+            update();
+        }
+    };
+    // delete
+    private ActionListener delete = 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;
+            }
+            // display confirm window
+            KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ConfirmWindow(new ActionListener() {
+                public void actionPerformed(ActionEvent event) {
+                    // remove the publisher email object
+                    parent.getEnvironmentWindow().getEnvironment().getPublishers().remove(email);
+                    // add a change event
+                    parent.getEnvironmentWindow().getChangeEvents().add("Delete publisher " + email.getMailhost());
+                    // change the updated flag
+                    parent.getEnvironmentWindow().setUpdated(true);
+                    // update the journal log tab pane
+                    parent.getEnvironmentWindow().updateJournalPane();
+                    // update the parent pane
+                    parent.update();
+                    // close the window
+                    PublisherWindow.this.userClose();
+                }
+            }));
+        }
+    };
+    // apply
+    private ActionListener apply = 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;
+            }
+            // get fields value
+            String mailhostFieldValue = mailhostField.getText();
+            String fromFieldValue = fromField.getText();
+            // check fields
+            if (mailhostFieldValue == null || mailhostFieldValue.trim().length() < 1 || fromFieldValue == null || fromFieldValue.trim().length() < 1) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("publisher.mandatory"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // add a change event
+            if (mailhost != null) {
+                parent.getEnvironmentWindow().getChangeEvents().add("Change publisher " + email.getMailhost());
+            }
+            // update the email publisher object
+            email.setMailhost(mailhostFieldValue);
+            email.setFrom(fromFieldValue);
+            // add the email publisher object if needed
+            if (mailhost == null) {
+                try {
+                    parent.getEnvironmentWindow().getEnvironment().addPublisher(email);
+                    parent.getEnvironmentWindow().getChangeEvents().add("Add publisher " + email.getMailhost());
+                } catch (Exception e) {
+                    KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("publisher.exists"), getEnvironmentWindow().getEnvironmentName());
+                    return;
+                }
+            }
+            // update the window definition
+            setTitle(Messages.getString("publisher") + " " + email.getMailhost());
+            setId("publisherwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + email.getMailhost());
+            mailhost = email.getMailhost();
+            // change the updated flag
+            parent.getEnvironmentWindow().setUpdated(true);
+            // update the journal log tab pane
+            parent.getEnvironmentWindow().updateJournalPane();
+            // update the parent pane
+            parent.update();
+            // update the window
+            update();
+        }
+    };
+    // delete destination
+    private ActionListener deleteDestination = 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;
+            }
+            // looking for the destination object
+            final Destination destination = email.getDestination(event.getActionCommand());
+            if (destination == null) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("destination.notfound"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // display confirm window
+            KalumetConsoleApplication.getApplication().getDefaultWindow().getContent().add(new ConfirmWindow(new ActionListener() {
+                public void actionPerformed(ActionEvent event) {
+                    // delete the destination object
+                    email.getDestinations().remove(destination);
+                    // add a change event
+                    parent.getEnvironmentWindow().getChangeEvents().add("Delete destination " + destination.getAddress());
+                    // change the updated flag
+                    parent.getEnvironmentWindow().setUpdated(true);
+                    // update the journal log tab pane
+                    parent.getEnvironmentWindow().updateJournalPane();
+                    // update the parent pane
+                    parent.update();
+                    // update the window
+                    update();
+                }
+            }));
+        }
+    };
+    // edit destination
+    private ActionListener editDestination = 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;
+            }
+            // get field
+            TextField destinationAddressField = (TextField) PublisherWindow.this.getComponent("destination_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + mailhost + "_" + event.getActionCommand());
+            // get field value
+            String destinationAddressFieldValue = destinationAddressField.getText();
+            // check field value
+            if (destinationAddressFieldValue == null || destinationAddressFieldValue.trim().length() < 1) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("destination.mandatory"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // if the user change the destination address, check if the address is
+            // not already in user
+            if (!destinationAddressFieldValue.equals(event.getActionCommand())) {
+                if (email.getDestination(destinationAddressFieldValue) != null) {
+                    KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("destination.exists"), getEnvironmentWindow().getEnvironmentName());
+                    return;
+                }
+            }
+            // looking for the destination object
+            Destination destination = email.getDestination(event.getActionCommand());
+            if (destination == null) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("destination.notfound"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // add a change event
+            parent.getEnvironmentWindow().getChangeEvents().add("Change destination " + destination.getAddress());
+            // update the destination object
+            destination.setAddress(destinationAddressFieldValue);
+            // change the updated flag
+            parent.getEnvironmentWindow().setUpdated(true);
+            // update the journal log tab pane
+            parent.getEnvironmentWindow().updateJournalPane();
+            // update the parent pane
+            parent.update();
+            // update the window
+            update();
+        }
+    };
+    // add destination
+    private ActionListener addDestination = 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;
+            }
+            // get field value
+            String newDestinationFieldValue = newDestinationField.getText();
+            // check field
+            if (newDestinationFieldValue == null || newDestinationFieldValue.trim().length() < 1) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("destination.mandatory"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // create a new destination object
+            Destination destination = new Destination();
+            destination.setAddress(newDestinationFieldValue);
+            // add the destination
+            try {
+                email.addDestination(destination);
+            } catch (Exception e) {
+                KalumetConsoleApplication.getApplication().getLogPane().addWarning(Messages.getString("destination.exists"), getEnvironmentWindow().getEnvironmentName());
+                return;
+            }
+            // add a change event
+            parent.getEnvironmentWindow().getChangeEvents().add("Add destination " + destination.getAddress());
+            // change the updated flag
+            parent.getEnvironmentWindow().setUpdated(true);
+            // update the journal log tab pane
+            parent.getEnvironmentWindow().updateJournalPane();
+            // update the parent pane
+            parent.update();
+            // update the window
+            update();
+        }
+    };
+    // copy
+    private ActionListener copy = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            try {
+                KalumetConsoleApplication.getApplication().setCopyComponent(email.clone());
+            } catch (Exception e) {
+                return;
+            }
+        }
+    };
+    // paste
+    private ActionListener paste = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+            // check the copy object
+            if (copy == null || !(copy instanceof Email)) {
+                return;
+            }
+            // update
+            email = (Email) copy;
+            mailhost = null;
+            // update the window
+            update();
+        }
+    };
+    // copy destination
+    private ActionListener copyDestination = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            // looking for the destination object
+            Destination destination = email.getDestination(event.getActionCommand());
+            if (destination == null) {
+                return;
+            }
+            try {
+                KalumetConsoleApplication.getApplication().setCopyComponent(destination.clone());
+            } catch (Exception e) {
+                return;
+            }
+        }
+    };
+    // paste destination
+    private ActionListener pasteDestination = new ActionListener() {
+        public void actionPerformed(ActionEvent event) {
+            Object copy = KalumetConsoleApplication.getApplication().getCopyComponent();
+            // check the copy object
+            if (copy == null || !(copy instanceof Destination)) {
+                return;
+            }
+            // update the new fields
+            newDestinationField.setText(((Destination) copy).getAddress());
+        }
+    };
+
+    /**
+     * Create a new <code>PublisherWindow</code>.
+     *
+     * @param parent   the parent <code>PublishersPane</code>.
+     * @param mailhost the original mailhost.
+     */
+    public PublisherWindow(PublishersPane parent, String mailhost) {
+        super();
+
+        // update the parent tab pane
+        this.parent = parent;
+
+        // update the email mailhost
+        this.mailhost = mailhost;
+
+        // update the email object from the parent environment
+        this.email = parent.getEnvironmentWindow().getEnvironment().getPublisher(mailhost);
+        if (this.email == null) {
+            this.email = new Email();
+        }
+
+        if (mailhost == null) {
+            setTitle(Messages.getString("publisher"));
+        } else {
+            setTitle(Messages.getString("publisher") + " " + mailhost);
+        }
+        setId("publisherwindow_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + mailhost);
+        setStyleName("default");
+        setModal(false);
+        setDefaultCloseOperation(WindowPane.DISPOSE_ON_CLOSE);
+
+        // create a split pane for the control button
+        SplitPane splitPane = new SplitPane(SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent(32));
+        add(splitPane);
+
+        // add the control pane
+        Row controlRow = new Row();
+        controlRow.setStyleName("control");
+        splitPane.add(controlRow);
+        // add the refresh button
+        Button refreshButton = new Button(Messages.getString("reload"), Styles.DATABASE_REFRESH);
+        refreshButton.setStyleName("control");
+        refreshButton.addActionListener(refresh);
+        controlRow.add(refreshButton);
+        // add the copy button
+        Button copyButton = new Button(Messages.getString("copy"), Styles.PAGE_COPY);
+        copyButton.setStyleName("control");
+        copyButton.addActionListener(copy);
+        controlRow.add(copyButton);
+        if (getEnvironmentWindow().adminPermission) {
+            // add the paste button
+            Button pasteButton = new Button(Messages.getString("paste"), Styles.PAGE_PASTE);
+            pasteButton.setStyleName("control");
+            pasteButton.addActionListener(paste);
+            controlRow.add(pasteButton);
+            // add the apply button
+            Button applyButton = new Button(Messages.getString("apply"), Styles.ACCEPT);
+            applyButton.setStyleName("control");
+            applyButton.addActionListener(apply);
+            controlRow.add(applyButton);
+            // add the delete button
+            Button deleteButton = new Button(Messages.getString("delete"), Styles.DELETE);
+            deleteButton.setStyleName("control");
+            deleteButton.addActionListener(delete);
+            controlRow.add(deleteButton);
+        }
+        // add the close button
+        Button closeButton = new Button(Messages.getString("close"), Styles.CROSS);
+        closeButton.setStyleName("control");
+        closeButton.addActionListener(close);
+        controlRow.add(closeButton);
+
+        // add the main tab pane
+        TabPane tabPane = new TabPane();
+        tabPane.setStyleName("default");
+        splitPane.add(tabPane);
+
+        // add the general tab
+        TabPaneLayoutData tabLayoutData = new TabPaneLayoutData();
+        tabLayoutData.setTitle(Messages.getString("general"));
+        ContentPane generalTabPane = new ContentPane();
+        generalTabPane.setStyleName("default");
+        generalTabPane.setLayoutData(tabLayoutData);
+        tabPane.add(generalTabPane);
+        Grid generalLayoutGrid = new Grid(2);
+        generalLayoutGrid.setStyleName("default");
+        generalLayoutGrid.setWidth(new Extent(100, Extent.PERCENT));
+        generalLayoutGrid.setColumnWidth(0, new Extent(20, Extent.PERCENT));
+        generalTabPane.add(generalLayoutGrid);
+        // mailhost
+        Label emailMailhostLabel = new Label(Messages.getString("mailhost"));
+        emailMailhostLabel.setStyleName("default");
+        generalLayoutGrid.add(emailMailhostLabel);
+        mailhostField = new TextField();
+        mailhostField.setStyleName("default");
+        mailhostField.setWidth(new Extent(100, Extent.PERCENT));
+        generalLayoutGrid.add(mailhostField);
+        Label emailFromLabel = new Label(Messages.getString("from"));
+        emailFromLabel.setStyleName("default");
+        generalLayoutGrid.add(emailFromLabel);
+        fromField = new TextField();
+        fromField.setStyleName("default");
+        fromField.setWidth(new Extent(100, Extent.PERCENT));
+        generalLayoutGrid.add(fromField);
+
+        // add the destinations tab
+        tabLayoutData = new TabPaneLayoutData();
+        tabLayoutData.setTitle(Messages.getString("destinations"));
+        ContentPane destinationsTabPane = new ContentPane();
+        destinationsTabPane.setStyleName("default");
+        destinationsTabPane.setLayoutData(tabLayoutData);
+        tabPane.add(destinationsTabPane);
+        destinationsGrid = new Grid(2);
+        destinationsGrid.setStyleName("border.grid");
+        destinationsTabPane.add(destinationsGrid);
+
+        // update the window
+        update();
+    }
+
+    /**
+     * Update the pane.
+     */
+    public void update() {
+        // update the email mailhost field
+        mailhostField.setText(email.getMailhost());
+        // update the email from field
+        fromField.setText(email.getFrom());
+        // update the destinations grid
+        // remove all destinations grid children
+        destinationsGrid.removeAll();
+        // add destinations grid header
+        Label actionHeader = new Label("");
+        actionHeader.setStyleName("grid.header");
+        destinationsGrid.add(actionHeader);
+        Label destinationAddressHeader = new Label(Messages.getString("address"));
+        destinationAddressHeader.setStyleName("grid.header");
+        destinationsGrid.add(destinationAddressHeader);
+        // add the destinations e-mails
+        for (Iterator destinationIterator = email.getDestinations().iterator(); destinationIterator.hasNext(); ) {
+            Destination destination = (Destination) destinationIterator.next();
+            // row
+            Row row = new Row();
+            row.setInsets(new Insets(2));
+            row.setCellSpacing(new Extent(2));
+            destinationsGrid.add(row);
+            // copy
+            Button copyButton = new Button(Styles.PAGE_COPY);
+            copyButton.setActionCommand(destination.getAddress());
+            copyButton.addActionListener(copyDestination);
+            row.add(copyButton);
+            if (getEnvironmentWindow().adminPermission) {
+                // edit button
+                Button editButton = new Button(Styles.ACCEPT);
+                editButton.setActionCommand(destination.getAddress());
+                editButton.addActionListener(editDestination);
+                row.add(editButton);
+                // delete
+                Button deleteButton = new Button(Styles.DELETE);
+                deleteButton.setActionCommand(destination.getAddress());
+                deleteButton.addActionListener(deleteDestination);
+                row.add(deleteButton);
+            }
+            // destination
+            TextField destinationField = new TextField();
+            destinationField.setId("destination_" + parent.getEnvironmentWindow().getEnvironmentName() + "_" + mailhost + "_" + destination.getAddress());
+            destinationField.setStyleName("default");
+            destinationField.setText(destination.getAddress());
+            destinationsGrid.add(destinationField);
+        }
+        // add create destination row in the destinations grid
+        if (getEnvironmentWindow().adminPermission) {
+            // row
+            Row row = new Row();
+            row.setInsets(new Insets(2));
+            row.setCellSpacing(new Extent(2));
+            destinationsGrid.add(row);
+            // paste
+            Button pasteButton = new Button(Styles.PAGE_PASTE);
+            pasteButton.addActionListener(pasteDestination);
+            row.add(pasteButton);
+            // add
+            Button addButton = new Button(Styles.ADD);
+            addButton.addActionListener(addDestination);
+            row.add(addButton);
+            // destination
+            newDestinationField = new TextField();
+            newDestinationField.setStyleName("default");
+            destinationsGrid.add(newDestinationField);
+        }
+    }
+
+    public EnvironmentWindow getEnvironmentWindow() {
+        return parent.getEnvironmentWindow();
+    }
+
+}
\ No newline at end of file



Mime
View raw message