Recent posts

#1
jArchi / Re: Snippet: Interacting with ...
Last post by Phil Beauvoir - December 05, 2022, 16:17:32 PM
Hi Gerald, thanks for sharing, that looks really nice!

Regards,

Phil
#2
jArchi / Re: Snippet: Interacting with ...
Last post by Gerald Groot Roessink - December 05, 2022, 15:08:50 PM
Hi Thomas and Phil,

I had a bit of fun with this snippet and enhanced the merging script in the community-script-pack by providing the user with details about the selected elements.

/*
 * Merge elememt
 *
 * Select two elements and merge them
 *
 * (c) 2018 Jean-Baptiste Sarrodie, Phillip Beauvoir, (c) 2022 Thomas Rohde, Gerald Groot Roessink.
 *
 * This work is licensed under the HUMANS Licence described below.
 *
 * The HUMANS (Help Us Make Archi Noteworthy & Sustainable) licence goal is to bring happiness
 * to both Archi users and developers.
 *
 * The only restrictions that apply are:
 *  - You can't redistribute this script.
 *  - You can't use this script for commercial purposes
 */


/*
Author: Thomas Klok Rohde
Description: Proof-of-concept of how to use a Browser to collect form data.
*/

console.show();
console.clear();

var el_selection = selection.filter("element");

if(el_selection.size() != 2) {
  window.alert("You have to select two elements to run this script.");
  exit();
}
if(el_selection[0].type != el_selection[1].type) {
  window.alert("You have to select two elements of the same type.");
  exit();
}


//create a shell
const SWT = Java.type('org.eclipse.swt.SWT');
const FillLayout = Java.type('org.eclipse.swt.layout.FillLayout');
const Shell = Java.type('org.eclipse.swt.widgets.Shell');
const Browser = Java.type('org.eclipse.swt.browser.Browser');
const ProgressAdapter = Java.extend(Java.type('org.eclipse.swt.browser.ProgressAdapter'));
const LocationAdapter = Java.extend(Java.type('org.eclipse.swt.browser.LocationAdapter'));
const CustomFunction = Java.extend(Java.type('org.eclipse.swt.browser.BrowserFunction'));
const IArchiImages = Java.type('com.archimatetool.editor.ui.IArchiImages');
const ImageFactory = Java.type('com.archimatetool.editor.ui.ImageFactory');

let display = shell.getDisplay();
let newShell = new Shell(display, SWT.MODAL | SWT.TITLE | SWT.ON_TOP | SWT.SHELL_TRIM);
newShell.setText("Merging elements");
newShell.setLayout(new FillLayout());


//create the html for the shell
var output=createTable(el_selection);
html=html_part1()+output+html_part3() ;

// take the user-input
let okPressed = false;
let cancelPressed = false;
let browser = new Browser(newShell, SWT.NONE);
let value = {};

browser.addProgressListener(new ProgressAdapter({
completed: function (event) {
let fncOk = new CustomFunction(browser, "okPressedEvent", {
function: function (args) {
okPressed = true;
value = JSON.parse(args[0]);
}
});
let fncCancel = new CustomFunction(browser, "cancelPressedEvent", {
function: function (args) {
cancelPressed = true;
}
});
browser.addLocationListener(new LocationAdapter({
changed: function (e) {
browser.removeLocationListener(this);
fncOk.dispose();
fncCancel.dispose();
}
}));
}
}));

browser.setText(html);

// Set icon to Archi icon, in case shell has a style which displays icons
newShell.setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_APP));
newShell.setSize(900, 650);
newShell.setLocation(300, 300);
newShell.open();

while (!newShell.isDisposed() && !okPressed && !cancelPressed) {
if (!display.readAndDispatch()) display.sleep();
}

if (okPressed) {

if (value.choice=="elm1") {
  var merge_target= el_selection.get(0);
  var merge_origin= el_selection.get(1);
  removeDocAndProps(merge_origin);
}
if (value.choice=="elm2") {
  var merge_target= el_selection.get(1);
  var merge_origin= el_selection.get(0);
  removeDocAndProps(merge_origin);
}
if (value.choice=="elm12") {
  var merge_target= el_selection.get(0);
  var merge_origin= el_selection.get(1);
  // do not remove doc en props
}
    console.log('Merging "', merge_origin.name, '" into "', merge_target.name, '"');
concept(merge_target).merge(concept(merge_origin));
merge_origin.delete();

console.setTextColor(20, 100, 200);
console.log ("You can use undo (control-z) when result is unwanted ");

}
else if (cancelPressed)
console.log('Dialog cancelled.');


// end shell
newShell.dispose();


// --------------------------
// if visual element change to model element
function concept(o) {
  if(o.concept)
    return o.concept;
  else
    return o;
}

// remove documentation and properties
function removeDocAndProps(c) {
  c.documentation = "";
  c.prop().forEach(function(p) {
    c.removeProp(p);
  });
}

// Function to create the html-table
function createTable(el_selection){
// console.log (el_selection);
var output='<table border="2" cellspacing="1" cellpadding="8" class="table">'

// Determine propertynames for selected elements
const  alltags = [] ;
el_selection.each(function(o) {
for (i = 0; i<o.prop().length;i++) {alltags.push(o.prop()[i])};
});
const props = [...new Set(alltags)]; //make props unique

// Put the data in a table
var output=output+"<tr><th>Property</th>";
for (k = 0; k<el_selection.length;k++) {
var ks=k+1;
output=output+"<td>Element "+ks+"</td>";
};
output=output+"</tr>";

output=output+"<tr><td>Name</td>";
el_selection.each(function(o) {
output=output+"<td>"+o.name+"</td>";
});
output=output+"</tr>";

output=output+"<tr><td>Documentation</td>";
el_selection.each(function(o) {
output=output+"<td>"+o.documentation+"</td>";
});
output=output+"</tr>";

for (j = 0; j<props.length;j++) {
output=output+"<tr><td>"+props[j]+"</td>";
el_selection.each(function(o) {
propval=o.prop(props[j])== null ? "" : o.prop(props[j]);
output=output+"<td>"+propval+"</td>";
});
output=output+"</tr>";
};
output=output+"</table>";
return output;
};

