org.eclipse.linuxtools.dataviewers.charts_4.1.0.201310101546

16:46:05.031 INFO  jd.cli.Main - Decompiling org.eclipse.linuxtools.dataviewers.charts_4.1.0.201310101546.jar
package org.eclipse.linuxtools.dataviewers.charts;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class Activator
  extends AbstractUIPlugin
{
  public static final String PLUGIN_ID = "org.eclipse.linuxtools.dataviewers.charts";
  private static Activator plugin;
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    plugin = this;
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    plugin = null;
    super.stop(context);
  }
  
  public static Activator getDefault()
  {
    return plugin;
  }
  
  public static ImageDescriptor getImageDescriptor(String path)
  {
    return imageDescriptorFromPlugin("org.eclipse.linuxtools.dataviewers.charts", path);
  }
  
  public static Image getImage(String path)
  {
    Image image = plugin.getImageRegistry().get(path);
    if (image == null)
    {
      image = getImageDescriptor(path).createImage();
      plugin.getImageRegistry().put(path, image);
    }
    return image;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.charts.Activator
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.charts;

public class ChartConstants
{
  public static final String TAG_SECTION_BIRTCHARTS_STATE = "birtcharts_section";
  public static final String TAG_COLUMN_BUTTON_ = "COLUMN_BUTTON_";
  public static final String TAG_BAR_GRAPH_BUTTON = "BAR_GRAPH_BUTTON";
  public static final String TAG_VERTICAL_BARS_BUTTON = "VERTICAL_BARS_BUTTON";
  public static final boolean DEFAULT_COLUMN_BUTTON = true;
  public static final boolean DEFAULT_BAR_GRAPH_BUTTON = true;
  public static final boolean DEFAULT_VERTICAL_BARS_BUTTON = false;
  public static final String TAG_SECTION_BIRTCHARTS_SAVEACTION_STATE = "birtcharts_saveasimg_section";
  public static final String TAG_IMG_FILE_NAME = "IMG_FILE_NAME";
  public static final String TAG_IMG_FILTER_PATH = "IMG_FILTER_PATH";
  public static final String DEFAULT_IMG_FILE_NAME = ".";
  public static final String DEFAULT_IMG_FILTER_PATH = ".";
  public static final String EXT_JPG = ".jpg";
  public static final String EXT_JPEG = ".jpeg";
  public static final String EXT_PNG = ".png";
  public static final String EXT_GIF = ".gif";
  public static final String EXT_SVG = ".svg";
  public static final String[] saveAsImageExt = {
    "*.jpg", 
    "*.jpeg", 
    "*.png", 
    "*.gif", 
    "*.*" };
  public static String[] saveAsImageExtNames = {
    "JPEG (*.jpg)", 
    "JPEG (*.jpeg)", 
    "PNG (*.png)", 
    "GIF (*.gif)", 
    "All Files (*.*)" };
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.charts.ChartConstants
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.charts;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.osgi.framework.Bundle;

public final class UIHelper
{
  public static URL getURL(String sPluginRelativePath)
  {
    URL url = null;
    if (Platform.getExtensionRegistry() != null) {
      try
      {
        url = new URL(Activator.getDefault()
          .getBundle()
          .getEntry("/"), sPluginRelativePath);
      }
      catch (MalformedURLException e)
      {
        e.printStackTrace();
      }
    } else {
      try
      {
        url = new URL("file:///" + new File(sPluginRelativePath).getAbsolutePath());
      }
      catch (MalformedURLException e)
      {
        e.printStackTrace();
      }
    }
    return url;
  }
  
  private static Image createImage(String sPluginRelativePath)
  {
    Image img = null;
    try
    {
      try
      {
        img = new Image(Display.getCurrent(), 
          getURL(sPluginRelativePath).openStream());
      }
      catch (MalformedURLException localMalformedURLException)
      {
        img = new Image(Display.getCurrent(), 
          new FileInputStream(getURL(sPluginRelativePath).toString()));
      }
      if (img != null) {
        return img;
      }
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
    img = new Image(Display.getCurrent(), 1, 1);
    
    return img;
  }
  
  public static Image getImage(String sPluginRelativePath)
  {
    ImageRegistry registry = JFaceResources.getImageRegistry();
    Image image = registry.get(sPluginRelativePath);
    if (image == null)
    {
      image = createImage(sPluginRelativePath);
      registry.put(sPluginRelativePath, image);
    }
    return image;
  }
  
  public static ImageDescriptor getImageDescriptor(String sPluginRelativePath)
  {
    ImageRegistry registry = JFaceResources.getImageRegistry();
    ImageDescriptor image = registry.getDescriptor(sPluginRelativePath);
    if (image == null)
    {
      registry.put(sPluginRelativePath, 
        createImage(sPluginRelativePath));
      image = registry.getDescriptor(sPluginRelativePath);
    }
    return image;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.charts.UIHelper
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.charts.actions;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;

class ChartAction$1
  implements ISelectionChangedListener
{
  ChartAction$1(ChartAction paramChartAction) {}
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    this$0.setEnabled(!event.getSelection().isEmpty());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.charts.actions.ChartAction.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.charts.actions;

import org.eclipse.birt.chart.model.Chart;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
import org.eclipse.linuxtools.dataviewers.charts.Activator;
import org.eclipse.linuxtools.dataviewers.charts.dialogs.ChartDialog;
import org.eclipse.linuxtools.dataviewers.charts.view.ChartView;
import org.eclipse.swt.widgets.Shell;

public class ChartAction
  extends Action
{
  private ChartDialog dialog;
  
  public ChartAction(Shell shell, AbstractSTViewer viewer)
  {
    super("Create chart...", Activator.getImageDescriptor("icons/chart_icon.png"));
    dialog = createDialog(shell, viewer);
    setEnabled(!viewer.getViewer().getSelection().isEmpty());
    viewer.getViewer().addSelectionChangedListener(new ISelectionChangedListener()
    {
      public void selectionChanged(SelectionChangedEvent event)
      {
        setEnabled(!event.getSelection().isEmpty());
      }
    });
  }
  
  public void run()
  {
    dialog.open();
    Chart chart = dialog.getValue();
    if (chart != null) {
      ChartView.createChartView(chart);
    }
  }
  
  protected ChartDialog createDialog(Shell shell, AbstractSTViewer viewer)
  {
    return new ChartDialog(shell, viewer);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.charts.actions.ChartAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.charts.actions;

import com.ibm.icu.util.ULocale;
import org.eclipse.birt.chart.computation.DataPointHints;
import org.eclipse.birt.chart.event.StructureSource;
import org.eclipse.birt.chart.event.StructureType;
import org.eclipse.birt.chart.model.attribute.ActionType;
import org.eclipse.birt.chart.model.attribute.JavaNumberFormatSpecifier;
import org.eclipse.birt.chart.model.attribute.TooltipValue;
import org.eclipse.birt.chart.model.attribute.impl.JavaNumberFormatSpecifierImpl;
import org.eclipse.birt.chart.model.data.Action;
import org.eclipse.birt.chart.render.ActionRendererAdapter;

public class ChartActionRenderer
  extends ActionRendererAdapter
{
  public void processAction(Action action, StructureSource source)
  {
    if (ActionType.SHOW_TOOLTIP_LITERAL.equals(action.getType()))
    {
      TooltipValue tv = (TooltipValue)action.getValue();
      if (StructureType.SERIES_DATA_POINT.equals(source.getType()))
      {
        DataPointHints dph = (DataPointHints)source.getSource();
        String MyToolTip = "Value is " + 
          JavaNumberFormatSpecifierImpl.create("0.00").format(
          ((Double)dph.getOrthogonalValue()).doubleValue(), ULocale.getDefault());
        tv.setText(MyToolTip);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.charts.actions.ChartActionRenderer
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.charts.actions;

import java.io.File;
import java.io.FileInputStream;
import org.eclipse.birt.chart.model.Chart;
import org.eclipse.birt.chart.model.Serializer;
import org.eclipse.birt.chart.model.impl.SerializerImpl;
import org.eclipse.birt.core.ui.frameworks.taskwizard.WizardBase;
import org.eclipse.jface.action.Action;
import org.eclipse.linuxtools.dataviewers.charts.UIHelper;
import org.eclipse.linuxtools.dataviewers.charts.view.ChartView;
import org.eclipse.linuxtools.dataviewers.charts.viewer.ChartViewer;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;

public class OpenChartAction
  extends Action
{
  private Chart chart = null;
  private FileDialog dialog;
  private ChartView chartView;
  
  public OpenChartAction(Shell shell, ChartView cView)
  {
    setImageDescriptor(UIHelper.getImageDescriptor("icons/eimport.gif"));
    setDisabledImageDescriptor(UIHelper.getImageDescriptor("icons/dimport.gif"));
    setToolTipText("Open XML Source");
    setEnabled(true);
    chartView = cView;
    dialog = new FileDialog(shell, 4096);
    dialog.setText("Select a chart file ");
    dialog.setFilterExtensions(new String[] { "*.chart" });
  }
  
  public void run()
  {
    String path = dialog.open();
    if (path == null) {
      return;
    }
    Serializer serializer = null;
    File chartFile = new File(path);
    try
    {
      serializer = SerializerImpl.instance();
      if (chartFile.exists())
      {
        chart = serializer.read(new FileInputStream(chartFile));
        chartView.getChartViewer().setBuffer(null);
        chartView.setChart(chart);
      }
    }
    catch (Exception e)
    {
      WizardBase.displayException(e);
    }
  }
  
  public Chart getChart()
  {
    return chart;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.charts.actions.OpenChartAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.charts.actions;

import java.io.File;
import java.io.IOException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;

class SaveChartAction$1
  extends Job
{
  SaveChartAction$1(SaveChartAction paramSaveChartAction, String $anonymous0, File paramFile)
  {
    super($anonymous0);
  }
  
  protected IStatus run(IProgressMonitor monitor)
  {
    try
    {
      monitor.beginTask("Saving chart as " + val$file.getName() + "...", -1);
      val$file.createNewFile();
      this$0.generateImageFile(val$file);
      return Status.OK_STATUS;
    }
    catch (IOException e)
    {
      return new Status(
        4, 
        "org.eclipse.linuxtools.dataviewers.charts", 
        "Error saving chart to \"" + 
        val$file.getAbsolutePath() + 
        "\":" + 
        e.getMessage(), 
        e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.charts.actions.SaveChartAction.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.charts.actions;

import com.ibm.icu.util.ULocale;
import java.io.File;
import java.io.IOException;
import org.eclipse.birt.chart.device.IDeviceRenderer;
import org.eclipse.birt.chart.exception.ChartException;
import org.eclipse.birt.chart.factory.GeneratedChartState;
import org.eclipse.birt.chart.factory.Generator;
import org.eclipse.birt.chart.factory.RunTimeContext;
import org.eclipse.birt.chart.model.Chart;
import org.eclipse.birt.chart.model.attribute.Bounds;
import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl;
import org.eclipse.birt.chart.util.PluginSettings;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.linuxtools.dataviewers.charts.Activator;
import org.eclipse.linuxtools.dataviewers.charts.ChartConstants;
import org.eclipse.linuxtools.dataviewers.charts.view.ChartView;
import org.eclipse.linuxtools.dataviewers.charts.viewer.ChartViewer;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;

public class SaveChartAction
  extends Action
{
  private FileDialog dialog;
  private Shell shell;
  private Chart cm;
  private IDeviceRenderer idr;
  private Bounds bo;
  private ChartView chartView;
  
  public SaveChartAction(Shell shell, ChartView cview)
  {
    super("Save chart as...", Activator.getImageDescriptor("icons/save_chart.gif"));
    chartView = cview;
    setEnabled(false);
    this.shell = shell;
    dialog = new FileDialog(shell, 8192);
    dialog.setFileName(".");
    dialog.setFilterPath(".");
    dialog.setFilterExtensions(ChartConstants.saveAsImageExt);
    dialog.setFilterNames(ChartConstants.saveAsImageExtNames);
    dialog.setText("Select an image file (extension will be set to \".jpeg\" if not recognized).");
    
    restoreState();
  }
  
  public void setChart(Chart chart)
  {
    try
    {
      if (chart != null) {
        setEnabled(true);
      } else {
        setEnabled(false);
      }
      cm = chart;
    }
    catch (Throwable _)
    {
      Status s = new Status(
        4, 
        "org.eclipse.linuxtools.dataviewers.charts", 
        4, 
        "Error when creating \"save as image\" action...", 
        _);
      Activator.getDefault().getLog().log(s);
    }
  }
  
  public void setBounds(Bounds bo)
  {
    this.bo = bo;
  }
  
  public void run()
  {
    String path = dialog.open();
    if (path == null) {
      return;
    }
    String ext = "";
    
    int dotIdx = path.lastIndexOf(".");
    if (dotIdx > 0) {
      ext = path.substring(dotIdx);
    }
    try
    {
      if (ext.equals(".gif"))
      {
        idr = PluginSettings.instance().getDevice("dv.GIF");
      }
      else if (ext.equals(".jpeg"))
      {
        idr = PluginSettings.instance().getDevice("dv.JPEG");
      }
      else if (ext.equals(".jpg"))
      {
        idr = PluginSettings.instance().getDevice("dv.JPG");
      }
      else if (ext.equals(".png"))
      {
        idr = PluginSettings.instance().getDevice("dv.PNG");
      }
      else
      {
        path = path + ".jpeg";
        idr = PluginSettings.instance().getDevice("dv.JPG");
      }
    }
    catch (ChartException e)
    {
      Status s = new Status(
        4, 
        "org.eclipse.linuxtools.dataviewers.charts", 
        4, 
        e.getMessage(), 
        e);
      Activator.getDefault().getLog().log(s);
    }
    final File file = new File(path);
    if (file.exists())
    {
      boolean overwrite = 
        MessageDialog.openQuestion(shell, "Confirm overwrite", "File already exists. Overwrite?");
      if (overwrite) {
        file.delete();
      } else {
        return;
      }
    }
    Job saveAsImage = new Job("Save chart as " + file.getName())
    {
      protected IStatus run(IProgressMonitor monitor)
      {
        try
        {
          monitor.beginTask("Saving chart as " + file.getName() + "...", -1);
          file.createNewFile();
          generateImageFile(file);
          return Status.OK_STATUS;
        }
        catch (IOException e)
        {
          return new Status(
            4, 
            "org.eclipse.linuxtools.dataviewers.charts", 
            "Error saving chart to \"" + 
            file.getAbsolutePath() + 
            "\":" + 
            e.getMessage(), 
            e);
        }
      }
    };
    saveAsImage.setUser(true);
    saveAsImage.schedule();
    
    saveState();
  }
  
  public void restoreState()
  {
    try
    {
      IDialogSettings settings = 
        Activator.getDefault().getDialogSettings().getSection("birtcharts_saveasimg_section");
      if (settings == null)
      {
        settings = Activator.getDefault().getDialogSettings().addNewSection("birtcharts_saveasimg_section");
        return;
      }
      dialog.setFileName(settings.get("IMG_FILE_NAME"));
      dialog.setFilterPath(settings.get("IMG_FILTER_PATH"));
    }
    catch (Exception e)
    {
      Status s = new Status(
        4, 
        "org.eclipse.linuxtools.dataviewers.charts", 
        4, 
        e.getMessage(), 
        e);
      Activator.getDefault().getLog().log(s);
    }
  }
  
  public void saveState()
  {
    try
    {
      IDialogSettings settings = 
        Activator.getDefault().getDialogSettings().getSection("birtcharts_saveasimg_section");
      if (settings == null) {
        settings = Activator.getDefault().getDialogSettings().addNewSection("birtcharts_saveasimg_section");
      }
      settings.put("IMG_FILE_NAME", dialog.getFileName());
      settings.put("IMG_FILTER_PATH", dialog.getFilterPath());
    }
    catch (Exception e)
    {
      Status s = new Status(
        4, 
        "org.eclipse.linuxtools.dataviewers.charts", 
        4, 
        e.getMessage(), 
        e);
      Activator.getDefault().getLog().log(s);
    }
  }
  
  protected void generateImageFile(File file)
  {
    RunTimeContext rtc = new RunTimeContext();
    rtc.setULocale(ULocale.getDefault());
    
    Generator gr = Generator.instance();
    GeneratedChartState gcs = null;
    
    Bounds boFile = null;
    bo = chartView.getChartViewer().getBounds();
    if (bo != null) {
      boFile = BoundsImpl.create(bo.getLeft(), bo.getTop(), bo.getWidth(), bo.getHeight());
    } else {
      boFile = BoundsImpl.create(0.0D, 0.0D, 800.0D, 600.0D);
    }
    try
    {
      gcs = gr.build(idr.getDisplayServer(), cm, boFile, null, rtc, null);
    }
    catch (ChartException e)
    {
      Status s = new Status(
        4, 
        "org.eclipse.linuxtools.dataviewers.charts", 
        4, 
        e.getMessage(), 
        e);
      Activator.getDefault().getLog().log(s);
    }
    idr.setProperty("device.file.identifier", file.getAbsolutePath());
    try
    {
      gr.render(idr, gcs);
    }
    catch (ChartException e)
    {
      Status s = new Status(
        4, 
        "org.eclipse.linuxtools.dataviewers.charts", 
        4, 
        e.getMessage(), 
        e);
      Activator.getDefault().getLog().log(s);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.charts.actions.SaveChartAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.charts.actions;

import org.eclipse.birt.chart.model.Chart;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.Action;
import org.eclipse.linuxtools.dataviewers.charts.Activator;
import org.eclipse.linuxtools.dataviewers.charts.UIHelper;
import org.eclipse.swt.widgets.Composite;

public class SaveXMLAction
  extends Action
{
  private Composite cmp;
  private Chart cm;
  
  public SaveXMLAction(Composite parent)
  {
    cmp = parent;
    setImageDescriptor(UIHelper.getImageDescriptor("icons/eexport.gif"));
    setDisabledImageDescriptor(UIHelper.getImageDescriptor("icons/dexport.gif"));
    setToolTipText("Save XML Source");
    setDescription("Save XML Source to the designated directory");
  }
  
  /* Error */
  public void run()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 51	org/eclipse/linuxtools/dataviewers/charts/actions/SaveXMLAction:cm	Lorg/eclipse/birt/chart/model/Chart;
    //   4: ifnull +252 -> 256
    //   7: new 53	org/eclipse/swt/widgets/FileDialog
    //   10: dup
    //   11: aload_0
    //   12: getfield 15	org/eclipse/linuxtools/dataviewers/charts/actions/SaveXMLAction:cmp	Lorg/eclipse/swt/widgets/Composite;
    //   15: invokevirtual 55	org/eclipse/swt/widgets/Composite:getShell	()Lorg/eclipse/swt/widgets/Shell;
    //   18: sipush 8192
    //   21: invokespecial 61	org/eclipse/swt/widgets/FileDialog:<init>	(Lorg/eclipse/swt/widgets/Shell;I)V
    //   24: astore_1
    //   25: aload_1
    //   26: iconst_1
    //   27: anewarray 64	java/lang/String
    //   30: dup
    //   31: iconst_0
    //   32: ldc 66
    //   34: aastore
    //   35: invokevirtual 68	org/eclipse/swt/widgets/FileDialog:setFilterExtensions	([Ljava/lang/String;)V
    //   38: aload_1
    //   39: invokevirtual 72	org/eclipse/swt/widgets/FileDialog:open	()Ljava/lang/String;
    //   42: pop
    //   43: aload_1
    //   44: invokevirtual 76	org/eclipse/swt/widgets/FileDialog:getFileName	()Ljava/lang/String;
    //   47: astore_2
    //   48: aload_2
    //   49: ifnull +207 -> 256
    //   52: aload_2
    //   53: ldc 79
    //   55: if_acmpeq +201 -> 256
    //   58: aconst_null
    //   59: astore_3
    //   60: new 81	java/io/File
    //   63: dup
    //   64: aload_1
    //   65: invokevirtual 83	org/eclipse/swt/widgets/FileDialog:getFilterPath	()Ljava/lang/String;
    //   68: aload_2
    //   69: invokespecial 86	java/io/File:<init>	(Ljava/lang/String;Ljava/lang/String;)V
    //   72: astore 4
    //   74: aload 4
    //   76: invokevirtual 89	java/io/File:exists	()Z
    //   79: ifeq +47 -> 126
    //   82: new 93	org/eclipse/swt/widgets/MessageBox
    //   85: dup
    //   86: aload_0
    //   87: getfield 15	org/eclipse/linuxtools/dataviewers/charts/actions/SaveXMLAction:cmp	Lorg/eclipse/swt/widgets/Composite;
    //   90: invokevirtual 55	org/eclipse/swt/widgets/Composite:getShell	()Lorg/eclipse/swt/widgets/Shell;
    //   93: sipush 200
    //   96: invokespecial 95	org/eclipse/swt/widgets/MessageBox:<init>	(Lorg/eclipse/swt/widgets/Shell;I)V
    //   99: astore 5
    //   101: aload 5
    //   103: ldc 34
    //   105: invokevirtual 96	org/eclipse/swt/widgets/MessageBox:setText	(Ljava/lang/String;)V
    //   108: aload 5
    //   110: ldc 99
    //   112: invokevirtual 101	org/eclipse/swt/widgets/MessageBox:setMessage	(Ljava/lang/String;)V
    //   115: aload 5
    //   117: invokevirtual 104	org/eclipse/swt/widgets/MessageBox:open	()I
    //   120: bipush 64
    //   122: if_icmpeq +4 -> 126
    //   125: return
    //   126: invokestatic 107	org/eclipse/birt/chart/model/impl/SerializerImpl:instance	()Lorg/eclipse/birt/chart/model/Serializer;
    //   129: astore_3
    //   130: aload_3
    //   131: aload_0
    //   132: getfield 51	org/eclipse/linuxtools/dataviewers/charts/actions/SaveXMLAction:cm	Lorg/eclipse/birt/chart/model/Chart;
    //   135: invokeinterface 113 1 0
    //   140: new 119	java/io/FileOutputStream
    //   143: dup
    //   144: aload 4
    //   146: invokespecial 121	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   149: invokeinterface 124 3 0
    //   154: invokestatic 130	org/eclipse/core/resources/ResourcesPlugin:getWorkspace	()Lorg/eclipse/core/resources/IWorkspace;
    //   157: invokeinterface 136 1 0
    //   162: new 142	org/eclipse/core/runtime/Path
    //   165: dup
    //   166: aload 4
    //   168: invokevirtual 144	java/io/File:getAbsolutePath	()Ljava/lang/String;
    //   171: invokespecial 147	org/eclipse/core/runtime/Path:<init>	(Ljava/lang/String;)V
    //   174: invokeinterface 149 2 0
    //   179: astore 5
    //   181: aload 5
    //   183: ifnull +73 -> 256
    //   186: aload 5
    //   188: iconst_1
    //   189: new 155	org/eclipse/core/runtime/NullProgressMonitor
    //   192: dup
    //   193: invokespecial 157	org/eclipse/core/runtime/NullProgressMonitor:<init>	()V
    //   196: invokeinterface 158 3 0
    //   201: goto +55 -> 256
    //   204: astore 6
    //   206: new 164	org/eclipse/core/runtime/Status
    //   209: dup
    //   210: iconst_4
    //   211: ldc -90
    //   213: aload 6
    //   215: invokevirtual 168	org/eclipse/core/runtime/CoreException:getMessage	()Ljava/lang/String;
    //   218: aload 6
    //   220: invokespecial 173	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   223: astore 7
    //   225: invokestatic 176	org/eclipse/linuxtools/dataviewers/charts/Activator:getDefault	()Lorg/eclipse/linuxtools/dataviewers/charts/Activator;
    //   228: invokevirtual 182	org/eclipse/linuxtools/dataviewers/charts/Activator:getLog	()Lorg/eclipse/core/runtime/ILog;
    //   231: aload 7
    //   233: invokeinterface 186 2 0
    //   238: goto +18 -> 256
    //   241: astore 5
    //   243: aload 5
    //   245: invokevirtual 192	java/io/IOException:printStackTrace	()V
    //   248: goto +8 -> 256
    //   251: astore_2
    //   252: aload_2
    //   253: invokevirtual 197	java/lang/Throwable:printStackTrace	()V
    //   256: return
    // Line number table:
    //   Java source line #58	-> byte code offset #0
    //   Java source line #60	-> byte code offset #7
    //   Java source line #61	-> byte code offset #18
    //   Java source line #60	-> byte code offset #21
    //   Java source line #62	-> byte code offset #25
    //   Java source line #63	-> byte code offset #32
    //   Java source line #62	-> byte code offset #35
    //   Java source line #66	-> byte code offset #38
    //   Java source line #67	-> byte code offset #43
    //   Java source line #68	-> byte code offset #48
    //   Java source line #70	-> byte code offset #58
    //   Java source line #71	-> byte code offset #60
    //   Java source line #72	-> byte code offset #68
    //   Java source line #71	-> byte code offset #69
    //   Java source line #73	-> byte code offset #74
    //   Java source line #75	-> byte code offset #82
    //   Java source line #76	-> byte code offset #93
    //   Java source line #75	-> byte code offset #96
    //   Java source line #77	-> byte code offset #101
    //   Java source line #78	-> byte code offset #108
    //   Java source line #79	-> byte code offset #115
    //   Java source line #81	-> byte code offset #125
    //   Java source line #85	-> byte code offset #126
    //   Java source line #89	-> byte code offset #130
    //   Java source line #90	-> byte code offset #154
    //   Java source line #91	-> byte code offset #181
    //   Java source line #93	-> byte code offset #186
    //   Java source line #94	-> byte code offset #204
    //   Java source line #95	-> byte code offset #206
    //   Java source line #96	-> byte code offset #225
    //   Java source line #101	-> byte code offset #241
    //   Java source line #103	-> byte code offset #243
    //   Java source line #107	-> byte code offset #251
    //   Java source line #109	-> byte code offset #252
    //   Java source line #112	-> byte code offset #256
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	257	0	this	SaveXMLAction
    //   24	41	1	saveDialog	org.eclipse.swt.widgets.FileDialog
    //   47	22	2	name	String
    //   251	2	2	e	Throwable
    //   59	72	3	serializer	org.eclipse.birt.chart.model.Serializer
    //   72	95	4	file	java.io.File
    //   99	17	5	box	org.eclipse.swt.widgets.MessageBox
    //   179	8	5	c	org.eclipse.core.resources.IFile
    //   241	3	5	ioe	java.io.IOException
    //   204	15	6	e	org.eclipse.core.runtime.CoreException
    //   223	9	7	status	org.eclipse.core.runtime.IStatus
    // Exception table:
    //   from	to	target	type
    //   186	201	204	org/eclipse/core/runtime/CoreException
    //   130	238	241	java/io/IOException
    //   38	125	251	java/lang/Throwable
    //   126	248	251	java/lang/Throwable
  }
  
  public void setChart(Chart chart)
  {
    try
    {
      if (chart != null) {
        setEnabled(true);
      } else {
        setEnabled(false);
      }
      cm = chart;
    }
    catch (Throwable _)
    {
      Status s = new Status(
        4, 
        "org.eclipse.linuxtools.dataviewers.charts", 
        4, 
        "Error when creating \"save as image\" action...", 
        _);
      Activator.getDefault().getLog().log(s);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.charts.actions.SaveXMLAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.charts.dataengine;

import com.ibm.icu.util.ULocale;
import org.eclipse.birt.chart.exception.ChartException;
import org.eclipse.birt.chart.factory.Generator;
import org.eclipse.birt.chart.factory.IDataRowExpressionEvaluator;
import org.eclipse.birt.chart.factory.RunTimeContext;
import org.eclipse.birt.chart.model.Chart;
import org.eclipse.birt.chart.model.ChartWithAxes;
import org.eclipse.birt.chart.model.attribute.AxisOrigin;
import org.eclipse.birt.chart.model.attribute.AxisType;
import org.eclipse.birt.chart.model.attribute.FontDefinition;
import org.eclipse.birt.chart.model.attribute.IntersectionType;
import org.eclipse.birt.chart.model.attribute.LegendItemType;
import org.eclipse.birt.chart.model.attribute.LineAttributes;
import org.eclipse.birt.chart.model.attribute.Palette;
import org.eclipse.birt.chart.model.attribute.Position;
import org.eclipse.birt.chart.model.attribute.Text;
import org.eclipse.birt.chart.model.attribute.TickStyle;
import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionImpl;
import org.eclipse.birt.chart.model.component.Axis;
import org.eclipse.birt.chart.model.component.Grid;
import org.eclipse.birt.chart.model.component.Label;
import org.eclipse.birt.chart.model.component.Series;
import org.eclipse.birt.chart.model.component.impl.SeriesImpl;
import org.eclipse.birt.chart.model.data.SeriesDefinition;
import org.eclipse.birt.chart.model.data.impl.QueryImpl;
import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl;
import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl;
import org.eclipse.birt.chart.model.layout.Block;
import org.eclipse.birt.chart.model.layout.ClientArea;
import org.eclipse.birt.chart.model.layout.Legend;
import org.eclipse.birt.chart.model.layout.Plot;
import org.eclipse.birt.chart.model.layout.TitleBlock;
import org.eclipse.birt.chart.model.type.BarSeries;
import org.eclipse.birt.chart.model.type.impl.BarSeriesImpl;
import org.eclipse.birt.core.data.ExpressionUtil;
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.data.engine.api.DataEngine;
import org.eclipse.birt.data.engine.api.DataEngineContext;
import org.eclipse.birt.data.engine.api.IPreparedQuery;
import org.eclipse.birt.data.engine.api.IQueryResults;
import org.eclipse.birt.data.engine.api.querydefn.Binding;
import org.eclipse.birt.data.engine.api.querydefn.GroupDefinition;
import org.eclipse.birt.data.engine.api.querydefn.OdaDataSetDesign;
import org.eclipse.birt.data.engine.api.querydefn.OdaDataSourceDesign;
import org.eclipse.birt.data.engine.api.querydefn.QueryDefinition;
import org.eclipse.birt.data.engine.api.querydefn.ScriptExpression;
import org.eclipse.birt.data.engine.core.DataException;
import org.eclipse.emf.common.util.EList;

public class BindDataEngine
{
  private String[] columnsName = null;
  private FlatFileDataSource ffds = null;
  
  public final Chart createWorkingWithBIRTDataEngine(FlatFileDataSource ffds)
    throws ChartException
  {
    this.ffds = ffds;
    columnsName = ffds.getCOLUMNNAME();
    String[] expressions = new String[columnsName.length];
    expressions[0] = ExpressionUtil.createRowExpression(columnsName[0]);
    expressions[1] = ExpressionUtil.createRowExpression(columnsName[1]);
    
    ChartWithAxes cwaBar = createChartModel(expressions);
    
    cwaBar = bindData(cwaBar, expressions);
    
    return cwaBar;
  }
  
  private static ChartWithAxes createChartModel(String[] expressions)
  {
    ChartWithAxes cwaBar = ChartWithAxesImpl.create();
    cwaBar.setType("Bar Chart");
    cwaBar.setSubType("Side-by-side");
    
    cwaBar.getBlock().setBackground(ColorDefinitionImpl.WHITE());
    cwaBar.getBlock().getOutline().setVisible(true);
    Plot p = cwaBar.getPlot();
    p.getClientArea().setBackground(ColorDefinitionImpl.create(255, 
      255, 
      225));
    
    cwaBar.getTitle()
      .getLabel()
      .getCaption()
      .setValue("Working with BIRT Data Engine");
    
    Legend lg = cwaBar.getLegend();
    lg.setItemType(LegendItemType.CATEGORIES_LITERAL);
    
    Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes()[0];
    
    xAxisPrimary.setType(AxisType.TEXT_LITERAL);
    xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL);
    xAxisPrimary.getOrigin().setType(IntersectionType.MIN_LITERAL);
    
    Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis(xAxisPrimary);
    yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL);
    yAxisPrimary.setType(AxisType.LINEAR_LITERAL);
    yAxisPrimary.getLabel().getCaption().getFont().setRotation(90.0D);
    yAxisPrimary.getTitle().setVisible(true);
    yAxisPrimary.getTitle().getCaption().setValue("Customer Amount");
    yAxisPrimary.getTitle()
      .getCaption()
      .setColor(ColorDefinitionImpl.GREEN());
    
    Series seCategory = SeriesImpl.create();
    
    seCategory.getDataDefinition()
      .add(QueryImpl.create(expressions[0]));
    
    SeriesDefinition sdX = SeriesDefinitionImpl.create();
    sdX.getSeriesPalette().shift(0);
    
    xAxisPrimary.getSeriesDefinitions().add(sdX);
    sdX.getSeries().add(seCategory);
    
    BarSeries bs1 = (BarSeries)BarSeriesImpl.create();
    bs1.getDataDefinition().add(QueryImpl.create(expressions[1]));
    bs1.getLabel().setVisible(true);
    bs1.setLabelPosition(Position.INSIDE_LITERAL);
    
    SeriesDefinition sdY = SeriesDefinitionImpl.create();
    yAxisPrimary.getSeriesDefinitions().add(sdY);
    sdY.getSeries().add(bs1);
    return cwaBar;
  }
  
  private ChartWithAxes bindData(ChartWithAxes cwaBar, String[] expressions)
    throws ChartException
  {
    RunTimeContext context = new RunTimeContext();
    context.setULocale(ULocale.getDefault());
    try
    {
      IDataRowExpressionEvaluator evaluator = prepareRowExpressionEvaluator(cwaBar, expressions);
      
      Generator.instance().bindData(evaluator, cwaBar, context);
    }
    catch (BirtException e)
    {
      throw new ChartException("org.eclipse.linuxtools.dataviewers.charts", 
        19, 
        e);
    }
    IDataRowExpressionEvaluator evaluator;
    return cwaBar;
  }
  
  private IDataRowExpressionEvaluator prepareRowExpressionEvaluator(ChartWithAxes chart, String[] expressions)
    throws BirtException
  {
    OdaDataSourceDesign odaDataSource = newDataSource();
    OdaDataSetDesign odaDataSet = newDataSet(odaDataSource);
    
    QueryDefinition query = createQueryDefinition(odaDataSet, expressions);
    
    DataEngine dataEngine = newDataEngine();
    dataEngine.defineDataSource(odaDataSource);
    dataEngine.defineDataSet(odaDataSet);
    IPreparedQuery preparedQuery = dataEngine.prepare(query);
    
    IQueryResults queryResults = preparedQuery.execute(null);
    
    return new GroupedRowExpressionsEvaluator(queryResults.getResultIterator(), 
      true);
  }
  
  private QueryDefinition createQueryDefinition(OdaDataSetDesign odaDataSet, String[] expressions)
    throws ChartException
  {
    QueryDefinition queryDefn = new QueryDefinition();
    queryDefn.setDataSetName(odaDataSet.getName());
    try
    {
      initDefaultBindings(queryDefn);
      
      String groupName = "Group_Country";
      GroupDefinition gd = new GroupDefinition(groupName);
      gd.setKeyExpression(expressions[0]);
      gd.setInterval(0);
      gd.setIntervalRange(0.0D);
      for (int i = 0; i < expressions.length; i++)
      {
        String expr = expressions[i];
        Binding colBinding = new Binding(expr);
        colBinding.setExpression(new ScriptExpression(expr));
        if (i == 1)
        {
          colBinding.setExpression(null);
          colBinding.setAggrFunction("COUNT");
          colBinding.addAggregateOn(groupName);
          colBinding.addArgument(new ScriptExpression(expressions[i]));
        }
        queryDefn.addBinding(colBinding);
      }
      queryDefn.addGroup(gd);
    }
    catch (DataException e)
    {
      throw new ChartException("org.eclipse.linuxtools.dataviewers.charts", 
        19, 
        e);
    }
    return queryDefn;
  }
  
  private void initDefaultBindings(QueryDefinition queryDefn)
    throws DataException
  {
    for (int i = 0; i < columnsName.length; i++)
    {
      Binding colBinding = new Binding(columnsName[i]);
      colBinding.setExpression(new ScriptExpression(ExpressionUtil.createDataSetRowExpression(columnsName[i])));
      queryDefn.addBinding(colBinding);
    }
  }
  
  private static DataEngine newDataEngine()
    throws BirtException
  {
    DataEngineContext context = DataEngineContext.newInstance(3, null, null, null);
    
    DataEngine myDataEngine = DataEngine.newDataEngine(context);
    return myDataEngine;
  }
  
  private OdaDataSetDesign newDataSet(OdaDataSourceDesign dataSourceDesign)
  {
    OdaDataSetDesign dataSet = new OdaDataSetDesign("Data Set1");
    
    dataSet.setDataSource(dataSourceDesign.getName());
    dataSet.setExtensionID("org.eclipse.datatools.connectivity.oda.flatfile.dataSet");
    dataSet.setQueryText(ffds.getQuery());
    return dataSet;
  }
  
  private OdaDataSourceDesign newDataSource()
    throws BirtException
  {
    OdaDataSourceDesign dataSource = new OdaDataSourceDesign("Data Source1");
    dataSource.setExtensionID("org.eclipse.datatools.connectivity.oda.flatfile");
    dataSource.addPrivateProperty("HOME", ffds.HOME);
    dataSource.addPrivateProperty("CHARSET", "UTF-8");
    dataSource.addPrivateProperty("DELIMTYPE", 
      "TAB");
    dataSource.addPrivateProperty("INCLTYPELINE", 
      "NO");
    dataSource.addPrivateProperty("OdaPropertyConfigId", 
      dataSource.getExtensionID() + 
      "_" + 
      dataSource.getName());
    
    return dataSource;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.charts.dataengine.BindDataEngine
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.charts.dataengine;

public class FlatFileDataSource
{
  static final String DATA_SOURCE_TYPE = "org.eclipse.datatools.connectivity.oda.flatfile";
  static final String DATA_SET_TYPE = "org.eclipse.datatools.connectivity.oda.flatfile.dataSet";
  static final String CHARSET = "UTF-8";
  static final String DELIMTYPE = "TAB";
  static final String INCLTYPELINE = "NO";
  protected String HOME = null;
  protected String dataFile = "";
  protected String query = "";
  protected String[] columnsName = null;
  
  public FlatFileDataSource() {}
  
  public FlatFileDataSource(String HOME, Strin
1 2 3

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd