Search in sources :

Example 11 with Dialog

use of org.eclipse.jface.dialogs.Dialog in project ecf by eclipse.

the class ScreenCaptureJob method runInUIThread.

public IStatus runInUIThread(IProgressMonitor monitor) {
    final Display display = getDisplay();
    final GC context = new GC(display);
    final Rectangle displayBounds = display.getBounds();
    final Image image = new Image(display, displayBounds);
    context.copyArea(image, displayBounds.x, displayBounds.y);
    context.dispose();
    final Shell shell = new Shell(display, SWT.NO_TRIM);
    shell.setLayout(new FillLayout());
    shell.setBounds(displayBounds);
    crossCursor = new Cursor(display, SWT.CURSOR_CROSS);
    shell.setCursor(crossCursor);
    gc = new GC(shell);
    shell.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent e) {
            e.gc.drawImage(image, 0, 0);
        }
    });
    shell.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            if (e.character == SWT.ESC)
                shell.close();
        }

        public void keyReleased(KeyEvent e) {
            if (e.character == SWT.ESC)
                shell.close();
        }
    });
    shell.addMouseListener(new MouseAdapter() {

        public void mouseDown(MouseEvent e) {
            isDragging = true;
            downX = e.x;
            downY = e.y;
        }

        public void mouseUp(MouseEvent e) {
            isDragging = false;
            final int width = Math.max(downX, e.x) - Math.min(downX, e.x);
            final int height = Math.max(downY, e.y) - Math.min(downY, e.y);
            if (width != 0 && height != 0) {
                final Image copy = new Image(display, width, height);
                gc.copyArea(copy, Math.min(downX, e.x), Math.min(downY, e.y));
                blackColor.dispose();
                whiteColor.dispose();
                final Dialog dialog = new ScreenCaptureConfirmationDialog(shell, targetID, nickName, copy, width, height, imageSender);
                dialog.open();
                shell.close();
                copy.dispose();
            }
        }
    });
    shell.addMouseMoveListener(new MouseMoveListener() {

        public void mouseMove(MouseEvent e) {
            if (isDragging) {
                gc.drawImage(image, 0, 0);
                gc.setForeground(blackColor);
                gc.drawRectangle(downX, downY, e.x - downX, e.y - downY);
                gc.setForeground(whiteColor);
                gc.drawRectangle(downX - 1, downY - 1, e.x - downX + 2, e.y - downY + 2);
            }
        }
    });
    shell.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            image.dispose();
            crossCursor.dispose();
            gc.dispose();
        }
    });
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return Status.OK_STATUS;
}
Also used : FillLayout(org.eclipse.swt.layout.FillLayout) Shell(org.eclipse.swt.widgets.Shell) Dialog(org.eclipse.jface.dialogs.Dialog) Display(org.eclipse.swt.widgets.Display)

Example 12 with Dialog

use of org.eclipse.jface.dialogs.Dialog in project portfolio by buchen.

the class SecuritiesTable method fillTransactionContextMenu.

