Drag and drop from gef viewer to editor - eclipse

I have a ScrollingGraphicalViewer containing a list of figures, let's call them "group figures", representing some business objects with relations between them. Each "group figure" may contain some other figures which are related. There are edit parts for every "group figure".
I want to be able to drag and drop any figure from the viewer into another editor. Right now, the viewer has a drag listener extending an AbstractTransferDragSourceListener class. Inside the listener, we get the viewer selection which is a corresponding EditPart of the selected group figure.
When there are many figures in the viewer and the vertical scrolling appears, I'm not able to detect the exact figure I dragged, based on the drag event and figure coordinates. How can I obtain the dragged figure?

There is a GEF tutorial on DnD. Here is is: https://eclipse.org/articles/Article-GEF-dnd/GEF-dnd.html
You can assume that you're dragging selected editparts I guess. Also you should set the transfer data for DnDing staff outside the viewer. The transfer data should most likely be the model object or image of the figure.
If you're DnDing not selected editparts then you'd have to figure out what exactly you're dragging from the mosule location coordinates at the drag start. Use viewer's
#findObjectAtExcluding(Point location, Collection exclusionSet, Conditional conditional)
method to find editpart under mouse. From the found editpart you can either get or the figure to set the appropriate transfer data.

Related

Visio protect object from selection

A big problem for me creating diagrams in visio (and powerpoint and similar programs) is that if you have a background object, it blocks you from selecting multiple objects by lassoing. Instead you end up moving the background around, this is annoying.
In many applications there's an option to "lock" or "protect" a specific object so it becomes un-selectable while still visible on the drawing. In Visio there is no simple way of doing this as far as I'm aware.
There's a rather convoluted way of doing this, it feels to me like Visio designers wanted to make this difficult on purpose. The methods I'm aware of I list here, feel free to let me know of a better way(s)
You can protect objects from selection by going to (hidden by default) Developer tab and pick "shape design"-> protection -> selection. However this does not actually protect them from selection, which makes sense . To actually protect the said object from selection, you have to open drawing explorer, which is also hidden by default and the visibility tickbox is in hidden by default Developer tab under show/hide section.
Drawing explorer, however won't highlight whatever object you have selected in the drawing, another unexplicable design decision. If you want to see the name of the object you've selected with live update, you have to enable the diagram navigation pane. That's found in View tab on Show section under "task panes" icon. This pane does highlight whatever you've selected and you can rename the object to give it a meaningful name, but not change the shape in any other way.
To finally protect that shape from selection, right click on the top level document on the drawing explorer and pick "Protect document" and tick "shapes" and hey presto, now your background rectangle is visible but not selectable. Very straightforward indeed
There are also layers which offer similar functionality but they naturally come with their own gotchas.
You can see layers on the Drawing explorer under foreground pages, page name, "Layers" tree. To move an object on a specific layer, you cannot do it by right clicking on the object, because of course you can't. There's an assign to layer button in Home->Editing->Layers->"Assign to Layer", which will let you select the layer(s) for the selected object. You can also do this by right clicking on an object from the Drawing explorer, but you have to know the object name, because there's no reverse selection .. The object name you can get from the Diagram navigation. By default "protected" and "lock" layers do nothing.
To change what the layers do, you again go to the Home -> Editing -> Layers and select "Layer properties". This is also available from Drawing explorer by right clicking on the "layers" tree under a specific page. Here you can control if the layer is visible and/or protected. However, if you lock a layer, you also cannot move objects to/from it, as that'd be too easy. So you have to untick "lock" if you want to move stuff in and out of a protection layer.
So there are two awkward ways of doing that that I'm aware of.
If the shape really is a background object then maybe you should be looking at putting the shape on a background page. You can then make it the background page for your active page. That'll fix all your shape selection problems.

Scroll to the dropped object when it's released outside of the current view of a GEF editor

