getDiagramInfos(final WorkbenchPartDiagramIntentProviderContext context) {
26 | if (context.getWorkbenchPart() instanceof IEditorPart) {
27 | final IEditorInput editorInput = ((IEditorPart) context.getWorkbenchPart()).getEditorInput();
28 | IClassFile classFile = (IClassFile) editorInput.getAdapter(IClassFile.class);
29 | try {
30 | classFile.open(new NullProgressMonitor());
31 | return Collections.singletonList(new JdtDiagramIntent(Arrays.asList(classFile.getType())));
32 | } catch (final JavaModelException e) {
33 | }
34 | }
35 | return null;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/bundles/no.hal.osgi.emf/src/no/hal/osgi/ExportedPackage.java:
--------------------------------------------------------------------------------
1 | /**
2 | */
3 | package no.hal.osgi;
4 |
5 | import no.hal.osgi.emf.util.Version;
6 |
7 |
8 | /**
9 | *
10 | * A representation of the model object 'Exported Package'.
11 | *
12 | *
13 | *
14 | * The following features are supported:
15 | *
16 | *
17 | * - {@link no.hal.osgi.ExportedPackage#getVersion Version}
18 | *
19 | *
20 | * @see no.hal.osgi.OsgiPackage#getExportedPackage()
21 | * @model
22 | * @generated
23 | */
24 | public interface ExportedPackage extends BundlePackage {
25 | /**
26 | * Returns the value of the 'Version' attribute.
27 | *
28 | *
29 | * If the meaning of the 'Version' containment reference isn't clear,
30 | * there really should be more of a description here...
31 | *
32 | *
33 | * @return the value of the 'Version' attribute.
34 | * @see #setVersion(Version)
35 | * @see no.hal.osgi.OsgiPackage#getExportedPackage_Version()
36 | * @model dataType="no.hal.osgi.Version"
37 | * @generated
38 | */
39 | Version getVersion();
40 |
41 | /**
42 | * Sets the value of the '{@link no.hal.osgi.ExportedPackage#getVersion Version}' attribute.
43 | *
44 | *
45 | * @param value the new value of the 'Version' attribute.
46 | * @see #getVersion()
47 | * @generated
48 | */
49 | void setVersion(Version value);
50 |
51 | } // ExportedPackage
52 |
--------------------------------------------------------------------------------
/bundles/no.hal.osgi.emf/src/no/hal/osgi/BundlePackage.java:
--------------------------------------------------------------------------------
1 | /**
2 | */
3 | package no.hal.osgi;
4 |
5 | import no.hal.osgi.emf.util.QualifiedName;
6 | import org.eclipse.emf.ecore.EObject;
7 |
8 | /**
9 | *
10 | * A representation of the model object 'Bundle Package'.
11 | *
12 | *
13 | *
14 | * The following features are supported:
15 | *
16 | *
17 | * - {@link no.hal.osgi.BundlePackage#getName Name}
18 | *
19 | *
20 | * @see no.hal.osgi.OsgiPackage#getBundlePackage()
21 | * @model abstract="true"
22 | * @generated
23 | */
24 | public interface BundlePackage extends EObject {
25 | /**
26 | * Returns the value of the 'Name' attribute.
27 | *
28 | *
29 | * If the meaning of the 'Name' attribute isn't clear,
30 | * there really should be more of a description here...
31 | *
32 | *
33 | * @return the value of the 'Name' attribute.
34 | * @see #setName(QualifiedName)
35 | * @see no.hal.osgi.OsgiPackage#getBundlePackage_Name()
36 | * @model dataType="no.hal.osgi.QualifiedName"
37 | * @generated
38 | */
39 | QualifiedName getName();
40 |
41 | /**
42 | * Sets the value of the '{@link no.hal.osgi.BundlePackage#getName Name}' attribute.
43 | *
44 | *
45 | * @param value the new value of the 'Name' attribute.
46 | * @see #getName()
47 | * @generated
48 | */
49 | void setName(QualifiedName value);
50 |
51 | } // BundlePackage
52 |
--------------------------------------------------------------------------------
/bundles/net.sourceforge.plantuml.eclipse/src/net/sourceforge/plantuml/eclipse/views/DiagramSourceView.java:
--------------------------------------------------------------------------------
1 | package net.sourceforge.plantuml.eclipse.views;
2 |
3 | import org.eclipse.core.runtime.IProgressMonitor;
4 | import org.eclipse.swt.SWT;
5 | import org.eclipse.swt.widgets.Composite;
6 | import org.eclipse.swt.widgets.Text;
7 |
8 | import net.sourceforge.plantuml.util.DiagramIntent;
9 |
10 | public class DiagramSourceView extends AbstractDiagramSourceView {
11 |
12 | private String diagramText;
13 | private Text diagramTextView;
14 |
15 | @Override
16 | public void createPartControl(final Composite parent) {
17 | diagramTextView = new Text(parent, SWT.MULTI | SWT.V_SCROLL);
18 | diagramTextView.setEditable(false);
19 | super.createPartControl(parent);
20 | }
21 |
22 | @Override
23 | protected void updateDiagramText(final String textDiagram, final DiagramIntent diagramIntent, final IProgressMonitor progressMonitor) {
24 | if (isValidControl(diagramTextView)) {
25 | setDiagramViewStatus(ViewStatus.DIAGRAM_VIEW_TEXT, textDiagram);
26 | this.diagramText = textDiagram;
27 | setDiagramViewStatus(ViewStatus.DIAGRAM_VIEW_DATA, textDiagram);
28 | asyncExec(() -> {
29 | if (isValidControl(diagramTextView)) {
30 | final String text = (textDiagram == null ? "" : textDiagram);
31 | diagramTextView.setText(text);
32 | setDiagramViewStatus(ViewStatus.DIAGRAM_VIEW, text);
33 | }
34 | });
35 | }
36 | }
37 |
38 | @Override
39 | public String getDiagramText() {
40 | return diagramText;
41 | }
42 |
43 | @Override
44 | public void setFocus() {
45 | diagramTextView.setFocus();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/bundles/net.sourceforge.plantuml.eclipse/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: Plantuml Plug-in
4 | Bundle-SymbolicName: net.sourceforge.plantuml.eclipse; singleton:=true
5 | Bundle-Version: 1.1.33.qualifier
6 | Bundle-Activator: net.sourceforge.plantuml.eclipse.Activator
7 | Bundle-Vendor: PlantUML Team
8 | Require-Bundle: org.eclipse.ui.ide;bundle-version="3.10.2",
9 | org.eclipse.ui;bundle-version="3.106.1",
10 | org.eclipse.core.resources;bundle-version="3.9.1",
11 | net.sourceforge.plantuml.lib;bundle-version="1.2024.5"
12 | Bundle-ActivationPolicy: lazy
13 | Bundle-RequiredExecutionEnvironment: JavaSE-17
14 | Import-Package: net.sourceforge.plantuml.eclipse.imagecontrol,
15 | net.sourceforge.plantuml.eclipse.imagecontrol.jface,
16 | net.sourceforge.plantuml.eclipse.imagecontrol.jface.actions,
17 | org.eclipse.core.runtime,
18 | org.eclipse.core.runtime.jobs,
19 | org.eclipse.jface.action,
20 | org.eclipse.jface.dialogs,
21 | org.eclipse.jface.preference,
22 | org.eclipse.jface.resource,
23 | org.eclipse.jface.util,
24 | org.eclipse.jface.viewers,
25 | org.eclipse.swt,
26 | org.eclipse.swt.dnd,
27 | org.eclipse.swt.events,
28 | org.eclipse.swt.graphics,
29 | org.eclipse.swt.layout,
30 | org.eclipse.swt.printing,
31 | org.eclipse.swt.program,
32 | org.eclipse.swt.widgets,
33 | org.eclipse.ui,
34 | org.eclipse.ui.part,
35 | org.eclipse.ui.plugin,
36 | org.osgi.framework;version="1.8.0"
37 | Export-Package: net.sourceforge.plantuml.eclipse,
38 | net.sourceforge.plantuml.eclipse.utils,
39 | net.sourceforge.plantuml.eclipse.views,
40 | net.sourceforge.plantuml.util
41 | Bundle-ClassPath: .
42 |
--------------------------------------------------------------------------------
/tests/net.sourceforge.plantuml.jdt.tests/src/net/sourceforge/plantuml/jdt/test/JavaProjectConfigurer.java:
--------------------------------------------------------------------------------
1 | package net.sourceforge.plantuml.jdt.test;
2 |
3 | import java.lang.reflect.InvocationTargetException;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import org.eclipse.core.resources.IProject;
8 | import org.eclipse.jdt.core.IClasspathEntry;
9 | import org.eclipse.jdt.core.IJavaProject;
10 | import org.eclipse.jdt.core.IPackageFragmentRoot;
11 | import org.eclipse.jdt.core.JavaCore;
12 | import org.eclipse.jdt.core.JavaModelException;
13 | import org.eclipse.jdt.launching.JavaRuntime;
14 |
15 | import net.sourceforge.plantuml.eclipse.test.util.ProjectConfigurer;
16 | import net.sourceforge.plantuml.eclipse.test.util.WorkspaceHelper;
17 |
18 | public class JavaProjectConfigurer implements ProjectConfigurer {
19 |
20 | private final WorkspaceHelper workspaceHelper = new WorkspaceHelper();
21 |
22 | @Override
23 | public void configureProject(final IProject project) throws InvocationTargetException, InterruptedException, JavaModelException {
24 | final IJavaProject javaProject = JavaCore.create(project);
25 |
26 | final List entries = new ArrayList();
27 | entries.add(JavaCore.newContainerEntry(JavaRuntime.newDefaultJREContainerPath().append("org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType").append("JavaSE-1.8")));
28 |
29 | final IPackageFragmentRoot srcRoot = javaProject.getPackageFragmentRoot(workspaceHelper.createFolder(project, "src"));
30 | entries.add(JavaCore.newSourceEntry(srcRoot.getPath()));
31 | //add libs to project class path
32 | javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/tests/net.sourceforge.plantuml.text.tests/src/net/sourceforge/plantuml/text/test/TextEditorDiagramTextProviderTest.java:
--------------------------------------------------------------------------------
1 | package net.sourceforge.plantuml.text.test;
2 |
3 | import org.junit.Test;
4 |
5 | import net.sourceforge.plantuml.eclipse.test.util.AbstractDiagramTextTest;
6 | import net.sourceforge.plantuml.eclipse.utils.PlantumlConstants;
7 | import net.sourceforge.plantuml.text.TextEditorDiagramIntentProvider;
8 |
9 | public class TextEditorDiagramTextProviderTest {
10 |
11 | private final TextEditorDiagramIntentProvider diagramTextProvider = new TextEditorDiagramIntentProvider(PlantumlConstants.START_UML, PlantumlConstants.END_UML);
12 |
13 | private final String toto = PlantumlConstants.START_UML + "\ntoto\n" + PlantumlConstants.END_UML;
14 |
15 | private String getDiagramText(final String s) {
16 | return diagramTextProvider.getDiagramText(s);
17 | }
18 |
19 | @Test
20 | public void testWithoutPrefix() {
21 | AbstractDiagramTextTest.assertDiagramText(toto, getDiagramText(toto));
22 | }
23 |
24 | @Test
25 | public void testWithWrongPrefix() {
26 | AbstractDiagramTextTest.assertDiagramText(PlantumlConstants.START_UML + "\n\n" + PlantumlConstants.END_UML, getDiagramText("toto" + toto));
27 | }
28 |
29 | @Test
30 | public void testWithSimplePrefix() {
31 | AbstractDiagramTextTest.assertDiagramText(toto, getDiagramText(" * " + PlantumlConstants.START_UML + "\n * toto\n * " + PlantumlConstants.END_UML + "\n"));
32 | }
33 |
34 | @Test
35 | public void testWithMixedWhitespacePrefix() {
36 | AbstractDiagramTextTest.assertDiagramText(toto, getDiagramText(" *\t" + PlantumlConstants.START_UML + "\n\t*\ttoto\n * " + PlantumlConstants.END_UML + "\n"));
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/bundles/no.hal.osgi.emf/src/org/osgi/scr/util/ScrResourceFactoryImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | */
3 | package org.osgi.scr.util;
4 |
5 | import org.eclipse.emf.common.util.URI;
6 |
7 | import org.eclipse.emf.ecore.resource.Resource;
8 |
9 | import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
10 |
11 | import org.eclipse.emf.ecore.xmi.XMLResource;
12 |
13 | /**
14 | *
15 | * The Resource Factory associated with the package.
16 | *
17 | * @see org.osgi.scr.util.ScrResourceImpl
18 | * @generated
19 | */
20 | public class ScrResourceFactoryImpl extends ResourceFactoryImpl {
21 | /**
22 | * Creates an instance of the resource factory.
23 | *
24 | *
25 | * @generated
26 | */
27 | public ScrResourceFactoryImpl() {
28 | super();
29 | }
30 |
31 | /**
32 | * Creates an instance of the resource.
33 | *
34 | *
35 | * @generated
36 | */
37 | @Override
38 | public Resource createResource(URI uri) {
39 | XMLResource result = new ScrResourceImpl(uri);
40 | result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
41 | result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
42 |
43 | result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
44 |
45 | result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
46 | result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
47 |
48 | result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
49 | return result;
50 | }
51 |
52 | } //ScrResourceFactoryImpl
53 |
--------------------------------------------------------------------------------
/tests/net.sourceforge.plantuml.text.tests/src/net/sourceforge/plantuml/text/test/TextEditorDiagramTextProviderTest2.java:
--------------------------------------------------------------------------------
1 | package net.sourceforge.plantuml.text.test;
2 |
3 | import org.eclipse.core.resources.IFile;
4 | import org.eclipse.core.runtime.Path;
5 | import org.junit.Before;
6 | import org.junit.Test;
7 |
8 | import net.sourceforge.plantuml.eclipse.test.util.AbstractDiagramTextTest;
9 | import net.sourceforge.plantuml.eclipse.utils.PlantumlConstants;
10 | import net.sourceforge.plantuml.eclipse.views.PlantUmlView;
11 |
12 | public class TextEditorDiagramTextProviderTest2 extends AbstractDiagramTextTest {
13 |
14 | @Before
15 | public void setUpJavaProject() throws Exception {
16 | createProject("texteditortest");
17 | }
18 |
19 | private void testJavaEditorDiagramText(String path, String expected) throws Exception {
20 | String pluginProject = "net.sourceforge.plantuml.text.tests";
21 | IFile file = createFile(new Path("/texteditortest/" + path), getPluginTestFileContents(pluginProject, path));
22 | waitForBuild();
23 | openEditor(file, "org.eclipse.ui.DefaultTextEditor");
24 | PlantUmlView view = openView("net.sourceforge.plantuml.eclipse.views.PlantUmlView", PlantUmlView.class);
25 |
26 | // wait some time, otherwise the view has not been initialized and filled
27 | sleep(1500);
28 |
29 | AbstractDiagramTextTest.assertDiagramText(expected, view.getDiagramText());
30 | }
31 |
32 | @Test
33 | public void testJavaEditorDiagramFromComment() throws Exception {
34 | // TODO Improve this test, sometimes it fails, maybe because of timing issues
35 | testJavaEditorDiagramText("src/net/sourceforge/plantuml/text/test/ClassWithDiagramInComment.java",
36 | PlantumlConstants.START_UML + "\nclass ClassWithDiagramInComment {\n\tint field\n}\n" + PlantumlConstants.END_UML);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/bundles/net.sourceforge.plantuml.eclipse/src/net/sourceforge/plantuml/util/DiagramImageData.java:
--------------------------------------------------------------------------------
1 | package net.sourceforge.plantuml.util;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Collection;
5 |
6 | import org.eclipse.core.runtime.IPath;
7 | import org.eclipse.swt.graphics.ImageData;
8 |
9 | import net.sourceforge.plantuml.eclipse.utils.LinkData;
10 |
11 | public class DiagramImageData {
12 |
13 | private final DiagramData diagramData;
14 | private final int imageNum;
15 |
16 | private ImageData imageData;
17 |
18 | private final Collection links = new ArrayList();
19 |
20 | public DiagramImageData(final DiagramData diagram, final int imageNum, final ImageData imageData) {
21 | super();
22 | this.diagramData = diagram;
23 | this.imageNum = imageNum;
24 | this.imageData = imageData;
25 | }
26 |
27 | public DiagramImageData(final DiagramData diagram, final ImageData imageData) {
28 | this(diagram, 0, imageData);
29 | }
30 |
31 | public DiagramImageData(final DiagramData diagram, final int imageNum) {
32 | this(diagram, imageNum, null);
33 | }
34 |
35 | public DiagramImageData(final DiagramData diagram) {
36 | this(diagram, 0);
37 | }
38 |
39 | public DiagramImageData withImageNum(final int imageNum) {
40 | return new DiagramImageData(diagramData, imageNum);
41 | }
42 |
43 | public DiagramData getDiagramData() {
44 | return diagramData;
45 | }
46 |
47 | public IPath getSourcePath() {
48 | return diagramData.getOriginal();
49 | }
50 |
51 | public int getImageNum() {
52 | return imageNum;
53 | }
54 |
55 | public ImageData getImage() {
56 | if (imageData == null) {
57 | imageData = diagramData.getImage(imageNum, links);
58 | }
59 | return imageData;
60 | }
61 |
62 | public Iterable getLinks() {
63 | return links;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------