private void fillTransactionContextMenu(IMenuManager manager, Security security) {
    // $NON-NLS-1$
    new OpenDialogAction(view, Messages.SecurityMenuBuy + "...").type(// 
    SecurityTransactionDialog.class).parameters(// 
    PortfolioTransaction.Type.BUY).with(// 
    security).onSuccess(// 
    d -> performFinish(security)).addTo(manager);
    // $NON-NLS-1$
    new OpenDialogAction(view, Messages.SecurityMenuSell + "...").type(// 
    SecurityTransactionDialog.class).parameters(// 
    PortfolioTransaction.Type.SELL).with(// 
    security).onSuccess(// 
    d -> performFinish(security)).addTo(manager);
    // $NON-NLS-1$
    new OpenDialogAction(view, Messages.SecurityMenuDividends + "...").type(// 
    AccountTransactionDialog.class).parameters(// 
    AccountTransaction.Type.DIVIDENDS).with(// 
    security).onSuccess(// 
    d -> performFinish(security)).addTo(manager);
    // $NON-NLS-1$
    new OpenDialogAction(view, AccountTransaction.Type.TAX_REFUND + "...").type(// 
    AccountTransactionDialog.class).parameters(// 
    AccountTransaction.Type.TAX_REFUND).with(// 
    security).onSuccess(// 
    d -> performFinish(security)).addTo(manager);
    manager.add(new AbstractDialogAction(Messages.SecurityMenuStockSplit) {

        @Override
        Dialog createDialog(Security security) {
            StockSplitWizard wizard = new StockSplitWizard(getClient(), security);
            return new WizardDialog(getShell(), wizard);
        }
    });
    if (view.getClient().getActivePortfolios().size() > 1) {
        manager.add(new Separator());
        // 
        new OpenDialogAction(view, Messages.SecurityMenuTransfer).type(// 
        SecurityTransferDialog.class).with(// 
        security).addTo(manager);
    }
    manager.add(new Separator());
    // $NON-NLS-1$
    new OpenDialogAction(view, PortfolioTransaction.Type.DELIVERY_INBOUND.toString() + "...").type(// 
    SecurityTransactionDialog.class).parameters(// 
    PortfolioTransaction.Type.DELIVERY_INBOUND).with(// 
    security).onSuccess(// 
    d -> performFinish(security)).addTo(manager);
    // $NON-NLS-1$
    new OpenDialogAction(view, PortfolioTransaction.Type.DELIVERY_OUTBOUND.toString() + "...").type(// 
    SecurityTransactionDialog.class).parameters(// 
    PortfolioTransaction.Type.DELIVERY_OUTBOUND).with(// 
    security).onSuccess(// 
    d -> performFinish(security)).addTo(manager);
    manager.add(new Separator());
}
Also used : ReportingPeriodColumnOptions(name.abuchen.portfolio.ui.util.viewers.ReportingPeriodColumnOptions) Client(name.abuchen.portfolio.model.Client) TableViewer(org.eclipse.jface.viewers.TableViewer) BiFunction(java.util.function.BiFunction) DND(org.eclipse.swt.dnd.DND) SecurityDragListener(name.abuchen.portfolio.ui.dnd.SecurityDragListener) CurrencyColumn(name.abuchen.portfolio.ui.views.columns.CurrencyColumn) ModificationListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.ModificationListener) SecurityTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransactionDialog) StockSplitWizard(name.abuchen.portfolio.ui.wizards.splits.StockSplitWizard) Composite(org.eclipse.swt.widgets.Composite) AbstractFinanceView(name.abuchen.portfolio.ui.AbstractFinanceView) KeyEvent(org.eclipse.swt.events.KeyEvent) Factory(name.abuchen.portfolio.online.Factory) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Separator(org.eclipse.jface.action.Separator) SecurityTransferDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransferDialog) MenuManager(org.eclipse.jface.action.MenuManager) Security(name.abuchen.portfolio.model.Security) Display(org.eclipse.swt.widgets.Display) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Collectors(java.util.stream.Collectors) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) Transfer(org.eclipse.swt.dnd.Transfer) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) OptionLabelProvider(name.abuchen.portfolio.ui.util.viewers.OptionLabelProvider) List(java.util.List) UpdateQuotesJob(name.abuchen.portfolio.ui.UpdateQuotesJob) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) Colors(name.abuchen.portfolio.ui.util.Colors) EditSecurityDialog(name.abuchen.portfolio.ui.wizards.security.EditSecurityDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) Watchlist(name.abuchen.portfolio.model.Watchlist) AccountTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransactionDialog) SecurityTransfer(name.abuchen.portfolio.ui.dnd.SecurityTransfer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed) BooleanEditingSupport(name.abuchen.portfolio.ui.util.viewers.BooleanEditingSupport) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Values(name.abuchen.portfolio.money.Values) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) BookmarkMenu(name.abuchen.portfolio.ui.util.BookmarkMenu) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) Function(java.util.function.Function) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn) Messages(name.abuchen.portfolio.ui.Messages) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) Taxonomy(name.abuchen.portfolio.model.Taxonomy) NumberColorLabelProvider(name.abuchen.portfolio.ui.util.viewers.NumberColorLabelProvider) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Shell(org.eclipse.swt.widgets.Shell) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) LatestSecurityPrice(name.abuchen.portfolio.model.LatestSecurityPrice) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction) Color(org.eclipse.swt.graphics.Color) IMenuManager(org.eclipse.jface.action.IMenuManager) Dialog(org.eclipse.jface.dialogs.Dialog) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) Menu(org.eclipse.swt.widgets.Menu) SecurityTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransactionDialog) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) SecurityTransferDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransferDialog) EditSecurityDialog(name.abuchen.portfolio.ui.wizards.security.EditSecurityDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) AccountTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransactionDialog) Dialog(org.eclipse.jface.dialogs.Dialog) StockSplitWizard(name.abuchen.portfolio.ui.wizards.splits.StockSplitWizard) Security(name.abuchen.portfolio.model.Security) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Separator(org.eclipse.jface.action.Separator) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction)

