Search in sources :

Example 81 with JToolBar

use of javax.swing.JToolBar in project processdash by dtuma.

the class ProxyEditor method buildToolbar.

private void buildToolbar() {
    toolBar = new JToolBar();
    toolBar.setFloatable(false);
    toolBar.setMargin(new Insets(0, 0, 0, 0));
    addToolbarButton(undoList.getUndoAction());
    addToolbarButton(undoList.getRedoAction());
    table.tweakClipboardActions(resources, IconFactory.getCopyProxyIcon(), IconFactory.getPasteProxyIcon());
    addToolbarButton(table.CUT_ACTION);
    addToolbarButton(table.COPY_ACTION);
    addToolbarButton(table.PASTE_ACTION);
    addToolbarButton(table.EXPAND_ACTION);
    addToolbarButton(table.COLLAPSE_ACTION);
    addToolbarButton(table.MOVEUP_ACTION);
    addToolbarButton(table.MOVEDOWN_ACTION);
    addToolbarButton(table.DELETE_ACTION);
    toolBar.addSeparator();
    if (!isEditable(teamProject)) {
        IMPORT.setEnabled(false);
        IMPORT_ORG.setEnabled(false);
    }
    TeamProcess teamProcess = teamProject.getTeamProcess();
    if (ProxyLibraryEditor.orgAssetsAreAvailable(teamProcess))
        addToolbarButton(IMPORT_ORG);
    addToolbarButton(IMPORT);
    addToolbarButton(EXPORT);
}
Also used : Insets(java.awt.Insets) JToolBar(javax.swing.JToolBar)

Example 82 with JToolBar

use of javax.swing.JToolBar in project litiengine by gurkenlabs.

the class Program method initToolBar.

