ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1297240 - in /ace/trunk/ace-webui-vaadin: ./ src/main/java/org/apache/ace/webui/vaadin/ src/main/java/org/apache/ace/webui/vaadin/component/
Date Mon, 05 Mar 2012 21:52:07 GMT
Author: marrs
Date: Mon Mar  5 21:52:06 2012
New Revision: 1297240

URL: http://svn.apache.org/viewvc?rev=1297240&view=rev
Log:
ACE-226 applied the patch, fixed some headers

Added:
    ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/
    ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/ConfirmationDialog.java
    ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
Modified:
    ace/trunk/ace-webui-vaadin/pom.xml
    ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Activator.java
    ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java

Modified: ace/trunk/ace-webui-vaadin/pom.xml
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/pom.xml?rev=1297240&r1=1297239&r2=1297240&view=diff
==============================================================================
--- ace/trunk/ace-webui-vaadin/pom.xml (original)
+++ ace/trunk/ace-webui-vaadin/pom.xml Mon Mar  5 21:52:06 2012
@@ -52,6 +52,7 @@
         </import.package>
         <private.package>
             org.apache.ace.webui.vaadin,
+            org.apache.ace.webui.vaadin.component,
             org.apache.ace.webui.domain,
             org.apache.ace.test.utils
         </private.package>

Modified: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Activator.java?rev=1297240&r1=1297239&r2=1297240&view=diff
==============================================================================
--- ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Activator.java (original)
+++ ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Activator.java Mon
Mar  5 21:52:06 2012
@@ -24,12 +24,12 @@ import java.util.Properties;
 import javax.servlet.Servlet;
 
 import org.apache.ace.client.repository.stateful.StatefulGatewayObject;
-import org.apache.ace.http.listener.constants.HttpConstants;
 import org.apache.ace.webui.NamedObject;
 import org.apache.ace.webui.UIExtensionFactory;
 import org.apache.felix.dm.DependencyActivatorBase;
 import org.apache.felix.dm.DependencyManager;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
 import org.osgi.service.http.HttpService;
 
 import com.vaadin.ui.Component;
@@ -45,38 +45,43 @@ public class Activator extends Dependenc
                 .setService(HttpService.class)
                 .setRequired(true)
             )
-        );
+            );
         // register the main application for the ACE UI client
         manager.add(createComponent()
             .setInterface(Servlet.class.getName(), null)
             .setImplementation(VaadinServlet.class)
             .add(createConfigurationDependency()
                 .setPid(VaadinServlet.PID).setPropagate(true))
-        );
-        
+            );
+
+        Properties props = new Properties();
+        props.put(UIExtensionFactory.EXTENSION_POINT_KEY, UIExtensionFactory.EXTENSION_POINT_VALUE_TARGET);
+        props.put(Constants.SERVICE_RANKING, Integer.valueOf(100));
+
         // shows off components that are contributed by extensions
         manager.add(createComponent()
-            .setInterface(UIExtensionFactory.class.getName(), new Properties() {{ put(UIExtensionFactory.EXTENSION_POINT_KEY,
UIExtensionFactory.EXTENSION_POINT_VALUE_TARGET); }})
+            .setInterface(UIExtensionFactory.class.getName(), props)
             .setImplementation(new UIExtensionFactory() {
                 public Component create(Map<String, Object> context) {
-                    final NamedObject object = (NamedObject) context.get("object");
                     VerticalLayout vl = new VerticalLayout();
                     vl.setCaption("Info");
                     final NamedObject namedObject = (NamedObject) context.get("object");
                     final StatefulGatewayObject target = (StatefulGatewayObject) namedObject.getObject();
-                    Label info = new Label("Target ID: " + namedObject.getName() + "<br
/>" +
-                		"Installed version: " + target.getLastInstallVersion() + "<br />"
+
-        				"Available version: " + target.getCurrentVersion() + "<br />" +
-						"Provisioning state: " + target.getProvisioningState() + "<br />" +
-						"Registration state: " + target.getRegistrationState());
-                    info.setContentMode(Label.CONTENT_XHTML);
+                    Label info = new Label(
+                        "Target ID          : " + namedObject.getName() + "\n" +
+                        "Installed version  : " + (target.getLastInstallVersion() == null
? "(none)" : target.getLastInstallVersion()) + "\n" +
+                        "Available version  : " + target.getCurrentVersion() + "\n" +
+                        "Store state        : " + target.getStoreState() + "\n" +
+                        "Provisioning state : " + target.getProvisioningState() + "\n" +
+                        "Registration state : " + target.getRegistrationState());
+                    info.setContentMode(Label.CONTENT_PREFORMATTED);
                     vl.addComponent(info);
                     return vl;
                 }
             })
-        );
+            );
     }
