Skip to content

Commit

Permalink
ImportIBHandler: Use last saved dir to import IBKR XML files
Browse files Browse the repository at this point in the history
Use existing CSV_IMPORT_PATH saved path ID to not introduce another one.
Previously, the open dialog started with some internal path to PP
executables, so using the same dir as CSV is good enough improvement.
  • Loading branch information
pfalcon authored and buchen committed Dec 13, 2024
1 parent b82f65d commit aceddd4
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
import name.abuchen.portfolio.datatransfer.ibflex.IBFlexStatementExtractor;
import name.abuchen.portfolio.model.Client;
import name.abuchen.portfolio.ui.Messages;
import name.abuchen.portfolio.ui.UIConstants;
import name.abuchen.portfolio.ui.PortfolioPlugin;
import name.abuchen.portfolio.ui.editor.FilePathHelper;
import name.abuchen.portfolio.ui.editor.PortfolioPart;
import name.abuchen.portfolio.ui.wizards.datatransfer.ImportExtractedItemsWizard;

Expand Down Expand Up @@ -63,11 +65,15 @@ private void runImport(MPart part, Shell shell, Client client)
{
Extractor extractor = new IBFlexStatementExtractor(client);

PortfolioPart portPart = (PortfolioPart) part.getObject();
FilePathHelper helper = new FilePathHelper(portPart, UIConstants.Preferences.CSV_IMPORT_PATH);

FileDialog fileDialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
fileDialog.setText(extractor.getLabel());
fileDialog.setFilterNames(
new String[] { MessageFormat.format("{0} ({1})", extractor.getLabel(), "*.xml") }); //$NON-NLS-1$ //$NON-NLS-2$
fileDialog.setFilterExtensions(new String[] { "*.xml;*.XML" }); //$NON-NLS-1$
fileDialog.setFilterPath(helper.getPath());
fileDialog.open();

String[] filenames = fileDialog.getFileNames();
Expand All @@ -89,7 +95,7 @@ private void runImport(MPart part, Shell shell, Client client)
if (!errors.isEmpty())
e.put(files.get(0).getFile(), errors);

IPreferenceStore preferences = ((PortfolioPart) part.getObject()).getPreferenceStore();
IPreferenceStore preferences = portPart.getPreferenceStore();

ImportExtractedItemsWizard wizard = new ImportExtractedItemsWizard(client, preferences, result, e);
Dialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard);
Expand Down

0 comments on commit aceddd4

Please sign in to comment.