Issue #716 fix lots of minor issues, fix merge problem

Change-Id: I5a43ad089766b5f2a9a3ea6901d8f6761983b575

Former-commit-id: ae131c0d05148e58ba445e5f144aa21c8c5c12c3
This commit is contained in:
Nate Jensen 2012-06-13 09:39:19 -05:00
parent 5f66b0995a
commit 619d3062c2
24 changed files with 3329 additions and 3354 deletions

View file

@ -19,8 +19,6 @@
**/
package com.raytheon.uf.viz.collaboration.comm.identity.event;
import com.google.common.eventbus.EventBus;
/**
* TODO Add Description
*
@ -31,6 +29,7 @@ import com.google.common.eventbus.EventBus;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 21, 2012 jkorman Initial creation
* Jun 12, 2012 njensen Improved
*
* </pre>
*
@ -40,24 +39,9 @@ import com.google.common.eventbus.EventBus;
public interface IEventPublisher {
/**
*
* @param handler
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#registerEventHandler(java.lang.Object)
*/
void registerEventHandler(Object handler);
public void registerEventHandler(Object handler);
/**
*
* @param handler
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#unRegisterEventHandler(java.lang.Object)
*/
void unRegisterEventHandler(Object handler);
public void unregisterEventHandler(Object handler);
/**
* Get the underlying event publisher. Any class implementing this interface
* must return a not null event publisher.
* @return The event publisher.
*/
EventBus getEventPublisher();
public void postEvent(Object event);
}

View file

