Issue #642 add ability for keywords in collaboration

Former-commit-id: d8e64039dc [formerly 098e51414d1c148e55e6dd17b0f7b8d579f204fd]
Former-commit-id: 4e9b3ca786
This commit is contained in:
Matt Nash 2012-05-18 10:30:49 -05:00
parent f28f51f5a5
commit 3a3d320eb4
15 changed files with 859 additions and 88 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View file

@ -1,6 +1,6 @@
Manifest-Version: 1.0 Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: Plugin Bundle-Name: Collaboration UI Plugin
Bundle-SymbolicName: com.raytheon.uf.viz.collaboration.ui;singleton:=true Bundle-SymbolicName: com.raytheon.uf.viz.collaboration.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.raytheon.uf.viz.collaboration.ui.Activator Bundle-Activator: com.raytheon.uf.viz.collaboration.ui.Activator

View file

@ -179,5 +179,10 @@
class="com.raytheon.uf.viz.collaboration.ui.prefs.CollaborationPreferencePage" class="com.raytheon.uf.viz.collaboration.ui.prefs.CollaborationPreferencePage"
id="com.raytheon.uf.viz.collaboration.ui.prefs.collaborationpreferencepage" id="com.raytheon.uf.viz.collaboration.ui.prefs.collaborationpreferencepage"
name="Collaboration"/> name="Collaboration"/>
<page
class="com.raytheon.uf.viz.collaboration.ui.prefs.CollaborationAlertWordsPreferencePage"
id="com.raytheon.uf.viz.collaboration.ui.prefs.collaborationalertwordspreferencepage"
name="Significant Words"
category="com.raytheon.uf.viz.collaboration.ui.prefs.collaborationpreferencepage"/>
</extension> </extension>
</plugin> </plugin>

View file

@ -0,0 +1,164 @@
/**
* 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.data;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 16, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
@DynamicSerialize
public class AlertWord {
@DynamicSerializeElement
private String text;
@DynamicSerializeElement
private Integer red;
@DynamicSerializeElement
private Integer green;
@DynamicSerializeElement
private Integer blue;
@DynamicSerializeElement
private String soundPath;
@DynamicSerializeElement
private String font;
public AlertWord() {
}
public AlertWord(String text, RGB color) {
this.text = text;
red = color.red;
green = color.green;
blue = color.blue;
}
/**
* @return the text
*/
public String getText() {
return text;
}
/**
* @param text
* the text to set
*/
public void setText(String text) {
this.text = text;
}
/**
* @return the red
*/
public Integer getRed() {
return red;
}
/**
* @param red
* the red to set
*/
public void setRed(Integer red) {
this.red = red;
}
/**
* @return the green
*/
public Integer getGreen() {
return green;
}
/**
* @param green
* the green to set
*/
public void setGreen(Integer green) {
this.green = green;
}
/**
* @return the blue
*/
public Integer getBlue() {
return blue;
}
/**
* @param blue
* the blue to set
*/
public void setBlue(Integer blue) {
this.blue = blue;
}
/**
* @return the soundPath
*/
public String getSoundPath() {
return soundPath;
}
/**
* @param soundPath
* the soundPath to set
*/
public void setSoundPath(String soundPath) {
this.soundPath = soundPath;
}
/**
* @return the font
*/
public String getFont() {
return font;
}
/**
* @param font
* the font to set
*/
public void setFont(String font) {
this.font = font;
}
}

View file

@ -0,0 +1,62 @@
/**
* 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.data;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 16, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
@DynamicSerialize
public class AlertWordWrapper {
@DynamicSerializeElement
private AlertWord[] alertWords;
/**
* @return the alertWords
*/
public AlertWord[] getAlertWords() {
return alertWords;
}
/**
* @param alertWords
* the alertWords to set
*/
public void setAlertWords(AlertWord[] alertWords) {
this.alertWords = alertWords;
}
}

View file

