Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

first commit

  • Loading branch information...
commit 69216e21c492117bc3fb07cd853c713d75a40556 0 parents
Hiroki Kondo kompiro authored

Showing 48 changed files with 2,850 additions and 0 deletions. Show diff stats Hide diff stats

  1. +1 0  .gitignore
  2. +136 0 Makefile
  3. +38 0 ja.json
  4. +178 0 make.bat
  5. +23 0 source/_snippets/Activator.java
  6. +117 0 source/_snippets/AstahAPIUtils.java
  7. +299 0 source/_snippets/AstahModelUtils.java
  8. +89 0 source/_snippets/ClassDiagramDropExtension.java
  9. +62 0 source/_snippets/CountClassAction.java
  10. +27 0 source/_snippets/HelloWorldAction.java
  11. +91 0 source/_snippets/HelloWorldView.java
  12. +23 0 source/_snippets/plugin_count_class_action.xml
  13. +10 0 source/_snippets/plugin_extraview.xml
  14. +24 0 source/_snippets/plugin_menu.xml
  15. BIN  source/_static/favicon.ico
  16. BIN  source/_static/navigation.png
  17. +371 0 source/_static/sphinxdoc.css
  18. BIN  source/_static/top-bar.png
  19. +40 0 source/_templates/customcover.tmpl
  20. +56 0 source/_templates/search.html
  21. +23 0 source/apilist.rst
  22. +118 0 source/appendixA.rst
  23. +12 0 source/appendixB.rst
  24. +291 0 source/conf.py
  25. +124 0 source/devenv.rst
  26. +99 0 source/example.rst
  27. +68 0 source/extraview.rst
  28. +336 0 source/helloworld.rst
  29. BIN  source/images/Eclipse_settings.png
  30. BIN  source/images/IntelliJ_settings.png
  31. BIN  source/images/added_menu.png
  32. BIN  source/images/added_new_menu.png
  33. BIN  source/images/archtecture.png
  34. BIN  source/images/astah-build-success.png
  35. BIN  source/images/astah-generate-project-success.png
  36. BIN  source/images/astah-generate-project.png
  37. BIN  source/images/astah-launch-success.png
  38. BIN  source/images/extend-view.png
  39. BIN  source/images/installed_plugin.png
  40. BIN  source/images/logo.png
  41. BIN  source/images/plugin-list.png
  42. BIN  source/images/remote-debug.png
  43. BIN  source/images/structure.png
  44. +63 0 source/index.rst
  45. +14 0 source/installplugin.rst
  46. +25 0 source/overview.rst
  47. +26 0 source/releaseplugin.rst
  48. +66 0 source/snippets.rst
