Skip to content

Commit 26bb87b

Browse files
author
jan
committed
Add page to set the configuration to be shared
1 parent ed95508 commit 26bb87b

File tree

10 files changed

+190
-37
lines changed

10 files changed

+190
-37
lines changed

io.sloeber.autoBuild.ui/OSGI-INF/l10n/bundle.properties

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ Tool.Manager.tooltip=Use this tab to change the tools used to build the project
1616
Tool.settings=Tool Settings
1717
Build.steps=Build Steps
1818
Binary.parsers=Binary Parsers
19-
Error.parsers=Error Parsers
19+
Error.parsers=Error Parsers
20+
21+
Team.name=Team
2022

2123

2224
category.build.name=C/C++ Build

io.sloeber.autoBuild.ui/plugin.xml

+27-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
value="io.sloeber.autoBuildNature"/>
3636
</adapt>
3737
</enabledWhen>
38-
</page>
38+
</page>
3939
<page
4040
class="io.sloeber.autoBuild.ui.pages.Page_Variables"
4141
id="io.sloeber.autoBuild.projectProperties.macro"
@@ -103,7 +103,7 @@
103103
</enabledWhen>
104104

105105
</page>
106-
106+
107107
<page
108108
category="org.eclipse.cdt.ui.newui.Page_head_general"
109109
class="io.sloeber.autoBuild.ui.pages.Page_PathAndSymb"
@@ -120,6 +120,21 @@
120120
</adapt>
121121
</enabledWhen>
122122
</page>
123+
<page
124+
category="io.sloeber.autoBuild.projectProperties.main"
125+
class="io.sloeber.autoBuild.ui.pages.Page_Team"
126+
id="io.sloeber.autoBuild.ui.pages.Team"
127+
name="%Team.name">
128+
<enabledWhen>
129+
<adapt
130+
type="org.eclipse.core.resources.IProject">
131+
<test
132+
property="org.eclipse.core.resources.projectNature"
133+
value="io.sloeber.autoBuildNature">
134+
</test>
135+
</adapt>
136+
</enabledWhen>
137+
</page>
123138

124139
</extension>
125140
<extension
@@ -248,14 +263,20 @@
248263
class="org.eclipse.cdt.ui.newui.CLocationSourceTab"
249264
icon="icons/obj16/sroot_obj.gif"
250265
name="%Source.location"
251-
weight="080"
266+
weight="080"
252267
helpId="cdt_u_prop_pns_src"
253268
parent="io.sloeber.autoBuild.ui.pages.Page_PathAndSymb"/>
269+
<tab
270+
class="io.sloeber.autoBuild.ui.tabs.TeamSharedTab"
271+
name="other options"
272+
parent="io.sloeber.autoBuild.ui.pages.Page_Team"
273+
weight="030">
274+
</tab>
254275
</extension>
255-
276+
256277
</plugin>
257278

258279

259280

260-
261-
281+
282+

