You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ace.apache.org by ma...@apache.org on 2012/03/05 22:34:55 UTC
svn commit: r1297235 - in /ace/trunk/ace-target-mgmt-ui: ./ src/ src/main/
src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/ace/ src/main/java/org/apache/ace/target/
src/main/java/org/apache/ace/target/management/ sr...
Author: marrs
Date: Mon Mar 5 21:34:55 2012
New Revision: 1297235
URL: http://svn.apache.org/viewvc?rev=1297235&view=rev
Log:
ACE-227 applied the patch
Added:
ace/trunk/ace-target-mgmt-ui/
ace/trunk/ace-target-mgmt-ui/pom.xml
ace/trunk/ace-target-mgmt-ui/src/
ace/trunk/ace-target-mgmt-ui/src/main/
ace/trunk/ace-target-mgmt-ui/src/main/java/
ace/trunk/ace-target-mgmt-ui/src/main/java/org/
ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/
ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/
ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/
ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/
ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/
ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/Activator.java
ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/TargetManagementExtension.java
Added: ace/trunk/ace-target-mgmt-ui/pom.xml
URL: http://svn.apache.org/viewvc/ace/trunk/ace-target-mgmt-ui/pom.xml?rev=1297235&view=auto
==============================================================================
--- ace/trunk/ace-target-mgmt-ui/pom.xml (added)
+++ ace/trunk/ace-target-mgmt-ui/pom.xml Mon Mar 5 21:34:55 2012
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ace</groupId>
+ <artifactId>ace-pom</artifactId>
+ <version>0.8.1-incubator-SNAPSHOT</version>
+ <relativePath>../pom/pom.xml</relativePath>
+ </parent>
+
+ <version>0.8.1-incubator-SNAPSHOT</version>
+ <artifactId>org.apache.ace.target.mgmt.ui</artifactId>
+ <packaging>bundle</packaging>
+
+ <name>Apache ACE :: Target :: Management :: UI</name>
+ <description />
+
+ <properties>
+ <private.package>
+ org.apache.ace.target.management.ui
+ </private.package>
+ <bundle.activator>
+ org.apache.ace.target.management.ui.Activator
+ </bundle.activator>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.dependencymanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ace</groupId>
+ <artifactId>org.apache.ace.webui.vaadin</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Added: ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/Activator.java?rev=1297235&view=auto
==============================================================================
--- ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/Activator.java (added)
+++ ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/Activator.java Mon Mar 5 21:34:55 2012
@@ -0,0 +1,50 @@
+/*
+ * 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.target.management.ui;
+
+import java.util.Properties;
+
+import org.apache.ace.client.repository.RepositoryAdmin;
+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;
+
+public class Activator extends DependencyActivatorBase {
+
+ @Override
+ public void init(BundleContext context, DependencyManager manager) throws Exception {
+ Properties props = new Properties();
+ props.put(UIExtensionFactory.EXTENSION_POINT_KEY, UIExtensionFactory.EXTENSION_POINT_VALUE_TARGET);
+ props.put(Constants.SERVICE_RANKING, Integer.valueOf(200));
+
+ manager.add(createComponent().setInterface(UIExtensionFactory.class.getName(), props)
+ .setImplementation(TargetManagementExtension.class)
+ .add(createServiceDependency()
+ .setService(RepositoryAdmin.class)
+ .setRequired(true))
+ );
+ }
+
+ @Override
+ public void destroy(BundleContext context, DependencyManager manager) throws Exception {
+ // Nop
+ }
+}
Added: ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/TargetManagementExtension.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/TargetManagementExtension.java?rev=1297235&view=auto
==============================================================================
--- ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/TargetManagementExtension.java (added)
+++ ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/TargetManagementExtension.java Mon Mar 5 21:34:55 2012
@@ -0,0 +1,128 @@
+/*
+ * 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.target.management.ui;
+
+import java.util.Map;
+
+import org.apache.ace.client.repository.RepositoryObject;
+import org.apache.ace.client.repository.stateful.StatefulGatewayObject;
+import org.apache.ace.webui.NamedObject;
+import org.apache.ace.webui.UIExtensionFactory;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+
+/**
+ * Provides a simple management UI for targets.
+ */
+public class TargetManagementExtension implements UIExtensionFactory {
+
+ private static final String CAPTION = "Management";
+
+ /**
+ * {@inheritDoc}
+ */
+ public Component create(Map<String, Object> context) {
+ GridLayout result = new GridLayout(1, 4);
+ result.setCaption(CAPTION);
+
+ result.setMargin(true);
+ result.setSpacing(true);
+ result.setSizeFull();
+
+ RepositoryObject object = getRepositoryObjectFromContext(context);
+ if (!(object instanceof StatefulGatewayObject)) {
+ result.addComponent(new Label("This target is not a stateful gateway object."));
+ return result;
+ }
+
+ final StatefulGatewayObject target = (StatefulGatewayObject) object;
+
+ CheckBox registerCB = new CheckBox("Registered?");
+ registerCB.setImmediate(true);
+ registerCB.setEnabled(!target.isRegistered());
+ registerCB.setValue(Boolean.valueOf(target.isRegistered()));
+ registerCB.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (event.getButton().booleanValue()) {
+ target.register();
+ }
+ }
+ });
+
+ result.addComponent(registerCB);
+
+ CheckBox autoApproveCB = new CheckBox("Auto approve?");
+ autoApproveCB.setImmediate(true);
+ autoApproveCB.setEnabled(target.isRegistered());
+ autoApproveCB.setValue(Boolean.valueOf(target.getAutoApprove()));
+ autoApproveCB.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ target.setAutoApprove(event.getButton().booleanValue());
+ }
+ });
+
+ result.addComponent(autoApproveCB);
+
+
+ Button approveButton = new Button("Approve changes");
+ approveButton.setImmediate(true);
+ approveButton.setEnabled(!target.getAutoApprove() && target.isRegistered() && hasUnapprovedChanges(target));
+ approveButton.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ target.approve();
+ }
+ });
+
+ result.addComponent(approveButton);
+
+ // Add a spacer that fill the remainder of the available space...
+ result.addComponent(new Label(" "));
+ result.setRowExpandRatio(3, 1.0f);
+
+ return result;
+ }
+
+ /**
+ * @param target
+ * @return
+ */
+ private boolean hasUnapprovedChanges(StatefulGatewayObject target) {
+ String availableVersion = target.getCurrentVersion();
+ String currentVersion = target.getLastInstallVersion();
+ return (availableVersion != null) && !availableVersion.equals(currentVersion);
+ }
+
+ private RepositoryObject getRepositoryObjectFromContext(Map<String, Object> context) {
+ Object contextObject = context.get("object");
+ if (contextObject == null) {
+ throw new IllegalStateException("No context object found");
+ }
+ // It looks like there is some bug (or some other reason that escapes
+ // me) why ace is using either the object directly or wraps it in a
+ // NamedObject first.
+ // Its unclear when it does which so for now we cater for both.
+ return (contextObject instanceof NamedObject ? ((NamedObject) contextObject).getObject()
+ : (RepositoryObject) contextObject);
+ }
+}