private static JToolBar initToolBar() {
    // create basic icon toolbar
    JToolBar basicMenu = new JToolBar();
    JButton cr = new JButton();
    cr.setIcon(new ImageIcon(Resources.getImage("button-create.png")));
    basicMenu.add(cr);
    cr.addActionListener(a -> EditorScreen.instance().create());
    JButton op = new JButton();
    op.setIcon(new ImageIcon(Resources.getImage("button-load.png")));
    basicMenu.add(op);
    op.addActionListener(a -> EditorScreen.instance().load());
    JButton sv = new JButton();
    sv.setIcon(new ImageIcon(Resources.getImage("button-save.png")));
    basicMenu.add(sv);
    sv.addActionListener(a -> EditorScreen.instance().save(false));
    basicMenu.addSeparator();
    JButton undo = new JButton();
    undo.setIcon(new ImageIcon(Resources.getImage("button-undo.png")));
    basicMenu.add(undo);
    undo.addActionListener(a -> UndoManager.instance().undo());
    JButton redo = new JButton();
    redo.setIcon(new ImageIcon(Resources.getImage("button-redo.png")));
    basicMenu.add(redo);
    redo.addActionListener(a -> UndoManager.instance().redo());
    undo.setEnabled(false);
    redo.setEnabled(false);
    basicMenu.addSeparator();
    JToggleButton place = new JToggleButton();
    place.setIcon(new ImageIcon(Resources.getImage("button-placeobject.png")));
    basicMenu.add(place);
    JToggleButton ed = new JToggleButton();
    ed.setIcon(new ImageIcon(Resources.getImage("button-edit.png")));
    ed.setSelected(true);
    JToggleButton mv = new JToggleButton();
    mv.setIcon(new ImageIcon(Resources.getImage("button-move.png")));
    mv.setEnabled(false);
    ed.addActionListener(a -> {
        ed.setSelected(true);
        place.setSelected(false);
        mv.setSelected(false);
        isChanging = true;
        EditorScreen.instance().getMapComponent().setEditMode(MapComponent.EDITMODE_EDIT);
        isChanging = false;
        Game.getScreenManager().getRenderComponent().setCursor(CURSOR, 0, 0);
    });
    basicMenu.add(ed);
    basicMenu.add(mv);
    place.addActionListener(a -> {
        place.setSelected(true);
        ed.setSelected(false);
        mv.setSelected(false);
        isChanging = true;
        EditorScreen.instance().getMapComponent().setEditMode(MapComponent.EDITMODE_CREATE);
        isChanging = false;
    });
    mv.addActionListener(a -> {
        mv.setSelected(true);
        ed.setSelected(false);
        place.setSelected(false);
        isChanging = true;
        EditorScreen.instance().getMapComponent().setEditMode(MapComponent.EDITMODE_MOVE);
        isChanging = false;
        Game.getScreenManager().getRenderComponent().setCursor(CURSOR_MOVE, 0, 0);
    });
    EditorScreen.instance().getMapComponent().onEditModeChanged(i -> {
        if (isChanging) {
            return;
        }
        if (i == MapComponent.EDITMODE_CREATE) {
            ed.setSelected(false);
            mv.setSelected(false);
            place.setSelected(true);
        }
        if (i == MapComponent.EDITMODE_EDIT) {
            place.setSelected(false);
            mv.setSelected(false);
            ed.setSelected(true);
            Game.getScreenManager().getRenderComponent().setCursor(CURSOR, 0, 0);
        }
        if (i == MapComponent.EDITMODE_MOVE) {
            ed.setSelected(false);
            place.setSelected(false);
            mv.setSelected(true);
            Game.getScreenManager().getRenderComponent().setCursor(CURSOR_MOVE, 0, 0);
        }
    });
    JButton del = new JButton();
    del.setIcon(new ImageIcon(Resources.getImage("button-delete.png")));
    basicMenu.add(del);
    del.setEnabled(false);
    del.addActionListener(a -> EditorScreen.instance().getMapComponent().delete());
    // copy
    JButton cop = new JButton();
    cop.setIcon(new ImageIcon(Resources.getImage("button-copy.png")));
    basicMenu.add(cop);
    cop.setEnabled(false);
    ActionListener copyAction = a -> EditorScreen.instance().getMapComponent().copy();
    cop.addActionListener(copyAction);
    cop.getModel().setMnemonic('C');
    KeyStroke keyStroke = KeyStroke.getKeyStroke('C', Event.CTRL_MASK, false);
    cop.registerKeyboardAction(copyAction, keyStroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    // paste
    JButton paste = new JButton();
    paste.setIcon(new ImageIcon(Resources.getImage("button-paste.png")));
    basicMenu.add(paste);
    ActionListener pasteAction = a -> EditorScreen.instance().getMapComponent().paste();
    paste.addActionListener(pasteAction);
    paste.getModel().setMnemonic('V');
    KeyStroke keyStrokePaste = KeyStroke.getKeyStroke('V', Event.CTRL_MASK, false);
    paste.registerKeyboardAction(pasteAction, keyStrokePaste, JComponent.WHEN_IN_FOCUSED_WINDOW);
    // cut
    JButton cut = new JButton();
    cut.setIcon(new ImageIcon(Resources.getImage("button-cut.png")));
    basicMenu.add(cut);
    cut.setEnabled(false);
    ActionListener cutAction = a -> EditorScreen.instance().getMapComponent().cut();
    cut.addActionListener(cutAction);
    cut.getModel().setMnemonic('X');
    KeyStroke keyStrokeCut = KeyStroke.getKeyStroke('X', Event.CTRL_MASK, false);
    cut.registerKeyboardAction(cutAction, keyStrokeCut, JComponent.WHEN_IN_FOCUSED_WINDOW);
    EditorScreen.instance().getMapComponent().onFocusChanged(mo -> {
        if (mv.isSelected()) {
            mv.setSelected(false);
            ed.setSelected(true);
        }
        mv.setEnabled(mo != null);
        del.setEnabled(mo != null);
        cop.setEnabled(mo != null);
        cut.setEnabled(mo != null);
        undo.setEnabled(UndoManager.instance().canUndo());
        redo.setEnabled(UndoManager.instance().canRedo());
        paste.setEnabled(EditorScreen.instance().getMapComponent().getCopiedBlueprint() != null);
    });
    EditorScreen.instance().getMapComponent().onEditModeChanged(mode -> paste.setEnabled(EditorScreen.instance().getMapComponent().getCopiedBlueprint() != null));
    UndoManager.onUndoStackChanged(manager -> {
        EditorScreen.instance().getMapComponent().updateTransformControls();
        undo.setEnabled(manager.canUndo());
        redo.setEnabled(manager.canRedo());
    });
    basicMenu.addSeparator();
    JButton colorButton = new JButton();
    colorButton.setIcon(new ImageIcon(Resources.getImage("button-color.png")));
    colorButton.setEnabled(false);
    JTextField colorText = new JTextField();
    colorText.setEnabled(false);
    colorText.setMaximumSize(new Dimension(50, 50));
    JSpinner spinnerAmbientAlpha = new JSpinner();
    spinnerAmbientAlpha.setModel(new SpinnerNumberModel(0, 0, 255, 1));
    spinnerAmbientAlpha.setFont(Program.TEXT_FONT);
    spinnerAmbientAlpha.setMaximumSize(new Dimension(50, 50));
    spinnerAmbientAlpha.setEnabled(false);
    spinnerAmbientAlpha.addChangeListener(e -> {
        if (Game.getEnvironment() == null || Game.getEnvironment().getMap() == null || isChanging) {
            return;
        }
        Game.getEnvironment().getMap().setCustomProperty(MapProperty.AMBIENTALPHA, spinnerAmbientAlpha.getValue().toString());
        Game.getEnvironment().getAmbientLight().setAlpha((int) spinnerAmbientAlpha.getValue());
    });
    colorButton.addActionListener(a -> {
        if (Game.getEnvironment() == null || Game.getEnvironment().getMap() == null || isChanging) {
            return;
        }
        Color color = null;
        if (colorText.getText() != null && !colorText.getText().isEmpty()) {
            Color solid = Color.decode(colorText.getText());
            color = new Color(solid.getRed(), solid.getGreen(), solid.getBlue(), (int) spinnerAmbientAlpha.getValue());
        }
        Color result = ColorChooser.showRgbDialog("Select an ambient color.", color);
        if (result == null) {
            return;
        }
        String h = "#" + Integer.toHexString(result.getRGB()).substring(2);
        colorText.setText(h);
        spinnerAmbientAlpha.setValue(result.getAlpha());
        Game.getEnvironment().getMap().setCustomProperty(MapProperty.AMBIENTCOLOR, colorText.getText());
        Game.getEnvironment().getAmbientLight().setColor(result);
    });
    EditorScreen.instance().getMapComponent().onMapLoaded(map -> {
        isChanging = true;
        colorButton.setEnabled(map != null);
        spinnerAmbientAlpha.setEnabled(map != null);
        colorText.setText(map.getCustomProperty(MapProperty.AMBIENTCOLOR));
        String alpha = map.getCustomProperty(MapProperty.AMBIENTALPHA);
        if (alpha != null && !alpha.isEmpty()) {
            spinnerAmbientAlpha.setValue((int) Double.parseDouble(alpha));
        }
        isChanging = false;
    });
    basicMenu.add(colorButton);
    basicMenu.add(Box.createHorizontalStrut(5));
    basicMenu.add(colorText);
    basicMenu.add(Box.createHorizontalStrut(5));
    basicMenu.add(spinnerAmbientAlpha);
    return basicMenu;
}
Also used : Color(java.awt.Color) UIManager(javax.swing.UIManager) Point2D(java.awt.geom.Point2D) GridEditPanel(de.gurkenlabs.utiliti.swing.dialogs.GridEditPanel) JToggleButton(javax.swing.JToggleButton) MapPropertyPanel(de.gurkenlabs.utiliti.swing.dialogs.MapPropertyPanel) Map(de.gurkenlabs.litiengine.environment.tilemap.xml.Map) PopupMenu(java.awt.PopupMenu) TrayIcon(java.awt.TrayIcon) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) Locale(java.util.Locale) Event(java.awt.Event) MouseAdapter(java.awt.event.MouseAdapter) AssetPanel(de.gurkenlabs.utiliti.swing.AssetPanel) MenuShortcut(java.awt.MenuShortcut) BorderLayout(java.awt.BorderLayout) SystemTray(java.awt.SystemTray) JFrame(javax.swing.JFrame) CheckboxMenuItem(java.awt.CheckboxMenuItem) KeyStroke(javax.swing.KeyStroke) JToolBar(javax.swing.JToolBar) Resources(de.gurkenlabs.litiengine.Resources) BufferedImage(java.awt.image.BufferedImage) Font(java.awt.Font) Menu(java.awt.Menu) BorderFactory(javax.swing.BorderFactory) ComponentEvent(java.awt.event.ComponentEvent) KeyEvent(java.awt.event.KeyEvent) Logger(java.util.logging.Logger) Canvas(java.awt.Canvas) Component(java.awt.Component) MenuBar(java.awt.MenuBar) Box(javax.swing.Box) Dimension(java.awt.Dimension) MenuItem(java.awt.MenuItem) AWTException(java.awt.AWTException) JPanel(javax.swing.JPanel) Game(de.gurkenlabs.litiengine.Game) ActionListener(java.awt.event.ActionListener) JSplitPane(javax.swing.JSplitPane) JTextField(javax.swing.JTextField) SpinnerNumberModel(javax.swing.SpinnerNumberModel) Level(java.util.logging.Level) AssetTree(de.gurkenlabs.utiliti.swing.AssetTree) MapComponent(de.gurkenlabs.utiliti.components.MapComponent) SwingUtilities(javax.swing.SwingUtilities) InvalidPathException(java.nio.file.InvalidPathException) JMenuItem(javax.swing.JMenuItem) JTabbedPane(javax.swing.JTabbedPane) ImageIcon(javax.swing.ImageIcon) JTextPane(javax.swing.JTextPane) MapProperty(de.gurkenlabs.litiengine.environment.tilemap.MapProperty) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) JSpinner(javax.swing.JSpinner) JPopupMenu(javax.swing.JPopupMenu) JOptionPane(javax.swing.JOptionPane) MapObjectPanel(de.gurkenlabs.utiliti.swing.panels.MapObjectPanel) MouseEvent(java.awt.event.MouseEvent) File(java.io.File) Input(de.gurkenlabs.litiengine.input.Input) ComponentAdapter(java.awt.event.ComponentAdapter) JScrollPane(javax.swing.JScrollPane) Paths(java.nio.file.Paths) JLabel(javax.swing.JLabel) JScrollBar(javax.swing.JScrollBar) ColorChooser(de.gurkenlabs.utiliti.swing.ColorChooser) ImageIcon(javax.swing.ImageIcon) Color(java.awt.Color) JButton(javax.swing.JButton) JToolBar(javax.swing.JToolBar) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) SpinnerNumberModel(javax.swing.SpinnerNumberModel) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) KeyStroke(javax.swing.KeyStroke) JSpinner(javax.swing.JSpinner)

