summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProjectSpecificSetting.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProjectSpecificSetting.java')
-rw-r--r--plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProjectSpecificSetting.java88
1 files changed, 88 insertions, 0 deletions
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProjectSpecificSetting.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProjectSpecificSetting.java
new file mode 100644
index 0000000..2a55a64
--- /dev/null
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProjectSpecificSetting.java
@@ -0,0 +1,88 @@
1/*******************************************************************************
2 * Copyright (c) 2012 BMW Car IT GmbH.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * BMW Car IT - initial API and implementation
10 *******************************************************************************/
11package org.yocto.sdk.ide;
12
13import org.eclipse.jface.preference.PreferencePage;
14import org.eclipse.swt.SWT;
15import org.eclipse.swt.events.SelectionEvent;
16import org.eclipse.swt.events.SelectionListener;
17import org.eclipse.swt.layout.GridData;
18import org.eclipse.swt.layout.GridLayout;
19import org.eclipse.swt.widgets.Button;
20import org.eclipse.swt.widgets.Composite;
21import org.eclipse.swt.widgets.Group;
22import org.yocto.sdk.ide.preferences.YoctoSDKProjectPropertyPage;
23
24public class YoctoProjectSpecificSetting {
25 private static final String PROJECT_SPECIFIC_TITLE = "Preferences.Profile.ProjectSpecific.Title";
26 private static final String PROJECT_SPECIFIC_GROUP_TITLE = "Preferences.Profile.ProjectSpecific.Group.Title";
27
28 private YoctoProfileSetting yoctoConfigurationsSetting;
29 private YoctoUISetting yoctoUISetting;
30
31 private Button btnUseProjectSpecificSettingsCheckbox;
32 private PreferencePage preferencePage;
33
34 public YoctoProjectSpecificSetting(YoctoProfileSetting yoctoConfigurationsSetting,
35 YoctoUISetting yoctoUISetting, PreferencePage preferencePage) {
36 this.yoctoConfigurationsSetting = yoctoConfigurationsSetting;
37 this.yoctoUISetting = yoctoUISetting;
38 this.preferencePage = preferencePage;
39 }
40
41 public void createComposite(Composite composite) {
42 GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
43 GridLayout layout = new GridLayout(2, false);
44
45 Group storeYoctoConfigurationsGroup = new Group (composite, SWT.NONE);
46 layout = new GridLayout(2, false);
47 storeYoctoConfigurationsGroup.setLayout(layout);
48 gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
49 gd.horizontalSpan = 2;
50 storeYoctoConfigurationsGroup.setLayoutData(gd);
51 storeYoctoConfigurationsGroup.setText(YoctoSDKMessages.getString(PROJECT_SPECIFIC_GROUP_TITLE));
52
53 btnUseProjectSpecificSettingsCheckbox = new Button(storeYoctoConfigurationsGroup, SWT.CHECK);
54 btnUseProjectSpecificSettingsCheckbox.setText(YoctoSDKMessages.getString(PROJECT_SPECIFIC_TITLE));
55 btnUseProjectSpecificSettingsCheckbox.addSelectionListener(new SelectionListener() {
56 @Override
57 public void widgetSelected(SelectionEvent e) {
58 if (btnUseProjectSpecificSettingsCheckbox.getSelection()){
59 yoctoConfigurationsSetting.setUIFormEnabledState(false);
60 yoctoUISetting.setUIFormEnabledState(true);
61
62 if (preferencePage instanceof YoctoSDKProjectPropertyPage) {
63 ((YoctoSDKProjectPropertyPage) preferencePage).switchToProjectSpecificProfile();
64 }
65 } else {
66 yoctoConfigurationsSetting.setUIFormEnabledState(true);
67 yoctoConfigurationsSetting.setButtonsEnabledState(false);
68 yoctoUISetting.setUIFormEnabledState(false);
69
70 if (preferencePage instanceof YoctoSDKProjectPropertyPage) {
71 ((YoctoSDKProjectPropertyPage) preferencePage).switchToSelectedProfile();
72 }
73 }
74 }
75
76 @Override
77 public void widgetDefaultSelected(SelectionEvent e) {}
78 });
79 }
80
81 public void setUseProjectSpecificSettings(boolean isUsingProjectSpecificSettings) {
82 btnUseProjectSpecificSettingsCheckbox.setSelection(isUsingProjectSpecificSettings);
83 }
84
85 public boolean isUsingProjectSpecificSettings() {
86 return btnUseProjectSpecificSettingsCheckbox.getSelection();
87 }
88}