Author: chris.laprun(a)jboss.com
Date: 2008-08-23 11:47:32 -0400 (Sat, 23 Aug 2008)
New Revision: 11731
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/CoordinationAction.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/editCoordination.xhtml
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/coordination/CoordinationConfigurator.java
Log:
- Finished first step of event wiring creation. Back-end is currently failing...
- Fixed CoordinationAction.addEventInfoFor which wasn't using the propery key type.
- Minor clean-ups.
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/coordination/CoordinationConfigurator.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/coordination/CoordinationConfigurator.java 2008-08-22
16:26:52 UTC (rev 11730)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/coordination/CoordinationConfigurator.java 2008-08-23
15:47:32 UTC (rev 11731)
@@ -67,8 +67,6 @@
*/
void setEventWiringImplicitMode(PageContainer pageContainer, boolean mode) throws
IllegalCoordinationException;
-
-
/**
* Checks if implicit event wiring is enabled for a given page container. May return
null if no implicit mode is not
* set for this portal object
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/CoordinationAction.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/CoordinationAction.java 2008-08-22
16:26:52 UTC (rev 11730)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/CoordinationAction.java 2008-08-23
15:47:32 UTC (rev 11731)
@@ -51,6 +51,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -60,10 +61,10 @@
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
-import java.util.Iterator;
/**
* @author <a href="mailto:whales@redhat.com">Wesley Hales</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision: 777 $
*/
public class CoordinationAction
@@ -74,14 +75,6 @@
private List<String> selectedWindows;
- private Map<String, EventWiringInfo> eventWirings;
- private Map<String, DisplayEventWiring> displayEventWirings;
-
- private Map<QNameSelectItem, SortedSet<WindowSelectItem>>
eventNameToWindowSources;
- private Map<QNameSelectItem, SortedSet<WindowSelectItem>>
eventNameToWindowDestinations;
-
- private List<? extends SelectItem> selectedSourceEvents;
-
private Map<String, String> aliasBindings;
private Map<String, Map<String, String>> windowBindings;
@@ -98,6 +91,18 @@
private String windowBindingName;
+ private Map<String, EventWiringInfo> eventWirings;
+ private Map<String, DisplayEventWiring> displayEventWirings;
+
+ private Map<QNameSelectItem, SortedSet<WindowSelectItem>>
eventNameToWindowSources;
+ private Map<QNameSelectItem, SortedSet<WindowSelectItem>>
eventNameToWindowDestinations;
+
+ private List<String> selectedSourceEvents;
+ private List<String> selectedSourceWindows;
+ private List<String> selectedDestinationEvents;
+ private List<String> selectedDestinationWindows;
+ private EventWiringInfoCreator currentWiring;
+
public PortalObjectId getSelectedObjectId()
{
//since this backing bean is in session, always check for new object request
@@ -239,9 +244,8 @@
loadWindowBindings();
//aliasbindings prep for ui
- for (Object o : pomb.getCoordinationService().getAliasBindings(page))
+ for (AliasBindingInfo abInfo :
pomb.getCoordinationService().getAliasBindings(page))
{
- AliasBindingInfo abInfo = (AliasBindingInfo)o;
for (QName name : abInfo.getNames())
{
getAliasBindings().put(name.getNamespaceURI(),
name.getNamespaceURI());
@@ -254,7 +258,6 @@
for (PortalObject po : page.getChildren(PortalObject.WINDOW_MASK))
{
Window window = (Window)po;
- String temp = window.getId() + "";
windows.put(window.getName(),
window.getId().toString(PortalObjectPath.LEGACY_BASE64_FORMAT));
if (ContentType.PORTLET.equals(window.getContentType()))
{
@@ -264,9 +267,8 @@
// retrieve metadata on public render parameters
NavigationInfo navInfo = info.getNavigation();
- for (Object o : navInfo.getPublicParameters())
+ for (ParameterInfo pInfo : navInfo.getPublicParameters())
{
- ParameterInfo pInfo = (ParameterInfo)o;
availableRenderParameters.put(pInfo.getName().toString(),
pInfo.getName().toString());
}
@@ -297,11 +299,12 @@
}
for (QName qName : windowEvents.keySet())
{
- SortedSet<WindowSelectItem> windows = existing.get(qName);
+ QNameSelectItem item = new QNameSelectItem(qName);
+ SortedSet<WindowSelectItem> windows = existing.get(item);
if (windows == null)
{
windows = new TreeSet<WindowSelectItem>();
- existing.put(new QNameSelectItem(qName), windows);
+ existing.put(item, windows);
}
windows.add(new WindowSelectItem(window));
}
@@ -404,12 +407,27 @@
}
}
+ public void selectSourceWindows(ValueChangeEvent event)
+ {
+ System.out.println("selectWindows");
+ System.out.println("old value = " + event.getOldValue());
+ System.out.println("new value = " + event.getNewValue());
+ }
- public Map<String, EventWiringInfo> getEventWirings()
+ public void selectDestinationEvents(ValueChangeEvent event)
{
- return eventWirings;
+ System.out.println("selectDestinationEvents");
+ System.out.println("old value = " + event.getOldValue());
+ System.out.println("new value = " + event.getNewValue());
}
+ public void selectDestinationWindows(ValueChangeEvent event)
+ {
+ System.out.println("selectDestinationWindows");
+ System.out.println("old value = " + event.getOldValue());
+ System.out.println("new value = " + event.getNewValue());
+ }
+
public Collection<DisplayEventWiring> getDisplayEventWirings()
{
if (displayEventWirings == null)
@@ -425,44 +443,185 @@
public List<QNameSelectItem> getSourceEvents()
{
- if (eventNameToWindowSources == null)
+ // create new wiring
+ currentWiring = new EventWiringInfoCreator();
+
+ // return list of produced events
+ return getPossibleEvents(eventNameToWindowSources);
+ }
+
+ public List<QNameSelectItem> getDestinationEvents()
+ {
+ // at this point, we have the sources selected, populate new wiring
+ Map<Window, QName> sources = getMappingForWiring(selectedSourceWindows,
selectedSourceEvents);
+ currentWiring.setSources(sources);
+
+ return getPossibleEvents(eventNameToWindowDestinations);
+ }
+
+ private List<QNameSelectItem> getPossibleEvents(Map<QNameSelectItem,
SortedSet<WindowSelectItem>> eventNameToWindows)
+ {
+ if (eventNameToWindows == null)
{
return Collections.emptyList();
}
+
List<QNameSelectItem> result = new LinkedList<QNameSelectItem>();
- result.addAll(eventNameToWindowSources.keySet());
+ result.addAll(eventNameToWindows.keySet());
Collections.sort(result);
return result;
}
+ /**
+ * Format selected information into something that can be used to construct a new
event wiring.
+ *
+ * @param selectedWindows
+ * @param selectedEvents
+ * @return
+ */
+ private Map<Window, QName> getMappingForWiring(List<String>
selectedWindows, List<String> selectedEvents)
+ {
+ if (selectedWindows != null)
+ {
+ if (selectedObject == null)
+ {
+ throw new IllegalStateException("A page should have been
selected!");
+ }
+
+ Map<Window, QName> windowQNameMap = new HashMap<Window,
QName>(selectedWindows.size());
+ for (String windowName : selectedWindows)
+ {
+ Window window = (Window)selectedObject.getChild(windowName);
+ windowQNameMap.put(window, QName.valueOf(selectedEvents.get(0)));
+ }
+
+ return windowQNameMap;
+ }
+
+ return Collections.emptyMap();
+ }
+
public List<WindowSelectItem> getSourceWindows()
{
- if (eventNameToWindowSources == null)
+ return getPossibleWindows(eventNameToWindowSources, selectedSourceEvents);
+ }
+
+ public List<WindowSelectItem> getDestinationWindows()
+ {
+ return getPossibleWindows(eventNameToWindowDestinations,
selectedDestinationEvents);
+ }
+
+ private List<WindowSelectItem> getPossibleWindows(Map<QNameSelectItem,
SortedSet<WindowSelectItem>> eventNameToWindows, List<String>
selectedEventNames)
+ {
+ if (eventNameToWindows == null)
{
return Collections.emptyList();
}
- List<WindowSelectItem> result = new LinkedList<WindowSelectItem>();
- for (Object o : eventNameToWindowSources.entrySet())
+
+ if (selectedEventNames != null)
{
- //todo - implement
+ List<WindowSelectItem> result = new LinkedList<WindowSelectItem>();
+ for (String qNameAsString : selectedEventNames)
+ {
+ result.addAll(eventNameToWindows.get(new
QNameSelectItem(QName.valueOf(qNameAsString))));
+ }
+
+ Collections.sort(result);
+ return result;
}
- Collections.sort(result);
- return result;
+ return Collections.emptyList();
}
-
-
- public List<? extends SelectItem> getSelectedSourceEvents()
+ public List<String> getSelectedSourceEvents()
{
return selectedSourceEvents;
}
- public void setSelectedSourceEvents(List<? extends SelectItem>
selectedSourceEvents)
+ public void setSelectedSourceEvents(List<String> selectedSourceEvents)
{
this.selectedSourceEvents = selectedSourceEvents;
}
+ public List<String> getSelectedSourceWindows()
+ {
+ return selectedSourceWindows;
+ }
+
+ public void setSelectedSourceWindows(List<String> selectedSourceWindows)
+ {
+ this.selectedSourceWindows = selectedSourceWindows;
+ }
+
+ public List<String> getSelectedDestinationEvents()
+ {
+ return selectedDestinationEvents;
+ }
+
+ public void setSelectedDestinationEvents(List<String>
selectedDestinationEvents)
+ {
+ this.selectedDestinationEvents = selectedDestinationEvents;
+ }
+
+ public List<String> getSelectedDestinationWindows()
+ {
+ return selectedDestinationWindows;
+ }
+
+ public void setSelectedDestinationWindows(List<String>
selectedDestinationWindows)
+ {
+ this.selectedDestinationWindows = selectedDestinationWindows;
+ }
+
+ public String getWiringName()
+ {
+ if (currentWiring == null)
+ {
+ return null;
+ }
+
+ return currentWiring.getName();
+ }
+
+ public void setWiringName(String eventWiringName)
+ {
+ if (currentWiring != null)
+ {
+ currentWiring.setName(eventWiringName);
+
+ // we also now have the information to build the destinations
+ Map<Window, QName> destinations =
getMappingForWiring(selectedDestinationWindows, selectedDestinationEvents);
+ currentWiring.setDestinations(destinations);
+ }
+ }
+
+ public String createWiring()
+ {
+ if (currentWiring != null)
+ {
+ try
+ {
+ pomb.getCoordinationService().setEventWiring(currentWiring.getSources(),
currentWiring.getDestinations(), currentWiring.getName());
+ }
+ catch (IllegalCoordinationException e)
+ {
+ e.printStackTrace(); //To change body of catch statement use File | Settings
| File Templates.
+ }
+ }
+ return null;
+ }
+
+ public String cancelWiring()
+ {
+ currentWiring = null;
+ selectedSourceEvents = null;
+ selectedSourceWindows = null;
+ selectedDestinationEvents = null;
+ selectedDestinationWindows = null;
+
+ return null;
+ }
+
public String deleteWiring()
{
String wiring = getFacesParam("wiring");
@@ -546,20 +705,31 @@
{
public WindowSelectItem(Window window)
{
- super(window, window.getName());
+ super(window.getName(), window.getName());
}
public int compareTo(Object o)
{
WindowSelectItem other = (WindowSelectItem)o;
- return getWindow().getName().compareTo(other.getWindow().getName());
+ return getLabel().compareTo(other.getLabel());
}
- public Window getWindow()
+ @Override
+ public int hashCode()
{
- return (Window)getValue();
+ return getLabel().hashCode();
}
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof WindowSelectItem)
+ {
+ return false;
+ }
+ WindowSelectItem item = (WindowSelectItem)obj;
+ return getLabel().equals(item.getLabel());
+ }
}
public static class QNameSelectItem extends SelectItem implements Comparable
@@ -598,6 +768,51 @@
}
}
+ private static class EventWiringInfoCreator implements EventWiringInfo
+ {
+ private String name;
+ private Map<Window, QName> sources;
+ private Map<Window, QName> destinations;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public Map<Window, QName> getSources()
+ {
+ return sources;
+ }
+
+ public void setSources(Map<Window, QName> sources)
+ {
+ this.sources = sources;
+ }
+
+ public Map<Window, QName> getDestinations()
+ {
+ return destinations;
+ }
+
+ public void setDestinations(Map<Window, QName> destinations)
+ {
+ this.destinations = destinations;
+ }
+ }
+
+ public static class QNameComparator implements Comparator<QName>
+ {
+ public int compare(QName o1, QName o2)
+ {
+ return o1.toString().compareTo(o2.toString());
+ }
+ }
+
// Parameter Binding
public boolean isParameterImplicitEnabled()
{
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/editCoordination.xhtml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/editCoordination.xhtml 2008-08-22
16:26:52 UTC (rev 11730)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/editCoordination.xhtml 2008-08-23
15:47:32 UTC (rev 11731)
@@ -10,8 +10,7 @@
<ui:define name="content">
<div class="tenpx-top-bottom">
- <h2
-
class="portlet-area-header">#{coordinationAction.selectedObject.name}
#{bundle.COORDINATION_PARAMETER_BINDINGS}</h2>
+ <h2
class="portlet-area-header">#{coordinationAction.selectedObject.name}
#{bundle.COORDINATION_PARAMETER_BINDINGS}</h2>
<!-- Create parameter binding -->
<h3 class="sectionTitle
tenpx-top-bottom">#{bundle.COORDINATION_CREATE_PARAMETER_BINDING}</h3>
@@ -114,18 +113,37 @@
<!-- Create new event wiring -->
<h3 class="sectionTitle
tenpx-top-bottom">#{bundle.COORDINATION_EVENT_CREATE}</h3>
<h:form>
- <h:selectManyListbox size="5"
value="#{coordinationAction.selectedSourceEvents}">
+ <h:selectManyListbox size="5"
value="#{coordinationAction.selectedSourceEvents}" immediate="true"
+
valueChangeListener="#{coordinationAction.selectSourceWindows}"
onchange="this.form.submit()">
<f:selectItems value="#{coordinationAction.sourceEvents}"/>
</h:selectManyListbox>
- <h:selectManyListbox size="5"
value="#{coordinationAction.selectedSourceEvents}">
+ <h:selectManyListbox size="5"
value="#{coordinationAction.selectedSourceWindows}"
+ rendered="#{!empty
coordinationAction.selectedSourceEvents}" immediate="true"
+
valueChangeListener="#{coordinationAction.selectDestinationEvents}"
onchange="this.form.submit()">
<f:selectItems value="#{coordinationAction.sourceWindows}"/>
</h:selectManyListbox>
+
+ <h:selectManyListbox size="5"
value="#{coordinationAction.selectedDestinationEvents}"
+ rendered="#{!empty
coordinationAction.selectedSourceWindows}" immediate="true"
+
valueChangeListener="#{coordinationAction.selectDestinationEvents}"
onchange="this.form.submit()">
+ <f:selectItems
value="#{coordinationAction.destinationEvents}"/>
+ </h:selectManyListbox>
+
+ <h:selectManyListbox size="5"
value="#{coordinationAction.selectedDestinationWindows}"
+ rendered="#{!empty
coordinationAction.selectedDestinationEvents}" immediate="true"
+
valueChangeListener="#{coordinationAction.selectDestinationWindows}"
onchange="this.form.submit()">
+ <f:selectItems
value="#{coordinationAction.destinationWindows}"/>
+ </h:selectManyListbox>
+
+ <h:panelGroup rendered="#{!empty
coordinationAction.selectedDestinationWindows}">
+ <h:inputText value="#{coordinationAction.wiringName}"/>
+ <h:commandButton value="#{bundle.COORDINATION_EVENT_CREATE_CREATE}"
action="#{coordinationAction.createWiring}"
+ styleClass="portlet-form-button"/>
+ <h:commandButton value="#{bundle.COMMON_CANCEL}"
action="#{coordinationAction.cancelWiring}"
+ styleClass="portlet-form-button"/>
+ </h:panelGroup>
</h:form>
-
- <ui:repeat var="eventWirings"
value="#{coordinationAction.displayEventWirings}">
- #{eventWirings}
- </ui:repeat>
<hr/>
<!-- Manage existing wirings -->