Return-Path: X-Original-To: apmail-ace-commits-archive@www.apache.org Delivered-To: apmail-ace-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D0B4D9816 for ; Wed, 4 Apr 2012 06:44:23 +0000 (UTC) Received: (qmail 69674 invoked by uid 500); 4 Apr 2012 06:44:17 -0000 Delivered-To: apmail-ace-commits-archive@ace.apache.org Received: (qmail 69000 invoked by uid 500); 4 Apr 2012 06:44:13 -0000 Mailing-List: contact commits-help@ace.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ace.apache.org Delivered-To: mailing list commits@ace.apache.org Received: (qmail 68880 invoked by uid 99); 4 Apr 2012 06:44:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2012 06:44:07 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2012 06:44:05 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E32EF238897A for ; Wed, 4 Apr 2012 06:43:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1309263 - /ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java Date: Wed, 04 Apr 2012 06:43:45 -0000 To: commits@ace.apache.org From: jawi@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120404064345.E32EF238897A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jawi Date: Wed Apr 4 06:43:45 2012 New Revision: 1309263 URL: http://svn.apache.org/viewvc?rev=1309263&view=rev Log: ACE-246: ensure the delete-target button is disabled for unregistered targets. Modified: ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java 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=1309263&r1=1309262&r2=1309263&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 Wed Apr 4 06:43:45 2012 @@ -68,6 +68,7 @@ import org.osgi.service.useradmin.User; import org.osgi.service.useradmin.UserAdmin; import com.vaadin.data.Item; +import com.vaadin.data.Property; import com.vaadin.event.ItemClickEvent; import com.vaadin.event.ItemClickEvent.ItemClickListener; import com.vaadin.event.Transferable; @@ -320,8 +321,7 @@ public class VaadinClient extends com.va m_featuresPanel.addListener(m_associations.createSelectionListener(m_featuresPanel, m_featureRepository, new Class[] { ArtifactObject.class }, new Class[] { DistributionObject.class, TargetObject.class }, new Table[] { m_artifactsPanel, m_distributionsPanel, m_targetsPanel })); - m_distributionsPanel - .addListener(m_associations.createSelectionListener(m_distributionsPanel, m_distributionRepository, + m_distributionsPanel.addListener(m_associations.createSelectionListener(m_distributionsPanel, m_distributionRepository, new Class[] { FeatureObject.class, ArtifactObject.class }, new Class[] { TargetObject.class }, new Table[] { m_artifactsPanel, m_featuresPanel, m_targetsPanel })); m_targetsPanel.addListener(m_associations.createSelectionListener(m_targetsPanel, m_statefulTargetRepository, @@ -554,8 +554,7 @@ public class VaadinClient extends com.va } }; buttons.addComponent(removeLinkButton); - buttons.addComponent(new RemoveItemButton(artifact, - m_artifactRepository)); + buttons.addComponent(new RemoveItemButton(artifact, m_artifactRepository)); item.getItemProperty(ACTIONS).setValue(buttons); } } @@ -632,8 +631,7 @@ public class VaadinClient extends com.va }; HorizontalLayout buttons = new HorizontalLayout(); buttons.addComponent(removeLinkButton); - buttons.addComponent(new RemoveItemButton(feature, - m_featureRepository)); + buttons.addComponent(new RemoveItemButton(feature, m_featureRepository)); item.getItemProperty(ACTIONS).setValue(buttons); } } @@ -682,10 +680,11 @@ public class VaadinClient extends com.va protected abstract void removeLinkFromRight(REPO_OBJECT object, RepositoryObject other); } - public class RemoveItemButton extends Button { - public RemoveItemButton(final REPO_OBJECT object, final REPO repository) { + public class RemoveItemButton extends Button { + public RemoveItemButton(final RepositoryObject object, final ObjectRepository repository) { super("x"); setStyleName("small"); + addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { @@ -734,8 +733,7 @@ public class VaadinClient extends com.va if (item != null) { item.getItemProperty(OBJECT_NAME).setValue(distribution.getName()); item.getItemProperty(OBJECT_DESCRIPTION).setValue(distribution.getDescription()); - Button removeLinkButton = new RemoveLinkButton(distribution, m_featuresPanel, - m_targetsPanel) { + Button removeLinkButton = new RemoveLinkButton(distribution, m_featuresPanel, m_targetsPanel) { @Override protected void removeLinkFromLeft(DistributionObject object, RepositoryObject other) { List associations = object @@ -760,8 +758,7 @@ public class VaadinClient extends com.va }; HorizontalLayout buttons = new HorizontalLayout(); buttons.addComponent(removeLinkButton); - buttons.addComponent(new RemoveItemButton(distribution, - m_distributionRepository)); + buttons.addComponent(new RemoveItemButton(distribution, m_distributionRepository)); item.getItemProperty(ACTIONS).setValue(buttons); } } @@ -781,6 +778,8 @@ public class VaadinClient extends com.va private ObjectPanel createTargetsPanel(Window main) { return new ObjectPanel(m_associations, "Target", UIExtensionFactory.EXTENSION_POINT_VALUE_TARGET, main, true) { + private RemoveItemButton m_deleteButton; + @Override protected RepositoryObject getFromId(String id) { return getTarget(id); @@ -794,8 +793,7 @@ public class VaadinClient extends com.va } public void handleEvent(org.osgi.service.event.Event event) { - StatefulTargetObject statefulTarget = (StatefulTargetObject) event - .getProperty(StatefulTargetObject.EVENT_ENTITY); + StatefulTargetObject statefulTarget = (StatefulTargetObject) event.getProperty(StatefulTargetObject.EVENT_ENTITY); String topic = (String) event.getProperty(EventConstants.EVENT_TOPIC); if (StatefulTargetObject.TOPIC_ADDED.equals(topic)) { add(statefulTarget); @@ -828,9 +826,12 @@ public class VaadinClient extends com.va protected void removeLinkFromRight(StatefulTargetObject object, RepositoryObject other) { } }; + m_deleteButton = new RemoveItemButton(statefulTarget, m_statefulTargetRepository); + m_deleteButton.setEnabled(statefulTarget.isRegistered()); + HorizontalLayout buttons = new HorizontalLayout(); buttons.addComponent(removeLinkButton); - buttons.addComponent(new RemoveItemButton(statefulTarget, m_statefulTargetRepository)); + buttons.addComponent(m_deleteButton); item.getItemProperty(ACTIONS).setValue(buttons); } } @@ -839,6 +840,8 @@ public class VaadinClient extends com.va Item item = getItem(statefulTarget.getDefinition()); if (item != null) { item.getItemProperty(OBJECT_DESCRIPTION).setValue(""); + + m_deleteButton.setEnabled(statefulTarget.isRegistered()); } } @@ -1116,25 +1119,32 @@ public class VaadinClient extends com.va public abstract class ObjectPanel extends Table implements EventHandler { public static final String ACTIONS = "actions"; - protected Table m_table = this; - protected Associations m_associations; - private List m_extensionFactories = new ArrayList(); + + protected final Table m_table; + protected final Associations m_associations; + + private final List m_extensionFactories; private final String m_extensionPoint; - public ObjectPanel(Associations associations, final String name, String extensionPoint, final Window main, - boolean hasEdit) { + public ObjectPanel(Associations associations, final String name, String extensionPoint, final Window main, final boolean hasEdit) { super(name + "s"); + + m_table = this; + m_extensionFactories = new ArrayList(); m_associations = associations; m_extensionPoint = extensionPoint; + addContainerProperty(OBJECT_NAME, String.class, null); addContainerProperty(OBJECT_DESCRIPTION, String.class, null); addContainerProperty(ACTIONS, HorizontalLayout.class, null); + setSizeFull(); setCellStyleGenerator(m_associations.createCellStyleGenerator()); setSelectable(true); setMultiSelect(true); setImmediate(true); setDragMode(TableDragMode.MULTIROW); + if (hasEdit) { addListener(new ItemClickListener() { public void itemClick(ItemClickEvent event) { @@ -1151,6 +1161,7 @@ public class VaadinClient extends com.va public void init(Component component) { populate(); + DependencyManager dm = component.getDependencyManager(); component.add(dm .createServiceDependency()