示例#1
0
  /**
   * Adds the supplied collection of beans at the supplied index in the list of collections. If the
   * index is not supplied then the primary collection is set (i.e. index 0). Also adds the beans to
   * the supplied JComponent container (if not null)
   *
   * @param beanInstances a <code>Vector</code> value
   * @param container a <code>JComponent</code> value
   */
  public static void setBeanInstances(
      Vector<Object> beanInstances, JComponent container, Integer... tab) {
    removeAllBeansFromContainer(container, tab);

    if (container != null) {
      for (int i = 0; i < beanInstances.size(); i++) {
        Object bean = ((BeanInstance) beanInstances.elementAt(i)).getBean();
        if (Beans.isInstanceOf(bean, JComponent.class)) {
          container.add((JComponent) bean);
        }
      }
      container.revalidate();
      container.repaint();
    }

    int index = 0;
    if (tab.length > 0) {
      index = tab[0].intValue();
    }

    if (index < TABBED_COMPONENTS.size()) {
      TABBED_COMPONENTS.set(index, beanInstances);
    }

    // COMPONENTS = beanInstances;
  }
示例#2
0
  /**
   * Removes all beans from containing component
   *
   * @param container a <code>JComponent</code> value
   */
  public static void removeAllBeansFromContainer(JComponent container, Integer... tab) {

    int index = 0;
    if (tab.length > 0) {
      index = tab[0].intValue();
    }

    Vector<Object> components = null;
    if (TABBED_COMPONENTS.size() > 0 && index < TABBED_COMPONENTS.size()) {
      components = TABBED_COMPONENTS.get(index);
    }

    if (container != null) {
      if (components != null) {
        for (int i = 0; i < components.size(); i++) {
          Object tempInstance = components.elementAt(i);
          Object tempBean = ((BeanInstance) tempInstance).getBean();
          if (Beans.isInstanceOf(tempBean, JComponent.class)) {
            container.remove((JComponent) tempBean);
          }
        }
      }
      container.revalidate();
    }
  }
示例#3
0
 private void revalidateFilterLayout() {
   JComponent c = (JComponent) keyFilter.getParent();
   if (c != null) {
     c.revalidate();
     c.repaint();
   }
 }
示例#4
0
  /** Restore the original state of the Component */
  @Override
  public void mouseReleased(MouseEvent e) {
    if (!potentialDrag) {
      return;
    }

    source.removeMouseMotionListener(this);
    potentialDrag = false;

    if (changeCursor) {
      source.setCursor(originalCursor);
    }

    if (destination instanceof JComponent) {
      ((JComponent) destination).setAutoscrolls(autoscrolls);
    }

    // Layout the components on the parent container

    if (autoLayout) {
      if (destination instanceof JComponent) {
        ((JComponent) destination).revalidate();
      } else {
        destination.validate();
      }
    }
  }
  public void actionPerformed(ActionEvent ev) {
    if (collapsed) {
      if (label != null) {
        remove(label);
      }
      add(comp);
      moreOrLessButton.setIcon(collapseIcon);
    } else {
      remove(comp);
      if (valueLabelStr != null) {
        if (label == null) {
          label = new JLabel(Resources.format(Messages.CURRENT_VALUE, valueLabelStr));
        }
        add(label);
      }
      moreOrLessButton.setIcon(expandIcon);
    }
    collapsed = !collapsed;

    JComponent container = (JComponent) getParent();
    if (container != null && container.getLayout() instanceof VariableGridLayout) {

      ((VariableGridLayout) container.getLayout()).setFillRow(this, !collapsed);
      container.revalidate();
    }
  }
