diff options
author | caniszczyk | 2007-07-24 15:25:19 +0000 |
---|---|---|
committer | caniszczyk | 2007-07-24 15:25:19 +0000 |
commit | 22fe895434029ae433f5830be5baba8d02f5e783 (patch) | |
tree | 1e3328c247c8c999024e2167dd8068f44ae79a08 /providers/bundles | |
parent | be56ebc7c7e031764f70a84338a9036f2737be74 (diff) | |
download | org.eclipse.ecf-22fe895434029ae433f5830be5baba8d02f5e783.tar.gz org.eclipse.ecf-22fe895434029ae433f5830be5baba8d02f5e783.tar.xz org.eclipse.ecf-22fe895434029ae433f5830be5baba8d02f5e783.zip |
bug 192762: [IRC] Support common operations on usernames like op,voice,etc
https://bugs.eclipse.org/bugs/show_bug.cgi?id=192762
Diffstat (limited to 'providers/bundles')
10 files changed, 268 insertions, 0 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.properties b/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.properties index 7d38f1344..782d6f462 100644 --- a/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.properties +++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.properties @@ -11,3 +11,11 @@ plugin.provider=Eclipse.org TextEditorHyperlinkTarget= Textual Editors IRCHyperlinkDetector= IRC + +KickAction_Label=Kick +BanAction_Label=Ban +OpAction_Label=Op +DeopAction_Label=Deop +VoiceAction_Label=Voice +DevoiceAction_Label=Devoice +WhoisAction_Label=Whois
\ No newline at end of file diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.xml b/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.xml index 1fcdc02dc..bc2a1d80e 100644 --- a/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.xml +++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.xml @@ -20,5 +20,60 @@ targetId="org.eclipse.ui.DefaultTextEditor"> </hyperlinkDetector> </extension> + <extension + point="org.eclipse.ui.popupMenus"> + <viewerContribution + id="org.eclipse.ecf.provider.irc.ui.viewerContribution1" + targetID="org.eclipse.ecf.presence.ui.chatroom.participantsView"> + <action + class="org.eclipse.ecf.internal.irc.ui.actions.KickAction" + id="org.eclipse.ecf.provider.irc.ui.action2" + label="%KickAction_Label" + menubarPath="additions"> + </action> + <action + class="org.eclipse.ecf.internal.irc.ui.actions.BanAction" + id="org.eclipse.ecf.provider.irc.ui.action2" + label="%BanAction_Label" + menubarPath="additions"> + </action> + <action + class="org.eclipse.ecf.internal.irc.ui.actions.OpAction" + id="org.eclipse.ecf.provider.irc.ui.action2" + label="%OpAction_Label" + menubarPath="additions"> + </action> + <action + class="org.eclipse.ecf.internal.irc.ui.actions.DeopAction" + id="org.eclipse.ecf.provider.irc.ui.action2" + label="%DeopAction_Label" + menubarPath="additions"> + </action> + <action + class="org.eclipse.ecf.internal.irc.ui.actions.VoiceAction" + id="org.eclipse.ecf.provider.irc.ui.action2" + label="%VoiceAction_Label" + menubarPath="additions"> + </action> + <action + class="org.eclipse.ecf.internal.irc.ui.actions.DevoiceAction" + id="org.eclipse.ecf.provider.irc.ui.action2" + label="%DevoiceAction_Label" + menubarPath="additions"> + </action> + <action + class="org.eclipse.ecf.internal.irc.ui.actions.WhoisAction" + id="org.eclipse.ecf.provider.irc.ui.action2" + label="%WhoisAction_Label" + menubarPath="additions"> + </action> + <visibility> + <objectState + name="scheme" + value="irc"> + </objectState> + </visibility> + </viewerContribution> + </extension> </plugin> diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/AbstractActionDelegate.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/AbstractActionDelegate.java new file mode 100644 index 000000000..c4458e975 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/AbstractActionDelegate.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2007 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: + * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 192762 + ******************************************************************************/ +package org.eclipse.ecf.internal.irc.ui.actions; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.ecf.core.user.IUser; +import org.eclipse.ecf.core.util.ECFException; +import org.eclipse.ecf.internal.irc.ui.Activator; +import org.eclipse.ecf.presence.chatroom.IChatRoomContainer; +import org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerView; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IViewActionDelegate; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.statushandlers.StatusManager; + +abstract public class AbstractActionDelegate implements IViewActionDelegate { + + private IUser user; + private String username; + private IChatRoomContainer chatRoomContainer; + + public AbstractActionDelegate() { + super(); + } + + protected abstract String getMessage(); + + protected String getUsername() { + if (username != null) { + return username; + } + + if (user != null) { + username = user.getName(); + if (username.startsWith("@")) { //$NON-NLS-1$ + username = username.substring(1); + } + return username; + } + + return null; + } + + public void run(IAction action) { + if ((chatRoomContainer == null) || (user == null)) { + return; + } + try { + chatRoomContainer.getChatRoomMessageSender().sendMessage(getMessage()); //$NON-NLS-1$ + } catch (ECFException e) { + StatusManager.getManager().handle(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); + } + } + + public void selectionChanged(IAction action, ISelection selection) { + if (! (selection instanceof IStructuredSelection)) { + return; + } + + user = (IUser) ((IStructuredSelection) selection).getFirstElement(); + } + + public void init(IViewPart view) { + chatRoomContainer = ((ChatRoomManagerView) view).getActiveChatRoomContainer(); + } + +} diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/BanAction.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/BanAction.java new file mode 100644 index 000000000..63d9d9950 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/BanAction.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2007 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: + * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 192762 + ******************************************************************************/ +package org.eclipse.ecf.internal.irc.ui.actions; + + +public class BanAction extends AbstractActionDelegate { + + protected String getMessage() { + return "/ban "+getUsername(); //$NON-NLS-1$ + } +} diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/DeopAction.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/DeopAction.java new file mode 100644 index 000000000..089f3f57a --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/DeopAction.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2007 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: + * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 192762 + ******************************************************************************/ +package org.eclipse.ecf.internal.irc.ui.actions; + +public class DeopAction extends AbstractActionDelegate { + + protected String getMessage() { + return "/dop "+getUsername(); //$NON-NLS-1$ + } +} diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/DevoiceAction.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/DevoiceAction.java new file mode 100644 index 000000000..b9463814c --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/DevoiceAction.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2007 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: + * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 192762 + ******************************************************************************/ +package org.eclipse.ecf.internal.irc.ui.actions; + +public class DevoiceAction extends AbstractActionDelegate { + + protected String getMessage() { + return "/mode -v "+getUsername(); //$NON-NLS-1$ + } +} diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/KickAction.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/KickAction.java new file mode 100644 index 000000000..06f767c61 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/KickAction.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2007 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: + * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 192762 + ******************************************************************************/ +package org.eclipse.ecf.internal.irc.ui.actions; + +public class KickAction extends AbstractActionDelegate { + + protected String getMessage() { + return "/kick "+getUsername(); //$NON-NLS-1$ + } +} diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/OpAction.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/OpAction.java new file mode 100644 index 000000000..ad4096e74 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/OpAction.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2007 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: + * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 192762 + ******************************************************************************/ +package org.eclipse.ecf.internal.irc.ui.actions; + +public class OpAction extends AbstractActionDelegate { + + protected String getMessage() { + return "/op "+getUsername(); //$NON-NLS-1$ + } +} diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/VoiceAction.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/VoiceAction.java new file mode 100644 index 000000000..f564be60a --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/VoiceAction.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2007 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: + * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 192762 + ******************************************************************************/ +package org.eclipse.ecf.internal.irc.ui.actions; + +public class VoiceAction extends AbstractActionDelegate { + + protected String getMessage() { + return "/mode +v "+getUsername(); //$NON-NLS-1$ + } +} diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/WhoisAction.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/WhoisAction.java new file mode 100644 index 000000000..a0395db4a --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/actions/WhoisAction.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2007 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: + * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 192762 + ******************************************************************************/ +package org.eclipse.ecf.internal.irc.ui.actions; + +public class WhoisAction extends AbstractActionDelegate { + + protected String getMessage() { + return "/whois "+getUsername(); //$NON-NLS-1$ + } +} |