Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Commit

Permalink
Easily add new number to contacts
Browse files Browse the repository at this point in the history
When an unknown number is provided in the recipient field, offer an easy
way to create a new contact from this dialog - show a button nearby.

Fixes: https://code.google.com/p/esmska/issues/detail?id=255
Contributed by: tomas kozak <kozakto2@fel.cvut.cz>
Pull request: #12
  • Loading branch information
kparal committed May 13, 2014
1 parent b52c3d8 commit f2d74f4
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 25 deletions.
43 changes: 31 additions & 12 deletions src/esmska/gui/SMSPanel.form
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.1" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
Expand All @@ -9,6 +9,9 @@
</TitledBorder>
</Border>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[5, 5]"/>
</Property>
</Properties>
<Events>
<EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="formFocusGained"/>
Expand Down Expand Up @@ -37,12 +40,14 @@
<Group type="102" alignment="1" attributes="0">
<Component id="recipientLabel" linkSize="5" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="recipientTextField" pref="310" max="32767" attributes="0"/>
<Component id="recipientTextField" pref="325" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="addContactButton" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="gatewayLabel" linkSize="5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="gatewayComboBox" pref="276" max="32767" attributes="0"/>
<Component id="gatewayComboBox" pref="325" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="suggestGatewayButton" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
Expand All @@ -57,11 +62,11 @@
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Component id="smsCounterLabel" pref="286" max="32767" attributes="0"/>
<Component id="smsCounterLabel" pref="341" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="sendButton" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jScrollPane1" pref="310" max="32767" attributes="0"/>
<Component id="jScrollPane1" pref="378" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
Expand All @@ -71,7 +76,7 @@
<Component id="infoPanel" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand All @@ -80,7 +85,8 @@
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="recipientLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="recipientTextField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="recipientTextField" linkSize="6" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="addContactButton" linkSize="6" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
Expand All @@ -96,7 +102,7 @@
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jScrollPane1" pref="24" max="32767" attributes="0"/>
<Component id="jScrollPane1" pref="65" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="infoPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
Expand Down Expand Up @@ -141,7 +147,7 @@
<SubComponents>
<Component class="javax.swing.JTextPane" name="smsTextPane">
<AuxValues>
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="smsTextPane.getDocument().addDocumentListener(smsTextPaneListener);&#xa;smsTextPaneDocumentFilter = new SMSTextPaneDocumentFilter();&#xa;((AbstractDocument)smsTextPane.getStyledDocument()).setDocumentFilter(smsTextPaneDocumentFilter);&#xa;&#xa;//bind actions and listeners&#xa;smsTextUndoManager.setLimit(-1);&#xa;smsTextPane.getDocument().addUndoableEditListener(new UndoableEditListener() {&#xa; public void undoableEditHappened(UndoableEditEvent e) {&#xa; if (e.getEdit().getPresentationName().contains(&quot;style&quot;))&#xa; return;&#xa; smsTextUndoManager.addEdit(e.getEdit());&#xa; }&#xa;});&#xa;&#xa;//this mapping is here bcz of some weird performance improvements when holding undo key stroke&#xa;int menuMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();&#xa;String command = &quot;undo&quot;;&#xa;smsTextPane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, menuMask), command);&#xa;smsTextPane.getActionMap().put(command,undoAction);&#xa;command = &quot;redo&quot;;&#xa;smsTextPane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Y, menuMask), command);&#xa;smsTextPane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Z,&#xa; menuMask|KeyEvent.SHIFT_DOWN_MASK), command);&#xa;smsTextPane.getActionMap().put(command, redoAction);&#xa;&#xa;//ctrl+enter&#xa;command = &quot;send&quot;;&#xa;smsTextPane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, menuMask), command);&#xa;smsTextPane.getActionMap().put(command, sendAction);&#xa;"/>
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="smsTextPane.getDocument().addDocumentListener(smsTextPaneListener);&#xa;smsTextPaneDocumentFilter = new SMSTextPaneDocumentFilter();&#xa;((AbstractDocument)smsTextPane.getStyledDocument()).setDocumentFilter(smsTextPaneDocumentFilter);&#xa;&#xa;//bind actions and listeners&#xa;smsTextUndoManager.setLimit(-1);&#xa;smsTextPane.getDocument().addUndoableEditListener(new UndoableEditListener() {&#xa; public void undoableEditHappened(UndoableEditEvent e) {&#xa; if (e.getEdit().getPresentationName().contains(&quot;style&quot;))&#xa; return;&#xa; smsTextUndoManager.addEdit(e.getEdit());&#xa; }&#xa;});&#xa;&#xa;int menuMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();&#xa;String command = &quot;undo&quot;;&#xa;smsTextPane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, menuMask), command);&#xa;smsTextPane.getActionMap().put(command,undoAction);&#xa;command = &quot;redo&quot;;&#xa;smsTextPane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Y, menuMask), command);&#xa;smsTextPane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Z,&#xa; menuMask|KeyEvent.SHIFT_DOWN_MASK), command);&#xa;smsTextPane.getActionMap().put(command, redoAction);&#xa;&#xa;//ctrl+enter&#xa;command = &quot;send&quot;;&#xa;smsTextPane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, menuMask), command);&#xa;smsTextPane.getActionMap().put(command, sendAction);"/>
</AuxValues>
</Component>
</SubComponents>
Expand Down Expand Up @@ -220,9 +226,9 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="credentialsInfoLabel" alignment="0" pref="328" max="32767" attributes="0"/>
<Component id="numberInfoLabel" alignment="0" pref="328" max="32767" attributes="0"/>
<Component id="countryInfoLabel" alignment="0" pref="328" max="32767" attributes="0"/>
<Component id="credentialsInfoLabel" alignment="0" pref="368" max="32767" attributes="0"/>
<Component id="numberInfoLabel" alignment="0" max="32767" attributes="0"/>
<Component id="countryInfoLabel" alignment="0" pref="368" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
Expand Down Expand Up @@ -285,5 +291,18 @@
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
</Component>
<Component class="javax.swing.JButton" name="addContactButton">
<Properties>
<Property name="action" type="javax.swing.Action" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="showAddContactDialogAction" type="code"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/esmska/resources/add-16.png"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="addContactButton.setText(null);&#xd;&#xa;addContactButton.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE);"/>
</AuxValues>
</Component>
</SubComponents>
</Form>
Loading

0 comments on commit f2d74f4

Please sign in to comment.