示例#6
0
  private void refreshMenu() {
    if (menuItems != null && menuItems.length > 0) {
      firstIndex = Math.max(topFixedCount, firstIndex);
      firstIndex = Math.min(menuItems.length - bottomFixedCount - scrollCount, firstIndex);

      upItem.setEnabled(firstIndex > topFixedCount);
      downItem.setEnabled(firstIndex + scrollCount < menuItems.length - bottomFixedCount);

      menu.removeAll();
      for (int i = 0; i < topFixedCount; i++) {
        menu.add(menuItems[i]);
      }
      if (topFixedCount > 0) {
        menu.addSeparator();
      }

      menu.add(upItem);
      for (int i = firstIndex; i < scrollCount + firstIndex; i++) {
        menu.add(menuItems[i]);
      }
      menu.add(downItem);

      if (bottomFixedCount > 0) {
        menu.addSeparator();
      }
      for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) {
        menu.add(menuItems[i]);
      }

      JComponent parent = (JComponent) upItem.getParent();
      parent.revalidate();
      parent.repaint();
    }
  }
  public void insertDraggableComponent(DraggableComponent component, int index) {
    component.setLayoutOrderList(layoutOrderList);

    component.addListener(draggableComponentListener);
    if (index < 0) {
      layoutOrderList.add(component.getComponent());
      componentBox.add(component.getComponent());
    } else {
      layoutOrderList.add(index, component.getComponent());
      componentBox.add(component.getComponent(), index);
    }

    sortComponentList(!descendingSortOrder);

    draggableComponentList.add(component);
    component.setOuterParentArea(outerParentArea);
    componentBox.revalidate();

    fireAddedEvent(component);
    if (autoSelect
        && layoutOrderList.size() == 1
        && selectedComponent == null
        && component.isEnabled()) doSelectComponent(component);

    updateScrollButtons();
  }
 public void refreshPanel() {
   criteriaListPanel.removeAll();
   criteriaList.clear();
   criteriaListPanel.revalidate();
   criteriaListPanel.repaint();
   setHeadersEnabled(false);
 }
示例#9
0
 public void revalidate() {
   if (c instanceof RootPaneContainer) {
     ((RootPaneContainer) c).getRootPane().revalidate();
   } else if (jc != null) {
     jc.revalidate();
   }
 }
示例#10
0
 /**
  * Removes a list of CardButtons from a JComponent
  *
  * @param list the list of CardButtons to be removed
  * @param fromWhere the JComponent to remove the CardButtons from
  */
 private void removeCardButtons(List<CardButton> list, JComponent fromWhere) {
   for (CardButton button : list) {
     fromWhere.remove(button);
     cardButtonMap.remove(button.getCard());
   }
   fromWhere.revalidate();
   validate();
 }
示例#11
0
  /**
   * Creates a CardButton and adds it to a JComponent
   *
   * @param card the card which the CardButton illustrates
   * @param where the JComponent to add it to
   * @return the created CardButton
   */
  private CardButton createCardGraphics(Card card, JComponent where) {
    CardButton sprite = createCardButton(card);

    where.add(sprite);
    where.revalidate();
    validate();

    return sprite;
  }
 private static void validateIfNeeded(final JComponent c, final Rectangle rect) {
   if (!Splitter.isNull(c)) {
     if (!c.getBounds().equals(rect)) {
       c.setBounds(rect);
       c.revalidate();
     }
   } else {
     Splitter.hideNull(c);
   }
 }
 @Override
 public void setFilter(@NotNull VcsLogFilter filter) {
   ApplicationManager.getApplication().assertIsDispatchThread();
   if (filter instanceof VcsLogBranchFilter) {
     myBranchFilterModel.setFilter((VcsLogBranchFilter) filter);
     JComponent toolbar = myUi.getMainFrame().getToolbar();
     toolbar.revalidate();
     toolbar.repaint();
   }
 }
