Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://dl.bintray.com/contextmapper/context-map-generator-releases/"/>
<unit id="org.contextmapper.contextmap.generator.feature.feature.group" version="1.0.0"/>
<unit id="org.contextmapper.contextmap.generator.feature.feature.group" version="1.0.1"/>
</location>
</locations>
</target>
2 changes: 1 addition & 1 deletion org.contextmapper.dsl.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Require-Bundle: org.contextmapper.dsl,
org.eclipse.xtext.xbase.testing,
org.eclipse.xtext.xbase.lib;bundle-version="2.14.0",
org.apache.commons.io;bundle-version="2.2.0",
org.contextmapper.contextmap.generator;bundle-version="1.0.0"
org.contextmapper.contextmap.generator;bundle-version="1.0.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.contextmapper.dsl.tests;x-internal=true,
org.contextmapper.tactic.dsl.tests;x-internal=true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void canGenerateSVGFile() {

// when
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
this.generator.setContextMapFormat(ContextMapFormat.SVG);
this.generator.setContextMapFormats(ContextMapFormat.SVG);
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());

// then
Expand All @@ -80,7 +80,7 @@ void canGenerateDOTFile() {

// when
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
this.generator.setContextMapFormat(ContextMapFormat.DOT);
this.generator.setContextMapFormats(ContextMapFormat.DOT);
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());

// then
Expand Down
30 changes: 12 additions & 18 deletions org.contextmapper.dsl.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -675,27 +675,24 @@
</menuContribution>
<menuContribution locationURI="popup:#TextEditorContext?after=additions">
<menu id="org.contextmapper.dsl.ui.context.menu" label="Context Mapper" icon="icons/cml.png">
<command defaultHandler="org.contextmapper.dsl.ui.handler.MDSLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.MDSLGenerationCommand" style="push">
<command defaultHandler="org.contextmapper.dsl.ui.handler.ContextMapGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.ContextMapGenerationCommand" style="push">
</command>
<command defaultHandler="org.contextmapper.dsl.ui.handler.PlantUMLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.PlantUMLGenerationCommand" style="push">
</command>
<separator
name="org.contextmapper.dsl.ui.separator1" visible="true">
</separator>
<command defaultHandler="org.contextmapper.dsl.ui.handler.ContextMapGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.ContextMapGenerationCommand" style="push">
<command defaultHandler="org.contextmapper.dsl.ui.handler.MDSLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.MDSLGenerationCommand" style="push">
</command>
<separator
name="org.contextmapper.dsl.ui.separator2" visible="true">
</separator>
<command defaultHandler="org.contextmapper.dsl.ui.handler.PlantUMLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.PlantUMLGenerationCommand" style="push">
</command>
<separator
name="org.contextmapper.dsl.ui.separator3" visible="true">
</separator>
<command defaultHandler="org.contextmapper.dsl.ui.handler.ServiceCutterGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.ServiceCutterGenerationCommand" style="push">
</command>
<command defaultHandler="org.contextmapper.dsl.ui.handler.ServiceCutterUserRepresentationsExampleGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.ServiceCutterUserRepresentationsExampleGenerationCommand" style="push">
</command>
<separator
name="org.contextmapper.dsl.ui.separator4" visible="true">
name="org.contextmapper.dsl.ui.separator3" visible="true">
</separator>
<command defaultHandler="org.contextmapper.dsl.ui.handler.XMIGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.XMIGenerationCommand" style="push">
</command>
Expand Down Expand Up @@ -799,7 +796,7 @@
</extension>
<extension point="org.eclipse.ui.commands">
<command name="ServiceCutter: Generate Input File (JSON)" id="org.contextmapper.dsl.ui.handler.ServiceCutterGenerationCommand"></command>
<command name="Generate Graphical Context Map" id="org.contextmapper.dsl.ui.handler.ContextMapGenerationCommand"></command>
<command name="Context Map: Generate Graphical Context Map" id="org.contextmapper.dsl.ui.handler.ContextMapGenerationCommand"></command>
<command name="PlantUML: Generate Diagrams" id="org.contextmapper.dsl.ui.handler.PlantUMLGenerationCommand"></command>
<command name="Save Model as XMI" id="org.contextmapper.dsl.ui.handler.XMIGenerationCommand"></command>
<command name="ServiceCutter: Generate User Representations File (JSON)" id="org.contextmapper.servicecutter.dsl.ui.handler.ServiceCutterUserRepresentationsJSONGenerationCommand"></command>
Expand All @@ -810,7 +807,7 @@
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<menu id="org.contextmapper.dsl.ui.menu" label="Context Mapper" icon="icons/cml.png">
<command defaultHandler="org.contextmapper.dsl.ui.handler.MDSLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.MDSLGenerationCommand" style="push">
<command defaultHandler="org.contextmapper.dsl.ui.handler.ContextMapGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.ContextMapGenerationCommand" style="push">
<visibleWhen checkEnabled="false">
<iterate>
<adapt type="org.eclipse.core.resources.IResource">
Expand All @@ -819,10 +816,7 @@
</iterate>
</visibleWhen>
</command>
<separator
name="org.contextmapper.dsl.ui.separator1" visible="true">
</separator>
<command defaultHandler="org.contextmapper.dsl.ui.handler.ContextMapGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.ContextMapGenerationCommand" style="push">
<command defaultHandler="org.contextmapper.dsl.ui.handler.PlantUMLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.PlantUMLGenerationCommand" style="push">
<visibleWhen checkEnabled="false">
<iterate>
<adapt type="org.eclipse.core.resources.IResource">
Expand All @@ -832,9 +826,9 @@
</visibleWhen>
</command>
<separator
name="org.contextmapper.dsl.ui.separator2" visible="true">
name="org.contextmapper.dsl.ui.separator1" visible="true">
</separator>
<command defaultHandler="org.contextmapper.dsl.ui.handler.PlantUMLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.PlantUMLGenerationCommand" style="push">
<command defaultHandler="org.contextmapper.dsl.ui.handler.MDSLGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.MDSLGenerationCommand" style="push">
<visibleWhen checkEnabled="false">
<iterate>
<adapt type="org.eclipse.core.resources.IResource">
Expand All @@ -844,7 +838,7 @@
</visibleWhen>
</command>
<separator
name="org.contextmapper.dsl.ui.separator3" visible="true">
name="org.contextmapper.dsl.ui.separator2" visible="true">
</separator>
<command defaultHandler="org.contextmapper.dsl.ui.handler.ServiceCutterGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.ServiceCutterGenerationCommand" style="push">
<visibleWhen checkEnabled="false">
Expand Down Expand Up @@ -883,7 +877,7 @@
</visibleWhen>
</command>
<separator
name="org.contextmapper.dsl.ui.separator4" visible="true">
name="org.contextmapper.dsl.ui.separator3" visible="true">
</separator>
<command defaultHandler="org.contextmapper.dsl.ui.handler.XMIGenerationHandler" commandId="org.contextmapper.dsl.ui.handler.XMIGenerationCommand" style="push">
<visibleWhen checkEnabled="false">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.contextmapper.dsl.ui.handler;

