Search in sources :

Example 1 with ImportExtractedItemsWizard

use of name.abuchen.portfolio.ui.wizards.datatransfer.ImportExtractedItemsWizard in project portfolio by buchen.

the class ImportIBHandler method execute.

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell) throws IOException {
    Client client = MenuHelper.getActiveClient(part);
    if (client == null)
        return;
    try {
        Extractor extractor = new IBFlexStatementExtractor(client);
        FileDialog fileDialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
        fileDialog.setText(extractor.getLabel());
        fileDialog.setFilterNames(new String[] { // $NON-NLS-1$
        MessageFormat.format("{0} ({1})", extractor.getLabel(), extractor.getFilterExtension()) });
        fileDialog.setFilterExtensions(new String[] { extractor.getFilterExtension() });
        fileDialog.open();
        String[] filenames = fileDialog.getFileNames();
        if (filenames.length == 0)
            return;
        List<Extractor.InputFile> files = new ArrayList<>();
        for (String filename : filenames) files.add(new Extractor.InputFile(new File(fileDialog.getFilterPath(), filename)));
        IPreferenceStore preferences = ((PortfolioPart) part.getObject()).getPreferenceStore();
        Dialog wizwardDialog = new WizardDialog(Display.getDefault().getActiveShell(), new ImportExtractedItemsWizard(client, extractor, preferences, files));
        wizwardDialog.open();
    } catch (IllegalArgumentException e) {
        PortfolioPlugin.log(e);
        MessageDialog.openError(shell, Messages.LabelError, e.getMessage());
    }
}
Also used : ArrayList(java.util.ArrayList) IBFlexStatementExtractor(name.abuchen.portfolio.datatransfer.IBFlexStatementExtractor) PortfolioPart(name.abuchen.portfolio.ui.PortfolioPart) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) FileDialog(org.eclipse.swt.widgets.FileDialog) Dialog(org.eclipse.jface.dialogs.Dialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ImportExtractedItemsWizard(name.abuchen.portfolio.ui.wizards.datatransfer.ImportExtractedItemsWizard) IBFlexStatementExtractor(name.abuchen.portfolio.datatransfer.IBFlexStatementExtractor) Extractor(name.abuchen.portfolio.datatransfer.Extractor) Client(name.abuchen.portfolio.model.Client) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Execute(org.eclipse.e4.core.di.annotations.Execute) CanExecute(org.eclipse.e4.core.di.annotations.CanExecute)

Example 2 with ImportExtractedItemsWizard

use of name.abuchen.portfolio.ui.wizards.datatransfer.ImportExtractedItemsWizard in project portfolio by buchen.

the class ImportPDFHandler method openWizard.

protected void openWizard(Shell shell, Client client, List<Extractor.InputFile> files, IPreferenceStore preferences, boolean isLegacyMode) {
    try {
        ImportExtractedItemsWizard wizard = new ImportExtractedItemsWizard(client, null, preferences, files);
        wizard.setLegacyMode(isLegacyMode);
        Dialog wizwardDialog = new WizardDialog(shell, wizard);
        wizwardDialog.open();
    } catch (IOException e) {
        PortfolioPlugin.log(e);
        MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.LabelError, e.getMessage());
    }
}
Also used : MessageDialog(org.eclipse.jface.dialogs.MessageDialog) FileDialog(org.eclipse.swt.widgets.FileDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) Dialog(org.eclipse.jface.dialogs.Dialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ImportExtractedItemsWizard(name.abuchen.portfolio.ui.wizards.datatransfer.ImportExtractedItemsWizard) IOException(java.io.IOException) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Aggregations

ImportExtractedItemsWizard (name.abuchen.portfolio.ui.wizards.datatransfer.ImportExtractedItemsWizard)2 Dialog (org.eclipse.jface.dialogs.Dialog)2 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)2 WizardDialog (org.eclipse.jface.wizard.WizardDialog)2 FileDialog (org.eclipse.swt.widgets.FileDialog)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Extractor (name.abuchen.portfolio.datatransfer.Extractor)1 IBFlexStatementExtractor (name.abuchen.portfolio.datatransfer.IBFlexStatementExtractor)1 Client (name.abuchen.portfolio.model.Client)1 PortfolioPart (name.abuchen.portfolio.ui.PortfolioPart)1 CanExecute (org.eclipse.e4.core.di.annotations.CanExecute)1 Execute (org.eclipse.e4.core.di.annotations.Execute)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1