Skip to content

Commit a54cdfd

Browse files
author
jan
committed
Add team exclusion key editing (very badly)
The dialog to add a key is from swing so it doesn'tr work nicely Do not try to cut and paste on windows
1 parent d88d203 commit a54cdfd

File tree

3 files changed

+164
-56
lines changed

3 files changed

+164
-56
lines changed

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

Lines changed: 5 additions & 0 deletions
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+
9+
810
public static String ShareConfigTitle ;
911

1012
public static String NewAutoMakeProjectWizard_WindowTitle;
@@ -313,6 +315,9 @@ public class Messages extends NLS {
313315
public static String TemplateWizard_InternalError;
314316

315317
public static String shareConfigButton;
318+
public static String addExclusion;
319+
public static String removeExclusion;
320+
public static String ProvideExclusionKey ;
316321

317322
static {
318323
// initialize resource bundle

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,6 @@ TemplateWizard_InternalError=Internal Error:
348348

349349
shareConfigButton=Share configuration
350350
ShareConfigTitle=Share settings
351+
addExclusion=Add Exclusion
352+
removeExclusion=Delete Exclusion
353+
ProvideExclusionKey=Provide the exclusion key

io.sloeber.autoBuild.ui/src/io/sloeber/autoBuild/ui/tabs/TeamSharedTab.java

Lines changed: 156 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,25 @@
1717
*******************************************************************************/
1818
package io.sloeber.autoBuild.ui.tabs;
1919

20+
import static io.sloeber.autoBuild.helpers.api.AutoBuildConstants.*;
21+
import java.util.Arrays;
22+
import java.util.Set;
23+
import java.util.TreeSet;
24+
25+
import javax.swing.JFrame;
26+
import javax.swing.JOptionPane;
27+
2028
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
29+
import org.eclipse.swt.SWT;
2130
import org.eclipse.swt.events.SelectionEvent;
2231
import org.eclipse.swt.events.SelectionListener;
2332
import org.eclipse.swt.layout.GridData;
2433
import org.eclipse.swt.layout.GridLayout;
2534
import org.eclipse.swt.widgets.Button;
2635
import org.eclipse.swt.widgets.Composite;
2736
import org.eclipse.swt.widgets.Group;
37+
import org.eclipse.swt.widgets.List;
38+
2839
import io.sloeber.autoBuild.ui.internal.Messages;
2940

3041
/**
@@ -33,61 +44,150 @@
3344
*/
3445
public class TeamSharedTab extends AbstractAutoBuildPropertyTab {
3546

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-
}
47+
private Button myShareConfigButton;
48+
private List myExclusions;
49+
private Button myAddExclusionButton;
50+
private Button myRemoveExclusionButton;
51+
52+
@Override
53+
public void createControls(Composite parent) {
54+
super.createControls(parent);
55+
usercomp.setLayout(new GridLayout(1, false));
56+
57+
// Builder group
58+
Group g1 = setupGroup(usercomp, Messages.ShareConfigTitle, 2,
59+
GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
60+
myShareConfigButton = setupCheck(g1, Messages.shareConfigButton, 2, GridData.BEGINNING);
61+
Group g3 = setupGroup(g1, EMPTY_STR, 1, SWT.FILL | GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
62+
myExclusions = new List(g3, GridData.FILL_BOTH);
63+
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
64+
myExclusions.setLayoutData(gridData);
65+
Group g4 = setupGroup(g1, EMPTY_STR, 1, GridData.VERTICAL_ALIGN_BEGINNING);
66+
67+
int mode = GridData.BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING;
68+
myAddExclusionButton = setupButton(g4, Messages.addExclusion, 1, mode);
69+
myRemoveExclusionButton = setupButton(g4, Messages.removeExclusion, 1, mode);
70+
myExclusions.addSelectionListener(new SelectionListener() {
71+
72+
@Override
73+
public void widgetSelected(SelectionEvent e) {
74+
myRemoveExclusionButton.setEnabled(myExclusions.getSelectionCount() > 0);
75+
76+
}
77+
78+
@Override
79+
public void widgetDefaultSelected(SelectionEvent e) {
80+
// Nothing to be done
81+
82+
}
83+
});
84+
myShareConfigButton.addSelectionListener(new SelectionListener() {
85+
86+
@Override
87+
public void widgetSelected(SelectionEvent e) {
88+
myAutoConfDesc.setTeamShared(myShareConfigButton.getSelection());
89+
updateButtons();
90+
}
91+
92+
@Override
93+
public void widgetDefaultSelected(SelectionEvent e) {
94+
return;
95+
}
96+
});
97+
98+
myRemoveExclusionButton.addSelectionListener(new SelectionListener() {
99+
100+
@Override
101+
public void widgetSelected(SelectionEvent e) {
102+
String[] selected = myExclusions.getSelection();
103+
if (selected.length == 0) {
104+
return;
105+
}
106+
Set<String> allItem = new TreeSet<>(Arrays.asList(myExclusions.getItems()));
107+
allItem.removeAll(Arrays.asList(selected));
108+
myAutoConfDesc.setCustomTeamExclusionKeys(allItem);
109+
updateDisplayedData();
110+
}
111+
112+
@Override
113+
public void widgetDefaultSelected(SelectionEvent e) {
114+
// Nothing to be done
115+
}
116+
});
117+
118+
myAddExclusionButton.addSelectionListener(new SelectionListener() {
119+
120+
@Override
121+
public void widgetSelected(SelectionEvent e) {
122+
JFrame frame = new JFrame();
123+
String text = JOptionPane.showInputDialog(frame, Messages.ProvideExclusionKey);
124+
if (text != null) {
125+
Set<String> exclusiosn = getCustomTeamExclusionKeys();
126+
exclusiosn.add(text);
127+
myAutoConfDesc.setCustomTeamExclusionKeys(exclusiosn);
128+
updateDisplayedData();
129+
}
130+
}
131+
132+
@Override
133+
public void widgetDefaultSelected(SelectionEvent e) {
134+
// nothing to do her
135+
}
136+
});
137+
}
138+
139+
private void updateDisplayedData() {
140+
boolean isShared = myAutoConfDesc.isTeamShared();
141+
myShareConfigButton.setSelection(isShared);
142+
myAddExclusionButton.setEnabled(isShared);
143+
myExclusions.setEnabled(isShared);
144+
myExclusions.removeAll();
145+
if (isShared) {
146+
String prefix=myAutoConfDesc.getCdtConfigurationDescription().getName()+DOT;
147+
Set<String> exclusions = getCustomTeamExclusionKeys();
148+
for (String curExclusion : exclusions) {
149+
myExclusions.add(prefix+curExclusion);
150+
}
151+
myRemoveExclusionButton.setEnabled(myExclusions.getSelectionCount() > 0);
152+
} else {
153+
myRemoveExclusionButton.setEnabled(isShared);
154+
155+
}
156+
}
157+
158+
private Set<String> getCustomTeamExclusionKeys() {
159+
Set<String> ret = myAutoConfDesc.getCustomTeamExclusionKeys();
160+
if (ret == null) {
161+
ret = myAutoConfDesc.getDefaultTeamExclusionKeys();
162+
}
163+
return ret;
164+
}
165+
166+
@Override
167+
public void updateData(ICResourceDescription cfgd) {
168+
super.updateData(cfgd);
169+
updateDisplayedData();
170+
}
171+
172+
/**
173+
* sets widgets states
174+
*/
175+
@Override
176+
protected void updateButtons() {
177+
updateDisplayedData();
178+
}
179+
180+
// This page can be displayed for project only
181+
@Override
182+
public boolean canBeVisible() {
183+
return page.isForProject() || page.isForPrefs();
184+
}
185+
186+
@Override
187+
protected void performDefaults() {
188+
myAutoConfDesc.setTeamShared(false);
189+
myAutoConfDesc.setCustomTeamExclusionKeys(null);
190+
updateDisplayedData();
191+
}
92192

93193
}

0 commit comments

Comments
 (0)