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;
}
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());
}
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());
}
}
});
}
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));
}
}
}
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());
}
}
Aggregations