Package net.laubenberger.bogatyr.view.swing

Examples of net.laubenberger.bogatyr.view.swing.Menu


    if (!getModules().isEmpty()) {
      result = new ArrayList<JMenu>();
      for (final Module module : getModules()) {
        if (module.getModuleEnabled()) {
          final JMenu menu = new Menu(module.getModel().getName(), controller.getScaledIcon(module.getLogo()),
              module.getModel().getName(), 0);
          for (final Object item : module.getMenuItems()) {
            if (item instanceof Action) {
              menu.add((Action) item);
            } else if (item instanceof JComponent) {
              menu.add((JComponent) item);
            } else {
              log.warn("Unsupported object in getMenuItems() of module " + module.getModel().getName() + ": " //$NON-NLS-1$//$NON-NLS-2$
                  + item);
            }
          }
View Full Code Here


//  }

  private JMenu getMenuLanguage() {
    if (log.isTraceEnabled()) log.trace(HelperLog.methodStart());

    final JMenu result = new Menu(localizer.getValue(HelperResource.RES_ACTION_LOCALE), controller.getScaledIcon(Icon.LOCALE),
        localizer.getTooltip(HelperResource.RES_ACTION_LOCALE), localizer.getMnemonic(HelperResource.RES_ACTION_LOCALE));
    final ButtonGroup group = new ButtonGroup();

    final List<Language> list = localizer.getAvailableLanguages();
    Collections.sort(list, new Comparator<Language>() {
      @Override
      public int compare(final Language arg0, final Language arg1) {
        return arg0.getName(localizer.getLocale()).compareTo(arg1.getName(localizer.getLocale()));
      }
    });

    for (final Language language : list) {
      final JMenuItem item = new MenuItemRadioButton(language.getName(localizer.getLocale()));
      item.setIcon(controller.getScaledIcon(new ScalableIconImpl(language.getIcon())));
      item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
          localizer.setLocale(language.getLocale());
          data.setLanguage(language);
        }
      });
      item.setSelected(HelperObject
          .isEquals(localizer.getLocale().getLanguage(), language.getLocale().getLanguage()));
      result.add(item);
      group.add(item);
    }

    if (log.isTraceEnabled()) log.trace(HelperLog.methodExit(result));
    return result;
View Full Code Here

  }

  private JMenu getMenuLookAndFeel() {
    if (log.isTraceEnabled()) log.trace(HelperLog.methodStart());

    final JMenu result = new Menu(localizer.getValue(HelperResource.RES_ACTION_LAF), controller.getScaledIcon(Icon.LAF), localizer
        .getTooltip(HelperResource.RES_ACTION_LAF), localizer.getMnemonic(HelperResource.RES_ACTION_LAF));
    final ButtonGroup group = new ButtonGroup();
   
    // Java L&F
    final List<LookAndFeelInfo> list = HelperSwing.getAvailableLookAndFeels();
    Collections.sort(list, new Comparator<LookAndFeelInfo>() {
      @Override
      public int compare(final LookAndFeelInfo arg0, final LookAndFeelInfo arg1) {
        return arg0.getName().compareTo(arg1.getName());
      }
    });

    for (final LookAndFeelInfo info : list) {
      final JMenuItem item = new MenuItemRadioButton(info.getName());
      item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
          try {
            UIManager.setLookAndFeel(info.getClassName());

            data.setLookAndFeel(info.getClassName());
            data.setFontSizeOffset(0);
          } catch (Exception ex) {
            log.error("Could not initialize L&F", ex); //$NON-NLS-1$
          }
        }
      });
      item.setSelected(HelperObject.isEquals(info.getClassName(), UIManager.getLookAndFeel().getClass()
          .getCanonicalName()));
      result.add(item);
      group.add(item);
    }

    result.add(new JXTitledSeparator("Substance", SwingConstants.CENTER)); //$NON-NLS-1$

    // Substance L&F
    final SubstanceSkin skin = SubstanceLookAndFeel.getCurrentSkin();
    for (final SkinInfo info : SubstanceLookAndFeel.getAllSkins().values()) {
      final JMenuItem item = new MenuItemRadioButton(info.getDisplayName());
      item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
          SubstanceLookAndFeel.setSkin(info.getClassName());

          data.setLookAndFeel(info.getClassName());
        }
      });
      if (null != skin) {
        item.setSelected(HelperObject.isEquals(info.getClassName(), skin.getClass().getCanonicalName()));
      }
      result.add(item);
      group.add(item);
    }

    if (log.isTraceEnabled()) log.trace(HelperLog.methodExit(result));
    return result;
