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
|
/*******************************************************************************
* Copyright (c) 2012 BMW Car IT GmbH.
* 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:
* BMW Car IT - initial API and implementation
*******************************************************************************/
package org.yocto.sdk.ide;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.yocto.sdk.ide.preferences.YoctoSDKProjectPropertyPage;
public class YoctoProjectSpecificSetting {
private static final String PROJECT_SPECIFIC_TITLE = "Preferences.Profile.ProjectSpecific.Title";
private static final String PROJECT_SPECIFIC_GROUP_TITLE = "Preferences.Profile.ProjectSpecific.Group.Title";
private YoctoProfileSetting yoctoConfigurationsSetting;
private YoctoUISetting yoctoUISetting;
private Button btnUseProjectSpecificSettingsCheckbox;
private PreferencePage preferencePage;
public YoctoProjectSpecificSetting(YoctoProfileSetting yoctoConfigurationsSetting,
YoctoUISetting yoctoUISetting, PreferencePage preferencePage) {
this.yoctoConfigurationsSetting = yoctoConfigurationsSetting;
this.yoctoUISetting = yoctoUISetting;
this.preferencePage = preferencePage;
}
public void createComposite(Composite composite) {
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
GridLayout layout = new GridLayout(2, false);
Group storeYoctoConfigurationsGroup = new Group (composite, SWT.NONE);
layout = new GridLayout(2, false);
storeYoctoConfigurationsGroup.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
gd.horizontalSpan = 2;
storeYoctoConfigurationsGroup.setLayoutData(gd);
storeYoctoConfigurationsGroup.setText(YoctoSDKMessages.getString(PROJECT_SPECIFIC_GROUP_TITLE));
btnUseProjectSpecificSettingsCheckbox = new Button(storeYoctoConfigurationsGroup, SWT.CHECK);
btnUseProjectSpecificSettingsCheckbox.setText(YoctoSDKMessages.getString(PROJECT_SPECIFIC_TITLE));
btnUseProjectSpecificSettingsCheckbox.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnUseProjectSpecificSettingsCheckbox.getSelection()){
yoctoConfigurationsSetting.setUIFormEnabledState(false);
yoctoUISetting.setUIFormEnabledState(true);
if (preferencePage instanceof YoctoSDKProjectPropertyPage) {
((YoctoSDKProjectPropertyPage) preferencePage).switchToProjectSpecificProfile();
}
} else {
yoctoConfigurationsSetting.setUIFormEnabledState(true);
yoctoConfigurationsSetting.setButtonsEnabledState(false);
yoctoUISetting.setUIFormEnabledState(false);
if (preferencePage instanceof YoctoSDKProjectPropertyPage) {
((YoctoSDKProjectPropertyPage) preferencePage).switchToSelectedProfile();
}
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {}
});
}
public void setUseProjectSpecificSettings(boolean isUsingProjectSpecificSettings) {
btnUseProjectSpecificSettingsCheckbox.setSelection(isUsingProjectSpecificSettings);
}
public boolean isUsingProjectSpecificSettings() {
return btnUseProjectSpecificSettingsCheckbox.getSelection();
}
}
|