Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 4a7b4479f3f6e1403582aa826906825ee781cebe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*******************************************************************************
 * Copyright (c) 2006 IBM Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
 *******************************************************************************/

package org.eclipse.linuxtools.systemtap.graphingapi.ui.wizards.dataset;

import java.io.File;
import java.io.IOException;

import org.eclipse.jface.dialogs.IPageChangedListener;
import org.eclipse.jface.dialogs.PageChangedEvent;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.linuxtools.internal.systemtap.graphingapi.ui.Localization;
import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataSet;
import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataSetParser;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;

/**
 * @deprecated The means of creating/editing graph configurations has
 * deviated significantly from this implementation.
 * TODO remove in 3.0
 */
@Deprecated
public class DataSetWizard extends Wizard implements INewWizard {
	public DataSetWizard(File metaFile, String scriptFile) {
		this.metaFile = metaFile;
		this.scriptFile = scriptFile;
	}

	@Override
	public void init(IWorkbench workbench, IStructuredSelection selection) {}

	@Override
	public void addPages() {
		setWindowTitle(Localization.getString("DataSetWizard.CreateDataSet")); //$NON-NLS-1$
		dataSetPage = new SelectDataSetWizardPage();
		addPage(dataSetPage);

		String[] ids = DataSetFactory.getIDs();
		parsingPages = new ParsingWizardPage[ids.length];
		for(int i=0; i<ids.length; i++) {
			parsingPages[i] = DataSetFactory.getParsingWizardPage(ids[i]);
			addPage(parsingPages[i]);
		}

		((WizardDialog)getContainer()).addPageChangedListener(pageListener);
	}

	@Override
	public boolean canFinish() {
		IWizardPage page = this.getContainer().getCurrentPage();
		if((null != dataSet) && (null != parser) && (page instanceof ParsingWizardPage)) {
			return true;
		}
		return false;
	}

	@Override
	public boolean performCancel() {
		parser = null;
		dataSet = null;
		return true;
	}

	@Override
	public boolean performFinish() {
		return true;
	}

	public IDataSetParser getParser() {
		return parser;
	}

	public IDataSet getDataSet() {
		return dataSet;
	}

	protected boolean openFile() {
		try {
			if (!metaFile.exists()) {
				metaFile.createNewFile();
			}
		} catch(IOException ioe) {
			return false;
		}

		return true;
	}

	@Override
	public void dispose() {
		if(null != getContainer()) {
			((WizardDialog)getContainer()).removePageChangedListener(pageListener);
		}
		if(null != dataSetPage) {
			dataSetPage.dispose();
		}
		if(null != parsingPages) {
			for(int i=0; i<parsingPages.length; i++) {
				if(null != parsingPages[i]) {
					parsingPages[i].dispose();
					parsingPages[i] = null;
				}
			}
			parsingPages = null;
		}
	}

	private IPageChangedListener pageListener = new IPageChangedListener() {
		@Override
		public void pageChanged(PageChangedEvent e) {
			if(e.getSelectedPage() instanceof ParsingWizardPage) {
				((ParsingWizardPage)e.getSelectedPage()).checkComplete();
				getContainer().updateButtons();
			}
		}
	};

	private SelectDataSetWizardPage dataSetPage;

	private ParsingWizardPage[] parsingPages;
	public String scriptFile;
	public File metaFile;
	public IDataSet dataSet;
	public IDataSetParser parser;
}

Back to the top