1  .gitignore
... ... @@ -0,0 +1 @@
  1 +build/*
136 Makefile
... ... @@ -0,0 +1,136 @@
  1 +# Makefile for Sphinx documentation
  2 +#
  3 +
  4 +# You can set these variables from the command line.
  5 +SPHINXOPTS =
  6 +SPHINXBUILD = sphinx-build
  7 +PAPER =
  8 +BUILDDIR = build
  9 +
  10 +# Internal variables.
  11 +PAPEROPT_a4 = -D latex_paper_size=a4
  12 +PAPEROPT_letter = -D latex_paper_size=letter
  13 +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
  14 +
  15 +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
  16 +
  17 +help:
  18 + @echo "Please use \`make <target>' where <target> is one of"
  19 + @echo " html to make standalone HTML files"
  20 + @echo " dirhtml to make HTML files named index.html in directories"
  21 + @echo " singlehtml to make a single large HTML file"
  22 + @echo " pickle to make pickle files"
  23 + @echo " json to make JSON files"
  24 + @echo " htmlhelp to make HTML files and a HTML help project"
  25 + @echo " qthelp to make HTML files and a qthelp project"
  26 + @echo " devhelp to make HTML files and a Devhelp project"
  27 + @echo " epub to make an epub"
  28 + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
  29 + @echo " latexpdf to make LaTeX files and run them through pdflatex"
  30 + @echo " text to make text files"
  31 + @echo " man to make manual pages"
  32 + @echo " pdf to make PDF file"
  33 + @echo " changes to make an overview of all changed/added/deprecated items"
  34 + @echo " linkcheck to check all external links for integrity"
  35 + @echo " doctest to run all doctests embedded in the documentation (if enabled)"
  36 +
  37 +clean:
  38 + -rm -rf $(BUILDDIR)/*
  39 +
  40 +html:
  41 + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
  42 + @echo
  43 + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
  44 +
  45 +dirhtml:
  46 + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
  47 + @echo
  48 + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
  49 +
  50 +singlehtml:
  51 + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
  52 + @echo
  53 + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
  54 +
  55 +pickle:
  56 + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
  57 + @echo
  58 + @echo "Build finished; now you can process the pickle files."
  59 +
  60 +json:
  61 + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
  62 + @echo
  63 + @echo "Build finished; now you can process the JSON files."
  64 +
  65 +htmlhelp:
  66 + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
  67 + @echo
  68 + @echo "Build finished; now you can run HTML Help Workshop with the" \
  69 + ".hhp project file in $(BUILDDIR)/htmlhelp."
  70 +
  71 +qthelp:
  72 + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
  73 + @echo
  74 + @echo "Build finished; now you can run "qcollectiongenerator" with the" \
  75 + ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
  76 + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/astahPlug-inSDKDocument.qhcp"
  77 + @echo "To view the help file:"
  78 + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/astahPlug-inSDKDocument.qhc"
  79 +
  80 +devhelp:
  81 + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
  82 + @echo
  83 + @echo "Build finished."
  84 + @echo "To view the help file:"
  85 + @echo "# mkdir -p $$HOME/.local/share/devhelp/astahPlug-inSDKDocument"
  86 + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/astahPlug-inSDKDocument"
  87 + @echo "# devhelp"
  88 +
  89 +epub:
  90 + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
  91 + @echo
  92 + @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
  93 +
  94 +latex:
  95 + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
  96 + @echo
  97 + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
  98 + @echo "Run \`make' in that directory to run these through (pdf)latex" \
  99 + "(use \`make latexpdf' here to do that automatically)."
  100 +
  101 +latexpdf:
  102 + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
  103 + @echo "Running LaTeX files through pdflatex..."
  104 + make -C $(BUILDDIR)/latex all-pdf
  105 + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
  106 +
  107 +text:
  108 + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
  109 + @echo
  110 + @echo "Build finished. The text files are in $(BUILDDIR)/text."
  111 +
  112 +man:
  113 + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
  114 + @echo
  115 + @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
  116 +
  117 +changes:
  118 + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
  119 + @echo
  120 + @echo "The overview file is in $(BUILDDIR)/changes."
  121 +
  122 +linkcheck:
  123 + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
  124 + @echo
  125 + @echo "Link check complete; look for any errors in the above output " \
  126 + "or in $(BUILDDIR)/linkcheck/output.txt."
  127 +
  128 +doctest:
  129 + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
  130 + @echo "Testing of doctests in the sources finished, look at the " \
  131 + "results in $(BUILDDIR)/doctest/output.txt."
  132 +
  133 +pdf:
  134 + $(SPHINXBUILD) -b pdf $(ALLSPHINXOPTS) $(BUILDDIR)/pdf
  135 + @echo
  136 + @echo "Build finished; the pdf files are in $(BUILDDIR)/pdf."
38 ja.json
... ... @@ -0,0 +1,38 @@
  1 +{
  2 + "embeddedFonts" :
  3 + [[
  4 + "VL-Gothic-Regular.ttf",
  5 + "VL-PGothic-Regular.ttf"
  6 + ]],
  7 + "fontsAlias" : {
  8 + "stdFont": "VL-PGothic-Regular",
  9 + "stdBold": "VL-PGothic-Regular",
  10 + "stdItalic": "VL-PGothic-Regular",
  11 + "stdBoldItalic": "VL-PGothic-Regular",
  12 + "stdMono": "VL-Gothic-Regular",
  13 + "stdMonoBold": "VL-Gothic-Regular",
  14 + "stdMonoItalic": "VL-Gothic-Regular",
  15 + "stdMonoBoldItalic": "VL-Gothic-Regular"
  16 + },
  17 + "styles" : [
  18 + ["base", {
  19 + "wordWrap": "CJK"
  20 + }],
  21 + ["literal", {
  22 + "wordWrap": "None"
  23 + }],
  24 + ["right", {
  25 + "parent": "bodytext",
  26 + "alignment": "right"
  27 + }],
  28 + ["centered", {
  29 + "parent": "bodytext",
  30 + "alignment": "center"
  31 + }],
  32 + ["headertable" , {
  33 + "parent" : "table",
  34 + "colWidths": ["20%","60%","20%"],
  35 + "commands": []
  36 + }]
  37 + ]
  38 +}
178 make.bat
... ... @@ -0,0 +1,178 @@
  1 +@ECHO OFF
  2 +
  3 +REM Command file for Sphinx documentation
  4 +
  5 +if "%SPHINXBUILD%" == "" (
  6 + set SPHINXBUILD=sphinx-build
  7 +)
  8 +set BUILDDIR=build
  9 +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source
  10 +if NOT "%PAPER%" == "" (
  11 + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
  12 +)
  13 +
  14 +if "%1" == "" goto help
  15 +
  16 +if "%1" == "help" (
  17 + :help
  18 + echo.Please use `make ^<target^>` where ^<target^> is one of
  19 + echo. html to make standalone HTML files
  20 + echo. dirhtml to make HTML files named index.html in directories
  21 + echo. singlehtml to make a single large HTML file
  22 + echo. pickle to make pickle files
  23 + echo. json to make JSON files
  24 + echo. htmlhelp to make HTML files and a HTML help project
  25 + echo. qthelp to make HTML files and a qthelp project
  26 + echo. devhelp to make HTML files and a Devhelp project
  27 + echo. epub to make an epub
  28 + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
  29 + echo. text to make text files
  30 + echo. man to make manual pages
  31 + echo. changes to make an overview over all changed/added/deprecated items
  32 + echo. linkcheck to check all external links for integrity
  33 + echo. doctest to run all doctests embedded in the documentation if enabled
  34 + echo. pdf to make PDF file
  35 + goto end
  36 +)
  37 +
  38 +if "%1" == "clean" (
  39 + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
  40 + del /q /s %BUILDDIR%\*
  41 + goto end
  42 +)
  43 +
  44 +if "%1" == "html" (
  45 + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
  46 + if errorlevel 1 exit /b 1
  47 + echo.
  48 + echo.Build finished. The HTML pages are in %BUILDDIR%/html.
  49 + goto end
  50 +)
  51 +
  52 +if "%1" == "dirhtml" (
  53 + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
  54 + if errorlevel 1 exit /b 1
  55 + echo.
  56 + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
  57 + goto end
  58 +)
  59 +
  60 +if "%1" == "singlehtml" (
  61 + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
  62 + if errorlevel 1 exit /b 1
  63 + echo.
  64 + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
  65 + goto end
  66 +)
  67 +
  68 +if "%1" == "pickle" (
  69 + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
  70 + if errorlevel 1 exit /b 1
  71 + echo.
  72 + echo.Build finished; now you can process the pickle files.
  73 + goto end
  74 +)
  75 +
  76 +if "%1" == "json" (
  77 + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
  78 + if errorlevel 1 exit /b 1
  79 + echo.
  80 + echo.Build finished; now you can process the JSON files.
  81 + goto end
  82 +)
  83 +
  84 +if "%1" == "htmlhelp" (
  85 + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
  86 + if errorlevel 1 exit /b 1
  87 + echo.
  88 + echo.Build finished; now you can run HTML Help Workshop with the ^
  89 +.hhp project file in %BUILDDIR%/htmlhelp.
  90 + goto end
  91 +)
  92 +
  93 +if "%1" == "qthelp" (
  94 + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
  95 + if errorlevel 1 exit /b 1
  96 + echo.
  97 + echo.Build finished; now you can run "qcollectiongenerator" with the ^
  98 +.qhcp project file in %BUILDDIR%/qthelp, like this:
  99 + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\astahPlug-inSDKDocument.qhcp
  100 + echo.To view the help file:
  101 + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\astahPlug-inSDKDocument.ghc
  102 + goto end
  103 +)
  104 +
  105 +if "%1" == "devhelp" (
  106 + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
  107 + if errorlevel 1 exit /b 1
  108 + echo.
  109 + echo.Build finished.
  110 + goto end
  111 +)
  112 +
  113 +if "%1" == "epub" (
  114 + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
  115 + if errorlevel 1 exit /b 1
  116 + echo.
  117 + echo.Build finished. The epub file is in %BUILDDIR%/epub.
  118 + goto end
  119 +)
  120 +
  121 +if "%1" == "latex" (
  122 + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
  123 + if errorlevel 1 exit /b 1
  124 + echo.
  125 + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
  126 + goto end
  127 +)
  128 +
  129 +if "%1" == "text" (
  130 + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
  131 + if errorlevel 1 exit /b 1
  132 + echo.
  133 + echo.Build finished. The text files are in %BUILDDIR%/text.
  134 + goto end
  135 +)
  136 +
  137 +if "%1" == "man" (
  138 + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
  139 + if errorlevel 1 exit /b 1
  140 + echo.
  141 + echo.Build finished. The manual pages are in %BUILDDIR%/man.
  142 + goto end
  143 +)
  144 +
  145 +if "%1" == "changes" (
  146 + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
  147 + if errorlevel 1 exit /b 1
  148 + echo.
  149 + echo.The overview file is in %BUILDDIR%/changes.
  150 + goto end
  151 +)
  152 +
  153 +if "%1" == "linkcheck" (
  154 + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
  155 + if errorlevel 1 exit /b 1
  156 + echo.
  157 + echo.Link check complete; look for any errors in the above output ^
  158 +or in %BUILDDIR%/linkcheck/output.txt.
  159 + goto end
  160 +)
  161 +
  162 +if "%1" == "doctest" (
  163 + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
  164 + if errorlevel 1 exit /b 1
  165 + echo.
  166 + echo.Testing of doctests in the sources finished, look at the ^
  167 +results in %BUILDDIR%/doctest/output.txt.
  168 + goto end
  169 +)
  170 +
  171 +if "%1" == "pdf" (
  172 + %SPHINXBUILD% -b pdf %ALLSPHINXOPTS% %BUILDDIR%/pdf
  173 + if errorlevel 1 exit /b 1
  174 + echo.
  175 + echo.Build finished. The PDF files are in %BUILDDIR%/pdf.
  176 + goto end
  177 +)
  178 +:end
23 source/_snippets/Activator.java
... ... @@ -0,0 +1,23 @@
  1 +package com.example;
  2 +
  3 +import org.osgi.framework.BundleActivator;
  4 +import org.osgi.framework.BundleContext;
  5 +
  6 +import com.example.internal.ClassDiagramDropExtension;
  7 +import com.example.internal.util.AstahAPIUtils;
  8 +import com.change_vision.jude.api.inf.view.IDiagramViewManager;
  9 +
  10 +public class Activator implements BundleActivator {
  11 +
  12 + private AstahAPIUtils utils = new AstahAPIUtils();
  13 +
  14 + public void start(BundleContext context) {
  15 + ClassDiagramDropExtension diagramDropTargetListener = new ClassDiagramDropExtension();
  16 + IDiagramViewManager diagramViewManager = utils.getDiagramViewManager();
  17 + diagramViewManager.addDropTargetListener(diagramDropTargetListener);
  18 + }
  19 +
  20 + public void stop(BundleContext context) {
  21 + }
  22 +
  23 +}
117 source/_snippets/AstahAPIUtils.java
... ... @@ -0,0 +1,117 @@
  1 +/*
  2 + * Please change this class's package to your genearated Plug-in's package.
  3 + * Plug-in's package namespace => com.example
  4 + * com.change_vision.astah.extension.plugin => X
  5 + * com.example => O
  6 + * com.example.internal => O
  7 + * learning => X
  8 + */
  9 +package com.example.internal;
  10 +
  11 +import javax.swing.JFrame;
  12 +
  13 +import com.change_vision.astah.extension.plugin.util.exception.APIException;
  14 +import com.change_vision.jude.api.inf.editor.BasicModelEditor;
  15 +import com.change_vision.jude.api.inf.editor.ClassDiagramEditor;
  16 +import com.change_vision.jude.api.inf.editor.IDiagramEditorFactory;
  17 +import com.change_vision.jude.api.inf.editor.IModelEditorFactory;
  18 +import com.change_vision.jude.api.inf.exception.InvalidEditingException;
  19 +import com.change_vision.jude.api.inf.exception.InvalidUsingException;
  20 +import com.change_vision.jude.api.inf.model.IClassDiagram;
  21 +import com.change_vision.jude.api.inf.project.ProjectAccessor;
  22 +import com.change_vision.jude.api.inf.project.ProjectAccessorFactory;
  23 +import com.change_vision.jude.api.inf.view.IDiagramViewManager;
  24 +import com.change_vision.jude.api.inf.view.IViewManager;
  25 +
  26 +/**
  27 + * A class containing utilities easing astah* API operation
  28 + * Instance must be created before this class is used.
  29 + */
  30 +public class AstahAPIUtils {
  31 +
  32 + /**
  33 + * Get diagramViewManager
  34 + */
  35 + public IDiagramViewManager getDiagramViewManager() {
  36 + IViewManager viewManager = getViewManager();
  37 + IDiagramViewManager diagramViewManager = viewManager.getDiagramViewManager();
  38 + return diagramViewManager;
  39 + }
  40 +
  41 +
  42 + /**
  43 + * Get ClassDiagramEditor by which models on class diagrams can be modified
  44 + */
  45 + public ClassDiagramEditor getClassDiagramEditor() {
  46 + try {
  47 + return getDiagramEditorFactory().getClassDiagramEditor();
  48 + } catch (InvalidUsingException e) {
  49 + throw new APIException(e);
  50 + }
  51 + }
  52 +
  53 + /**
  54 + * Get BasicModelEditor by which basic models can be modified
  55 + *
  56 + * @return BasicModelEditor
  57 + */
  58 + public BasicModelEditor getBasicModelEditor() {
  59 + try {
  60 + return getModelEditorFactory().getBasicModelEditor();
  61 + } catch (InvalidEditingException e) {
  62 + throw new APIException(e);
  63 + }
  64 + }
  65 +
  66 + /**
  67 + * Get ProjectAccessor by which astah* project can be operated
  68 + */
  69 + public ProjectAccessor getProjectAccessor() {
  70 + ProjectAccessor projectAccessor = null;
  71 + try {
  72 + projectAccessor = ProjectAccessorFactory.getProjectAccessor();
  73 + } catch (ClassNotFoundException e) {
  74 + throw new IllegalStateException(e);
  75 + }
  76 + if(projectAccessor == null) throw new IllegalStateException("projectAccessor is null.");
  77 + return projectAccessor;
  78 + }
  79 +
  80 + /**
  81 + * Get JFrame representing the main window of astah*
  82 + *
  83 + * @return JFrame
  84 + */
  85 + public JFrame getMainFrame() {
  86 + return getProjectAccessor().getViewManager().getMainFrame();
  87 + }
  88 +
  89 + /**
  90 + * Get the edition of running astah*
  91 + */
  92 + public String getEdition() {
  93 + return getProjectAccessor().getAstahEdition();
  94 + }
  95 +
  96 + private IViewManager getViewManager() {
  97 + ProjectAccessor projectAccessor = getProjectAccessor();
  98 + IViewManager viewManager = projectAccessor.getViewManager();
  99 + if(viewManager == null) throw new IllegalStateException("ViewManager is null.");
  100 + return viewManager;
  101 + }
  102 +
  103 + private IModelEditorFactory getModelEditorFactory() {
  104 + ProjectAccessor projectAccessor = getProjectAccessor();
  105 + IModelEditorFactory modelEditorFactory = projectAccessor.getModelEditorFactory();
  106 + if(modelEditorFactory == null) throw new IllegalStateException("modelEditorFactory is null.");
  107 + return modelEditorFactory;
  108 + }
  109 +
  110 + private IDiagramEditorFactory getDiagramEditorFactory() {
  111 + ProjectAccessor projectAccessor = getProjectAccessor();
  112 + IDiagramEditorFactory diagramEditorFactory = projectAccessor.getDiagramEditorFactory();
  113 + if(diagramEditorFactory == null) throw new IllegalStateException("diagramEditorFactory is null.");
  114 + return diagramEditorFactory;
  115 + }
  116 +
  117 +}
