Search in sources :

Example 1 with TransferAbortEvent

use of org.opendatakit.briefcase.model.TransferAbortEvent in project briefcase by opendatakit.

the class MainBriefcaseWindow method windowClosing.

@Override
public void windowClosing(WindowEvent arg0) {
    exportTerminationFuture.markAsCancelled(new ExportAbortEvent("Main window closed"));
    transferTerminationFuture.markAsCancelled(new TransferAbortEvent("Main window closed"));
}
Also used : ExportAbortEvent(org.opendatakit.briefcase.model.ExportAbortEvent) TransferAbortEvent(org.opendatakit.briefcase.model.TransferAbortEvent)

Example 2 with TransferAbortEvent

use of org.opendatakit.briefcase.model.TransferAbortEvent in project briefcase by opendatakit.

the class MainFormUploaderWindow method initialize.

/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
    frame.setBounds(100, 100, 680, 206);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel lblFormDefinitionFile = new JLabel("Form Definition to upload:");
    txtFormDefinitionFile = new JTextField();
    txtFormDefinitionFile.setFocusable(false);
    txtFormDefinitionFile.setEditable(false);
    txtFormDefinitionFile.setColumns(10);
    btnChoose = new JButton("Choose...");
    btnChoose.addActionListener(new FormDefinitionActionListener());
    txtDestinationName = new JTextField();
    txtDestinationName.setFocusable(false);
    txtDestinationName.setEditable(false);
    txtDestinationName.setColumns(10);
    btnChooseServer = new JButton("Configure...");
    btnChooseServer.addActionListener(new DestinationActionListener());
    lblUploading = new JLabel("");
    btnDetails = new JButton("Details...");
    btnDetails.addActionListener(__ -> {
        if (fs != null) {
            ScrollingStatusListDialog.showDialog(MainFormUploaderWindow.this.frame, fs.getFormDefinition(), fs.getStatusHistory());
        }
    });
    btnUploadForm = new JButton("Upload Form");
    btnUploadForm.addActionListener(__ -> {
        setActiveTransferState(true);
        File formDefn = new File(txtFormDefinitionFile.getText());
        TransferAction.uploadForm(MainFormUploaderWindow.this.frame.getOwner(), destinationServerInfo, terminationFuture, formDefn, fs);
    });
    btnCancel = new JButton("Cancel");
    btnCancel.addActionListener(__ -> terminationFuture.markAsCancelled(new TransferAbortEvent("Form upload cancelled by user.")));
    btnClose = new JButton("Close");
    btnClose.addActionListener(__ -> {
        if (transferStateActive) {
            if (JOptionPane.YES_OPTION != JOptionPane.showOptionDialog(frame, "An upload is in progress. Are you sure you want to abort and exit?", "Confirm Stop Form Upload", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, null, null)) {
                // no-op
                return;
            }
            terminationFuture.markAsCancelled(new TransferAbortEvent("User closes window"));
        }
        frame.setVisible(false);
        frame.dispose();
        System.exit(0);
    });
    JLabel lblUploadToServer = new JLabel("Upload to server:");
    GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
    groupLayout.setHorizontalGroup(groupLayout.createSequentialGroup().addContainerGap().addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addComponent(lblFormDefinitionFile).addComponent(lblUploadToServer).addComponent(lblUploading)).addPreferredGap(ComponentPlacement.RELATED).addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addComponent(txtFormDefinitionFile, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE).addComponent(txtDestinationName, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE).addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup().addComponent(btnDetails).addPreferredGap(ComponentPlacement.RELATED).addComponent(btnUploadForm).addPreferredGap(ComponentPlacement.RELATED).addComponent(btnCancel))).addPreferredGap(ComponentPlacement.RELATED).addGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addComponent(btnChoose, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE).addComponent(btnChooseServer, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)).addComponent(btnClose)).addContainerGap());
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout.createSequentialGroup().addContainerGap().addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(txtFormDefinitionFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(lblFormDefinitionFile).addComponent(btnChoose)).addPreferredGap(ComponentPlacement.RELATED).addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(lblUploadToServer).addComponent(txtDestinationName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(btnChooseServer)).addPreferredGap(ComponentPlacement.UNRELATED, 10, Short.MAX_VALUE).addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(lblUploading).addComponent(btnDetails).addComponent(btnUploadForm).addComponent(btnCancel).addComponent(btnClose)).addContainerGap()));
    frame.getContentPane().setLayout(groupLayout);
    setActiveTransferState(false);
}
Also used : JFrame(javax.swing.JFrame) JButton(javax.swing.JButton) GroupLayout(javax.swing.GroupLayout) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) File(java.io.File) TransferAbortEvent(org.opendatakit.briefcase.model.TransferAbortEvent)

