Issue #239 Added ability to remove remote graphics functionality from

editor.  Execute on session shutdown

Former-commit-id: 7c09df3cc0 [formerly cc6386f9f6] [formerly bbb8d0e596] [formerly c64d84d1b5 [formerly bbb8d0e596 [formerly 8a2d8b0ce27364eae1bc7e696a5d1074e03169dc]]]
Former-commit-id: c64d84d1b5
Former-commit-id: 4661f0efcc23248722873b2218c7e248eb554c0e [formerly d4bff8bbc5]
Former-commit-id: f7616d9c15
This commit is contained in:
Max Schenkelberg 2012-04-18 10:49:15 -05:00
parent 347cf62f56
commit add307f5bd
2 changed files with 86 additions and 32 deletions

View file

@ -32,6 +32,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.event.ParticipantEventTyp
import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole; import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
import com.raytheon.uf.viz.collaboration.comm.provider.TransferRoleCommand; import com.raytheon.uf.viz.collaboration.comm.provider.TransferRoleCommand;
import com.raytheon.uf.viz.collaboration.comm.provider.event.VenueParticipantEvent; import com.raytheon.uf.viz.collaboration.comm.provider.event.VenueParticipantEvent;
import com.raytheon.uf.viz.collaboration.data.SessionContainer;
import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr; import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr;
import com.raytheon.uf.viz.collaboration.ui.editor.EditorSetup; import com.raytheon.uf.viz.collaboration.ui.editor.EditorSetup;
import com.raytheon.uf.viz.collaboration.ui.editor.SharedEditorData; import com.raytheon.uf.viz.collaboration.ui.editor.SharedEditorData;
@ -77,6 +78,8 @@ public class DataProviderEventController extends AbstractRoleEventController {
private static final transient IUFStatusHandler statusHandler = UFStatus private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(DataProviderEventController.class); .getHandler(DataProviderEventController.class);
private ResourceWrapperListener wrappingListener;
public DataProviderEventController(ISharedDisplaySession session) { public DataProviderEventController(ISharedDisplaySession session) {
super(session); super(session);
} }
@ -212,6 +215,7 @@ public class DataProviderEventController extends AbstractRoleEventController {
public void startup() { public void startup() {
super.startup(); super.startup();
super.activateTelestrator(); super.activateTelestrator();
wrappingListener = new ResourceWrapperListener();
for (IDisplayPaneContainer container : SharedDisplaySessionMgr for (IDisplayPaneContainer container : SharedDisplaySessionMgr
.getSessionContainer(session.getSessionId()).getSharedEditors()) { .getSessionContainer(session.getSessionId()).getSharedEditors()) {
// Replace pane resources that will be shared with // Replace pane resources that will be shared with
@ -221,25 +225,8 @@ public class DataProviderEventController extends AbstractRoleEventController {
for (ResourcePair rp : pane.getDescriptor().getResourceList()) { for (ResourcePair rp : pane.getDescriptor().getResourceList()) {
wrapResourcePair(rp); wrapResourcePair(rp);
} }
list.addPreAddListener(new AddListener() { list.addPreAddListener(wrappingListener);
@Override list.addPostRemoveListener(wrappingListener);
public void notifyAdd(ResourcePair rp) throws VizException {
if (wrapResourcePair(rp)) {
// Send event to venue to load
sendSharedResource(rp, false);
}
}
});
list.addPostRemoveListener(new RemoveListener() {
@Override
public void notifyRemove(ResourcePair rp)
throws VizException {
if (rp.getResource() instanceof CollaborationWrapperResource) {
// Send event to venue to unload
sendSharedResource(rp, true);
}
}
});
} }
// Inject remote graphics functionality in container // Inject remote graphics functionality in container
@ -323,6 +310,17 @@ public class DataProviderEventController extends AbstractRoleEventController {
return false; return false;
} }
private void unwrapResourcePair(ResourcePair rp) {
if (rp.getResource() instanceof CollaborationWrapperResource) {
rp.setResource(((CollaborationWrapperResource) rp.getResource())
.getWrappedResource());
}
if (rp.getResourceData() instanceof CollaborationWrapperResourceData) {
rp.setResourceData(((CollaborationWrapperResourceData) rp
.getResourceData()).getWrappedResourceData());
}
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -334,7 +332,41 @@ public class DataProviderEventController extends AbstractRoleEventController {
public void shutdown() { public void shutdown() {
super.shutdown(); super.shutdown();
super.deactivateTelestrator(); super.deactivateTelestrator();
SessionContainer sc = SharedDisplaySessionMgr
.getSessionContainer(session.getSessionId());
if (sc != null) {
for (IDisplayPaneContainer container : sc.getSharedEditors()) {
for (IDisplayPane pane : container.getDisplayPanes()) {
ResourceList list = pane.getDescriptor().getResourceList();
for (ResourcePair rp : list) {
unwrapResourcePair(rp);
}
list.removePreAddListener(wrappingListener);
list.removePostRemoveListener(wrappingListener);
}
DispatchingGraphicsFactory
.extractRemoteFunctionality(container);
}
}
// TODO should remove the SharedEditorIndiciatorRsc // TODO should remove the SharedEditorIndiciatorRsc
} }
private class ResourceWrapperListener implements AddListener,
RemoveListener {
@Override
public void notifyAdd(ResourcePair rp) throws VizException {
if (wrapResourcePair(rp)) {
// Send event to venue to load
sendSharedResource(rp, false);
}
}
@Override
public void notifyRemove(ResourcePair rp) throws VizException {
if (rp.getResource() instanceof CollaborationWrapperResource) {
// Send event to venue to unload
sendSharedResource(rp, true);
}
}
}
} }

View file

@ -162,20 +162,42 @@ public class DispatchingGraphicsFactory extends AbstractGraphicsFactoryAdapter {
// Wrap the graphics adapter in dispatching one // Wrap the graphics adapter in dispatching one
display.setGraphicsAdapter(new DispatchingGraphicsFactory(display display.setGraphicsAdapter(new DispatchingGraphicsFactory(display
.getGraphicsAdapter(), dispatcher)); .getGraphicsAdapter(), dispatcher));
refreshPane(pane);
// Force resetting of the pane's display
pane.setRenderableDisplay(null);
pane.setRenderableDisplay(display);
display.setup(pane.getTarget());
for (ResourcePair rp : pane.getDescriptor().getResourceList()) {
if (rp.getResource() != null) {
rp.getResource().recycle();
}
}
pane.refresh();
} }
} }
/**
* Removes remote graphics functionality from a display pane container
*
* @param container
*/
public static void extractRemoteFunctionality(
IDisplayPaneContainer container) {
for (IDisplayPane pane : container.getDisplayPanes()) {
IRenderableDisplay display = pane.getRenderableDisplay();
AbstractGraphicsFactoryAdapter adapter = display
.getGraphicsAdapter();
if (adapter instanceof DispatchingGraphicsFactory) {
AbstractGraphicsFactoryAdapter wrapped = ((DispatchingGraphicsFactory) adapter).delegate;
display.setGraphicsAdapter(wrapped);
refreshPane(pane);
}
}
}
private static void refreshPane(IDisplayPane pane) {
IRenderableDisplay display = pane.getRenderableDisplay();
// Force resetting of the pane's display
pane.setRenderableDisplay(null);
pane.setRenderableDisplay(display);
display.setup(pane.getTarget());
for (ResourcePair rp : display.getDescriptor().getResourceList()) {
if (rp.getResource() != null) {
rp.getResource().recycle();
}
}
pane.refresh();
}
} }