/**
   * Shows on the right the configuration form given by the given <tt>ConfigFormDescriptor</tt>.
   *
   * @param configForm the configuration form to show
   */
  private void showFormContent(ConfigurationForm configForm) {
    this.centerPanel.removeAll();

    JComponent configFormPanel = (JComponent) configForm.getForm();

    configFormPanel.setOpaque(false);

    this.centerPanel.add(configFormPanel, BorderLayout.CENTER);

    this.centerPanel.revalidate();
    this.centerPanel.repaint();
  }
示例#2
0
  /**
   * Adds the component of a specific <tt>PluginComponent</tt> to the associated <tt>Container</tt>.
   *
   * @param c the <tt>PluginComponent</tt> which is to have its component added to the
   *     <tt>Container</tt> associated with this <tt>PluginContainer</tt>
   */
  private synchronized void addPluginComponent(PluginComponent c) {
    /*
     * Try to respect positionIndex of PluginComponent to some extent:
     * PluginComponents with positionIndex equal to 0 go at the beginning,
     * these with positionIndex equal to -1 follow them and then go these
     * with positionIndex greater than 0.
     */
    int cIndex = c.getPositionIndex();
    int index = -1;
    int i = 0;

    for (PluginComponent pluginComponent : pluginComponents) {
      if (pluginComponent.equals(c)) return;

      if (-1 == index) {
        int pluginComponentIndex = pluginComponent.getPositionIndex();

        if ((0 == cIndex) || (-1 == cIndex)) {
          if ((0 != pluginComponentIndex) && (cIndex != pluginComponentIndex)) index = i;
        } else if (cIndex < pluginComponentIndex) index = i;
      }

      i++;
    }

    int pluginComponentCount = pluginComponents.size();

    if (-1 == index) index = pluginComponents.size();

    /*
     * The container may have added Components of its own apart from the
     * ones this PluginContainer has added to it. Since the common case for
     * the additional Components is to have them appear at the beginning,
     * adjust the index so it gets correct in the common case.
     */
    int containerComponentCount = getComponentCount(container);

    addComponentToContainer(
        (Component) c.getComponent(),
        container,
        (containerComponentCount > pluginComponentCount)
            ? (index + (containerComponentCount - pluginComponentCount))
            : index);
    pluginComponents.add(index, c);

    container.revalidate();
    container.repaint();
  }
示例#3
0
  /**
   * Runs clean-up for associated resources which need explicit disposal (e.g. listeners keeping
   * this instance alive because they were added to the model which operationally outlives this
   * instance).
   */
  public void dispose() {
    GuiActivator.getUIService().removePluginComponentListener(this);

    /*
     * Explicitly remove the components of the PluginComponent instances
     * because the latter are registered with OSGi and are thus global.
     */
    synchronized (this) {
      for (PluginComponent pluginComponent : pluginComponents)
        container.remove((Component) pluginComponent.getComponent());
      pluginComponents.clear();
    }
  }
示例#4
0
 /**
  * Adds a specific <tt>Component</tt> to a specific <tt>JComponent</tt> container. Allows
  * extenders to apply custom logic to the exact placement of the specified <tt>Component</tt> in
  * the specified container.
  *
  * @param component the <tt>Component</tt> to be added to the specified <tt>JComponent</tt>
  *     container
  * @param container the <tt>JComponent</tt> container to add the specified <tt>Component</tt> to
  * @param preferredIndex the index at which <tt>component</tt> is to be added to
  *     <tt>container</tt> if possible or <tt>-1</tt> if there is no preference with respect to the
  *     index in question
  */
 protected void addComponentToContainer(
     Component component, JComponent container, int preferredIndex) {
   if ((0 <= preferredIndex) && (preferredIndex < getComponentCount(container)))
     container.add(component, preferredIndex);
   else container.add(component);
 }
示例#5
0
 /**
  * Removes the component of a specific <code>PluginComponent</code> from this <code>
  * PluginContainer</code>.
  *
  * @param c the <code>PluginComponent</code> which is to have its component removed from this
  *     <code>PluginContainer</code>
  */
 private synchronized void removePluginComponent(PluginComponent c) {
   container.remove((Component) c.getComponent());
   pluginComponents.remove(c);
 }
示例#6
0
 /**
  * Gets the number of <tt>Component</tt>s in a specific <tt>JComponent</tt> container. For
  * example, returns the result of <tt>getMenuComponentCount()</tt> if <tt>container</tt> is an
  * instance of <tt>JMenu</tt>.
  *
  * @param container the <tt>JComponent</tt> container to get the number of <tt>Component</tt>s of
  * @return the number of <tt>Component</tt>s in the specified <tt>container</tt>
  */
 protected int getComponentCount(JComponent container) {
   return (container instanceof JMenu)
       ? ((JMenu) container).getMenuComponentCount()
       : container.getComponentCount();
 }