Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-04-26 22:02:59 +0000
committerslewis2007-04-26 22:02:59 +0000
commit5021aefe4f37f7b5f923ba3e40070c13bc65e9f4 (patch)
treeb1ad8bb8221c2708eaec789f1b608538d9244682 /framework/bundles/org.eclipse.ecf.ui/src
parent9c4aefaeb30cadabe2d3e61d283f5492a5111bc1 (diff)
downloadorg.eclipse.ecf-5021aefe4f37f7b5f923ba3e40070c13bc65e9f4.tar.gz
org.eclipse.ecf-5021aefe4f37f7b5f923ba3e40070c13bc65e9f4.tar.xz
org.eclipse.ecf-5021aefe4f37f7b5f923ba3e40070c13bc65e9f4.zip
Fixes for 183030
Diffstat (limited to 'framework/bundles/org.eclipse.ecf.ui/src')
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/internal/ui/deprecated/views/ChatWindow.java (renamed from framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatWindow.java)24
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/internal/ui/deprecated/views/RosterView.java1
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/internal/ui/deprecated/views/SimpleLinkTextViewer.java (renamed from framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/SimpleLinkTextViewer.java)2
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/internal/ui/deprecated/views/TextChatComposite.java (renamed from framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/TextChatComposite.java)91
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatLine.java4
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatRoomManagerView.java372
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatRoomView.java89
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/MessageLoader.java53
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/MessageLoader.properties4
9 files changed, 266 insertions, 374 deletions
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/internal/ui/deprecated/views/ChatWindow.java
index 934b1aa66..5db699b4f 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/internal/ui/deprecated/views/ChatWindow.java
@@ -9,7 +9,7 @@
* Composent, Inc. - initial API and implementation
*****************************************************************************/
-package org.eclipse.ecf.ui.views;
+package org.eclipse.ecf.internal.ui.deprecated.views;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -20,6 +20,8 @@ import org.eclipse.ecf.presence.IIMMessageListener;
import org.eclipse.ecf.presence.im.IChatMessage;
import org.eclipse.ecf.presence.im.IChatMessageEvent;
import org.eclipse.ecf.ui.SharedImages;
+import org.eclipse.ecf.ui.views.ChatLine;
+import org.eclipse.ecf.ui.views.ILocalInputHandler;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
@@ -101,12 +103,6 @@ public class ChatWindow extends ApplicationWindow implements IIMMessageListener
*/
protected void configureShell(final Shell newShell) {
super.configureShell(newShell);
- String shellTitlePrefix = MessageLoader
- .getString("ChatWindow.titleprefix");
- if (shellTitlePrefix != null && !shellTitlePrefix.equals("")) {
- shellTitlePrefix = shellTitlePrefix + ": ";
- }
- titleBarText = shellTitlePrefix + titleBarText;
newShell.setText(titleBarText);
image = SharedImages.getImage(SharedImages.IMG_USER_AVAILABLE);
newShell.setImage(image);
@@ -178,7 +174,7 @@ public class ChatWindow extends ApplicationWindow implements IIMMessageListener
else if (obj instanceof ILocalInputHandler) {
inputHandler = (ILocalInputHandler) obj;
}
- chat = new TextChatComposite(view,parent, SWT.NORMAL, initText,
+ chat = new TextChatComposite(view, parent, SWT.NORMAL, initText,
inputHandler, getLocalUser(), getRemoteUser());
chat.setLayoutData(new GridData(GridData.FILL_BOTH));
chat.setFont(parent.getFont());
@@ -301,20 +297,24 @@ public class ChatWindow extends ApplicationWindow implements IIMMessageListener
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.ecf.presence.IIMMessageListener#handleMessageEvent(org.eclipse.ecf.presence.IIMMessageEvent)
*/
public void handleMessageEvent(IIMMessageEvent messageEvent) {
if (messageEvent instanceof IChatMessageEvent) {
- final IChatMessage m = ((IChatMessageEvent) messageEvent).getChatMessage();
+ final IChatMessage m = ((IChatMessageEvent) messageEvent)
+ .getChatMessage();
Display.getDefault().syncExec(new Runnable() {
public void run() {
if (!disposed && chat != null) {
- chat.appendText(new ChatLine(m.getBody(), getRemoteUser()));
+ chat.appendText(new ChatLine(m.getBody(),
+ getRemoteUser()));
}
}
});
}
-
+
}
} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/internal/ui/deprecated/views/RosterView.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/internal/ui/deprecated/views/RosterView.java
index 709ec133f..2867c2a4d 100644
--- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/internal/ui/deprecated/views/RosterView.java
+++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/internal/ui/deprecated/views/RosterView.java
@@ -72,7 +72,6 @@ import org.eclipse.ecf.ui.dialogs.AddBuddyDialog;
import org.eclipse.ecf.ui.dialogs.ChangePasswordDialog;
import org.eclipse.ecf.ui.dialogs.ChatRoomSelectionDialog;
import org.eclipse.ecf.ui.views.ChatRoomView;
-import org.eclipse.ecf.ui.views.ChatWindow;
import org.eclipse.ecf.ui.views.IChatRoomViewCloseListener;
import org.eclipse.ecf.ui.views.ILocalInputHandler;
import org.eclipse.jface.action.Action;
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/SimpleLinkTextViewer.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/internal/ui/deprecated/views/SimpleLinkTextViewer.java
index 2ec929d23..1947675e3 100644
--- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/SimpleLinkTextViewer.java
+++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/internal/ui/deprecated/views/SimpleLinkTextViewer.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.ecf.ui.views;
+package org.eclipse.ecf.internal.ui.deprecated.views;
import java.util.ArrayList;
import java.util.List;
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/internal/ui/deprecated/views/TextChatComposite.java
index d0ac2cf87..523872a92 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/internal/ui/deprecated/views/TextChatComposite.java
@@ -9,7 +9,7 @@
* Composent, Inc. - initial API and implementation
*****************************************************************************/
-package org.eclipse.ecf.ui.views;
+package org.eclipse.ecf.internal.ui.deprecated.views;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -18,6 +18,8 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.internal.ui.Activator;
+import org.eclipse.ecf.ui.views.ChatLine;
+import org.eclipse.ecf.ui.views.ILocalInputHandler;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@@ -25,9 +27,14 @@ import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.StyleRange;
@@ -51,6 +58,8 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
import org.eclipse.ui.part.ViewPart;
public class TextChatComposite extends Composite {
@@ -59,8 +68,7 @@ public class TextChatComposite extends Composite {
protected static final int DEFAULT_INPUT_SEPARATOR = 5;
- protected String TEXT_INPUT_INIT = MessageLoader
- .getString("TextChatComposite.textinputinit");
+ protected String TEXT_INPUT_INIT = "<input chat text here>";
protected Color meColor = null;
@@ -70,7 +78,7 @@ public class TextChatComposite extends Composite {
protected StyledText styledText;
- protected TextViewer textoutput;
+ //protected TextViewer textoutput;
protected Text textinput;
@@ -97,11 +105,12 @@ public class TextChatComposite extends Composite {
private Action outputPaste = null;
private Action outputSelectAll = null;
-
+
private ViewPart view = null;
- public TextChatComposite(ViewPart view, Composite parent, int style, String initText,
- ILocalInputHandler handler, IUser localUser, IUser remoteUser) {
+ public TextChatComposite(ViewPart view, Composite parent, int style,
+ String initText, ILocalInputHandler handler, IUser localUser,
+ IUser remoteUser) {
super(parent, style);
this.view = view;
@@ -130,12 +139,15 @@ public class TextChatComposite extends Composite {
sash.setLayoutData(new GridData(GridData.FILL_BOTH));
// Setup text output
- textoutput = new TextViewer(sash, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
- styledText = textoutput.getTextWidget();
+ SourceViewer result = new SourceViewer(sash, null, null,
+ true, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI
+ | SWT.H_SCROLL | SWT.READ_ONLY);
+ result.configure(new TextSourceViewerConfiguration(EditorsUI
+ .getPreferenceStore()));
+ result.setDocument(new Document());
+
+ styledText = result.getTextWidget();
styledText.setEditable(false);
- textoutput.setDocument(new Document(this.initText));
-
- textoutput.setEditable(false);
// Setup text input
textinput = new Text(sash, SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
@@ -247,17 +259,17 @@ public class TextChatComposite extends Composite {
protected void outputClear() {
if (MessageDialog.openConfirm(null, "Confirm Clear Text Output",
"Are you sure you want to clear output?"))
- textoutput.getTextWidget().setText("");
+ styledText.setText("");
}
protected void outputCopy() {
- String t = textoutput.getTextWidget().getSelectionText();
+ String t = styledText.getSelectionText();
if (t == null || t.length() == 0) {
- textoutput.getTextWidget().selectAll();
+ styledText.selectAll();
}
- textoutput.getTextWidget().copy();
- textoutput.getTextWidget().setSelection(
- textoutput.getTextWidget().getText().length());
+ styledText.copy();
+ styledText.setSelection(
+ styledText.getText().length());
}
protected void outputPaste() {
@@ -265,7 +277,7 @@ public class TextChatComposite extends Composite {
}
protected void outputSelectAll() {
- textoutput.getTextWidget().selectAll();
+ styledText.selectAll();
}
private void hookContextMenu() {
@@ -276,10 +288,37 @@ public class TextChatComposite extends Composite {
fillContextMenu(manager);
}
});
- Menu menu = menuMgr.createContextMenu(textoutput.getControl());
- textoutput.getControl().setMenu(menu);
-
- view.getSite().registerContextMenu(menuMgr, textoutput);
+ Menu menu = menuMgr.createContextMenu(styledText);
+ styledText.setMenu(menu);
+ ISelectionProvider selectionProvider = new ISelectionProvider() {
+
+ public void addSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+
+ public ISelection getSelection() {
+ ISelection selection = new TextSelection(styledText
+ .getSelectionRange().x, styledText
+ .getSelectionRange().y);
+
+ return selection;
+ }
+
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+
+ public void setSelection(ISelection selection) {
+ if (selection instanceof ITextSelection) {
+ ITextSelection textSelection = (ITextSelection) selection;
+ styledText.setSelection(textSelection.getOffset(),
+ textSelection.getOffset()
+ + textSelection.getLength());
+ }
+ }
+
+ };
+ view.getSite().registerContextMenu(menuMgr, selectionProvider);
}
private void fillContextMenu(IMenuManager manager) {
@@ -323,9 +362,9 @@ public class TextChatComposite extends Composite {
}
public void appendText(ChatLine text) {
- StyledText st = textoutput.getTextWidget();
+ StyledText st = styledText;
- if (text == null || textoutput == null || st == null)
+ if (text == null || st == null)
return;
int startRange = st.getText().length();
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatLine.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatLine.java
index d89544527..57619c73a 100644
--- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatLine.java
+++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatLine.java
@@ -13,10 +13,6 @@ package org.eclipse.ecf.ui.views;
import org.eclipse.ecf.core.user.IUser;
-/**
- * @author kgilmer
- *
- */
public class ChatLine {
private IUser originator = null; //
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatRoomManagerView.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatRoomManagerView.java
index a4e037b35..0d57766a1 100644
--- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatRoomManagerView.java
+++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatRoomManagerView.java
@@ -10,10 +10,8 @@
******************************************************************************/
package org.eclipse.ecf.ui.views;
-import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -29,7 +27,6 @@ import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.security.ConnectContextFactory;
import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.core.util.ECFException;
-import org.eclipse.ecf.internal.ui.Activator;
import org.eclipse.ecf.presence.IIMMessageEvent;
import org.eclipse.ecf.presence.IIMMessageListener;
import org.eclipse.ecf.presence.IPresence;
@@ -41,15 +38,21 @@ import org.eclipse.ecf.presence.chatroom.IChatRoomMessage;
import org.eclipse.ecf.presence.chatroom.IChatRoomMessageEvent;
import org.eclipse.ecf.presence.chatroom.IChatRoomMessageSender;
import org.eclipse.ecf.presence.chatroom.IChatRoomParticipantListener;
-import org.eclipse.ecf.ui.ChatPreferencePage;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.swt.SWT;
@@ -76,17 +79,17 @@ import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
-import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
public class ChatRoomManagerView extends ViewPart implements
IChatRoomInvitationListener {
-
+
public static final String VIEW_ID = "org.eclipse.ecf.ui.views.ChatRoomManagerView";
-
+
private static final String COMMAND_PREFIX = "/";
private static final String COMMAND_DELIM = " ";
@@ -125,7 +128,7 @@ public class ChatRoomManagerView extends ViewPart implements
private Composite mainComp = null;
- private SimpleLinkTextViewer readText = null;
+ private StyledText readText = null;
private Text writeText = null;
@@ -133,9 +136,6 @@ public class ChatRoomManagerView extends ViewPart implements
private Manager rootChatRoomTabItem = null;
- private IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench()
- .getBrowserSupport();
-
IChatRoomViewCloseListener closeListener = null;
IChatRoomMessageSender messageSender = null;
@@ -181,12 +181,12 @@ public class ChatRoomManagerView extends ViewPart implements
KeyListener keyListener;
- SimpleLinkTextViewer textOutput;
+ StyledText textOutput;
Text textInput;
ListViewer listViewer;
-
+
Action outputSelectAll;
Action outputCopy;
Action outputClear;
@@ -215,11 +215,18 @@ public class ChatRoomManagerView extends ViewPart implements
Composite readInlayComp = new Composite(rightSash, SWT.FILL);
readInlayComp.setLayout(new GridLayout());
readInlayComp.setLayoutData(new GridData(GridData.FILL_BOTH));
- textOutput = new SimpleLinkTextViewer(readInlayComp, SWT.V_SCROLL
- | SWT.H_SCROLL | SWT.WRAP);
- textOutput.getTextWidget().setEditable(false);
- textOutput.getTextWidget().setLayoutData(
- new GridData(GridData.FILL_BOTH));
+
+ SourceViewer result = new SourceViewer(readInlayComp, null, null,
+ true, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI
+ | SWT.H_SCROLL | SWT.READ_ONLY);
+ result.configure(new TextSourceViewerConfiguration(EditorsUI
+ .getPreferenceStore()));
+ result.setDocument(new Document());
+
+ textOutput = result.getTextWidget();
+ textOutput.setEditable(false);
+ textOutput.setLayoutData(new GridData(GridData.FILL_BOTH));
+
Composite writeComp = new Composite(rightSash, SWT.NONE);
writeComp.setLayout(new FillLayout());
textInput = new Text(writeComp, SWT.BORDER | SWT.MULTI | SWT.WRAP
@@ -235,32 +242,31 @@ public class ChatRoomManagerView extends ViewPart implements
} else
tabItem.setControl(rightSash);
parent.setSelection(tabItem);
-
+
makeActions();
hookContextMenu();
}
-
+
protected void outputClear() {
if (MessageDialog.openConfirm(null, "Confirm Clear Text Output",
"Are you sure you want to clear output?")) {
- textOutput.getTextWidget().setText(""); //$NON-NLS-1$
+ textOutput.setText(""); //$NON-NLS-1$
}
}
protected void outputCopy() {
- String t = textOutput.getTextWidget().getSelectionText();
+ String t = textOutput.getSelectionText();
if (t == null || t.length() == 0) {
- textOutput.getTextWidget().selectAll();
+ textOutput.selectAll();
}
- textOutput.getTextWidget().copy();
- textOutput.getTextWidget().setSelection(
- textOutput.getTextWidget().getText().length());
+ textOutput.copy();
+ textOutput.setSelection(textOutput.getText().length());
}
protected void outputSelectAll() {
- textOutput.getTextWidget().selectAll();
+ textOutput.selectAll();
}
-
+
private void fillContextMenu(IMenuManager manager) {
manager.add(outputCopy);
manager.add(outputClear);
@@ -277,9 +283,37 @@ public class ChatRoomManagerView extends ViewPart implements
fillContextMenu(manager);
}
});
- Menu menu = menuMgr.createContextMenu(textOutput.getControl());
- textOutput.getControl().setMenu(menu);
- getSite().registerContextMenu(menuMgr, textOutput);
+ Menu menu = menuMgr.createContextMenu(textOutput);
+ textOutput.setMenu(menu);
+ ISelectionProvider selectionProvider = new ISelectionProvider() {
+
+ public void addSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+
+ public ISelection getSelection() {
+ ISelection selection = new TextSelection(textOutput
+ .getSelectionRange().x, textOutput
+ .getSelectionRange().y);
+
+ return selection;
+ }
+
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+
+ public void setSelection(ISelection selection) {
+ if (selection instanceof ITextSelection) {
+ ITextSelection textSelection = (ITextSelection) selection;
+ textOutput.setSelection(textSelection.getOffset(),
+ textSelection.getOffset()
+ + textSelection.getLength());
+ }
+ }
+
+ };
+ getSite().registerContextMenu(menuMgr, selectionProvider);
}
private void makeActions() {
@@ -316,6 +350,7 @@ public class ChatRoomManagerView extends ViewPart implements
};
}
+
protected String getTabName() {
return tabItem.getText();
}
@@ -328,10 +363,6 @@ public class ChatRoomManagerView extends ViewPart implements
return textInput;
}
- protected SimpleLinkTextViewer getTextOutput() {
- return textOutput;
- }
-
protected void setKeyListener(KeyListener listener) {
if (listener != null)
textInput.addKeyListener(listener);
@@ -340,6 +371,13 @@ public class ChatRoomManagerView extends ViewPart implements
protected ListViewer getListViewer() {
return listViewer;
}
+
+ /**
+ * @return
+ */
+ public StyledText getTextOutput() {
+ return textOutput;
+ }
}
public void createPartControl(Composite parent) {
@@ -433,11 +471,10 @@ public class ChatRoomManagerView extends ViewPart implements
private void initializeControls(ID targetID) {
// clear text output area
- if (!readText.getControl().isDisposed())
- readText.getTextWidget().setText(
- new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z")
- .format(new Date())
- + "\nConnecting to " + targetID.getName() + "\n\n");
+ if (!readText.isDisposed())
+ readText.setText(new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z")
+ .format(new Date())
+ + "\nConnecting to " + targetID.getName() + "\n\n");
}
public void setEnabled(boolean enabled) {
@@ -582,10 +619,9 @@ public class ChatRoomManagerView extends ViewPart implements
rooms.put(target, chatroomview);
} catch (Exception e) {
MessageDialog.openError(getSite().getShell(),
- "Connect Error",
- "Could connect to " + target
- + ".\n\nError is " + e.getLocalizedMessage()
- + ".");
+ "Connect Error", "Could connect to "
+ + target + ".\n\nError is "
+ + e.getLocalizedMessage() + ".");
}
}
});
@@ -606,7 +642,7 @@ public class ChatRoomManagerView extends ViewPart implements
Text inputText;
- SimpleLinkTextViewer outputText;
+ StyledText outputText;
IChatRoomMessageSender channelMessageSender;
@@ -1210,30 +1246,8 @@ public class ChatRoomManagerView extends ViewPart implements
+ ",subject=" + subject + ",body=" + body);
}
- private boolean intelligentAppend(SimpleLinkTextViewer readText,
- StyledText st, ChatLine text) {
+ private boolean intelligentAppend(StyledText st, ChatLine text) {
String line = text.getText();
- // check to see if a link exists in this line
- int index = line.indexOf("http://"); //$NON-NLS-1$
- if (index == -1) {
- index = line.indexOf("https://"); //$NON-NLS-1$
- if (index == -1) {
- index = line.indexOf("www."); //$NON-NLS-1$
- if (index == -1) {
- return false;
- }
- }
- } else {
- int nextIndex = line.indexOf("https://"); //$NON-NLS-1$
- if (nextIndex != -1 && nextIndex < index) {
- index = nextIndex;
- }
-
- nextIndex = line.indexOf("www."); //$NON-NLS-1$
- if (nextIndex != -1 && nextIndex < index) {
- index = nextIndex;
- }
- }
int startRange = st.getText().length();
StringBuffer sb = new StringBuffer();
@@ -1266,117 +1280,6 @@ public class ChatRoomManagerView extends ViewPart implements
st.setStyleRange(sr);
}
- while (index != -1) {
- String front = line.substring(0, index);
- line = line.substring(index);
- int beforeMessageIndex = st.getText().length();
- st.append(front);
- if (text.getOriginator() == null) {
- StyleRange sr = new StyleRange();
- sr.start = beforeMessageIndex;
- sr.length = front.length();
- sr.foreground = systemColor;
- sr.fontStyle = SWT.BOLD;
- st.setStyleRange(sr);
- } else if (nickContained) {
- // highlight the message itself as necessary
- StyleRange sr = new StyleRange();
- sr.start = beforeMessageIndex;
- sr.length = front.length();
- sr.foreground = highlightColor;
- st.setStyleRange(sr);
- }
-
- int spaceIndex = line.indexOf(' ');
- if (spaceIndex != -1) {
- String url = line.substring(0, spaceIndex);
- int symbols = 0;
- for (int i = url.length() - 1; i != 0; i--) {
- char ch = url.charAt(i);
- if (!Character.isLetterOrDigit(ch)) {
- symbols++;
- } else {
- break;
- }
- }
- if (!url.startsWith("http")) { //$NON-NLS-1$
- if (symbols == 0) {
- readText.appendLink(url, createLinkRunnable("http://" //$NON-NLS-1$
- + url));
- } else {
- int symbolIndex = url.length() - symbols;
- String link = url.substring(0, symbolIndex);
- readText.appendLink(link, createLinkRunnable("http://" //$NON-NLS-1$
- + link));
- st.append(url.substring(symbolIndex));
- }
- } else {
- if (symbols == 0) {
- readText.appendLink(url, createLinkRunnable(url));
- } else {
- int symbolIndex = url.length() - symbols;
- String link = url.substring(0, symbolIndex);
- readText.appendLink(link, createLinkRunnable(link));
- st.append(url.substring(symbolIndex));
- }
- }
- line = line.substring(spaceIndex);
- index = line.indexOf("http://"); //$NON-NLS-1$
- if (index == -1) {
- index = line.indexOf("https://"); //$NON-NLS-1$
- if (index == -1) {
- index = line.indexOf("www."); //$NON-NLS-1$
- if (index == -1) {
- break;
- }
- }
- } else {
- int nextIndex = line.indexOf("https://"); //$NON-NLS-1$
- if (nextIndex != -1 && nextIndex < index) {
- index = nextIndex;
- }
-
- nextIndex = line.indexOf("www."); //$NON-NLS-1$
- if (nextIndex != -1 && nextIndex < index) {
- index = nextIndex;
- }
- }
- } else {
- int symbols = 0;
- for (int i = line.length() - 1; i != 0; i--) {
- char ch = line.charAt(i);
- if (!Character.isLetterOrDigit(ch)) {
- symbols++;
- } else {
- break;
- }
- }
- if (!line.startsWith("http")) { //$NON-NLS-1$
- if (symbols == 0) {
- readText.appendLink(line, createLinkRunnable("http://" //$NON-NLS-1$
- + line));
- } else {
- int symbolIndex = line.length() - symbols;
- String link = line.substring(0, symbolIndex);
- readText.appendLink(link, createLinkRunnable("http://" //$NON-NLS-1$
- + link));
- st.append(line.substring(symbolIndex));
- }
- } else {
- if (symbols == 0) {
- readText.appendLink(line, createLinkRunnable(line));
- } else {
- int symbolIndex = line.length() - symbols;
- String link = line.substring(0, symbolIndex);
- readText.appendLink(link, createLinkRunnable(link));
- st.append(line.substring(symbolIndex));
- }
- }
- line = null;
- break;
- }
- }
-
if (line != null && !line.equals("")) { //$NON-NLS-1$
int beforeMessageIndex = st.getText().length();
st.append(line);
@@ -1404,69 +1307,12 @@ public class ChatRoomManagerView extends ViewPart implements
return true;
}
- private Runnable createLinkRunnable(final String url) {
- return new Runnable() {
- public void run() {
- URL link = null;
- try {
- link = new URL(url);
- } catch (MalformedURLException e) {
- MessageDialog.openError(getSite().getShell(), "Link Error",
- "The link is not of a proper form");
- return;
- }
- if (browserSupport.isInternalWebBrowserAvailable()) {
- String pref = Activator
- .getDefault()
- .getPreferenceStore()
- .getString(ChatPreferencePage.PREF_BROWSER_FOR_CHAT);
- try {
- if (pref.equals(ChatPreferencePage.VIEW)) {
- browserSupport.createBrowser(
- IWorkbenchBrowserSupport.AS_VIEW,
- "org.eclipse.ecf", url, url).openURL(link);
- } else if (pref.equals(ChatPreferencePage.EDITOR)) {
- browserSupport.createBrowser(
- IWorkbenchBrowserSupport.AS_EDITOR,
- "org.eclipse.ecf", url, url).openURL(link);
- } else {
- try {
- browserSupport.getExternalBrowser().openURL(
- link);
- } catch (PartInitException ex) {
- MessageDialog.openError(getSite().getShell(),
- "Browser Error",
- "Could not open a browser instance.");
- }
- }
- } catch (PartInitException e) {
- try {
- browserSupport.getExternalBrowser().openURL(link);
- } catch (PartInitException ex) {
- MessageDialog.openError(getSite().getShell(),
- "Browser Error",
- "Could not open a browser instance.");
- }
- }
- } else {
- try {
- browserSupport.getExternalBrowser().openURL(link);
- } catch (PartInitException e) {
- MessageDialog.openError(getSite().getShell(),
- "Browser Error",
- "Could not open a browser instance.");
- }
- }
- }
- };
- }
-
- protected void appendText(SimpleLinkTextViewer readText, ChatLine text) {
+ protected void appendText(StyledText readText, ChatLine text) {
if (readText == null || text == null) {
return;
}
- StyledText st = readText.getTextWidget();
- if (st == null || intelligentAppend(readText, st, text)) {
+ StyledText st = readText;
+ if (st == null || intelligentAppend(st, text)) {
return;
}
int startRange = st.getText().length();
@@ -1532,18 +1378,17 @@ public class ChatRoomManagerView extends ViewPart implements
protected void outputClear() {
if (MessageDialog.openConfirm(null, "Confirm Clear Text Output",
"Are you sure you want to clear output?")) {
- readText.getTextWidget().setText(""); //$NON-NLS-1$
+ readText.setText(""); //$NON-NLS-1$
}
}
protected void outputCopy() {
- String t = readText.getTextWidget().getSelectionText();
+ String t = readText.getSelectionText();
if (t == null || t.length() == 0) {
- readText.getTextWidget().selectAll();
+ readText.selectAll();
}
- readText.getTextWidget().copy();
- readText.getTextWidget().setSelection(
- readText.getTextWidget().getText().length());
+ readText.copy();
+ readText.setSelection(readText.getText().length());
}
protected void outputPaste() {
@@ -1551,7 +1396,7 @@ public class ChatRoomManagerView extends ViewPart implements
}
protected void outputSelectAll() {
- readText.getTextWidget().selectAll();
+ readText.selectAll();
}
protected void makeActions() {
@@ -1611,9 +1456,36 @@ public class ChatRoomManagerView extends ViewPart implements
fillContextMenu(manager);
}
});
- Menu menu = menuMgr.createContextMenu(readText.getControl());
- readText.getControl().setMenu(menu);
- getSite().registerContextMenu(menuMgr, readText);
+ Menu menu = menuMgr.createContextMenu(readText);
+ readText.setMenu(menu);
+ ISelectionProvider selectionProvider = new ISelectionProvider() {
+
+ public void addSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+
+ public ISelection getSelection() {
+ ISelection selection = new TextSelection(readText
+ .getSelectionRange().x, readText.getSelectionRange().y);
+
+ return selection;
+ }
+
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+
+ public void setSelection(ISelection selection) {
+ if (selection instanceof ITextSelection) {
+ ITextSelection textSelection = (ITextSelection) selection;
+ readText.setSelection(textSelection.getOffset(),
+ textSelection.getOffset()
+ + textSelection.getLength());
+ }
+ }
+
+ };
+ getSite().registerContextMenu(menuMgr, selectionProvider);
}
private Color colorFromRGBString(String rgb) {
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatRoomView.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatRoomView.java
index fd9b446af..e7c7e1f45 100644
--- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatRoomView.java
+++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/ChatRoomView.java
@@ -35,6 +35,13 @@ import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
@@ -52,13 +59,16 @@ import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
-public class ChatRoomView extends ViewPart implements IChatRoomInvitationListener {
-
+public class ChatRoomView extends ViewPart implements
+ IChatRoomInvitationListener {
+
public static final String VIEW_ID = "org.eclipse.ecf.ui.views.ChatRoomView"; //$NON-NLS-1$
-
+
private static final String USERNAME_HOST_DELIMETER = "@";
private static final int RATIO_WRITE_PANE = 2;
@@ -93,7 +103,7 @@ public class ChatRoomView extends ViewPart implements IChatRoomInvitationListene
private Text writeText = null;
- private SimpleLinkTextViewer readText = null;
+ private StyledText readText = null;
private ListViewer memberViewer = null;
@@ -173,12 +183,17 @@ public class ChatRoomView extends ViewPart implements IChatRoomInvitationListene
readInlayComp.setLayout(new GridLayout());
readInlayComp.setLayoutData(new GridData(GridData.FILL_BOTH));
readInlayComp.setBackground(memberViewer.getList().getBackground());
- readText = new SimpleLinkTextViewer(readInlayComp, SWT.V_SCROLL
- | SWT.H_SCROLL | SWT.WRAP);
+ SourceViewer result = new SourceViewer(readInlayComp, null, null, true,
+ SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI | SWT.H_SCROLL
+ | SWT.READ_ONLY);
+ result.configure(new TextSourceViewerConfiguration(EditorsUI
+ .getPreferenceStore()));
+ result.setDocument(new Document());
+
+ readText = result.getTextWidget();
- readText.getTextWidget().setEditable(false);
- readText.getTextWidget()
- .setLayoutData(new GridData(GridData.FILL_BOTH));
+ readText.setEditable(false);
+ readText.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite writeComp = new Composite(rightSash, SWT.NONE);
writeComp.setLayout(new FillLayout());
@@ -327,7 +342,7 @@ public class ChatRoomView extends ViewPart implements IChatRoomInvitationListene
private static final long serialVersionUID = 2008114088656711572L;
ID id;
-
+
public Participant(ID id) {
this.id = id;
}
@@ -365,7 +380,9 @@ public class ChatRoomView extends ViewPart implements IChatRoomInvitationListene
return null;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.ecf.core.user.IUser#getNickname()
*/
public String getNickname() {
@@ -479,7 +496,7 @@ public class ChatRoomView extends ViewPart implements IChatRoomInvitationListene
}
protected void appendText(ChatLine text) {
- StyledText st = readText.getTextWidget();
+ StyledText st = readText;
if (text == null || readText == null || st == null)
return;
@@ -545,17 +562,16 @@ public class ChatRoomView extends ViewPart implements IChatRoomInvitationListene
protected void outputClear() {
if (MessageDialog.openConfirm(null, "Confirm Clear Text Output",
"Are you sure you want to clear output?"))
- readText.getTextWidget().setText("");
+ readText.setText("");
}
protected void outputCopy() {
- String t = readText.getTextWidget().getSelectionText();
+ String t = readText.getSelectionText();
if (t == null || t.length() == 0) {
- readText.getTextWidget().selectAll();
+ readText.selectAll();
}
- readText.getTextWidget().copy();
- readText.getTextWidget().setSelection(
- readText.getTextWidget().getText().length());
+ readText.copy();
+ readText.setSelection(readText.getText().length());
}
protected void outputPaste() {
@@ -577,9 +593,9 @@ public class ChatRoomView extends ViewPart implements IChatRoomInvitationListene
public void handleUpdated(IUser user) {
// XXX todo
}
-
+
protected void outputSelectAll() {
- readText.getTextWidget().selectAll();
+ readText.selectAll();
}
protected void makeActions() {
@@ -642,9 +658,36 @@ public class ChatRoomView extends ViewPart implements IChatRoomInvitationListene
fillContextMenu(manager);
}
});
- Menu menu = menuMgr.createContextMenu(readText.getControl());
- readText.getControl().setMenu(menu);
- getSite().registerContextMenu(menuMgr, readText);
+ Menu menu = menuMgr.createContextMenu(readText);
+ readText.setMenu(menu);
+ ISelectionProvider selectionProvider = new ISelectionProvider() {
+
+ public void addSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+
+ public ISelection getSelection() {
+ ISelection selection = new TextSelection(readText
+ .getSelectionRange().x, readText.getSelectionRange().y);
+
+ return selection;
+ }
+
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+
+ public void setSelection(ISelection selection) {
+ if (selection instanceof ITextSelection) {
+ ITextSelection textSelection = (ITextSelection) selection;
+ readText.setSelection(textSelection.getOffset(),
+ textSelection.getOffset()
+ + textSelection.getLength());
+ }
+ }
+
+ };
+ getSite().registerContextMenu(menuMgr, selectionProvider);
}
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/MessageLoader.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/MessageLoader.java
deleted file mode 100644
index c65b9d175..000000000
--- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/MessageLoader.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
- * Copyright (c) 2004 Composent, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Composent, Inc. - initial API and implementation
- *****************************************************************************/
-
-package org.eclipse.ecf.ui.views;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class MessageLoader {
-
- private static final String RESOURCE_BUNDLE = MessageLoader.class.getName();
-
- private static ResourceBundle fgResourceBundle = ResourceBundle
- .getBundle(RESOURCE_BUNDLE);
-
- private MessageLoader() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key
- * the string used to get the bundle value, must not be null
- */
- public static String getFormattedString(String key, Object arg) {
- return MessageFormat.format(getString(key), new Object[] { arg });
- }
-
- /**
- * Gets a string from the resource bundle and formats it with arguments
- */
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-
-}
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/MessageLoader.properties b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/MessageLoader.properties
deleted file mode 100644
index 8f6b73c5a..000000000
--- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/MessageLoader.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-TextChatComposite.textinputinit=<input chat text here>
-ChatWindow.titleprefix=
-
-

Back to the top