Package org.pushingpixels.flamingo.api.common

Examples of org.pushingpixels.flamingo.api.common.JCommandButton$PopupHandler


      CommandButtonDisplayState state,
      CommandButtonKind commandButtonKind, int fontSize) {
    ResizableIcon mainPasteIcon = SvgBatikResizableIcon.getSvgIcon(
        TestCommandButtons.class.getClassLoader().getResource(
            "test/svg/edit-paste.svg"), new Dimension(32, 32));
    JCommandButton mainButton = new JCommandButton(text, mainPasteIcon);
    mainButton.setDisabledIcon(new FilteredResizableIcon(mainPasteIcon,
        new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY),
            null)));
    // mainButton.setMnemonic('P');
    mainButton.setExtraText("Extra for " + text.toLowerCase());
    mainButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        System.out.println("Action invoked");
      }
    });
    mainButton.setPopupCallback(new PopupPanelCallback() {
      @Override
      public JPopupPanel getPopupPanel(JCommandButton commandButton) {
        return new SamplePopupMenu(commandButton
            .getComponentOrientation());
      }
    });
    mainButton.setCommandButtonKind(commandButtonKind);
    mainButton.setDisplayState(state);
    mainButton.setFlat(false);
    mainButton.setFont(mainButton.getFont().deriveFont((float) fontSize));
    return mainButton;
  }
View Full Code Here


      private JRibbonBand createBand(int buttonCount, String title,
          String titlePrefix) {
        JRibbonBand result = new JRibbonBand(title,
            new EmptyResizableIcon(32));
        for (int i = 0; i < buttonCount; i++) {
          result.addCommandButton(new JCommandButton(titlePrefix
              + (i + 1), new EmptyResizableIcon(32)),
              RibbonElementPriority.TOP);
        }
        return result;
      }
