Merge "Omaha #3709 reworked custom user color configuration" into omaha_14.4.1
Former-commit-id:511ba87c5c
[formerly65a0433605
[formerly d7cc45aa26f71ad81d82dc1dfa2541e105b4c76c]] Former-commit-id:65a0433605
Former-commit-id:bb5b975ae0
This commit is contained in:
commit
22ecd81209
18 changed files with 736 additions and 200 deletions
|
@ -40,6 +40,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
|||
* Jan 28, 2014 2698 bclement removed getInfo, added methods to replace
|
||||
* Jan 30, 2014 2698 bclement changed UserId to VenueParticipant
|
||||
* Mar 06, 2014 2751 bclement added getParticipantUserid()
|
||||
* Jan 09, 2015 3709 bclement added isPersistent()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -91,4 +92,10 @@ public interface IVenue {
|
|||
*/
|
||||
public UserId getParticipantUserid(VenueParticipant participant);
|
||||
|
||||
/**
|
||||
* @return true if this is a room that exists on the server even when there
|
||||
* are no participants
|
||||
*/
|
||||
public boolean isPersistent();
|
||||
|
||||
}
|
||||
|
|
|
@ -34,10 +34,12 @@ import org.jivesoftware.smack.packet.Presence.Type;
|
|||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.muc.Affiliate;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChat;
|
||||
import org.jivesoftware.smackx.muc.RoomInfo;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenue;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.connection.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.comm.provider.user.VenueParticipant;
|
||||
|
@ -59,6 +61,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
|||
* Mar 05, 2014 2798 mpduff Get Presence from MUC.
|
||||
* Mar 06, 2014 2751 bclement added getParticipantUserid()
|
||||
* Mar 07, 2014 2848 bclement added hasOtherParticipants()
|
||||
* Jan 09, 2015 3709 bclement added isPersistent()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -195,4 +198,21 @@ public class Venue implements IVenue {
|
|||
return getParticipantCount() > 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPersistent() {
|
||||
boolean rval = false;
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
XMPPConnection xmppConn = connection.getXmppConnection();
|
||||
try {
|
||||
RoomInfo roomInfo = MultiUserChat.getRoomInfo(xmppConn,
|
||||
muc.getRoom());
|
||||
rval = roomInfo.isPersistent();
|
||||
} catch (XMPPException e) {
|
||||
log.error("Unable to determine if room " + this.getId()
|
||||
+ " is persistent", e);
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -113,7 +113,8 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
|||
* Apr 29, 2014 3061 bclement moved invite payload to shared display session
|
||||
* May 09, 2014 3107 bclement removed catch from isRoomOwner() so callers know about errors
|
||||
* Jun 16, 2014 3288 bclement changed String venueName to VenueId venueId, added createVenueId()
|
||||
* Oct 08, 2014 3705 bclement aded getVenueId()
|
||||
* Oct 08, 2014 3705 bclement added getVenueId()
|
||||
* Jan 12, 2015 3709 bclement fixed rare invite bug
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -247,7 +248,11 @@ public class VenueSession extends BaseSession implements IVenueSession {
|
|||
protected Message createInviteMessage(UserId id, VenueInvite invite) {
|
||||
Message msg = new Message();
|
||||
msg.setType(Type.normal);
|
||||
msg.setBody(invite.getMessage());
|
||||
/*
|
||||
* don't set a body on the message. smack will add a packet extension on
|
||||
* it that will have the actual invite. openfire gets confused if there
|
||||
* is both a body and an extension and drops the invite on the floor.
|
||||
*/
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
|
|
@ -123,6 +123,7 @@ import com.raytheon.uf.viz.collaboration.ui.actions.RemoveFromRosterAction;
|
|||
import com.raytheon.uf.viz.collaboration.ui.actions.SendSubReqAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.ShowVenueAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.UserSearchAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.UserColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.AlertWordWrapper;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.CollaborationGroupContainer;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.PublicRoomContainer;
|
||||
|
@ -168,6 +169,7 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
|
|||
* Nov 14, 2014 3709 mapeters Removed change background/foreground color actions from menu.
|
||||
* Dec 08, 2014 3709 mapeters Added MB3 change user text color actions to contacts list.
|
||||
* Dec 12, 2014 3709 mapeters Store {@link ChangeTextColorAction}s in map, dispose them.
|
||||
* Jan 09, 2015 3709 bclement color config manager API changes
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -448,7 +450,7 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
if (o instanceof SessionGroupContainer) {
|
||||
manager.add(createSessionAction);
|
||||
return;
|
||||
} else if (o instanceof PublicRoomContainer){
|
||||
} else if (o instanceof PublicRoomContainer) {
|
||||
manager.add(roomSearchAction);
|
||||
return;
|
||||
} else if (o instanceof IVenueSession) {
|
||||
|
@ -476,14 +478,15 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
}
|
||||
manager.add(new AddNotifierAction(this));
|
||||
manager.add(new Separator());
|
||||
String name = user.getName();
|
||||
ChangeTextColorAction userColorAction = userColorActions.get(name);
|
||||
String colorActionKey = user.getFQName();
|
||||
ChangeTextColorAction userColorAction = userColorActions
|
||||
.get(colorActionKey);
|
||||
if (userColorAction == null) {
|
||||
userColorAction = ChangeTextColorAction
|
||||
.createChangeUserTextColorAction(name, false, false,
|
||||
.createChangeUserTextColorAction(user, false, false,
|
||||
new RGB(0, 0, 255),
|
||||
new UserColorConfigManager());
|
||||
userColorActions.put(name, userColorAction);
|
||||
UserColorConfigManager.getInstance());
|
||||
userColorActions.put(colorActionKey, userColorAction);
|
||||
}
|
||||
manager.add(userColorAction);
|
||||
} else if (o instanceof UserId) {
|
||||
|
@ -494,15 +497,15 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
UserId me = connection.getUser();
|
||||
if (me.isSameUser(user)) {
|
||||
createMenu(manager);
|
||||
String name = user.getName();
|
||||
String colorActionKey = user.getFQName();
|
||||
ChangeTextColorAction userColorAction = userColorActions
|
||||
.get(name);
|
||||
.get(colorActionKey);
|
||||
if (userColorAction == null) {
|
||||
userColorAction = ChangeTextColorAction
|
||||
.createChangeUserTextColorAction(name, true, true,
|
||||
.createChangeUserTextColorAction(user, true, true,
|
||||
new RGB(0, 0, 255),
|
||||
new UserColorConfigManager());
|
||||
userColorActions.put(name, userColorAction);
|
||||
UserColorConfigManager.getInstance());
|
||||
userColorActions.put(colorActionKey, userColorAction);
|
||||
}
|
||||
manager.insertBefore("afterFont", userColorAction);
|
||||
}
|
||||
|
|
|
@ -32,12 +32,12 @@ import org.eclipse.swt.graphics.Rectangle;
|
|||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.ui.AbstractColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
|
||||
import com.raytheon.uf.viz.collaboration.ui.FeedColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.ForegroundBackgroundColorDlg;
|
||||
import com.raytheon.uf.viz.collaboration.ui.UserColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.FeedColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.ForegroundBackgroundColorDlg;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
|
@ -50,12 +50,13 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 12/02/14 3709 mapeters Initial creation.
|
||||
* 12/09/14 3709 mapeters Uses {@link ForegroundBackgroundColorDlg}, renamed from
|
||||
* Dec 02, 2014 3709 mapeters Initial creation.
|
||||
* Dec 09, 2014 3709 mapeters Uses {@link ForegroundBackgroundColorDlg}, renamed from
|
||||
* ChangeUserColorAction, support both user and site colors.
|
||||
* 12/12/14 3709 mapeters Use static methods to call constructor, icon displays
|
||||
* Dec 12, 2014 3709 mapeters Use static methods to call constructor, icon displays
|
||||
* current foreground and background colors.
|
||||
* 01/05/15 3709 mapeters Added getTextColors(), added me param to createChangeUserTextColorAction().
|
||||
* Jan 05, 2015 3709 mapeters Added getTextColors(), added me param to createChangeUserTextColorAction().
|
||||
* Jan 09, 2015 3709 bclement color change manager API changes
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -68,7 +69,7 @@ public class ChangeTextColorAction extends Action {
|
|||
|
||||
private RGB defaultForeground;
|
||||
|
||||
private AbstractColorConfigManager colorConfigManager;
|
||||
private IColorConfigManager colorConfigManager;
|
||||
|
||||
private Image icon;
|
||||
|
||||
|
@ -88,20 +89,21 @@ public class ChangeTextColorAction extends Action {
|
|||
* @return
|
||||
*/
|
||||
public static ChangeTextColorAction createChangeUserTextColorAction(
|
||||
String user, boolean me, boolean displayName,
|
||||
RGB defaultForeground, UserColorConfigManager colorConfigManager) {
|
||||
IUser user, boolean me, boolean displayName,
|
||||
RGB defaultForeground, IColorConfigManager colorConfigManager) {
|
||||
String name = user.getName();
|
||||
String text = "Change ";
|
||||
if (displayName) {
|
||||
text += me ? "Your" : (user + "'s");
|
||||
text += me ? "Your" : (name + "'s");
|
||||
} else {
|
||||
text += "User";
|
||||
}
|
||||
text += " Text Colors...";
|
||||
|
||||
return new ChangeTextColorAction(text, user, defaultForeground,
|
||||
colorConfigManager);
|
||||
return new ChangeTextColorAction(text, user.getFQName(),
|
||||
defaultForeground, colorConfigManager);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create and return new action for changing site colors.
|
||||
*
|
||||
|
@ -121,7 +123,7 @@ public class ChangeTextColorAction extends Action {
|
|||
}
|
||||
|
||||
private ChangeTextColorAction(String text, String key,
|
||||
RGB defaultForeground, AbstractColorConfigManager colorConfigManager) {
|
||||
RGB defaultForeground, IColorConfigManager colorConfigManager) {
|
||||
super(text);
|
||||
this.key = key;
|
||||
this.defaultForeground = defaultForeground;
|
||||
|
@ -137,7 +139,8 @@ public class ChangeTextColorAction extends Action {
|
|||
public void run() {
|
||||
RGB[] colors = getTextColors();
|
||||
ForegroundBackgroundColorDlg dialog = new ForegroundBackgroundColorDlg(
|
||||
Display.getCurrent().getActiveShell(), colors[0], colors[1]);
|
||||
Display.getCurrent().getActiveShell(),
|
||||
colorConfigManager.getDescription(key), colors[0], colors[1]);
|
||||
|
||||
dialog.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
|
@ -238,4 +241,5 @@ public class ChangeTextColorAction extends Action {
|
|||
icon.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.collaboration.ui;
|
||||
package com.raytheon.uf.viz.collaboration.ui.colors;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -17,12 +17,12 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.collaboration.ui;
|
||||
package com.raytheon.uf.viz.collaboration.ui.colors;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
||||
|
||||
/**
|
||||
* Configuration manager for reading/writing colors for each site to/from a
|
||||
|
@ -35,21 +35,32 @@ import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 10, 2014 3708 bclement Moved color methods from SiteConfigurationManager
|
||||
* Nov 26, 2014 3709 mapeters Abstracted out code to {@link AbstractColorConfigManager},
|
||||
* Nov 26, 2014 3709 mapeters Abstracted out code to {@link PersistentColorConfigManager},
|
||||
* renamed from SiteColorConfigManager.
|
||||
* Dec 08, 2014 3709 mapeters Set foreground and background colors together.
|
||||
* Jan 09, 2015 3709 bclement made into a true singleton, moved colorInfoMap to super
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class FeedColorConfigManager extends AbstractColorConfigManager {
|
||||
public class FeedColorConfigManager extends PersistentColorConfigManager {
|
||||
|
||||
private static final String FILE_PATH = "collaboration"
|
||||
private static final String FILE_PATH = CONFIG_DIR_NAME
|
||||
+ IPathManager.SEPARATOR + "siteColorInfo.xml";
|
||||
|
||||
private static ColorInfoMap colorInfoMap;
|
||||
private static FeedColorConfigManager instance;
|
||||
|
||||
public static synchronized FeedColorConfigManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new FeedColorConfigManager();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
protected FeedColorConfigManager() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set and store the given colors for the given site.
|
||||
|
@ -75,13 +86,16 @@ public class FeedColorConfigManager extends AbstractColorConfigManager {
|
|||
return super.getColor(site, FILE_PATH);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager#
|
||||
* getDescription()
|
||||
*/
|
||||
@Override
|
||||
protected ColorInfoMap getColorInfoMap() {
|
||||
return colorInfoMap;
|
||||
public String getDescription(String key) {
|
||||
return "Color changes will apply to all users from site " + key
|
||||
+ " in the feed room.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setColorInfoMap(ColorInfoMap colorInfoMap) {
|
||||
FeedColorConfigManager.colorInfoMap = colorInfoMap;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
/**
|
||||
* 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.colors;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.FontData;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
/**
|
||||
* A dialog that displays a label with settable foreground and background colors
|
||||
* using a color control.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 04, 2014 3709 lvenable Initial creation
|
||||
* Jan 09, 2015 3709 bclement moved primary logic to new super class
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author lvenable
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ForegroundBackgroundColorDlg extends ForegroundColorDlg {
|
||||
|
||||
/** Background color. */
|
||||
private Color backgroundClr = null;
|
||||
|
||||
private Button foregroundRdo;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param parentShell
|
||||
* Parent shell.
|
||||
*/
|
||||
public ForegroundBackgroundColorDlg(Shell parentShell, String description) {
|
||||
this(parentShell, description, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param parentShell
|
||||
* Parent shell.
|
||||
* @param fgRGB
|
||||
* Foreground RGB.
|
||||
* @param bgRGB
|
||||
* Background RGB.
|
||||
*/
|
||||
public ForegroundBackgroundColorDlg(Shell parentShell, String description,
|
||||
RGB fgRGB, RGB bgRGB) {
|
||||
super(parentShell, description, fgRGB);
|
||||
setText("Foreground/Background Color Chooser");
|
||||
|
||||
/*
|
||||
* If the background RGB is null then set it to a white color.
|
||||
*/
|
||||
if (bgRGB == null) {
|
||||
backgroundClr = new Color(parentShell.getDisplay(), new RGB(255,
|
||||
255, 255));
|
||||
} else {
|
||||
backgroundClr = new Color(parentShell.getDisplay(), bgRGB);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void disposed() {
|
||||
super.disposed();
|
||||
|
||||
if (backgroundClr != null) {
|
||||
backgroundClr.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createColorControls() {
|
||||
Composite colorControlComp = new Composite(shell, SWT.NONE);
|
||||
colorControlComp.setLayout(new GridLayout(3, false));
|
||||
colorControlComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT,
|
||||
true, false));
|
||||
|
||||
/*
|
||||
* Foreground/background radio buttons.
|
||||
*/
|
||||
foregroundRdo = new Button(colorControlComp, SWT.RADIO);
|
||||
foregroundRdo.setText("Foreground Color");
|
||||
foregroundRdo.setSelection(true);
|
||||
foregroundRdo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
colorWheelComp.setColor(foregroundClr.getRGB());
|
||||
}
|
||||
});
|
||||
|
||||
GridData gd = new GridData();
|
||||
gd.horizontalIndent = 13;
|
||||
Button backgroundRdo = new Button(colorControlComp, SWT.RADIO);
|
||||
backgroundRdo.setText("Background Color");
|
||||
backgroundRdo.setLayoutData(gd);
|
||||
backgroundRdo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
colorWheelComp.setColor(backgroundClr.getRGB());
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Label displaying the foreground/background colors.
|
||||
*/
|
||||
gd = new GridData();
|
||||
gd.horizontalIndent = 13;
|
||||
previewLabel = new Label(colorControlComp, SWT.BORDER);
|
||||
FontData fd = previewLabel.getFont().getFontData()[0];
|
||||
fd.setHeight(16);
|
||||
fd.setStyle(SWT.BOLD);
|
||||
labelFont = new Font(getDisplay(), fd);
|
||||
previewLabel.setFont(labelFont);
|
||||
previewLabel.setText(" Sample Text ");
|
||||
previewLabel.setLayoutData(gd);
|
||||
|
||||
previewLabel.setForeground(foregroundClr);
|
||||
previewLabel.setBackground(backgroundClr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void collectReturnValue() {
|
||||
RGB[] rgbArray = new RGB[] { foregroundClr.getRGB(),
|
||||
backgroundClr.getRGB() };
|
||||
setReturnValue(rgbArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void colorChange(RGB rgb, String colorWheelTitle) {
|
||||
if (foregroundRdo.getSelection()) {
|
||||
foregroundClr.dispose();
|
||||
foregroundClr = new Color(getDisplay(), rgb);
|
||||
previewLabel.setForeground(foregroundClr);
|
||||
} else {
|
||||
backgroundClr.dispose();
|
||||
backgroundClr = new Color(getDisplay(), rgb);
|
||||
previewLabel.setBackground(backgroundClr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.collaboration.ui;
|
||||
package com.raytheon.uf.viz.collaboration.ui.colors;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
|
@ -39,8 +39,8 @@ import com.raytheon.viz.ui.dialogs.colordialog.ColorWheelComp;
|
|||
import com.raytheon.viz.ui.dialogs.colordialog.IColorWheelChange;
|
||||
|
||||
/**
|
||||
* A dialog that displays a label with settable foreground and background colors
|
||||
* using a color control.
|
||||
* A dialog that displays a label with settable foreground color using a color
|
||||
* control.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -48,32 +48,31 @@ import com.raytheon.viz.ui.dialogs.colordialog.IColorWheelChange;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 4, 2014 3709 lvenable Initial creation
|
||||
* Jan 09, 2015 3709 bclement Initial creation, logic from ForegroundBackgroundColorDlg
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author lvenable
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ForegroundBackgroundColorDlg extends CaveSWTDialog implements
|
||||
public class ForegroundColorDlg extends CaveSWTDialog implements
|
||||
IColorWheelChange {
|
||||
|
||||
/** Color wheel composite. */
|
||||
private ColorWheelComp colorWheelComp;
|
||||
protected ColorWheelComp colorWheelComp;
|
||||
|
||||
/** Foreground color. */
|
||||
private Color foregroundClr = null;
|
||||
protected Color foregroundClr = null;
|
||||
|
||||
/** Background color. */
|
||||
private Color backgroundClr = null;
|
||||
/** preview label control. */
|
||||
protected Label previewLabel = null;
|
||||
|
||||
/** Foreground/Background label control. */
|
||||
private Label fgbgLabel = null;
|
||||
/** Font for the preview label. */
|
||||
protected Font labelFont = null;
|
||||
|
||||
/** Fond for the foreground/background label. */
|
||||
private Font labelFont = null;
|
||||
protected final String description;
|
||||
|
||||
private Button foregroundRdo;
|
||||
protected Label descriptionLabel = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -81,8 +80,8 @@ public class ForegroundBackgroundColorDlg extends CaveSWTDialog implements
|
|||
* @param parentShell
|
||||
* Parent shell.
|
||||
*/
|
||||
public ForegroundBackgroundColorDlg(Shell parentShell) {
|
||||
this(parentShell, null, null);
|
||||
public ForegroundColorDlg(Shell parentShell, String description) {
|
||||
this(parentShell, description, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,14 +91,12 @@ public class ForegroundBackgroundColorDlg extends CaveSWTDialog implements
|
|||
* Parent shell.
|
||||
* @param fgRGB
|
||||
* Foreground RGB.
|
||||
* @param bgRGB
|
||||
* Background RGB.
|
||||
*/
|
||||
public ForegroundBackgroundColorDlg(Shell parentShell, RGB fgRGB, RGB bgRGB) {
|
||||
public ForegroundColorDlg(Shell parentShell, String description, RGB fgRGB) {
|
||||
super(parentShell, SWT.DIALOG_TRIM | SWT.MIN, CAVE.DO_NOT_BLOCK
|
||||
| CAVE.PERSPECTIVE_INDEPENDENT);
|
||||
setText("Foreground/Background Color Chooser");
|
||||
|
||||
setText("Foreground Color Chooser");
|
||||
this.description = description;
|
||||
/*
|
||||
* If the foreground RGB is null then set it to a blue color.
|
||||
*/
|
||||
|
@ -109,16 +106,6 @@ public class ForegroundBackgroundColorDlg extends CaveSWTDialog implements
|
|||
} else {
|
||||
foregroundClr = new Color(parentShell.getDisplay(), fgRGB);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the background RGB is null then set it to a white color.
|
||||
*/
|
||||
if (bgRGB == null) {
|
||||
backgroundClr = new Color(parentShell.getDisplay(), new RGB(255,
|
||||
255, 255));
|
||||
} else {
|
||||
backgroundClr = new Color(parentShell.getDisplay(), bgRGB);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -140,19 +127,21 @@ public class ForegroundBackgroundColorDlg extends CaveSWTDialog implements
|
|||
foregroundClr.dispose();
|
||||
}
|
||||
|
||||
if (backgroundClr != null) {
|
||||
backgroundClr.dispose();
|
||||
}
|
||||
|
||||
if (labelFont != null) {
|
||||
labelFont.dispose();
|
||||
}
|
||||
if (descriptionLabel != null) {
|
||||
descriptionLabel.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
createColorWheelControl();
|
||||
createColorControls();
|
||||
if (description != null && !description.isEmpty()) {
|
||||
createDescriptionLabel();
|
||||
}
|
||||
addSeparator();
|
||||
createBottomButtons();
|
||||
|
||||
|
@ -162,7 +151,7 @@ public class ForegroundBackgroundColorDlg extends CaveSWTDialog implements
|
|||
/**
|
||||
* Create the color wheel controls.
|
||||
*/
|
||||
private void createColorWheelControl() {
|
||||
protected void createColorWheelControl() {
|
||||
colorWheelComp = new ColorWheelComp(shell, this, " Color Chooser: ",
|
||||
true);
|
||||
}
|
||||
|
@ -170,59 +159,33 @@ public class ForegroundBackgroundColorDlg extends CaveSWTDialog implements
|
|||
/**
|
||||
* Create the color controls.
|
||||
*/
|
||||
private void createColorControls() {
|
||||
Composite colorControlComp = new Composite(shell, SWT.NONE);
|
||||
colorControlComp.setLayout(new GridLayout(3, false));
|
||||
colorControlComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT,
|
||||
true, false));
|
||||
|
||||
/*
|
||||
* Foreground/background radio buttons.
|
||||
*/
|
||||
foregroundRdo = new Button(colorControlComp, SWT.RADIO);
|
||||
foregroundRdo.setText("Foreground Color");
|
||||
foregroundRdo.setSelection(true);
|
||||
foregroundRdo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
colorWheelComp.setColor(foregroundClr.getRGB());
|
||||
}
|
||||
});
|
||||
|
||||
GridData gd = new GridData();
|
||||
gd.horizontalIndent = 13;
|
||||
Button backgroundRdo = new Button(colorControlComp, SWT.RADIO);
|
||||
backgroundRdo.setText("Background Color");
|
||||
backgroundRdo.setLayoutData(gd);
|
||||
backgroundRdo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
colorWheelComp.setColor(backgroundClr.getRGB());
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Label displaying the foreground/background colors.
|
||||
*/
|
||||
gd = new GridData();
|
||||
gd.horizontalIndent = 13;
|
||||
fgbgLabel = new Label(colorControlComp, SWT.BORDER);
|
||||
FontData fd = fgbgLabel.getFont().getFontData()[0];
|
||||
protected void createColorControls() {
|
||||
previewLabel = new Label(shell, SWT.BORDER);
|
||||
FontData fd = previewLabel.getFont().getFontData()[0];
|
||||
fd.setHeight(16);
|
||||
fd.setStyle(SWT.BOLD);
|
||||
labelFont = new Font(getDisplay(), fd);
|
||||
fgbgLabel.setFont(labelFont);
|
||||
fgbgLabel.setText(" Sample Text ");
|
||||
fgbgLabel.setLayoutData(gd);
|
||||
previewLabel.setFont(labelFont);
|
||||
previewLabel.setText(" Sample Text ");
|
||||
previewLabel.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true,
|
||||
true));
|
||||
previewLabel.setForeground(foregroundClr);
|
||||
}
|
||||
|
||||
fgbgLabel.setForeground(foregroundClr);
|
||||
fgbgLabel.setBackground(backgroundClr);
|
||||
/**
|
||||
* Create a label that describes the scope of the color change.
|
||||
*/
|
||||
protected void createDescriptionLabel() {
|
||||
descriptionLabel = new Label(shell, SWT.CENTER);
|
||||
descriptionLabel.setText(description);
|
||||
descriptionLabel.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true,
|
||||
true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the bottom OK/Cancel buttons.
|
||||
*/
|
||||
private void createBottomButtons() {
|
||||
protected void createBottomButtons() {
|
||||
Composite buttonComp = new Composite(shell, SWT.NONE);
|
||||
buttonComp.setLayout(new GridLayout(2, false));
|
||||
buttonComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true,
|
||||
|
@ -238,9 +201,7 @@ public class ForegroundBackgroundColorDlg extends CaveSWTDialog implements
|
|||
okBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
RGB[] rgbArray = new RGB[] { foregroundClr.getRGB(),
|
||||
backgroundClr.getRGB() };
|
||||
setReturnValue(rgbArray);
|
||||
collectReturnValue();
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
@ -259,10 +220,18 @@ public class ForegroundBackgroundColorDlg extends CaveSWTDialog implements
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect the return value from fields. Called when user clicks the ok
|
||||
* button.
|
||||
*/
|
||||
protected void collectReturnValue() {
|
||||
setReturnValue(foregroundClr.getRGB());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a separator line to the dialog.
|
||||
*/
|
||||
private void addSeparator() {
|
||||
protected void addSeparator() {
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
Label sepLbl = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
|
||||
sepLbl.setLayoutData(gd);
|
||||
|
@ -277,15 +246,9 @@ public class ForegroundBackgroundColorDlg extends CaveSWTDialog implements
|
|||
*/
|
||||
@Override
|
||||
public void colorChange(RGB rgb, String colorWheelTitle) {
|
||||
if (foregroundRdo.getSelection()) {
|
||||
foregroundClr.dispose();
|
||||
foregroundClr = new Color(getDisplay(), rgb);
|
||||
fgbgLabel.setForeground(foregroundClr);
|
||||
} else {
|
||||
backgroundClr.dispose();
|
||||
backgroundClr = new Color(getDisplay(), rgb);
|
||||
fgbgLabel.setBackground(backgroundClr);
|
||||
}
|
||||
|
||||
foregroundClr.dispose();
|
||||
foregroundClr = new Color(getDisplay(), rgb);
|
||||
previewLabel.setForeground(foregroundClr);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/**
|
||||
* 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.colors;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
||||
|
||||
/**
|
||||
* Interface for color configuration managers to keep track of custom color
|
||||
* settings for users. Colors are tracked by a string key which could be the
|
||||
* user name or attribute (eg site name).
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 08, 2015 3709 bclement Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public interface IColorConfigManager {
|
||||
|
||||
/**
|
||||
* Set display colors
|
||||
*
|
||||
* @param key
|
||||
* @param foreground
|
||||
* @param background
|
||||
*/
|
||||
public void setColors(String key, RGB foreground, RGB background);
|
||||
|
||||
/**
|
||||
* Get display colors
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public ColorInfo getColor(String key);
|
||||
|
||||
/**
|
||||
* @return human readable description of color management
|
||||
*/
|
||||
public String getDescription(String key);
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.raytheon.uf.viz.collaboration.ui;
|
||||
package com.raytheon.uf.viz.collaboration.ui.colors;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -14,7 +14,8 @@ import com.raytheon.uf.common.localization.PathManager;
|
|||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
||||
|
||||
/**
|
||||
* Abstract class for collaboration chat coloring configuration managers
|
||||
|
@ -27,17 +28,24 @@ import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 13, 2014 3709 mapeters Initial creation.
|
||||
* Dec 09, 2014 3709 mapeters setColors() sets foreground and background together.
|
||||
* Jan 09, 2015 3709 bclement renamed from AbstractColorConfigManager
|
||||
* moved colorInfoMap from subclasses to here
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mapeters
|
||||
* @version 1.0
|
||||
*/
|
||||
public abstract class AbstractColorConfigManager {
|
||||
public abstract class PersistentColorConfigManager implements
|
||||
IColorConfigManager {
|
||||
|
||||
protected static final String CONFIG_DIR_NAME = "collaboration";
|
||||
|
||||
private static final SingleTypeJAXBManager<ColorInfoMap> jaxb = SingleTypeJAXBManager
|
||||
.createWithoutException(ColorInfoMap.class);
|
||||
|
||||
private ColorInfoMap colorInfoMap;
|
||||
|
||||
/**
|
||||
* Set and store the given foreground and background colors for the given
|
||||
* user/site at the given file location.
|
||||
|
@ -118,11 +126,11 @@ public abstract class AbstractColorConfigManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
public abstract void setColors(String key, RGB foreground, RGB background);
|
||||
protected ColorInfoMap getColorInfoMap() {
|
||||
return colorInfoMap;
|
||||
}
|
||||
|
||||
public abstract ColorInfo getColor(String key);
|
||||
|
||||
protected abstract ColorInfoMap getColorInfoMap();
|
||||
|
||||
protected abstract void setColorInfoMap(ColorInfoMap colorInfo);
|
||||
protected void setColorInfoMap(ColorInfoMap colorInfo) {
|
||||
this.colorInfoMap = colorInfo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
/**
|
||||
* 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.colors;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
||||
|
||||
/**
|
||||
* Keeps track of custom user color configurations for users in a particular
|
||||
* chat room
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 08, 2015 3709 bclement Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class RoomSpecificColorConfigManager extends
|
||||
PersistentColorConfigManager {
|
||||
|
||||
private static final String ROOM_CONFIG_DIR = CONFIG_DIR_NAME
|
||||
+ IPathManager.SEPARATOR + "roomColors";
|
||||
|
||||
private final String roomId;
|
||||
|
||||
private final String configFilePath;
|
||||
|
||||
/**
|
||||
* @param roomId
|
||||
* @return
|
||||
*/
|
||||
public static RoomSpecificColorConfigManager getManagerForRoom(String roomId) {
|
||||
/*
|
||||
* if multiple managers are created for the same room, it could cause
|
||||
* concurrency issues with writing to localization. This could be solved
|
||||
* with a soft reference cache here. However, since there *should* only
|
||||
* be one of these per room id, it might be overkill
|
||||
*/
|
||||
return new RoomSpecificColorConfigManager(roomId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param roomId
|
||||
*/
|
||||
protected RoomSpecificColorConfigManager(String roomId) {
|
||||
this.roomId = roomId;
|
||||
this.configFilePath = ROOM_CONFIG_DIR + IPathManager.SEPARATOR + roomId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.collaboration.ui.AbstractColorConfigManager#setColors
|
||||
* (java.lang.String, org.eclipse.swt.graphics.RGB,
|
||||
* org.eclipse.swt.graphics.RGB)
|
||||
*/
|
||||
@Override
|
||||
public synchronized void setColors(String participant, RGB foreground,
|
||||
RGB background) {
|
||||
super.setColors(participant, foreground, background, configFilePath);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.collaboration.ui.AbstractColorConfigManager#getColor
|
||||
* (java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized ColorInfo getColor(String participant) {
|
||||
return super.getColor(participant, configFilePath);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager#
|
||||
* getDescription()
|
||||
*/
|
||||
@Override
|
||||
public String getDescription(String key) {
|
||||
VenueParticipant id = IDConverter.convertFromRoom(null, key);
|
||||
VenueId venue = VenueId.fromString(roomId);
|
||||
return "Color changes will apply to the user " + id.getName()
|
||||
+ " only in the " + venue.getName() + " room.";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
/**
|
||||
* 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.colors;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
||||
|
||||
/**
|
||||
* Non-persistent color configuration manager
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 08, 2015 3709 bclement Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class TemporaryColorConfigManager implements IColorConfigManager {
|
||||
|
||||
private final Map<String, ColorInfo> map = new HashMap<String, ColorInfoMap.ColorInfo>();
|
||||
|
||||
private final String roomId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public TemporaryColorConfigManager(String roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager#setColors
|
||||
* (java.lang.String, org.eclipse.swt.graphics.RGB,
|
||||
* org.eclipse.swt.graphics.RGB)
|
||||
*/
|
||||
@Override
|
||||
public void setColors(String key, RGB foreground, RGB background) {
|
||||
ColorInfo info = new ColorInfo();
|
||||
info.setColors(foreground, background);
|
||||
map.put(key, info);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager#getColor
|
||||
* (java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ColorInfo getColor(String key) {
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager#
|
||||
* getDescription()
|
||||
*/
|
||||
@Override
|
||||
public String getDescription(String key) {
|
||||
VenueParticipant id = IDConverter.convertFromRoom(null, key);
|
||||
VenueId venue = VenueId.fromString(roomId);
|
||||
return "Color changes will apply to the user " + id.getName()
|
||||
+ " only in the " + venue.getName() + " room. "
|
||||
+ "\nColor changes will be discarded when you leave the room.";
|
||||
}
|
||||
|
||||
}
|
|
@ -17,15 +17,18 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.collaboration.ui;
|
||||
package com.raytheon.uf.viz.collaboration.ui.colors;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
|
||||
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.ui.colors.ColorInfoMap.ColorInfo;
|
||||
|
||||
/**
|
||||
* User coloring configuration manager
|
||||
* Custom user coloring configuration manager for use where the user's true
|
||||
* identity is known (eg one-to-one chat)
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -34,20 +37,31 @@ import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 13, 2014 3709 mapeters Initial creation.
|
||||
* Nov 26, 2014 3709 mapeters Abstracted out code to {@link AbstractColorConfigManager}.
|
||||
* Nov 26, 2014 3709 mapeters Abstracted out code to {@link PersistentColorConfigManager}.
|
||||
* Dec 08, 2014 3709 mapeters Set foreground and background colors together.
|
||||
* Jan 09, 2015 3709 bclement made into a true singleton, moved colorInfoMap to super
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mapeters
|
||||
* @version 1.0
|
||||
*/
|
||||
public class UserColorConfigManager extends AbstractColorConfigManager {
|
||||
public class UserColorConfigManager extends PersistentColorConfigManager {
|
||||
|
||||
private static final String FILE_PATH = "collaboration"
|
||||
private static final String FILE_PATH = CONFIG_DIR_NAME
|
||||
+ IPathManager.SEPARATOR + "userColorInfo.xml";
|
||||
|
||||
private static ColorInfoMap colorInfoMap;
|
||||
private static UserColorConfigManager instance;
|
||||
|
||||
public static synchronized UserColorConfigManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new UserColorConfigManager();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
protected UserColorConfigManager() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set and store the given colors for the given user.
|
||||
|
@ -73,13 +87,17 @@ public class UserColorConfigManager extends AbstractColorConfigManager {
|
|||
return super.getColor(user, FILE_PATH);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager#
|
||||
* getDescription()
|
||||
*/
|
||||
@Override
|
||||
protected ColorInfoMap getColorInfoMap() {
|
||||
return colorInfoMap;
|
||||
public String getDescription(String key) {
|
||||
UserId id = IDConverter.convertFrom(key);
|
||||
return "Color changes will apply to one-on-one chat sessions with user "
|
||||
+ id.getName() + ".";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setColorInfoMap(ColorInfoMap colorInfoMap) {
|
||||
UserColorConfigManager.colorInfoMap = colorInfoMap;
|
||||
}
|
||||
}
|
|
@ -34,7 +34,6 @@ import org.eclipse.jface.action.ToolBarManager;
|
|||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.ColorDialog;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
@ -73,6 +72,7 @@ import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDr
|
|||
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingToolLayer;
|
||||
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingUIManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.ForegroundColorDlg;
|
||||
import com.raytheon.uf.viz.core.ContextManager;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
|
||||
|
@ -82,6 +82,7 @@ import com.raytheon.uf.viz.core.rsc.IResourceDataChanged;
|
|||
import com.raytheon.uf.viz.core.rsc.capabilities.EditableCapability;
|
||||
import com.raytheon.uf.viz.drawing.DrawingToolLayer;
|
||||
import com.raytheon.uf.viz.drawing.DrawingToolLayer.DrawMode;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
import com.raytheon.viz.ui.input.EditableManager;
|
||||
|
||||
/**
|
||||
|
@ -107,6 +108,7 @@ import com.raytheon.viz.ui.input.EditableManager;
|
|||
* May 05, 2014 3076 bclement added clear all action
|
||||
* Jun 30, 2014 1798 bclement added disableCurrentLayer()
|
||||
* Dev 02, 2014 3709 mapeters added {@link #initComponents()} override
|
||||
* Jan 09, 2015 3709 bclement now uses ForegroundColorDlg for consistency
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -248,6 +250,29 @@ public class CollaborationSessionView extends SessionView implements
|
|||
super.initComponents(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback used in the change color action. Gets the new color from the
|
||||
* dialog and sends a color change event to the session
|
||||
*/
|
||||
private final ICloseCallback colorChangeCallback = new ICloseCallback() {
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue != null && returnValue instanceof RGB) {
|
||||
RGB rgb = (RGB) returnValue;
|
||||
IStructuredSelection selection = (IStructuredSelection) usersTable
|
||||
.getSelection();
|
||||
VenueParticipant entry = (VenueParticipant) selection
|
||||
.getFirstElement();
|
||||
ColorChangeEvent event = new ColorChangeEvent(entry, rgb);
|
||||
try {
|
||||
session.sendObjectToVenue(event);
|
||||
} catch (CollaborationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to send color change to venue", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void createActions() {
|
||||
super.createActions();
|
||||
|
@ -256,22 +281,12 @@ public class CollaborationSessionView extends SessionView implements
|
|||
IconUtil.getImageDescriptor(bundle, "change_color.gif")) {
|
||||
@Override
|
||||
public void run() {
|
||||
ColorDialog dlg = new ColorDialog(Display.getCurrent()
|
||||
.getActiveShell());
|
||||
RGB rgb = dlg.open();
|
||||
if (rgb != null) {
|
||||
IStructuredSelection selection = (IStructuredSelection) usersTable
|
||||
.getSelection();
|
||||
VenueParticipant entry = (VenueParticipant) selection
|
||||
.getFirstElement();
|
||||
ColorChangeEvent event = new ColorChangeEvent(entry, rgb);
|
||||
try {
|
||||
session.sendObjectToVenue(event);
|
||||
} catch (CollaborationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to send color change to venue", e);
|
||||
}
|
||||
}
|
||||
ForegroundColorDlg dlg = new ForegroundColorDlg(Display
|
||||
.getCurrent().getActiveShell(),
|
||||
"Color changes will be seen by all participants of the "
|
||||
+ session.getVenueName() + " session.");
|
||||
dlg.setCloseCallback(colorChangeCallback);
|
||||
dlg.open();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -49,10 +49,10 @@ import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationC
|
|||
import com.raytheon.uf.viz.collaboration.comm.provider.user.RosterItem;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
||||
import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
|
||||
import com.raytheon.uf.viz.collaboration.ui.UserColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeTextColorAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.PrintLogActionContributionItem;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.UserColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.notifier.NotifierTask;
|
||||
import com.raytheon.uf.viz.collaboration.ui.notifier.NotifierTools;
|
||||
import com.raytheon.uf.viz.core.sounds.SoundUtil;
|
||||
|
@ -77,6 +77,7 @@ import com.raytheon.uf.viz.core.sounds.SoundUtil;
|
|||
* Dec 08, 2014 3709 mapeters move color change actions to menu bar.
|
||||
* Dec 12, 2014 3709 mapeters Store {@link ChangeTextColorAction}s as fields,
|
||||
* dispose them.
|
||||
* Jan 09, 2015 3709 bclement color config manager API changes
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -241,7 +242,7 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
if (userId != null) {
|
||||
// get user colors from config manager
|
||||
ColorInfo userColor = colorConfigManager.getColor(userId
|
||||
.getName());
|
||||
.getFQName());
|
||||
if (userColor != null) {
|
||||
fgColor = getColorFromRGB(userColor.getColor(SWT.FOREGROUND));
|
||||
bgColor = getColorFromRGB(userColor.getColor(SWT.BACKGROUND));
|
||||
|
@ -329,7 +330,7 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
@Override
|
||||
protected void initComponents(Composite parent) {
|
||||
super.initComponents(parent);
|
||||
colorConfigManager = new UserColorConfigManager();
|
||||
colorConfigManager = UserColorConfigManager.getInstance();
|
||||
|
||||
// unfortunately this code cannot be a part of createToolbarButton
|
||||
// because I cannot instantiate the ACI until after the messagesText
|
||||
|
@ -398,11 +399,10 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
*/
|
||||
private void createDropDownMenu() {
|
||||
IMenuManager mgr = getViewSite().getActionBars().getMenuManager();
|
||||
String myName = CollaborationConnection.getConnection().getUser()
|
||||
.getName();
|
||||
UserId myUser = CollaborationConnection.getConnection().getUser();
|
||||
RGB defaultUserForeground = DEFAULT_USER_FOREGROUND_COLOR.getRGB();
|
||||
userColorAction = ChangeTextColorAction
|
||||
.createChangeUserTextColorAction(myName, true, true,
|
||||
.createChangeUserTextColorAction(myUser, true, true,
|
||||
defaultUserForeground, colorConfigManager);
|
||||
mgr.add(userColorAction);
|
||||
}
|
||||
|
@ -412,10 +412,9 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
*/
|
||||
public void addChangePeerColorAction() {
|
||||
IMenuManager mgr = getViewSite().getActionBars().getMenuManager();
|
||||
String peerName = peer.getName();
|
||||
RGB defaultPeerForeground = DEFAULT_PEER_FOREGROUND_COLOR.getRGB();
|
||||
peerColorAction = ChangeTextColorAction
|
||||
.createChangeUserTextColorAction(peerName, false, true,
|
||||
.createChangeUserTextColorAction(peer, false, true,
|
||||
defaultPeerForeground, colorConfigManager);
|
||||
mgr.add(peerColorAction);
|
||||
}
|
||||
|
|
|
@ -43,10 +43,10 @@ import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformatio
|
|||
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
|
||||
import com.raytheon.uf.viz.collaboration.ui.FeedColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.SiteConfigurationManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeTextColorAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.FeedColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
||||
|
||||
/**
|
||||
|
@ -79,6 +79,7 @@ import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
|||
* Dec 08, 2014 3709 mapeters Removed ChangeSiteColorAction, uses {@link ChangeTextColorAction}.
|
||||
* Dec 12, 2014 3709 mapeters Store {@link ChangeTextColorAction}s in map, dispose them.
|
||||
* Jan 05, 2015 3709 mapeters Use both site and user name as key in siteColorActions map.
|
||||
* Jan 09, 2015 3709 bclement color config manager API changes
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -131,7 +132,7 @@ public class SessionFeedView extends SessionView {
|
|||
enableUserColors = false;
|
||||
super.initComponents(parent);
|
||||
|
||||
colorConfigManager = new FeedColorConfigManager();
|
||||
colorConfigManager = FeedColorConfigManager.getInstance();
|
||||
usersTable.refresh();
|
||||
|
||||
siteColorActions = new HashMap<>();
|
||||
|
|
|
@ -83,11 +83,13 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
|||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
||||
import com.raytheon.uf.viz.collaboration.display.data.SessionColorManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
|
||||
import com.raytheon.uf.viz.collaboration.ui.UserColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeTextColorAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.PeerToPeerChatAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.PrintLogActionContributionItem;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.RoomSpecificColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.colors.TemporaryColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.core.sounds.SoundUtil;
|
||||
|
@ -122,6 +124,7 @@ import com.raytheon.uf.viz.core.sounds.SoundUtil;
|
|||
* use parent's colors map.
|
||||
* Dec 02, 2014 3709 mapeters added color actions for group chats without shared display.
|
||||
* Dec 12, 2014 3709 mapeters Store {@link ChangeTextColorAction}s in map, dispose them.
|
||||
* Jan 09, 2015 3709 bclement color config manager API changes
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -155,7 +158,7 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
|||
|
||||
protected SessionColorManager colorManager;
|
||||
|
||||
private static UserColorConfigManager colorConfigManager;
|
||||
private IColorConfigManager colorConfigManager;
|
||||
|
||||
private Map<String, ChangeTextColorAction> userColorActions;
|
||||
|
||||
|
@ -183,7 +186,14 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
|||
initColorManager();
|
||||
super.initComponents(parent);
|
||||
if (enableUserColors) {
|
||||
colorConfigManager = new UserColorConfigManager();
|
||||
IVenue venue = session.getVenue();
|
||||
if (venue.isPersistent()) {
|
||||
colorConfigManager = RoomSpecificColorConfigManager
|
||||
.getManagerForRoom(venue.getId());
|
||||
} else {
|
||||
colorConfigManager = new TemporaryColorConfigManager(
|
||||
venue.getId());
|
||||
}
|
||||
userColorActions = new HashMap<>();
|
||||
}
|
||||
|
||||
|
@ -241,14 +251,15 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
|||
}
|
||||
if (enableUserColors) {
|
||||
// add color actions if in group chat room without shared display
|
||||
String user = entry.getName();
|
||||
String colorActionKey = entry.getFQName();
|
||||
RGB defaultForeground = colorManager.getColorForUser(entry);
|
||||
ChangeTextColorAction userColorAction = userColorActions.get(user);
|
||||
ChangeTextColorAction userColorAction = userColorActions
|
||||
.get(colorActionKey);
|
||||
if (userColorAction == null) {
|
||||
userColorAction = ChangeTextColorAction
|
||||
.createChangeUserTextColorAction(user, me, me,
|
||||
.createChangeUserTextColorAction(entry, me, me,
|
||||
defaultForeground, colorConfigManager);
|
||||
userColorActions.put(user, userColorAction);
|
||||
userColorActions.put(colorActionKey, userColorAction);
|
||||
}
|
||||
manager.add(userColorAction);
|
||||
}
|
||||
|
@ -522,9 +533,10 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
|||
protected void styleAndAppendText(StringBuilder sb, int offset,
|
||||
String name, VenueParticipant userId, List<StyleRange> ranges,
|
||||
Color fgColor, Color bgColor, String subject) {
|
||||
if (enableUserColors && name != null) {
|
||||
if (enableUserColors && userId != null) {
|
||||
// Color text by user if in group chat room without shared display
|
||||
ColorInfo userColor = colorConfigManager.getColor(name);
|
||||
ColorInfo userColor = colorConfigManager.getColor(userId
|
||||
.getFQName());
|
||||
if (userColor != null) {
|
||||
fgColor = getColorFromRGB(userColor.getColor(SWT.FOREGROUND));
|
||||
bgColor = getColorFromRGB(userColor.getColor(SWT.BACKGROUND));
|
||||
|
|
Loading…
Add table
Reference in a new issue