@ -25,6 +25,7 @@ import gov.noaa.nws.ncep.ui.pgen.PgenUtil;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -105,6 +106,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; 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.IDConverter;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.data.AlertWordWrapper;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.data.CollaborationGroupContainer; import com.raytheon.uf.viz.collaboration.data.CollaborationGroupContainer;
import com.raytheon.uf.viz.collaboration.data.SessionContainer; import com.raytheon.uf.viz.collaboration.data.SessionContainer;
@ -1225,6 +1227,18 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
}); });
} }
@Subscribe
public void addAlertWords(AlertWordWrapper words) {
for (IViewReference ref : getViewSite().getWorkbenchWindow()
.getActivePage().getViewReferences()) {
IViewPart viewPart = ref.getView(false);
if (viewPart instanceof AbstractSessionView) {
((AbstractSessionView) viewPart).setAlertWords(Arrays
.asList(words.getAlertWords()));
}
}
}
@Subscribe @Subscribe
public void handleRosterChangeEvent(IRosterChangeEvent rosterChangeEvent) { public void handleRosterChangeEvent(IRosterChangeEvent rosterChangeEvent) {
final IRosterItem rosterItem = rosterChangeEvent.getItem(); final IRosterItem rosterItem = rosterChangeEvent.getItem();

View file

@ -23,6 +23,7 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import javax.xml.bind.JAXB; import javax.xml.bind.JAXB;
@ -55,6 +56,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter; 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.UserId;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserIdWrapper; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserIdWrapper;
import com.raytheon.uf.viz.collaboration.data.AlertWord;
import com.raytheon.uf.viz.collaboration.data.AlertWordWrapper;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.core.icon.IconUtil; import com.raytheon.uf.viz.core.icon.IconUtil;
@ -243,4 +246,46 @@ public class CollaborationUtils {
return result.toString(); return result.toString();
} }
public static List<AlertWord> getAlertWords() {
LocalizationFile file = null;
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext context = pm.getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
file = PathManagerFactory.getPathManager().getLocalizationFile(context,
"collaboration" + File.separator + "alertWords.xml");
if (file.exists()) {
AlertWordWrapper words = (AlertWordWrapper) JAXB.unmarshal(
file.getFile(), AlertWordWrapper.class);
if (words.getAlertWords() == null) {
return new ArrayList<AlertWord>();
} else {
List<AlertWord> alertWords = new ArrayList<AlertWord>();
for (int i = 0; i < words.getAlertWords().length; i++) {
alertWords.add(words.getAlertWords()[i]);
}
return alertWords;
}
} else {
return new ArrayList<AlertWord>();
}
}
public static void saveAlertWords(List<AlertWord> words) {
LocalizationFile file = null;
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext context = pm.getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
file = PathManagerFactory.getPathManager().getLocalizationFile(context,
"collaboration" + File.separator + "alertWords.xml");
AlertWordWrapper wrapper = new AlertWordWrapper();
wrapper.setAlertWords(words.toArray(new AlertWord[0]));
JAXB.marshal(wrapper, file.getFile());
try {
file.save();
} catch (LocalizationOpFailedException e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to save alert words to localization", e);
}
}
} }

View file

