Esempio n. 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;
  }
Esempio n. 2
0
  private SOURCETYPE typeForSource(final IGmlSource source) {
    final String file = source.getLocation().getPath().toLowerCase();
    if (file.endsWith(".hmo")) // $NON-NLS-1$
    return SOURCETYPE.hmo;

    if (file.endsWith(".gml")) // $NON-NLS-1$
    return SOURCETYPE.gml;

    if (file.endsWith(".shp")) // $NON-NLS-1$
    return SOURCETYPE.shape;

    // In doubt, probably its an gml
    return SOURCETYPE.gml;
  }