Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0c490e9

Browse files
committed
Markdown support
- Add com.archimatetool.markdown plug-in - Add preview tab in Property Documentation and Purpose sections - Render in Jasper and HTML reports - Add a DocumentationRenderer#setRenderMarkdown(). This uses a org.commonmark.renderer.text.TextContentRenderer to strip out MD - Very limited support of rendering HTML in Jasper Reports so use a org.commonmark.renderer.text.TextContentRenderer
1 parent a892a83 commit 0c490e9

50 files changed

Lines changed: 694 additions & 154 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

com.archimatetool.canvas/META-INF/MANIFEST.MF

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Require-Bundle: org.eclipse.core.runtime,
1414
org.eclipse.ui.views.properties.tabbed,
1515
com.archimatetool.editor,
1616
com.archimatetool.jdom,
17+
com.archimatetool.markdown,
1718
com.archimatetool.templates
1819
Bundle-ClassPath: com.archimatetool.canvas.jar
1920
Bundle-Activator: com.archimatetool.canvas.CanvasEditorPlugin

com.archimatetool.editor.feature/feature.xml

Lines changed: 16 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -38,152 +38,98 @@ OTHER DEALINGS IN THE SOFTWARE.
3838

3939
<plugin
4040
id="com.archimatetool.canvas"
41-
download-size="0"
42-
install-size="0"
4341
version="0.0.0"/>
4442

4543
<plugin
4644
id="com.archimatetool.csv"
47-
download-size="0"
48-
install-size="0"
49-
version="0.0.0"
50-
unpack="false"/>
45+
version="0.0.0"/>
5146

5247
<plugin
5348
id="com.archimatetool.editor"
54-
download-size="0"
55-
install-size="0"
5649
version="0.0.0"/>
5750

5851
<plugin
5952
id="com.archimatetool.editor.themes"
60-
download-size="0"
61-
install-size="0"
6253
version="0.0.0"/>
6354

6455
<plugin
6556
id="com.archimatetool.export.svg"
66-
download-size="0"
67-
install-size="0"
6857
version="0.0.0"/>
6958

7059
<plugin
7160
id="com.archimatetool.hammer"
72-
download-size="0"
73-
install-size="0"
74-
version="0.0.0"
75-
unpack="false"/>
61+
version="0.0.0"/>
7662

7763
<plugin
7864
id="com.archimatetool.help"
79-
download-size="0"
80-
install-size="0"
8165
version="0.0.0"/>
8266

8367
<plugin
8468
id="com.archimatetool.jasperreports"
85-
download-size="0"
86-
install-size="0"
8769
version="0.0.0"/>
8870

8971
<plugin
9072
id="com.archimatetool.jdom"
91-
download-size="0"
92-
install-size="0"
9373
version="0.0.0"/>
9474

9575
<plugin
9676
id="com.archimatetool.model"
97-
download-size="0"
98-
install-size="0"
9977
version="0.0.0"/>
10078

10179
<plugin
10280
id="com.archimatetool.reports"
103-
download-size="0"
104-
install-size="0"
10581
version="0.0.0"/>
10682

10783
<plugin
10884
id="com.archimatetool.templates"
109-
download-size="0"
110-
install-size="0"
11185
version="0.0.0"/>
11286

11387
<plugin
11488
id="com.archimatetool.widgets"
115-
download-size="0"
116-
install-size="0"
11789
version="0.0.0"/>
11890

11991
<plugin
12092
id="com.archimatetool.zest"
121-
download-size="0"
122-
install-size="0"
123-
version="0.0.0"
124-
unpack="false"/>
93+
version="0.0.0"/>
12594

12695
<plugin
12796
id="com.archimatetool.editor.browser"
128-
download-size="0"
129-
install-size="0"
130-
version="0.0.0"
131-
unpack="false"/>
97+
version="0.0.0"/>
13298

13399
<plugin
134100
id="com.archimatetool.commandline"
135-
download-size="0"
136-
install-size="0"
137-
version="0.0.0"
138-
unpack="false"/>
101+
version="0.0.0"/>
139102

140103
<plugin
141104
id="com.archimatetool.reports.commandline"
142-
download-size="0"
143-
install-size="0"
144-
version="0.0.0"
145-
unpack="false"/>
105+
version="0.0.0"/>
146106

147107
<plugin
148108
id="com.archimatetool.csv.commandline"
149-
download-size="0"
150-
install-size="0"
151-
version="0.0.0"
152-
unpack="false"/>
109+
version="0.0.0"/>
153110

