Search in sources :

Example 1 with LabelledField

use of nl.andrewl.emaildatasetbrowser.view.LabelledField in project EmailDatasetBrowser by ArchitecturalKnowledgeAnalysis.

the class UpgradeDatasetAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    JDialog upgradeDialog = new JDialog(browser, "Upgrade Dataset", true);
    PathSelectField ds1Select = PathSelectField.directorySelectField();
    PathSelectField ds2Select = PathSelectField.directorySelectField();
    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel bodyPanel = new JPanel();
    bodyPanel.setLayout(new BoxLayout(bodyPanel, BoxLayout.PAGE_AXIS));
    bodyPanel.add(new LabelledField("Old Dataset Directory", ds1Select));
    bodyPanel.add(new LabelledField("New Dataset Directory", ds2Select));
    mainPanel.add(bodyPanel, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(e1 -> upgradeDialog.dispose());
    buttonPanel.add(cancelButton);
    JButton okayButton = new JButton("Upgrade");
    okayButton.addActionListener(e1 -> {
        var ds1 = EmailDataset.open(ds1Select.getSelectedPath()).join();
        try {
            if (ds1.getVersion() != 1) {
                JOptionPane.showMessageDialog(upgradeDialog, "Can only upgrade from version 1 datasets.", "Invalid Version", JOptionPane.WARNING_MESSAGE);
                return;
            }
            ProgressDialog progress = ProgressDialog.minimalText(upgradeDialog, "Upgrading...");
            Async.run(() -> {
                new Version1Upgrader().upgrade(ds1Select.getSelectedPath(), ds2Select.getSelectedPath(), new Status().withMessageConsumer(progress));
                progress.done();
                upgradeDialog.dispose();
            });
        } catch (Exception e2) {
            e2.printStackTrace();
            upgradeDialog.dispose();
        }
    });
    buttonPanel.add(okayButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    upgradeDialog.setContentPane(mainPanel);
    upgradeDialog.setPreferredSize(new Dimension(500, 300));
    upgradeDialog.pack();
    upgradeDialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    upgradeDialog.setLocationRelativeTo(browser);
    upgradeDialog.setVisible(true);
}
Also used : Status(nl.andrewl.email_indexer.util.Status) ProgressDialog(nl.andrewl.emaildatasetbrowser.view.ProgressDialog) PathSelectField(nl.andrewl.emaildatasetbrowser.view.PathSelectField) Version1Upgrader(nl.andrewl.email_indexer.data.upgrade.Version1Upgrader) LabelledField(nl.andrewl.emaildatasetbrowser.view.LabelledField)

Example 2 with LabelledField

use of nl.andrewl.emaildatasetbrowser.view.LabelledField in project EmailDatasetBrowser by ArchitecturalKnowledgeAnalysis.

the class DownloadEmailsAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    JDialog dialog = new JDialog(owner, "Download ", Dialog.ModalityType.APPLICATION_MODAL);
    JPanel p = new JPanel(new BorderLayout());
    JTextField domainField = new JTextField(0);
    JTextField listField = new JTextField(0);
    var timeSettings = new TimePickerSettings();
    timeSettings.setAllowEmptyTimes(false);
    timeSettings.setInitialTimeToNow();
    var dateSettings = new DatePickerSettings();
    dateSettings.setAllowEmptyDates(false);
    DateTimePicker startPicker = new DateTimePicker(dateSettings.copySettings(), timeSettings);
    startPicker.setDateTimeStrict(LocalDateTime.now().minusYears(10));
    DateTimePicker endPicker = new DateTimePicker(dateSettings.copySettings(), timeSettings);
    endPicker.setDateTimeStrict(LocalDateTime.now());
    PathSelectField dirField = PathSelectField.directorySelectField();
    JPanel inputPanel = new JPanel();
    inputPanel.setLayout(new BoxLayout(inputPanel, BoxLayout.PAGE_AXIS));
    inputPanel.add(new LabelledField("Domain", domainField));
    inputPanel.add(new LabelledField("List", listField));
    inputPanel.add(new LabelledField("Start", startPicker));
    inputPanel.add(new LabelledField("End", endPicker));
    inputPanel.add(dirField);
    p.add(inputPanel, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(event -> dialog.dispose());
    JButton downloadButton = new JButton("Download");
    downloadButton.addActionListener(event -> {
        ApacheMailingListFetcher fetcher = new ApacheMailingListFetcher();
        Path outputDir = dirField.getSelectedPath();
        dialog.dispose();
        ProgressDialog progressDialog = new ProgressDialog(owner, "Downloading...", "Downloading emails");
        progressDialog.activate();
        fetcher.download(outputDir, domainField.getText(), listField.getText(), startPicker.getDateTimeStrict().atZone(ZoneId.systemDefault()), endPicker.getDateTimeStrict().atZone(ZoneId.systemDefault()), progressDialog).handle((paths, throwable) -> {
            progressDialog.done();
            if (throwable == null) {
                JOptionPane.showMessageDialog(progressDialog, "MBox files downloaded successfully.", "Done", JOptionPane.INFORMATION_MESSAGE);
            } else {
                throwable.printStackTrace();
            }
            return null;
        });
    });
    buttonPanel.add(downloadButton);
    buttonPanel.add(cancelButton);
    p.add(buttonPanel, BorderLayout.SOUTH);
    dialog.setContentPane(p);
    dialog.pack();
    dialog.setLocationRelativeTo(owner);
    dialog.setVisible(true);
}
Also used : Path(java.nio.file.Path) ApacheMailingListFetcher(nl.andrewl.emaildownloader.ApacheMailingListFetcher) TimePickerSettings(com.github.lgooddatepicker.components.TimePickerSettings) DateTimePicker(com.github.lgooddatepicker.components.DateTimePicker) ProgressDialog(nl.andrewl.emaildatasetbrowser.view.ProgressDialog) DatePickerSettings(com.github.lgooddatepicker.components.DatePickerSettings) PathSelectField(nl.andrewl.emaildatasetbrowser.view.PathSelectField) LabelledField(nl.andrewl.emaildatasetbrowser.view.LabelledField)

Example 3 with LabelledField

use of nl.andrewl.emaildatasetbrowser.view.LabelledField in project EmailDatasetBrowser by ArchitecturalKnowledgeAnalysis.

the class TagEditDialog method buildUI.

private Container buildUI() {
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(new LabelledField("Name", nameField), BorderLayout.NORTH);
    descriptionField.setLineWrap(true);
    descriptionField.setWrapStyleWord(true);
    mainPanel.add(new LabelledField("Description", new JScrollPane(descriptionField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)), BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(e -> dispose());
    JButton okayButton = new JButton("Okay");
    okayButton.addActionListener(e -> {
        if (!validateTag())
            return;
        onSubmit();
        dispose();
    });
    buttonPanel.add(cancelButton);
    buttonPanel.add(okayButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    return mainPanel;
}
Also used : LabelledField(nl.andrewl.emaildatasetbrowser.view.LabelledField)

Aggregations

LabelledField (nl.andrewl.emaildatasetbrowser.view.LabelledField)3 PathSelectField (nl.andrewl.emaildatasetbrowser.view.PathSelectField)2 ProgressDialog (nl.andrewl.emaildatasetbrowser.view.ProgressDialog)2 DatePickerSettings (com.github.lgooddatepicker.components.DatePickerSettings)1 DateTimePicker (com.github.lgooddatepicker.components.DateTimePicker)1 TimePickerSettings (com.github.lgooddatepicker.components.TimePickerSettings)1 Path (java.nio.file.Path)1 Version1Upgrader (nl.andrewl.email_indexer.data.upgrade.Version1Upgrader)1 Status (nl.andrewl.email_indexer.util.Status)1 ApacheMailingListFetcher (nl.andrewl.emaildownloader.ApacheMailingListFetcher)1