Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpnehrer2005-09-28 04:23:51 +0000
committerpnehrer2005-09-28 04:23:51 +0000
commit117ee1169a35c6dc2172db5cb578d2a310c65df8 (patch)
treeb5495494ff5e78200626d9b3a2881c1c7a2ed24d
parentd59744a29c1dec65535af89a27b483caed3d52cc (diff)
downloadorg.eclipse.ecf-117ee1169a35c6dc2172db5cb578d2a310c65df8.tar.gz
org.eclipse.ecf-117ee1169a35c6dc2172db5cb578d2a310c65df8.tar.xz
org.eclipse.ecf-117ee1169a35c6dc2172db5cb578d2a310c65df8.zip
Made chat input text multi-line, wrapped. Changed chat composite layout to sash form. Re-implemented chat window icon flasher as UI job.
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatLayout.java3
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatWindow.java108
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/TextChatComposite.java22
3 files changed, 51 insertions, 82 deletions
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatLayout.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatLayout.java
index e5de2098c..79ab2feab 100644
--- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatLayout.java
+++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatLayout.java
@@ -18,6 +18,9 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Layout;
+/**
+ * @deprecated not used anywhere
+ */
class ChatLayout extends Layout {
protected static final int TEXT_HEIGHT_FUDGE = 8;
Point iExtent, tExtent;
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatWindow.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatWindow.java
index 2d423f34c..a426c7a92 100644
--- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatWindow.java
+++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatWindow.java
@@ -11,7 +11,10 @@
package org.eclipse.ecf.ui.views;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.presence.IMessageListener;
@@ -26,6 +29,7 @@ import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.PaletteData;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
@@ -33,6 +37,7 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.progress.UIJob;
/**
* @author pnehrer
@@ -47,7 +52,6 @@ public class ChatWindow extends ApplicationWindow implements IMessageListener {
private TextChatComposite chat;
private Image image;
private Image blank;
- private boolean flashing;
private String titleBarText;
@@ -56,7 +60,6 @@ public class ChatWindow extends ApplicationWindow implements IMessageListener {
protected IUser remoteUser;
protected boolean disposed = false;
- protected Thread flashThread = null;
protected IUser getLocalUser() {
return localUser;
@@ -65,55 +68,8 @@ public class ChatWindow extends ApplicationWindow implements IMessageListener {
protected IUser getRemoteUser() {
return remoteUser;
}
- private final Runnable flipImage = new Runnable() {
- public void run() {
- Shell shell = getShell();
- if (!shell.isDisposed())
- if (blank == shell.getImage()) {
- if (image != null && !image.isDisposed())
- shell.setImage(image);
- } else {
- if (blank != null && !blank.isDisposed())
- shell.setImage(blank);
- }
- }
- };
-
- private Flash flash;
-
- private class Flash implements Runnable {
-
- private final Display display;
-
- public Flash(Display display) {
- this.display = display;
- }
-
- public void run() {
- while (true) {
- synchronized (this) {
- try {
- while (!flashing)
- wait();
- } catch (InterruptedException e) {
- break;
- }
- }
-
- if (display.isDisposed())
- break;
-
- display.syncExec(flipImage);
- synchronized (this) {
- try {
- wait(FLASH_INTERVAL);
- } catch (InterruptedException e) {
- break;
- }
- }
- }
- }
- };
+
+ private UIJob flasher;
public ChatWindow(ViewPart view, String titleBarText, String initOutputText, IUser localUser, IUser remoteUser) {
super(null);
@@ -159,13 +115,29 @@ public class ChatWindow extends ApplicationWindow implements IMessageListener {
data.transparentPixel = 0;
blank = new Image(newShell.getDisplay(), data);
- flash = new Flash(newShell.getDisplay());
- flashThread = new Thread(flash);
- flashThread.start();
+ flasher = new UIJob("Chat View Icon Flasher") {
+
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ Shell shell = getShell();
+ if (shell.getImage() == image)
+ shell.setImage(blank);
+ else
+ shell.setImage(image);
+
+ schedule(FLASH_INTERVAL);
+ return Status.OK_STATUS;
+ }
+
+ public boolean shouldRun() {
+ return !getShell().isDisposed();
+ }
+ };
+
+ flasher.setSystem(true);
newShell.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
- flash();
+ flasher.cancel();
if (image != null)
image.dispose();
@@ -182,6 +154,10 @@ public class ChatWindow extends ApplicationWindow implements IMessageListener {
}
});
}
+
+ protected Point getInitialSize() {
+ return new Point(320, 240);
+ }
/*
* (non-Javadoc)
@@ -264,33 +240,19 @@ public class ChatWindow extends ApplicationWindow implements IMessageListener {
}
public void flash() {
- synchronized (flash) {
- if (!flashing) {
- flashing = true;
- flash.notify();
- }
- }
+ flasher.schedule();
}
private void stopFlashing() {
- synchronized (flash) {
- if (flashing) {
- flashing = false;
- if (!getShell().isDisposed() && image != null && !image.isDisposed())
- getShell().setImage(image);
- flash.notify();
- }
- }
+ flasher.cancel();
+ if (getShell().getImage() != image)
+ getShell().setImage(image);
}
public void setDisposed(final String message) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
disposed = true;
- if (flashThread != null) {
- flashThread.interrupt();
- flashThread = null;
- }
if (chat != null) {
chat.setDisposed();
}
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/TextChatComposite.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/TextChatComposite.java
index 2992f1840..2649f8074 100644
--- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/TextChatComposite.java
+++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/TextChatComposite.java
@@ -13,6 +13,7 @@ package org.eclipse.ecf.ui.views;
import java.text.SimpleDateFormat;
import java.util.Date;
+
import org.eclipse.core.runtime.Status;
import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.ui.Trace;
@@ -28,6 +29,7 @@ import org.eclipse.jface.text.TextViewer;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.DisposeEvent;
@@ -41,6 +43,8 @@ import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Text;
@@ -66,9 +70,8 @@ public class TextChatComposite extends Composite {
protected TextViewer textoutput;
protected Text textinput;
- protected int [] sashWeights = new int[] { 90, 10 };
+ protected int [] sashWeights = new int[] { 7, 2 };
- protected ChatLayout cl = null;
protected boolean isTyping;
protected String initText;
protected ILocalInputHandler inputHandler;
@@ -105,12 +108,12 @@ public class TextChatComposite extends Composite {
});
- // Setup layout
- cl = new ChatLayout(DEFAULT_INPUT_HEIGHT, DEFAULT_INPUT_SEPARATOR);
- setLayout(cl);
+ setLayout(new GridLayout());
+ SashForm sash = new SashForm(this, SWT.VERTICAL | SWT.SMOOTH);
+ sash.setLayoutData(new GridData(GridData.FILL_BOTH));
// Setup text output
- textoutput = new TextViewer(this, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
+ textoutput = new TextViewer(sash, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
styledText = textoutput.getTextWidget();
styledText.setEditable(false);
textoutput.setDocument(new Document(this.initText));
@@ -118,9 +121,7 @@ public class TextChatComposite extends Composite {
textoutput.setEditable(false);
// Setup text input
- textinput = new Text(this, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL);
- cl.setInputTextHeight(textinput.getFont().getFontData()[0]
- .getHeight() + 2);
+ textinput = new Text(sash, SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
textinput.setText(TEXT_INPUT_INIT);
textinput.selectAll();
@@ -168,6 +169,8 @@ public class TextChatComposite extends Composite {
}
});
+ sash.setWeights(sashWeights);
+
makeActions();
hookContextMenu();
@@ -344,6 +347,7 @@ public class TextChatComposite extends Composite {
protected void handleKeyPressed(KeyEvent evt) {
if (evt.character == SWT.CR) {
handleEnter();
+ evt.doit = false;
}
}

Back to the top