Examples of RibbonTask


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

      int width = 0;
      int maxMinBandHeight = 0;
      int gap = getBandGap();

      // minimum is when all the tasks are collapsed
      RibbonTask selectedTask = ribbon.getSelectedTask();
      // System.out.println(selectedTask.getTitle() + " min width");
      for (AbstractRibbonBand ribbonBand : selectedTask.getBands()) {
        int bandPrefHeight = ribbonBand.getMinimumSize().height;
        Insets bandInsets = ribbonBand.getInsets();
        RibbonBandUI bandUI = ribbonBand.getUI();
        int preferredCollapsedWidth = bandUI
            .getPreferredCollapsedWidth()
            + bandInsets.left + bandInsets.right;
        width += preferredCollapsedWidth;
        // System.out.println("\t" + ribbonBand.getTitle() + ":" +
        // preferredCollapsedWidth);
        maxMinBandHeight = Math.max(maxMinBandHeight, bandPrefHeight
        // + bandInsets.top + bandInsets.bottom
            );
      }
      // add inter-band gaps
      width += gap * (selectedTask.getBandCount() + 1);
      // System.out.println("\t" + gap + "*" +
      // (selectedTask.getBandCount() + 1));

      // System.out.println(selectedTask.getTitle() + " min width:" +
      // width);
View Full Code Here

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

      // the top row - task bar components
      int x = 0;
      int y = 0;

      RibbonTask selectedTask = ribbon.getSelectedTask();
      if (selectedTask == null)
        return;

      // check that the resize policies are still consistent
      for (AbstractRibbonBand<?> band : selectedTask.getBands()) {
        FlamingoUtilities.checkResizePoliciesConsistency(band);
      }

      // start with the most "permissive" resize policy for each band
      for (AbstractRibbonBand<?> band : selectedTask.getBands()) {
        List<RibbonBandResizePolicy> policies = band
            .getResizePolicies();
        RibbonBandResizePolicy last = policies.get(0);
        band.setCurrentResizePolicy(last);
      }

      int availableBandHeight = c.getHeight();
      int availableWidth = c.getWidth();
      if (selectedTask.getBandCount() > 0) {
        RibbonBandResizeSequencingPolicy resizeSequencingPolicy = selectedTask
            .getResizeSequencingPolicy();
        resizeSequencingPolicy.reset();
        AbstractRibbonBand<?> currToTakeFrom = resizeSequencingPolicy
            .next();
        while (true) {
          // check whether all bands have the current resize
          // policy as their last (most restrictive) registered policy
          boolean noMore = true;
          for (AbstractRibbonBand<?> band : selectedTask.getBands()) {
            RibbonBandResizePolicy currentResizePolicy = band
                .getCurrentResizePolicy();
            List<RibbonBandResizePolicy> resizePolicies = band
                .getResizePolicies();
            if (currentResizePolicy != resizePolicies
                .get(resizePolicies.size() - 1)) {
              noMore = false;
              break;
            }
          }
          if (noMore)
            break;

          // get the current preferred width of the bands
          int totalWidth = 0;
          // System.out.println("Iteration");
          for (AbstractRibbonBand<?> ribbonBand : selectedTask
              .getBands()) {
            RibbonBandResizePolicy currentResizePolicy = ribbonBand
                .getCurrentResizePolicy();

            Insets ribbonBandInsets = ribbonBand.getInsets();
            AbstractBandControlPanel controlPanel = ribbonBand
                .getControlPanel();
            if (controlPanel == null) {
              controlPanel = ribbonBand.getPopupRibbonBand()
                  .getControlPanel();
            }
            Insets controlPanelInsets = controlPanel.getInsets();
            int controlPanelGap = controlPanel.getUI()
                .getLayoutGap();
            int ribbonBandHeight = availableBandHeight
                - ribbonBandInsets.top
                - ribbonBandInsets.bottom;
            int availableHeight = ribbonBandHeight
                - ribbonBand.getUI().getBandTitleHeight();
            if (controlPanel != null) {
              availableHeight = availableHeight
                  - controlPanelInsets.top
                  - controlPanelInsets.bottom;
            }
            int preferredWidth = currentResizePolicy
                .getPreferredWidth(availableHeight,
                    controlPanelGap)
                + ribbonBandInsets.left
                + ribbonBandInsets.right;
            totalWidth += preferredWidth + bandGap;
            // System.out.println("\t"
            // + ribbonBand.getTitle()
            // + ":"
            // + currentResizePolicy.getClass()
            // .getSimpleName() + ":" + preferredWidth
            // + " under " + availableHeight + " with "
            // + controlPanel.getComponentCount()
            // + " children");
          }
          // System.out.println("\t:Total:" + totalWidth + "("
          // + availableWidth + ")");
          // System.out.println("\n");
          if (totalWidth < availableWidth)
            break;

          // try to take from the currently rotating band
          List<RibbonBandResizePolicy> policies = currToTakeFrom
              .getResizePolicies();
          int currPolicyIndex = policies.indexOf(currToTakeFrom
              .getCurrentResizePolicy());
          if (currPolicyIndex == (policies.size() - 1)) {
            // nothing to take
          } else {
            currToTakeFrom.setCurrentResizePolicy(policies
                .get(currPolicyIndex + 1));
          }
          currToTakeFrom = resizeSequencingPolicy.next();
        }
      }

      boolean ltr = c.getComponentOrientation().isLeftToRight();
      x = ltr ? 1 : c.getWidth() - 1;
      // System.out.println("Will get [" + availableWidth + "]:");
      for (AbstractRibbonBand<?> ribbonBand : selectedTask.getBands()) {
        Insets ribbonBandInsets = ribbonBand.getInsets();
        RibbonBandResizePolicy currentResizePolicy = ribbonBand
            .getCurrentResizePolicy();
        AbstractBandControlPanel controlPanel = ribbonBand
            .getControlPanel();
View Full Code Here

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

  public Collection<RibbonTask> createRibbon(String name, CustomRibbonBandGenerator customBandsGenerator) throws MissingResourceException, ResourceFormatException, MissingListenerException {
    List<RibbonTask> ribbonTasks=new ArrayList<RibbonTask>();
    @SuppressWarnings("unchecked")
    List<String> taskNames = (List<String>)getStringList(name);
    for (String taskName : taskNames){
      RibbonTask task=createRibbonTask(taskName, customBandsGenerator);
      ribbonTasks.add(task);
    }
    return ribbonTasks;
  }
View Full Code Here

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

      AbstractRibbonBand<?> band=createRibbonBand(bandName, customBandsGenerator);
      ribbonBands.add(band);
    }
    AbstractRibbonBand<?>[] bands=ribbonBands.toArray(new AbstractRibbonBand<?>[ribbonBands.size()]);   
   
    RibbonTask result = new RibbonTask(title,bands);   

    return result;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.