Package de.yaams.extensions.basemap.tiled.mapeditor.widget

Examples of de.yaams.extensions.basemap.tiled.mapeditor.widget.TMenuItem


  /**
   * Creates all the menus and submenus of the top menu bar. Handles assigning
   * listeners and tooltips as well.
   */
  private void createMenuBar() {
    JMenuItem save = new TMenuItem(saveAction);
    JMenuItem saveAs = new TMenuItem(saveAsAction);
    JMenuItem saveAsImage = new TMenuItem(saveAsImageAction);
    // JMenuItem close = new TMenuItem(new CloseMapAction(this,
    // saveAction));

    recentMenu = new JMenu(Resources.getString("menu.file.recent"));

    mapEventAdapter.addListener(save);
    mapEventAdapter.addListener(saveAs);
    mapEventAdapter.addListener(saveAsImage);
    // mapEventAdapter.addListener(close);

    JMenu fileMenu = new JMenu(Resources.getString("menu.file"));
    // fileMenu.add(new TMenuItem(new NewMapAction(this, saveAction)));
    // fileMenu.add(new TMenuItem(new OpenMapAction(this, saveAction)));
    // fileMenu.add(recentMenu);
    fileMenu.add(save);
    fileMenu.add(saveAs);
    fileMenu.add(saveAsImage);
    fileMenu.addSeparator();
    // fileMenu.add(close);
    fileMenu.add(new TMenuItem(exitAction));

    JMenuItem copyMenuItem = new TMenuItem(new CopyAction());
    JMenuItem copyAllMenuItem = new TMenuItem(new CopyAllAction());
    JMenuItem cutMenuItem = new TMenuItem(new CutAction());
    JMenuItem pasteMenuItem = new TMenuItem(new PasteAction());
    copyMenuItem.setEnabled(false);
    copyAllMenuItem.setEnabled(false);
    cutMenuItem.setEnabled(false);
    pasteMenuItem.setEnabled(false);

    JMenu transformSub = new JMenu(Resources.getString("menu.edit.transform"));
    transformSub.add(new TMenuItem(rot90Action, true));
    transformSub.add(new TMenuItem(rot180Action, true));
    transformSub.add(new TMenuItem(rot270Action, true));
    transformSub.addSeparator();
    transformSub.add(new TMenuItem(flipHorAction, true));
    transformSub.add(new TMenuItem(flipVerAction, true));
    mapEventAdapter.addListener(transformSub);

    JMenu editMenu = new JMenu(Resources.getString("menu.edit"));
    editMenu.add(new TMenuItem(undoHandler.getUndoAction()));
    editMenu.add(new TMenuItem(undoHandler.getRedoAction()));
    editMenu.addSeparator();
    editMenu.add(copyMenuItem);
    editMenu.add(copyAllMenuItem);
    editMenu.add(cutMenuItem);
    editMenu.add(pasteMenuItem);
    editMenu.addSeparator();
    editMenu.add(transformSub);
    editMenu.addSeparator();
    editMenu.add(createMenuItem(Resources.getString("menu.edit.preferences"), null,
        Resources.getString("menu.edit.preferences.tooltip"), null));
    editMenu.add(createMenuItem(Resources.getString("menu.edit.brush"), null, Resources.getString("menu.edit.brush.tooltip"),
        "control B"));

    mapEventAdapter.addListener(copyMenuItem);
    mapEventAdapter.addListener(copyAllMenuItem);
    mapEventAdapter.addListener(cutMenuItem);
    mapEventAdapter.addListener(pasteMenuItem);

    JMenu mapMenu = new JMenu(Resources.getString("menu.map"));
    mapMenu.add(createMenuItem(Resources.getString("menu.map.resize"), null, Resources.getString("menu.map.resize.tooltip")));
    mapMenu.add(createMenuItem(Resources.getString("menu.map.search"), null, Resources.getString("menu.map.search.tooltip")));
    // mapMenu.addSeparator();
    // mapMenu.add(createMenuItem(Resources.getString("menu.map.properties"),
    // null, Resources.getString("menu.map.properties.tooltip")));
    mapEventAdapter.addListener(mapMenu);

    JMenu layerMenu = new JMenu(Resources.getString("menu.layer"));
    JMenuItem layerAdd = new TMenuItem(addLayerAction);
    mapEventAdapter.addListener(layerAdd);
    layerMenu.add(layerAdd);
    layerMenu.add(new TMenuItem(cloneLayerAction));
    layerMenu.add(new TMenuItem(deleteLayerAction));
    // layerMenu.addSeparator();
    // layerMenu.add(new TMenuItem(addObjectGroupAction));
    layerMenu.addSeparator();
    layerMenu.add(new TMenuItem(moveLayerUpAction));
    layerMenu.add(new TMenuItem(moveLayerDownAction));
    layerMenu.addSeparator();
    layerMenu.add(new TMenuItem(mergeLayerDownAction));
    layerMenu.add(new TMenuItem(mergeAllLayersAction));
    layerMenu.addSeparator();
    layerMenu.add(createMenuItem(Resources.getString("menu.layer.properties"), null,
        Resources.getString("menu.layer.properties.tooltip")));

    JMenu tilesetMenu = new JMenu(Resources.getString("menu.tilesets"));
    // tilesetMenu.add(createMenuItem(
    // Resources.getString("menu.tilesets.new"), null,
    // Resources.getString("menu.tilesets.new.tooltip")));
    // tilesetMenu.add(createMenuItem(
    // Resources.getString("menu.tilesets.import"), null,
    // Resources.getString("menu.tilesets.import.tooltip")));
    // tilesetMenu.addSeparator();
    tilesetMenu.add(createMenuItem(Resources.getString("menu.tilesets.refresh"), null,
        Resources.getString("menu.tilesets.refresh.tooltip"), "F5"));
    // tilesetMenu.addSeparator();
    // tilesetMenu.add(createMenuItem(Resources.getString("menu.tilesets.manager"),
    // null,
    // Resources.getString("menu.tilesets.manager.tooltip")));

    /*
     * objectMenu = new JMenu("Objects");
     * objectMenu.add(createMenuItem("Add Object", null, "Add an object"));
     * mapEventAdapter.addListener(objectMenu);
     *
     * JMenu modifySub = new JMenu("Modify");
     * modifySub.add(createMenuItem("Expand Selection", null, ""));
     * modifySub.add(createMenuItem("Contract Selection", null, ""));
     */

    JMenu selectMenu = new JMenu(Resources.getString("menu.select"));
    selectMenu.add(new TMenuItem(selectAllAction, true));
    selectMenu.add(new TMenuItem(cancelSelectionAction, true));
    selectMenu.add(new TMenuItem(inverseAction, true));
    // selectMenu.addSeparator();
    // selectMenu.add(modifySub);

    gridMenuItem = new JCheckBoxMenuItem(Resources.getString("menu.view.grid"));
    gridMenuItem.addActionListener(this);
    gridMenuItem.setToolTipText(Resources.getString("menu.view.grid.tooltip"));
    gridMenuItem.setAccelerator(KeyStroke.getKeyStroke("control G"));

    cursorMenuItem = new JCheckBoxMenuItem(Resources.getString("menu.view.cursor"));
    cursorMenuItem.setSelected(prefs.getBoolean("cursorhighlight", true));
    cursorMenuItem.addActionListener(this);
    cursorMenuItem.setToolTipText(Resources.getString("menu.view.cursor.tooltip"));

    boundaryMenuItem = new JCheckBoxMenuItem(Resources.getString("menu.view.boundaries"));
    boundaryMenuItem.addActionListener(this);
    boundaryMenuItem.setToolTipText(Resources.getString("menu.view.boundaries.tooltip"));
    boundaryMenuItem.setAccelerator(KeyStroke.getKeyStroke("control E"));

    coordinatesMenuItem = new JCheckBoxMenuItem(Resources.getString("menu.view.coordinates"));
    coordinatesMenuItem.addActionListener(this);
    coordinatesMenuItem.setToolTipText(Resources.getString("menu.view.coordinates.tooltip"));

    JMenu viewMenu = new JMenu(Resources.getString("menu.view"));
    viewMenu.add(new TMenuItem(zoomInAction));
    viewMenu.add(new TMenuItem(zoomOutAction));
    viewMenu.add(new TMenuItem(zoomNormalAction));
    viewMenu.addSeparator();
    viewMenu.add(gridMenuItem);
    viewMenu.add(cursorMenuItem);
    // TODO: Enable when boudary drawing code finished.
    // viewMenu.add(boundaryMenuItem);
View Full Code Here


    java.util.List<String> files = TiledConfiguration.getRecentFiles();

    recentMenu.removeAll();

    for (String file : files) {
      recentMenu.add(new TMenuItem(new OpenRecentAction(this, saveAction, file)));
    }
  }
View Full Code Here

TOP

Related Classes of de.yaams.extensions.basemap.tiled.mapeditor.widget.TMenuItem

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.