Skip to content

Commit c5da88e

Browse files
authored
Feature/context map generator ui improvements (#153)
1 parent 1eed973 commit c5da88e

File tree

11 files changed

+92
-68
lines changed

11 files changed

+92
-68
lines changed

org.contextmapper.dsl.target/org.contextmapper.dsl.target.target

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
</location>
5656
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
5757
<repository location="https://dl.bintray.com/contextmapper/context-map-generator-releases/"/>
58-
<unit id="org.contextmapper.contextmap.generator.feature.feature.group" version="1.0.0"/>
58+
<unit id="org.contextmapper.contextmap.generator.feature.feature.group" version="1.0.1"/>
5959
</location>
6060
</locations>
6161
</target>

org.contextmapper.dsl.tests/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Require-Bundle: org.contextmapper.dsl,
1313
org.eclipse.xtext.xbase.testing,
1414
org.eclipse.xtext.xbase.lib;bundle-version="2.14.0",
1515
org.apache.commons.io;bundle-version="2.2.0",
16-
org.contextmapper.contextmap.generator;bundle-version="1.0.0"
16+
org.contextmapper.contextmap.generator;bundle-version="1.0.1"
1717
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
1818
Export-Package: org.contextmapper.dsl.tests;x-internal=true,
1919
org.contextmapper.tactic.dsl.tests;x-internal=true,

org.contextmapper.dsl.tests/src/org/contextmapper/dsl/tests/generators/contextmap/ContextMapGeneratorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void canGenerateSVGFile() {
6464

6565
// when
6666
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
67-
this.generator.setContextMapFormat(ContextMapFormat.SVG);
67+
this.generator.setContextMapFormats(ContextMapFormat.SVG);
6868
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
6969

7070
// then
@@ -80,7 +80,7 @@ void canGenerateDOTFile() {
8080

8181
// when
8282
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
83-
this.generator.setContextMapFormat(ContextMapFormat.DOT);
83+
this.generator.setContextMapFormats(ContextMapFormat.DOT);
8484
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
8585

8686
// then

org.contextmapper.dsl.ui/plugin.xml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -675,27 +675,24 @@
675675
</menuContribution>
676676
<menuContribution locationURI="popup:#TextEditorContext?after=additions">
677677
<menu id="org.contextmapper.dsl.ui.context.menu" label="Context Mapper" icon="icons/cml.png">
678-
<command defaultHandler="org.contextmapper.dsl.ui.handler.MDSLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.MDSLGenerationCommand" style="push">
678+
<command defaultHandler="org.contextmapper.dsl.ui.handler.ContextMapGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.ContextMapGenerationCommand" style="push">
679+
</command>
680+
<command defaultHandler="org.contextmapper.dsl.ui.handler.PlantUMLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.PlantUMLGenerationCommand" style="push">
679681
</command>
680682
<separator
681683
name="org.contextmapper.dsl.ui.separator1" visible="true">
682684
</separator>
683-
<command defaultHandler="org.contextmapper.dsl.ui.handler.ContextMapGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.ContextMapGenerationCommand" style="push">
685+
<command defaultHandler="org.contextmapper.dsl.ui.handler.MDSLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.MDSLGenerationCommand" style="push">
684686
</command>
685687
<separator
686688
name="org.contextmapper.dsl.ui.separator2" visible="true">
687689
</separator>
688-
<command defaultHandler="org.contextmapper.dsl.ui.handler.PlantUMLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.PlantUMLGenerationCommand" style="push">
689-
</command>
690-
<separator
691-
name="org.contextmapper.dsl.ui.separator3" visible="true">
692-
</separator>
693690
<command defaultHandler="org.contextmapper.dsl.ui.handler.ServiceCutterGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.ServiceCutterGenerationCommand" style="push">
694691
</command>
695692
<command defaultHandler="org.contextmapper.dsl.ui.handler.ServiceCutterUserRepresentationsExampleGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.ServiceCutterUserRepresentationsExampleGenerationCommand" style="push">
696693
</command>
697694
<separator
698-
name="org.contextmapper.dsl.ui.separator4" visible="true">
695+
name="org.contextmapper.dsl.ui.separator3" visible="true">
699696
</separator>
700697
<command defaultHandler="org.contextmapper.dsl.ui.handler.XMIGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.XMIGenerationCommand" style="push">
701698
</command>
@@ -799,7 +796,7 @@
799796
</extension>
800797
<extension point="org.eclipse.ui.commands">
801798
<command name="ServiceCutter: Generate Input File (JSON)" id="org.contextmapper.dsl.ui.handler.ServiceCutterGenerationCommand"></command>
802-
<command name="Generate Graphical Context Map" id="org.contextmapper.dsl.ui.handler.ContextMapGenerationCommand"></command>
799+
<command name="Context Map: Generate Graphical Context Map" id="org.contextmapper.dsl.ui.handler.ContextMapGenerationCommand"></command>
803800
<command name="PlantUML: Generate Diagrams" id="org.contextmapper.dsl.ui.handler.PlantUMLGenerationCommand"></command>
804801
<command name="Save Model as XMI" id="org.contextmapper.dsl.ui.handler.XMIGenerationCommand"></command>
805802
<command name="ServiceCutter: Generate User Representations File (JSON)" id="org.contextmapper.servicecutter.dsl.ui.handler.ServiceCutterUserRepresentationsJSONGenerationCommand"></command>
@@ -810,7 +807,7 @@
810807
<extension point="org.eclipse.ui.menus">
811808
<menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">
812809
<menu id="org.contextmapper.dsl.ui.menu" label="Context Mapper" icon="icons/cml.png">
813-
<command defaultHandler="org.contextmapper.dsl.ui.handler.MDSLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.MDSLGenerationCommand" style="push">
810+
<command defaultHandler="org.contextmapper.dsl.ui.handler.ContextMapGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.ContextMapGenerationCommand" style="push">
814811
<visibleWhen checkEnabled="false">
815812
<iterate>
816813
<adapt type="org.eclipse.core.resources.IResource">
@@ -819,10 +816,7 @@
819816
</iterate>
820817
</visibleWhen>
821818
</command>
822-
<separator
823-
name="org.contextmapper.dsl.ui.separator1" visible="true">
824-
</separator>
825-
<command defaultHandler="org.contextmapper.dsl.ui.handler.ContextMapGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.ContextMapGenerationCommand" style="push">
819+
<command defaultHandler="org.contextmapper.dsl.ui.handler.PlantUMLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.PlantUMLGenerationCommand" style="push">
826820
<visibleWhen checkEnabled="false">
827821
<iterate>
828822
<adapt type="org.eclipse.core.resources.IResource">
@@ -832,9 +826,9 @@
832826
</visibleWhen>
833827
</command>
834828
<separator
835-
name="org.contextmapper.dsl.ui.separator2" visible="true">
829+
name="org.contextmapper.dsl.ui.separator1" visible="true">
836830
</separator>
837-
<command defaultHandler="org.contextmapper.dsl.ui.handler.PlantUMLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.PlantUMLGenerationCommand" style="push">
831+
<command defaultHandler="org.contextmapper.dsl.ui.handler.MDSLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.MDSLGenerationCommand" style="push">
838832
<visibleWhen checkEnabled="false">
839833
<iterate>
840834
<adapt type="org.eclipse.core.resources.IResource">
@@ -844,7 +838,7 @@
844838
</visibleWhen>
845839
</command>
846840
<separator
847-
name="org.contextmapper.dsl.ui.separator3" visible="true">
841+
name="org.contextmapper.dsl.ui.separator2" visible="true">
848842
</separator>
849843
<command defaultHandler="org.contextmapper.dsl.ui.handler.ServiceCutterGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.ServiceCutterGenerationCommand" style="push">
850844
<visibleWhen checkEnabled="false">
@@ -883,7 +877,7 @@
883877
</visibleWhen>
884878
</command>
885879
<separator
886-
name="org.contextmapper.dsl.ui.separator4" visible="true">
880+
name="org.contextmapper.dsl.ui.separator3" visible="true">
887881
</separator>
888882
<command defaultHandler="org.contextmapper.dsl.ui.handler.XMIGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.XMIGenerationCommand" style="push">
889883
<visibleWhen checkEnabled="false">

org.contextmapper.dsl.ui/src/org/contextmapper/dsl/ui/handler/ContextMapGenerationHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.contextmapper.dsl.ui.handler;
1717

1818
import org.contextmapper.dsl.generator.ContextMapGenerator;
19+
import org.contextmapper.dsl.generator.contextmap.ContextMapFormat;
1920
import org.contextmapper.dsl.generator.exception.GeneratorInputException;
2021
import org.contextmapper.dsl.ui.handler.wizard.GenerateContextMapContext;
2122
import org.contextmapper.dsl.ui.handler.wizard.GenerateContextMapWizard;
@@ -63,7 +64,7 @@ protected void runGeneration(Resource resource, ExecutionEvent event, IFileSyste
6364

6465
GenerateContextMapContext context = new GenerateContextMapContext();
6566
new WizardDialog(HandlerUtil.getActiveShell(event), new GenerateContextMapWizard(context, executionContext -> {
66-
generator.setContextMapFormat(context.getFormat());
67+
generator.setContextMapFormats(context.getFormats().toArray(new ContextMapFormat[context.getFormats().size()]));
6768
generator.setLabelSpacingFactor(context.getLabelSpacingFactor());
6869
if (context.isFixWidth())
6970
generator.setWidth(context.getWidth());

org.contextmapper.dsl.ui/src/org/contextmapper/dsl/ui/handler/wizard/GenerateContextMapContext.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,25 @@
1515
*/
1616
package org.contextmapper.dsl.ui.handler.wizard;
1717

18+
import java.util.Set;
19+
1820
import org.contextmapper.dsl.generator.contextmap.ContextMapFormat;
1921

2022
public class GenerateContextMapContext {
2123

22-
private ContextMapFormat format;
24+
private Set<ContextMapFormat> formats;
2325
private int labelSpacingFactor;
2426
private boolean fixWidth;
2527
private boolean fixHeight;
2628
private int width;
2729
private int height;
2830

29-
public void setFormat(ContextMapFormat format) {
30-
this.format = format;
31+
public void setFormats(Set<ContextMapFormat> formats) {
32+
this.formats = formats;
3133
}
3234

33-
public ContextMapFormat getFormat() {
34-
return format;
35+
public Set<ContextMapFormat> getFormats() {
36+
return formats;
3537
}
3638

3739
public void setLabelSpacingFactor(int labelSpacingFactor) {

org.contextmapper.dsl.ui/src/org/contextmapper/dsl/ui/handler/wizard/GenerateContextMapWizard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void addPages() {
4646

4747
@Override
4848
public boolean performFinish() {
49-
context.setFormat(page.getSelectedFormat());
49+
context.setFormats(page.getSelectedFormats());
5050
context.setLabelSpacingFactor(page.getLabelSpacingFactor());
5151
context.setFixHeight(page.takeHeight());
5252
context.setFixWidth(page.takeWidth());

org.contextmapper.dsl.ui/src/org/contextmapper/dsl/ui/handler/wizard/pages/GenerateContextMapWizardPage.java

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,45 @@
1515
*/
1616
package org.contextmapper.dsl.ui.handler.wizard.pages;
1717

18-
import java.util.Arrays;
19-
import java.util.List;
20-
import java.util.stream.Collectors;
18+
import java.util.HashSet;
19+
import java.util.Set;
2120

2221
import org.contextmapper.dsl.generator.contextmap.ContextMapFormat;
2322
import org.eclipse.swt.SWT;
2423
import org.eclipse.swt.events.SelectionAdapter;
2524
import org.eclipse.swt.events.SelectionEvent;
25+
import org.eclipse.swt.events.SelectionListener;
2626
import org.eclipse.swt.layout.GridData;
2727
import org.eclipse.swt.layout.GridLayout;
2828
import org.eclipse.swt.program.Program;
2929
import org.eclipse.swt.widgets.Button;
30-
import org.eclipse.swt.widgets.Combo;
3130
import org.eclipse.swt.widgets.Composite;
3231
import org.eclipse.swt.widgets.Event;
32+
import org.eclipse.swt.widgets.Group;
3333
import org.eclipse.swt.widgets.Label;
3434
import org.eclipse.swt.widgets.Listener;
3535
import org.eclipse.swt.widgets.Scale;
3636
import org.eclipse.swt.widgets.Spinner;
3737

3838
public class GenerateContextMapWizardPage extends ContextMapperWizardPage {
3939

40-
private Combo formatSelectionCombo;
4140
private Composite container;
4241
private Button widthCheckBox;
4342
private Spinner widthSpinner;
4443
private Button heightCheckBox;
4544
private Spinner heightSpinner;
4645

47-
private ContextMapFormat selectedFormat = ContextMapFormat.PNG;
46+
private Set<ContextMapFormat> selectedFormats;
4847
private int labelSpacingFactor = 5;
49-
private int width = 3600;
50-
private int height = 1500;
48+
private int width = 2000;
49+
private int height = 1000;
5150

5251
public GenerateContextMapWizardPage() {
5352
super("Generate Context Map Configuration Page");
53+
this.selectedFormats = new HashSet<>();
54+
this.selectedFormats.add(ContextMapFormat.PNG);
55+
this.selectedFormats.add(ContextMapFormat.SVG);
56+
this.selectedFormats.add(ContextMapFormat.DOT);
5457
}
5558

5659
@Override
@@ -73,21 +76,33 @@ public void createControl(Composite parent) {
7376

7477
// name label
7578
Label formatSelectionLabel = new Label(container, SWT.NONE);
76-
formatSelectionLabel.setText("Format:");
77-
78-
// selection field
79-
formatSelectionCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
80-
formatSelectionCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
81-
List<String> selectionStrings = Arrays.asList(ContextMapFormat.values()).stream().map(l -> l.toString()).collect(Collectors.toList());
82-
formatSelectionCombo.setItems(selectionStrings.toArray(new String[selectionStrings.size()]));
83-
formatSelectionCombo.select(selectionStrings.indexOf(ContextMapFormat.PNG.toString()));
84-
formatSelectionCombo.addSelectionListener(new SelectionAdapter() {
85-
@Override
86-
public void widgetSelected(SelectionEvent e) {
87-
selectedFormat = ContextMapFormat.valueOf(formatSelectionCombo.getText());
79+
formatSelectionLabel.setText("Generated formats:");
80+
81+
// format selection checkboxes
82+
Group formatSelectionGroup = new Group(container, SWT.NONE);
83+
GridLayout gridLayout = new GridLayout();
84+
gridLayout.numColumns = 3;
85+
formatSelectionGroup.setLayout(gridLayout);
86+
formatSelectionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
87+
88+
SelectionListener formatSelectionListener = new SelectionAdapter() {
89+
public void widgetSelected(SelectionEvent event) {
90+
Button button = ((Button) event.widget);
91+
ContextMapFormat format = ContextMapFormat.valueOf(button.getText());
92+
if (button.getSelection())
93+
selectedFormats.add(format);
94+
else if (selectedFormats.contains(format))
95+
selectedFormats.remove(format);
8896
setPageComplete(isPageComplete());
89-
}
90-
});
97+
};
98+
};
99+
100+
for (ContextMapFormat format : ContextMapFormat.values()) {
101+
Button button = new Button(formatSelectionGroup, SWT.CHECK);
102+
button.setText(format.toString());
103+
button.setSelection(true);
104+
button.addSelectionListener(formatSelectionListener);
105+
}
91106

92107
// fix width to custom value
93108
widthCheckBox = new Button(container, SWT.CHECK);
@@ -169,11 +184,10 @@ public void handleEvent(Event event) {
169184
@Override
170185
public void setVisible(boolean visible) {
171186
super.setVisible(visible);
172-
this.formatSelectionCombo.forceFocus();
173187
}
174188

175-
public ContextMapFormat getSelectedFormat() {
176-
return selectedFormat;
189+
public Set<ContextMapFormat> getSelectedFormats() {
190+
return new HashSet<>(selectedFormats);
177191
}
178192

179193
public int getLabelSpacingFactor() {
@@ -198,7 +212,7 @@ public int getHeight() {
198212

199213
@Override
200214
public boolean isPageComplete() {
201-
return this.selectedFormat != null;
215+
return this.selectedFormats.size() > 0;
202216
}
203217

204218
@Override

org.contextmapper.dsl/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Require-Bundle: org.eclipse.xtext,
2121
org.eclipse.emf.henshin.interpreter;bundle-version="1.4.0",
2222
org.apache.commons.io;bundle-version="2.2.0",
2323
org.freemarker;bundle-version="2.3.22",
24-
org.contextmapper.contextmap.generator;bundle-version="1.0.0",
24+
org.contextmapper.contextmap.generator;bundle-version="1.0.1",
2525
org.apache.commons.lang3;bundle-version="3.9.0",
2626
org.slf4j.api,
2727
org.apache.commons.exec;bundle-version="1.3.0",

org.contextmapper.dsl/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies {
99
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.9'
1010
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.9.9'
1111
compile group: 'org.contextmapper', name: 'henshin-interpreter', version: '1.4.0'
12-
compile group: 'org.contextmapper', name: 'context-map-generator', version: '1.0.0'
12+
compile group: 'org.contextmapper', name: 'context-map-generator', version: '1.0.1'
1313
}
1414
configurations {
1515
mwe2 {

0 commit comments

Comments
 (0)