Package de.innovationgate.eclipse.editors.all

Source Code of de.innovationgate.eclipse.editors.all.InvalidMediaKeyMarkingHandler

/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.editors.all;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.MarkerUtilities;

import de.innovationgate.eclipse.editors.helpers.MarkingHandler;
import de.innovationgate.eclipse.utils.ui.model.WGADesignConfigurationModelWrapper;
import de.innovationgate.eclipse.utils.wga.WGADesignStructureHelper;
import de.innovationgate.wga.common.beans.csconfig.v1.MediaKey;
import de.innovationgate.wga.model.VersionCompliance;

public class InvalidMediaKeyMarkingHandler implements MarkingHandler {

  public static final String MARKER_ID = "de.innovationgate.eclipse.ids.markers.InvalidMediaKey";
  private VersionCompliance _compliance;

  public void createMarkers(IResource resource) throws CoreException {
    resource.deleteMarkers(MARKER_ID, true, IResource.DEPTH_ZERO);

    if (_compliance.toWGAVersion().isAtLeast(5, 0)){
      IContainer container = (IContainer) resource;
      if(!container.getName().startsWith(".")){
        if (WGADesignStructureHelper.isMediaKeyContainer(container)) {
          IFile syncInfo = WGADesignStructureHelper.determineSyncInfo(container);       
          WGADesignConfigurationModelWrapper conf;
          try {
            conf = new WGADesignConfigurationModelWrapper(syncInfo);
            List<String> mediaKeyStrings = new ArrayList<String>();
            mediaKeyStrings.addAll(WGADesignStructureHelper.DEFAULT_MEDIA_KEYS);
            for (MediaKey current : conf.getMediaKeys()) {
              mediaKeyStrings.add(current.getKey());
            }
            if (!mediaKeyStrings.contains(container.getName())) {
              Map<String, Object> map = new HashMap<String, Object>();
              MarkerUtilities.setMessage(map, "Missing mediakey '" + container.getName() + "' in design configuration.");
              map.put(IMarker.LOCATION, resource.getFullPath().toString());
              map.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
              MarkerUtilities.createMarker(resource, map, MARKER_ID);
            }
          } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }       
        }
      }
    }
  }

  public void createMarkers(IFile file, IDocument document) throws CoreException {
  }

  public void setDocumentProvider(IDocumentProvider provider) {
  }

  public void setWGAVersionCompliance(VersionCompliance versionCompliance) {
    _compliance = versionCompliance;

  }
}
TOP

Related Classes of de.innovationgate.eclipse.editors.all.InvalidMediaKeyMarkingHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.