List of usage examples for java.lang.reflect InvocationTargetException InvocationTargetException
public InvocationTargetException(Throwable target)
From source file:org.kalypso.model.wspm.ui.profil.wizard.createDivider.CreateDividerOperation.java
@Override public IStatus execute(final IProgressMonitor monitor) throws InvocationTargetException { try {// ww w. j a v a2 s .c o m createDevider(monitor); final FeatureChange[] changes = m_changes.toArray(new FeatureChange[m_changes.size()]); if (changes.length > 0) { final GMLWorkspace gmlworkspace = changes[0].getFeature().getWorkspace(); final ICommand command = new ChangeFeaturesCommand(gmlworkspace, changes); m_commandTarget.postCommand(command, null); } } catch (final Exception e) { throw new InvocationTargetException(e); } return Status.OK_STATUS; }
From source file:org.kalypso.model.wspm.ui.profil.wizard.intersectRoughness.IntersectRoughnessWizard.java
/** * @see org.eclipse.jface.wizard.Wizard#performFinish() *//* w w w . j a v a2s . c o m*/ @Override public boolean performFinish() { final Object[] choosen = m_profileChooserPage.getChoosen(); if (ArrayUtils.isEmpty(choosen)) return true; final IKalypsoFeatureTheme theme = m_theme; final ICoreRunnableWithProgress runnable = new ICoreRunnableWithProgress() { @Override public IStatus execute(final IProgressMonitor monitor) throws InvocationTargetException { monitor.beginTask(Messages.getString("org.kalypso.model.wspm.ui.wizard.IntersectRoughnessWizard.3"), //$NON-NLS-1$ 1 + choosen.length); try { monitor.worked(1); final IntersectRoughnessesLanduseDelegate delegate = new IntersectRoughnessesLanduseDelegate( m_roughnessIntersectPage, (IProfileFeature[]) choosen); final ApplyLanduseWorker worker = new ApplyLanduseWorker(delegate); RunnableContextHelper.execute(getContainer(), true, false, worker); final FeatureChange[] changes = worker.getChanges(); if (!ArrayUtils.isEmpty(changes)) { final GMLWorkspace gmlworkspace = changes[0].getFeature().getWorkspace(); final ICommand command = new ChangeFeaturesCommand(gmlworkspace, changes); theme.postCommand(command, null); } } catch (final Exception e) { throw new InvocationTargetException(e); } finally { monitor.done(); } return Status.OK_STATUS; } }; final IStatus status = RunnableContextHelper.execute(getContainer(), true, true, runnable); ErrorDialog.openError(getShell(), getWindowTitle(), Messages.getString("org.kalypso.model.wspm.ui.wizard.IntersectRoughnessWizard.5"), status); //$NON-NLS-1$ return status.isOK(); }
From source file:org.kalypso.model.wspm.ui.profil.wizard.landuse.runnables.ImportLanduseShapeRunnable.java
@Override public IStatus execute(final IProgressMonitor monitor) throws InvocationTargetException { try {//from w w w. j av a2 s . c o m FolderUtilities.mkdirs(m_landuseFolder); // copy shape file into landuse folder final String baseName = importShapeFile(monitor); writePropertyMappings(m_roughnessMapping, String.format("%s.roughness.properties", baseName), monitor); //$NON-NLS-1$ writePropertyMappings(m_vegetationMapping, String.format("%s.vegetation.properties", baseName), //$NON-NLS-1$ monitor); buildStyledLayerDescriptor(m_roughnessMapping, String.format("%s.roughness.sld", baseName), monitor); //$NON-NLS-1$ buildStyledLayerDescriptor(m_vegetationMapping, String.format("%s.vegetation.sld", baseName), monitor); //$NON-NLS-1$ return Status.OK_STATUS; } catch (final OperationCanceledException e) { return Status.CANCEL_STATUS; } catch (final Exception e) { e.printStackTrace(); throw new InvocationTargetException(e); } }
From source file:org.kalypso.ogc.sensor.view.actions.DumpStructureHandler.java
/** * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) *//* ww w . ja v a 2s . c o m*/ @Override public Object execute(final ExecutionEvent event) { final IEvaluationContext context = (IEvaluationContext) event.getApplicationContext(); final Shell shell = (Shell) context.getVariable(ISources.ACTIVE_SHELL_NAME); final IWorkbenchPart part = (IWorkbenchPart) context.getVariable(ISources.ACTIVE_PART_NAME); final ObservationChooser chooser = (ObservationChooser) part.getAdapter(ObservationChooser.class); final IRepository rep = chooser.isRepository(chooser.getSelection()); if (rep == null) return Status.OK_STATUS; final StringWriter writer = new StringWriter(); final IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(Messages.getString("org.kalypso.ogc.sensor.view.DumpStructureHandler.0"), 1000); //$NON-NLS-1$ try { rep.dumpStructure(writer, monitor); writer.close(); } catch (final IOException e) { throw new InvocationTargetException(e); } catch (final RepositoryException e) { throw new InvocationTargetException(e); } finally { IOUtils.closeQuietly(writer); monitor.done(); } } }; try { PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runnable); final Clipboard clipboard = new Clipboard(shell.getDisplay()); clipboard.setContents(new Object[] { writer.toString() }, new Transfer[] { TextTransfer.getInstance() }); clipboard.dispose(); } catch (final InvocationTargetException e) { e.printStackTrace(); MessageDialog.openWarning(shell, Messages.getString("org.kalypso.ogc.sensor.view.DumpStructureHandler.1"), //$NON-NLS-1$ e.getLocalizedMessage()); } catch (final InterruptedException ignored) { // empty } return Status.OK_STATUS; }
From source file:org.kalypso.ui.repository.RepositoryDumper.java
@Override public IStatus execute(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(Messages.getString("org.kalypso.ogc.sensor.view.DumpExtendedHandler.5"), //$NON-NLS-1$ IProgressMonitor.UNKNOWN); Writer structureWriter = null; try {/*from w ww . j a v a2s.co m*/ /* Create the structure file. */ final File structureFile = new File(m_directory, "structure.txt"); //$NON-NLS-1$ /* The writer to save the file. */ structureWriter = new OutputStreamWriter(new FileOutputStream(structureFile), "UTF-8"); //$NON-NLS-1$ /* Dump upwards */ final File baseDirectory = dumpUpwards(structureWriter); FileUtils.forceMkdir(baseDirectory); /* Do the dump into the filesystem. */ dumpExtendedRecursive(structureWriter, baseDirectory, m_root, monitor); structureWriter.close(); /* Update monitor. */ monitor.worked(800); /* Create the result status. */ final IStatus status = m_stati.asMultiStatusOrOK(Messages.getString("RepositoryDumper.0"), //$NON-NLS-1$ Messages.getString("RepositoryDumper.1")); //$NON-NLS-1$ /* Writes the log. */ writeLogQuietly(status); return status; } catch (final InterruptedException e) { throw e; } catch (final Exception e) { throw new InvocationTargetException(e); } finally { IOUtils.closeQuietly(structureWriter); monitor.done(); } }
From source file:org.kalypso.ui.wizards.imports.elevationmodel.ImportElevationWizard.java
@Override public boolean performFinish() { try {//from w w w.j a v a2 s . com final IPath sourcePath = m_mPage.getSourceLocation();// .toOSString(); final String setFileName = m_mPage.getNameForFile(); final String setFileDescription = m_mPage.getDescriptionForFileArea(); final String defaultText = ""; //$NON-NLS-1$ final String replaceText = Messages .getString("org.kalypso.ui.wizards.imports.elevationModel.Elevation.10"); //$NON-NLS-1$ final String selectedCoordinateSystem = m_mPage.getCoordinateSystem(); getContainer().run(true, true, new IRunnableWithProgress() { @Override public void run(final IProgressMonitor monitor) throws InvocationTargetException, IllegalArgumentException { try { SubMonitor progress = null; if (monitor != null) { progress = SubMonitor.convert(monitor, Messages.getString("ImportElevationWizard.0"), //$NON-NLS-1$ 100); } final ITerrainElevationModelSystem temSys = m_terrainModel.getTerrainElevationModelSystem(); final GMLWorkspace workspace = temSys.getWorkspace(); // Decoding the White Spaces present in the File Paths. final File modelFolderFile = getUTF_DecodedFile( new File(FileLocator.toFileURL(workspace.getContext()).getFile()).getParentFile()); final File temFolderFile = getUTF_DecodedFile( new File(FileLocator.toFileURL(m_tempFolder.getLocationURI().toURL()).getFile())); final File srcFileTif = getUTF_DecodedFile(sourcePath.toFile()); if (progress != null) { ProgressUtilities.worked(progress, 30); } File dstFileTif = null; if ((new File(temFolderFile, srcFileTif.getName())).exists()) { dstFileTif = new File(temFolderFile, getNewFileName(temFolderFile, srcFileTif)); } else { dstFileTif = new File(temFolderFile, srcFileTif.getName()); // mPage.getSourceLocation().lastSegment() } copy(srcFileTif, dstFileTif, monitor); m_modelFolder.getProject().refreshLocal(IResource.DEPTH_INFINITE, null/* new NullProgressMonitor() */); String nativeTEMRelPath = modelFolderFile.toURI() .relativize(new File(URLDecoder.decode(dstFileTif.toString(), "UTF-8")).toURI()) //$NON-NLS-1$ .toString(); if (nativeTEMRelPath == null) { nativeTEMRelPath = getUTF_DecodedFile(dstFileTif).toString(); } final INativeTerrainElevationModelWrapper tem = (INativeTerrainElevationModelWrapper) temSys .getTerrainElevationModels() .addNew(NativeTerrainElevationModelWrapper.SIM_BASE_F_NATIVE_TERRAIN_ELE_WRAPPER); tem.setSourceFile(nativeTEMRelPath); // TODO introduce in the first page a name imput field and gets the // name from there final String name = dstFileTif.getName(); if (setFileName.compareTo("") != 0) //$NON-NLS-1$ { tem.setName(setFileName); } else { tem.setName(name); } if (setFileDescription.compareTo(defaultText) != 0) { tem.setDescription(setFileDescription); } else { tem.setDescription(replaceText); } if (selectedCoordinateSystem.compareTo("") != 0) //$NON-NLS-1$ { tem.setCoordinateSystem(selectedCoordinateSystem); } final Feature temFeature = tem; workspace.fireModellEvent(new FeatureStructureChangeModellEvent(workspace, temSys, temFeature, FeatureStructureChangeModellEvent.STRUCTURE_CHANGE_ADD)); workspace.fireModellEvent( new FeatureStructureChangeModellEvent(workspace, temFeature.getOwner(), temFeature, FeatureStructureChangeModellEvent.STRUCTURE_CHANGE_ADD)); // TODO check why saving thow pool does not work final IScenarioDataProvider caseDataProvider = KalypsoAFGUIFrameworkPlugin .getDataProvider(); caseDataProvider.postCommand(ITerrainModel.class.getName(), new AddTerrainelevationModelCmd()); caseDataProvider.saveModel(ITerrainModel.class.getName(), null); if (progress != null) { ProgressUtilities.worked(progress, 100); progress.done(); } } catch (final Exception e) { e.printStackTrace(); throw new InvocationTargetException(e); } } }); } catch (final Throwable th) { th.printStackTrace(); return false; } return true; }
From source file:org.kalypso.ui.wizards.results.Import2DResultsOperation.java
private void importData(final File outputDir, final ICalcUnitResultMeta calcMeta, final IResultMeta[] resultsToRemove, final IProgressMonitor monitor) throws CoreException, InvocationTargetException { try {/*from w ww . j a v a 2s .c o m*/ final IContainer scenarioFolder = KalypsoAFGUIFrameworkPlugin.getActiveWorkContext().getCurrentCase() .getFolder(); final IFolder calcUnitFolder = scenarioFolder.getFolder(calcMeta.getFullPath()); removeOldResults(calcMeta, resultsToRemove); /* Move processed files to the right place */ final File calcUnitDir = calcUnitFolder.getLocation().toFile(); VFSUtilities.moveContents(outputDir, calcUnitDir); ProgressUtilities.worked(monitor, 90); calcUnitFolder.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 10)); } catch (final IOException e) { throw new InvocationTargetException(e); } }
From source file:org.kalypso.ui.wizards.results.Import2DResultsOperation.java
private FileSystemManager getFileSystemManager() throws InvocationTargetException { try {/*from w ww . j av a 2 s . com*/ return VFSUtilities.getManager(); } catch (final FileSystemException e) { throw new InvocationTargetException(e); } }
From source file:org.kalypso.ui.wizards.results.Import2DResultsOperation.java
private Date findStepDate(final FileObject inputFile) throws InvocationTargetException { try {/*from w w w . j a v a 2 s.c om*/ final String timeLine = ResultMeta1d2dHelper.findFirstSpecifiedLine2dFile(inputFile, "TI"); //$NON-NLS-1$ if (StringUtils.isBlank(timeLine)) return ResultManager.STEADY_DATE; // FIXME: does not work yet -> special case for bce-2d final Date stepDate = interpreteRMA2TimeLine(timeLine); if (stepDate == null) return ResultManager.STEADY_DATE; return stepDate; } catch (final IOException e) { // stop operation if we have an io exception throw new InvocationTargetException(e); } catch (final URISyntaxException e) { e.printStackTrace(); throw new InvocationTargetException(e); } }
From source file:org.mc4j.ems.impl.jmx.connection.bean.attribute.DAttribute.java
/** * Set the attribute on the server/*w w w .j av a2 s. co m*/ * * @param newValue The value to be set * @throws Exception */ public void setValue(Object newValue) throws Exception { try { MBeanServer server = bean.getConnectionProvider().getMBeanServer(); server.setAttribute(bean.getObjectName(), new Attribute(getName(), newValue)); alterValue(newValue); } catch (Exception e) { throw new InvocationTargetException(e); } refresh(); }