@Override protected void onPostExecute(String result) { // Log.e("Joseph", result); Gson gson = new Gson(); Authorisation auth = gson.fromJson(result, Authorisation.class); String error = auth.getError(); if (error.equals("false")) { // User has logged in successfully and api key has been issued // Send data to FragmentActivity by hooking into UI event APIKEY = auth.getApikey(); if (mListener != null) { String[] authDetails = {auth.getName(), auth.getEmail(), auth.getApikey()}; mListener.onFragmentInteraction(authDetails); Toast.makeText(getActivity(), auth.getMessage(), Toast.LENGTH_SHORT).show(); // Update the list in the Drawer so that it can show logout CloseFragment(); } } else { // Login failed because error was returned from service registerFailed.setText(auth.getMessage()); registerFailed.setTextColor(Color.RED); Name.setText(""); Email.setText(""); Password.setText(""); ConfirmPassword.setText(""); Name.requestFocus(); } }
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); cmbBoxPersonalTypes = new javax.swing.JComboBox(); jLabel2 = new javax.swing.JLabel(); txtFieldID = new javax.swing.JTextField(); Name = new javax.swing.JLabel(); txtFieldName = new javax.swing.JTextField(); btnSave = new javax.swing.JButton(); btnCancel = new javax.swing.JButton(); lblErrorMessage = new javax.swing.JLabel(); txtFieldPrimaryAirport = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); setClosable(true); setIconifiable(true); setMaximizable(true); setResizable(true); setName("Form"); // NOI18N org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(flyaway.FlyAWayApp.class) .getContext() .getResourceMap(CreateChangeStaffView.class); jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N jLabel1.setName("jLabel1"); // NOI18N cmbBoxPersonalTypes.setName("cmbBoxPersonalTypes"); // NOI18N jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N jLabel2.setName("jLabel2"); // NOI18N txtFieldID.setText(resourceMap.getString("txtFieldID.text")); // NOI18N txtFieldID.setName("txtFieldID"); // NOI18N Name.setText(resourceMap.getString("Name.text")); // NOI18N Name.setName("Name"); // NOI18N txtFieldName.setText(resourceMap.getString("txtFieldName.text")); // NOI18N txtFieldName.setName("txtFieldName"); // NOI18N btnSave.setText(resourceMap.getString("btnSave.text")); // NOI18N btnSave.setName("btnSave"); // NOI18N btnSave.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSaveActionPerformed(evt); } }); btnCancel.setText(resourceMap.getString("btnCancel.text")); // NOI18N btnCancel.setName("btnCancel"); // NOI18N btnCancel.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCancelActionPerformed(evt); } }); lblErrorMessage.setName("lblErrorMessage"); // NOI18N txtFieldPrimaryAirport.setName("txtFieldPrimaryAirport"); // NOI18N jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N jLabel3.setName("jLabel3"); // NOI18N javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout .createSequentialGroup() .addContainerGap(22, Short.MAX_VALUE) .addComponent( lblErrorMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) .addGroup( layout .createSequentialGroup() .addGap(88, 88, 88) .addComponent(btnSave) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnCancel) .addContainerGap(178, Short.MAX_VALUE)) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout .createSequentialGroup() .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup( javax.swing.GroupLayout.Alignment.LEADING, layout .createSequentialGroup() .addGap(24, 24, 24) .addGroup( layout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(Name) .addComponent(jLabel2)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup( layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent( txtFieldName, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE) .addComponent( txtFieldID, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE))) .addGroup( javax.swing.GroupLayout.Alignment.LEADING, layout .createSequentialGroup() .addContainerGap() .addGroup( layout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel1) .addComponent(jLabel3)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup( layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent( txtFieldPrimaryAirport, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE) .addComponent( cmbBoxPersonalTypes, 0, 280, Short.MAX_VALUE)))) .addGap(22, 22, 22))); layout.setVerticalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGap(15, 15, 15) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent( txtFieldID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(Name) .addComponent( txtFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent( cmbBoxPersonalTypes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent( txtFieldPrimaryAirport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3)) .addGap(16, 16, 16) .addComponent( lblErrorMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnSave) .addComponent(btnCancel)) .addContainerGap())); pack(); } // </editor-fold>//GEN-END:initComponents