Search in sources :

Example 11 with KeyShortcut

use of com.igormaznitsa.mindmap.swing.panel.utils.KeyShortcut in project netbeans-mmd-plugin by raydac.

the class KeyShortCutEditPanel method updateCurrentSelectedForKey.

private void updateCurrentSelectedForKey(final KeyEvent evt) {
    final int index = this.tableKeyShortcuts.getSelectedRow();
    if (index >= 0) {
        final KeyShortcut oldShortcut = this.listOfKeys.get(index);
        final int keyCode = evt.getKeyCode();
        final int modifiers = evt.getModifiers() & (KeyEvent.META_MASK | KeyEvent.SHIFT_MASK | KeyEvent.CTRL_MASK | KeyEvent.ALT_MASK);
        final KeyShortcut newShortCut = new KeyShortcut(oldShortcut.getID(), keyCode, modifiers);
        this.listOfKeys.set(index, newShortCut);
        for (final TableModelListener l : this.listeners) {
            l.tableChanged(new TableModelEvent(this, index));
        }
    }
    updateForSelected();
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) KeyShortcut(com.igormaznitsa.mindmap.swing.panel.utils.KeyShortcut) TableModelListener(javax.swing.event.TableModelListener)

Example 12 with KeyShortcut

use of com.igormaznitsa.mindmap.swing.panel.utils.KeyShortcut in project netbeans-mmd-plugin by raydac.

the class KeyShortCutEditPanel method updateCurrentSelectedForKey.

private void updateCurrentSelectedForKey(final KeyEvent evt) {
    final int index = this.tableKeyShortcuts.getSelectedRow();
    if (index >= 0) {
        final KeyShortcut oldShortcut = this.listOfKeys.get(index);
        final int keyCode = evt.getKeyCode();
        final int modifiers = evt.getModifiers() & (KeyEvent.META_MASK | KeyEvent.SHIFT_MASK | KeyEvent.CTRL_MASK | KeyEvent.ALT_MASK);
        final KeyShortcut newShortCut = new KeyShortcut(oldShortcut.getID(), keyCode, modifiers);
        this.listOfKeys.set(index, newShortCut);
        for (final TableModelListener l : this.listeners) {
            l.tableChanged(new TableModelEvent(this, index));
        }
    }
    updateForSelected();
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) KeyShortcut(com.igormaznitsa.mindmap.swing.panel.utils.KeyShortcut) TableModelListener(javax.swing.event.TableModelListener)

Example 13 with KeyShortcut

use of com.igormaznitsa.mindmap.swing.panel.utils.KeyShortcut in project netbeans-mmd-plugin by raydac.

the class KeyShortCutEditPanel method updateForSelected.

private void updateForSelected() {
    final KeyShortcut shortcut = getSelectedRow();
    if (shortcut == null) {
        this.buttonEditKeyCode.setEnabled(false);
        this.buttonEditKeyCode.setSelected(false);
        this.checkBoxALT.setSelected(false);
        this.checkBoxSHIFT.setSelected(false);
        this.checkBoxCTRL.setSelected(false);
        this.checkBoxMeta.setSelected(false);
        this.checkBoxALT.setEnabled(false);
        this.checkBoxCTRL.setEnabled(false);
        this.checkBoxSHIFT.setEnabled(false);
        this.checkBoxMeta.setEnabled(false);
        // NOI18N
        this.textFieldKeyCode.setText("");
        this.textFieldKeyCode.setEnabled(false);
    } else {
        this.buttonEditKeyCode.setEnabled(true);
        this.buttonEditKeyCode.setSelected(false);
        this.textFieldKeyCode.setEnabled(true);
        this.checkBoxALT.setEnabled(true);
        this.checkBoxCTRL.setEnabled(true);
        this.checkBoxMeta.setEnabled(true);
        this.checkBoxSHIFT.setEnabled(true);
        this.textFieldKeyCode.setText(shortcut.getKeyCodeName());
        this.checkBoxALT.setSelected(shortcut.isAlt());
        this.checkBoxSHIFT.setSelected(shortcut.isShift());
        this.checkBoxMeta.setSelected(shortcut.isMeta());
        this.checkBoxCTRL.setSelected(shortcut.isCtrl());
    }
}
Also used : KeyShortcut(com.igormaznitsa.mindmap.swing.panel.utils.KeyShortcut)

Example 14 with KeyShortcut

use of com.igormaznitsa.mindmap.swing.panel.utils.KeyShortcut in project netbeans-mmd-plugin by raydac.

the class MindMapSettingsPanel method makeConfig.

