Fixed position and focus.
authorJimmy Christensen <dusted@dusted.dk>
Mon, 11 Aug 2014 19:08:30 +0000 (21:08 +0200)
committerJimmy Christensen <dusted@dusted.dk>
Mon, 11 Aug 2014 19:08:30 +0000 (21:08 +0200)
src/fkgui/MainWin.java
src/fkgui/NewAccountDialog.java
src/fkgui/PermitCountDownDialog.java
src/fkgui/SerialWorker.java
src/fkgui/TriggerDialog.java

index 3e97ca3..30d0754 100644 (file)
@@ -370,9 +370,9 @@ public class MainWin implements ConsoleMsg, UpdateCheckResultListener {
                
                chkAutoHide = new Button(cmpConnect, SWT.CHECK);
                FormData fd_chkAutoHide = new FormData();
+               fd_chkAutoHide.top = new FormAttachment(btnConnect, 0, SWT.TOP);
+               fd_chkAutoHide.left = new FormAttachment(txtDev, 6);
                fd_chkAutoHide.right = new FormAttachment(0, 501);
-               fd_chkAutoHide.top = new FormAttachment(0);
-               fd_chkAutoHide.left = new FormAttachment(0, 262);
                chkAutoHide.setLayoutData(fd_chkAutoHide);
                chkAutoHide.setText(Messages.MainWin_19);
                
@@ -621,8 +621,8 @@ public class MainWin implements ConsoleMsg, UpdateCheckResultListener {
                fd_btnNewAccoount.left = new FormAttachment(btnActivateAccount, 6);
                btnActivateAccount.setImage(SWTResourceManager.getImage(MainWin.class, "/fkgui/gfx/lightbulb.png")); //$NON-NLS-1$
                FormData fd_btnActivateAccount = new FormData();
+               fd_btnActivateAccount.bottom = new FormAttachment(btnNewAccoount, 0, SWT.BOTTOM);
                fd_btnActivateAccount.top = new FormAttachment(btnNewAccoount, 0, SWT.TOP);
-               fd_btnActivateAccount.bottom = new FormAttachment(100, -10);
                fd_btnActivateAccount.right = new FormAttachment(100, -169);
                btnActivateAccount.setLayoutData(fd_btnActivateAccount);
                fd_lstAccounts.top = new FormAttachment(0, 10);
@@ -716,11 +716,11 @@ public class MainWin implements ConsoleMsg, UpdateCheckResultListener {
        private void showTrigDialog(Account acc) {
                TriggerDialog diag = new TriggerDialog(shell, shell.getStyle(), acc, mySelf );
 
-               shell.setMinimized(true);
+               //shell.setMinimized(true);
                shell.setEnabled(false);
                if( !((Boolean)diag.open()) )
                {
-                       shell.setMinimized(false);
+                       //shell.setMinimized(false);
                }
                
                shell.setEnabled(true);
index bd94741..a304b28 100644 (file)
@@ -210,8 +210,8 @@ public class NewAccountDialog extends Dialog implements FkActionEventListener {
                });
                btnNext0.setText(Messages.NewAccountDialog_9);
                FormData fd_btnNext0 = new FormData();
-               fd_btnNext0.bottom = new FormAttachment(btnCancel, 0, SWT.BOTTOM);
-               fd_btnNext0.right = new FormAttachment(lblEnterNewName, 0, SWT.RIGHT);
+               fd_btnNext0.top = new FormAttachment(btnCancel, 0, SWT.TOP);
+               fd_btnNext0.right = new FormAttachment(100, -10);
                btnNext0.setLayoutData(fd_btnNext0);
                btnNext0.setVisible(false);
                
@@ -262,7 +262,6 @@ public class NewAccountDialog extends Dialog implements FkActionEventListener {
                Button btnNext1 = new Button(composite, SWT.NONE);
                btnNext1.setText(Messages.NewAccountDialog_13);
                FormData fd_btnNext1 = new FormData();
-               fd_btnNext1.bottom = new FormAttachment(100, -10);
                fd_btnNext1.right = new FormAttachment(100, -10);
                btnNext1.setLayoutData(fd_btnNext1);
                btnNext1.addSelectionListener(new SelectionListener() {
@@ -287,9 +286,10 @@ public class NewAccountDialog extends Dialog implements FkActionEventListener {
                });
                
                Button btnBack0 = new Button(composite, SWT.NONE);
+               fd_btnNext1.top = new FormAttachment(btnBack0, 0, SWT.TOP);
                btnBack0.setText(Messages.NewAccountDialog_14);
                FormData fd_btnBack0 = new FormData();
-               fd_btnBack0.bottom = new FormAttachment(btnNext1, 0, SWT.BOTTOM);
+               fd_btnBack0.bottom = new FormAttachment(100, -10);
                fd_btnBack0.left = new FormAttachment(lblNextUpSetting, 0, SWT.LEFT);
                btnBack0.setLayoutData(fd_btnBack0);
                btnBack0.addSelectionListener( new SelectionListener() {
@@ -325,8 +325,9 @@ public class NewAccountDialog extends Dialog implements FkActionEventListener {
                
                Label lblBeforeCreatingA = new Label(composite, SWT.NONE);
                FormData fd_lblBeforeCreatingA = new FormData();
-               fd_lblBeforeCreatingA.top = new FormAttachment(0, 10);
                fd_lblBeforeCreatingA.left = new FormAttachment(0, 10);
+               fd_lblBeforeCreatingA.right = new FormAttachment(100, -10);
+               fd_lblBeforeCreatingA.top = new FormAttachment(0, 10);
                lblBeforeCreatingA.setLayoutData(fd_lblBeforeCreatingA);
                
                lblBeforeCreatingA.setText(Messages.NewAccountDialog_15);
@@ -389,11 +390,9 @@ public class NewAccountDialog extends Dialog implements FkActionEventListener {
                
                
                Button button_6 = new Button(composite, SWT.NONE);
-               fd_lblBeforeCreatingA.right = new FormAttachment(button_6, 0, SWT.RIGHT);
                button_6.setText(Messages.NewAccountDialog_21);
                FormData fd_button_6 = new FormData();
-               fd_button_6.bottom = new FormAttachment(100, -10);
-               fd_button_6.right = new FormAttachment(100, -10);
+               fd_button_6.right = new FormAttachment(lblBeforeCreatingA, 0, SWT.RIGHT);
                button_6.setLayoutData(fd_button_6);
                
                button_6.addSelectionListener(new SelectionListener() {
@@ -411,11 +410,11 @@ public class NewAccountDialog extends Dialog implements FkActionEventListener {
                
 
                Button button_5 = new Button(composite, SWT.NONE);
+               fd_button_6.top = new FormAttachment(button_5, 0, SWT.TOP);
                button_5.setText(Messages.NewAccountDialog_20);
                FormData fd_button_5 = new FormData();
+               fd_button_5.bottom = new FormAttachment(100, -10);
                fd_button_5.left = new FormAttachment(0, 10);
-
-               fd_button_5.bottom = new FormAttachment(button_6, 0, SWT.BOTTOM);
                button_5.setLayoutData(fd_button_5);
                
                button_5.addSelectionListener(new SelectionListener() {
@@ -527,7 +526,8 @@ public class NewAccountDialog extends Dialog implements FkActionEventListener {
                
                btnManPassPageNext = new Button(composite, SWT.NONE);
                FormData fd_btnManPassPageNext = new FormData();
-               fd_btnManPassPageNext.bottom = new FormAttachment(BtnBack1, 0, SWT.BOTTOM);
+               fd_btnManPassPageNext.top = new FormAttachment(BtnBack1, 0, SWT.TOP);
+               fd_btnManPassPageNext.right = new FormAttachment(100, -10);
                btnManPassPageNext.setLayoutData(fd_btnManPassPageNext);
                btnManPassPageNext.setText(Messages.NewAccountDialog_24);
                btnManPassPageNext.setVisible(false);
@@ -544,7 +544,6 @@ public class NewAccountDialog extends Dialog implements FkActionEventListener {
                });
                
                lblTypeThePassword = new Label(composite, SWT.NONE);
-               fd_btnManPassPageNext.right = new FormAttachment(lblTypeThePassword, 0, SWT.RIGHT);
                fd_BtnBack1.left = new FormAttachment(lblTypeThePassword, 0, SWT.LEFT);
                FormData fd_lblTypeThePassword = new FormData();
                fd_lblTypeThePassword.right = new FormAttachment(0, 613);
@@ -609,8 +608,7 @@ public class NewAccountDialog extends Dialog implements FkActionEventListener {
                
                Button button_7 = new Button(composite, SWT.NONE);
                FormData fd_button_7 = new FormData();
-               fd_button_7.top = new FormAttachment(0, 325);
-               fd_button_7.left = new FormAttachment(0, 10);
+               fd_button_7.left = new FormAttachment(lblToMakeFinalkey, 0, SWT.LEFT);
                button_7.setLayoutData(fd_button_7);
                button_7.setText(Messages.NewAccountDialog_30);
                button_7.addSelectionListener(new SelectionListener() {
@@ -632,9 +630,10 @@ public class NewAccountDialog extends Dialog implements FkActionEventListener {
                });
                
                Button button_8 = new Button(composite, SWT.NONE);
+               fd_button_7.top = new FormAttachment(button_8, 0, SWT.TOP);
                FormData fd_button_8 = new FormData();
-               fd_button_8.top = new FormAttachment(0, 325);
-               fd_button_8.left = new FormAttachment(0, 565);
+               fd_button_8.bottom = new FormAttachment(100, -10);
+               fd_button_8.right = new FormAttachment(100, -10);
                button_8.setLayoutData(fd_button_8);
                button_8.setText(Messages.NewAccountDialog_31);
                button_8.addSelectionListener(new SelectionListener() {
@@ -717,6 +716,7 @@ public class NewAccountDialog extends Dialog implements FkActionEventListener {
                
                Button button_9 = new Button(composite, SWT.NONE);
                FormData fd_button_9 = new FormData();
+               fd_button_9.bottom = new FormAttachment(100, -10);
                fd_button_9.left = new FormAttachment(lblHeresAnOverview, 0, SWT.LEFT);
                button_9.setLayoutData(fd_button_9);
                button_9.setText(Messages.NewAccountDialog_38);
@@ -733,10 +733,9 @@ public class NewAccountDialog extends Dialog implements FkActionEventListener {
                });
                
                Button btnSave = new Button(composite, SWT.NONE);
-               fd_button_9.bottom = new FormAttachment(btnSave, 0, SWT.BOTTOM);
                FormData fd_btnSave = new FormData();
-               fd_btnSave.bottom = new FormAttachment(100, -10);
-               fd_btnSave.right = new FormAttachment(lblHeresAnOverview, 0, SWT.RIGHT);
+               fd_btnSave.top = new FormAttachment(button_9, 0, SWT.TOP);
+               fd_btnSave.right = new FormAttachment(100, -10);
                btnSave.setLayoutData(fd_btnSave);
                btnSave.setText(Messages.NewAccountDialog_39);
                btnSave.setFocus();
@@ -829,6 +828,7 @@ public class NewAccountDialog extends Dialog implements FkActionEventListener {
                
                txtBUSYMSG = new Label(composite, SWT.NONE);
                FormData fd_txtBUSYMSG = new FormData();
+               fd_txtBUSYMSG.bottom = new FormAttachment(0, 113);
                fd_txtBUSYMSG.top = new FormAttachment(0, 10);
                fd_txtBUSYMSG.right = new FormAttachment(100, -10);
                fd_txtBUSYMSG.left = new FormAttachment(0, 78);
@@ -855,8 +855,7 @@ public class NewAccountDialog extends Dialog implements FkActionEventListener {
                {
                        composite.dispose();
                }
-               //System.out.println(curPage);
-               
+
                switch(curPage)
                {
                case CLICKBTN:
index 666e1aa..17e8cc4 100644 (file)
@@ -50,7 +50,7 @@ public class PermitCountDownDialog extends Dialog {
                lblMsg.setText(msg);
                
                lblTimeLeft = new Label(shell, SWT.NONE);
-               lblTimeLeft.setBounds(48, 56, 201, 32);
+               lblTimeLeft.setBounds(48, 70, 461, 27);
                
                Animation animation = new Animation(shell, SWT.NONE, 4);
                animation.setBounds(10, 32, 32, 32);
index 7ebc929..8f70f01 100644 (file)
@@ -59,6 +59,7 @@ public class SerialWorker extends javax.swing.SwingWorker<Void, String> implemen
        public String expectString(String expect, int timeOut)
        {
                
+               System.out.println("Searching for string:"+expect+" timeout:"+timeOut);
                //Read from port, and if not found within 2 seconds, exit with null
                String in=new String();
                int msLeft=timeOut;
@@ -67,8 +68,8 @@ public class SerialWorker extends javax.swing.SwingWorker<Void, String> implemen
                        try {
                                if( serialPort.getInputBufferBytesCount() > 0)
                                {
-                                       in += serialPort.readString(serialPort.getInputBufferBytesCount());
-                                       
+                                       in += serialPort.readString();
+                                       System.out.println("In:"+in);
                                        if( in.contains(expect))
                                        {
                                                return(in);
@@ -86,7 +87,7 @@ public class SerialWorker extends javax.swing.SwingWorker<Void, String> implemen
                                }
                        } catch (Exception e)
                        {
-                               //I don't care
+                               System.out.println("Exception from expectString:" + e.getMessage() );
                        }
                }
                
@@ -121,9 +122,15 @@ public class SerialWorker extends javax.swing.SwingWorker<Void, String> implemen
                        } else {
                                //Try logging out.
                                serialPort.writeByte( (byte)'q');
-                               publish(Messages.SerialWorker_5);
-                               disconnect();
-                               return null;
+                               test = expectString("The Final Key", 1000); //$NON-NLS-1$
+                               if( test != null )
+                               {
+                                       publish(Messages.SerialWorker_4);
+                               } else {
+                                       publish(Messages.SerialWorker_5);
+                                       disconnect();
+                                       return null;
+                               }
                        }
                        
                        if( expectString( "Pass:", 0 ) != null ) //$NON-NLS-1$
index cb0108e..acffe9b 100644 (file)
@@ -96,12 +96,14 @@ public class TriggerDialog extends Dialog implements FkActionEventListener {
                        public void widgetSelected(SelectionEvent e) {
                                FkManager.getInstance().trig(account, '%', mySelf);
                                permitCountdownDialog = new PermitCountDownDialog(shell,SWT.SHELL_TRIM, account.name + Messages.TriggerDialog_3, Messages.TriggerDialog_4, 30000);
-                               shell.setMinimized(true);
+                               //shell.setMinimized(true);
+                               shell.setEnabled(false); //Fisk
                                permitCountdownDialog.open();
                        }
                });
                btnUsernamePassword.setImage(SWTResourceManager.getImage(MainWin.class, "/fkgui/gfx/both.png")); //$NON-NLS-1$
                FormData fd_btnUsernamePassword = new FormData();
+               fd_btnUsernamePassword.bottom = new FormAttachment(0, 45);
                fd_btnUsernamePassword.top = new FormAttachment(0, 10);
                fd_btnUsernamePassword.left = new FormAttachment(0, 10);
                fd_btnUsernamePassword.right = new FormAttachment(0, 224);
@@ -115,21 +117,22 @@ public class TriggerDialog extends Dialog implements FkActionEventListener {
                        public void widgetSelected(SelectionEvent e) {
                                FkManager.getInstance().trig(account, 'u', mySelf);
                                permitCountdownDialog = new PermitCountDownDialog(shell,SWT.SHELL_TRIM, account.name + Messages.TriggerDialog_7, Messages.TriggerDialog_8, 30000);
-                               shell.setMinimized(true);
+                               //shell.setMinimized(true);
+                               shell.setEnabled(false); //Fisk
                                permitCountdownDialog.open();
                        }
                });
                btnUsernameOnly.setImage(SWTResourceManager.getImage(MainWin.class, "/fkgui/gfx/user.png")); //$NON-NLS-1$
                FormData fd_btnUsernameOnly = new FormData();
-               fd_btnUsernameOnly.top = new FormAttachment(btnUsernamePassword, -35);
-               fd_btnUsernameOnly.bottom = new FormAttachment(btnUsernamePassword, 0, SWT.BOTTOM);
-               fd_btnUsernameOnly.left = new FormAttachment(btnUsernamePassword, 6);
-               fd_btnUsernameOnly.right = new FormAttachment(0, 405);
+               fd_btnUsernameOnly.bottom = new FormAttachment(100, -15);
+               fd_btnUsernameOnly.top = new FormAttachment(0, 10);
+               fd_btnUsernameOnly.left = new FormAttachment(btnUsernamePassword);
                btnUsernameOnly.setLayoutData(fd_btnUsernameOnly);
 
                btnUsernameOnly.setText(Messages.TriggerDialog_10);
                
                Button btnPasswordOnly = new Button(grpMakeFinalKey, SWT.NONE);
+               fd_btnUsernameOnly.right = new FormAttachment(btnPasswordOnly, -29);
                btnPasswordOnly.addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(SelectionEvent e) {
@@ -137,16 +140,17 @@ public class TriggerDialog extends Dialog implements FkActionEventListener {
                                
                                permitCountdownDialog = new PermitCountDownDialog(shell,SWT.SHELL_TRIM, account.name + Messages.TriggerDialog_11, Messages.TriggerDialog_12, 30000);
 
-                               shell.setMinimized(true);
+                               //shell.setMinimized(true);
+                               shell.setEnabled(false); //Fisk
                                permitCountdownDialog.open();
                        }
                });
                btnPasswordOnly.setImage(SWTResourceManager.getImage(MainWin.class, "/fkgui/gfx/key-icon.png")); //$NON-NLS-1$
                FormData fd_btnPasswordOnly = new FormData();
-               fd_btnPasswordOnly.left = new FormAttachment(btnUsernameOnly, 29);
-               fd_btnPasswordOnly.top = new FormAttachment(btnUsernamePassword, 0, SWT.TOP);
-               fd_btnPasswordOnly.right = new FormAttachment(100, -9);
-               fd_btnPasswordOnly.bottom = new FormAttachment(0, 45);
+               fd_btnPasswordOnly.bottom = new FormAttachment(100, -15);
+               fd_btnPasswordOnly.top = new FormAttachment(0, 10);
+               fd_btnPasswordOnly.left = new FormAttachment(0, 431);
+               fd_btnPasswordOnly.right = new FormAttachment(100, -21);
                btnPasswordOnly.setLayoutData(fd_btnPasswordOnly);
 
                btnPasswordOnly.setText(Messages.TriggerDialog_14);
@@ -163,14 +167,16 @@ public class TriggerDialog extends Dialog implements FkActionEventListener {
                                Button btnEdit = new Button(grpChange, SWT.NONE);
                                btnEdit.setImage(SWTResourceManager.getImage(MainWin.class, "/fkgui/gfx/gtk_edit.png")); //$NON-NLS-1$
                                FormData fd_btnEdit = new FormData();
-                               fd_btnEdit.top = new FormAttachment(0, 10);
+                               fd_btnEdit.bottom = new FormAttachment(0, 48);
                                fd_btnEdit.left = new FormAttachment(0, 10);
+                               fd_btnEdit.top = new FormAttachment(0, 10);
                                btnEdit.setLayoutData(fd_btnEdit);
                                btnEdit.setText(Messages.TriggerDialog_17);
                                ///TODO: Inplement edit box..
                                btnEdit.setVisible(false);
                                
                                Button btnDelete = new Button(grpChange, SWT.NONE);
+                               fd_btnEdit.right = new FormAttachment(100, -138);
                                btnDelete.addSelectionListener(new SelectionAdapter() {
                                        @Override
                                        public void widgetSelected(SelectionEvent e) {
@@ -180,20 +186,22 @@ public class TriggerDialog extends Dialog implements FkActionEventListener {
                                                if( dialog.open() == SWT.YES )
                                                {
                                                        permitCountdownDialog = new PermitCountDownDialog(shell,SWT.SHELL_TRIM, account.name + Messages.TriggerDialog_22, Messages.TriggerDialog_23+account.name+Messages.TriggerDialog_24, 5000);
-                                                       shell.setMinimized(true);
+                                                       //shell.setMinimized(true);
                                                        FkManager.getInstance().trig(account, 'd', mySelf);
+                                                       shell.setEnabled(false); //Fisk
                                                        permitCountdownDialog.open();
                                                        
+                                                       
 
                                                }
                                        }
                                });
-                               fd_btnEdit.right = new FormAttachment(btnDelete, -6);
                                btnDelete.setImage(SWTResourceManager.getImage(MainWin.class, "/fkgui/gfx/trashdelete.gif")); //$NON-NLS-1$
                                FormData fd_btnDelete = new FormData();
+                               fd_btnDelete.bottom = new FormAttachment(100, -20);
                                fd_btnDelete.top = new FormAttachment(0, 10);
-                               fd_btnDelete.left = new FormAttachment(0, 166);
-                               fd_btnDelete.right = new FormAttachment(100, -11);
+                               fd_btnDelete.right = new FormAttachment(100, -16);
+                               fd_btnDelete.left = new FormAttachment(btnEdit, 10);
                                btnDelete.setLayoutData(fd_btnDelete);
                                btnDelete.setText(Messages.TriggerDialog_26);
 
@@ -228,12 +236,14 @@ public class TriggerDialog extends Dialog implements FkActionEventListener {
                                        public void widgetSelected(SelectionEvent e) {
                                                FkManager.getInstance().trig(account, 's', mySelf);
                                                permitCountdownDialog = new PermitCountDownDialog(shell,SWT.SHELL_TRIM, account.name + Messages.TriggerDialog_30, Messages.TriggerDialog_31, 30000);
-                                               shell.setMinimized(true);
+                                               //shell.setMinimized(true);
+                                               shell.setEnabled(false); //Fisk
                                                permitCountdownDialog.open();
+                                               
                                        }
                                });
                                btnShowUsername.setImage(SWTResourceManager.getImage(MainWin.class, "/fkgui/gfx/both.png")); //$NON-NLS-1$
-                               btnShowUsername.setBounds(10, 36, 327, 35);
+                               btnShowUsername.setBounds(10, 28, 327, 35);
                                btnShowUsername.setText(Messages.TriggerDialog_33);                             
                                
 
@@ -254,6 +264,7 @@ public class TriggerDialog extends Dialog implements FkActionEventListener {
                        permitCountdownDialog.shell.close();
                }
                
+               
                switch(event.type)
                {
                case STATE_ERROR:
@@ -312,7 +323,10 @@ public class TriggerDialog extends Dialog implements FkActionEventListener {
                        break;
                } //Switch
                
-
+               if( !shell.isDisposed() && !shell.isEnabled())
+               {
+                       shell.setEnabled(true); //Fisk
+               }
 
                
        }