diff options
| author | kgilmer | 2005-02-23 22:54:47 +0000 |
|---|---|---|
| committer | kgilmer | 2005-02-23 22:54:47 +0000 |
| commit | 5e6f150a276b075986c4437d93537eaf8f243b46 (patch) | |
| tree | 9f633fb87249c0ed5420b05bdca95a542b7323cc | |
| parent | e385a13a7dd12c7093076eb62f41de9054e45042 (diff) | |
| download | org.eclipse.ecf-5e6f150a276b075986c4437d93537eaf8f243b46.tar.gz org.eclipse.ecf-5e6f150a276b075986c4437d93537eaf8f243b46.tar.xz org.eclipse.ecf-5e6f150a276b075986c4437d93537eaf8f243b46.zip | |
Added color pref items to chat output viewer.
3 files changed, 57 insertions, 11 deletions
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ClientPluginConstants.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ClientPluginConstants.java index 03442e1e4..e117dea08 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ClientPluginConstants.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ClientPluginConstants.java @@ -27,6 +27,9 @@ public interface ClientPluginConstants { public static final String PREF_CONFIRM_REMOTE_VIEW = "confirmRemoteView"; public static final String PREF_FILE_SEND_PATH = "findSendPath"; public static final String PREF_CONFIRM_FILE_RECEIVE = "confirmFileReceive"; + public static final String PREF_ME_TEXT_COLOR = "prefMeTextColor"; + public static final String PREF_OTHER_TEXT_COLOR = "prefOtherTextColor"; + public static final String PREF_SYSTEM_TEXT_COLOR = "prefSystemTextColor"; /* * Contstants used to describe decoration images. diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatComposite.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatComposite.java index 4d6f13235..b3b17ff51 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatComposite.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatComposite.java @@ -17,6 +17,7 @@ import java.util.Date; import java.util.StringTokenizer; import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Preferences.PropertyChangeEvent; import org.eclipse.ecf.core.identity.ID; import org.eclipse.ecf.core.identity.IDFactory; import org.eclipse.ecf.example.collab.ClientPlugin; @@ -120,16 +121,25 @@ public class ChatComposite extends Composite { this.view = view; this.chatWindow = chatWindow; - this.meColor = new Color(getShell().getDisplay(), 23, 135, 65); - this.otherColor = new Color(getShell().getDisplay(), 65, 13, 165); - this.systemColor = new Color(getShell().getDisplay(), 123, 135, 165); + meColor = colorFromRGBString(ClientPlugin.getDefault().getPluginPreferences().getString(ClientPlugin.PREF_ME_TEXT_COLOR)); + otherColor = colorFromRGBString(ClientPlugin.getDefault().getPluginPreferences().getString(ClientPlugin.PREF_OTHER_TEXT_COLOR)); + systemColor = colorFromRGBString(ClientPlugin.getDefault().getPluginPreferences().getString(ClientPlugin.PREF_SYSTEM_TEXT_COLOR)); + ClientPlugin.getDefault().getPluginPreferences().addPropertyChangeListener(new ColorPropertyChangeListener()); this.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { - meColor.dispose(); - otherColor.dispose(); - systemColor.dispose(); + if (meColor != null) { + meColor.dispose(); + } + + if (otherColor != null) { + otherColor.dispose(); + } + + if (systemColor != null) { + systemColor.dispose(); + } } }); @@ -147,9 +157,8 @@ public class ChatComposite extends Composite { fr.put(CHAT_OUTPUT_FONT, newFont); textoutput.getTextWidget().setFont(fr.get(CHAT_OUTPUT_FONT)); } - FontPropertyChangeListener listener = new FontPropertyChangeListener(); - ClientPlugin.getDefault().getPluginPreferences().addPropertyChangeListener(listener); + ClientPlugin.getDefault().getPluginPreferences().addPropertyChangeListener(new FontPropertyChangeListener()); textoutput.setDocument(new Document(initText)); textoutput.setEditable(false); @@ -230,7 +239,7 @@ public class ChatComposite extends Composite { StyleRange sr = new StyleRange(); sr.start = startRange; sr.length = sb.length(); - if (view.userdata.getUserID().equals(text.getOriginator().getUserID())) { //we rote this + if (view.userdata.getUserID().equals(text.getOriginator().getUserID())) { sr.foreground = meColor; } else { sr.foreground = otherColor; @@ -1192,6 +1201,36 @@ public class ChatComposite extends Composite { treeDropTarget = new TreeDropTarget(view,treeView.getControl(), this); } + private Color colorFromRGBString(String rgb) { + Color color = null; + + if (rgb == null || rgb.equals("")) { + color = new Color(getShell().getDisplay(), 0, 0, 0); + return color; + } + + if (color != null) { + color.dispose(); + } + + String[] vals = rgb.split(","); + color = new Color(getShell().getDisplay(), Integer.parseInt(vals[0]), Integer.parseInt(vals[1]), Integer.parseInt(vals[2])); + return color; + } + + private class ColorPropertyChangeListener implements org.eclipse.core.runtime.Preferences.IPropertyChangeListener { + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent) + */ + public void propertyChange(PropertyChangeEvent event) { + meColor = colorFromRGBString(ClientPlugin.getDefault().getPluginPreferences().getString(ClientPlugin.PREF_ME_TEXT_COLOR)); + otherColor = colorFromRGBString(ClientPlugin.getDefault().getPluginPreferences().getString(ClientPlugin.PREF_OTHER_TEXT_COLOR)); + systemColor = colorFromRGBString(ClientPlugin.getDefault().getPluginPreferences().getString(ClientPlugin.PREF_SYSTEM_TEXT_COLOR)); + } + + } + private class FontPropertyChangeListener implements org.eclipse.core.runtime.Preferences.IPropertyChangeListener { /* (non-Javadoc) * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent) diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ClientPreferencePage.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ClientPreferencePage.java index c8f791dc0..1b384de58 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ClientPreferencePage.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ClientPreferencePage.java @@ -13,6 +13,7 @@ package org.eclipse.ecf.example.collab.ui; import org.eclipse.ecf.example.collab.ClientPlugin; import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.ColorFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.FontFieldEditor; import org.eclipse.ui.IWorkbench; @@ -34,7 +35,7 @@ public class ClientPreferencePage extends FieldEditorPreferencePage implements //this.getPreferenceStore().setDefault(ClientPlugin.PREF_CHAT_FONT, ""); this.getPreferenceStore().setDefault(ClientPlugin.PREF_CONFIRM_FILE_SEND, true); - this.getPreferenceStore().setDefault(ClientPlugin.PREF_CONFIRM_FILE_RECEIVE, true); + //this.getPreferenceStore().setDefault(ClientPlugin.PREF_CONFIRM_FILE_RECEIVE, true); this.getPreferenceStore().setDefault(ClientPlugin.PREF_CONFIRM_REMOTE_VIEW, true); } @@ -50,7 +51,10 @@ public class ClientPreferencePage extends FieldEditorPreferencePage implements addField(new BooleanFieldEditor(ClientPlugin.PREF_DISPLAY_TIMESTAMP, "Show time for each chat entry", getFieldEditorParent())); addField(new FontFieldEditor(ClientPlugin.PREF_CHAT_FONT, "Chat window font:", getFieldEditorParent())); - addField(new BooleanFieldEditor(ClientPlugin.PREF_CONFIRM_FILE_RECEIVE, "Confirm before receiving file.", getFieldEditorParent())); + //addField(new BooleanFieldEditor(ClientPlugin.PREF_CONFIRM_FILE_RECEIVE, "Confirm before receiving file.", getFieldEditorParent())); + addField(new ColorFieldEditor(ClientPlugin.PREF_ME_TEXT_COLOR, "Chat Text Color For Me:", getFieldEditorParent())); + addField(new ColorFieldEditor(ClientPlugin.PREF_OTHER_TEXT_COLOR, "Chat Text Color For Other:", getFieldEditorParent())); + addField(new ColorFieldEditor(ClientPlugin.PREF_SYSTEM_TEXT_COLOR, "Chat Text Color For System:", getFieldEditorParent())); /*IntegerFieldEditor rate = new IntegerFieldEditor(ClientPlugin.PREF_FILE_TRANSFER_RATE, "Maximum transfer rate for file transfers.", getFieldEditorParent());*/ |
