code: /*--------------------------------------------------------------*
    Copyright (C) 2006-2020 OpenSim Ltd.
  
    This file is distributed WITHOUT ANY WARRANTY. See the file
    'License' for details on this and other legal matters.
  *--------------------------------------------------------------*/
  
  package org.omnetpp.scave.actions;
  
  import org.eclipse.core.runtime.CoreException;
  import org.eclipse.jface.viewers.ISelection;
  import org.omnetpp.scave.ScaveImages;
  import org.omnetpp.scave.ScavePlugin;
  import org.omnetpp.scave.editors.ScaveEditor;
  
  /**
   * Refreshes the charts of the active chart page or
   * chart sheet page of the active Scave editor.
   *
   * @author tomi
   */
  public class RefreshChartAction extends AbstractScaveAction {
  
      public RefreshChartAction() {
          setText("Rerun Chart Script");
          setDescription("Refresh the content of the current chart");
          setImageDescriptor(ScavePlugin.getImageDescriptor(ScaveImages.IMG_ETOOL16_REFRESH));
      }
  
      @Override
      protected void doRun(ScaveEditor scaveEditor, ISelection selection) throws CoreException {
          scaveEditor.getActiveChartScriptEditor().refreshChart();
      }
  
      @Override
      protected boolean isApplicable(ScaveEditor editor, ISelection selection) {
          return editor.getActiveChartScriptEditor() != null;
      }
  }
  