I have a GEF editor with draggable figures. I have overriden the createChangeConstraintCommand of the main EditPart's XYLayoutEditPolicy.
This allows me to easily move (drag and drop) the figures.
The problem is, that if I drag one of them outside of the current view, although the scroll appears and the figure is moved, the view does not automatically scrolls to the dropped object.
Any idea how to implement this "auto-scroll" functionality? (It would be even nicer to have the "selected" (dragged/dropped) figure always visible in the view.)
Given the editpart object that has been dropped, you should use EditPartViewer#reveal(EditPart) method. Do this for example:
editpart.getViewer().reveal(editpart)

MATLAB: GUIDE "Save Figure" toolbar button

I created a Gui in GUIDE and added the predefined "Save" toolbar button in guide->tools->toolbar. When i press the save button, the next time i open the GUI it will show the saved values and axes.
Now i would like to remove that feature again, but only removing the save button doesn't seem to work. The Gui still opens with the last saved values.
Is there a way to clear the saved data?
It appears that no further answers are forthcoming, and since I just ran across the same issue, this is what I did.
Open the object browser and determine which ones changed;
In my case it changed two text boxes as well as the axes.
Open the properties inspector for the changed objects and edit as required to return them
to their original states. I replaced the string property with the correct values.
It's too difficult to figure out how to make the axes object revert to it's old state. You can create a 2nd temporary axes and copy those states to the first axes; but I found this doesn't work. Instead, delete the old axes, create a new axes in it's place, and rename the tag to match the original. If there are any callbacks, make sure they're in the right place and delete the old one.
That's it. Good luck.

I have a few GUI's in MATLAB and I need to view them in different tabs

I have 3 GUI files created using GUIDE. I need to have a tab Panel where I can view all of them in different tabs.
There is no straightforward way to accomplish that. A figure cannot be displayed inside another figure. GUIDE creates figure. You can convert your GUIDE figure to programmatical GUI by using some conversion procedure. There is one official by Mathworks, or other ones on file exchange. Then, you should place the 3 figures children inside a panel each.
There is no tab object in MATLAB. You can generate your own by making your own graphical objects: the tab buttons, that users can click to run a function that puts the right "tab" in front using uistack to change the order of your graphical objects, always bringing the clicked tab to the front.
But you would do this all in one GUI, in one figure window; you just not to make sure that hold is on in the figure, and you have to give all your plots a handle so that you can manipulate them with uistack.

Arrange GUI elements in WPF in a similar way to the applications on the iPhone

I would like to arrange UIControls in WPF in a similar way to the applications on the iPhone. They should be positioned on a grid, but a user should be able to drag them somewhere else, after releasing the mouse button (or the finger in case of an iPhone) the selected UIControl should snap back to the next position in the grid. The other UIElements should be rearranged automatically.
Further the user should also be connect two elements with a line or something.
I'm not experienced with WPF. The first question is if there is a container which is suitable for something (System.Windows.Controls.Grid ?) or if I have to extend canvas or somethig else for this.
I would like to know which elements from the WPF framework can be used and which elements I have to write myself.
For people who do not own an iPhone: http://www.youtube.com/watch?v=3omhu2AUWC8
Update
I've looked at AnimatedTilePanel in the BangOTricks examples (see below), this one explains how to create your own Panel and how to let it arrange things there.. However I still need an idea how to implement drag and drop correctly in this example..
Unfortunately, you'll have to write a lot of things yourself, as WPF doesn't automatically do what you're looking for.
For positioning the controls, you can use either UniformGrid or Grid. Assuming it's much like the iPhone video you showed, you can just use the UniformGrid with 4 columns and however many rows you need.
For the dragging animation, layout-wise, you could start by manipulating the RenderTransform property on whatever is being dragged, but you'll have to set a handler to check once you've met whatever threshold necessary to move into the another "cell" -- and at that point, you'll have to changed the order of the items in the tree.
Take a look at AnimatedTilePanel from Kevin's Bag-o-Tricks at:
http://j832.com/bagotricks/
It doesn't do everything you want but it will show you how to write a panel that animates its children when changing size or order.
New input to this old post in 09. Earlier this year (2012) someone has wrote a FluidWrapPanel and open sourced it. I tried it and it works like a charm - just like that on the iPhone menu.
You can also apply to other UI Elements or UserControl.