@ -0,0 +1,239 @@
/**
* 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.prefs;
import java.util.List;
import org.eclipse.jface.preference.ColorFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.FileFieldEditor;
import org.eclipse.jface.preference.FontFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
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.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.data.AlertWord;
import com.raytheon.uf.viz.collaboration.data.AlertWordWrapper;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 17, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class CollaborationAlertWordsPreferencePage extends
FieldEditorPreferencePage implements IWorkbenchPreferencePage {
private TableViewer viewer = null;
/**
*
*/
public CollaborationAlertWordsPreferencePage() {
super(GRID);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
* ()
*/
@Override
protected void createFieldEditors() {
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
data.horizontalSpan = 3;
viewer = new TableViewer(getFieldEditorParent());
viewer.setContentProvider(new CollaborationPreferenceContentProvider());
viewer.setLabelProvider(new CollaborationPreferencesLabelProvider());
viewer.setInput(CollaborationUtils.getAlertWords());
viewer.getTable().setLayoutData(data);
final StringFieldEditor stringEditor = new StringFieldEditor(
"significantword", "Word", getFieldEditorParent()) {
@Override
protected void doLoad() {
super.doLoad();
this.setStringValue("");
}
};
this.addField(stringEditor);
final ColorFieldEditor colorEditor = new ColorFieldEditor(
"coloreditor", "Color", getFieldEditorParent());
this.addField(colorEditor);
colorEditor.loadDefault();
final FontFieldChangeEditor fontEditor = new FontFieldChangeEditor(
"fonts", "Font", getFieldEditorParent());
this.addField(fontEditor);
final FileFieldEditor fileEditor = new FileFieldEditor("fileeditor",
"Sound File", getFieldEditorParent());
this.addField(fileEditor);
Composite buttonComp = new Composite(getFieldEditorParent(), SWT.NONE);
buttonComp.setLayout(new GridLayout(3, false));
data = new GridData(SWT.FILL, SWT.FILL, true, true);
data.horizontalSpan = 3;
buttonComp.setLayoutData(data);
Button saveButton = new Button(buttonComp, SWT.PUSH);
saveButton.setText("Save Current");
saveButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (!stringEditor.getStringValue().isEmpty()) {
AlertWord word = new AlertWord(stringEditor
.getStringValue(), colorEditor.getColorSelector()
.getColorValue());
int index = viewer.getTable().getSelectionIndex();
word.setSoundPath(fileEditor.getStringValue());
word.setFont(fontEditor
.getFontValue(getFieldEditorParent()));
((List<AlertWord>) viewer.getInput()).set(index, word);
viewer.refresh();
}
}
});
data = new GridData(SWT.NONE, SWT.NONE, false, true);
saveButton.setLayoutData(data);
Button addButton = new Button(buttonComp, SWT.PUSH);
addButton.setText("Add New");
addButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (!stringEditor.getStringValue().isEmpty()) {
AlertWord word = new AlertWord(stringEditor
.getStringValue(), colorEditor.getColorSelector()
.getColorValue());
word.setSoundPath(fileEditor.getStringValue());
word.setFont(fontEditor
.getFontValue(getFieldEditorParent()));
word.setSoundPath(fileEditor.getStringValue());
((List<AlertWord>) viewer.getInput()).add(word);
viewer.refresh();
}
}
});
data = new GridData(SWT.NONE, SWT.NONE, false, true);
addButton.setLayoutData(data);
Button removeButton = new Button(buttonComp, SWT.PUSH);
removeButton.setText("Remove Current");
removeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) viewer
.getSelection();
if (selection != null) {
AlertWord word = (AlertWord) selection.getFirstElement();
((List<AlertWord>) viewer.getInput()).remove(word);
viewer.refresh();
}
}
});
data = new GridData(SWT.NONE, SWT.NONE, false, true);
removeButton.setLayoutData(data);
viewer.getTable().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
AlertWord word = (AlertWord) e.item.getData();
colorEditor.getColorSelector()
.setColorValue(
new RGB(word.getRed(), word.getGreen(), word
.getBlue()));
stringEditor.setStringValue(word.getText());
fontEditor.setFontValue(word.getFont(), getFieldEditorParent());
fileEditor.setStringValue(word.getSoundPath());
}
});
}
private class FontFieldChangeEditor extends FontFieldEditor {
public FontFieldChangeEditor(String name, String text, Composite parent) {
super(name, text, parent);
}
public String getFontValue(Composite parent) {
return getValueControl(parent).getText();
}
public void setFontValue(String string, Composite parent) {
getValueControl(parent).setText(string);
doLoad();
}
}
public boolean performOk() {
List<AlertWord> words = (List<AlertWord>) viewer.getInput();
CollaborationUtils.saveAlertWords(words);
AlertWordWrapper wrapper = new AlertWordWrapper();
wrapper.setAlertWords(words.toArray(new AlertWord[0]));
CollaborationConnection connection = CollaborationDataManager
.getInstance().getCollaborationConnection(false);
if (connection != null && connection.isConnected()) {
connection.getEventPublisher().post(wrapper);
}
return true;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
@Override
public void init(IWorkbench workbench) {
setPreferenceStore(Activator.getDefault().getPreferenceStore());
setDescription("Significant Words");
}
}

View file

