List of usage examples for org.eclipse.jface.dialogs Dialog open
public int open()
From source file:net.refractions.udig.ui.ErrorManager.java
License:Open Source License
public void displayExceptions(final List<Throwable> exceptions, String message, final String pluginID) { final String m; if (message == null) m = ""; //$NON-NLS-1$ else//w w w . j a v a2s . co m m = message; final MultiStatus multi = new MultiStatus(pluginID, IStatus.OK, message, null); for (Throwable exception : exceptions) { Status status = new Status(IStatus.ERROR, pluginID, IStatus.ERROR, exception.getLocalizedMessage(), exception); multi.add(status); } PlatformGIS.syncInDisplayThread(new Runnable() { public void run() { Dialog dialog = new ErrorDialog(Display.getDefault().getActiveShell(), Messages.ErrorManager_very_informative_error, m, multi, IStatus.ERROR); dialog.open(); } }); }
From source file:net.refractions.udig.ui.ExceptionDisplayer.java
License:Open Source License
public static void displayExceptions(final List<Throwable> exceptions, final String message, final String pluginID) { final MultiStatus multi = new MultiStatus(pluginID, IStatus.OK, message, null); for (Throwable exception : exceptions) { Status status = new Status(IStatus.ERROR, pluginID, IStatus.ERROR, exception.getLocalizedMessage(), exception);/* w w w. j a va 2 s .c o m*/ multi.add(status); } PlatformGIS.syncInDisplayThread(new Runnable() { public void run() { Dialog dialog = new ErrorDialog(Display.getDefault().getActiveShell(), Messages.ExceptionDisplayer_very_informative_error, message, multi, IStatus.ERROR); dialog.open(); } }); }
From source file:net.refractions.udig.validation.IntegrityValidationOp.java
License:Open Source License
/** * //from w ww . j a va 2s . c o m * @see net.refractions.udig.ui.operations.IOp#op(org.eclipse.swt.widgets.Display, java.lang.Object, org.eclipse.core.runtime.IProgressMonitor) */ public void op(final Display display, Object target, IProgressMonitor monitor) throws Exception { // define the ILayer array final ILayer[] layer; if (target.getClass().isArray()) { layer = (ILayer[]) target; } else { layer = new ILayer[1]; layer[0] = (ILayer) target; } //construct the hashmap and run the validation ReferencedEnvelope envelope = layer[0].getMap().getViewportModel().getBounds(); FeatureSource<SimpleFeatureType, SimpleFeature> source; String nameSpace; String typeName; Map<String, FeatureSource<SimpleFeatureType, SimpleFeature>> map = new HashMap<String, FeatureSource<SimpleFeatureType, SimpleFeature>>(); for (int i = 0; i < layer.length; i++) { nameSpace = layer[i].getSchema().getName().getNamespaceURI(); typeName = layer[i].getSchema().getName().getLocalPart(); source = layer[i].getResource(FeatureSource.class, monitor); //map = dataStoreID:typeName map.put(nameSpace.toString() + ":" + typeName, source); //$NON-NLS-1$ } GenericValidationResults results = new GenericValidationResults(); genericResults = results; PlatformGIS.syncInDisplayThread(new Runnable() { public void run() { Dialog dialog = getDialog(display.getActiveShell(), layer[0].getSchema()); if (dialog != null) { dialog.open(); } } }); final IntegrityValidation integrityValidation = getValidator(layer); if (integrityValidation == null) return; integrityValidation.validate(map, envelope, results); OpUtils.setSelection(layer[0], results); OpUtils.notifyUser(display, results); monitor.internalWorked(1); monitor.done(); }
From source file:net.sf.eclipsensis.template.AbstractTemplateSettings.java
License:Open Source License
private void add() { T template = createTemplate(""); //$NON-NLS-1$ Dialog dialog = createDialog(template); if (dialog.open() != Window.CANCEL) { add(template);//from ww w. j av a 2 s .co m } }
From source file:net.sf.eclipsensis.template.AbstractTemplateSettings.java
License:Open Source License
@SuppressWarnings("unchecked") private void edit(T oldTemplate) { T newTemplate = (T) oldTemplate.clone(); Dialog dialog = createDialog(newTemplate); if (dialog.open() == Window.OK) { if (updateTemplate(oldTemplate, newTemplate)) { mTableViewer.refresh(true);//www.j a va 2 s .com doSelectionChanged(); mTableViewer.setChecked(newTemplate, newTemplate.isEnabled()); mTableViewer.setSelection(new StructuredSelection(newTemplate)); } } }
From source file:net.sf.jmoney.qif.wizards.QifBankDownloadImportWizard.java
License:Open Source License
public void importFile(File file) { try {/*ww w . j a v a 2 s. c o m*/ QifFile qifFile = new QifFile(file, QifDateFormat.DetermineFromFileAndSystem); if (!(account instanceof CurrencyAccount)) { // TODO: process error properly if (QIFPlugin.DEBUG) System.out.println("account is not a currency account"); throw new QifImportException("selected account is not a currency account"); } CurrencyAccount currencyAccount = (CurrencyAccount) account; /* * Create a transaction to be used to import the entries. This allows the entries to * be more efficiently written to the back-end datastore and it also groups * the entire import as a single change for undo/redo purposes. */ TransactionManager transactionManager = new TransactionManager(session.getDataManager()); Session sessionInTransaction = transactionManager.getSession(); CurrencyAccount accountInTransaction = transactionManager.getCopyInTransaction(currencyAccount); /* * Check that this QIF file is of a form that has entries only, no account information. This is the * form that is down-loaded from a banking site. */ if (!qifFile.accountList.isEmpty()) { throw new QifImportException( "QIF file contains information not typical of a bank download. It looks like the file was exported from an accounting program."); } if (!qifFile.invstTransactions.isEmpty()) { throw new QifImportException( "This QIF file has investement transactions. This is not supported for bank imports."); } /* * Import transactions that have no account information. */ if (!qifFile.transactions.isEmpty()) { // TODO: This should come from the account???? Currency currency = sessionInTransaction.getDefaultCurrency(); int transactionCount = 0; MatchingEntryFinder matchFinder = new MatchingEntryFinder() { @Override protected boolean alreadyMatched(Entry entry) { return entry.getPropertyValue(ReconciliationEntryInfo.getUniqueIdAccessor()) != null; } }; // ImportMatcher matcher = new ImportMatcher(accountInTransaction.getExtension(PatternMatcherAccountInfo.getPropertySet(), true)); Collection<EntryData> importedEntries = new ArrayList<EntryData>(); for (QifTransaction qifTransaction : qifFile.transactions) { if (!qifTransaction.getSplits().isEmpty()) { throw new RuntimeException( "QIF file contains information not typical of a bank download. It looks like the file was exported from an accounting program."); } if (qifTransaction.getCategory() != null) { throw new RuntimeException( "When transactions are listed in the QIF file with no account information (downloaded from bank), there must not be any category information."); } Date date = convertDate(qifTransaction.getDate()); long amount = adjustAmount(qifTransaction.getAmount(), currency); String uniqueId = Long.toString(date.getTime()) + '~' + amount; Entry match = matchFinder.findMatch(currencyAccount, amount, date, qifTransaction.getCheckNumber()); if (match != null) { Entry entryInTrans = transactionManager.getCopyInTransaction(match); entryInTrans.setValuta(date); entryInTrans.setCheck(qifTransaction.getCheckNumber()); entryInTrans.setPropertyValue(ReconciliationEntryInfo.getUniqueIdAccessor(), uniqueId); } else { EntryData entryData = new EntryData(); entryData.amount = amount; entryData.check = qifTransaction.getCheckNumber(); // entryData.valueDate = date; entryData.clearedDate = date; entryData.setMemo(qifTransaction.getMemo()); entryData.setPayee(qifTransaction.getPayee()); // Entry entry = matcher.process(entryData, sessionInTransaction); // entry.setPropertyValue(ReconciliationEntryInfo.getUniqueIdAccessor(), uniqueId); importedEntries.add(entryData); } /* do just the above. The following is obsolete. Then remove the duplicate autoMatch method. // Create a new transaction Transaction transaction = sessionInTransaction.createTransaction(); // Add the first entry for this transaction and set the account QIFEntry firstEntry = transaction.createEntry().getExtension(QIFEntryInfo.getPropertySet(), true); firstEntry.setAccount(accountInTransaction); transaction.setDate(date); firstEntry.setAmount(amount); firstEntry.setReconcilingState(qifTransaction.getStatus()); firstEntry.setCheck(qifTransaction.getCheckNumber()); firstEntry.setMemo(qifTransaction.getPayee()); // Add the second entry for this transaction Entry secondEntry = transaction.createEntry(); secondEntry.setAmount(-amount); firstEntry.setMemo(qifTransaction.getMemo()); String address = null; for (String line : qifTransaction.getAddressLines()) { if (address == null) { address = line; } else { address = address + '\n' + line; } } firstEntry.setAddress(address); if (secondEntry.getAccount() instanceof IncomeExpenseAccount) { // If this entry is for a multi-currency account, // set the currency to be the same as the currency for this // bank account. if (((IncomeExpenseAccount)secondEntry.getAccount()).isMultiCurrency()) { secondEntry.setIncomeExpenseCurrency(currency); } } */ transactionCount++; } PatternMatcherAccount matcherAccount = account .getExtension(PatternMatcherAccountInfo.getPropertySet(), true); Dialog dialog = new PatternMatchingDialog(window.getShell(), matcherAccount, importedEntries); if (dialog.open() == Dialog.OK) { ImportMatcher matcher = new ImportMatcher( accountInTransaction.getExtension(PatternMatcherAccountInfo.getPropertySet(), true)); for (net.sf.jmoney.importer.matcher.EntryData entryData : importedEntries) { Entry entry = matcher.process(entryData, sessionInTransaction); // entry.setPropertyValue(ReconciliationEntryInfo.getUniqueIdAccessor(), uniqueId); } } else { return; } /* * All entries have been imported and all the properties * have been set and should be in a valid state, so we * can now commit the imported entries to the datastore. */ String transactionDescription = String.format("Import {0}", file.getName()); transactionManager.commit(transactionDescription); if (transactionCount != 0) { StringBuffer combined = new StringBuffer(); combined.append(file.getName()); combined.append(" was successfully imported. "); combined.append(transactionCount).append(" transactions were imported."); MessageDialog.openInformation(window.getShell(), "QIF file imported", combined.toString()); } else { throw new QifImportException("No transactions were found within the given date range."); } } } catch (IOException e) { MessageDialog.openError(window.getShell(), "Unable to read QIF file", e.getLocalizedMessage()); } catch (InvalidQifFileException e) { MessageDialog.openError(window.getShell(), "Unable to import QIF file", e.getLocalizedMessage()); } catch (QifImportException e) { MessageDialog.openError(window.getShell(), "Unable to import QIF file", e.getLocalizedMessage()); } catch (AmbiguousDateException e) { MessageDialog.openError(window.getShell(), "QIF file has an ambiguous date format that cannot be guessed from your locale.", e.getLocalizedMessage()); } }
From source file:org.absmodels.abs.plugin.debug.perspective.DebugActionDelegate.java
License:Open Source License
@Override public void run(IAction action) { if (action == saveHistory) { FileDialog historyDialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE); String pathString = historyDialog.open(); if (pathString != null) { File path = new File(pathString); DebugUtils.getSchedulerRef().saveHistory(path); }/*from w ww.jav a 2s . c o m*/ } else if (action == executeSingleStep) { DebugUtils.getSchedulerRef().doSingleStep(); } else if (action == executeNSteps) { Dialog stepDialog = new StepNumberDialog(Display.getCurrent().getActiveShell()); stepDialog.open(); } else if (action == stepOver) { DebugUtils.getSchedulerRef().doStepOver(); } else if (action == runToLine) { Dialog lineDialog = new LineNumberDialog(Display.getCurrent().getActiveShell()); lineDialog.open(); } else if (action == resume) { DebugUtils.getSchedulerRef().resumeAutomaticScheduling(); } else if (action == terminate) { DebugUtils.getDebugger().shutdown(); } }
From source file:org.amanzi.awe.nem.ui.contributions.AbstractNetworkMenuContribution.java
License:Open Source License
/** * @param model//from w ww. j a v a 2 s .c o m * @param newType */ protected void openWizard(final INetworkModel model, final IDataElement root, final INodeType newType) { final IWizard wizard = getWizard(model, root, newType); final Dialog wizardDialog = createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), wizard); wizardDialog.create(); wizardDialog.open(); }
From source file:org.amanzi.awe.nem.ui.handlers.CreateNetworkHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { NetworkCreationWizard wizard = new NetworkCreationWizard(); Dialog wizardDialog = createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), wizard); wizardDialog.create();// w w w. ja v a 2 s . c om wizardDialog.open(); return null; }
From source file:org.amanzi.neo.loader.ui.handler.LoaderWizardHandler.java
License:Open Source License
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { String wizardId = event.getParameter(LOADER_WIZARD_ID); if (wizardId != null) { ILoaderWizard<?> wizard = loaderContext.getLoaderWizard(wizardId); if (wizard != null) { IWorkbenchWindow window = getWorkbenchWindow(event); IWorkbench workbench = window.getWorkbench(); wizard.init(workbench, null); Dialog wizardDialog = createDialog(window.getShell(), wizard); wizardDialog.create();/*w ww .ja v a2 s . co m*/ wizardDialog.open(); } else { throw new ExecutionException( Messages.formatString(Messages.LoaderWizardHandler_NoWizardByIdError, wizardId)); } } else { throw new ExecutionException(Messages.LoaderWizardHandler_NoWizardIdError); } return null; }