Package de.innovationgate.eclipse.editors.helpers

Source Code of de.innovationgate.eclipse.editors.helpers.MediaKeyResolution

/*******************************************************************************
* 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.helpers;

import java.io.IOException;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IMarker;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.PartInitException;

import de.innovationgate.eclipse.editors.Plugin;
import de.innovationgate.eclipse.editors.ResourceIDs;
import de.innovationgate.eclipse.editors.design.WGADesignEditor;
import de.innovationgate.eclipse.utils.WorkbenchUtils;
import de.innovationgate.eclipse.utils.ui.model.WGADesignConfigurationModelWrapper;
import de.innovationgate.eclipse.utils.wga.WGADesignStructureHelper;

public class MediaKeyResolution implements IMarkerResolution {
 
  private IMarker _marker;
  private IFolder _mediaKeyFolder;
  private IFile _syncInfo;
 
  public MediaKeyResolution (IMarker marker){
    _marker = marker;
    if(marker.getResource() instanceof IFolder){
      _mediaKeyFolder = (IFolder)_marker.getResource();
    }
   
  }
 
  public String getLabel() {
   
   
    if(_mediaKeyFolder != null && !_mediaKeyFolder.getName().equals("")){ 
      _syncInfo = WGADesignStructureHelper.determineSyncInfo(_mediaKeyFolder)
      try {
        WGADesignConfigurationModelWrapper designConfig = new WGADesignConfigurationModelWrapper(_syncInfo);
        return "Open designeditor to register mediakey '"+_mediaKeyFolder.getName()+"' in design '"+designConfig.getDesignKey()+"'.";
      } catch (IOException e) {
        Plugin.getDefault().logError("Can not find syncinfo for resource " + _mediaKeyFolder, e);
      }
      return null;     
    } else {
      Plugin.getDefault().logError("Can not get mediakey for marker " + _marker.getAttribute(IMarker.LOCATION, _marker.toString()));
      return null;
    }   
  }

  public void run(IMarker marker) {
    if(_syncInfo != null){
      IEditorPart editor;
      try {
        editor = WorkbenchUtils.openEditor(Plugin.getDefault().getWorkbench(), _syncInfo, WGADesignEditor.ID);
        if (editor instanceof WGADesignEditor) {
          ((WGADesignEditor) editor).setActivePage(ResourceIDs.EDITORPAGE_WGA_DESIGN_MAPPINGS);
        }
      } catch (PartInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

    }
  }

}
TOP

Related Classes of de.innovationgate.eclipse.editors.helpers.MediaKeyResolution

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.