Package com.onpositive.mapper.actions

Source Code of com.onpositive.mapper.actions.TilesetAction

package com.onpositive.mapper.actions;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.part.IPage;

import tiled.core.Map;

import com.onpositive.mapper.views.TilesetPage;
import com.onpositive.mapper.views.TilesetView;

public abstract class TilesetAction extends Action  implements IViewActionDelegate{

  protected TilesetView tilesetView;

  public TilesetAction() {
    super();
  }

  public TilesetAction(String text) {
    super(text);
  }

  public TilesetAction(String text, ImageDescriptor image) {
    super(text, image);
  }

  public TilesetAction(String text, int style) {
    super(text, style);
  }

  @Override
  public void init(IViewPart view) {
    if (view instanceof TilesetView) {
      tilesetView = (TilesetView) view;
    }
  }
 
  @Override
  public void run(IAction action) {
    IPage currentPage = tilesetView.getCurrentPage();
    if (currentPage instanceof TilesetPage) {
      runForMap(action,((TilesetPage) currentPage).getMapEditor().getMap());
    }
  }

  protected abstract void runForMap(IAction action, Map map);

}
TOP

Related Classes of com.onpositive.mapper.actions.TilesetAction

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.