示例#14
0
 /**
  * Creates CardButtons and adds them to a JComponent
  *
  * @param cards the cards which the CardButtons illustrate
  * @param where the JComponent to add them to
  * @return a list of the created CardButtons
  */
 private List<CardButton> createCardGraphics(List<Card> cards, JComponent where) {
   List<CardButton> rv = new ArrayList();
   for (Card card : cards) {
     CardButton sprite = createCardButton(card);
     where.add(sprite);
     rv.add(sprite);
   }
   where.revalidate();
   validate();
   return rv;
 }
 public void setComponentSpacing(int componentSpacing) {
   if (componentSpacing != getDirectionLayout().getComponentSpacing()) {
     if (getComponentSpacing() < 0 && componentSpacing >= 0) {
       DraggableComponent tmp = topComponent;
       sortComponentList(false);
       topComponent = tmp;
     }
     getDirectionLayout().setComponentSpacing(componentSpacing);
     sortComponentList(!descendingSortOrder);
     componentBox.revalidate();
   }
 }
 private static void processRootContainerResize(
     final RadContainer container, final boolean isRow, final int newSize) {
   final JComponent parentDelegee = container.getDelegee();
   Dimension containerSize = parentDelegee.getSize();
   if (isRow) {
     containerSize.height = newSize + parentDelegee.getBounds().y;
   } else {
     containerSize.width = newSize + parentDelegee.getBounds().x;
   }
   parentDelegee.setSize(containerSize);
   parentDelegee.revalidate();
 }
示例#17
0
  private void removeFromParent() {
    // Change visibility option
    opacity = 0f;

    // Remove file
    Container container = this.getParent();
    if (container != null && container instanceof JComponent) {
      JComponent parent = (JComponent) container;
      parent.remove(this);
      parent.revalidate();
      parent.repaint();
    }
  }
 /**
  * Selects the canvas at the specified index. If the index is out of bounds, perform no action.
  *
  * @param index - the index of the canvas to be viewed.
  * @requires none (INDEX DOES NOT HAVE TO BE WITHIN BOUNDS)
  */
 public void selectCanvas(int index) {
   if (index >= 0 && index < drawerCards.size()) {
     TabCard card = drawerCards.get(index);
     canvasPane.removeAll();
     canvasPane.add(card.getScroll());
     canvasPane.revalidate();
     canvasPane.repaint();
     for (TabCard otherCard : drawerCards) {
       otherCard.getButton().toggleSelected(false);
     }
     card.getButton().toggleSelected(true);
     this.selectedIndex = index;
     this.revalidate();
   }
 }
示例#19
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();
  }
示例#20
0
  /**
   * Adds the supplied collection of beans to the end of the list of collections and to the
   * JComponent container (if not null)
   *
   * @param beanInstances the vector of bean instances to add
   * @param container
   */
  public static void addBeanInstances(Vector<Object> beanInstances, JComponent container) {
    // reset(container);

    if (container != null) {
      for (int i = 0; i < beanInstances.size(); i++) {
        Object bean = ((BeanInstance) beanInstances.elementAt(i)).getBean();
        if (Beans.isInstanceOf(bean, JComponent.class)) {
          container.add((JComponent) bean);
        }
      }
      container.revalidate();
      container.repaint();
    }

    TABBED_COMPONENTS.add(beanInstances);
  }
  public void setSimulator(HackSimulatorGUI simulator) {
    ((JComponent) simulator).setLocation(0, TOOLBAR_HEIGHT);
    this.getContentPane().add((JComponent) simulator, null);
    ((JComponent) simulator).revalidate();
    repaint();

    if (simulator.getUsageFileName() != null) {
      usageWindow = new HTMLViewFrame(simulator.getUsageFileName());
      usageWindow.setSize(450, 430);
    }

    if (simulator.getAboutFileName() != null) {
      aboutWindow = new HTMLViewFrame(simulator.getAboutFileName());
      aboutWindow.setSize(450, 420);
    }
  }
