use of name.abuchen.portfolio.ui.wizards.datatransfer.CSVImportWizard in project portfolio by buchen.
the class QuotesContextMenu method menuAboutToShow.
public void menuAboutToShow(IMenuManager parent, final Security security) {
IMenuManager manager = new MenuManager(Messages.SecurityMenuQuotes);
parent.add(manager);
Action action = new Action(Messages.SecurityMenuUpdateQuotes) {
@Override
public void run() {
new UpdateQuotesJob(owner.getClient(), security).schedule();
}
};
// enable only if online updates are configured
action.setEnabled(!QuoteFeed.MANUAL.equals(security.getFeed()) || (security.getLatestFeed() != null && !QuoteFeed.MANUAL.equals(security.getLatestFeed())));
manager.add(action);
manager.add(new Action(Messages.SecurityMenuConfigureOnlineUpdate) {
@Override
public void run() {
EditSecurityDialog dialog = new EditSecurityDialog(Display.getDefault().getActiveShell(), owner.getClient(), security);
dialog.setShowQuoteConfigurationInitially(true);
if (dialog.open() != Dialog.OK)
return;
owner.markDirty();
owner.notifyModelUpdated();
}
});
manager.add(new Separator());
manager.add(new Action(Messages.SecurityMenuImportCSV) {
@Override
public void run() {
FileDialog fileDialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.OPEN);
fileDialog.setFilterNames(new String[] { Messages.CSVImportLabelFileCSV, Messages.CSVImportLabelFileAll });
// $NON-NLS-1$ //$NON-NLS-2$
fileDialog.setFilterExtensions(new String[] { "*.csv", "*.*" });
String fileName = fileDialog.open();
if (fileName == null)
return;
CSVImportWizard wizard = new CSVImportWizard(owner.getClient(), owner.getPreferenceStore(), new File(fileName));
wizard.setTarget(security);
Dialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard);
if (dialog.open() != Dialog.OK)
return;
owner.markDirty();
owner.notifyModelUpdated();
}
});
manager.add(new Action(Messages.SecurityMenuImportHTML) {
@Override
public void run() {
Dialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), new ImportQuotesWizard(security));
if (dialog.open() != Dialog.OK)
return;
owner.markDirty();
owner.notifyModelUpdated();
}
});
manager.add(new Action(Messages.SecurityMenuCreateManually) {
@Override
public void run() {
Dialog dialog = new SecurityPriceDialog(Display.getDefault().getActiveShell(), owner.getClient(), security);
if (dialog.open() != Dialog.OK)
return;
owner.markDirty();
owner.notifyModelUpdated();
}
});
manager.add(new Action(Messages.SecurityMenuCreateQuotesFromTransactions) {
@Override
public void run() {
QuoteFromTransactionExtractor qte = new QuoteFromTransactionExtractor(owner.getClient());
if (qte.extractQuotes(security)) {
owner.markDirty();
owner.notifyModelUpdated();
}
}
});
manager.add(new Separator());
manager.add(new Action(Messages.SecurityMenuExportCSV) {
@Override
public void run() {
FileDialog fileDialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.SAVE);
// $NON-NLS-1$
fileDialog.setFileName(TextUtil.sanitizeFilename(security.getName() + ".csv"));
fileDialog.setOverwrite(true);
String fileName = fileDialog.open();
if (fileName == null)
return;
try {
new CSVExporter().exportSecurityPrices(new File(fileName), security);
} catch (IOException e) {
PortfolioPlugin.log(e);
MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.LabelError, e.getMessage());
}
}
});
}
use of name.abuchen.portfolio.ui.wizards.datatransfer.CSVImportWizard in project portfolio by buchen.
the class ImportCSVHandler method execute.
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
Client client = MenuHelper.getActiveClient(part);
if (client == null)
return;
FileDialog fileDialog = new FileDialog(shell, SWT.OPEN);
fileDialog.setFilterNames(new String[] { Messages.CSVImportLabelFileCSV, Messages.CSVImportLabelFileAll });
// $NON-NLS-1$ //$NON-NLS-2$
fileDialog.setFilterExtensions(new String[] { "*.csv", "*.*" });
String fileName = fileDialog.open();
if (fileName == null)
return;
IPreferenceStore preferences = ((PortfolioPart) part.getObject()).getPreferenceStore();
Dialog wizwardDialog = new WizardDialog(shell, new CSVImportWizard(client, preferences, new File(fileName)));
wizwardDialog.open();
}
Aggregations