Search in sources :

Example 6 with KeyShortcut

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

the class PreferencesPanel method buttonOpenShortcutEditorActionPerformed.

// GEN-LAST:event_spinnerJumpLinkWidthStateChanged
private void buttonOpenShortcutEditorActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_buttonOpenShortcutEditorActionPerformed
    final List<KeyShortcut> list = new ArrayList<>();
    for (final Map.Entry<String, KeyShortcut> e : this.mapKeyShortCuts.entrySet()) {
        list.add(e.getValue());
    }
    final KeyShortCutEditPanel panel = new KeyShortCutEditPanel(list);
    if (DialogProviderManager.getInstance().getDialogProvider().msgOkCancel(this, "Edit shortcuts", panel)) {
        for (final KeyShortcut s : panel.getResult()) {
            this.mapKeyShortCuts.put(s.getID(), s);
        }
        if (this.changeNotificationAllowed) {
            this.changed = true;
        }
    }
}
Also used : KeyShortcut(com.igormaznitsa.mindmap.swing.panel.utils.KeyShortcut) ArrayList(java.util.ArrayList) KeyShortCutEditPanel(com.igormaznitsa.sciareto.ui.editors.mmeditors.KeyShortCutEditPanel) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 7 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 8 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 9 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 10 with KeyShortcut

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

the class MindMapPanelConfigTest method testHasDifferenceInParameters_DifferenceInKeyShortcuts.

@Test
public void testHasDifferenceInParameters_DifferenceInKeyShortcuts() {
    final MindMapPanelConfig one = new MindMapPanelConfig();
    final MindMapPanelConfig two = new MindMapPanelConfig();
    one.setKeyShortCut(new KeyShortcut(MindMapPanelConfig.KEY_ADD_CHILD_AND_START_EDIT, Integer.MAX_VALUE, Integer.MIN_VALUE));
    assertTrue(one.hasDifferenceInParameters(two));
}
Also used : KeyShortcut(com.igormaznitsa.mindmap.swing.panel.utils.KeyShortcut) Test(org.junit.Test)

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