Example 13 with Dialog

use of org.eclipse.jface.dialogs.Dialog 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());
            }
        }
    });
}
Also used : SecurityPriceDialog(name.abuchen.portfolio.ui.dialogs.SecurityPriceDialog) Action(org.eclipse.jface.action.Action) CSVImportWizard(name.abuchen.portfolio.ui.wizards.datatransfer.CSVImportWizard) UpdateQuotesJob(name.abuchen.portfolio.ui.UpdateQuotesJob) IOException(java.io.IOException) EditSecurityDialog(name.abuchen.portfolio.ui.wizards.security.EditSecurityDialog) QuoteFromTransactionExtractor(name.abuchen.portfolio.util.QuoteFromTransactionExtractor) CSVExporter(name.abuchen.portfolio.datatransfer.csv.CSVExporter) ImportQuotesWizard(name.abuchen.portfolio.ui.wizards.datatransfer.ImportQuotesWizard) SecurityPriceDialog(name.abuchen.portfolio.ui.dialogs.SecurityPriceDialog) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) FileDialog(org.eclipse.swt.widgets.FileDialog) EditSecurityDialog(name.abuchen.portfolio.ui.wizards.security.EditSecurityDialog) Dialog(org.eclipse.jface.dialogs.Dialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Separator(org.eclipse.jface.action.Separator)

Example 14 with Dialog

use of org.eclipse.jface.dialogs.Dialog in project portfolio by buchen.

the class UpdateHelper method runUpdate.

public void runUpdate(IProgressMonitor monitor, boolean silent) throws OperationCanceledException, CoreException {
    SubMonitor sub = SubMonitor.convert(monitor, Messages.JobMsgCheckingForUpdates, 200);
    checkForLetsEncryptRootCertificate(silent);
    final NewVersion newVersion = checkForUpdates(sub.newChild(100));
    if (newVersion != null) {
        final boolean[] doUpdate = new boolean[1];
        Display.getDefault().syncExec(() -> {
            Dialog dialog = new UpdateMessageDialog(Display.getDefault().getActiveShell(), // 
            Messages.LabelUpdatesAvailable, // 
            MessageFormat.format(Messages.MsgConfirmInstall, newVersion.getVersion()), newVersion);
            doUpdate[0] = dialog.open() == 0;
        });
        if (doUpdate[0]) {
            runUpdateOperation(sub.newChild(100));
            promptForRestart();
        }
    } else {
        if (!silent) {
            Display.getDefault().asyncExec(() -> MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.LabelInfo, Messages.MsgNoUpdatesAvailable));
        }
    }
}
Also used : MessageDialog(org.eclipse.jface.dialogs.MessageDialog) Dialog(org.eclipse.jface.dialogs.Dialog) SubMonitor(org.eclipse.core.runtime.SubMonitor)

Example 15 with Dialog

use of org.eclipse.jface.dialogs.Dialog 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

Dialog (org.eclipse.jface.dialogs.Dialog)49 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)15 FileDialog (org.eclipse.swt.widgets.FileDialog)11 Composite (org.eclipse.swt.widgets.Composite)9 ArrayList (java.util.ArrayList)8 WizardDialog (org.eclipse.jface.wizard.WizardDialog)8 Control (org.eclipse.swt.widgets.Control)7 Shell (org.eclipse.swt.widgets.Shell)7 GridData (org.eclipse.swt.layout.GridData)6 Button (org.eclipse.swt.widgets.Button)6 ITextSelection (org.eclipse.jface.text.ITextSelection)5 GridLayout (org.eclipse.swt.layout.GridLayout)5 IStructuredCleanupProcessor (org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupProcessor)5 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)5 File (java.io.File)4 Client (name.abuchen.portfolio.model.Client)4 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)4 List (java.util.List)3 SWT (org.eclipse.swt.SWT)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3