DataService.java

Go to the documentation of this file.
00001 package edu.rice.cs.hpc.traceviewer.services;
00002 
00003 import java.util.HashMap;
00004 import java.util.Map;
00005 
00006 import org.eclipse.ui.AbstractSourceProvider;
00007 import org.eclipse.ui.ISources;
00008 
00009 import edu.rice.cs.hpc.traceviewer.spaceTimeData.SpaceTimeDataController;
00010 
00011 public class DataService extends AbstractSourceProvider {
00012 
00013     final static public String DATA_PROVIDER = "edu.rice.cs.hpc.traceviewer.services.DataService.data";
00014     final static public String DATA_UPDATE = "edu.rice.cs.hpc.traceviewer.services.DataService.update";
00015     
00016     private SpaceTimeDataController data;
00017     
00018 
00019     /*
00020      * (non-Javadoc)
00021      * @see org.eclipse.ui.ISourceProvider#dispose()
00022      */
00023     public void dispose() {}
00024 
00025     /*
00026      * (non-Javadoc)
00027      * @see org.eclipse.ui.ISourceProvider#getCurrentState()
00028      */
00029     public Map getCurrentState() {
00030 
00031         Map<String, Object> map = new HashMap<String, Object>(1);
00032         map.put(DATA_PROVIDER, getValue());
00033         map.put(DATA_UPDATE, data);
00034         
00035         return map;
00036     }
00037 
00038     /*
00039      * (non-Javadoc)
00040      * @see org.eclipse.ui.ISourceProvider#getProvidedSourceNames()
00041      */
00042     public String[] getProvidedSourceNames() {
00043 
00044         return new String[] {DATA_PROVIDER, DATA_UPDATE};
00045     }
00046     
00047     /***
00048      * set the updated data
00049      * @param data
00050      */
00051     public void setData( SpaceTimeDataController data ) {
00052         this.data = data;
00053         fireSourceChanged(ISources.WORKBENCH, DATA_PROVIDER, "ENABLED");
00054     }
00055     
00056     /***
00057      * broadcast updated data
00058      */
00059     public void broadcastUpdate( Object updatedData ) {
00060         if (updatedData == null)
00061             fireSourceChanged(ISources.WORKBENCH, DATA_UPDATE, data);
00062         else
00063             fireSourceChanged(ISources.WORKBENCH, DATA_UPDATE, updatedData);
00064     }
00065     
00066     /***
00067      * retrieve the current data
00068      * @return
00069      */
00070     public SpaceTimeDataController getData() {
00071         return data;
00072     }
00073  
00074     
00075     private String getValue() {
00076         return (data != null)? "ENABLED" : "DISABLED";
00077     }
00078 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1