summaryrefslogtreecommitdiffstats
path: root/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CustomizeProblemComposite.java
blob: 32ba550010b1042077ef6671cca27a607fc51e61 (plain)
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
/*******************************************************************************
 * Copyright (c) 2009, 2010 Alena Laskavaia 
 * 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:
 *    Alena Laskavaia  - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.codan.internal.ui.widgets;

import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
import org.eclipse.core.resources.IResource;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;

/**
 * Composite for problem customisable parameters
 * 
 */
public class CustomizeProblemComposite extends Composite {
	private Composite parametersTab;
	private IProblem problem;
	private ParametersComposite problemsComposite;
	private FileScopeComposite scopeComposite;
	private IResource resource;

	/**
	 * @param parent
	 * @param selectedProblem
	 * @param resource
	 * @param style
	 */
	public CustomizeProblemComposite(Composite parent,
			IProblem selectedProblem, IResource resource) {
		super(parent, SWT.NONE);
		this.setLayout(new GridLayout(1, false));
		this.problem = selectedProblem;
		this.resource = resource;
		final TabFolder tabFolder = new TabFolder(this, SWT.TOP);
		tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
		// createMainTab(tabFolder);
		createParamtersTab(tabFolder);
		createScopeTab(tabFolder);
	}

	public void save(IProblemWorkingCopy problem) {
		problemsComposite.save(problem);
		scopeComposite.save(problem);
	}

	/**
	 * @param tabFolder
	 */
	private void createParamtersTab(TabFolder tabFolder) {
		TabItem tabItem1 = new TabItem(tabFolder, SWT.NULL);
		tabItem1.setText(CodanUIMessages.CustomizeProblemComposite_TabParameters);
		parametersTab = new Composite(tabFolder, SWT.NONE);
		tabItem1.setControl(parametersTab);
		parametersTab.setLayout(new GridLayout());
		problemsComposite = new ParametersComposite(parametersTab, problem);
		problemsComposite.setLayoutData(new GridData(SWT.BEGINNING,
				SWT.BEGINNING, true, false));
	}

	/**
	 * @param tabFolder
	 */
	private void createScopeTab(TabFolder tabFolder) {
		TabItem tabItem1 = new TabItem(tabFolder, SWT.NULL);
		tabItem1.setText(CodanUIMessages.CustomizeProblemComposite_TabScope);
		Composite comp = new Composite(tabFolder, SWT.NONE);
		tabItem1.setControl(comp);
		comp.setLayout(new GridLayout());
		scopeComposite = new FileScopeComposite(comp, problem, resource);
		scopeComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING,
				true, false));
	}
}