299 source/_snippets/AstahModelUtils.java
... ... @@ -0,0 +1,299 @@
  1 +/*
  2 + * Please change this class's package to your genearated Plug-in's package.
  3 + * Plug-in's package namespace => com.example
  4 + * com.change_vision.astah.extension.plugin => X
  5 + * com.example => O
  6 + * com.example.internal => O
  7 + * learning => X
  8 + */
  9 +package com.example.internal;
  10 +
  11 +import java.util.ArrayList;
  12 +import java.util.List;
  13 +
  14 +import com.change_vision.jude.api.inf.exception.InvalidEditingException;
  15 +import com.change_vision.jude.api.inf.model.IAttribute;
  16 +import com.change_vision.jude.api.inf.model.IClass;
  17 +import com.change_vision.jude.api.inf.model.IClassifierTemplateParameter;
  18 +import com.change_vision.jude.api.inf.model.IElement;
  19 +import com.change_vision.jude.api.inf.model.IGeneralization;
  20 +import com.change_vision.jude.api.inf.model.INamedElement;
  21 +import com.change_vision.jude.api.inf.model.IOperation;
  22 +import com.change_vision.jude.api.inf.model.IPackage;
  23 +import com.change_vision.jude.api.inf.model.IParameter;
  24 +import com.change_vision.jude.api.inf.model.IRealization;
  25 +
  26 +public class AstahUtils {
  27 +
  28 + /**
  29 + * Get classes owned by the owner
  30 + *
  31 + * @param owner Class or Package
  32 + * @return Classes nesting in the owner
  33 + */
  34 + public static IClass[] getOwnedClasses(Object owner) {
  35 + if (owner instanceof IClass) {
  36 + return ((IClass) owner).getNestedClasses();
  37 + } else if (owner instanceof IPackage) {
  38 + List<IClass> classes = new ArrayList<IClass>();
  39 + for (INamedElement element : ((IPackage) owner).getOwnedElements()) {
  40 + if (element instanceof IClass) {
  41 + classes.add((IClass) element);
  42 + }
  43 + }
  44 + return classes.toArray(new IClass[classes.size()]);
  45 + } else {
  46 + return new IClass[0];
  47 + }
  48 + }
  49 +
  50 + /**
  51 + * Get a owner's class whose name is specified
  52 + *
  53 + * @param owner Class or Package
  54 + * @param name Owner name
  55 + * @return An owner's class whose name is specified
  56 + */
  57 + public static IClass getOwnedClass(Object owner, String name) {
  58 + if (owner instanceof IClass) {
  59 + return getNestedClass((IClass) owner, name);
  60 + } else if (owner instanceof IPackage) {
  61 + return getOwnedElement((IPackage) owner, name, IClass.class);
  62 + } else {
  63 + return null;
  64 + }
  65 + }
  66 +
  67 +
  68 + /**
  69 + * Get an INamedElement whose name is specified in the target package
  70 + *
  71 + * @param owner Target package
  72 + * @param name Name
  73 + * @return a namedElement whose name is specified in the target package
  74 + */
  75 + public static INamedElement getOwnedElement(IPackage owner, String name) {
  76 + return getOwnedElement(owner, name, INamedElement.class);
  77 + }
  78 +
  79 + /**
  80 + * Get an Object whose name and type are specified in the target package
  81 + *
  82 + * @param owner Target package
  83 + * @param name Name
  84 + * @param elementType The child class type of INamedElement
  85 + * @return the child class type of INamedElement whose name and type are specified in the target package
  86 + */
  87 + public static <T extends INamedElement> T getOwnedElement(IPackage owner,
  88 + String name, Class<T> elementType) {
  89 + for (INamedElement element : owner.getOwnedElements()) {
  90 + if (name.equals(element.getName())) {
  91 + if (elementType.isInstance(element)) {
  92 + return elementType.cast(element);
  93 + }
  94 + }
  95 + }
  96 + return null;
  97 + }
  98 +
  99 + /**
  100 + * Get a class whose name is specified in the target class
  101 + *
  102 + * @param owner Target class
  103 + * @param name Name
  104 + * @return a class whose name is specified in the target class
  105 + */
  106 + public static IClass getNestedClass(IClass owner, String name) {
  107 + for (IClass element : owner.getNestedClasses()) {
  108 + if (name.equals(element.getName())) {
  109 + return element;
  110 + }
  111 + }
  112 + return null;
  113 + }
  114 +
  115 + /**
  116 + * Get a generalization whose parent class is specified
  117 + *
  118 + * @param owner Target class
  119 + * @param superType Parent class
  120 + * @return Generalization
  121 + * Null if the superType isn't generalized by the owner
  122 + */
  123 + public static IGeneralization getGeneralization(IClass owner,
  124 + IClass superType) {
  125 + for (IGeneralization generalization : owner.getGeneralizations()) {
  126 + if (superType.equals(generalization.getSuperType())) {
  127 + return generalization;
  128 + }
  129 + }
  130 + return null;
  131 + }
  132 +
  133 + /**
  134 + * Get a generalization whose child class is specified
  135 + *
  136 + * @param owner Target class
  137 + * @param subType Child class
  138 + * @return Generalization
  139 + * Null if the owner isn't generalized by the subType
  140 + */
  141 + public static IGeneralization getSpecialization(IClass owner, IClass subType) {
  142 + for (IGeneralization generalization : owner.getSpecializations()) {
  143 + if (subType.equals(generalization.getSubType())) {
  144 + return generalization;
  145 + }
  146 + }
  147 + return null;
  148 + }
  149 +
  150 + /**
  151 + * Get a realization whose supplier class is specified
  152 + *
  153 + * @param owner Target class
  154 + * @param supplier Supplier Class
  155 + *
  156 + * @return Realization
  157 + * Null if the owner isn't realized by the supplier
  158 + */
  159 + public static IRealization getClientRealization(IClass owner,
  160 + IClass supplier) {
  161 + for (IRealization realization : owner.getClientRealizations()) {
  162 + if (supplier.equals(realization.getSupplier())) {
  163 + return realization;
  164 + }
  165 + }
  166 + return null;
  167 + }
  168 +
  169 + /**
  170 + * Get a realization whose client class is specified
  171 + *
  172 + * @param owner Target class
  173 + * @param client Client Class
  174 + *
  175 + * @return Realization
  176 + * Null if the client isn't realized by the owner
  177 + */
  178 + public static IRealization getSupplierRealization(IClass owner,
  179 + IClass client) {
  180 + for (IRealization realization : owner.getSupplierRealizations()) {
  181 + if (client.equals(realization.getClient())) {
  182 + return realization;
  183 + }
  184 + }
  185 + return null;
  186 + }
  187 +
  188 +
  189 + /**
  190 + * Get a owner's template parameter whose name is specified
  191 + *
  192 + * @param owner Target class
  193 + * @param name Parameter Name
  194 + * @return Template Parameter
  195 + * Null if the template parameter dosn't exist
  196 + */
  197 + public static IClassifierTemplateParameter getTemplateParameter(
  198 + IClass owner, String name) {
  199 + for (IClassifierTemplateParameter templateParameter : owner
  200 + .getTemplateParameters()) {
  201 + if (name.equals(templateParameter.getName())) {
  202 + return templateParameter;
  203 + }
  204 + }
  205 + return null;
  206 + }
  207 +
  208 + /**
  209 + * Get a owner's attribute whose name is specified
  210 + *
  211 + * @param owner Target class
  212 + * @param name Attribute name
  213 + * @return Attribute
  214 + * Null if the attribute dosn't exist
  215 + */
  216 + public static IAttribute getAttribute(IClass owner, String name) {
  217 + for (IAttribute attribute : owner.getAttributes()) {
  218 + if (name.equals(attribute.getName())) {
  219 + return attribute;
  220 + }
  221 + }
  222 + return null;
  223 + }
  224 +
  225 + /**
  226 + * Get a owner's operation whose name is specified。
  227 + *
  228 + * @param owner Target class
  229 + * @param name Operation name
  230 + * @return Operation
  231 + * Null if the operation dosn't exist
  232 + */
  233 + public static IOperation getOperation(IClass owner, String name,
  234 + Object[] parameterTypes) {
  235 + for (IOperation operation : owner.getOperations()) {
  236 + if (name.equals(operation.getName())) {
  237 + IParameter[] parameters = operation.getParameters();
  238 + if (matches(parameters, parameterTypes)) {
  239 + return operation;
  240 + }
  241 + }
  242 + }
  243 + return null;
  244 + }
  245 +
  246 + /**
  247 + * set a class as an interface
  248 + *
  249 + * @param type Target class
  250 + * @param isInterfase True if the class is an interface
  251 + * False if the class isn't an interface
  252 + */
  253 + public static void setInterface(IClass type, boolean isInterface)
  254 + throws InvalidEditingException {
  255 + if (isInterface) {
  256 + addStereotype(type, "interface");
  257 + } else {
  258 + type.removeStereotype("interface");
  259 + }
  260 + }
  261 +
  262 + /**
  263 + * Add a stereotype to an element
  264 + * @param element Target element
  265 + * @param stereotype Added stereotype
  266 + * @return True if the stereotype is added
  267 + * False if the stereotype has been owned by the element
  268 + */
  269 + public static boolean addStereotype(IElement element, String stereotype)
  270 + throws InvalidEditingException {
  271 + for (String exists : element.getStereotypes()) {
  272 + if (stereotype.equals(exists)) {
  273 + return false;
  274 + }
  275 + }
  276 + element.addStereotype(stereotype);
  277 + return true;
  278 + }
  279 +
  280 + static boolean matches(IParameter[] parameters, Object[] parameterTypes) {
  281 + if (parameterTypes.length != parameters.length) {
  282 + return false;
  283 + }
  284 + for (int i = 0; i < parameterTypes.length; i++) {
  285 + Object type = parameterTypes[i];
  286 + if (type instanceof IClass) {
  287 + if (!type.equals(parameters[i].getType())) {
  288 + return false;
  289 + }
  290 + } else {
  291 + if (!type.equals(parameters[i].getTypeExpression())) {
  292 + return false;
  293 + }
  294 + }
  295 + }
  296 + return true;
  297 + }
  298 +
  299 +}