public MindMapPanelConfig makeConfig() {
    final MindMapPanelConfig result = new MindMapPanelConfig(this.etalon, false);
    result.setPaperColor(this.colorButtonBackgroundColor.getValue());
    result.setGridColor(this.colorButtonGridColor.getValue());
    result.setCollapsatorBackgroundColor(this.colorButtonCollapsatorFill.getValue());
    result.setCollapsatorBorderColor(this.colorButtonCollapsatorBorder.getValue());
    result.setConnectorColor(this.colorButtonConnectorColor.getValue());
    result.setJumpLinkColor(this.colorButtonJumpLink.getValue());
    result.setSelectLineColor(this.colorButtonSelectFrameColor.getValue());
    result.setRootBackgroundColor(this.colorButtonRootFill.getValue());
    result.setRootTextColor(this.colorButtonRootText.getValue());
    result.setFirstLevelBackgroundColor(this.colorButton1stLevelFill.getValue());
    result.setFirstLevelTextColor(this.colorButton1stLevelText.getValue());
    result.setOtherLevelBackgroundColor(this.colorButton2ndLevelFill.getValue());
    result.setOtherLevelTextColor(this.colorButton2ndLevelText.getValue());
    result.setGridStep(getInt(this.spinnerGridStep));
    result.setConnectorWidth(getFloat(this.spinnerConnectorWidth));
    result.setCollapsatorSize(getInt(this.spinnerCollapsatorSize));
    result.setCollapsatorBorderWidth(getFloat(this.spinnerCollapsatorWidth));
    result.setJumpLinkWidth(getFloat(this.spinnerJumpLinkWidth));
    result.setSelectLineWidth(getFloat(this.spinnerSelectionFrameWidth));
    result.setSelectLineGap(getInt(this.spinnerSelectionFrameGap));
    result.setElementBorderWidth(getFloat(this.spinnerBorderWidth));
    result.setShowGrid(this.checkBoxShowGrid.isSelected());
    result.setDropShadow(this.checkBoxDropShadow.isSelected());
    result.setFirstLevelHorizontalInset(this.slider1stLevelHorzGap.getValue());
    result.setFirstLevelVerticalInset(this.slider1stLevelVertGap.getValue());
    result.setOtherLevelHorizontalInset(this.slider2ndLevelHorzGap.getValue());
    result.setOtherLevelVerticalInset(this.slider2ndLevelVertGap.getValue());
    result.setRenderQuality(GetUtils.ensureNonNull((RenderQuality) comboBoxRenderQuality.getSelectedItem(), RenderQuality.DEFAULT));
    result.setFont(this.theFont);
    final int scaleModifier = (this.checkBoxScalingModifierALT.isSelected() ? KeyEvent.ALT_MASK : 0) | (this.checkBoxScalingModifierCTRL.isSelected() ? KeyEvent.CTRL_MASK : 0) | (this.checkBoxScalingModifierSHFT.isSelected() ? KeyEvent.SHIFT_MASK : 0) | (this.checkBoxScalingModifierMETA.isSelected() ? KeyEvent.META_MASK : 0);
    result.setScaleModifiers(scaleModifier);
    for (final Map.Entry<String, KeyShortcut> e : this.mapKeyShortCuts.entrySet()) {
        result.setKeyShortCut(e.getValue());
    }
    return result;
}
Also used : KeyShortcut(com.igormaznitsa.mindmap.swing.panel.utils.KeyShortcut) RenderQuality(com.igormaznitsa.mindmap.swing.panel.utils.RenderQuality) MindMapPanelConfig(com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig)

Aggregations

KeyShortcut (com.igormaznitsa.mindmap.swing.panel.utils.KeyShortcut)14 RenderQuality (com.igormaznitsa.mindmap.swing.panel.utils.RenderQuality)3 Font (java.awt.Font)3 Field (java.lang.reflect.Field)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 TableModelEvent (javax.swing.event.TableModelEvent)3 TableModelListener (javax.swing.event.TableModelListener)3 Color (java.awt.Color)2 Nullable (javax.annotation.Nullable)2 Test (org.junit.Test)2 ReturnsOriginal (com.igormaznitsa.meta.annotation.ReturnsOriginal)1 MindMapPanelConfig (com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig)1 KeyShortCutEditPanel (com.igormaznitsa.nbmindmap.nb.swing.KeyShortCutEditPanel)1 KeyShortCutEditPanel (com.igormaznitsa.sciareto.ui.editors.mmeditors.KeyShortCutEditPanel)1 ArrayList (java.util.ArrayList)1 TreeMap (java.util.TreeMap)1 BackingStoreException (java.util.prefs.BackingStoreException)1 Preferences (java.util.prefs.Preferences)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1