@ -0,0 +1,65 @@
/**
* 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.prefs;
import java.util.List;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 17, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class CollaborationPreferenceContentProvider implements
IStructuredContentProvider {
@Override
public void dispose() {
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
oldInput = newInput;
viewer.refresh();
}
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof List<?>) {
List<?> list = (List<?>) inputElement;
return list.toArray();
}
return null;
}
}

View file

@ -19,9 +19,6 @@
**/ **/
package com.raytheon.uf.viz.collaboration.ui.prefs; package com.raytheon.uf.viz.collaboration.ui.prefs;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditor; import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.FieldEditorPreferencePage;
@ -50,11 +47,8 @@ import com.raytheon.uf.viz.collaboration.ui.Activator;
public class CollaborationPreferencePage extends FieldEditorPreferencePage public class CollaborationPreferencePage extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage { implements IWorkbenchPreferencePage {
private List<FieldEditor> editors = null;
public CollaborationPreferencePage() { public CollaborationPreferencePage() {
super(GRID); super(GRID);
editors = new ArrayList<FieldEditor>();
} }
/* /*
@ -69,19 +63,6 @@ public class CollaborationPreferencePage extends FieldEditorPreferencePage
setDescription("Collaboration User Interface Preferences"); setDescription("Collaboration User Interface Preferences");
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
*/
@Override
public boolean performOk() {
for (FieldEditor editor : editors) {
editor.store();
}
return super.performOk();
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -91,33 +72,8 @@ public class CollaborationPreferencePage extends FieldEditorPreferencePage
*/ */
@Override @Override
protected void createFieldEditors() { protected void createFieldEditors() {
FieldEditor notifications = new BooleanFieldEditor("notifications", FieldEditor notifications = new BooleanFieldEditor("notifications",
"Show Notifications", getFieldEditorParent()); "Show Notifications", getFieldEditorParent());
this.addField(notifications); this.addField(notifications);
// ListEditor significant = new ListEditor("significantwords",
// "Significant Words", getFieldEditorParent()) {
//
// @Override
// protected String[] parseString(String stringList) {
// return new String[0];
// }
//
// @Override
// protected String getNewInputObject() {
// return "STRING";
// }
//
// @Override
// protected String createList(String[] items) {
// return "TEST";
// }
// };
// significant.getButtonBoxControl(getFieldEditorParent()).getChildren()[2]
// .setVisible(false);
// significant.getButtonBoxControl(getFieldEditorParent()).getChildren()[3]
// .setVisible(false);
// this.addField(significant);
} }
} }

View file

@ -0,0 +1,108 @@
/**
* 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.prefs;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.resource.StringConverter;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Display;
import com.raytheon.uf.viz.collaboration.data.AlertWord;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 17, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class CollaborationPreferencesLabelProvider extends ColumnLabelProvider {
private List<Color> colors = null;
private List<Font> fonts = null;
/**
*
*/
public CollaborationPreferencesLabelProvider() {
colors = new ArrayList<Color>();
fonts = new ArrayList<Font>();
}
@Override
public String getText(Object element) {
AlertWord word = (AlertWord) element;
return word.getText();
}
@Override
public Color getForeground(Object element) {
AlertWord word = (AlertWord) element;
Color color = new Color(Display.getCurrent(), word.getRed(),
word.getGreen(), word.getBlue());
colors.add(color);
return color;
}
@Override
public Font getFont(Object element) {
AlertWord word = (AlertWord) element;
String fontString = word.getFont();
Font font = null;
if (fontString != null) {
FontData data = StringConverter.asFontData(fontString);
font = new Font(Display.getCurrent(), data);
fonts.add(font);
}
return font;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.BaseLabelProvider#dispose()
*/
@Override
public void dispose() {
for (Font font : fonts) {
font.dispose();
}
for (Color color : colors) {
color.dispose();
}
super.dispose();
}
}

View file

@ -19,13 +19,19 @@
**/ **/
package com.raytheon.uf.viz.collaboration.ui.session; package com.raytheon.uf.viz.collaboration.ui.session;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.jface.resource.StringConverter;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyleRange;
@ -35,7 +41,11 @@ import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.TextStyle;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
@ -44,8 +54,17 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService; import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
import sun.audio.AudioData;
import sun.audio.AudioDataStream;
import sun.audio.AudioPlayer;
import sun.audio.AudioStream;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.collaboration.comm.identity.IMessage; import com.raytheon.uf.viz.collaboration.comm.identity.IMessage;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.data.AlertWord;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.ui.Activator; import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils; import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
@ -71,6 +90,9 @@ import com.raytheon.uf.viz.notification.notifier.PopupNotifier;
*/ */
public abstract class AbstractSessionView extends ViewPart { public abstract class AbstractSessionView extends ViewPart {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(AbstractSessionView.class);
private static final String SESSION_IMAGE_KEY = "sessionId.key"; private static final String SESSION_IMAGE_KEY = "sessionId.key";
/** /**
@ -90,6 +112,14 @@ public abstract class AbstractSessionView extends ViewPart {
private UserId[] userIds = null; private UserId[] userIds = null;
private SessionMsgArchive msgArchive; private SessionMsgArchive msgArchive;
private List<AlertWord> alertWords = null;
private AudioDataStream ads = null;
private Map<String, Font> fonts = null;
private Map<RGB, Color> colors = null;
protected abstract String getSessionImageName(); protected abstract String getSessionImageName();
@ -102,6 +132,8 @@ public abstract class AbstractSessionView extends ViewPart {
public AbstractSessionView() { public AbstractSessionView() {
imageMap = new HashMap<String, Image>(); imageMap = new HashMap<String, Image>();
userIds = CollaborationUtils.getIds(); userIds = CollaborationUtils.getIds();
fonts = new HashMap<String, Font>();
colors = new HashMap<RGB, Color>();
} }
protected void initComponents(Composite parent) { protected void initComponents(Composite parent) {
@ -262,25 +294,59 @@ public abstract class AbstractSessionView extends ViewPart {
// here is the place to put the font and color changes for keywords // here is the place to put the font and color changes for keywords
// read in localization file once and then don't read in again, per // read in localization file once and then don't read in again, per
// chat room? // chat room?
Collection<String> alertWords = findAlertWords(sb, List<AlertWord> alertWords = retrieveAlertWords();
offset + name.length() + 2);
List<StyleRange> ranges = new ArrayList<StyleRange>(); List<StyleRange> ranges = new ArrayList<StyleRange>();
if (alertWords != null) { if (alertWords != null) {
for (String keyword : alertWords) { for (AlertWord keyword : alertWords) {
if (sb.toString().toLowerCase().contains(keyword.toLowerCase())) { if (sb.toString().toLowerCase()
StyleRange keywordRange = new StyleRange( .contains(keyword.getText().toLowerCase())) {
messagesText.getCharCount() Font font = null;
+ sb.toString().toLowerCase() if (fonts.containsKey(keyword.getFont())) {
.indexOf(keyword.toLowerCase()), font = fonts.get(keyword.getFont());
keyword.length(), null, null, SWT.BOLD | SWT.ITALIC); } else {
FontData fd = StringConverter.asFontData(keyword
.getFont());
font = new Font(Display.getCurrent(), fd);
fonts.put(keyword.getFont(), font);
}
RGB rgb = new RGB(keyword.getRed(), keyword.getGreen(),
keyword.getBlue());
Color color = null;
if (colors.containsKey(rgb)) {
color = colors.get(rgb);
} else {
color = new Color(Display.getCurrent(), rgb);
colors.put(rgb, color);
}
TextStyle style = new TextStyle(font, color, null);
StyleRange keywordRange = new StyleRange(style);
keywordRange.start = messagesText.getCharCount()
+ sb.toString().toLowerCase()
.indexOf(keyword.getText().toLowerCase());
keywordRange.length = keyword.getText().length();
// compare to see if this position is already styled
// List<StyleRange> rnges = new ArrayList<StyleRange>();
// rnges.addAll(ranges);
// for (StyleRange range : rnges) {
// if (range.start >= keywordRange.start
// && (range.start + range.length) >= (keywordRange.start))
// {
// if (range.length < keywordRange.length) {
// ranges.remove(range);
// ranges.add(keywordRange);
// } else {
// ranges.add(keywordRange);
// }
// }
// }
ranges.add(keywordRange); ranges.add(keywordRange);
executeSightsSounds(keyword);
} }
} }
} }
styleAndAppendText(sb, offset, name, userId, ranges); styleAndAppendText(sb, offset, name, userId, ranges);
// room for other fun things here, such as sounds and such
executeSightsSounds();
if (msgArchive == null) { if (msgArchive == null) {
msgArchive = getMessageArchive(); msgArchive = getMessageArchive();
} }
@ -297,16 +363,68 @@ public abstract class AbstractSessionView extends ViewPart {
* @param offset * @param offset
* @return alertWords * @return alertWords
*/ */
protected Collection<String> findAlertWords(StringBuilder builder, protected List<AlertWord> retrieveAlertWords() {
int offset) { if (alertWords == null) {
return null; alertWords = CollaborationUtils.getAlertWords();
}
return alertWords;
} }
/** /**
* Place holder must override to do something. * Place holder must override to do something.
*/ */
protected void executeSightsSounds() { protected void executeSightsSounds(AlertWord word) {
// placeholder for future things String filename = word.getSoundPath();
if (filename == null || filename.isEmpty()) {
return;
}
File soundFile = new File(filename);
InputStream in;
AudioStream as = null;
AudioData data = null;
try {
if (ads != null) {
AudioPlayer.player.stop(ads);
}
in = new FileInputStream(soundFile);
as = new AudioStream(in);
data = as.getData();
ads = new AudioDataStream(data);
Field field = null;
try {
field = AudioPlayer.player.getClass().getDeclaredField("DEBUG");
field.setAccessible(true);
field.setBoolean(field, true);
} catch (SecurityException e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
} catch (NoSuchFieldException e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
AudioPlayer.player.start(ads);
} catch (FileNotFoundException e) {
statusHandler.handle(Priority.PROBLEM, "Unable to find sound file",
e);
} catch (IOException e) {
statusHandler.handle(Priority.PROBLEM, "Unable to read sound file",
e);
}
System.out.println("\n\nNew\n\n");
} }
/* /*
@ -328,12 +446,23 @@ public abstract class AbstractSessionView extends ViewPart {
for (Image im : imageMap.values()) { for (Image im : imageMap.values()) {
im.dispose(); im.dispose();
} }
for (Font font : fonts.values()) {
font.dispose();
}
for (Color color : colors.values()) {
color.dispose();
}
imageMap.clear(); imageMap.clear();
imageMap = null; imageMap = null;
if (msgArchive != null) { alertWords = null;
if (msgArchive != null) {
msgArchive.close(); msgArchive.close();
msgArchive = null; msgArchive = null;
} }
super.dispose(); super.dispose();
} }
@ -374,5 +503,9 @@ public abstract class AbstractSessionView extends ViewPart {
this.userIds = userIds; this.userIds = userIds;
} }
public void setAlertWords(List<AlertWord> words) {
alertWords = words;
}
protected abstract SessionMsgArchive getMessageArchive(); protected abstract SessionMsgArchive getMessageArchive();
} }

View file

@ -20,8 +20,6 @@ package com.raytheon.uf.viz.collaboration.ui.session;
* further licensing information. * further licensing information.
**/ **/
import java.util.Collection;
import org.eclipse.ecf.presence.roster.IRosterEntry; import org.eclipse.ecf.presence.roster.IRosterEntry;
import org.eclipse.ecf.presence.roster.RosterEntry; import org.eclipse.ecf.presence.roster.RosterEntry;
import org.eclipse.jface.action.Action; import org.eclipse.jface.action.Action;
@ -260,24 +258,6 @@ public class CollaborationSessionView extends SessionView {
return COLLABORATION_SESSION_IMAGE_NAME; return COLLABORATION_SESSION_IMAGE_NAME;
} }
@Override
protected Collection<String> findAlertWords(StringBuilder builder,
int offset) {
// TODO
// 1) if needed read in localized list of key words/sounds
// 2) search builder starting at offset for key works. besides the key
// words found may also want to return the location(s) of where they are
// found along with the sound to used.
return super.findAlertWords(builder, offset);
}
@Override
protected void executeSightsSounds() {
// TODO From the alert words found determine what sound to play and for
// how long?
super.executeSightsSounds();
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *

View file

@ -667,7 +667,8 @@ public class SessionView extends AbstractSessionView {
List<IRosterEntry> users = (List<IRosterEntry>) usersTable.getInput(); List<IRosterEntry> users = (List<IRosterEntry>) usersTable.getInput();
if (users != null) { if (users != null) {
for (IRosterEntry entry : users) { for (IRosterEntry entry : users) {
if (entry.getUser().equals(participant)) { UserId id = IDConverter.convertFrom(entry.getUser());
if (id.equals(participant)) {
((RosterEntry) entry).setPresence(presence); ((RosterEntry) entry).setPresence(presence);
usersTable.refresh(entry); usersTable.refresh(entry);
} }

View file

@ -117,9 +117,6 @@ public class PathToolbar extends CaveSWTDialog {
protected PathToolbar(Shell parentShell) { protected PathToolbar(Shell parentShell) {
super(parentShell, SWT.DIALOG_TRIM | CAVE.DO_NOT_BLOCK); super(parentShell, SWT.DIALOG_TRIM | CAVE.DO_NOT_BLOCK);
setText("Drawing"); setText("Drawing");
lastTool = VizPerspectiveListener.getCurrentPerspectiveManager()
.getToolManager().getSelectedModalTool(EDIT_TOOL_CATEGY);
} }
/* /*
@ -131,6 +128,8 @@ public class PathToolbar extends CaveSWTDialog {
*/ */
@Override @Override
protected void initializeComponents(Shell shell) { protected void initializeComponents(Shell shell) {
lastTool = VizPerspectiveListener.getCurrentPerspectiveManager()
.getToolManager().getSelectedModalTool(EDIT_TOOL_CATEGY);
shell.addShellListener(new ShellAdapter() { shell.addShellListener(new ShellAdapter() {
@Override @Override
public void shellClosed(ShellEvent e) { public void shellClosed(ShellEvent e) {