View Full Code Here

  }

  private JMenu getMenuFontSize() {
    if (log.isTraceEnabled()) log.trace(HelperLog.methodStart());

    final JMenu result = new Menu(localizer.getValue(HelperResource.RES_ACTION_FONT_SIZE), controller.getScaledIcon(Icon.FONT),
        localizer.getTooltip(HelperResource.RES_ACTION_FONT_SIZE), localizer.getMnemonic(HelperResource.RES_ACTION_FONT_SIZE));
    final ButtonGroup group = new ButtonGroup();

    final List<Integer> list = HelperCollection.getList(-4, -2, 0, 2, 4, 8, 12, 16, 24, 32, 48, 64);

    for (final Integer value : list) {
      final JMenuItem item = new MenuItemRadioButton(value.toString());
      item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
          try {
            SubstanceLookAndFeel.setFontPolicy(null);
            // Get the default font set
            final FontSet substanceCoreFontSet = SubstanceLookAndFeel.getFontPolicy().getFontSet("Substance", null); //$NON-NLS-1$

            // Create the wrapper font set
            final FontPolicy newFontPolicy = new FontPolicy() {
              @Override
              public FontSet getFontSet(final String lafName, final UIDefaults table) {
                return new WrapperFontSet(substanceCoreFontSet, value);
              }
            };

            // set the new font policy
            SubstanceLookAndFeel.setFontPolicy(newFontPolicy);

            data.setFontSizeOffset(value);
          } catch (Exception ex) {
            if (log.isWarnEnabled()) log.warn("Could not change the font size", ex); //$NON-NLS-1$
            data.setFontSizeOffset(0);
          }
        }
      });
      item.setSelected(data.getFontSizeOffset() == value);
      result.add(item);
      group.add(item);
    }

    result.setEnabled(HelperString.contains(data.getLookAndFeel(), ID_SUBSTANCE_NS));
   
    if (log.isTraceEnabled()) log.trace(HelperLog.methodExit(result));
    return result;
  }
View Full Code Here

  }

  private JMenu getMenuIconSize() {
    if (log.isTraceEnabled()) log.trace(HelperLog.methodStart());

    final JMenu result = new Menu(localizer.getValue(HelperResource.RES_ACTION_ICONS), controller.getScaledIcon(Icon.ICONS), localizer
        .getTooltip(HelperResource.RES_ACTION_ICONS), localizer.getMnemonic(HelperResource.RES_ACTION_ICONS));
    final ButtonGroup groupIcon = new ButtonGroup();

    final JMenuItem itemNoneIcon = new MenuItemRadioButton(localizer.getValue(HelperResource.RES_LABEL_NO_ICONS));
    itemNoneIcon.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(final ActionEvent e) {
        data.setIconSize(new Dimension(0, 0));
//        iconSizeChanged();
      }
    });
    itemNoneIcon.setSelected(0 == data.getIconSize().width);
    result.add(itemNoneIcon);
    groupIcon.add(itemNoneIcon);
   
    result.addSeparator();
   
    final List<Integer> list = HelperCollection.getList(8, 12, 16, 20, 24, 28, 32, 48, 64, 96, 128);

    for (final Integer value : list) {
      final JMenuItem item = new MenuItemRadioButton(value.toString());
      item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
          data.setIconSize(new Dimension(value, 0));
//          iconSizeChanged();
        }
      });
      item.setSelected(data.getIconSize().width == value);
      result.add(item);
      groupIcon.add(item);
    }

    if (log.isTraceEnabled()) log.trace(HelperLog.methodExit(result));
    return result;
View Full Code Here

TOP

Related Classes of net.laubenberger.bogatyr.view.swing.Menu

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.