Fixes missing account setup and improves menu account info menu

handling.
cusax-fix 4927
yanas 12 years ago
parent 9383a5e000
commit 47d352bca8

@ -21,6 +21,8 @@
import net.java.sip.communicator.impl.gui.main.configforms.*;
import net.java.sip.communicator.impl.gui.main.contactlist.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.plugin.desktoputil.SwingWorker;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.gui.Container;
import net.java.sip.communicator.service.notification.*;
@ -29,18 +31,20 @@
import net.java.sip.communicator.util.Logger;
import net.java.sip.communicator.util.account.*;
import net.java.sip.communicator.util.skin.*;
import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.plugin.desktoputil.SwingWorker;
import org.jitsi.service.configuration.*;
import org.jitsi.service.resources.*;
import org.jitsi.util.*;
import org.osgi.framework.*;
/**
* The <tt>FileMenu</tt> is a menu in the main application menu bar that
* contains "New account".
* The <tt>ToolsMenu</tt> is a menu in the contact list / chat panel bars that
* contains "Tools". This menu is separated in different sections by
* <tt>JSeparator</tt>s. These sections are ordered in the following matter:
* 0 0 0 | 1 1 | 2 2... where numbers indicate the indices of the corresponding
* sections and | are separators. Currently, section 0 contains "Options",
* "Create a video bridge", "Create a conference call"... until the first
* <tt>JSeparator</tt> after which starts the next section - section 1.
*
* @author Yana Stamcheva
* @author Lyubomir Marinov
@ -184,8 +188,11 @@ private void initPluginComponents()
{
public void run()
{
add((Component) f.getPluginComponentInstance(
ToolsMenu.this).getComponent());
PluginComponent pluginComponent =
f.getPluginComponentInstance(ToolsMenu.this);
insertInSection(
(JMenuItem) pluginComponent.getComponent(),
pluginComponent.getPositionIndex());
}
});
}
@ -309,7 +316,11 @@ public void pluginComponentAdded(PluginComponentEvent event)
{
public void run()
{
add((Component) c.getPluginComponentInstance(ToolsMenu.this));
PluginComponent pluginComponent =
c.getPluginComponentInstance(ToolsMenu.this);
insertInSection(
(JMenuItem) pluginComponent.getComponent(),
pluginComponent.getPositionIndex());
}
});
@ -435,6 +446,61 @@ private void registerMenuItems()
loadSkin();
}
/**
* Keeps track of the indices of <tt>JSeparator</tt>s
* that are places within this <tt>Container</tt>
*/
private List<Integer> separatorIndices = new LinkedList<Integer>();
/**
* When a new separator is added to this <tt>Container</tt> its position
* will be saved in separatorIndices.
*/
public void addSeparator()
{
super.addSeparator();
separatorIndices.add(this.getMenuComponentCount() - 1);
}
/**
* Inserts the given <tt>JMenuItem</tt> at the end of the specified section.
* Sections are ordered in the following matter: 0 0 0 | 1 1 | 2 2 ...
*
* @param item The <tt>JMenuItem</tt> that we insert
*
* @param section The section index in which we want to insert the specified
* <tt>JMenuItem</tt>. If section is < 0 or section is >= the
* <tt>JSeparator</tt>s count in this menu, this item will be inserted at
* the end of the menu.
*
* @return The inserted <tt>JMenuItem</tt>
*/
private JMenuItem insertInSection(JMenuItem item, int section)
{
if (section < 0 || section >= separatorIndices.size())
{
add(item);
return item;
}
// Gets the index of the separator so we can insert the JMenuItem
// before it.
int separatorIndex = separatorIndices.get(section);
// All following separators' positions must be incremented because we
// will insert a new JMenuItem before them.
ListIterator<Integer> it = separatorIndices.listIterator(section);
while (it.hasNext())
{
int i = it.next() + 1;
it.remove();
it.add(i);
}
insert(item, separatorIndex);
return item;
}
/**
* Returns a list of all available video bridge providers.
*

@ -11,15 +11,16 @@
import javax.imageio.*;
import org.jitsi.service.fileaccess.FileCategory;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.ServerStoredDetails.DisplayNameDetail;
import net.java.sip.communicator.service.protocol.ServerStoredDetails.GenericDetail;
import net.java.sip.communicator.service.protocol.ServerStoredDetails.ImageDetail;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*;
import net.sf.jml.*;
import org.jitsi.service.fileaccess.*;
/**
* Saves account avatar image. If one is already saved we set it as initial one
* for the MsnOwner.
@ -254,17 +255,8 @@ public Iterator<Class<? extends GenericDetail>> getSupportedDetailTypes()
public boolean isDetailClassSupported(
Class<? extends GenericDetail> detailClass)
{
List<GenericDetail> details = getContactDetails(uin);
Iterator<GenericDetail> iter = details.iterator();
while (iter.hasNext())
{
GenericDetail obj = iter.next();
if (detailClass.isAssignableFrom(obj.getClass()))
{
return true;
}
}
return false;
return ImageDetail.class.isAssignableFrom(detailClass) ||
DisplayNameDetail.class.isAssignableFrom(detailClass);
}
/**

@ -116,4 +116,17 @@ public String getName()
return
Resources.getString("plugin.accountinfo.TITLE");
}
/**
* Returns the position of this <tt>PluginComponent</tt> within its
* <tt>Container</tt>
*
* @return Always returns 0. 0 is index of the first section in the "Tools"
* menu bar in the Contacts list that also contains "Options",
* "Create a video bridge" etc...
*/
public int getPositionIndex()
{
return 0;
}
}

@ -681,4 +681,15 @@ public void valueChanged(ListSelectionEvent e)
}
}
}
/**
* Returns the index indicating the position of this menu in its container.
*
* @return -1 to indicate that this menu should take the last position
*/
@Override
public int getPositionIndex()
{
return -1;
}
}

@ -51,6 +51,15 @@ public interface PluginComponent
*/
public Object getComponent();
/**
* Returns the position of this <tt>PluginComponent</tt> within its
* <tt>Container</tt>
*
* @return The position of this <tt>PluginComponent</tt> within its
* <tt>Container</tt>
*/
public int getPositionIndex();
/**
* Sets the current contact. Meant to be used by plugin components that
* are interested of the current contact. The current contact is the contact

Loading…
Cancel
Save