89 source/_snippets/ClassDiagramDropExtension.java
... ... @@ -0,0 +1,89 @@
  1 +/*
  2 + * Please change this class's package to your genearated Plug-in's package.
  3 + * Plug-in's package namespace => com.example
  4 + * com.change_vision.astah.extension.plugin => X
  5 + * com.example => O
  6 + * com.example.internal => O
  7 + * learning => X
  8 + */
  9 +package com.example.internal;
  10 +
  11 +import java.awt.datatransfer.DataFlavor;
  12 +import java.awt.datatransfer.Transferable;
  13 +import java.awt.dnd.DnDConstants;
  14 +import java.awt.dnd.DropTargetDragEvent;
  15 +import java.awt.dnd.DropTargetDropEvent;
  16 +import java.awt.dnd.DropTargetEvent;
  17 +import java.io.File;
  18 +import java.util.ArrayList;
  19 +import java.util.List;
  20 +import java.util.Set;
  21 +
  22 +import com.change_vision.jude.api.inf.model.IClassDiagram;
  23 +import com.change_vision.jude.api.inf.view.DiagramDropTargetListener;
  24 +
  25 +public final class ClassDiagramDropExtension extends DiagramDropTargetListener {
  26 +
  27 + public ClassDiagramDropExtension() {
  28 + super(IClassDiagram.class);
  29 + }
  30 +
  31 + @Override
  32 + public void dropExternalData(DropTargetDropEvent dtde) {
  33 + if(dtde.isLocalTransfer()) return;
  34 +
  35 + if(dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) {
  36 + System.out.println("ClassDiagramDropExtension.stringFlavor" + getURLStringFromDropContent(dtde));
  37 + dtde.dropComplete(true);
  38 + } else if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
  39 + List<File> files = getFilesFromDropContent(dtde);
  40 + System.out.println("javaFileListFravor" + files);
  41 + dtde.dropComplete(true);
  42 + }
  43 + }
  44 +
  45 + private String getURLStringFromDropContent(DropTargetDropEvent dtde) {
  46 + dtde.acceptDrop(DnDConstants.ACTION_LINK);
  47 + Transferable target = dtde.getTransferable();
  48 +
  49 + String urlString;
  50 + try {
  51 + urlString = (String)target.getTransferData(DataFlavor.stringFlavor);
  52 + } catch (Exception e) {
  53 + urlString = "";
  54 + }
  55 + return urlString;
  56 + }
  57 +
  58 + @SuppressWarnings("unchecked")
  59 + private List<File> getFilesFromDropContent(DropTargetDropEvent dtde) {
  60 + dtde.acceptDrop(DnDConstants.ACTION_COPY);
  61 + List<File> list;
  62 + try {
  63 + list = (List<File>) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
  64 + } catch (Exception e) {
  65 + list = new ArrayList<File>();
  66 + }
  67 + return list;
  68 + }
  69 +
  70 + @Override
  71 + public void dropModels(DropTargetDropEvent dtde, Set<?> models) {
  72 + }
  73 +
  74 + @Override
  75 + public void dragEnter(DropTargetDragEvent dtde) {
  76 + }
  77 +
  78 + @Override
  79 + public void dragExit(DropTargetEvent dte) {
  80 + }
  81 +
  82 + @Override
  83 + public void dragOver(DropTargetDragEvent dtde) {
  84 + }
  85 +
  86 + @Override
  87 + public void dropActionChanged(DropTargetDragEvent dtde) {
  88 + }
  89 +}
