Author Topic: Is it possible to get the preferences settings from jArchi  (Read 200 times)

Manj75

  • Senior Member
  • ****
  • Posts: 152
Is it possible to get the preferences settings from jArchi
« on: June 23, 2021, 12:31:48 PM »
If the collaboration plugin is installed and setup I want to script the ability to fetch the Tools -> Preferences -> Collaboration -> Name text field value.

The script would throw an exception of the coArchi was not installed or if that field does not exist.

I'm want to create a script where you can append to the documentation that stamps the date and Name of the text appended.  This would also work on appending to multiple elements in one operation.

Phil Beauvoir

  • Administrator
  • Hero Member
  • *****
  • Posts: 1558
  • Code Punk
    • Archi
Re: Is it possible to get the preferences settings from jArchi
« Reply #1 on: June 23, 2021, 13:38:59 PM »
jArchi does not have an API for Archi's preferences.

If you are trying to access the user name that is used for coArchi (i.e. git) commits, this can be found in the ~/.gitconfig file which could be loaded in JS and parsed.

Or for other preferences, load and read Archi's preference files directly - %Home%\AppData\Roaming\Archi4\.metadata\.plugins\org.eclipse.core.runtime\.settings
« Last Edit: June 23, 2021, 13:45:29 PM by Phil Beauvoir »
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

Manj75

  • Senior Member
  • ****
  • Posts: 152
Re: Is it possible to get the preferences settings from jArchi
« Reply #2 on: June 23, 2021, 17:36:48 PM »
Phil - your suggestion of using the plugin preferences config file would've been perfect, however I don't see all the settings from the preferences Collaboration tab, only the following is there in the file:

Code: [Select]
eclipse.preferences.version=1
sshIdentityFile=
sshIdentityRequiresPassword=false

I'm I missing anything - could it be that the Name and Email values are only stored in the encrypted file?

Phil Beauvoir

  • Administrator
  • Hero Member
  • *****
  • Posts: 1558
  • Code Punk
    • Archi
Re: Is it possible to get the preferences settings from jArchi
« Reply #3 on: June 23, 2021, 17:39:58 PM »
I did say "Or for other preferences"  ;)

The name and email used by git (and coArchi) are stored in the <user.home>/.gitconfig file not the preferences file (I think it does say that on the Preferences dialog)
« Last Edit: June 23, 2021, 19:23:19 PM by Phil Beauvoir »
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

Manj75

  • Senior Member
  • ****
  • Posts: 152
Re: Is it possible to get the preferences settings from jArchi
« Reply #4 on: June 25, 2021, 12:17:38 PM »
Looking at the .gitconfig file it has exactly what I need and as it's basically an ini file I need to load and parse it, however I see no examples from community of file IO in jArchi/JS.  I've tried the FileReader but this doesn't seem to be supported - can you or anyone please point me to an example that'll work in jArchi to load a local file that I can parse or even if there is already an available JS library script that readily does this.  Thanks.

projetnumero9

  • Member
  • **
  • Posts: 16
Re: Is it possible to get the preferences settings from jArchi
« Reply #5 on: June 25, 2021, 12:35:00 PM »
This gist (https://gist.github.com/search?q=%23jarchi+extension%3Aajs+readfully&ref=searchresults) served me right on the spot (see the polyfill readFully)! (so happy you could publish it, JB!)

Another/similar example would be:
- https://gist.github.com/smileham/1e57a5946235e780dee5a824f664aa3d

Regards,
PN9

Jean-Baptiste Sarrodie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 695
  • Archi Evangelist and Contributor. Visionary.
    • About me...
Re: Is it possible to get the preferences settings from jArchi
« Reply #6 on: June 25, 2021, 13:27:36 PM »
Hi,

so happy you could publish it, JB!

What do you mean by "publish it" ?

JB
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

Jean-Baptiste Sarrodie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 695
  • Archi Evangelist and Contributor. Visionary.
    • About me...
Re: Is it possible to get the preferences settings from jArchi
« Reply #7 on: June 25, 2021, 13:29:14 PM »
BTW, I mentioned a bunch of useful blog posts and polyfills here: https://forum.archimatetool.com/index.php?topic=625.msg3506#msg3506

JB
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

projetnumero9

  • Member
  • **
  • Posts: 16
Re: Is it possible to get the preferences settings from jArchi
« Reply #8 on: June 25, 2021, 13:50:56 PM »
Hi,

so happy you could publish it, JB!

What do you mean by "publish it" ?

JB

Making it publicly available,

PN9

Jean-Baptiste Sarrodie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 695
  • Archi Evangelist and Contributor. Visionary.
    • About me...
Re: Is it possible to get the preferences settings from jArchi
« Reply #9 on: June 25, 2021, 14:18:22 PM »
Making it publicly available,

PN9

You mean, in a dedicated gist, a real git repo, somewhere else ? (BTW, this is not my work but someone else's work I used).

Maybe have a set of wiki page on jArchi repo with a list of really useful snippets ?

Don't know what's the best.

JB
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

Manj75

  • Senior Member
  • ****
  • Posts: 152
Re: Is it possible to get the preferences settings from jArchi
« Reply #10 on: June 25, 2021, 14:24:56 PM »
I've used the second example mentioned by PN9 in combination with a parse_ini_string function I found on https://gist.github.com/anonymous/dad852cde5df545ed81f1bc334ea6f72

Now, I just need to be able to get the user homedirectory, i.e. %userprofile% for win32 and $home for mac.

I was pointed to the $.process but not sure if it supports .env for environment variable.  I want to do something like:

Code: [Select]
process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
but, I get undefined for $.process.env, so not if this is supported.