View Full Code Here

  private static JRibbonBand getSampleRibbonBand(
      ActionListener expandActionListener) {
    JRibbonBand clipboardBand = new JRibbonBand("Clipboard",
        new edit_paste(), expandActionListener);

    JCommandButton mainButton = new JCommandButton("Paste",
        new edit_paste());
    mainButton
        .setCommandButtonKind(JCommandButton.CommandButtonKind.ACTION_AND_POPUP_MAIN_ACTION);
    clipboardBand.addCommandButton(mainButton, RibbonElementPriority.TOP);

    JCommandButton cutButton = new JCommandButton("Cut", new edit_cut());
    cutButton
        .setCommandButtonKind(JCommandButton.CommandButtonKind.ACTION_AND_POPUP_MAIN_ACTION);
    clipboardBand.addCommandButton(cutButton, RibbonElementPriority.MEDIUM);

    JCommandButton copyButton = new JCommandButton("Copy", new edit_copy());
    copyButton
        .setCommandButtonKind(JCommandButton.CommandButtonKind.ACTION_AND_POPUP_MAIN_POPUP);
    clipboardBand
        .addCommandButton(copyButton, RibbonElementPriority.MEDIUM);

    JCommandButton formatButton = new JCommandButton("Format",
        new edit_paste());
    formatButton
        .setCommandButtonKind(JCommandButton.CommandButtonKind.POPUP_ONLY);
    clipboardBand.addCommandButton(formatButton,
        RibbonElementPriority.MEDIUM);

    List<RibbonBandResizePolicy> resizePolicies = new ArrayList<RibbonBandResizePolicy>();
View Full Code Here

              List<AFreeplaneAction> openActions = lastOpenedList.createOpenLastMapActionList();
              for (AFreeplaneAction action : openActions) {
                String restoreable = (String) action.getValue(Action.DEFAULT);
                StringTokenizer tokens = new StringTokenizer(restoreable, ";");
                File file = lastOpenedList.createFileFromRestorable(tokens);
                JCommandButton menuButton = new JCommandButton(file.getName());
                menuButton.addActionListener(action);
                menuButton.setCommandButtonKind(CommandButtonKind.ACTION_ONLY);
                menuButton.setHorizontalAlignment(SwingUtilities.LEADING);
                menuButton.setPopupOrientationKind(CommandButtonPopupOrientationKind.SIDEWARD);
                menuButton.setEnabled(true);
                menuButton.setActionRichTooltip(new RichTooltip((String) action
                    .getValue(Action.SHORT_DESCRIPTION), file.toString()));
                secondary.addButtonToLastGroup(menuButton);
              }
              JScrollablePanel<JCommandButtonPanel> scrollPanel = new JScrollablePanel<JCommandButtonPanel>(
                  secondary, ScrollType.VERTICALLY);
View Full Code Here

  public static JCommandButton createCommandButton(final AFreeplaneAction action) {
    String title = ActionUtils.getActionTitle(action);
    ResizableIcon icon = ActionUtils.getActionIcon(action);
   
    final JCommandButton button = new JCommandButton(title, icon);
   
    updateRichTooltip(button, action, null);
    button.addActionListener(new RibbonActionListener(action));
    button.setFocusable(false);
    return button;
  }
View Full Code Here

        }
        else {
          final String name = attributes.getProperty("name");
          if(name != null) {
            AFreeplaneAction action = ActionUtils.getDummyAction(name);
            final JCommandButton button = new JCommandButton(ActionUtils.getActionTitle(action), ActionUtils.getActionIcon(action));
            button.putClientProperty(ACTION_NAME_PROPERTY, action);
            updateRichTooltip(button, action, null);
            if(context.hasChildren(context.getCurrentPath())) {
              StructurePath path = context.getCurrentPath();
              button.setPopupCallback(getPopupPanelCallBack(path, context));
              button.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
            }
            button.setFocusable(false);
            parent.addChild(button, childProps);
          }
        }
      }
     
      private PopupPanelCallback getPopupPanelCallBack(StructurePath path, final RibbonBuildContext context) {
        childButtons.clear();
        context.processChildren(path, this);
        return new PopupPanelCallback() {
         
          public JPopupPanel getPopupPanel(JCommandButton commandButton) {
            JCommandPopupMenu popupmenu = new JCommandPopupMenu();
            for (Component comp : childButtons) {
              if(comp instanceof JSeparator) {
                popupmenu.addMenuSeparator();
              }
              else if(comp instanceof AbstractCommandButton) {
                AbstractCommandButton button = (AbstractCommandButton) comp;
               
                AbstractCommandButton menuButton = null;               
                AFreeplaneAction action = (AFreeplaneAction)button.getClientProperty(ACTION_KEY_PROPERTY);
                if(action != null) {
                  if(isSelectionListener(action)) {
                    menuButton = createCommandToggleMenuButton(action);
                    popupmenu.addMenuButton((JCommandToggleMenuButton) menuButton);
                  }
                  else {
                    menuButton = createCommandMenuButton(action);
                    popupmenu.addMenuButton((JCommandMenuButton) menuButton);
                  }
                  menuButton.setEnabled(button.isEnabled());
                  menuButton.putClientProperty(ACTION_KEY_PROPERTY, action);
                  KeyStroke ks = context.getBuilder().getAcceleratorManager().getAccelerator(action.getKey());
                  updateRichTooltip(menuButton, action, ks);
                  updateActionState(action, menuButton);
                }
                else {
                  action = (AFreeplaneAction)button.getClientProperty(ACTION_NAME_PROPERTY);
                  menuButton = createCommandMenuButton(action);
                  if(action != null) {
                    menuButton.putClientProperty(ACTION_NAME_PROPERTY, action);
                    updateRichTooltip(menuButton, action, null);
                  }
                }
               
                if(button instanceof JCommandButton) {
                  if(((JCommandButton) button).getPopupCallback() != null) {
                    ((JCommandMenuButton)menuButton).setPopupCallback(((JCommandButton) button).getPopupCallback());
                    ((JCommandMenuButton)menuButton).setCommandButtonKind(((JCommandButton) button).getCommandButtonKind());                   
                  }
                }
                //clear all RibbonActionListeners from the menuButton
                for (ActionListener listener : menuButton.getListeners(ActionListener.class)) {
                  if(listener instanceof RibbonActionListener) {
                    menuButton.removeActionListener(listener);
                  }
                }
                //add
                for (ActionListener listener : button.getListeners(ActionListener.class)) {
                  if(listener instanceof RibbonActionListener) {
                    menuButton.addActionListener(listener);
                  }
                }
               
View Full Code Here

            throw new RuntimeException("cannot resolve icon " + path);
        return ImageWrapperResizableIcon.getIcon(url, new Dimension(16, 16));
    }

    private void addScriptsPopup(ARibbonContributor parent) {
        JCommandButton button = RibbonActionContributorFactory
            .createCommandButton(ActionUtils.getDummyAction(getKey()));
        button.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
        button.setPopupCallback(new PopupPanelCallback() {
            public JPopupPanel getPopupPanel(JCommandButton commandButton) {
                JCommandPopupMenu popupmenu = new JCommandPopupMenu();
                registerScripts(popupmenu);
                return popupmenu;
            }
View Full Code Here

      public void contribute(final RibbonBuildContext context, ARibbonContributor parent) {
        if (parent == null) {
          return;
        }       
       
        JCommandButton button = new JCommandButton(TextUtils.removeTranslateComment(TextUtils.getText("FilterCondition")));
        button.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
        button.setPopupCallback(new PopupPanelCallback() {
          public JPopupPanel getPopupPanel(JCommandButton commandButton) {
            JCommandPopupMenu popupmenu = new JCommandPopupMenu();
             
              AFreeplaneAction action = context.getBuilder().getMode().getAction("ApplyToVisibleAction");
              JCommandToggleMenuButton toggleButton = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
View Full Code Here

        JRibbonBand band = new JRibbonBand(TextUtils.removeTranslateComment(TextUtils.getText("ribbon.band.edgeStyles")), null, null);
        band.setExpandButtonKeyTip("ES");
        band.setCollapsedStateKeyTip("ZE");

        JCommandButton styleGroupButton = new JCommandButton(TextUtils.removeTranslateComment(TextUtils.getText("edgeStyleGroupAction.text")));       
        styleGroupButton.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
        AFreeplaneAction action = context.getBuilder().getMode().getAction("EdgeStyleAsParentAction");
        final JCommandToggleMenuButton styleAsParent = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
        addDefaultToggleHandler(context, action, styleAsParent);
        action = context.getBuilder().getMode().getAction("EdgeStyleAction.linear");
        final JCommandToggleMenuButton styleLinear = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
        addDefaultToggleHandler(context, action, styleLinear);
        action = context.getBuilder().getMode().getAction("EdgeStyleAction.bezier");
        final JCommandToggleMenuButton styleBezier = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
        addDefaultToggleHandler(context, action, styleBezier);
        action = context.getBuilder().getMode().getAction("EdgeStyleAction.sharp_linear");
        final JCommandToggleMenuButton styleSharpLinear = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
        addDefaultToggleHandler(context, action, styleSharpLinear);
        action = context.getBuilder().getMode().getAction("EdgeStyleAction.sharp_bezier");
        final JCommandToggleMenuButton styleSharpBezier = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
        addDefaultToggleHandler(context, action, styleSharpBezier);
        action = context.getBuilder().getMode().getAction("EdgeStyleAction.horizontal");
        final JCommandToggleMenuButton styleHorizontal = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
        addDefaultToggleHandler(context, action, styleHorizontal);
        action = context.getBuilder().getMode().getAction("EdgeStyleAction.hide_edge");
        final JCommandToggleMenuButton styleHideEdge = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
        addDefaultToggleHandler(context, action, styleHideEdge);

        ButtonGroup group = new ButtonGroup();
        styleAsParent.getActionModel().setGroup(group);
        styleLinear.getActionModel().setGroup(group);
        styleAsParent.getActionModel().setGroup(group);
        styleBezier.getActionModel().setGroup(group);
        styleAsParent.getActionModel().setGroup(group);
        styleSharpLinear.getActionModel().setGroup(group);
        styleAsParent.getActionModel().setGroup(group);
        styleSharpBezier.getActionModel().setGroup(group);
        styleAsParent.getActionModel().setGroup(group);
        styleHorizontal.getActionModel().setGroup(group);
        styleAsParent.getActionModel().setGroup(group);
        styleHideEdge.getActionModel().setGroup(group);
        styleAsParent.getActionModel().setGroup(group);

        styleGroupButton.setPopupCallback(new PopupPanelCallback() {
          public JPopupPanel getPopupPanel(JCommandButton commandButton) {
            JCommandPopupMenu popupmenu = new JCommandPopupMenu();
            popupmenu.addMenuButton(styleAsParent);
            popupmenu.addMenuButton(styleLinear);
            popupmenu.addMenuButton(styleBezier);
            popupmenu.addMenuButton(styleSharpLinear);
            popupmenu.addMenuButton(styleSharpBezier);
            popupmenu.addMenuButton(styleHorizontal);
            popupmenu.addMenuButton(styleHideEdge);
            return popupmenu;
          }
        });

        band.addCommandButton(styleGroupButton, RibbonElementPriority.MEDIUM);

        JCommandButton lineWidthGroupButton = new JCommandButton(TextUtils.removeTranslateComment(TextUtils.getText("edgeLineWidthGroupAction.text")));
        lineWidthGroupButton.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);       
        action = context.getBuilder().getMode().getAction("EdgeWidthAction_width_parent");
        final JCommandToggleMenuButton widthParent = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
        addDefaultToggleHandler(context, action, widthParent);
        action = context.getBuilder().getMode().getAction("EdgeWidthAction_width_thin");
        final JCommandToggleMenuButton widthThin = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
        addDefaultToggleHandler(context, action, widthThin);
        action = context.getBuilder().getMode().getAction("EdgeWidthAction_1");
        final JCommandToggleMenuButton width1 = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
        addDefaultToggleHandler(context, action, width1);
        action = context.getBuilder().getMode().getAction("EdgeWidthAction_2");
        final JCommandToggleMenuButton width2 = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
        addDefaultToggleHandler(context, action, width2);
        action = context.getBuilder().getMode().getAction("EdgeWidthAction_4");
        final JCommandToggleMenuButton width4 = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
        addDefaultToggleHandler(context, action, width4);
        action = context.getBuilder().getMode().getAction("EdgeWidthAction_8");
        final JCommandToggleMenuButton width8 = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
        addDefaultToggleHandler(context, action, width8);

        lineWidthGroupButton.setPopupCallback(new PopupPanelCallback() {
          public JPopupPanel getPopupPanel(JCommandButton commandButton) {
            JCommandPopupMenu popupmenu = new JCommandPopupMenu();
            popupmenu.addMenuButton(widthParent);
            popupmenu.addMenuButton(widthThin);
            popupmenu.addMenuButton(width1);
            popupmenu.addMenuButton(width2);
            popupmenu.addMenuButton(width4);
            popupmenu.addMenuButton(width8);
            return popupmenu;
          }
        });

        band.addCommandButton(lineWidthGroupButton, RibbonElementPriority.MEDIUM);

        action = context.getBuilder().getMode().getAction("EdgeColorAction");
        final JCommandButton edgeColorButton = RibbonActionContributorFactory.createCommandButton(action);
        band.addCommandButton(edgeColorButton, RibbonElementPriority.MEDIUM);

        action = context.getBuilder().getMode().getAction("AutomaticEdgeColorHookAction");
        //RIBBONS
//        KeyStroke ks =RibbonAcceleratorManager.parseKeyStroke("j2ef2");
//        context.getBuilder().getAcceleratorManager().setAccelerator(action, ks);
//        RibbonActionContributorFactory.updateRichTooltip(button, action, ks);
        final JCommandButton automaticColorButton = RibbonActionContributorFactory.createCommandButton(action);
        band.addCommandButton(automaticColorButton, RibbonElementPriority.MEDIUM);

        List<RibbonBandResizePolicy> policies = new ArrayList<RibbonBandResizePolicy>();
        policies.add(new CoreRibbonResizePolicies.Mirror(band.getControlPanel()));
        policies.add(new CoreRibbonResizePolicies.High2Mid(band.getControlPanel()));
View Full Code Here

        band.addFlowComponent(zoomBox);
       
        JCommandButtonStrip strip = new JCommandButtonStrip();
               
        AFreeplaneAction action = context.getBuilder().getMode().getAction("ZoomInAction");       
        JCommandButton button = RibbonActionContributorFactory.createCommandButton(action);       
        button.setDisplayState(CommandButtonDisplayState.SMALL);
        getAccelChangeListener().addAction(action.getKey(), button);
        addDefaultToggleHandler(context, action, button);
        strip.add(button);
       
        action = context.getBuilder().getMode().getAction("ZoomOutAction");       
        button = RibbonActionContributorFactory.createCommandButton(action);       
        button.setDisplayState(CommandButtonDisplayState.SMALL);
        getAccelChangeListener().addAction(action.getKey(), button);
        addDefaultToggleHandler(context, action, button);
        strip.add(button);
       
        action = context.getBuilder().getMode().getAction("FitToPage");       
        button = RibbonActionContributorFactory.createCommandButton(action);       
        button.setDisplayState(CommandButtonDisplayState.MEDIUM);
        getAccelChangeListener().addAction(action.getKey(), button);
        addDefaultToggleHandler(context, action, button);
        strip.add(button);
       
        band.addFlowComponent(strip);
View Full Code Here

TOP

Related Classes of org.pushingpixels.flamingo.api.common.JCommandButton$PopupHandler

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.