示例#22
0
 void setSideTabsLimit(int sideTabsLimit) {
   if (mySideTabsLimit != sideTabsLimit) {
     mySideTabsLimit = sideTabsLimit;
     //      UIUtil.putClientProperty(myTabs, JBTabsImpl.SIDE_TABS_SIZE_LIMIT_KEY,
     // mySideTabsLimit);
     myTabs.resetLayout(true);
     myTabs.doLayout();
     myTabs.repaint();
     TabInfo info = myTabs.getSelectedInfo();
     JComponent page = info != null ? info.getComponent() : null;
     if (page != null) {
       page.revalidate();
       page.repaint();
     }
   }
 }
  /**
   * Sets current tool windows pane (panel where all tool windows are located). If <code>
   * toolWindowsPane</code> is <code>null</code> then the method just removes the current tool
   * windows pane.
   */
  final void setToolWindowsPane(@Nullable final ToolWindowsPane toolWindowsPane) {
    final JComponent contentPane = (JComponent) getContentPane();
    if (myToolWindowsPane != null) {
      contentPane.remove(myToolWindowsPane);
    }

    hideWelcomeScreen(contentPane);

    myToolWindowsPane = toolWindowsPane;
    if (myToolWindowsPane != null) {
      contentPane.add(myToolWindowsPane, BorderLayout.CENTER);
    } else if (!myApplication.isDisposeInProgress()) {
      showWelcomeScreen();
    }

    contentPane.revalidate();
  }
示例#24
0
  /**
   * Creates preview for the device(video) in the video container.
   *
   * @param device the device
   * @param videoContainer the container
   * @throws IOException a problem accessing the device.
   * @throws MediaException a problem getting preview.
   */
  private static void createPreview(MediaDevice device, final JComponent videoContainer)
      throws IOException, MediaException {
    videoContainer.removeAll();

    videoContainer.revalidate();
    videoContainer.repaint();

    if (device == null) return;

    Component c =
        (Component)
            GuiActivator.getMediaService()
                .getVideoPreviewComponent(
                    device, videoContainer.getSize().width, videoContainer.getSize().height);

    videoContainer.add(c);
  }
示例#25
0
    void validate() {
      Container parent =
          SwingUtilities.getAncestorOfClass(CollapsiblePaneContainer.class, JXCollapsiblePane.this);
      if (parent != null) {
        parent = ((CollapsiblePaneContainer) parent).getValidatingContainer();
      } else {
        parent = getParent();
      }

      if (parent != null) {
        if (parent instanceof JComponent) {
          ((JComponent) parent).revalidate();
        } else {
          parent.invalidate();
        }
        parent.doLayout();
        parent.repaint();
      }
    }
示例#26
0
  /**
   * Adds this bean to the global list of beans and to the supplied container. The constructor calls
   * this method, so a client should not need to unless they have called removeBean and then wish to
   * have it added again.
   *
   * @param container the Component on which this BeanInstance will be displayed
   */
  public void addBean(JComponent container, Integer... tab) {

    int index = 0;
    if (tab.length > 0) {
      index = tab[0].intValue();
    }

    Vector<Object> components = null;
    if (TABBED_COMPONENTS.size() > 0 && index < TABBED_COMPONENTS.size()) {
      components = TABBED_COMPONENTS.get(index);
    }

    // do nothing if we are already in the list
    if (components.contains(this)) {
      return;
    }

    // Ignore invisible components
    if (!Beans.isInstanceOf(m_bean, JComponent.class)) {
      System.out.println("Component is invisible!");
      return;
    }

    components.addElement(this);

    // Position and layout the component
    JComponent c = (JComponent) m_bean;
    Dimension d = c.getPreferredSize();
    int dx = (int) (d.getWidth() / 2);
    int dy = (int) (d.getHeight() / 2);
    m_x -= dx;
    m_y -= dy;
    c.setLocation(m_x, m_y);
    // c.doLayout();
    c.validate();
    // bp.addBean(c);
    // c.repaint();
    if (container != null) {
      container.add(c);
      container.revalidate();
    }
  }