Example 83 with JToolBar

use of javax.swing.JToolBar in project litiengine by gurkenlabs.

the class Program method setupInterface.

private static void setupInterface() {
    MenuBar menuBar = new MenuBar();
    JFrame window = ((JFrame) Game.getScreenManager());
    Game.onTerminating(s -> {
        boolean terminate = notifyPendingChanges();
        if (terminate) {
            getUserPreferences().setFrameState(((JFrame) Game.getScreenManager()).getExtendedState());
        }
        return terminate;
    });
    window.setResizable(true);
    window.setMenuBar(menuBar);
    if (userPreferences.getWidth() != 0 && userPreferences.getHeight() != 0) {
        window.setSize(userPreferences.getWidth(), userPreferences.getHeight());
    }
    if (userPreferences.getFrameState() != JFrame.ICONIFIED && userPreferences.getFrameState() != JFrame.NORMAL) {
        window.setExtendedState(userPreferences.getFrameState());
    }
    Canvas canvas = Game.getScreenManager().getRenderComponent();
    canvas.setFocusable(true);
    canvas.setSize((int) (window.getSize().width * 0.75), window.getSize().height);
    window.remove(canvas);
    JPanel renderPane = new JPanel(new BorderLayout());
    renderPane.add(canvas);
    renderPane.setMinimumSize(new Dimension(300, 0));
    initCanvasPopupMenu(canvas);
    JPanel contentPane = new JPanel(new BorderLayout());
    window.setContentPane(contentPane);
    horizontalScroll = new JScrollBar(JScrollBar.HORIZONTAL);
    renderPane.add(horizontalScroll, BorderLayout.SOUTH);
    verticalScroll = new JScrollBar(JScrollBar.VERTICAL);
    renderPane.add(verticalScroll, BorderLayout.EAST);
    horizontalScroll.addAdjustmentListener(e -> {
        if (EditorScreen.instance().getMapComponent().isLoading()) {
            return;
        }
        Point2D newFocus = new Point2D.Double(horizontalScroll.getValue(), Game.getCamera().getFocus().getY());
        Game.getCamera().setFocus(newFocus);
    });
    verticalScroll.addAdjustmentListener(e -> {
        if (EditorScreen.instance().getMapComponent().isLoading()) {
            return;
        }
        Point2D newFocus = new Point2D.Double(Game.getCamera().getFocus().getX(), verticalScroll.getValue());
        Game.getCamera().setFocus(newFocus);
    });
    MapObjectPanel mapEditorPanel = new MapObjectPanel();
    MapSelectionPanel mapSelectionPanel = new MapSelectionPanel();
    JSplitPane mapWrap = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    mapWrap.setMinimumSize(new Dimension(300, 0));
    mapWrap.setBottomComponent(mapEditorPanel);
    mapWrap.setTopComponent(mapSelectionPanel);
    mapWrap.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setSelectionEditSplitter(mapWrap.getDividerLocation()));
    if (userPreferences.getSelectionEditSplitter() != 0) {
        mapWrap.setDividerLocation(userPreferences.getSelectionEditSplitter());
    }
    JPanel bottomPanel = new JPanel(new BorderLayout());
    JTabbedPane bottomTab = new JTabbedPane();
    bottomTab.addTab(Resources.get("assettree_assets"), initAssetsComponent());
    bottomTab.addTab("Console", initConsole());
    bottomTab.setIconAt(0, new ImageIcon(Resources.getImage("asset.png")));
    bottomTab.setIconAt(1, new ImageIcon(Resources.getImage("console.png")));
    bottomPanel.add(bottomTab, BorderLayout.CENTER);
    statusBar = new JLabel("");
    statusBar.setPreferredSize(new Dimension(0, 16));
    statusBar.setFont(new Font(ConsoleLogHandler.CONSOLE_FONT, Font.PLAIN, 10));
    bottomPanel.add(statusBar, BorderLayout.SOUTH);
    EditorScreen.instance().getMapComponent().onSelectionChanged(selection -> {
        if (selection.isEmpty()) {
            statusBar.setText("");
        } else {
            statusBar.setText(" " + selection.size() + " selected objects");
        }
    });
    JSplitPane rendersplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, renderPane, bottomPanel);
    if (userPreferences.getBottomSplitter() != 0) {
        rendersplit.setDividerLocation(userPreferences.getBottomSplitter());
    } else {
        rendersplit.setDividerLocation((int) (window.getSize().height * 0.75));
    }
    rendersplit.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setBottomSplitter(rendersplit.getDividerLocation()));
    rendersplit.setContinuousLayout(true);
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, rendersplit, mapWrap);
    split.setContinuousLayout(true);
    split.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            userPreferences.setWidth(window.getWidth());
            userPreferences.setHeight(window.getHeight());
        }
    });
    split.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setMainSplitter(split.getDividerLocation()));
    contentPane.add(split, BorderLayout.CENTER);
    split.setDividerLocation(userPreferences.getMainSplitterPosition() != 0 ? userPreferences.getMainSplitterPosition() : (int) (window.getSize().width * 0.75));
    JToolBar toolbar = initToolBar();
    contentPane.add(toolbar, BorderLayout.NORTH);
    EditorScreen.instance().setMapEditorPanel(mapEditorPanel);
    EditorScreen.instance().setMapSelectionPanel(mapSelectionPanel);
    Menu mnFile = initFileMenu();
    menuBar.add(mnFile);
    Menu mnView = initViewMenu();
    menuBar.add(mnView);
    Menu mnProject = initProjectMenu();
    menuBar.add(mnProject);
    Menu mnMap = initMapMenu();
    menuBar.add(mnMap);
}
Also used : JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) Canvas(java.awt.Canvas) JTabbedPane(javax.swing.JTabbedPane) MenuBar(java.awt.MenuBar) MapObjectPanel(de.gurkenlabs.utiliti.swing.panels.MapObjectPanel) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JToolBar(javax.swing.JToolBar) Font(java.awt.Font) JScrollBar(javax.swing.JScrollBar) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) Point2D(java.awt.geom.Point2D) ComponentEvent(java.awt.event.ComponentEvent) PopupMenu(java.awt.PopupMenu) Menu(java.awt.Menu) JPopupMenu(javax.swing.JPopupMenu) JSplitPane(javax.swing.JSplitPane) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 84 with JToolBar