function html_part1(){
html_part1 = `<html>
<title>Eclipse browser</title>
<style>
*
{
  box-sizing: border-box;
}

table
{
  font-family: arial, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

td, th {
  border: 1px solid #dddddd;
  text-align: left;
  padding: 8 px;
}

tr:nth-child(even) {
  background-color: #dddddd;
}


input[type=text], input[type=email], select {
padding: 5px;
margin:5px 0;
border-radius:5px;
border-width: 2px;
width: 100%;
}
fieldset {
margin: 10px;
border-width: 2px;
border-radius:5px;
}
button {
margin: 10px;
padding: 5px;
width: 100px;
}
</style>

<body>
<h2>Choose the element to keep or combine both</h2>`;
return html_part1;
}

function html_part3(){
html_part3=`
<p>
Choose the element with the preferable documentation and properties or choose to combine.
    Existing diagram instances of the other ArchiMate element will be replaced.
    All source and target relationships of the other element are set to this element.
</p>

    <fieldset>
<legend>Choose the element to keep or combine both</legend>
<!-- Radio button with value -->
<input type="radio" id="elm1" name="choice" value="elm1" checked>
<label for="elm1">Element 1</label>
<input type="radio" id="elm2" name="choice" value="elm2">
<label for="elm2">Element 2</label>
<input type="radio" id="elm12" name="choice" value="elm12">
<label for="elm12">Both</label>
    </fieldset>
    <button onclick="okPressed()">Ok</button>
<button onclick="cancelPressed()">Cancel</button>
    <script>
        function okPressed() {

var radios = document.getElementsByName('choice');
function get_checked_radio(radios) {
for (var r = 0; r < radios.length; r++) {
var current = radios[r];
if (current.checked) {
return current;
}
}
};

// alert(get_checked_radio(radios).value);

            let value = {
choice: get_checked_radio(radios).value
};


okPressedEvent(JSON.stringify(value)); 
        }
        function cancelPressed() {
            cancelPressedEvent();
        }
    </script>
</body></html>`;
return html_part3;
}

#3
Hi,

Quote from: qrt on December 05, 2022, 10:52:55 AMCoArchi is still work in development.

Even though it is still in development, coArchi is already used in "production" by lots of people (including the team I work with). It's almost impossible to loss data with it and you can work on different computers and/or with your colleagues.

Quote from: qrt on December 05, 2022, 10:52:55 AMHow do you share your models with colleagues, and ensure that you are working on the right version?

"Right version" doesn't really mean something in such context, but if you want to be sure you have the same version as the one on the server, simply do a publish (your changes will be shared and you'll be up to date with your colleagues' work.

Quote from: qrt on December 05, 2022, 10:52:55 AMWhat sharing strategies are you using for your models? Strict versioning?

Not sure to understand.

Regards,

JB
#4
General Archi Discussion / Re: Conditionnal dynamic color...
Last post by rchevallier - December 05, 2022, 10:54:13 AM
FYI, I'm developing a jarchi script allowing that (evolved version of https://smileham.co.uk/2022/06/15/archi-jarchi-and-rag-status-maps/), shall be (hopefully) soon ready
#5
General Archi Discussion / What sharing strategies can be...
Last post by qrt - December 05, 2022, 10:52:55 AM
How do you share your models with colleagues, and ensure that you are working on the right version? 


Have you ever worked on the model on two different computers and experienced data loss? 

What sharing strategies are you using for your models? Strict versioning? 


CoArchi is still work in development. Is that the only /sane/ tool to use when sharing your models? 
#6
jArchi / Re: Is it possible to make jar...
Last post by Phil Beauvoir - December 05, 2022, 10:05:28 AM
It will be after Archi 5 is released and jArchi 1.4. See https://github.com/archimatetool/archi-scripting-plugin/issues/62
#7
jArchi / Is it possible to make jarchi ...
Last post by margolyesh - December 05, 2022, 10:01:40 AM
Hello!

Subj :)
#8
Quote from: blaise on December 04, 2022, 04:34:20 AMI suppose this is not going to happen?


Oops, I totally forgot. I'll manage to share it asap.

Regards,

JB
#9
I'm just getting started and if there are corrections or examples of anti patterns, I would love to see them.

-Blaise

Quote from: Jean-Baptiste Sarrodie on November 26, 2020, 17:46:52 PMHi,

Quote from: kdrangej on November 24, 2020, 09:22:58 AMTo get a better understanding of how the Archi Collaboration (GIT flow) extension is working I attempted to model it.

Thank you for that initiative, that's always good to share.

If you don't mind, I'd like to react on some ArchiMate "errors" I can see in your view which are (unfortunately) quite common. Could you please share your model file in native Archi format so that I can react on it and comment it more easilly?

Regards,

JB


#10
I suppose this is not going to happen?

Quote from: Jean-Baptiste Sarrodie on October 26, 2021, 21:10:07 PMHi,
...

That's planned for the near future. I was waiting for 4.9.1 to be out.

Regards,

JB