示例#27
0
  public static void appendBeans(JComponent container, Vector<Object> beans, int tab) {
    if (TABBED_COMPONENTS.size() > 0 && tab < TABBED_COMPONENTS.size()) {
      Vector<Object> components = TABBED_COMPONENTS.get(tab);
      //

      for (int i = 0; i < beans.size(); i++) {
        components.add(beans.get(i));
        if (container != null) {
          Object bean = ((BeanInstance) beans.elementAt(i)).getBean();
          if (Beans.isInstanceOf(bean, JComponent.class)) {
            container.add((JComponent) bean);
          }
        }
      }

      if (container != null) {
        container.revalidate();
        container.repaint();
      }
    }
  }
  public void setSize(final Dimension size) {
    if (myIsRealPopup && myPopup != null) {
      // There is a possible case that a popup wraps target content component into other components
      // which might have borders.
      // That's why we can't just apply component's size to the whole popup. It needs to be adjusted
      // before that.
      JComponent popupContent = myPopup.getContent();
      int widthExpand = 0;
      int heightExpand = 0;
      boolean adjustSize = false;
      JComponent prev = myComponent;
      for (Container c = myComponent.getParent(); c != null; c = c.getParent()) {
        if (c == popupContent) {
          adjustSize = true;
          break;
        }
        if (c instanceof JComponent) {
          Border border = ((JComponent) c).getBorder();
          if (prev != null && border != null) {
            Insets insets = border.getBorderInsets(prev);
            widthExpand += insets.left + insets.right;
            heightExpand += insets.top + insets.bottom;
          }
          prev = (JComponent) c;
        } else {
          prev = null;
        }
      }
      Dimension sizeToUse = size;
      if (adjustSize && (widthExpand != 0 || heightExpand != 0)) {
        sizeToUse = new Dimension(size.width + widthExpand, size.height + heightExpand);
      }
      myPopup.setSize(sizeToUse);
    } else if (!isAwtTooltip()) {
      myComponent.setSize(size);

      myComponent.revalidate();
      myComponent.repaint();
    }
  }
  public void removeDraggableComponent(DraggableComponent component) {
    if (component != null && draggableComponentList.contains(component)) {
      // component.abortDrag();
      int index = layoutOrderList.indexOf(component.getComponent());
      component.removeListener(draggableComponentListener);
      if (component == topComponent) topComponent = null;
      if (layoutOrderList.size() > 1 && selectedComponent != null) {
        if (selectedComponent == component) {
          if (autoSelect) {
            int selectIndex = findSelectableComponentIndex(index);
            if (selectIndex > -1)
              selectDraggableComponent(
                  findDraggableComponent((Component) layoutOrderList.get(selectIndex)));
            else selectedComponent = null;
          } else {
            selectDraggableComponent(null);
          }
        }
      } else {
        if (selectedComponent != null) {
          DraggableComponent oldSelected = selectedComponent;
          selectedComponent = null;
          fireSelectedEvent(selectedComponent, oldSelected);
        }
      }
      draggableComponentList.remove(component);
      layoutOrderList.remove(component.getComponent());
      componentBox.remove(component.getComponent());
      componentBox.revalidate();
      // componentBox.validate();
      component.setLayoutOrderList(null);

      sortComponentList(!descendingSortOrder);

      updateScrollButtons();

      fireRemovedEvent(component);
    }
  }
示例#30
0
  /**
   * Creates preview for the (video) device in the video container.
   *
   * @param device the device
   * @param videoContainer the video container
   * @throws IOException a problem accessing the device
   * @throws MediaException a problem getting preview
   */
  private static void createVideoPreview(CaptureDeviceInfo device, JComponent videoContainer)
      throws IOException, MediaException {
    videoContainer.removeAll();

    videoContainer.revalidate();
    videoContainer.repaint();

    if (device == null) return;

    for (MediaDevice mediaDevice : mediaService.getDevices(MediaType.VIDEO, MediaUseCase.ANY)) {
      if (((MediaDeviceImpl) mediaDevice).getCaptureDeviceInfo().equals(device)) {
        Dimension videoContainerSize = videoContainer.getPreferredSize();
        Component preview =
            (Component)
                mediaService.getVideoPreviewComponent(
                    mediaDevice, videoContainerSize.width, videoContainerSize.height);

        if (preview != null) videoContainer.add(preview);
        break;
      }
    }
  }