Search in sources :

Example 66 with JToggleButton

use of javax.swing.JToggleButton in project chatty by chatty.

the class CommercialPanel method createCommercialButtons.

/**
 * Creates buttons for the defined commercial lengths, adds them to a JPanel,
 * a ButtonGroup and a Map for further reference.
 *
 * @return The JPanel to be added to the GUI.
 */
private JPanel createCommercialButtons() {
    ButtonGroup g = new NoneSelectedButtonGroup();
    JPanel panel = new JPanel();
    ActionListener listener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            commercialButtonClicked(e.getActionCommand());
        }
    };
    for (int i : commercialButtonsDef) {
        JToggleButton b = new JToggleButton(i + "s");
        b.setActionCommand(String.valueOf(i));
        g.add(b);
        commercialButtons.put(i, b);
        panel.add(b);
        b.addActionListener(listener);
    }
    return panel;
}
Also used : JPanel(javax.swing.JPanel) ActionListener(java.awt.event.ActionListener) JToggleButton(javax.swing.JToggleButton) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent)

Example 67 with JToggleButton

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

the class SlideEditorController method createSetZoomToggleButton.

private JToggleButton createSetZoomToggleButton() {
    final JToggleButton btnSetsZoom = createToggleButtonWithIconAndLabel("SetZoomSlideContent.icon", "slide.setzoom");
    btnSetsZoom.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final boolean changesZoom = !slide.changesZoom();
            UndoableSlide.of(slide).setChangesZoom(changesZoom);
            if (changesZoom) {
                UndoableSlide.of(slide).setZoom(Controller.getCurrentController().getMapViewManager().getZoom());
            }
        }
    });
    return btnSetsZoom;
}
Also used : JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 68 with JToggleButton

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

the class SlideEditorController method createPlacesSelectedNodeToggleButton.

private JToggleButton createPlacesSelectedNodeToggleButton() {
    final JToggleButton checkBoxOnlySpecificNodes = createToggleButtonWithIconAndLabel("PlaceSelectedNodeOnSlide.icon", "slide.placenode");
    checkBoxOnlySpecificNodes.setAlignmentX(Component.CENTER_ALIGNMENT);
    checkBoxOnlySpecificNodes.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final String centeredNodeId = slide.getPlacedNodeId();
            final IMapSelection selection = Controller.getCurrentController().getSelection();
            if (centeredNodeId == null) {
                final NodeModel selected = selection.getSelected();
                if (selected != null) {
                    UndoableSlide.of(slide).setPlacedNodeId(selected.getID());
                    setNodePlacementControlsEnabled(true, slide.getPlacedNodePosition());
                } else {
                    UndoableSlide.of(slide).setPlacedNodeId(null);
                    setNodePlacementControlsEnabled(false, slide.getPlacedNodePosition());
                }
            } else {
                UndoableSlide.of(slide).setPlacedNodeId(null);
                setNodePlacementControlsEnabled(false, slide.getPlacedNodePosition());
                final MapModel map = Controller.getCurrentController().getMap();
                final NodeModel node = map.getNodeForID(centeredNodeId);
                if (node != null)
                    selection.selectAsTheOnlyOneSelected(node);
            }
            checkBoxOnlySpecificNodes.setSelected(slide.getPlacedNodeId() != null);
        }
    });
    return checkBoxOnlySpecificNodes;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) IMapSelection(org.freeplane.features.map.IMapSelection) MapModel(org.freeplane.features.map.MapModel)

Example 69 with JToggleButton

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

the class TranslatedElementFactory method createToggleButton.

public static JToggleButton createToggleButton(Action action, String labelKey) {
    final JToggleButton component = action != null ? new JAutoToggleButton(action) : new JAutoToggleButton();
    final String text = TextUtils.getRawText(labelKey);
    LabelAndMnemonicSetter.setLabelAndMnemonic(component, text);
    TranslatedElement.TEXT.setKey(component, labelKey);
    createTooltip(component, labelKey + ".tooltip");
    return component;
}
Also used : JAutoToggleButton(org.freeplane.core.ui.components.JAutoToggleButton) JToggleButton(javax.swing.JToggleButton)

Example 70 with JToggleButton

use of javax.swing.JToggleButton in project com.revolsys.open by revolsys.

the class RecordLayerTablePanel method newToolBar.