154111
<plugin
155112
id="com.archimatetool.jasperreports.commandline"
156-
download-size="0"
157-
install-size="0"
158-
version="0.0.0"
159-
unpack="false"/>
113+
version="0.0.0"/>
160114

161115
<plugin
162116
id="org.opengroup.archimate.xmlexchange"
163-
download-size="0"
164-
install-size="0"
165-
version="0.0.0"
166-
unpack="false"/>
117+
version="0.0.0"/>
167118

168119
<plugin
169120
id="org.opengroup.archimate.xmlexchange.commandline"
170-
download-size="0"
171-
install-size="0"
172-
version="0.0.0"
173-
unpack="false"/>
121+
version="0.0.0"/>
174122

175123
<plugin
176124
id="com.archimatetool.modelimporter"
177-
download-size="0"
178-
install-size="0"
179-
version="0.0.0"
180-
unpack="false"/>
125+
version="0.0.0"/>
181126

182127
<plugin
183128
id="com.archimatetool.modelimporter.commandline"
184-
download-size="0"
185-
install-size="0"
186-
version="0.0.0"
187-
unpack="false"/>
129+
version="0.0.0"/>
130+
131+
<plugin
132+
id="com.archimatetool.markdown"
133+
version="0.0.0"/>
188134

189135
</feature>

com.archimatetool.editor/META-INF/MANIFEST.MF

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Require-Bundle: org.eclipse.core.runtime,
1818
org.eclipse.ui.views.properties.tabbed;visibility:=reexport,
1919
com.archimatetool.model;visibility:=reexport,
2020
com.archimatetool.jdom,
21+
com.archimatetool.markdown,
2122
com.archimatetool.widgets,
2223
org.eclipse.e4.core.services,
2324
org.eclipse.e4.core.contexts,

com.archimatetool.editor/src/com/archimatetool/editor/propertysections/AbstractECorePropertySection.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,23 @@ protected PropertySectionTextControl createDocumentationControl(Composite parent
288288
return createDocumentationPropertySectionTextControl(styledTextControl.getControl());
289289
}
290290

291+
/**
292+
* Create a Documentation Markdown control
293+
*/
294+
protected MarkdownControl createDocumentationMarkdownControl(Composite parent, String hint) {
295+
// Label
296+
createLabel(parent, Messages.AbstractECorePropertySection_2, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.NONE);
297+
298+
MarkdownControl markDownControl = new MarkdownControl(parent, this, Messages.AbstractNameDocumentationSection_1) {
299+
@Override
300+
protected PropertySectionTextControl createPropertySectionTextControl(StyledTextControl styledTextControl) {
301+
return createDocumentationPropertySectionTextControl(styledTextControl.getControl());
302+
}
303+
};
304+
305+
return markDownControl;
306+
}
307+
291308
/**
292309
* Create a PropertySectionTextControl for Documentation
293310
*/

com.archimatetool.editor/src/com/archimatetool/editor/propertysections/AbstractNameDocumentationSection.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public abstract class AbstractNameDocumentationSection extends AbstractECoreProp
2323
private static final String HELP_ID = "com.archimatetool.help.elementPropertySection"; //$NON-NLS-1$
2424

2525
protected PropertySectionTextControl fTextName;
26-
protected PropertySectionTextControl fTextDocumentation;
26+
protected MarkdownControl documentationMarkdownControl;
2727

2828
@Override
2929
protected void createControls(Composite parent) {
3030
fTextName = createNameControl(parent, Messages.AbstractNameDocumentationSection_0);
31-
fTextDocumentation = createDocumentationControl(parent, Messages.AbstractNameDocumentationSection_1);
32-
31+
documentationMarkdownControl = createDocumentationMarkdownControl(parent, Messages.AbstractNameDocumentationSection_1);
32+
3333
// Help ID
3434
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
3535
}
@@ -73,12 +73,21 @@ protected void refreshDocumentationField() {
7373
return;
7474
}
7575

76-
fTextDocumentation.refresh(getFirstSelectedObject());
77-
fTextDocumentation.setEditable(!isLocked(getFirstSelectedObject()));
76+
documentationMarkdownControl.update();
7877
}
7978

8079
@Override
8180
public boolean shouldUseExtraSpace() {
8281
return true;
8382
}
83+
84+
@Override
85+
public void dispose() {
86+
super.dispose();
87+
88+
if(documentationMarkdownControl != null) {
89+
documentationMarkdownControl.dispose();
90+
documentationMarkdownControl = null;
91+
}
92+
}
8493
}