62 source/_snippets/CountClassAction.java
... ... @@ -0,0 +1,62 @@
  1 +/*
  2 + * Please change this class's package to your genearated Plug-in's package.
  3 + * Plug-in's package namespace => com.example
  4 + * com.change_vision.astah.extension.plugin => X
  5 + * com.example => O
  6 + * com.example.internal => O
  7 + * learning => X
  8 + */
  9 +package com.example.actions;
  10 +
  11 +import java.util.ArrayList;
  12 +import java.util.List;
  13 +import javax.swing.JOptionPane;
  14 +import com.change_vision.jude.api.inf.exception.ProjectNotFoundException;
  15 +import com.change_vision.jude.api.inf.model.IClass;
  16 +import com.change_vision.jude.api.inf.model.IModel;
  17 +import com.change_vision.jude.api.inf.model.INamedElement;
  18 +import com.change_vision.jude.api.inf.model.IPackage;
  19 +import com.change_vision.jude.api.inf.project.ProjectAccessor;
  20 +import com.change_vision.jude.api.inf.project.ProjectAccessorFactory;
  21 +import com.change_vision.jude.api.inf.ui.IPluginActionDelegate;
  22 +import com.change_vision.jude.api.inf.ui.IWindow;
  23 +
  24 +public class CountClassAction implements IPluginActionDelegate {
  25 + public Object run(IWindow window) throws UnExpectedException {
  26 + try {
  27 + ProjectAccessor projectAccessor = ProjectAccessorFactory.getProjectAccessor();
  28 + IModel iCurrentProject = projectAccessor.getProject();
  29 + List<IClass> classeList = new ArrayList<IClass>();
  30 + getAllClasses(iCurrentProject, classeList);
  31 + JOptionPane.showMessageDialog(window.getParent(),
  32 + "There are " + classeList.size() + " classes.");
  33 + } catch (ProjectNotFoundException e) {
  34 + String message = "Please open a project";
  35 + JOptionPane.showMessageDialog(window.getParent(), message,
  36 + "Warning", JOptionPane.WARNING_MESSAGE);
  37 + throw new CalculateUnExpectedException();
  38 + } catch (Exception e) {
  39 + JOptionPane.showMessageDialog(window.getParent(),
  40 + "Exception occured", "Alert", JOptionPane.ERROR_MESSAGE);
  41 + throw new UnExpectedException();
  42 + }
  43 + return null;
  44 + }
  45 +
  46 + public class CalculateUnExpectedException extends UnExpectedException {
  47 + }
  48 +
  49 + private void getAllClasses(INamedElement element, List<IClass> classList)
  50 + throws ClassNotFoundException, ProjectNotFoundException {
  51 + if (element instanceof IPackage) {
  52 + for(INamedElement ownedNamedElement : ((IPackage)element).getOwnedElements()) {
  53 + getAllClasses(ownedNamedElement, classList);
  54 + }
  55 + } else if (element instanceof IClass) {
  56 + classList.add((IClass)element);
  57 + for(IClass nestedClasses : ((IClass)element).getNestedClasses()) {
  58 + getAllClasses(nestedClasses, classList);
  59 + }
  60 + }
  61 + }
  62 +}
