Package org.pushingpixels.flamingo.api.ribbon

Examples of org.pushingpixels.flamingo.api.ribbon.AbstractRibbonBand


     *
     * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
     */
    public void layoutContainer(Container c) {
      JFlowBandControlPanel flowBandControlPanel = (JFlowBandControlPanel) c;
      AbstractRibbonBand ribbonBand = flowBandControlPanel
          .getRibbonBand();
      RibbonBandResizePolicy currentResizePolicy = ribbonBand
          .getCurrentResizePolicy();
      if (currentResizePolicy == null)
        return;

      boolean ltr = c.getComponentOrientation().isLeftToRight();
      // need place for border
      Insets ins = c.getInsets();
      int x = ins.left;
      int gap = getLayoutGap();
      int availableHeight = c.getHeight() - ins.top - ins.bottom;

      if (SwingUtilities.getAncestorOfClass(
          CollapsedButtonPopupPanel.class, c) != null) {
        List<RibbonBandResizePolicy> resizePolicies = ribbonBand
            .getResizePolicies();
        // install the most permissive resize policy on the popup
        // panel of a collapsed ribbon band
        resizePolicies.get(0).install(availableHeight, gap);
      } else {
View Full Code Here


     * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
     */
    @Override
        public void layoutContainer(Container c) {
      JFlowBandControlPanel flowBandControlPanel = (JFlowBandControlPanel) c;
      AbstractRibbonBand ribbonBand = flowBandControlPanel
          .getRibbonBand();
      RibbonBandResizePolicy currentResizePolicy = ribbonBand
          .getCurrentResizePolicy();
      if (currentResizePolicy == null)
        return;

      boolean ltr = c.getComponentOrientation().isLeftToRight();
      // need place for border
      Insets ins = c.getInsets();
      int x = ins.left;
      int gap = getLayoutGap();
      int availableHeight = c.getHeight() - ins.top - ins.bottom;

      if (SwingUtilities.getAncestorOfClass(
          CollapsedButtonPopupPanel.class, c) != null) {
        List<RibbonBandResizePolicy> resizePolicies = ribbonBand
            .getResizePolicies();
        // install the most permissive resize policy on the popup
        // panel of a collapsed ribbon band
        resizePolicies.get(0).install(availableHeight, gap);
      } else {
View Full Code Here

      this.nextIndex = this.ribbonTask.getBandCount() - 1;
    }

    @Override
    public AbstractRibbonBand next() {
      AbstractRibbonBand result = this.ribbonTask.getBand(this.nextIndex);
      this.nextIndex--;
      if (this.nextIndex < 0)
        this.nextIndex = this.ribbonTask.getBandCount() - 1;
      return result;
    }
View Full Code Here

      this.nextIndex = this.ribbonTask.getBandCount() - 1;
    }

    @Override
    public AbstractRibbonBand next() {
      AbstractRibbonBand result = this.ribbonTask.getBand(this.nextIndex);

      // check whether the current resize policy on the returned ribbon
      // band is the last
      List<RibbonBandResizePolicy> resizePolicies = result
          .getResizePolicies();
      if (result.getCurrentResizePolicy() == resizePolicies
          .get(resizePolicies.size() - 1)) {
        this.nextIndex--;
        if (this.nextIndex < 0)
          this.nextIndex = 0;
      }
View Full Code Here

    super(controlPanel);
  }

  @Override
  public int getPreferredWidth(int availableHeight, int gap) {
    AbstractRibbonBand ribbonBand = this.controlPanel.getRibbonBand();
    RibbonBandUI ui = ribbonBand.getUI();
    return ui.getPreferredCollapsedWidth();
  }
View Full Code Here

                int prefHeight = bandScrollablePanel.getView()
                    .getPreferredSize().height;
                Insets ins = ribbon.getInsets();
                prefHeight += ins.top + ins.bottom;
                AbstractRibbonBand band = (ribbon
                    .getSelectedTask().getBandCount() > 0) ? ribbon
                    .getSelectedTask().getBand(0)
                    : null;
                if (band != null) {
                  Insets bandIns = band.getInsets();
                  prefHeight += bandIns.top + bandIns.bottom;
                }

                // System.out.println(prefHeight
                // + ":"
                // + bandScrollablePanel.getView()
                // .getComponentCount());

                JPopupPanel popupPanel = new BandHostPopupPanel(
                    bandScrollablePanel, new Dimension(
                        ribbon.getWidth(), prefHeight));

                int x = ribbon.getLocationOnScreen().x;
                int y = ribbon.getLocationOnScreen().y
                    + ribbon.getHeight();

                // make sure that the popup stays in
                // bounds
                Rectangle scrBounds = ribbon
                    .getGraphicsConfiguration().getBounds();
                int pw = popupPanel.getPreferredSize().width;
                if ((x + pw) > (scrBounds.x + scrBounds.width)) {
                  x = scrBounds.x + scrBounds.width - pw;
                }
                int ph = popupPanel.getPreferredSize().height;
                if ((y + ph) > (scrBounds.y + scrBounds.height)) {
                  y = scrBounds.y + scrBounds.height - ph;
                }

                // get the popup and show it
                popupPanel.setPreferredSize(new Dimension(
                    ribbon.getWidth(), prefHeight));
                Popup popup = PopupFactory.getSharedInstance()
                    .getPopup(taskToggleButton, popupPanel,
                        x, y);
                PopupPanelManager.PopupListener tracker = new PopupPanelManager.PopupListener() {
                  @Override
                  public void popupShown(PopupEvent event) {
                    JComponent originator = event
                        .getPopupOriginator();
                    if (originator instanceof JRibbonTaskToggleButton) {
                      bandScrollablePanel.doLayout();
                      bandScrollablePanel.repaint();
                    }
                  }

                  @Override
                  public void popupHidden(PopupEvent event) {
                    JComponent originator = event
                        .getPopupOriginator();
                    if (originator instanceof JRibbonTaskToggleButton) {
                      ribbon.add(bandScrollablePanel);
                      PopupPanelManager.defaultManager()
                          .removePopupListener(this);
                      ribbon.revalidate();
                      ribbon.doLayout();
                      ribbon.repaint();
                    }
                  }
                };
                PopupPanelManager.defaultManager()
                    .addPopupListener(tracker);
                PopupPanelManager.defaultManager().addPopup(
                    taskToggleButton, popup, popupPanel);
              }
            }
          });
        }
      });
      // wire listener to toggle ribbon minimization on double
      // mouse click
      taskToggleButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
          if ((ribbon.getSelectedTask() == task)
              && (e.getClickCount() == 2)) {
            boolean wasMinimized = ribbon.isMinimized();
            ribbon.setMinimized(!wasMinimized);
            if (!wasMinimized) {
              // fix for issue 69 - mark the ribbon as
              // "just minimized" to prevent the action handler
              // of the toggle button to show the ribbon in
              // popup mode
              ribbon.putClientProperty(JUST_MINIMIZED,
                  Boolean.TRUE);
            }
          }
        }
      });
      // set the background hue color on the tab buttons
      // of tasks in contextual groups
      if (task.getContextualGroup() != null) {
        taskToggleButton.setContextualGroupHueColor(task
            .getContextualGroup().getHueColor());
      }

      taskToggleButton.putClientProperty(
          BasicCommandButtonUI.DONT_DISPOSE_POPUPS, Boolean.TRUE);

      this.taskToggleButtonGroup.add(taskToggleButton);
      taskToggleButtonsHostPanel.add(taskToggleButton);
      this.taskToggleButtons.put(task, taskToggleButton);
    }

    JRibbonTaskToggleButton toSelect = this.taskToggleButtons
        .get(selectedTask);
    if (toSelect != null) {
      toSelect.getActionModel().setSelected(true);
    }

    for (int i = 0; i < this.ribbon.getTaskCount(); i++) {
      RibbonTask task = this.ribbon.getTask(i);
      for (AbstractRibbonBand band : task.getBands()) {
        bandHostPanel.add(band);
        band.setVisible(selectedTask == task);
      }
    }
    for (int i = 0; i < this.ribbon.getContextualTaskGroupCount(); i++) {
      RibbonContextualTaskGroup taskGroup = this.ribbon
          .getContextualTaskGroup(i);
      for (int j = 0; j < taskGroup.getTaskCount(); j++) {
        RibbonTask task = taskGroup.getTask(j);
        for (AbstractRibbonBand band : task.getBands()) {
          bandHostPanel.add(band);
          band.setVisible(selectedTask == task);
        }
      }
    }

    ActionListener helpListener = this.ribbon.getHelpActionListener();
View Full Code Here

TOP

Related Classes of org.pushingpixels.flamingo.api.ribbon.AbstractRibbonBand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.