@ -246,10 +246,10 @@ public abstract class BaseSession implements ISession {
/**
*
* @param handler
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher#unRegisterEventHandler(java.lang.Object)
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher#unregisterEventHandler(java.lang.Object)
*/
@Override
public void unRegisterEventHandler(Object handler) {
public void unregisterEventHandler(Object handler) {
eventSubscribers.remove(handler);
eventBus.unregister(handler);
}
@ -258,8 +258,10 @@ public abstract class BaseSession implements ISession {
*
*/
@Override
public EventBus getEventPublisher() {
return eventBus;
public void postEvent(Object event) {
if (event != null) {
eventBus.post(event);
}
}
@Override

View file

@ -210,7 +210,7 @@ public class CollaborationConnection implements IEventPublisher {
}
contactsMgr = new ContactsManager(this);
this.getEventPublisher().register(contactsMgr);
this.registerEventHandler(contactsMgr);
}
/**
@ -329,10 +329,12 @@ public class CollaborationConnection implements IEventPublisher {
/**
*
*/
public void closeManager() {
public void close() {
if (container != null) {
// Close any created sessions.
for (ISession session : sessions.values()) {
Collection<ISession> toRemove = sessions.values();
sessions.clear();
for (ISession session : toRemove) {
if ((chatInstance != null) && chatInstance.equals(session)) {
chatInstance.close();
chatInstance = null;
@ -630,19 +632,18 @@ public class CollaborationConnection implements IEventPublisher {
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher#unRegisterEventHandler(java.lang.Object)
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher#unregisterEventHandler(java.lang.Object)
*/
@Override
public void unRegisterEventHandler(Object handler) {
public void unregisterEventHandler(Object handler) {
eventBus.unregister(handler);
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher#getEventPublisher()
*/
@Override
public EventBus getEventPublisher() {
return eventBus;
public void postEvent(Object event) {
if (event != null) {
eventBus.post(event);
}
}
public ContactsManager getContactsManager() {

View file

@ -125,13 +125,4 @@ public class PeerToPeerChat extends BaseSession implements IPeerToPeer {
this.sendPeerToPeer(msg);
}
/**
*
* @return
*/
@Override
public EventBus getEventPublisher() {
return getManagerEventPublisher();
}
}

View file

@ -33,14 +33,14 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.collaboration.comm.Activator;
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
import com.raytheon.uf.viz.collaboration.comm.identity.ISession;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IHttpdCollaborationConfigurationEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.ITextMessageEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage;
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
import com.raytheon.uf.viz.collaboration.comm.provider.event.ChatMessageEvent;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IHttpdCollaborationConfigurationEvent;
import com.raytheon.uf.viz.collaboration.comm.provider.event.HttpdCollaborationConfigurationEvent;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
* Listens for peer to peer messages and routes them appropriately.
@ -116,18 +116,18 @@ public class PeerToPeerCommHelper implements IIMMessageListener {
String sessionId = (String) message.getProperties().get(
Tools.PROP_SESSION_ID);
if (sessionId == null) {
manager.getEventPublisher().post(object);
manager.postEvent(object);
} else {
// Ok, we have a session id.
ISession session = manager.getSession(sessionId);
if (session != null) {
session.getEventPublisher().post(object);
session.postEvent(object);
} else {
statusHandler.handle(Priority.PROBLEM,
"ERROR: Unknown sessionid [" + sessionId + "]");
}
}
manager.getEventPublisher().post(object);
manager.postEvent(object);
}
}
@ -162,12 +162,12 @@ public class PeerToPeerCommHelper implements IIMMessageListener {
// Now find out who gets the message. If the message doesn't contain
// a session id then assume its a straight text chat message.
if (sessionId == null) {
manager.getEventPublisher().post(chatEvent);
manager.postEvent(chatEvent);
} else {
// Ok, we have a session id.
ISession session = manager.getSession(sessionId);
if (session != null) {
session.getEventPublisher().post(chatEvent);
session.postEvent(chatEvent);
}
}
}
@ -205,13 +205,14 @@ public class PeerToPeerCommHelper implements IIMMessageListener {
if (urlPattern.matcher(httpdCollaborationURL).matches() == false) {
statusHandler.handle(UFStatus.Priority.PROBLEM,
"Received an invalid http url from openfire - "
+ httpdCollaborationURL + ". Shared Display Sessions have been disabled.");
+ httpdCollaborationURL
+ ". Shared Display Sessions have been disabled.");
return;
}
// configuration is valid; publish it.
IHttpdCollaborationConfigurationEvent configurationEvent = new HttpdCollaborationConfigurationEvent(
httpdCollaborationURL);
manager.getEventPublisher().post(configurationEvent);
manager.postEvent(configurationEvent);
}
}

View file

@ -378,12 +378,12 @@ public class VenueSession extends BaseSession implements IVenueSession {
if (IPresence.Type.AVAILABLE.equals(presence.getType())) {
event = new VenueParticipantEvent(vp, presence,
ParticipantEventType.ARRIVED);
getEventPublisher().post(event);
VenueSession.this.postEvent(event);
} else if (IPresence.Type.UNAVAILABLE.equals(presence
.getType())) {
event = new VenueParticipantEvent(vp, presence,
ParticipantEventType.DEPARTED);
getEventPublisher().post(event);
VenueSession.this.postEvent(event);
}
}
};
@ -459,7 +459,7 @@ public class VenueSession extends BaseSession implements IVenueSession {
try {
o = Tools.unMarshallData(body);
if (o != null) {
getEventPublisher().post(o);
this.postEvent(o);
}
} catch (CollaborationException ce) {
statusHandler.error(
@ -474,7 +474,7 @@ public class VenueSession extends BaseSession implements IVenueSession {
message.getBody());
msg.setFrom(message.getFrom());
getEventPublisher().post(msg);
this.postEvent(msg);
} else {
// attempt to handle outside clients as text only since the
// SEND_TXT won't be appended to the first portion of the

View file

@ -58,7 +58,6 @@ import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.window.ToolTip;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.TreeEditor;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
@ -111,9 +110,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.display.editor.CollaborationEditor;
import com.raytheon.uf.viz.collaboration.ui.data.AlertWordWrapper;
import com.raytheon.uf.viz.collaboration.ui.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.ui.data.CollaborationGroupContainer;
import com.raytheon.uf.viz.collaboration.ui.data.SessionContainer;
import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer;
import com.raytheon.uf.viz.collaboration.ui.data.SharedDisplaySessionMgr;
import com.raytheon.uf.viz.collaboration.ui.login.ChangeStatusDialog;
@ -126,7 +123,6 @@ import com.raytheon.uf.viz.collaboration.ui.session.SessionMsgArchive;
import com.raytheon.uf.viz.collaboration.ui.session.SessionView;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.icon.IconUtil;
import com.raytheon.viz.ui.VizWorkbenchManager;
import com.raytheon.viz.ui.views.CaveFloatingView;
/**
@ -157,10 +153,6 @@ public class CollaborationGroupView extends CaveFloatingView implements
private TreeViewer usersTreeViewer;
private StyledText messages;
private StyledText composeBox;
private CollaborationGroupContainer topLevel;
private Action createSessionAction;
@ -271,7 +263,7 @@ public class CollaborationGroupView extends CaveFloatingView implements
CollaborationConnection connection = CollaborationConnection
.getConnection();
if (connection != null) {
connection.unRegisterEventHandler(this);
connection.unregisterEventHandler(this);
}
getViewSite().getWorkbenchWindow().getPartService()
.removePartListener(this);
@ -540,8 +532,7 @@ public class CollaborationGroupView extends CaveFloatingView implements
FontData postData = dialog.open();
if (postData != null) {
PreferenceConverter.setValue(store, "font", postData);
CollaborationConnection.getConnection().getEventPublisher()
.post(postData);
CollaborationConnection.getConnection().postEvent(postData);
}
};
};
@ -694,8 +685,6 @@ public class CollaborationGroupView extends CaveFloatingView implements
* Get entries for all part of the Tree Viewer and enable actions.
*/
protected void populateTree() {
CollaborationDataManager manager = CollaborationDataManager
.getInstance();
CollaborationConnection connection = CollaborationConnection
.getConnection();
topLevel.clear();
@ -748,9 +737,6 @@ public class CollaborationGroupView extends CaveFloatingView implements
*/
private void populateActiveSessions() {
activeSessionGroup.clear();
try {
CollaborationDataManager manager = CollaborationDataManager
.getInstance();
for (IViewReference ref : getViewSite().getWorkbenchWindow()
.getActivePage().getViewReferences()) {
IViewPart viewPart = ref.getView(false);
@ -760,12 +746,6 @@ public class CollaborationGroupView extends CaveFloatingView implements
.getConnection().getSession(sessionId));
}
}
} catch (NullPointerException e) {
// Ignore happens when creating view when starting CAVE.
// TODO bad to ignore, need to take care of
statusHandler.handle(Priority.ERROR,
"Unable to populate active sessions", e);
}
}
/**
@ -918,8 +898,8 @@ public class CollaborationGroupView extends CaveFloatingView implements
.getItem().getText());
}
CollaborationUtils.addAlias();
CollaborationConnection.getConnection().getEventPublisher()
.post(entry.getUser());
CollaborationConnection.getConnection().postEvent(
entry.getUser());
}
}
});
@ -965,8 +945,8 @@ public class CollaborationGroupView extends CaveFloatingView implements
treeEditor.getItem().getText());
}
CollaborationUtils.addAlias();
CollaborationConnection.getConnection().getEventPublisher()
.post(entry.getUser());
CollaborationConnection.getConnection().postEvent(
entry.getUser());
break;
case SWT.Verify:
String newText = modText.getText();
@ -1047,7 +1027,7 @@ public class CollaborationGroupView extends CaveFloatingView implements
RosterEntry rosterEntry = new RosterEntry(manager.getRoster(), id,
presence);
rosterEntry.setPresence(presence);
connection.getEventPublisher().post(rosterEntry);
connection.postEvent(rosterEntry);
} catch (CollaborationException e) {
statusHandler.handle(Priority.PROBLEM, "Error sending presence", e);
}
@ -1144,8 +1124,6 @@ public class CollaborationGroupView extends CaveFloatingView implements
} catch (PartInitException e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to open collaboration sesson", e);
} catch (Exception e) {
statusHandler.handle(Priority.ERROR, "Unexpected excepton", e);
}
}
@ -1167,7 +1145,8 @@ public class CollaborationGroupView extends CaveFloatingView implements
statusHandler.handle(Priority.PROBLEM,
"Unable to open text only chat session", e);
} catch (Exception e) {
statusHandler.handle(Priority.ERROR, "Unexpected exception", e);
statusHandler.handle(Priority.ERROR,
"Unable to open chat room view", e);
}
}
@ -1288,7 +1267,7 @@ public class CollaborationGroupView extends CaveFloatingView implements
CollaborationConnection connection = CollaborationConnection
.getConnection();
ConnectionSubscriber.unsubscribe(connection);
connection.closeManager();
connection.close();
}
}
@ -1361,9 +1340,6 @@ public class CollaborationGroupView extends CaveFloatingView implements
public void handleModifiedPresence(final IRosterEntry rosterEntry) {
// Only need to update the usersTreeViewer.
final UserId id = IDConverter.convertFrom(rosterEntry.getUser());
System.out.println("group view roster entry for:" + id.getName() + "@"
+ id.getHost() + " " + rosterEntry.getPresence().getMode()
+ "/" + rosterEntry.getPresence().getType());
((RosterEntry) CollaborationConnection.getConnection()
.getContactsManager().getUsersMap().get(id))
@ -1564,6 +1540,7 @@ public class CollaborationGroupView extends CaveFloatingView implements
ISession session = CollaborationConnection.getConnection()
.getSession(sessionId);
activeSessionGroup.addObject(session);
// register here because we unregister in part closed
session.registerEventHandler(sessionView);
usersTreeViewer.refresh(activeSessionGroup);
}
@ -1579,7 +1556,13 @@ public class CollaborationGroupView extends CaveFloatingView implements
public void partClosed(IWorkbenchPart part) {
if (part instanceof SessionView) {
SessionView sessionView = (SessionView) part;
String sessionId = sessionView.getViewSite().getSecondaryId();
ISession session = CollaborationConnection.getConnection()
.getSession(sessionId);
// unregister here because we registered in partOpened
session.unregisterEventHandler(sessionView);
for (Object node : activeSessionGroup.getObjects()) {
IVenueSession group = (IVenueSession) node;
@ -1593,23 +1576,6 @@ public class CollaborationGroupView extends CaveFloatingView implements
}
}
}
if (part instanceof CollaborationSessionView) {
String sessionId = ((CollaborationSessionView) part).getSessionId();
SessionContainer container = SharedDisplaySessionMgr
.getSessionContainer(sessionId);
if (container != null) {
CollaborationEditor assocEditor = container
.getCollaborationEditor();
if (assocEditor != null) {
IWorkbenchPage page = VizWorkbenchManager.getInstance()
.getCurrentWindow().getActivePage();
if (page != null) {
page.closeEditor(assocEditor, false);
}
}
}
}
}
@Override

View file

@ -136,7 +136,7 @@ public class ConnectionSubscriber {
public void postShutdown(IWorkbench workbench) {
dispose(connection);
if (connection != null) {
connection.closeManager();
connection.close();
}
}
};
@ -149,12 +149,12 @@ public class ConnectionSubscriber {
if (connection != null) {
try {
ISession p2pSession = connection.getPeerToPeerSession();
p2pSession.unRegisterEventHandler(this);
p2pSession.unregisterEventHandler(this);
} catch (CollaborationException e) {
statusHandler.handle(Priority.PROBLEM,
"Error unregistering peer to peer handler", e);
}
connection.unRegisterEventHandler(this);
connection.unregisterEventHandler(this);
}
PlatformUI.getWorkbench().removeWorkbenchListener(wbListener);
}
@ -162,7 +162,7 @@ public class ConnectionSubscriber {
@Subscribe
public void handleInvitationEvent(IVenueInvitationEvent event) {
final IVenueInvitationEvent invitation = event;
VizApp.runSync(new Runnable() {
VizApp.runAsync(new Runnable() {
@Override
public void run() {

View file

@ -44,9 +44,12 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo;
import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.ui.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.ui.data.SharedDisplaySessionMgr;
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
@ -259,18 +262,23 @@ public class CreateSessionDialog extends CaveSWTDialog {
result.setInviteUsers(inviteUsers.getSelection());
result.setInviteMessage(inviteMessageTF.getText());
}
CollaborationDataManager manager = CollaborationDataManager
.getInstance();
String sessionId = null;
IVenueSession session = null;
try {
CollaborationConnection connection = CollaborationConnection
.getConnection();
if (result.isCollaborationSession()) {
sessionId = manager.createCollaborationSession(
session = connection.createCollaborationVenue(
result.getName(), result.getSubject());
ISharedDisplaySession displaySession = (ISharedDisplaySession) session;
SharedDisplaySessionMgr.joinSession(
displaySession,
SharedDisplayRole.DATA_PROVIDER, null);
} else {
sessionId = manager.createTextOnlySession(
session = connection.createTextOnlyVenue(
result.getName(), result.getSubject());
}
result.setSessionId(sessionId);
result.setSessionId(session.getSessionId());
setReturnValue(result);
CreateSessionDialog.this.getShell().dispose();
} catch (CollaborationException ex) {

View file

@ -1,104 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.ui.data;
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
/**
* A single class that contains all data information.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 1, 2012 rferrel Initial creation
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class CollaborationDataManager {
private static CollaborationDataManager instance;
public static CollaborationDataManager getInstance() {
if (instance == null) {
instance = new CollaborationDataManager();
}
return instance;
}
/**
* Private constructor to for singleton class.
*/
private CollaborationDataManager() {
}
/**
* Generate a new session.
*
* @param venue
* - Session name
* @param subject
* - Session topic
* @return sessionId - the key to use to retrieve the sesson or null if
* unable to create the session
*/
public String createCollaborationSession(String venue, String subject)
throws CollaborationException {
CollaborationConnection connection = CollaborationConnection
.getConnection();
IVenueSession session = null;
String sessionId = null;
// try {
session = connection.createCollaborationVenue(venue, subject);
// sessionId = venueIdToSessionId(session.getVenue().getInfo()
// .getVenueID());
sessionId = session.getSessionId();
// TODO throw an exception if unable to make connection?
if (session.isConnected()) {
ISharedDisplaySession displaySession = (ISharedDisplaySession) session;
SharedDisplaySessionMgr.joinSession(displaySession,
SharedDisplayRole.DATA_PROVIDER, null);
}
return sessionId;
}
public String createTextOnlySession(String venueName, String subject)
throws CollaborationException {
CollaborationConnection connection = CollaborationConnection
.getConnection();
IVenueSession session = null;
String sessionId = null;
session = connection.createTextOnlyVenue(venueName, subject);
if (session.isConnected()) {
sessionId = session.getSessionId();
}
return sessionId;
}
}

View file

@ -25,6 +25,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.ui.IEditorPart;
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession;
import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole;
import com.raytheon.uf.viz.collaboration.ui.SessionColorManager;
@ -65,7 +68,8 @@ public class SharedDisplaySessionMgr {
}
public static void joinSession(ISharedDisplaySession session,
SharedDisplayRole initialRole, SessionColorManager colors) {
SharedDisplayRole initialRole, SessionColorManager colors)
throws CollaborationException {
SessionContainer container = new SessionContainer();
container.setSessionId(session.getSessionId());
container.setSession(session);
@ -78,11 +82,18 @@ public class SharedDisplaySessionMgr {
// TODO better way to determine which editor to start sharing?
// or better yet, maybe we should add this elsewhere after it has
// already been initialized with the correct target/resources
AbstractEditor sharedEditor = (AbstractEditor) VizWorkbenchManager
.getInstance().getActiveEditor();
IEditorPart part = VizWorkbenchManager.getInstance()
.getActiveEditor();
if (part instanceof AbstractEditor) {
AbstractEditor sharedEditor = (AbstractEditor) part;
editorList.add(sharedEditor);
container.setSharedEditors(editorList);
} else {
throw new CollaborationException(
"Cannot share a Collaboration Editor, please select a different tab");
}
break;
case PARTICIPANT:
rec = new ParticipantEventController(session);
// don't need to set the CollaborationEditor, as it won't be created

View file

@ -264,7 +264,7 @@ public class CollaborationAlertWordsPreferencePage extends
.getConnection();
if (connection != null && connection.isConnected()) {
// refresh any open chats or sessions
connection.getEventPublisher().post(wrapper);
connection.postEvent(wrapper);
}
return true;
}

View file

@ -91,8 +91,8 @@ public class CollaborationPreferencePage extends FieldEditorPreferencePage
CollaborationConnection connection = CollaborationConnection
.getConnection();
if (connection != null && connection.isConnected()) {
CollaborationConnection.getConnection().getEventPublisher()
.post(Activator.getDefault().getPreferenceStore());
CollaborationConnection.getConnection().postEvent(
Activator.getDefault().getPreferenceStore());
}
return super.performOk();
}

View file

@ -81,7 +81,7 @@ public abstract class AbstractRoleEventController implements
@Override
public void shutdown() {
session.unRegisterEventHandler(this);
session.unregisterEventHandler(this);
// Orphaned tellestrators, not sure what to do yet about clear
for (AbstractEditor editor : resourceEditors) {

View file

@ -319,7 +319,7 @@ public class CollaborationDispatcher extends Dispatcher {
e.getLocalizedMessage(), e);
}
disposeFrames();
session.unRegisterEventHandler(this);
session.unregisterEventHandler(this);
}
private void disposeFrames() {

View file

@ -178,7 +178,7 @@ public class CollaborationResource extends
@Override
protected void disposeInternal() {
resourceData.getSession().unRegisterEventHandler(this);
resourceData.getSession().unregisterEventHandler(this);
for (DisplayData data : displayData.values()) {
data.dispose();
}

View file

@ -40,6 +40,7 @@ import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
@ -56,6 +57,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.TransferRoleCommand;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.display.editor.CollaborationEditor;
import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.ColorChangeEvent;
import com.raytheon.uf.viz.collaboration.ui.data.SessionContainer;
@ -70,6 +72,7 @@ import com.raytheon.uf.viz.core.icon.IconUtil;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.uf.viz.drawing.DrawingToolLayer;
import com.raytheon.uf.viz.drawing.DrawingToolLayer.DrawMode;
import com.raytheon.viz.ui.VizWorkbenchManager;
import com.raytheon.viz.ui.editor.AbstractEditor;
/**
@ -477,6 +480,16 @@ public class CollaborationSessionView extends SessionView implements
@Override
public void dispose() {
CollaborationEditor assocEditor = SharedDisplaySessionMgr
.getSessionContainer(session.getSessionId())
.getCollaborationEditor();
if (assocEditor != null) {
IWorkbenchPage page = VizWorkbenchManager.getInstance()
.getCurrentWindow().getActivePage();
if (page != null) {
page.closeEditor(assocEditor, false);
}
}
SharedDisplaySessionMgr.exitSession(session.getSessionId());
session.close();
super.dispose();

View file

@ -84,8 +84,7 @@ public class PeerToPeerView extends AbstractSessionView {
userColor = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
chatterColor = Display.getCurrent().getSystemColor(SWT.COLOR_RED);
black = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
CollaborationConnection.getConnection().getEventPublisher()
.register(this);
CollaborationConnection.getConnection().registerEventHandler(this);
}
/*
@ -99,7 +98,7 @@ public class PeerToPeerView extends AbstractSessionView {
public void dispose() {
CollaborationConnection conn = CollaborationConnection.getConnection();
if (conn != null) {
conn.getEventPublisher().unregister(this);
conn.unregisterEventHandler(this);
}
super.dispose();
}

View file

@ -141,8 +141,7 @@ public class SessionView extends AbstractSessionView {
@Override
protected void initComponents(Composite parent) {
initColorManager();
CollaborationConnection.getConnection().getEventPublisher()
.register(this);
CollaborationConnection.getConnection().registerEventHandler(this);
super.initComponents(parent);
}
@ -408,11 +407,10 @@ public class SessionView extends AbstractSessionView {
}
// clean up event handlers
session.unRegisterEventHandler(this);
session.close();
CollaborationConnection conn = CollaborationConnection.getConnection();
if (conn != null) {
conn.getEventPublisher().unregister(this);
conn.unregisterEventHandler(this);
}
super.dispose();

View file

@ -188,7 +188,7 @@ public class CollaborationDrawingResource extends
layerMap = null;
manager.dispose();
container.getSession().unRegisterEventHandler(this);
container.getSession().unregisterEventHandler(this);
}
private void disposeLayers() {

View file

@ -19,6 +19,7 @@
**/
package com.raytheon.uf.viz.collaboration.ui.telestrator;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
@ -60,9 +61,10 @@ public class CollaborationDrawingUIManager extends DrawingToolUIManager {
CollaborationDrawingResource resource = CollaborationDrawingUIManager.this.resource;
IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
view = (CollaborationSessionView) page.findViewReference(
CollaborationSessionView.ID,
resource.getContainer().getSessionId()).getPart(false);
IViewReference viewRef = page.findViewReference(
CollaborationSessionView.ID, resource.getContainer()
.getSessionId());
view = (CollaborationSessionView) viewRef.getPart(false);
view.updateToolItems();
}
});

View file

@ -17,15 +17,6 @@ import gov.noaa.nws.ncep.ui.pgen.file.ProductConverter;
import gov.noaa.nws.ncep.ui.pgen.file.Products;
import gov.noaa.nws.ncep.ui.pgen.productmanage.ProductConfigureDialog;
import gov.noaa.nws.ncep.ui.pgen.PgenStaticDataProvider;
import gov.noaa.nws.ncep.ui.pgen.elements.AbstractDrawableComponent;
import gov.noaa.nws.ncep.ui.pgen.elements.Text;
import gov.noaa.nws.ncep.ui.pgen.elements.Track;
import gov.noaa.nws.ncep.ui.pgen.file.FileTools;
import gov.noaa.nws.ncep.ui.pgen.file.ProductConverter;
import gov.noaa.nws.ncep.ui.pgen.file.Products;
import gov.noaa.nws.ncep.ui.pgen.productManage.ProductConfigureDialog;
import java.io.File;
import java.util.Calendar;
import java.util.HashMap;
@ -62,10 +53,12 @@ public class AttrSettings {
private static HashMap<String, AbstractDrawableComponent> settings = null;
private static String settingsTblLocal = "." + File.separator;
public static String settingsFileName = "settings_tbl.xml";
/**
* Private constructor
*
* @throws VizException
*/
private AttrSettings() throws VizException {
@ -75,8 +68,8 @@ public class AttrSettings {
}
/**
* Creates a AttrSettings instance if it does not exist
* and returns the instance. If it exists, return the instance.
* Creates a AttrSettings instance if it does not exist and returns the
* instance. If it exists, return the instance.
*
* @return
*/
@ -104,28 +97,23 @@ public class AttrSettings {
}
/**
* @param value the DrawableElement to set
* gilbert: noticed this wasn't being used AND I wasn't sure how to
* modify it for the new pgenType and pgenCategory DE attributes,
* so I juct commented it out for now.
* @param value
* the DrawableElement to set gilbert: noticed this wasn't being
* used AND I wasn't sure how to modify it for the new pgenType
* and pgenCategory DE attributes, so I juct commented it out for
* now.
*
public void setSettings( IAttribute de ) {
String pgenID = null;
DrawableElement elem = null;
if ( de instanceof IMultiPoint ) {
pgenID = de.getLinePattern();
}
else {
pgenID = de.getType();
}
elem = (DrawableElement)settings.get( pgenID );
elem.update( de );
settings.put( pgenID, elem );
}
* public void setSettings( IAttribute de ) {
*
* String pgenID = null; DrawableElement elem = null;
*
* if ( de instanceof IMultiPoint ) { pgenID =
* de.getLinePattern(); } else { pgenID = de.getType(); }
*
* elem = (DrawableElement)settings.get( pgenID ); elem.update(
* de );
*
* settings.put( pgenID, elem ); }
*/
public void setSettings(AbstractDrawableComponent de) {
@ -136,9 +124,8 @@ public class AttrSettings {
}
/**
* Load default settings from settings_tbl.xml
* First try to load from user's local directory; if not found, load
* the base directory.
* Load default settings from settings_tbl.xml First try to load from user's
* local directory; if not found, load the base directory.
*/
private void loadSettingsTable() {
@ -146,7 +133,8 @@ public class AttrSettings {
* Get the settings table file from localization
*/
File settingsFile = PgenStaticDataProvider.getProvider().getFile(
PgenStaticDataProvider.getProvider().getPgenLocalizationRoot() + settingsFileName);
PgenStaticDataProvider.getProvider().getPgenLocalizationRoot()
+ settingsFileName);
if (settingsFile == null) {
System.out.println("Unable to fing pgen settings table");
@ -159,24 +147,24 @@ public class AttrSettings {
if (prodName == null || prodName.isEmpty()) {
loadSettingsTable();
}
else {
} else {
try {
String pt = ProductConfigureDialog.getProductTypes().get(prodName).getType();
String pt = ProductConfigureDialog.getProductTypes()
.get(prodName).getType();
String pt1 = pt.replaceAll(" ", "_");
LocalizationFile lFile = PgenStaticDataProvider.getProvider().getStaticLocalizationFile(ProductConfigureDialog.getSettingFullPath(pt1));
LocalizationFile lFile = PgenStaticDataProvider.getProvider()
.getStaticLocalizationFile(
ProductConfigureDialog.getSettingFullPath(pt1));
String filePath = lFile.getFile().getAbsolutePath();
if (!new File(filePath).canRead()) {
loadSettingsTable();
}
else {
} else {
loadPgenSettings(filePath);
}
}
catch ( Exception e ){
} catch (Exception e) {
loadSettingsTable();
}
}
@ -200,9 +188,11 @@ public class AttrSettings {
for (gov.noaa.nws.ncep.ui.pgen.elements.Product p : prds) {
for ( gov.noaa.nws.ncep.ui.pgen.elements.Layer layer:p.getLayers() ) {
for (gov.noaa.nws.ncep.ui.pgen.elements.Layer layer : p
.getLayers()) {
for ( gov.noaa.nws.ncep.ui.pgen.elements.AbstractDrawableComponent de:layer.getDrawables() ) {
for (gov.noaa.nws.ncep.ui.pgen.elements.AbstractDrawableComponent de : layer
.getDrawables()) {
String pgenID = null;
pgenID = de.getPgenType();
@ -213,10 +203,10 @@ public class AttrSettings {
if (pgenID.equalsIgnoreCase("General Text")) {
((Text) de).setText(new String[] { "" });
}
else if ( pgenID.equalsIgnoreCase("STORM_TRACK")){
} else if (pgenID.equalsIgnoreCase("STORM_TRACK")) {
// set Track time to current time
Calendar cal1 = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
Calendar cal1 = Calendar.getInstance(TimeZone
.getTimeZone("GMT"));
Calendar cal2 = (Calendar) cal1.clone();
cal2.add(Calendar.HOUR_OF_DAY, 1);
@ -235,8 +225,7 @@ public class AttrSettings {
}
}
}
catch ( Exception e ){
} catch (Exception e) {
ret = false;
}

View file

@ -14,12 +14,6 @@ import gov.noaa.nws.ncep.ui.pgen.attrdialog.AttrDlg;
import gov.noaa.nws.ncep.ui.pgen.display.IAttribute;
import gov.noaa.nws.ncep.ui.pgen.sigmet.CcfpInfo;
import gov.noaa.nws.ncep.ui.pgen.PgenStaticDataProvider;
import gov.noaa.nws.ncep.ui.pgen.PgenUtil;
import gov.noaa.nws.ncep.ui.pgen.attrDialog.AttrDlg;
import gov.noaa.nws.ncep.ui.pgen.display.IAttribute;
import gov.noaa.nws.ncep.ui.pgen.sigmet.CcfpInfo;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@ -59,28 +53,27 @@ public class CcfpMsgDlg extends AttrDlg{
// Constant for Button Update
private static final int CCFP_CONSTANT_UPDATE = 20101007;
public static final String PGEN_CCFP_XSLT = "xslt"+File.separator+
"ccfp"+File.separator+"ccfpXml2Txt.xslt";
public static final String PGEN_CCFP_XSLT = "xslt" + File.separator
+ "ccfp" + File.separator + "ccfpXml2Txt.xslt";
// singleton instance for this class
private static CcfpMsgDlg INSTANCE = null;
// the instance of CcfpTimeDlg class
private CcfpTimeDlg timeDlg = null;
// issue and valid times
private String issueTime;
private String validTime;
// Text field for displaying the text product
private Text txtInfo;
// Text field for the name of the file to be saved.
private Text txtSave;
// variables holding directory and file content.
private String dirLocal = ".", txtFileContent = "", txtFileName = "";
@ -89,7 +82,9 @@ public class CcfpMsgDlg extends AttrDlg{
/**
* constructor for this class
* @param Shell: parent Shell of this class
*
* @param Shell
* : parent Shell of this class
* @throws VizException
*/
public CcfpMsgDlg(Shell parShell) throws VizException {
@ -99,7 +94,9 @@ public class CcfpMsgDlg extends AttrDlg{
/**
* singleton creation method for this class
* @param Shell: parent Shell of this class
*
* @param Shell
* : parent Shell of this class
* @return
*/
public static CcfpMsgDlg getInstance(Shell parShell) {
@ -115,25 +112,36 @@ public class CcfpMsgDlg extends AttrDlg{
}
@Override
public void setAttrForDlg(IAttribute ia) { }
public void setAttrForDlg(IAttribute ia) {
}
/**
* method overridden from the super class
* for Save/Cancel buttons of this class
* method overridden from the super class for Save/Cancel buttons of this
* class
*/
@Override
public void createButtonsForButtonBar(Composite parent) {
createButton(parent, CCFP_CONSTANT_UPDATE, "Update", true);
createButton(parent, IDialogConstants.OK_ID, "Save", true);
createButton(parent, IDialogConstants.CANCEL_ID,IDialogConstants.CANCEL_LABEL, false);
createButton(parent, IDialogConstants.CANCEL_ID,
IDialogConstants.CANCEL_LABEL, false);
this.getButton(CCFP_CONSTANT_UPDATE).addListener(SWT.Selection, new Listener(){
this.getButton(CCFP_CONSTANT_UPDATE).addListener(SWT.Selection,
new Listener() {
public void handleEvent(Event e) {
String xmlFileName = CcfpInfo.saveCcfpXmlFile(getIssueTime(), getValidTime());
txtFileContent = CcfpInfo.convertXml2Txt(xmlFileName,
PgenStaticDataProvider.getProvider().getFileAbsolutePath(
PgenStaticDataProvider.getProvider().getPgenLocalizationRoot() + PGEN_CCFP_XSLT ));
String xmlFileName = CcfpInfo.saveCcfpXmlFile(
getIssueTime(), getValidTime());
txtFileContent = CcfpInfo
.convertXml2Txt(
xmlFileName,
PgenStaticDataProvider
.getProvider()
.getFileAbsolutePath(
PgenStaticDataProvider
.getProvider()
.getPgenLocalizationRoot()
+ PGEN_CCFP_XSLT));
txtInfo.setText(txtFileContent.trim());
}
@ -141,8 +149,8 @@ public class CcfpMsgDlg extends AttrDlg{
}
/**
* method overridden from the super class
* for Save/Cancel buttons of this class
* method overridden from the super class for Save/Cancel buttons of this
* class
*/
@Override
public void enableButtons() {
@ -152,8 +160,8 @@ public class CcfpMsgDlg extends AttrDlg{
}
/**
* method listener overridden from the super class
* for Cancel button of this class
* method listener overridden from the super class for Cancel button of this
* class
*/
@Override
public void cancelPressed() {
@ -162,23 +170,26 @@ public class CcfpMsgDlg extends AttrDlg{
}
/**
* method listener overridden from the super class
* for Save button of this class:
* it saves the displayed text with the displayed name
* as a text file in local directory.
* method listener overridden from the super class for Save button of this
* class: it saves the displayed text with the displayed name as a text file
* in local directory.
*/
@Override
public void okPressed() {
try {
File f = new File(/*dirLocal*/PgenUtil.getWorkingDirectory()+File.separator+txtSave.getText());
File f = new File(/* dirLocal */PgenUtil.getWorkingDirectory()
+ File.separator + txtSave.getText());
Writer output = new BufferedWriter(new FileWriter(f));
try {
output.write( txtInfo.getText() );//wrap( txtInfo.getText(), 51, null, false) );
output.write(txtInfo.getText());// wrap( txtInfo.getText(), 51,
// null, false) );
output.flush();
} catch (Exception ee) {
System.out.println(ee.getMessage());
} finally { output.close(); }
} finally {
output.close();
}
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
@ -189,8 +200,8 @@ public class CcfpMsgDlg extends AttrDlg{
}
/**
* method overridden from the super class
* to create the dialog area for this class
* method overridden from the super class to create the dialog area for this
* class
*/
@Override
public Control createDialogArea(Composite parent) {
@ -204,26 +215,32 @@ public class CcfpMsgDlg extends AttrDlg{
this.getShell().setText("Collective Convection Forecast Message");
//this.volcano = this.volAttrDlgInstance.getVolcano();//TODO: already set in attrDlg before this is open 20100309
// this.volcano = this.volAttrDlgInstance.getVolcano();//TODO: already
// set in attrDlg before this is open 20100309
txtInfo = new Text( top, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
txtInfo = new Text(top, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL
| SWT.V_SCROLL);
GridData gData = new GridData(800, 300);
gData.horizontalSpan = 3;
txtInfo.setEditable(false);
txtInfo.setBackground(new Color(this.getShell().getDisplay(), 235,235,235));
txtInfo.setBackground(new Color(this.getShell().getDisplay(), 235, 235,
235));
txtInfo.setLayoutData(gData);
txtInfo.setFont( new Font(this.getShell().getDisplay(), "Monospace", 11, SWT.NORMAL));
txtInfo.setFont(new Font(this.getShell().getDisplay(), "Monospace", 11,
SWT.NORMAL));
txtInfo.setText(getFileContent());// getFileContent());
Group top_3 = new Group(top, SWT.LEFT);
top_3.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,true,LAYOUT_WIDTH,1));
top_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true,
LAYOUT_WIDTH, 1));
top_3.setLayout(new GridLayout(LAYOUT_WIDTH, false));
Label lblFileName = new Label(top_3, SWT.LEFT);
lblFileName.setText("File Name: ");
txtSave = new Text(top_3, SWT.BORDER);// | SWT.READ_ONLY);
txtSave.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,false,1,1));
txtSave.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,
1, 1));
txtSave.setText(getFileName());
return top;
@ -231,8 +248,8 @@ public class CcfpMsgDlg extends AttrDlg{
}
/**
* set the content for the text field;
* called by CcfpTimeDlg.java
* set the content for the text field; called by CcfpTimeDlg.java
*
* @param txt
*/
public void setFileContent(String txt) {
@ -242,8 +259,8 @@ public class CcfpMsgDlg extends AttrDlg{
}
/**
* set the name of the text file;
* called by CcfpTimeDlg.java
* set the name of the text file; called by CcfpTimeDlg.java
*
* @param name
*/
public void setFileName(String name) {
@ -270,6 +287,7 @@ public class CcfpMsgDlg extends AttrDlg{
/**
* return the CcfpTimeDlg instance
*
* @return CcfpTimeDlg instance
*/
public CcfpTimeDlg getTimeDlg() {
@ -278,7 +296,9 @@ public class CcfpMsgDlg extends AttrDlg{
/**
* set the CcfpTimeDlg instance
* @param timeDlg: CcfpTimeDlg instance
*
* @param timeDlg
* : CcfpTimeDlg instance
*/
public void setTimeDlg(CcfpTimeDlg timeDlg) {
this.timeDlg = timeDlg;
@ -286,6 +306,7 @@ public class CcfpMsgDlg extends AttrDlg{
/**
* getter for Issue time
*
* @return issue time String
*/
public String getIssueTime() {
@ -294,6 +315,7 @@ public class CcfpMsgDlg extends AttrDlg{
/**
* setter for issue time
*
* @param issueTime
*/
public void setIssueTime(String issueTime) {
@ -302,6 +324,7 @@ public class CcfpMsgDlg extends AttrDlg{
/**
* getter for valid time
*
* @return valid time String
*/
public String getValidTime() {
@ -310,6 +333,7 @@ public class CcfpMsgDlg extends AttrDlg{
/**
* setter for valid time
*
* @param validTime
*/
public void setValidTime(String validTime) {