use of javax.swing.JToolBar in project jgnash by ccavanaugh.

the class ExpandingAccountTablePanel method initComponents.

private void initComponents() {
    accountPane = new ExpandingAccountTablePane();
    JPanel toolPanel = new JPanel();
    JToolBar toolBar = new JToolBar();
    setLayout(new BorderLayout());
    toolPanel.setLayout(new BorderLayout());
    toolBar.setFloatable(false);
    toolBar.setRollover(true);
    newButton = new RollOverButton(rb.getString("Button.New"), IconUtils.getIcon("/jgnash/resource/document-new.png"));
    newButton.setToolTipText(rb.getString("ToolTip.NewAccount"));
    toolBar.add(newButton);
    modifyButton = new RollOverButton(rb.getString("Button.Modify"), IconUtils.getIcon("/jgnash/resource/document-properties.png"));
    modifyButton.setToolTipText(rb.getString("ToolTip.ModifyAccount"));
    toolBar.add(modifyButton);
    reconcileButton = new RollOverButton(rb.getString("Button.Reconcile"), IconUtils.getIcon("/jgnash/resource/view-refresh.png"));
    reconcileButton.setToolTipText(rb.getString("ToolTip.ReconcileAccount"));
    toolBar.add(reconcileButton);
    deleteButton = new RollOverButton(rb.getString("Button.Delete"), IconUtils.getIcon("/jgnash/resource/edit-delete.png"));
    deleteButton.setToolTipText(rb.getString("ToolTip.DeleteAccount"));
    toolBar.add(deleteButton);
    filterButton = new RollOverButton(rb.getString("Button.Filter"), IconUtils.getIcon("/jgnash/resource/preferences-system.png"));
    filterButton.setToolTipText(rb.getString("ToolTip.FilterAccount"));
    toolBar.add(filterButton);
    zoomButton = new RollOverButton(rb.getString("Button.Zoom"), IconUtils.getIcon("/jgnash/resource/edit-find.png"));
    toolBar.add(zoomButton);
    toolPanel.add(toolBar, BorderLayout.NORTH);
    toolPanel.add(new JSeparator(), BorderLayout.CENTER);
    add(toolPanel, BorderLayout.NORTH);
    accountPane.setBorder(new EmptyBorder(new Insets(0, 0, 0, 0)));
    accountPane.setMinimumSize(new Dimension(200, 100));
    accountPane.setAutoscrolls(true);
    add(accountPane, BorderLayout.CENTER);
}
Also used : JPanel(javax.swing.JPanel) RollOverButton(jgnash.ui.components.RollOverButton) Insets(java.awt.Insets) BorderLayout(java.awt.BorderLayout) JToolBar(javax.swing.JToolBar) Dimension(java.awt.Dimension) EmptyBorder(javax.swing.border.EmptyBorder) JSeparator(javax.swing.JSeparator)