27 source/_snippets/HelloWorldAction.java
... ... @@ -0,0 +1,27 @@
  1 +/*
  2 + * Please change this class's package to your genearated Plug-in's package.
  3 + * Plug-in's package namespace => com.example
  4 + * com.change_vision.astah.extension.plugin => X
  5 + * com.example => O
  6 + * com.example.internal => O
  7 + * learning => X
  8 + */
  9 +package com.example.actions;
  10 +
  11 +
  12 +import javax.swing.JOptionPane;
  13 +import com.change_vision.jude.api.inf.ui.IPluginActionDelegate;
  14 +import com.change_vision.jude.api.inf.ui.IWindow;
  15 +
  16 +public class HelloWorldAction implements IPluginActionDelegate {
  17 + public Object run(IWindow window) throws UnExpectedException {
  18 + try {
  19 + JOptionPane.showMessageDialog(window.getParent(), "Hello World");
  20 + } catch (Exception e) {
  21 + JOptionPane.showMessageDialog(window.getParent(),
  22 + "Exception occured", "Alert", JOptionPane.ERROR_MESSAGE);
  23 + throw new UnExpectedException();
  24 + }
  25 + return null;
  26 + }
  27 +}
91 source/_snippets/HelloWorldView.java
... ... @@ -0,0 +1,91 @@
  1 +/*
  2 + * Please change this class's package to your genearated Plug-in's package.
  3 + * Plug-in's package namespace => com.example
  4 + * com.change_vision.astah.extension.plugin => X
  5 + * com.example => O
  6 + * com.example.internal => O
  7 + * learning => X
  8 + */
  9 +package com.example.internal;
  10 +
  11 +import java.awt.BorderLayout;
  12 +import java.awt.Component;
  13 +import java.awt.Container;
  14 +
  15 +import javax.swing.JLabel;
  16 +import javax.swing.JPanel;
  17 +import javax.swing.JScrollPane;
  18 +
  19 +import com.change_vision.jude.api.inf.project.ProjectAccessor;
  20 +import com.change_vision.jude.api.inf.project.ProjectAccessorFactory;
  21 +import com.change_vision.jude.api.inf.project.ProjectEvent;
  22 +import com.change_vision.jude.api.inf.project.ProjectEventListener;
  23 +import com.change_vision.jude.api.inf.ui.IPluginExtraTabView;
  24 +import com.change_vision.jude.api.inf.ui.ISelectionListener;
  25 +
  26 +public class HelloWorldView extends JPanel
  27 + implements IPluginExtraTabView, ProjectEventListener {
  28 + public HelloWorldView() {
  29 + initComponents();
  30 + }
  31 +
  32 + private void initComponents() {
  33 + setLayout(new BorderLayout());
  34 + add(createLabelPane(), BorderLayout.CENTER);
  35 + addProjectEventListener();
  36 + }
  37 +
  38 + private void addProjectEventListener() {
  39 + try {
  40 + ProjectAccessor projectAccessor = ProjectAccessorFactory.getProjectAccessor();
  41 + projectAccessor.addProjectEventListener(this);
  42 + } catch (ClassNotFoundException e) {
  43 + e.getMessage();
  44 + }
  45 + }
  46 +
  47 + private Container createLabelPane() {
  48 + JLabel label = new JLabel("hello world");
  49 + JScrollPane pane = new JScrollPane(label);
  50 + return pane;
  51 + }
  52 +
  53 + @Override
  54 + public void projectChanged(ProjectEvent e) {
  55 + }
  56 +
  57 + @Override
  58 + public void projectClosed(ProjectEvent e) {
  59 + }
  60 +
  61 + @Override
  62 + public void projectOpened(ProjectEvent e) {
  63 + }
  64 +
  65 + @Override
  66 + public void addSelectionListener(ISelectionListener listener) {
  67 + }
  68 +
  69 + @Override
  70 + public Component getComponent() {
  71 + return this;
  72 + }
  73 +
  74 + @Override
  75 + public String getDescription() {
  76 + return "Show Hello World here";
  77 + }
  78 +
  79 + @Override
  80 + public String getTitle() {
  81 + return "Hello World View";
  82 + }
  83 +
  84 + public void activated() {
  85 +
  86 + }
  87 +
  88 + public void deactivated() {
  89 +
  90 + }
  91 +}
