Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to duplicate a view #33

Open
ghost opened this issue Aug 21, 2018 · 6 comments
Open

Add function to duplicate a view #33

ghost opened this issue Aug 21, 2018 · 6 comments

Comments

@ghost
Copy link

ghost commented Aug 21, 2018

Please, as this can be done with the Gui.

@Phillipus
Copy link
Member

I just looked at the underlying Java code that does this. It's quite complicated and creates a few actions for the Undo/Redo Command Stack. This code can't be used "as is" because jArchi uses a different approach for the Undo/Redo stack.

So this code would need to be more or less duplicated for jArchi. The problem with this is that more and more features might also require underlying duplicated Java code.

An alternate approach is to implement these types of features in JavaScript as part of a jArchi library. jArchi should supply the basic building blocks but not attempt to duplicate every feature in Archi itself.

I'll try to start a library of these types of functions over the coming weeks...

@Phillipus
Copy link
Member

Phillipus commented Aug 21, 2018

Having said all that, an object.duplicate() or object.copy() method might be a useful core method.

@cedepz
Copy link

cedepz commented Nov 25, 2019

Hi,

I know this is a bit old topic but I had recently the same need to duplicate objects from javascript. So I made a quick workaround by adding this code to 'EObjectProxy' class and redeploying JArchi on my Archi instance:

public void duplicate() {   
	Object[] objects = new Object[1];    
	objects[0] = getEObject();    
	DuplicateCommandHandler handler = new DuplicateCommandHandler(objects);    
	handler.duplicate();   
}

This allowed me to duplicate views and objects from scripts (my test script is $(selection).first().duplicate();)
As I am far from knowing all about Undo/Redo command stacks in both Archi and JArchi this may be a very bad implementation but at least that was enough for my small (and quick) need.

The main drawback of this is that it is not possible to get an handle on the newly created object as DuplicateCommandHandler keeps newly created objects private. This means that this duplicate method can only return void without implementation changes in Archi...

@romualdrichard
Copy link

Is there a way to do this?

@Phillipus
Copy link
Member

Is there a way to do this?

Not yet. I'll take another look at it.

@Phillipus
Copy link
Member

Will be in the next version of jArchi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants