Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b1ca5e6aec5fd963a89f6e10cdf874c8093b2116 (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
/*****************************************************************************
 * Copyright (c) 2011 Nicolas Deblock & Manuel Giles.
 *
 *
 * 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:
 * 	Nicolas Deblock  nico.deblock@gmail.com  - Initial API and implementation
 * 	Manuel Giles	 giles.manu@live.fr		 - Initial API and implementation
 * 	Cedric Dumoulin  Cedric.dumoulin@lifl.fr - Idea of the java generator project & help for the conception 
 *
 *****************************************************************************/

package org.eclipse.papyrus.java.generator.ui.preference;

import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.papyrus.java.generator.jdtsynchronizer.GeneratorPreference;
import org.eclipse.papyrus.java.generator.ui.Activator;

public class GeneratorPreferenceImpl implements GeneratorPreference {

	/**
	 * allow to gather default value
	 */
	private IPreferenceStore store = Activator.getDefault().getPreferenceStore();


	public boolean implementMethodsOfIntefaces() {
		return store.getBoolean(PreferenceConstants.P_IMPLEMENT_METHODS_OF_INTERFACES_AND_ABSTRACT_CLASS);
	}

	public boolean implementMethodsOfAbstractClass() {
		return store.getBoolean(PreferenceConstants.P_IMPLEMENT_METHODS_OF_INTERFACES_AND_ABSTRACT_CLASS);
	}

	public boolean generateGetters() {
		return store.getBoolean(PreferenceConstants.P_GENERATE_GETTERS);
	}

	public boolean generateSetters() {
		return store.getBoolean(PreferenceConstants.P_GENERATE_SETTERS);
	}

	public boolean isPackageToGenerate(String packageQualifiedName) {
		if(packageQualifiedName == null || packageQualifiedName.isEmpty())
			return true;

		// gather list of packages :
		String listStr = store.getString(PreferenceConstants.P_FILTER_OF_PACKAGE_NOT_TO_GENERATE);

		// if list of package don't exist, return true
		if(listStr == null || listStr.isEmpty())
			return true;

		// gather list in a table
		String[] listPackage = listStr.split(";");

		for(String _package : listPackage) {
			if(_package.equals(packageQualifiedName))
				return false;

			// if package have a *, we delete *			
			String packageWithoutStar = _package;
			if(_package.contains("*"))
				packageWithoutStar = _package.substring(0, _package.indexOf("*") - 1);

			if(packageQualifiedName.contains(packageWithoutStar))
				return false;
		}

		// by default, return true
		return true;
	}

	public String genericClassForMultiValue() {
		return store.getString(PreferenceConstants.P_GENERIC_CLASS_FOR_MULTIVALUE);
	}

	@Override
	public boolean stopOnFirstError() {
		return store.getBoolean(PreferenceConstants.P_STOP_ON_FIRST_ERROR);
	}

}

Back to the top