Search in sources :

Example 1 with IBFlexStatementExtractor

use of name.abuchen.portfolio.datatransfer.IBFlexStatementExtractor 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)

Aggregations

File (java.io.File)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 ImportExtractedItemsWizard (name.abuchen.portfolio.ui.wizards.datatransfer.ImportExtractedItemsWizard)1 CanExecute (org.eclipse.e4.core.di.annotations.CanExecute)1 Execute (org.eclipse.e4.core.di.annotations.Execute)1 Dialog (org.eclipse.jface.dialogs.Dialog)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1