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"));
}
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);
}
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);
}
}
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);
}
Aggregations