23 source/_snippets/plugin_count_class_action.xml
... ... @@ -0,0 +1,23 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<plugin>
  3 + <extension point="com.change_vision.astah.ui.actionSets">
  4 + <actionSet
  5 + label="%action_set_label "
  6 + visible="true"
  7 + id="com.example.actions.actionSet1">
  8 + <menu
  9 + label="%sample_menu"
  10 + id="sampleMenu"
  11 + path="tool/sampleMenu">
  12 + </menu>
  13 + <action
  14 + label="%count_classes"
  15 + icon="icons/sample.gif"
  16 + class="com.example.actions.CountClassAction"
  17 + tooltip="Count classes"
  18 + menubarPath="tool/sampleMenu/"
  19 + id="com.example.actions.CountClassdAction">
  20 + </action>
  21 + </actionSet>
  22 + </extension>
  23 +</plugin>
10 source/_snippets/plugin_extraview.xml
... ... @@ -0,0 +1,10 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<plugin>
  3 + <extension point="com.change_vision.astah.ui.view">
  4 + <view
  5 + id="com.example.internal.HelloWorldView"
  6 + type="extraTab"
  7 + class="com.example.internal.HelloWorldView" />
  8 + </extension>
  9 +</plugin>
  10 +
24 source/_snippets/plugin_menu.xml
... ... @@ -0,0 +1,24 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<plugin>
  3 + <extension point="com.change_vision.astah.ui.actionSets">
  4 + <actionSet
  5 + label="%action_set_label"
  6 + visible="true"
  7 + id="com.example.helloworld.actionSet">
  8 + <menu
  9 + id="helloworld"
  10 + label="%menu_group"
  11 + path="tool/helloworld">
  12 + </menu>
  13 + <action
  14 + label="%menu_label"
  15 + icon="icons/sample.gif"
  16 + class="com.example.TemplateAction"
  17 + tooltip="%menu_tooltip"
  18 + menubarPath="tool/helloworld/"
  19 + id="com.example.actions.HelloWorldAction">
  20