com.archimatetool.editor/src/com/archimatetool/editor/propertysections/ArchimateModelSection.java

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public Class<?> getAdaptableType() {
4848

4949
private PropertySectionTextControl fTextName;
5050
private Text fTextFile;
51-
private PropertySectionTextControl fTextPurpose;
51+
private MarkdownControl purposeMarkdownControl;
5252

5353
@Override
5454
protected void createControls(Composite parent) {
@@ -72,22 +72,23 @@ private void createPurposeControl(Composite parent) {
7272
// Label
7373
createLabel(parent, Messages.ArchimateModelSection_2, STANDARD_LABEL_WIDTH, SWT.NONE);
7474

75-
// Text
76-
StyledTextControl styledTextControl = createStyledTextControl(parent, SWT.BORDER);
77-
styledTextControl.setMessage(Messages.ArchimateModelSection_4);
78-
79-
fTextPurpose = new PropertySectionTextControl(styledTextControl.getControl(), IArchimatePackage.Literals.ARCHIMATE_MODEL__PURPOSE) {
75+
purposeMarkdownControl = new MarkdownControl(parent, this, Messages.ArchimateModelSection_4) {
8076
@Override
81-
protected void textChanged(String oldText, String newText) {
82-
EObject model = getFirstSelectedObject();
77+
protected PropertySectionTextControl createPropertySectionTextControl(StyledTextControl styledTextControl) {
78+
return new PropertySectionTextControl(styledTextControl.getControl(), IArchimatePackage.Literals.ARCHIMATE_MODEL__PURPOSE) {
79+
@Override
80+
protected void textChanged(String oldText, String newText) {
81+
EObject model = getFirstSelectedObject();
8382

84-
if(isAlive(model)) {
85-
Command cmd = new EObjectFeatureCommand(Messages.ArchimateModelSection_3, getFirstSelectedObject(),
86-
IArchimatePackage.Literals.ARCHIMATE_MODEL__PURPOSE, newText);
87-
if(cmd.canExecute()) {
88-
executeCommand(cmd);
83+
if(isAlive(model)) {
84+
Command cmd = new EObjectFeatureCommand(Messages.ArchimateModelSection_3, getFirstSelectedObject(),
85+
IArchimatePackage.Literals.ARCHIMATE_MODEL__PURPOSE, newText);
86+
if(cmd.canExecute()) {
87+
executeCommand(cmd);
88+
}
89+
}
8990
}
90-
}
91+
};
9192
}
9293
};
9394
}
@@ -139,7 +140,8 @@ protected void refreshPurposeField() {
139140
if(isExecutingCommand()) {
140141
return;
141142
}
142-
fTextPurpose.refresh(getFirstSelectedObject());
143+
144+
purposeMarkdownControl.update();
143145
}
144146

145147
@Override
@@ -151,4 +153,14 @@ protected IObjectFilter getFilter() {
151153
public boolean shouldUseExtraSpace() {
152154
return true;
153155
}
156+
157+
@Override
158+
public void dispose() {
159+
super.dispose();
160+
161+
if(purposeMarkdownControl != null) {
162+
purposeMarkdownControl.dispose();
163+
purposeMarkdownControl = null;
164+
}
165+
}
154166
}

com.archimatetool.editor/src/com/archimatetool/editor/propertysections/DiagramModelImageSection.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
public class DiagramModelImageSection extends ImageChooserSection {
2323

24-
private PropertySectionTextControl fTextDocumentation;
24+
private MarkdownControl documentationMarkdownControl;
2525

2626
/**
2727
* Filter to show or reject this section depending on input value
@@ -41,7 +41,7 @@ public Class<?> getAdaptableType() {
4141
@Override
4242
protected void createControls(Composite parent) {
4343
createImageButton(parent);
44-
fTextDocumentation = createDocumentationControl(parent, Messages.AbstractNameDocumentationSection_1);
44+
documentationMarkdownControl = createDocumentationMarkdownControl(parent, Messages.AbstractNameDocumentationSection_1);
4545

4646
// Help
4747
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
@@ -63,8 +63,7 @@ protected void refreshDocumentationField() {
6363
return;
6464
}
6565

66-
fTextDocumentation.refresh(getFirstSelectedObject());
67-
fTextDocumentation.setEditable(!isLocked(getFirstSelectedObject()));
66+
documentationMarkdownControl.update();
6867
}
6968

7069
@Override
@@ -84,4 +83,13 @@ public boolean shouldUseExtraSpace() {
8483
return true;
8584
}
8685

86+
@Override
87+
public void dispose() {
88+
super.dispose();
89+
90+
if(documentationMarkdownControl != null) {
91+
documentationMarkdownControl.dispose();
92+
documentationMarkdownControl = null;
93+
}
94+
}
8795
}

0 commit comments

Comments
 (0)