Example 85 with JToolBar

use of javax.swing.JToolBar in project freeplane by freeplane.

the class JToolbarComponentBuilder method visit.

@Override
public void visit(Entry entry) {
    Component component = componentProvider.createComponent(entry);
    if (component != null) {
        final EntryAccessor entryAccessor = new EntryAccessor();
        entryAccessor.setComponent(entry, component);
        final AFreeplaneAction action = entryAccessor.getAction(entry);
        if (action != null) {
            final ActionEnabler actionEnabler = new ActionEnabler(component);
            action.addPropertyChangeListener(actionEnabler);
            entry.setAttribute(actionEnabler.getClass(), actionEnabler);
        }
        final Container container = (Container) new EntryAccessor().getAncestorComponent(entry);
        if (container instanceof JToolBar)
            container.add(component);
        else
            SwingUtilities.getAncestorOfClass(JToolBar.class, container).add(component);
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Container(java.awt.Container) ActionEnabler(org.freeplane.core.ui.ActionEnabler) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) JToolBar(javax.swing.JToolBar) Component(java.awt.Component)

Aggregations

JToolBar (javax.swing.JToolBar)124 JButton (javax.swing.JButton)51 BorderLayout (java.awt.BorderLayout)45 JPanel (javax.swing.JPanel)37 JScrollPane (javax.swing.JScrollPane)30 Dimension (java.awt.Dimension)25 Insets (java.awt.Insets)25 ActionEvent (java.awt.event.ActionEvent)24 JLabel (javax.swing.JLabel)23 ActionListener (java.awt.event.ActionListener)19 ImageIcon (javax.swing.ImageIcon)17 Component (java.awt.Component)14 JSplitPane (javax.swing.JSplitPane)14 JTable (javax.swing.JTable)14 JTextField (javax.swing.JTextField)14 JPopupMenu (javax.swing.JPopupMenu)13 JToggleButton (javax.swing.JToggleButton)12 GridBagConstraints (java.awt.GridBagConstraints)10 GridBagLayout (java.awt.GridBagLayout)10 JComponent (javax.swing.JComponent)10