47
47
public class ImportDataSetAction extends Action implements IWorkbenchWindowActionDelegate {
48
48
public void init(IWorkbenchWindow window) {
49
LogManager.logDebug("Start ImportDataSetAction.init", this);
50
LogManager.logDebug("Initializing", this);
49
LogManager.logDebug("Start ImportDataSetAction.init", this); //$NON-NLS-1$
50
LogManager.logDebug("Initializing", this); //$NON-NLS-1$
52
LogManager.logDebug("End ImportDataSetAction.init", this);
52
LogManager.logDebug("End ImportDataSetAction.init", this); //$NON-NLS-1$
59
59
* @param act The action that fired this method.
61
61
public void run(IAction act) {
62
LogManager.logDebug("Start ImportDataSetAction.run", this);
62
LogManager.logDebug("Start ImportDataSetAction.run", this); //$NON-NLS-1$
64
64
FileDialog dialog= new FileDialog(fWindow.getShell(), SWT.OPEN);
65
65
dialog.setText(Localization.getString("ImportDataSetAction.OpenDataSetFile"));
89
89
IViewPart ivp = p.findView(GraphSelectorView.ID);
90
90
((GraphSelectorView)ivp).createScriptSet(fileName, dataSet);
91
91
} catch(WorkbenchException we) {
92
LogManager.logCritical("WorkbenchException ImportDataSetAction.run:" + we.getMessage(), this);
92
LogManager.logCritical("WorkbenchException ImportDataSetAction.run:" + we.getMessage(), this); //$NON-NLS-1$
94
LogManager.logDebug("End ImportDataSetAction.run", this);
94
LogManager.logDebug("End ImportDataSetAction.run", this); //$NON-NLS-1$
97
97
public void selectionChanged(IAction a, ISelection s) {}
102
102
* @return The newly created DataSet containing the data from the file.
104
104
private IDataSet readFile(File f) {
105
LogManager.logDebug("Start ImportDataSetAction.readFile", this);
105
LogManager.logDebug("Start ImportDataSetAction.readFile", this); //$NON-NLS-1$
112
112
data = DataSetFactory.createFilteredDataSet(id, labels);
113
113
data.readFromFile(f);
115
LogManager.logDebug("End ImportDataSetAction.readFile", this);
115
LogManager.logDebug("End ImportDataSetAction.readFile", this); //$NON-NLS-1$
122
122
* @return An array of all of the labels found in the file
124
124
private void readHeader(File f) {
125
LogManager.logDebug("Start ImportDataSetAction.readLabels", this);
125
LogManager.logDebug("Start ImportDataSetAction.readLabels", this); //$NON-NLS-1$
128
128
FileReader fr = new FileReader(f);
135
135
labels = line.split(", ");
136
136
} catch(FileNotFoundException fnfe) {
137
LogManager.logCritical("FileNotFoundException ImportDataSetAction.readLabels:" + fnfe.getMessage(), this);
137
LogManager.logCritical("FileNotFoundException ImportDataSetAction.readLabels:" + fnfe.getMessage(), this); //$NON-NLS-1$
138
138
} catch(IOException ioe) {
139
LogManager.logCritical("IOException ImportDataSetAction.readLabels:" + ioe.getMessage(), this);
139
LogManager.logCritical("IOException ImportDataSetAction.readLabels:" + ioe.getMessage(), this); //$NON-NLS-1$
142
LogManager.logDebug("End ImportDataSetAction.readLabels", this);
142
LogManager.logDebug("End ImportDataSetAction.readLabels", this); //$NON-NLS-1$
145
145
private void displayError(String message) {
146
LogManager.logInfo("Initializing", MessageDialog.class);
146
LogManager.logInfo("Initializing", MessageDialog.class); //$NON-NLS-1$
147
147
MessageDialog.openWarning(fWindow.getShell(), Localization.getString("ImportDataSetAction.Problem"), message);
148
LogManager.logInfo("Disposing", MessageDialog.class);
148
LogManager.logInfo("Disposing", MessageDialog.class); //$NON-NLS-1$
151
151
public void dispose() {
152
LogManager.logDebug("Start ImportDataSetAction.dispose", this);
153
LogManager.logInfo("Disposing", this);
152
LogManager.logDebug("Start ImportDataSetAction.dispose", this); //$NON-NLS-1$
153
LogManager.logInfo("Disposing", this); //$NON-NLS-1$
155
LogManager.logDebug("End ImportDataSetAction.dispose", this);
155
LogManager.logDebug("End ImportDataSetAction.dispose", this); //$NON-NLS-1$
158
158
private IWorkbenchWindow fWindow;