io.sloeber.autoBuild.ui/src/io/sloeber/autoBuild/ui/internal/Messages.java

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
public class Messages extends NLS {
66
private static final String BUNDLE_NAME = "io.sloeber.autoBuild.ui.internal.messages"; //$NON-NLS-1$
77

8+
public static String ShareConfigTitle ;
9+
810
public static String NewAutoMakeProjectWizard_WindowTitle;
911
public static String NewAutoMakeProjectWizard_Description;
1012
public static String NewAutoMakeProjectWizard_PageTitle;
@@ -310,6 +312,8 @@ public class Messages extends NLS {
310312
public static String TemplateWizard_Generating;
311313
public static String TemplateWizard_InternalError;
312314

315+
public static String shareConfigButton;
316+
313317
static {
314318
// initialize resource bundle
315319
NLS.initializeMessages(BUNDLE_NAME, Messages.class);

io.sloeber.autoBuild.ui/src/io/sloeber/autoBuild/ui/internal/messages.properties

+26-24
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# Generated makefile builder messages
1616
NewAutoMakeProjectWizard_WindowTitle = Create project with automagically created makefile.
17-
NewAutoMakeProjectWizard_Description=Use this wizard to create a C/C++ project that can be build automagically
17+
NewAutoMakeProjectWizard_Description=Use this wizard to create a C/C++ project that can be build automagically
1818
NewAutoMakeProjectWizard_PageTitle=Project creation Wizard for autoBuild
1919

2020
BuildBehaviourTab_Use_custom_build_arguments=Use custom build arguments
@@ -314,29 +314,29 @@ GCCBuildCommandParserOptionPage_Project=Project (use when settings are the same
314314
GCCBuildCommandParserOptionPage_ResolvePaths=Use heuristics to resolve paths
315315

316316

317-
CDTCommonProjectWizard_creatingProject = CDTCommonProjectWizard_creatingProject
318-
CDTCommonProjectWizard_0 = CDTCommonProjectWizard_0
319-
CDTCommonProjectWizard_1 = CDTCommonProjectWizard_1
317+
CDTCommonProjectWizard_creatingProject = CDTCommonProjectWizard_creatingProject
318+
CDTCommonProjectWizard_0 = CDTCommonProjectWizard_0
319+
CDTCommonProjectWizard_1 = CDTCommonProjectWizard_1
320320
NewModelProjectWizard_0 = NewModelProjectWizard_0
321-
NewModelProjectWizard_1 = NewModelProjectWizard_1
322-
CMainWizardPage_0 = CMainWizardPage_0
323-
CMainWizardPage_1 = CMainWizardPage_1
324-
CDTMainWizardPage_0 = CDTMainWizardPage_0
325-
CDTMainWizardPage_1 = Project category is selected. Expand the category and select a concrete project type.
326-
CMainWizardPage_3 = CMainWizardPage_3
327-
CMainWizardPage_5 = CMainWizardPage_5
328-
CMainWizardPage_6 = CMainWizardPage_6
329-
CDTMainWizardPage_DefaultProjectCategory = Executable
330-
CDTMainWizardPage_DefaultProjectType = Empty Project
331-
CMainWizardPage_10 = Show project types and toolchains only if they are supported on the platform
332-
CMainWizardPage_7 = CMainWizardPage_7
333-
CMainWizardPage_DirReadOnlyError = CMainWizardPage_DirReadOnlyError
334-
NewModelProjectWizard_2 = C++ Project
335-
NewModelProjectWizard_3 = Create C++ project of selected type
336-
CCProjectWizard_0 = Add CC Project Nature
337-
NewModelProjectWizard_4 = NewModelProjectWizard_4
338-
NewModelProjectWizard_5 = NewModelProjectWizard_5
339-
CProjectWizard_0 = CProjectWizard_0
321+
NewModelProjectWizard_1 = NewModelProjectWizard_1
322+
CMainWizardPage_0 = CMainWizardPage_0
323+
CMainWizardPage_1 = CMainWizardPage_1
324+
CDTMainWizardPage_0 = CDTMainWizardPage_0
325+
CDTMainWizardPage_1 = Project category is selected. Expand the category and select a concrete project type.
326+
CMainWizardPage_3 = CMainWizardPage_3
327+
CMainWizardPage_5 = CMainWizardPage_5
328+
CMainWizardPage_6 = CMainWizardPage_6
329+
CDTMainWizardPage_DefaultProjectCategory = Executable
330+
CDTMainWizardPage_DefaultProjectType = Empty Project
331+
CMainWizardPage_10 = Show project types and toolchains only if they are supported on the platform
332+
CMainWizardPage_7 = CMainWizardPage_7
333+
CMainWizardPage_DirReadOnlyError = CMainWizardPage_DirReadOnlyError
334+
NewModelProjectWizard_2 = C++ Project
335+
NewModelProjectWizard_3 = Create C++ project of selected type
336+
CCProjectWizard_0 = Add CC Project Nature
337+
NewModelProjectWizard_4 = NewModelProjectWizard_4
338+
NewModelProjectWizard_5 = NewModelProjectWizard_5
339+
CProjectWizard_0 = CProjectWizard_0
340340

341341

342342
ProjectImportConfigurator_Checking=Checking: {0}
@@ -345,4 +345,6 @@ TemplateWizard_ErrorCreating=Error Creating Project
345345
TemplateWizard_FailedToOpen=Failed to open editor
346346
TemplateWizard_Generating=Generating
347347
TemplateWizard_InternalError=Internal Error:
348-
348+
349+
shareConfigButton=Share configuration
350+
ShareConfigTitle=Share settings
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.sloeber.autoBuild.ui.pages;
2+
3+
import org.eclipse.cdt.ui.newui.AbstractPage;
4+
5+
public class Page_Team extends AbstractPage {
6+
7+
@Override
8+
protected boolean isSingle() {
9+
return true;
10+
}
11+
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2007, 2011 Intel Corporation and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* Intel Corporation - Initial API and implementation
13+
* IBM Corporation
14+
* Dmitry Kozlov (CodeSourcery) - save build output preferences (bug 294106)
15+
* Andrew Gvozdev (Quoin Inc) - Saving build output implemented in different way (bug 306222)
16+
* Jan Baeyens - adapted and rewritten for autoBuild also removed multiconfig feature
17+
*******************************************************************************/
18+
package io.sloeber.autoBuild.ui.tabs;
19+
20+
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
21+
import org.eclipse.swt.events.SelectionEvent;
22+
import org.eclipse.swt.events.SelectionListener;
23+
import org.eclipse.swt.layout.GridData;
24+
import org.eclipse.swt.layout.GridLayout;
25+
import org.eclipse.swt.widgets.Button;
26+
import org.eclipse.swt.widgets.Composite;
27+
import org.eclipse.swt.widgets.Group;
28+
import io.sloeber.autoBuild.ui.internal.Messages;
29+
30+
/**
31+
* @noextend This class is not intended to be subclassed by clients.
32+
* @noinstantiate This class is not intended to be instantiated by clients.
33+
*/
34+
public class TeamSharedTab extends AbstractAutoBuildPropertyTab {
35+
36+
private Button myShareConfigButton;
37+
38+
@Override
39+
public void createControls(Composite parent) {
40+
super.createControls(parent);
41+
usercomp.setLayout(new GridLayout(1, false));
42+
43+
// Builder group
44+
Group g1 = setupGroup(usercomp, Messages.ShareConfigTitle, 3, GridData.FILL_HORIZONTAL);
45+
myShareConfigButton = setupCheck(g1, Messages.shareConfigButton, 3, GridData.BEGINNING);
46+
myShareConfigButton.addSelectionListener(new SelectionListener() {
47+
48+
@Override
49+
public void widgetSelected(SelectionEvent e) {
50+
myAutoConfDesc.setTeamShared(myShareConfigButton.getSelection());
51+
updateButtons();
52+
}
53+
54+
@Override
55+
public void widgetDefaultSelected(SelectionEvent e) {
56+
// TODO Auto-generated method stub
57+
return;
58+
}
59+
});
60+
61+
}
62+
63+
private void updateDisplayedData() {
64+
myShareConfigButton.setSelection(myAutoConfDesc.isTeamShared());
65+
}
66+
67+
@Override
68+
public void updateData(ICResourceDescription cfgd) {
69+
super.updateData(cfgd);
70+
updateDisplayedData();
71+
}
72+
73+
/**
74+
* sets widgets states
75+
*/
76+
@Override
77+
protected void updateButtons() {
78+
myShareConfigButton.setSelection(myAutoConfDesc.isTeamShared());
79+
}
80+
81+
82+
// This page can be displayed for project only
83+
@Override
84+
public boolean canBeVisible() {
85+
return page.isForProject() || page.isForPrefs();
86+
}
87+
88+
@Override
89+
protected void performDefaults() {
90+
myShareConfigButton.setSelection(false);
91+
}
92+
93+
}

io.sloeber.autoBuild/src/io/sloeber/autoBuild/helpers/api/KeyValueTree.java

+5
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,9 @@ public void mergeFile(File boardsFileName) throws IOException {
226226
}
227227
}
228228

229+
public void removeChild(String name) {
230+
myChildren.remove(name);
231+
232+
}
233+
229234
}

io.sloeber.autoBuild/src/io/sloeber/autoBuild/integration/AutoBuildConfigurationDescription.java

+9
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public class AutoBuildConfigurationDescription extends AutoBuildResourceData
5858
implements IAutoBuildConfigurationDescription {
5959
private static final String KEY_MODEL = "Model"; //$NON-NLS-1$
6060
private static final String KEY_CONFIGURATION = "configuration"; //$NON-NLS-1$
61+
private static final String KEY_TEAM= "team"; //$NON-NLS-1$
62+
private static final String KEY_IS_SHARED= "is shared"; //$NON-NLS-1$
6163
private static final String KEY_PROJECT_TYPE = "projectType"; //$NON-NLS-1$
6264
private static final String KEY_EXTENSION_ID = "extensionID"; //$NON-NLS-1$
6365
private static final String KEY_EXTENSION_POINT_ID = "extensionPointID"; //$NON-NLS-1$
@@ -202,6 +204,7 @@ public AutoBuildConfigurationDescription(ICConfigurationDescription cfgDescripti
202204
myIsValid = base.myIsValid;
203205
myName = myCdtConfigurationDescription.getName();
204206
myDescription = base.myDescription;
207+
myIsTeamShared=base.myIsTeamShared;
205208
myProperties.clear();
206209
myProperties.putAll(base.myProperties);
207210
options_copy(base.mySelectedOptions, mySelectedOptions);
@@ -310,6 +313,8 @@ public AutoBuildConfigurationDescription(ICConfigurationDescription cfgDescripti
310313
KeyValueTree buildToolsKeyValues =keyValues.getChild(KEY_BUILDTOOLS);
311314
KeyValueTree projectTypeKeyValues =modelKeyValues.getChild(KEY_PROJECT_TYPE);
312315
KeyValueTree configKeyValues =modelKeyValues.getChild(KEY_CONFIGURATION);
316+
KeyValueTree teamKeyValues =keyValues.getChild(KEY_TEAM);
317+
myIsTeamShared=Boolean.parseBoolean(teamKeyValues.getValue(KEY_IS_SHARED));
313318

314319
myName=keyValues.getValue(NAME);
315320
myDescription=keyValues.getValue(DESCRIPTION);
@@ -888,6 +893,10 @@ public void serialize(KeyValueTree keyValuePairs) {
888893
final int counterStart = 0;
889894
KeyValueTree modelKeyValue=keyValuePairs.addChild(KEY_MODEL );
890895
KeyValueTree projectTypeKeyValue=modelKeyValue.addChild(KEY_PROJECT_TYPE );
896+
897+
KeyValueTree teamKeyValues =keyValuePairs.addChild(KEY_TEAM);
898+
teamKeyValues.addChild(KEY_IS_SHARED,String.valueOf(myIsTeamShared));
899+
891900
projectTypeKeyValue.addChild( KEY_EXTENSION_POINT_ID , getExtensionPointID());
892901
projectTypeKeyValue.addChild( KEY_EXTENSION_ID , getExtensionID() );
893902
projectTypeKeyValue.addChild( ID, myProjectType.getId() );

io.sloeber.autoBuild/src/io/sloeber/autoBuild/integration/AutoBuildConfigurationDescriptionProvider.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public CConfigurationData applyConfiguration(ICConfigurationDescription cfgDescr
127127
ICProjectDescription projDesc = cfgDescription.getProjectDescription();
128128
IProject iProject = projDesc.getProject();
129129

130-
StringBuffer teamText=new StringBuffer();
130+
131131
Set<String> excludedKeys=new HashSet<>();
132132
KeyValueTree keyValuePairs=KeyValueTree.createRoot();
133133
//Map<ICConfigurationDescription,KeyValuePairs> keyValues=new TreeMap<>();
@@ -158,7 +158,16 @@ public CConfigurationData applyConfiguration(ICConfigurationDescription cfgDescr
158158
if (needsWriting) {
159159
FileUtils.write(projectFile, configText, Charset.defaultCharset());
160160
}
161+
for (ICConfigurationDescription curConfDesc : projDesc.getConfigurations()) {
162+
AutoBuildConfigurationDescription autoBuildConfigBase = (AutoBuildConfigurationDescription) curConfDesc
163+
.getConfigurationData();
164+
165+
if(!autoBuildConfigBase.isTeamShared()) {
166+
keyValuePairs.removeChild(curConfDesc.getName());
167+
}
168+
}
161169
needsWriting = true;
170+
String teamText= keyValuePairs.dump();
162171
if(teamText.length()<2) {
163172
teamFile.delete();
164173
needsWriting=false;
@@ -200,11 +209,8 @@ public CConfigurationData loadConfiguration(ICConfigurationDescription cfgDescri
200209
if (projectFile.exists()) {
201210
KeyValueTree keyValues =KeyValueTree.createRoot();
202211
keyValues.mergeFile(projectFile);
203-
//String curConfigsText = FileUtils.readFileToString(projectFile, Charset.defaultCharset());
204212
if (teamFile.exists()) {
205213
keyValues.mergeFile(teamFile);
206-
// curConfigsText = curConfigsText + NEWLINE
207-
// + FileUtils.readFileToString(teamFile, Charset.defaultCharset());
208214
}
209215
return new AutoBuildConfigurationDescription(cfgDescription, keyValues.getChild( cfgDescription.getName()));
210216
}

io.sloeber.core/src/io/sloeber/core/api/OtherDescription.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.util.TreeMap;
55
import java.util.Map.Entry;
66

7-
import static io.sloeber.autoBuild.helpers.api.AutoBuildConstants.*;
87
import io.sloeber.autoBuild.helpers.api.KeyValueTree;
98
import io.sloeber.core.txt.TxtFile;
109

@@ -17,7 +16,7 @@ public class OtherDescription {
1716

1817
KeyValueTree tree = configFile.getData();
1918
KeyValueTree section = tree.getChild(prefix);
20-
myIsVersionControlled = TRUE.equalsIgnoreCase(section.getValue(KEY_SLOEBER_IS_VERSION_CONTROLLED));
19+
myIsVersionControlled = Boolean.parseBoolean(section.getValue(KEY_SLOEBER_IS_VERSION_CONTROLLED));
2120
}
2221

2322
public OtherDescription() {

0 commit comments

Comments
 (0)