import org.contextmapper.dsl.generator.ContextMapGenerator;
import org.contextmapper.dsl.generator.contextmap.ContextMapFormat;
import org.contextmapper.dsl.generator.exception.GeneratorInputException;
import org.contextmapper.dsl.ui.handler.wizard.GenerateContextMapContext;
import org.contextmapper.dsl.ui.handler.wizard.GenerateContextMapWizard;
Expand Down Expand Up @@ -63,7 +64,7 @@ protected void runGeneration(Resource resource, ExecutionEvent event, IFileSyste

GenerateContextMapContext context = new GenerateContextMapContext();
new WizardDialog(HandlerUtil.getActiveShell(event), new GenerateContextMapWizard(context, executionContext -> {
generator.setContextMapFormat(context.getFormat());
generator.setContextMapFormats(context.getFormats().toArray(new ContextMapFormat[context.getFormats().size()]));
generator.setLabelSpacingFactor(context.getLabelSpacingFactor());
if (context.isFixWidth())
generator.setWidth(context.getWidth());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,25 @@
*/
package org.contextmapper.dsl.ui.handler.wizard;

import java.util.Set;

import org.contextmapper.dsl.generator.contextmap.ContextMapFormat;

public class GenerateContextMapContext {

private ContextMapFormat format;
private Set<ContextMapFormat> formats;
private int labelSpacingFactor;
private boolean fixWidth;
private boolean fixHeight;
private int width;
private int height;

public void setFormat(ContextMapFormat format) {
this.format = format;
public void setFormats(Set<ContextMapFormat> formats) {
this.formats = formats;
}

public ContextMapFormat getFormat() {
return format;
public Set<ContextMapFormat> getFormats() {
return formats;
}

public void setLabelSpacingFactor(int labelSpacingFactor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void addPages() {

@Override
public boolean performFinish() {
context.setFormat(page.getSelectedFormat());
context.setFormats(page.getSelectedFormats());
context.setLabelSpacingFactor(page.getLabelSpacingFactor());
context.setFixHeight(page.takeHeight());
context.setFixWidth(page.takeWidth());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,45 @@
*/
package org.contextmapper.dsl.ui.handler.wizard.pages;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.HashSet;
import java.util.Set;

import org.contextmapper.dsl.generator.contextmap.ContextMapFormat;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
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.program.Program;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Spinner;

public class GenerateContextMapWizardPage extends ContextMapperWizardPage {

private Combo formatSelectionCombo;
private Composite container;
private Button widthCheckBox;
private Spinner widthSpinner;
private Button heightCheckBox;
private Spinner heightSpinner;

private ContextMapFormat selectedFormat = ContextMapFormat.PNG;
private Set<ContextMapFormat> selectedFormats;
private int labelSpacingFactor = 5;
private int width = 3600;
private int height = 1500;
private int width = 2000;
private int height = 1000;

public GenerateContextMapWizardPage() {
super("Generate Context Map Configuration Page");
this.selectedFormats = new HashSet<>();
this.selectedFormats.add(ContextMapFormat.PNG);
this.selectedFormats.add(ContextMapFormat.SVG);
this.selectedFormats.add(ContextMapFormat.DOT);
}

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

// name label
Label formatSelectionLabel = new Label(container, SWT.NONE);
formatSelectionLabel.setText("Format:");

// selection field
formatSelectionCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
formatSelectionCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
List<String> selectionStrings = Arrays.asList(ContextMapFormat.values()).stream().map(l -> l.toString()).collect(Collectors.toList());
formatSelectionCombo.setItems(selectionStrings.toArray(new String[selectionStrings.size()]));
formatSelectionCombo.select(selectionStrings.indexOf(ContextMapFormat.PNG.toString()));
formatSelectionCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedFormat = ContextMapFormat.valueOf(formatSelectionCombo.getText());
formatSelectionLabel.setText("Generated formats:");

// format selection checkboxes
Group formatSelectionGroup = new Group(container, SWT.NONE);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
formatSelectionGroup.setLayout(gridLayout);
formatSelectionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

SelectionListener formatSelectionListener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
Button button = ((Button) event.widget);
ContextMapFormat format = ContextMapFormat.valueOf(button.getText());
if (button.getSelection())
selectedFormats.add(format);
else if (selectedFormats.contains(format))
selectedFormats.remove(format);
setPageComplete(isPageComplete());
}
});
};
};

for (ContextMapFormat format : ContextMapFormat.values()) {
Button button = new Button(formatSelectionGroup, SWT.CHECK);
button.setText(format.toString());
button.setSelection(true);
button.addSelectionListener(formatSelectionListener);
}

// fix width to custom value
widthCheckBox = new Button(container, SWT.CHECK);
Expand Down Expand Up @@ -169,11 +184,10 @@ public void handleEvent(Event event) {
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
this.formatSelectionCombo.forceFocus();
}

public ContextMapFormat getSelectedFormat() {
return selectedFormat;
public Set<ContextMapFormat> getSelectedFormats() {
return new HashSet<>(selectedFormats);
}

public int getLabelSpacingFactor() {
Expand All @@ -198,7 +212,7 @@ public int getHeight() {

@Override
public boolean isPageComplete() {
return this.selectedFormat != null;
return this.selectedFormats.size() > 0;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion org.contextmapper.dsl/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Require-Bundle: org.eclipse.xtext,
org.eclipse.emf.henshin.interpreter;bundle-version="1.4.0",
org.apache.commons.io;bundle-version="2.2.0",
org.freemarker;bundle-version="2.3.22",
org.contextmapper.contextmap.generator;bundle-version="1.0.0",
org.contextmapper.contextmap.generator;bundle-version="1.0.1",
org.apache.commons.lang3;bundle-version="3.9.0",
org.slf4j.api,
org.apache.commons.exec;bundle-version="1.3.0",
Expand Down
2 changes: 1 addition & 1 deletion org.contextmapper.dsl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.9'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.9.9'
compile group: 'org.contextmapper', name: 'henshin-interpreter', version: '1.4.0'
compile group: 'org.contextmapper', name: 'context-map-generator', version: '1.0.0'
compile group: 'org.contextmapper', name: 'context-map-generator', version: '1.0.1'
}
configurations {
mwe2 {
Expand Down
Loading