Search in sources :

Example 26 with MPart

use of org.eclipse.e4.ui.model.application.ui.basic.MPart in project portfolio by buchen.

the class RunConsistencyChecksHandler 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;
    new ConsistencyChecksJob(client, true).schedule();
}
Also used : ConsistencyChecksJob(name.abuchen.portfolio.ui.ConsistencyChecksJob) Client(name.abuchen.portfolio.model.Client) CanExecute(org.eclipse.e4.core.di.annotations.CanExecute) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 27 with MPart

use of org.eclipse.e4.ui.model.application.ui.basic.MPart in project portfolio by buchen.

the class SaveAsFileHandler method execute.

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell, @Named(UIConstants.Parameter.EXTENSION) String extension, @Named(UIConstants.Parameter.ENCRYPTION_METHOD) @Optional String encryptionMethod) {
    Client client = MenuHelper.getActiveClient(part);
    if (client == null)
        return;
    if (extension == null)
        // $NON-NLS-1$
        throw new IllegalArgumentException("Missing file extension parameter");
    // check whether encryption is supported
    if (// $NON-NLS-1$
    "AES256".equals(encryptionMethod) && !ClientFactory.isKeyLengthSupported(256)) {
        new JurisdictionFilesDownloadDialog(shell).open();
        return;
    }
    // trigger part to save file
    ((PortfolioPart) part.getObject()).doSaveAs(part, shell, extension, encryptionMethod);
}
Also used : PortfolioPart(name.abuchen.portfolio.ui.PortfolioPart) Client(name.abuchen.portfolio.model.Client) Execute(org.eclipse.e4.core.di.annotations.Execute) CanExecute(org.eclipse.e4.core.di.annotations.CanExecute)

Example 28 with MPart

use of org.eclipse.e4.ui.model.application.ui.basic.MPart 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();
}
Also used : PortfolioPart(name.abuchen.portfolio.ui.PortfolioPart) FileDialog(org.eclipse.swt.widgets.FileDialog) Dialog(org.eclipse.jface.dialogs.Dialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) CSVImportWizard(name.abuchen.portfolio.ui.wizards.datatransfer.CSVImportWizard) Client(name.abuchen.portfolio.model.Client) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) FileDialog(org.eclipse.swt.widgets.FileDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) File(java.io.File) CanExecute(org.eclipse.e4.core.di.annotations.CanExecute) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 29 with MPart

use of org.eclipse.e4.ui.model.application.ui.basic.MPart in project portfolio by buchen.

the class OpenFileHandler method execute.

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, // 
@Optional @Named(IServiceConstants.ACTIVE_PART) MPart activePart, MApplication app, EPartService partService, EModelService modelService) {
    FileDialog dialog = new FileDialog(shell, SWT.OPEN);
    // $NON-NLS-1$ //$NON-NLS-2$
    dialog.setFilterExtensions(new String[] { "*.xml;*.zip;*.portfolio", "*.*" });
    dialog.setFilterNames(new String[] { Messages.LabelPortfolioPerformanceFile, Messages.LabelAllFiles });
    String fileSelected = dialog.open();
    if (fileSelected != null) {
        MPart part = partService.createPart(UIConstants.Part.PORTFOLIO);
        part.setLabel(new File(fileSelected).getName());
        part.setTooltip(fileSelected);
        part.getPersistedState().put(UIConstants.File.PERSISTED_STATE_KEY, fileSelected);
        if (activePart != null)
            activePart.getParent().getChildren().add(part);
        else
            ((MPartStack) modelService.find(UIConstants.PartStack.MAIN, app)).getChildren().add(part);
        part.setVisible(true);
        part.getParent().setVisible(true);
        partService.showPart(part, PartState.ACTIVATE);
    }
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) MPartStack(org.eclipse.e4.ui.model.application.ui.basic.MPartStack) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 30 with MPart

use of org.eclipse.e4.ui.model.application.ui.basic.MPart in project portfolio by buchen.

the class ExportHandler 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;
    Dialog dialog = new WizardDialog(shell, new ExportWizard(client));
    dialog.open();
}
Also used : Dialog(org.eclipse.jface.dialogs.Dialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Client(name.abuchen.portfolio.model.Client) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ExportWizard(name.abuchen.portfolio.ui.wizards.datatransfer.ExportWizard) CanExecute(org.eclipse.e4.core.di.annotations.CanExecute) Execute(org.eclipse.e4.core.di.annotations.Execute)

Aggregations

Execute (org.eclipse.e4.core.di.annotations.Execute)20 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)19 Client (name.abuchen.portfolio.model.Client)12 CanExecute (org.eclipse.e4.core.di.annotations.CanExecute)11 File (java.io.File)7 MPartStack (org.eclipse.e4.ui.model.application.ui.basic.MPartStack)7 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)6 PortfolioPart (name.abuchen.portfolio.ui.PortfolioPart)5 WizardDialog (org.eclipse.jface.wizard.WizardDialog)5 FileDialog (org.eclipse.swt.widgets.FileDialog)5 Dialog (org.eclipse.jface.dialogs.Dialog)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 MUIElement (org.eclipse.e4.ui.model.application.ui.MUIElement)3 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)3 StringWriter (java.io.StringWriter)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 List (java.util.List)2 Named (javax.inject.Named)2 Extractor (name.abuchen.portfolio.datatransfer.Extractor)2