Author: chris.laprun(a)jboss.com
Date: 2008-08-12 13:38:02 -0400 (Tue, 12 Aug 2008)
New Revision: 11691
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
Log:
- Started event wiring creation form...
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-12
08:55:39 UTC (rev 11690)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/CoordinationAction.java 2008-08-12
17:38:02 UTC (rev 11691)
@@ -36,7 +36,8 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.info.EventInfo;
+import org.jboss.portal.portlet.info.EventingInfo;
import org.jboss.portal.portlet.info.NavigationInfo;
import org.jboss.portal.portlet.info.ParameterInfo;
import org.jboss.portal.portlet.info.PortletInfo;
@@ -51,9 +52,12 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
/**
* @author <a href="mailto:whales@redhat.com">Wesley Hales</a>
@@ -68,9 +72,10 @@
private Map<String, EventWiringInfo> eventWirings;
private Map<String, DisplayEventWiring> displayEventWirings;
- private Map<String, String> eventSources;
+ private Map<QNameSelectItem, SortedSet<WindowSelectItem>>
eventNameToWindowSources;
+ private Map<QNameSelectItem, SortedSet<WindowSelectItem>>
eventNameToWindowDestinations;
- private Map<String, String> eventDestinations;
+ private List<? extends SelectItem> selectedSourceEvents;
private Map<String, String> aliasBindings;
@@ -117,34 +122,6 @@
this.pomb = pomb;
}
- public Map<String, String> getEventSources()
- {
- if (eventSources == null)
- {
- eventSources = new HashMap<String, String>();
- }
- return eventSources;
- }
-
- public void setEventSources(Map<String, String> eventSources)
- {
- this.eventSources = eventSources;
- }
-
- public Map<String, String> getEventDestinations()
- {
- if (eventDestinations == null)
- {
- eventDestinations = new HashMap<String, String>();
- }
- return eventDestinations;
- }
-
- public void setEventDestinations(Map<String, String> eventDestinations)
- {
- this.eventDestinations = eventDestinations;
- }
-
public Map<String, String> getAliasBindings()
{
if (aliasBindings == null)
@@ -214,22 +191,25 @@
try
{
-
//eventwirings prep for ui
Collection<EventWiringInfo> wiringInfos =
pomb.getCoordinationService().getEventWirings(page);
- for (EventWiringInfo ewInfo : wiringInfos)
+ if (!wiringInfos.isEmpty())
{
if (eventWirings == null)
{
eventWirings = new HashMap<String,
EventWiringInfo>(wiringInfos.size());
}
- eventWirings.put(ewInfo.getName(), ewInfo);
if (displayEventWirings == null)
{
displayEventWirings = new HashMap<String, DisplayEventWiring>();
}
- displayEventWirings.put(ewInfo.getName(), new
DisplayEventWiring(ewInfo));
+
+ for (EventWiringInfo ewInfo : wiringInfos)
+ {
+ eventWirings.put(ewInfo.getName(), ewInfo);
+ displayEventWirings.put(ewInfo.getName(), new
DisplayEventWiring(ewInfo));
+ }
}
//aliasbindings prep for ui
@@ -251,12 +231,12 @@
Map.Entry entry = (Map.Entry)o1;
Window paramName = (Window)entry.getKey();
QName paramValue = (QName)entry.getValue();
- getWindowBindings().add(new
SelectItem(paramName.getName(),paramValue.toString()));
+ getWindowBindings().add(new SelectItem(paramName.getName(),
paramValue.toString()));
//System.out.println("-------paramName.getName()-" +
paramName.getName());
}
}
- // process only windows...
+ // Extract metadata only on window children
for (PortalObject po : page.getChildren(PortalObject.WINDOW_MASK))
{
Window window = (Window)po;
@@ -265,11 +245,10 @@
{
PortletContent pc = (PortletContent)window.getContent();
Instance instance =
pomb.getInstanceContainer().getDefinition(pc.getInstanceRef());
- Portlet portlet = instance.getPortlet();
- PortletInfo info = portlet.getInfo();
+ PortletInfo info = instance.getPortlet().getInfo();
+
+ // retrieve metadata on public render parameters
NavigationInfo navInfo = info.getNavigation();
-
-
for (Object o : navInfo.getPublicParameters())
{
ParameterInfo pInfo = (ParameterInfo)o;
@@ -280,6 +259,11 @@
// System.out.println("key---------" +
pInfo.getAliases());
}
+
+ // retrieve metadata on events
+ EventingInfo eventingInfo = info.getEventing();
+ eventNameToWindowSources = addEventInfoFor(window,
eventingInfo.getProducedEvents(), eventNameToWindowSources);
+ eventNameToWindowDestinations = addEventInfoFor(window,
eventingInfo.getConsumedEvents(), eventNameToWindowDestinations);
}
}
@@ -293,6 +277,29 @@
return "editCoordination";
}
+ private Map<QNameSelectItem, SortedSet<WindowSelectItem>>
addEventInfoFor(Window window, Map<QName, ? extends EventInfo> windowEvents,
Map<QNameSelectItem, SortedSet<WindowSelectItem>> existing)
+ {
+ if (windowEvents != null && !windowEvents.isEmpty())
+ {
+ if (existing == null)
+ {
+ existing = new HashMap<QNameSelectItem,
SortedSet<WindowSelectItem>>();
+ }
+ for (QName qName : windowEvents.keySet())
+ {
+ SortedSet<WindowSelectItem> windows = existing.get(qName);
+ if (windows == null)
+ {
+ windows = new TreeSet<WindowSelectItem>();
+ existing.put(new QNameSelectItem(qName), windows);
+ }
+ windows.add(new WindowSelectItem(window));
+ }
+ }
+
+ return existing;
+ }
+
// JSF helper methods
/**
@@ -336,12 +343,36 @@
return Collections.emptyList();
}
- ArrayList<DisplayEventWiring> result = new
ArrayList<DisplayEventWiring>(displayEventWirings.values());
+ List<DisplayEventWiring> result = new
LinkedList<DisplayEventWiring>(displayEventWirings.values());
Collections.sort(result);
return result;
}
+ public List<QNameSelectItem> getSourceEvents()
+ {
+ if (eventNameToWindowSources == null)
+ {
+ return Collections.emptyList();
+ }
+
+ List<QNameSelectItem> result = new LinkedList<QNameSelectItem>();
+ result.addAll(eventNameToWindowSources.keySet());
+ Collections.sort(result);
+
+ return result;
+ }
+
+ public List<? extends SelectItem> getSelectedSourceEvents()
+ {
+ return selectedSourceEvents;
+ }
+
+ public void setSelectedSourceEvents(List<? extends SelectItem>
selectedSourceEvents)
+ {
+ this.selectedSourceEvents = selectedSourceEvents;
+ }
+
public String deleteWiring()
{
String wiring = getFacesParam("wiring");
@@ -368,12 +399,15 @@
throw new NotYetImplemented("renameWiring not yet implemented!");
}
- public void useWSDLListener(ValueChangeEvent event)
+ /**
+ * Listener for explicit event checkbox
+ * @param event
+ */
+ public void explicitEventsListener(ValueChangeEvent event)
{
}
-
public static class DisplayEventWiring implements Comparable
{
private String name;
@@ -426,10 +460,68 @@
return name.compareTo(other.getName());
}
}
-
- public void createWindowBinding(ActionEvent event){
+
+ public static class WindowSelectItem extends SelectItem implements Comparable
+ {
+ public WindowSelectItem(Window window)
+ {
+ super(window, window.getName());
+ }
+
+ public int compareTo(Object o)
+ {
+ WindowSelectItem other = (WindowSelectItem)o;
+ return getWindow().getName().compareTo(other.getWindow().getName());
+ }
+
+ public Window getWindow()
+ {
+ return (Window) getValue();
+ }
+
+ }
+
+ public static class QNameSelectItem extends SelectItem implements Comparable
+ {
+ public QNameSelectItem(QName qName)
+ {
+ super(qName, qName.toString());
+ }
+
+ public QName getQName()
+ {
+ return (QName) getValue();
+ }
+
+ public int compareTo(Object o)
+ {
+ QNameSelectItem other = (QNameSelectItem) o;
+ return getQName().toString().compareTo(other.getQName().toString());
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return getQName().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if(!(obj instanceof QNameSelectItem))
+ {
+ return false;
+ }
+ QNameSelectItem item = (QNameSelectItem) obj;
+ return getQName().equals(item.getQName());
+ }
+ }
+
+ public void createWindowBinding(ActionEvent event)
+ {
//String id = (String) event.getComponent().getAttributes().get("");
- for (SelectItem binding : getSelectedWindowBindings()){
+ for (SelectItem binding : getSelectedWindowBindings())
+ {
System.out.println("-----------" + binding);
}
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-12
08:55:39 UTC (rev 11690)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/editCoordination.xhtml 2008-08-12
17:38:02 UTC (rev 11691)
@@ -111,14 +111,14 @@
<h:outputText
value="#{bundle.COORDINATION_EVENT_EXISTING_ACTIONS}"/>
</f:facet>
+ <h:commandLink
action="#{coordinationAction.renameWiring}">
+ <h:outputText styleClass="actionRename"
value="#{bundle.RENAME}"/>
+ <f:param name="wiring"
value="#{wiring.name}"/>
+ </h:commandLink> |
<h:commandLink
action="#{coordinationAction.deleteWiring}">
<h:outputText styleClass="actionDelete"
value="#{bundle.COMMON_DELETE}"/>
<f:param name="wiring"
value="#{wiring.name}"/>
</h:commandLink>
- <h:commandLink
action="#{coordinationAction.renameWiring}">
- <h:outputText styleClass="actionRename"
value="#{bundle.RENAME}"/>
- <f:param name="wiring"
value="#{wiring.name}"/>
- </h:commandLink>
</h:column>
</h:dataTable>
</h:form>
@@ -126,7 +126,9 @@
<!-- Create new event wiring -->
<h3 class="sectionTitle
tenpx-top-bottom">#{bundle.COORDINATION_EVENT_CREATE}</h3>
<h:form>
-
+ <h:selectManyListbox size="5"
value="#{coordinationAction.selectedSourceEvents}">
+ <f:selectItems value="#{coordinationAction.sourceEvents}"/>
+ </h:selectManyListbox>
</h:form>
<ui:remove>