From 3a3d320eb4bee34417d6bb28641c2b000032ad72 Mon Sep 17 00:00:00 2001 From: Matt Nash Date: Fri, 18 May 2012 10:30:49 -0500 Subject: [PATCH] Issue #642 add ability for keywords in collaboration Former-commit-id: d8e64039dc4157e464c1788eabdfbca6fd39ecec [formerly 098e51414d1c148e55e6dd17b0f7b8d579f204fd] Former-commit-id: 4e9b3ca786b454ccf58b58b3a69764469abd88be --- .../.classpath | 2 +- .../META-INF/MANIFEST.MF | 2 +- .../plugin.xml | 5 + .../uf/viz/collaboration/data/AlertWord.java | 164 ++++++++++++ .../collaboration/data/AlertWordWrapper.java | 62 +++++ .../ui/CollaborationGroupView.java | 14 + .../collaboration/ui/CollaborationUtils.java | 45 ++++ ...CollaborationAlertWordsPreferencePage.java | 239 ++++++++++++++++++ ...ollaborationPreferenceContentProvider.java | 65 +++++ .../ui/prefs/CollaborationPreferencePage.java | 44 ---- ...CollaborationPreferencesLabelProvider.java | 108 ++++++++ .../ui/session/AbstractSessionView.java | 169 +++++++++++-- .../ui/session/CollaborationSessionView.java | 20 -- .../collaboration/ui/session/SessionView.java | 3 +- .../raytheon/uf/viz/drawing/PathToolbar.java | 5 +- 15 files changed, 859 insertions(+), 88 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/AlertWord.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/AlertWordWrapper.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationAlertWordsPreferencePage.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferenceContentProvider.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencesLabelProvider.java diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/.classpath b/cave/com.raytheon.uf.viz.collaboration.ui/.classpath index 121e527a93..751c8f2e50 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/.classpath +++ b/cave/com.raytheon.uf.viz.collaboration.ui/.classpath @@ -1,7 +1,7 @@ - + diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF index 119c544551..5c3e795ab8 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF @@ -1,6 +1,6 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: Plugin +Bundle-Name: Collaboration UI Plugin Bundle-SymbolicName: com.raytheon.uf.viz.collaboration.ui;singleton:=true Bundle-Version: 1.0.0.qualifier Bundle-Activator: com.raytheon.uf.viz.collaboration.ui.Activator diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml b/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml index 2d367fc561..fab5ecfd48 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml +++ b/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml @@ -179,5 +179,10 @@ class="com.raytheon.uf.viz.collaboration.ui.prefs.CollaborationPreferencePage" id="com.raytheon.uf.viz.collaboration.ui.prefs.collaborationpreferencepage" name="Collaboration"/> + diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/AlertWord.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/AlertWord.java new file mode 100644 index 0000000000..8e897afabd --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/AlertWord.java @@ -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 + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 16, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @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; + } +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/AlertWordWrapper.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/AlertWordWrapper.java new file mode 100644 index 0000000000..8bc276d9b0 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/AlertWordWrapper.java @@ -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 + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 16, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @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; + } +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java index 3f6bcdc222..7f0cfee41b 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java @@ -25,6 +25,7 @@ import gov.noaa.nws.ncep.ui.pgen.PgenUtil; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashSet; 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.user.IDConverter; 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.CollaborationGroupContainer; 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 public void handleRosterChangeEvent(IRosterChangeEvent rosterChangeEvent) { final IRosterItem rosterItem = rosterChangeEvent.getItem(); diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationUtils.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationUtils.java index be1899188e..bb32081aa7 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationUtils.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationUtils.java @@ -23,6 +23,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; +import java.util.List; import java.util.Set; 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.UserId; 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.core.icon.IconUtil; @@ -243,4 +246,46 @@ public class CollaborationUtils { return result.toString(); } + + public static List 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(); + } else { + List alertWords = new ArrayList(); + for (int i = 0; i < words.getAlertWords().length; i++) { + alertWords.add(words.getAlertWords()[i]); + } + return alertWords; + } + } else { + return new ArrayList(); + } + } + + public static void saveAlertWords(List 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); + } + } } \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationAlertWordsPreferencePage.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationAlertWordsPreferencePage.java new file mode 100644 index 0000000000..1d1abe77a2 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationAlertWordsPreferencePage.java @@ -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 + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 17, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @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) 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) 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) 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 words = (List) 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"); + } +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferenceContentProvider.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferenceContentProvider.java new file mode 100644 index 0000000000..e4152a7dc7 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferenceContentProvider.java @@ -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 + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 17, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @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; + } +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencePage.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencePage.java index 3581ced50c..fcff1db19c 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencePage.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencePage.java @@ -19,9 +19,6 @@ **/ 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.FieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; @@ -50,11 +47,8 @@ import com.raytheon.uf.viz.collaboration.ui.Activator; public class CollaborationPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - private List editors = null; - public CollaborationPreferencePage() { super(GRID); - editors = new ArrayList(); } /* @@ -69,19 +63,6 @@ public class CollaborationPreferencePage extends FieldEditorPreferencePage 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) * @@ -91,33 +72,8 @@ public class CollaborationPreferencePage extends FieldEditorPreferencePage */ @Override protected void createFieldEditors() { - FieldEditor notifications = new BooleanFieldEditor("notifications", "Show Notifications", getFieldEditorParent()); 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); } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencesLabelProvider.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencesLabelProvider.java new file mode 100644 index 0000000000..81334b40fd --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencesLabelProvider.java @@ -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 + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 17, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class CollaborationPreferencesLabelProvider extends ColumnLabelProvider { + + private List colors = null; + + private List fonts = null; + + /** + * + */ + public CollaborationPreferencesLabelProvider() { + colors = new ArrayList(); + fonts = new ArrayList(); + } + + @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(); + } +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java index 6440874620..45ecd18b6e 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java @@ -19,13 +19,19 @@ **/ 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.Calendar; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.eclipse.jface.resource.StringConverter; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; 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.KeyListener; 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.RGB; +import org.eclipse.swt.graphics.TextStyle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; 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.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.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.ui.Activator; 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 { + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(AbstractSessionView.class); + private static final String SESSION_IMAGE_KEY = "sessionId.key"; /** @@ -90,6 +112,14 @@ public abstract class AbstractSessionView extends ViewPart { private UserId[] userIds = null; private SessionMsgArchive msgArchive; + + private List alertWords = null; + + private AudioDataStream ads = null; + + private Map fonts = null; + + private Map colors = null; protected abstract String getSessionImageName(); @@ -102,6 +132,8 @@ public abstract class AbstractSessionView extends ViewPart { public AbstractSessionView() { imageMap = new HashMap(); userIds = CollaborationUtils.getIds(); + fonts = new HashMap(); + colors = new HashMap(); } 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 // read in localization file once and then don't read in again, per // chat room? - Collection alertWords = findAlertWords(sb, - offset + name.length() + 2); + List alertWords = retrieveAlertWords(); List ranges = new ArrayList(); if (alertWords != null) { - for (String keyword : alertWords) { - if (sb.toString().toLowerCase().contains(keyword.toLowerCase())) { - StyleRange keywordRange = new StyleRange( - messagesText.getCharCount() - + sb.toString().toLowerCase() - .indexOf(keyword.toLowerCase()), - keyword.length(), null, null, SWT.BOLD | SWT.ITALIC); + for (AlertWord keyword : alertWords) { + if (sb.toString().toLowerCase() + .contains(keyword.getText().toLowerCase())) { + Font font = null; + if (fonts.containsKey(keyword.getFont())) { + font = fonts.get(keyword.getFont()); + } 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 rnges = new ArrayList(); + // 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); + executeSightsSounds(keyword); } } } styleAndAppendText(sb, offset, name, userId, ranges); - // room for other fun things here, such as sounds and such - executeSightsSounds(); if (msgArchive == null) { msgArchive = getMessageArchive(); } @@ -297,16 +363,68 @@ public abstract class AbstractSessionView extends ViewPart { * @param offset * @return alertWords */ - protected Collection findAlertWords(StringBuilder builder, - int offset) { - return null; + protected List retrieveAlertWords() { + if (alertWords == null) { + alertWords = CollaborationUtils.getAlertWords(); + } + return alertWords; } /** * Place holder must override to do something. */ - protected void executeSightsSounds() { - // placeholder for future things + protected void executeSightsSounds(AlertWord word) { + 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()) { im.dispose(); } + + for (Font font : fonts.values()) { + font.dispose(); + } + + for (Color color : colors.values()) { + color.dispose(); + } + imageMap.clear(); imageMap = null; - if (msgArchive != null) { + alertWords = null; + if (msgArchive != null) { msgArchive.close(); msgArchive = null; } + super.dispose(); } @@ -374,5 +503,9 @@ public abstract class AbstractSessionView extends ViewPart { this.userIds = userIds; } + public void setAlertWords(List words) { + alertWords = words; + } + protected abstract SessionMsgArchive getMessageArchive(); } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java index 0fde20e4ea..c01cf72adf 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java @@ -20,8 +20,6 @@ package com.raytheon.uf.viz.collaboration.ui.session; * further licensing information. **/ -import java.util.Collection; - import org.eclipse.ecf.presence.roster.IRosterEntry; import org.eclipse.ecf.presence.roster.RosterEntry; import org.eclipse.jface.action.Action; @@ -260,24 +258,6 @@ public class CollaborationSessionView extends SessionView { return COLLABORATION_SESSION_IMAGE_NAME; } - @Override - protected Collection 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) * diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java index 7b65c69d1f..0abbd83154 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java @@ -667,7 +667,8 @@ public class SessionView extends AbstractSessionView { List users = (List) usersTable.getInput(); if (users != null) { for (IRosterEntry entry : users) { - if (entry.getUser().equals(participant)) { + UserId id = IDConverter.convertFrom(entry.getUser()); + if (id.equals(participant)) { ((RosterEntry) entry).setPresence(presence); usersTable.refresh(entry); } diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java index ab41748e28..a7716728af 100644 --- a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java @@ -117,9 +117,6 @@ public class PathToolbar extends CaveSWTDialog { protected PathToolbar(Shell parentShell) { super(parentShell, SWT.DIALOG_TRIM | CAVE.DO_NOT_BLOCK); setText("Drawing"); - lastTool = VizPerspectiveListener.getCurrentPerspectiveManager() - .getToolManager().getSelectedModalTool(EDIT_TOOL_CATEGY); - } /* @@ -131,6 +128,8 @@ public class PathToolbar extends CaveSWTDialog { */ @Override protected void initializeComponents(Shell shell) { + lastTool = VizPerspectiveListener.getCurrentPerspectiveManager() + .getToolManager().getSelectedModalTool(EDIT_TOOL_CATEGY); shell.addShellListener(new ShellAdapter() { @Override public void shellClosed(ShellEvent e) {