-    
+
     @Override
     public void destroy(BundleContext context, DependencyManager manager) throws Exception
{
     }

Modified: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java?rev=1297240&r1=1297239&r2=1297240&view=diff
==============================================================================
--- ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
(original)
+++ ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
Mon Mar  5 21:52:06 2012
@@ -20,8 +20,10 @@ package org.apache.ace.webui.vaadin;
 
 import java.io.File;
 import java.io.IOException;
+import java.lang.ref.WeakReference;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -54,9 +56,12 @@ import org.apache.ace.test.utils.FileUti
 import org.apache.ace.webui.NamedObject;
 import org.apache.ace.webui.UIExtensionFactory;
 import org.apache.ace.webui.domain.OBREntry;
+import org.apache.ace.webui.vaadin.component.ConfirmationDialog;
+import org.apache.ace.webui.vaadin.component.MainActionToolbar;
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.event.EventConstants;
 import org.osgi.service.event.EventHandler;
 import org.osgi.service.log.LogService;
@@ -181,14 +186,15 @@ public class VaadinClient extends com.va
         addDependency(component, StatefulGatewayRepository.class);
     }
 
-    //@formatter:off
+    // @formatter:off
     private void addDependency(Component component, Class service) {
         component.add(m_manager.createServiceDependency()
             .setService(service, "(" + SessionFactory.SERVICE_SID + "=" + m_sessionID + ")")
             .setRequired(true)
             .setInstanceBound(true));
     }
-    //@formatter:on
+
+    // @formatter:on
 
     public void start() {
         System.out.println("Starting " + m_sessionID);
@@ -421,12 +427,12 @@ public class VaadinClient extends com.va
             }
             RepositoryAdminLoginContext context = m_admin.createLoginContext(user);
 
-            //@formatter:off
+            // @formatter:off
             context.addShopRepository(new URL(m_aceHost, endpoint), customerName, shopRepo,
true)
                 .setObrBase(m_obrUrl)
                 .addGatewayRepository(new URL(m_aceHost, endpoint), customerName, gatewayRepo,
true)
                 .addDeploymentRepository(new URL(m_aceHost, endpoint), customerName, deployRepo,
true);
-          //@formatter:on
+            // @formatter:on
             m_admin.login(context);
             initGrid(user);
             m_admin.checkout();
