コード例 #1
0
  @Override
  public IStatus execute(final IProgressMonitor monitor)
      throws CoreException, InvocationTargetException {
    final SubMonitor progress =
        SubMonitor.convert(
            monitor,
            Messages.getString("org.kalypso.model.flood.ui.map.operations.ImportTinOperation.0"),
            100); //$NON-NLS-1$

    /* Add sources as new tin references */
    progress.subTask(
        Messages.getString(
            "org.kalypso.model.flood.ui.map.operations.ImportTinOperation.1")); //$NON-NLS-1$
    m_tinRefs = new ITinReference[m_sources.length];
    final Feature[] changedFeatures = new Feature[m_sources.length];

    for (int i = 0; i < m_sources.length; i++) {
      final IGmlSource source = m_sources[i];

      final ITinReference tinRef = m_tins.addNew(-1, ITinReference.QNAME, ITinReference.class);
      tinRef.setName(source.getName());
      tinRef.setDescription(source.getDescription());
      tinRef.setSourceLocation(source.getLocation());
      tinRef.setSourceFeaturePath(source.getPath());
      tinRef.setSourceType(typeForSource(source));

      m_tinRefs[i] = tinRef;
      changedFeatures[i] = tinRef;
    }
    ProgressUtilities.worked(progress, 20);

    /* post command for events stuff... */
    final Feature parentFeature = m_tins.getParentFeature();
    final GMLWorkspace workspace = parentFeature.getWorkspace();
    final ModellEvent modelEvent =
        new FeatureStructureChangeModellEvent(
            workspace,
            parentFeature,
            changedFeatures,
            FeatureStructureChangeModellEvent.STRUCTURE_CHANGE_ADD);
    workspace.fireModellEvent(modelEvent);
    /* Save data model */
    // progress.subTask( "speichere Datenmodell" );
    // m_provider.saveModel( IFloodModel.class, progress.newChild( 20 ) );
    /* update tins */
    progress.subTask(
        Messages.getString(
            "org.kalypso.model.flood.ui.map.operations.ImportTinOperation.2")); //$NON-NLS-1$
    final UpdateTinsOperation updateOp = new UpdateTinsOperation(m_tinRefs, m_provider);
    updateOp.execute(progress.newChild(60));

    /* Jump to imported tins */
    final GM_Envelope envelope = FeatureHelper.getEnvelope(changedFeatures);
    final GM_Envelope scaledBox =
        envelope == null ? null : GeometryUtilities.scaleEnvelope(envelope, 1.05);
    if (m_mapPanel != null && scaledBox != null) m_mapPanel.setBoundingBox(scaledBox);

    return Status.OK_STATUS;
  }
コード例 #2
0
 @Override
 public boolean handleResult(final Shell shell, final IStatus resultStatus) {
   if (!resultStatus.isOK()) KalypsoCorePlugin.getDefault().getLog().log(resultStatus);
   ErrorDialog.openError(
       shell,
       Messages.getString("org.kalypso.model.flood.ui.map.operations.ImportTinOperation.6"),
       Messages.getString("org.kalypso.model.flood.ui.map.operations.ImportTinOperation.7"),
       resultStatus); //$NON-NLS-1$ //$NON-NLS-2$
   return resultStatus.isOK();
 }
コード例 #3
0
  @Override
  public IStatus execute(final IProgressMonitor monitor)
      throws CoreException, InvocationTargetException {
    monitor.beginTask(
        Messages.getString("RemoveEventOperation_0"), m_treeSelection.length + 10); // $NON-NLS-1$

    final Collection<IStatus> removeResults = new ArrayList<>();
    try {
      for (final Object element : m_treeSelection) {
        final Feature featureToRemove = (Feature) element;
        monitor.subTask(
            String.format(
                String.format(
                    Messages.getString("RemoveEventOperation_1"),
                    featureToRemove.getName()))); // $NON-NLS-1$

        final IStatus removeResult =
            removeEvent(
                featureToRemove,
                new SubProgressMonitor(
                    monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
        if (!removeResult.isOK()) removeResults.add(removeResult);
      }

      /* Save model, as undo is not possible here and the user should not be able to revert the changes */
      monitor.subTask(Messages.getString("RemoveEventOperation_2")); // $NON-NLS-1$
      m_provider.saveModel(IFloodModel.class.getName(), new SubProgressMonitor(monitor, 10));
    } catch (final Exception e) {
      if (e instanceof CoreException) throw (CoreException) e;

      throw new InvocationTargetException(e);
    }

    if (removeResults.size() == 0) return Status.OK_STATUS;

    final IStatus[] children = removeResults.toArray(new IStatus[removeResults.size()]);
    return new MultiStatus(
        KalypsoModelFloodPlugin.PLUGIN_ID,
        0,
        children,
        Messages.getString("RemoveEventOperation_3"),
        null); //$NON-NLS-1$
  }
コード例 #4
0
  private IStatus removeEvent(final Feature featureToRemove, final IProgressMonitor monitor)
      throws CoreException, Exception {
    final String msg =
        String.format(
            Messages.getString("RemoveEventOperation_4"), featureToRemove.getName()); // $NON-NLS-1$
    monitor.beginTask(msg, 100);

    final IRunoffEvent runoffEvent = (IRunoffEvent) featureToRemove.getAdapter(IRunoffEvent.class);
    IStatus removeResult = null;
    if (runoffEvent != null) {
      monitor.subTask(Messages.getString("RemoveEventOperation_5")); // $NON-NLS-1$
      deleteThemes(m_wspThemes, runoffEvent);
      monitor.worked(10);

      /* Delete underlying tin files */
      monitor.subTask(Messages.getString("RemoveEventOperation_6")); // $NON-NLS-1$
      final ICoverageCollection resultCoverages = runoffEvent.getResultCoverages();
      removeResult = FloodModelHelper.removeResultCoverages(m_provider, resultCoverages);
      monitor.worked(60);

      /* Delete event folder */
      monitor.subTask(Messages.getString("RemoveEventOperation_7")); // $NON-NLS-1$
      final IFolder eventFolder = EventManagementWidget.getEventFolder(runoffEvent);
      eventFolder.delete(true, new SubProgressMonitor(monitor, 20));
    }

    /* Delete coverage from collection */
    monitor.subTask(Messages.getString("RemoveEventOperation_8")); // $NON-NLS-1$
    final CommandableWorkspace workspace =
        m_provider.getCommandableWorkSpace(IFloodModel.class.getName());
    final DeleteFeatureCommand command = new DeleteFeatureCommand(featureToRemove);
    workspace.postCommand(command);
    monitor.worked(10);

    // TODO: Probably we need a more sophisticated error handling here
    if (removeResult != null) return removeResult;
    return Status.OK_STATUS;
  }