Customizing Element Properties Menu in Enterprise Architect - enterprise-architect

I have created a new stereotype based on "Requirement" and has exported it as profile. When I double click on an instantiation of that type, a menu appears that contains the default properties of the type "Requirement". It contains some tabs (e.g. the "Files" tab) that are useless to me.
Is there a way to eliminate this tabs?
How can I modify the default tabs of the properties dialog (open by double click on an element)?

A word of warning: be careful when stereotyping Requirements - the relationship between the element stereotype and the requirement types configured into the project (Settings - Project Types) is a bit murky.
That said, there is no way to modify EA's dialogs. What you can do is create your own property dialog and have EA open that when the user double-clicks the element.
In order to achieve this, you need to create an Add-In which catches the Context Item Event EA_OnContextItemDoubleClicked. In your event handler, return true to inform EA that you're handling the event (which prevents EA from opening the default property dialog), and open your own custom dialog.
The same event is fired when the user hits Enter with the element selected. The default property dialog can still be opened by pressing Alt-Enter.
As an alternative, you might want to look into the third-party extension eaForms, which allows you to create your own custom property dialogs without writing your own Add-In.

Related

Override "Paste As" dialog

When I drag Class element onto my diagram there is a window fired "Paste Class1", where I can choose the drop type, such as "Link","Property","Instance (Object)" and so.
I need to change that behavior - when I drag from ProjectBrowser I need apply only drop type "Link" and hide any variants from end user. Is it possible to do that via addin or anything else ?
Sparx 13.5
No you can't change the behavior of that dialog.
What you can do in an add-in is overrule whatever the user chose after the fact, and make it into a link anyway. (e.g. deleting the instance from the model and set the elementID of the classifier in the DiagramObject instead)
There is also a checkbox option to only show this window when Ctrl-drag is used. That might help to avoid mishaps as well.

selectionChanged on specific items

I have an eclipse plugin which has multiple classes which make some UI contributions.
The contribution is done through the deprecated org.eclipse.ui.actionSets and the classes implement the IWorkbenchWindowActionDelegate which require an implementation of the selectionChanged(IAction action, ISelection selection).
The selectionChanged method is triggered on any selection change (another file opened, another item selected in Project Explorer, some text is selected in the editor(this one triggers several calls of the method)).
Is there a filtering or something which I can do to limit the selectionChanged observed objects. For example, for class A, trigger the selectionChanged only if the opened file in editor changes)?
No, there is no way to filter that.
Selections coming from text editors with be instances of ITextSelection, other selections will usually be instances of IStructuredSelection so you can check for those instances to do simple filtering in your code.

Programmatically open a specific tab of the Eclipse CDT project property page

I would like to open a specific tab of the Eclipse CDT project property page from code. For example the screenshot below shows the property page open on the Build Steps tab.
The following code opens the property page succesfully, but always the last accessed tab.
private void openProperties(IProject project) {
String ID = "org.eclipse.cdt.managedbuilder.ui.properties.Page_BuildSettings";
org.eclipse.swt.widgets.Shell shell = org.eclipse.swt.widgets.Display.getCurrent().getActiveShell();
org.eclipse.ui.dialogs.PreferencesUtil.createPropertyDialogOn(
shell, project,
ID, null, null, 0)
.open();
}
The thing I don't quite understand is the Settings page is declared using extension point="org.eclipse.ui.propertyPages" and has an ID. But the tabs are added using extension point="org.eclipse.cdt.ui.cPropertyTab" which does not include an ID. So how are the tabs addressed without an ID?
This is only a partial solution, but hopefully it helps:
Save the return value of createPropertyDialogOn(). It's a PreferenceDialog.
Call getSelectedPage() on it to get the IPreferencePage representing the page.
Most CDT preference pages, including the Build Settings page, extend from org.eclipse.cdt.ui.newui.AbstractPage. AbstractPage uses an SWT TabFolder widget to store the tabs.
Here's the fuzzy part: get a hold of the TabFolder widget for the page. Unfortunately, it's not exposed via any public API, so I think your options are:
Use reflection. The TabFolder is stored as a protected field of the AbstractPage named folder.
Search the SWT widget hierarchy rooted at page.getControl(), where page is the AbstractPage, for a TabFolder.
Once you have the tab control, you can use getItemCount() and getItem(index) on it to enumerate its items, which will be of type TabItem.
On each TabItem, call getData() to retrieve the associated ICPropertyTab.
Examine the ICPropertyTab object to see if it's the one you want to activate. In your case, that might be a check like tab instanceof org.eclipse.cdt.managedbuilder.ui.properties.BuildStepsTab.
Once you've found the right tab, activate it via folder.setSelection(item).

FormControlName in ax 2012

is it possible to find the control name for control which is an edit method in ax 2012 form.
i.e how to find control name for edit method control.
I tried but could not find the correct name .
You can right click on the edit method and click "view details" and it will show you something like Fld_23 in the lower right corner.
Or if you need to dynamically determine this, I wrote a blogpost on how to recursively enumerate every control on the form. http://alexondax.blogspot.com/2014/05/how-to-use-recursion-to-loop-over-form.html
The controls are generated at runtime and there is a variable counter that just counts up as each new dynamic control is added during form runtime. So you can use the name you discover, as long as the form doesn't keep getting modified. It might be a good idea to just obtain the static group object or whatever that contains the edit method, then just find the child from there.
You must Right Click on form and click on Personalize option.
In personalization form , Goto information tab and Click on Edit form name.
Then You can see and edit form controls in AOT.
You can use below link for more information.
https://technet.microsoft.com/en-us/library/aa597239.aspx

Eclipse Plug-in / View Question

I have a plugin which contains class A that brings up a view defined in class B via the following line of code:
(VideoLogView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("Videolog.VideoLogView");
What I need to do in the createPartControl() method of the view (class B object) is access a method in the class A object.
How can this be done?
Thanks.
Look like you are facing the classic issue of "how do I pass arguments to my view" ?
This thread illustrates it best:
I was facing the same problem at the beggining of my RCP project. I was getting weird about the fact that there was no way to pass an argument to a view as the viewed model.
Why? Because (emphasis mine):
You are on an opened, pluggable platform.
You contribute to existing developments, others should be able to contribute to yours.
Therefore you will not "pass" arguments to a view, this would lock the whole thing into a non-opened design.
Instead, your view will ask the platform (or will listen to the platform) to determine which information to manage.
Other views (from other plugins that don't yet exist) might also want to manage the same information on the same event.
What you should do then is to ask the workbench for the current selection. I guess your view is opening on a double click action or simple selection so the object you want to manage in your view will be currently selected.
This is how you could retrieve the workbench selection from your view :
ISelection s = this.getSite().getWorkbenchWindow().getSelectionService().getSelection();
where "this" is a ViewPart.
Then you have to make your initial view (the one initiating the view creation from a given event like DoubleClick) a selection provider. A JFace viewer is a selection provider, so you can use it if you're using jface, or you can implement the ISelectionProvider interface when you're using custom SWT controls (that was my case).
The article "Eclipse Workbench: Using the Selection Service" can also give you some pointers.