Example 3 with TransferAbortEvent

use of org.opendatakit.briefcase.model.TransferAbortEvent in project briefcase by opendatakit.

the class ServerConnectionDialog method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (CONNECT.equals(e.getActionCommand())) {
        // do action...
        final ServerConnectionInfo info = new ServerConnectionInfo((textUrlField.getText()).trim(), textUsernameField.getText(), textPasswordField.getPassword());
        okButton.setEnabled(false);
        cancelButton.setEnabled(false);
        String errorString;
        Cursor saved = getCursor();
        try {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            paint(getGraphics());
            terminationFuture.reset();
            ServerConnectionTest backgroundAction = new ServerConnectionTest(info, terminationFuture, asTarget);
            backgroundAction.run();
            isSuccessful = backgroundAction.isSuccessful();
            errorString = backgroundAction.getErrorReason();
        } finally {
            setCursor(saved);
        }
        if (isSuccessful) {
            serverInfo = info;
            this.setVisible(false);
        } else {
            String errorMessage = errorString.trim();
            // with punctuation and some not
            if (!(errorMessage.endsWith("!") || errorMessage.endsWith("."))) {
                errorMessage += ". ";
            }
            ODKOptionPane.showErrorDialog(this, errorMessage + MessageStrings.PROXY_SET_ADVICE, "Invalid Server URL");
            okButton.setEnabled(true);
            cancelButton.setEnabled(true);
        }
    } else {
        // cancel...
        terminationFuture.markAsCancelled(new TransferAbortEvent("User cancels connection."));
        this.setVisible(false);
    }
}
Also used : ServerConnectionTest(org.opendatakit.briefcase.util.ServerConnectionTest) ServerConnectionInfo(org.opendatakit.briefcase.model.ServerConnectionInfo) Cursor(java.awt.Cursor) TransferAbortEvent(org.opendatakit.briefcase.model.TransferAbortEvent)

Example 4 with TransferAbortEvent

use of org.opendatakit.briefcase.model.TransferAbortEvent in project briefcase by opendatakit.

the class TransferInProgressDialog method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    terminationFuture.markAsCancelled(new TransferAbortEvent("User cancelled transfer."));
    cancelButton.setEnabled(false);
}
Also used : TransferAbortEvent(org.opendatakit.briefcase.model.TransferAbortEvent)

Aggregations

TransferAbortEvent (org.opendatakit.briefcase.model.TransferAbortEvent)4 Cursor (java.awt.Cursor)1 File (java.io.File)1 GroupLayout (javax.swing.GroupLayout)1 JButton (javax.swing.JButton)1 JFrame (javax.swing.JFrame)1 JLabel (javax.swing.JLabel)1 JTextField (javax.swing.JTextField)1 ExportAbortEvent (org.opendatakit.briefcase.model.ExportAbortEvent)1 ServerConnectionInfo (org.opendatakit.briefcase.model.ServerConnectionInfo)1 ServerConnectionTest (org.opendatakit.briefcase.util.ServerConnectionTest)1