@@ -448,57 +454,36 @@ public class VaadinClient extends com.va
     }
 
     private GridLayout createToolbar() {
-        GridLayout toolbar = new GridLayout(3, 1);
-        toolbar.setSpacing(true);
+        MainActionToolbar mainActionToolbar = new MainActionToolbar() {
+            @Override
+            protected RepositoryAdmin getRepositoryAdmin() {
+                return m_admin;
+            }
 
-        Button retrieveButton = new Button("Retrieve");
-        retrieveButton.addListener(new Button.ClickListener() {
-            public void buttonClick(ClickEvent event) {
-                try {
-                    m_admin.checkout();
-                    updateTableData();
-                }
-                catch (IOException e) {
-                    getMainWindow().showNotification("Retrieve failed",
-                        "Failed to retrieve the data from the server.<br />" + "Reason:
" + e.getMessage(),
-                        Notification.TYPE_ERROR_MESSAGE);
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
-                }
+            @Override
+            protected void doAfterRevert() throws IOException {
+                updateTableData();
             }
-        });
-        toolbar.addComponent(retrieveButton, 0, 0);
 
-        Button storeButton = new Button("Store");
-        storeButton.addListener(new Button.ClickListener() {
-            public void buttonClick(ClickEvent event) {
-                try {
-                    m_admin.commit();
-                }
-                catch (IOException e) {
-                    getMainWindow().showNotification("Commit failed",
-                        "Failed to commit the changes to the server.<br />" + "Reason:
" + e.getMessage(),
-                        Notification.TYPE_ERROR_MESSAGE);
-                }
+            @Override
+            protected void doAfterRetrieve() throws IOException {
+                updateTableData();
             }
-        });
-        toolbar.addComponent(storeButton, 1, 0);
-        Button revertButton = new Button("Revert");
-        revertButton.addListener(new Button.ClickListener() {
-            public void buttonClick(ClickEvent event) {
-                try {
-                    m_admin.revert();
-                    updateTableData();
-                }
-                catch (IOException e) {
-                    getMainWindow().showNotification("Revert failed",
-                        "Failed to revert your changes.<br />" + "Reason: " + e.getMessage(),
-                        Notification.TYPE_ERROR_MESSAGE);
-                }
+
+            @Override
+            protected void doAfterCommit() throws IOException {
+                // Nop
             }
-        });
-        toolbar.addComponent(revertButton, 2, 0);
-        return toolbar;
+
+            private void updateTableData() {
+                m_artifactsPanel.populate();
+                m_featuresPanel.populate();
+                m_distributionsPanel.populate();
+                m_targetsPanel.populate();
+            }
+        };
+        addListener(mainActionToolbar, RepositoryObject.PUBLIC_TOPIC_ROOT.concat(RepositoryObject.TOPIC_ALL_SUFFIX));
+        return mainActionToolbar;
     }
 
     private ObjectPanel createArtifactsPanel(Window main) {
@@ -1073,13 +1058,6 @@ public class VaadinClient extends com.va
         }
     }
 
-    private void updateTableData() {
-        m_artifactsPanel.populate();
-        m_featuresPanel.populate();
-        m_distributionsPanel.populate();
-        m_targetsPanel.populate();
-    }
-
     @Override
     public void close() {
         super.close();

Added: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/ConfirmationDialog.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/ConfirmationDialog.java?rev=1297240&view=auto
==============================================================================
--- ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/ConfirmationDialog.java
(added)
+++ ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/ConfirmationDialog.java
Mon Mar  5 21:52:06 2012
@@ -0,0 +1,133 @@
+/*
+ * 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.ace.webui.vaadin.component;
+
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+/**
+ * Provides a confirmation dialog, based on code found on <a href="https://vaadin.com/forum/-/message_boards/view_message/17883">this
forum posting</a>.
+ */
+public class ConfirmationDialog extends Window implements ClickListener {
+
+    /**
+     * Callback class for a {@link ConfirmationDialog}.
+     */
+    public static interface Callback {
+        /**
+         * Called upon pressing a button.
+         * 
+         * @param buttonName the name of the button that was clicked, never <code>null</code>.
+         */
+        void onDialogResult(String buttonName);
+    }
+
+    public static final String YES = "Yes";
+    public static final String NO = "No";
+    public static final String CANCEL = "Cancel";
+
+    private final Callback m_callback;
+
+    /**
+     * Provides a Yes/No confirmation dialog.
+     * 
+     * @param caption the caption of this dialog, cannot be <code>null</code>;
+     * @param message the message to display, may be <code>null</code> to omit
the message;
+     * @param callback the callback to call for each pressed button.
+     */
+    public ConfirmationDialog(String caption, String message, Callback callback) {
+        this(caption, message, callback, YES, NO);
+    }
+
+    /**
+     * Provides a confirmation dialog with a custom set of buttons.
+     * 
+     * @param caption the caption of this dialog, cannot be <code>null</code>;
+     * @param message the message to display, may be <code>null</code> to omit
the message;
+     * @param callback the callback to call for each pressed button;
+     * @param buttonNames the names of the buttons to display.
+     */
+    public ConfirmationDialog(String caption, String message, Callback callback, String...
buttonNames) {
+        super(caption);
+
+        if (buttonNames == null || buttonNames.length <= 1) {
+            throw new IllegalArgumentException("Need at least one button name!");
+        }
+        if (callback == null) {
+            throw new IllegalArgumentException("Need a callback!");
+        }
+
+        m_callback = callback;
+
+        setWidth("30em");
+        setModal(true);
+
+        VerticalLayout layout = (VerticalLayout) getContent();
+        layout.setMargin(true);
+        layout.setSpacing(true);
+
+        addComponents(message, buttonNames);
+    }
+
+    /**
+     * @see com.vaadin.ui.Button.ClickListener#buttonClick(com.vaadin.ui.Button.ClickEvent)
+     */
+    public void buttonClick(ClickEvent event) {
+        Window parent = getParent();
+        if (parent != null) {
+            parent.removeWindow(this);
+        }
+
+        AbstractComponent comp = (AbstractComponent) event.getComponent();
+        m_callback.onDialogResult((String) comp.getData());
+    }
+
+    /**
+     * Adds all components to this dialog.
+     * 
+     * @param message the optional message to display, can be <code>null</code>;
+     * @param buttonNames the names of the buttons to add, never <code>null</code>
or empty.
+     */
+    protected void addComponents(String message, String... buttonNames) {
+        if (message != null) {
+            addComponent(new Label(message));
+        }
+
+        GridLayout gl = new GridLayout(buttonNames.length + 1, 1);
+        gl.setSpacing(true);
+        gl.setWidth("100%");
+
+        gl.addComponent(new Label(" "));
+        gl.setColumnExpandRatio(0, 1.0f);
+
+        for (String buttonName : buttonNames) {
+            Button button = new Button(buttonName, this);
+            button.setData(buttonName);
+            gl.addComponent(button);
+        }
+
+        addComponent(gl);
+    }
+}

Added: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/MainActionToolbar.java?rev=1297240&view=auto
==============================================================================
--- ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
(added)
+++ ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
Mon Mar  5 21:52:06 2012
@@ -0,0 +1,279 @@
+/*
+ * 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.ace.webui.vaadin.component;
+
+import java.io.IOException;
+
+import org.apache.ace.client.repository.RepositoryAdmin;
+import org.osgi.service.event.EventHandler;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Window.Notification;
+
+/**
+ * Provides the main actions toolbar where one can commit, revert or retrieve changes.
+ */
+public abstract class MainActionToolbar extends GridLayout implements EventHandler {
+
+    /**
+     * Provides a button listener for the revert button.
+     */
+    private final class RevertButtonListener implements Button.ClickListener, ConfirmationDialog.Callback
{
+
+        /**
+         * {@inheritDoc}
+         */
+        public void buttonClick(ClickEvent event) {
+            try {
+                if (getRepositoryAdmin().isModified()) {
+                    // Revert all changes...
+                    getWindow().addWindow(new ConfirmationDialog("Revert changes?",
+                        "Are you sure you want to overwrite all local changes?", this));
+                }
+                else {
+                    // Nothing to revert...
+                    getWindow().showNotification("Nothing to revert",
+                        "There are no local changes that need to be reverted.",
+                        Notification.TYPE_WARNING_MESSAGE);
+                }
+            }
+            catch (IOException e) {
+                handleIOException(e);
+            }
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        public void onDialogResult(String buttonName) {
+            if (ConfirmationDialog.YES.equals(buttonName)) {
+                try {
+                    revertChanges();
+                }
+                catch (IOException e) {
+                    handleIOException(e);
+                }
+            }
+        }
+
+        /**
+         * Does the actual revert of changes.
+         * 
+         * @throws IOException in case of problems during I/O exception.
+         */
+        private void revertChanges() throws IOException {
+            getRepositoryAdmin().revert();
+            doAfterRevert();
+        }
+
+        /**
+         * @param e the exception to handle.
+         */
+        private void handleIOException(IOException e) {
+            getWindow().showNotification("Revert failed",
+                "Failed to revert your changes.<br />" + "Reason: " + e.getMessage(),
+                Notification.TYPE_ERROR_MESSAGE);
+        }
+    }
+
+    /**
+     * Provides a button listener for the store button.
+     */
+    private final class StoreButtonListener implements Button.ClickListener {
+
+        /**
+         * {@inheritDoc}
+         */
+        public void buttonClick(ClickEvent event) {
+            final RepositoryAdmin repoAdmin = getRepositoryAdmin();
+            try {
+                if (repoAdmin.isModified()) {
+                    if (repoAdmin.isCurrent()) {
+                        commitChanges();
+                    }
+                    else {
+                        getWindow().showNotification("Changes not stored",
+                            "Unable to store your changes; repository changed!", Notification.TYPE_WARNING_MESSAGE);
+                    }
+                }
+                else {
+                    getWindow().showNotification("Nothing to store",
+                        "There are no changes that can be stored to the repository.",
+                        Notification.TYPE_WARNING_MESSAGE);
+                }
+            }
+            catch (IOException e) {
+                getWindow().showNotification("Changes not stored",
+                    "Failed to store the changes to the server.<br />Reason: " + e.getMessage(),
+                    Notification.TYPE_ERROR_MESSAGE);
+            }
+        }
+
+        /**
+         * Does the actual commit of changes.
+         * 
+         * @throws IOException in case of I/O problems during the commit.
+         */
+        private void commitChanges() throws IOException {
+            getRepositoryAdmin().commit();
+            doAfterCommit();
+        }
+    }
+
+    /**
+     * Provides a button listener for the retrieve button.
+     */
+    private final class RetrieveButtonListener implements Button.ClickListener, ConfirmationDialog.Callback
{
+
+        /**
+         * {@inheritDoc}
+         */
+        public void buttonClick(ClickEvent event) {
+            final RepositoryAdmin repoAdmin = getRepositoryAdmin();
+            try {
+                if (repoAdmin.isModified()) {
+                    // Warn the user about the possible loss of changes...
+                    getWindow().addWindow(
+                        new ConfirmationDialog("Retrieve latest changes?",
+                            "The repository is changed. Are you sure you want to loose all
local changes?", this));
+                }
+                else {
+                    retrieveData();
+                }
+            }
+            catch (IOException e) {
+                handleIOException(e);
+            }
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        public void onDialogResult(String buttonName) {
+            if (ConfirmationDialog.YES.equals(buttonName)) {
+                try {
+                    retrieveData();
+                }
+                catch (IOException e) {
+                    handleIOException(e);
+                }
+            }
+        }
+
+        /**
+         * Does the actual retrieval of the latest version.
+         * 
+         * @throws IOException in case of I/O problems during the retrieve.
+         */
+        private void retrieveData() throws IOException {
+            getRepositoryAdmin().checkout();
+            doAfterRetrieve();
+        }
+
+        /**
+         * @param e the exception to handle.
+         */
+        private void handleIOException(IOException e) {
+            getWindow().showNotification("Retrieve failed", "Failed to retrieve the data
from the server.<br />" +
+                "Reason: " + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
+        }
+    }
+
+    private Button m_retrieveButton;
+    private Button m_storeButton;
+    private Button m_revertButton;
+
+    /**
+     * Creates a new {@link MainActionToolbar} instance.
+     */
+    public MainActionToolbar() {
+        super(3, 1);
+
+        setSpacing(true);
+
+        initComponent();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleEvent(org.osgi.service.event.Event event) {
+        String topic = event.getTopic();
+        if (RepositoryAdmin.TOPIC_STATUSCHANGED.equals(topic) || RepositoryAdmin.TOPIC_REFRESH.equals(topic)
+            || RepositoryAdmin.TOPIC_LOGIN.equals(topic)) {
+
+            boolean modified = false;
+            try {
+                modified = getRepositoryAdmin().isModified();
+            }
+            catch (IOException e) {
+                getWindow().showNotification("Communication failed!", "Failed to communicate
with the server.<br />" +
+                    "Reason: " + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
+            }
+
+            m_storeButton.setEnabled(modified);
+            m_revertButton.setEnabled(modified);
+        }
+    }
+
+    /**
+     * @return a repository admin instance, never <code>null</code>.
+     */
+    protected abstract RepositoryAdmin getRepositoryAdmin();
+
+    /**
+     * Called after a revert has taken place, allows additional UI-updates to be performed.
+     * 
+     * @throws IOException
+     */
+    protected abstract void doAfterRevert() throws IOException;
+
+    /**
+     * Called after a commit/store has taken place, allows additional UI-updates to be performed.
+     * 
+     * @throws IOException
+     */
+    protected abstract void doAfterCommit() throws IOException;
+
+    /**
+     * Called after a retrieve has taken place, allows additional UI-updates to be performed.
+     * 
+     * @throws IOException
+     */
+    protected abstract void doAfterRetrieve() throws IOException;
+
+    /**
+     * Initializes this component.
+     */
+    private void initComponent() {
+        m_retrieveButton = new Button("Retrieve");
+        m_retrieveButton.addListener(new RetrieveButtonListener());
+        addComponent(m_retrieveButton, 0, 0);
+
+        m_storeButton = new Button("Store");
+        m_storeButton.addListener(new StoreButtonListener());
+        addComponent(m_storeButton, 1, 0);
+
+        m_revertButton = new Button("Revert");
+        m_revertButton.addListener(new RevertButtonListener());
+        addComponent(m_revertButton, 2, 0);
+    }
+}



Mime
View raw message