protected void newToolBar(final Map<String, Object> pluginConfig) {
    final ToolBar toolBar = getToolBar();
    final RecordDefinition recordDefinition = getRecordDefinition();
    final boolean hasGeometry = recordDefinition.hasGeometryField();
    final MenuFactory layerMenuFactory = MenuFactory.findMenu(this.layer);
    if (layerMenuFactory != null) {
        toolBar.addButtonTitleIcon("menu", "Layer Menu", "menu", () -> layerMenuFactory.showMenu(this.layer, this, 10, 10));
    }
    if (hasGeometry) {
        final EnableCheck hasSelectedRecords = new ObjectPropertyEnableCheck(this.layer, "hasSelectedRecords");
        toolBar.addButton("layer", "Zoom to Selected", "magnifier_zoom_selected", hasSelectedRecords, this.layer::zoomToSelected);
        toolBar.addButton("layer", "Pan to Selected", "pan_selected", hasSelectedRecords, this.layer::panToSelected);
    }
    final RecordLayerTable table = getTable();
    final TableRowCount tableRowCount = new TableRowCount(table);
    toolBar.addComponent("count", tableRowCount);
    toolBar.addButtonTitleIcon("table", "Refresh", "table_refresh", this.layer::refresh);
    toolBar.addButtonTitleIcon("table", "Export Records", "table_save", new ObjectPropertyEnableCheck(tableRowCount, "rowCount", 0, true), () -> actionExportRecords());
    this.fieldSetsButton = toolBar.addButtonTitleIcon("table", "Field Sets", "fields_filter", () -> actionShowFieldSetsMenu());
    this.fieldFilterPanel = new FieldFilterPanel(this, this.tableModel, pluginConfig);
    if (this.fieldFilterPanel.isVisible()) {
        toolBar.addComponent("search", this.fieldFilterPanel);
        toolBar.addButtonTitleIcon("search", "Advanced Search", "filter_edits", this.fieldFilterPanel::showAdvancedFilter);
        final EnableCheck hasFilter = new ObjectPropertyEnableCheck(this.tableModel, "hasFilter");
        toolBar.addButton("search", "Clear Search", "filter_delete", hasFilter, this.fieldFilterPanel::clear);
        final EnableCheck hasFilterHistory = new ObjectPropertyEnableCheck(this.tableModel, "hasFilterHistory");
        toolBar.addButton("search", ConsumerAction.action("Search History", Icons.getIconWithBadge("book", "filter"), hasFilterHistory, (event) -> {
            final Object source = event.getSource();
            Component component = null;
            if (source instanceof Component) {
                component = (Component) source;
            }
            final BaseJPopupMenu menu = new BaseJPopupMenu();
            for (final Condition filter : this.tableModel.getFilterHistory()) {
                menu.addMenuItem(filter.toString(), () -> this.fieldFilterPanel.setFilter(filter));
            }
            menu.showMenu(component, 0, 20);
        }));
    }
    // Filter buttons
    boolean first = true;
    for (final TableRecordsMode fieldFilterMode : this.tableModel.getFieldFilterModes()) {
        final String key = fieldFilterMode.getKey();
        final String title = fieldFilterMode.getTitle();
        final Icon icon = fieldFilterMode.getIcon();
        final EnableCheck enableCheck = fieldFilterMode.getEnableCheck();
        final JToggleButton button = toolBar.addToggleButton(FILTER_FIELD, -1, null, title, icon, enableCheck, () -> {
            if (this.tableModel != null) {
                this.tableModel.setTableRecordsMode(fieldFilterMode);
            }
        });
        this.buttonByMode.put(FILTER_FIELD + "_" + key, button);
        if (first) {
            button.doClick();
            first = false;
        }
    }
    if (hasGeometry) {
        final JToggleButton showAllGeometries = addGeometryFilterToggleButton(toolBar, -1, "Show All Records ", "world_filter", "all", null);
        showAllGeometries.doClick();
        addGeometryFilterToggleButton(toolBar, -1, "Show Records on Map", "map_filter", "boundingBox", new ObjectPropertyEnableCheck(this.tableModel, "filterByBoundingBoxSupported"));
    }
}
Also used : FieldCalculator(com.revolsys.swing.map.layer.record.component.FieldCalculator) Icons(com.revolsys.swing.Icons) EnableCheck(com.revolsys.swing.action.enablecheck.EnableCheck) JToggleButton(javax.swing.JToggleButton) Property(com.revolsys.util.Property) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) RecordLayerTableModel(com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel) Map(java.util.Map) MenuFactory(com.revolsys.swing.menu.MenuFactory) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) Condition(com.revolsys.record.query.Condition) Font(java.awt.Font) Maps(com.revolsys.collection.map.Maps) BorderFactory(javax.swing.BorderFactory) Icon(javax.swing.Icon) RecordRowTable(com.revolsys.swing.table.record.RecordRowTable) Component(java.awt.Component) FieldNamesSetPanel(com.revolsys.swing.map.form.FieldNamesSetPanel) PropertyChangeListener(java.beans.PropertyChangeListener) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) SetRecordsFieldValue(com.revolsys.swing.map.layer.record.component.SetRecordsFieldValue) JTable(javax.swing.JTable) MapSerializer(com.revolsys.io.map.MapSerializer) FieldFilterPanel(com.revolsys.swing.map.layer.record.component.FieldFilterPanel) TableRecordsMode(com.revolsys.swing.map.layer.record.table.model.TableRecordsMode) JPanel(javax.swing.JPanel) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer) RecordTableCellEditor(com.revolsys.swing.table.record.editor.RecordTableCellEditor) ToolBar(com.revolsys.swing.toolbar.ToolBar) RecordDefinition(com.revolsys.record.schema.RecordDefinition) LayerRecordMenu(com.revolsys.swing.map.layer.record.LayerRecordMenu) HashMap(java.util.HashMap) BaseJPopupMenu(com.revolsys.swing.menu.BaseJPopupMenu) SwingConstants(javax.swing.SwingConstants) VerticalLayout(org.jdesktop.swingx.VerticalLayout) SwingUtilities(javax.swing.SwingUtilities) TableCellEditor(javax.swing.table.TableCellEditor) JMenuItem(javax.swing.JMenuItem) ObjectPropertyEnableCheck(com.revolsys.swing.action.enablecheck.ObjectPropertyEnableCheck) RunnableAction(com.revolsys.swing.action.RunnableAction) MapEx(com.revolsys.collection.map.MapEx) ConsumerAction(com.revolsys.swing.action.ConsumerAction) PropertyChangeEvent(java.beans.PropertyChangeEvent) MapPanel(com.revolsys.swing.map.MapPanel) JButton(javax.swing.JButton) TablePanel(com.revolsys.swing.table.TablePanel) JPopupMenu(javax.swing.JPopupMenu) TableRowCount(com.revolsys.swing.table.TableRowCount) MouseEvent(java.awt.event.MouseEvent) JLabel(javax.swing.JLabel) Condition(com.revolsys.record.query.Condition) ObjectPropertyEnableCheck(com.revolsys.swing.action.enablecheck.ObjectPropertyEnableCheck) EnableCheck(com.revolsys.swing.action.enablecheck.EnableCheck) ObjectPropertyEnableCheck(com.revolsys.swing.action.enablecheck.ObjectPropertyEnableCheck) TableRecordsMode(com.revolsys.swing.map.layer.record.table.model.TableRecordsMode) RecordDefinition(com.revolsys.record.schema.RecordDefinition) MenuFactory(com.revolsys.swing.menu.MenuFactory) JToggleButton(javax.swing.JToggleButton) ToolBar(com.revolsys.swing.toolbar.ToolBar) BaseJPopupMenu(com.revolsys.swing.menu.BaseJPopupMenu) Icon(javax.swing.Icon) Component(java.awt.Component) TableRowCount(com.revolsys.swing.table.TableRowCount) FieldFilterPanel(com.revolsys.swing.map.layer.record.component.FieldFilterPanel)

Aggregations

JToggleButton (javax.swing.JToggleButton)179 ActionEvent (java.awt.event.ActionEvent)92 ActionListener (java.awt.event.ActionListener)90 ImageIcon (javax.swing.ImageIcon)76 Dimension (java.awt.Dimension)69 JPanel (javax.swing.JPanel)58 JButton (javax.swing.JButton)46 JLabel (javax.swing.JLabel)39 Point (java.awt.Point)29 JScrollPane (javax.swing.JScrollPane)19 BorderLayout (java.awt.BorderLayout)17 ChangeEvent (javax.swing.event.ChangeEvent)15 Insets (java.awt.Insets)14 ItemEvent (java.awt.event.ItemEvent)14 ChangeListener (javax.swing.event.ChangeListener)14 ItemListener (java.awt.event.ItemListener)13 Component (java.awt.Component)12 FlowLayout (java.awt.FlowLayout)12 BoxLayout (javax.swing.BoxLayout)12 JToolBar (javax.swing.JToolBar)12