IntelliJ IDEA plugin : Jump to declaration for custom xml - java

I have component based application. All of the components are defined in XML. The components may be defined in different xml files.
<!-- filename: components.xml -->
<components>
<component type="x" name="y">
<property1 attribute="attr"/>
<property2 attribute="attr"/>
</component>
<component type="a" name="b">
<property1 attribute="attr"/>
…
</component>
</components>
<!-- filename: extra-components.xml -->
<components>
<component type="x" name="z" extends="x:y"> <!-- this extends component x:y -->
<property3 attribute="attr"/>
</component>
</components>
Right now I'm trying to write a plugin so that I can jump from the child components to parent component. In the example above, the component type 'x' and name 'z' extends component type 'x' and name 'y'.
Going throughs some of the source from different plugins, I was able to add a menu item and grab content under the caret.
Say, if my caret is under "x:y" in second component, I can garb x and y so at least I can know the component type and component name to look for.
But I want to underline the contents under extends i.e. "x:y" when I press ctrl and search for the component and jump to the declaration of the component when ctrl+click like we jump to declaration of class.
I want guidance like which class should I look, how should I go or similar implementation.
Thanks

I think what you are looking for is a reference contributor.
See this answer for more details on how to set up a contributor. Once this contributor is created, I think you'll have two ways to find which XML element x:y refers to:
parse every potential XML file and try to find a tag with the correct attributes, then return the corresponding PsiElement
create an index of every component tag, and lookup x:y in this index (requires much more work)

Related

XML override component Java

I am having a component that I need to override, the problem is I don't know-how.
My XML looks like this:
<border-layout>
<component name="myFirstComponent">
<fix-layout>
<component name="myController">
some options...
</component>
<component name="needToOverride">
<fix-position x="222" y="222" width="111" height="10" opaque="false" visible="true"/>
</component>
</fix-layout>
</border-layout>
I could escape some closing tags at the end, but don't take it insight. How can I override "needTOOverride" to modify my positions? the current XML is read-only, and I can't modify it.
I tried some google solutions but did not manage to make this work. Sorry for the dumb question, if it is.
I would use some XML Serialization and Deserialization Library like jackson or simplexml for that.

Aspect name in Alfresco showing up as undefined in 'Manage Aspect'

I was working with Alfresco-entreprise 4.1.1.3 and i moved to alfresco-community 5.0.2.
In this migration i copied all the config files of my custom aspects to the same locations as it was in
Alfresco-entreprise 4.1.1.3
I have set them to visible in share UI and I can see them in the share UI.
The problem is that when I right click on a site or folder and choose 'Manage Aspect', i see that the aspect name is listed as
undefined (gifapidocument:MyAspect)
I am not sure why it is showing up as undefined. When I click on manage rules -> add aspect , I see that the name is showing up correctly.
When i try to add a document to Alfresco from my application it works but the document is added without any properties and empty Aspects.
the paths of my configs are :
share-config-custom.xml : ./tomcat/shared/classes/alfresco/web-extension
In <alfresco-config><config><aspects><visible>, i added :
<aspect name="gifapidocument:*MyAspect*" />
In <alfresco-config><config><forms><form>, i added :
<field-visibility>
<show id="gifapidocument:typeDocumentXXXX" />
</field-visibility>
<field-visibility>
<show id="gifapidocument:idXXXXXXXX" />
</field-visibility>
another path of my configs :
myAppDocument-model.xml : ./tomcat/shared/classes/alfresco/extension/myApp/model
In <model><aspects>, i added :
<aspect name="gifapidocument:*MyAspect*">
<properties>
<property name="gifapidocument:typeDocumentXXXX">
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="gifapidocument:idXXXXXXXX">
<type>d:text</type>
<mandatory>false</mandatory>
</property>
</properties>
</aspect>
and finaly :
myApp.properties : ./tomcat/shared/classes/alfresco/extension/myApp/messages
i added :
aspect.gifapidocument_*myAspect*=GIF-API-MYAPP-*myAspect*
u can check yours aspects with:
yourhost/api/-default-/public/alfresco/versions/1/nodes/{{uiid}
it is shown in this properties"aspectNames": []
in my case when i click to manage aspect i cant see any thing in share but the aspect is added correctly.
Could the asterisks be in the name of aspect?

How to show undo and redo actions in toolbar in rcp application

I am working on an rcp application with a toolbar for quick access to certain actions, including undo and redo. My problem is that these two specific actions don't show up in the toolbar. I have located the cause to the workbench.xmi file that is generated when the application launches. A tag persistedState with an attribute key="persp.hiddenItems" contains persp.hideToolbarSC:org.eclipse.ui.edit.undo,persp.hideToolbarSC:org.eclipse.ui.edit.redo in the value="..." attribute. If I delete these entries from workbench.xmi, the undo and redo actions show up in the toolbar as they should.
My question is: What can I do so that org.eclipse.ui.edit.undo and org.eclipse.ui.edit.redo don't end up in this attribute to begin with?
I originally used eclipse neon without this problem, but when updating to eclipse 2018-12 this started happening.
Edit:
I finally got it to work by changing the IDs of my undo and redo actions to something else. I had to set the ID with setId(...) and setActionDefinedId(...) in the actions' constructors, and then the commands had to be defined in plugin.xml under <extension point="org.eclipse.ui.commands"> in a <command id="..." name="Undo"></command> tag.
This solutions feels more like a workaround than an actual solution, but it works for me.
This is set by the hiddenToolBarItem element of the org.eclipse.ui.perspectiveExtensions extension point.
The org.eclipse.ui.ide plug-in uses this to disable these tool-bar items:
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension targetID="*">
<!--
disable "print" button which is defined by org.eclipse.ui.actions.ActionFactory.PRINT
and contributed by org.eclipse.ui.internal.ide.WorkbenchActionBuilder
-->
<hiddenToolBarItem id="print" />
<!--
disable "undo" button which is defined by org.eclipse.ui.actions.ActionFactory.UNDO
and contributed by org.eclipse.ui.internal.ide.WorkbenchActionBuilder
-->
<hiddenToolBarItem id="org.eclipse.ui.edit.undo" />
<!--
disable "redo" button which is defined by org.eclipse.ui.actions.ActionFactory.REDO
and contributed by org.eclipse.ui.internal.ide.WorkbenchActionBuilder
-->
<hiddenToolBarItem id="org.eclipse.ui.edit.redo" />
</perspectiveExtension>
</extension>
I don't see a way to clear this other than leaving out the plug-in.
I ran into the same problem. Undo/Redo disappeared after upgrading to 2019 eclipse.
One way to override the hardcoding in org.eclipse.ui.ide global perspective setting is to modify the perspective state directly. E.g. in ApplicationWorkbenchWindowAdvisor.postWindowOpen()
WorkbenchPage page = (WorkbenchPage) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
String str = page.getCurrentPerspective().getPersistedState().get(ModeledPageLayout.HIDDEN_ITEMS_KEY);
str=str.replace("persp.hideToolbarSC:org.eclipse.ui.edit.undo,", "");
str=str.replace("persp.hideToolbarSC:org.eclipse.ui.edit.redo,", "");
page.getCurrentPerspective().getPersistedState().put(ModeledPageLayout.HIDDEN_ITEMS_KEY,str);

Add custom markers to java editor in eclipse

I've been trying to add custom markers to eclipse editor for many many hours (days) and I just can't get it to work.
I can add problem markers well and without any issues by extending them on my own plugin.xml. It does everything I want EXCEPT the icon for the marker. I want a different icon.
Here's What I have:
plugin.xml
<extension
point="org.eclipse.ui.editors.annotationTypes">
<type
markerType="Plugin.MyMarker"
name="Plugin.MyMarker"/>
</extension>
<extension
id="MyMarker"
point="org.eclipse.core.resources.markers">
<super type="org.eclipse.core.resources.textmarker" />
<!-- <super type="org.eclipse.core.resources.problemmarker" /> --><!-- if I remove this comment, all works... But I don't want that icon-->
<persistent value="true"/>
</extension>
<extension
id="Plugin.markerAnnotationSpecifications"
point="org.eclipse.ui.editors.markerAnnotationSpecification">
<specification
annotationType="Plugin.MyMarker"
colorPreferenceKey="Plugin.markerColor"
colorPreferenceValue="100,100,100"
contributesToHeader="false"
highlightPreferenceKey="Plugin.markerHighlight"
highlightPreferenceValue="true"
includeOnPreferencePage="true"
icon="icons/icon_mine.gif"
label="My beautiful label"
overviewRulerPreferenceKey="Plugin.markerOverview"
overviewRulerPreferenceValue="true"
presentationLayer="0"
symbolicIcon="warning"
textPreferenceKey="Plugin.tarkerText"
textPreferenceValue="true"
textStylePreferenceKey="Plugin.textStyle"
textStylePreferenceValue="BOX"
verticalRulerPreferenceKey="Plugin.markerRuler"
verticalRulerPreferenceValue="true" />
MyPlugin.java
IMarker myMarker = file.createMarker("Plugin.MyMarker");
if(!myMarker.exists()){
Activator.myLog.log(new Status(Status.ERROR, LOG_PLUGIN_NAME, 15, "There's no marker!", null));
}
myMarker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
myMarker.setAttribute(IMarker.MESSAGE, "Txt:\nabc");
myMarker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
myMarker.setAttribute(IMarker.LINE_NUMBER, line);
myMarker.setAttribute(IMarker.CHAR_START, searchStart);
myMarker.setAttribute(IMarker.CHAR_END, searchEnd);
The marker image is here: icon="icons/icon_mine.gif"
If I use the code as it is above, the annotation appears in the menu under the annotations (General>Editors>TextEditors>Annotations)option with the correct image and the correct options as I would expect it to be.
Other log messages that I placed in the code confirm that that code executes well same as the results if I just change that line I commented in the XML (see the XML comment).
But still, I can't see anything telling me if the marker is actually being applied or an error (or anything in the log or the console, on that matter). It is as if I didn't setup anything and nothing is happening.
Any help is welcome
Please do check that the ids of each <extension> must start with the same substring as as the package of the project. I see you using Plugin as the package and packages usually start with low case letters.
Please try renaming the prefixes of the ids to plugin. (low case) instead of Plugin.

GWT uiBinder TabPanel - Tab title from dictionary

I want to change GWT TabPanel behaviour, so it would allow me to set tab titles not directly in .ui.xml files, but in some kind of dictionary class.
Standard tabPanel looks like this:
<gwt:TabPanel ui:field="tabPanel">
<gwt:Tab text="Some tab title">
<gwt:VerticalPanel>
<!-- components -->
</gwt:VerticalPanel>
</gwt:Tab>
<gwt:Tab text="Other tab title">
<gwt:VerticalPanel>
<!-- components -->
</gwt:VerticalPanel>
</gwt:Tab>
</gwt:TabPanel>
I want to use external dictionary with all labels/titles, so I could get the label/title by it's dictionary key, e.g:
Tab.Title.some=Some tab title
Tab.Title.other=Other tab title
So my .ui.xml file should looks like this:
<gwt:TabPanel ui:field="tabPanel">
<gwt:Tab text="Tab.Title.some">
<gwt:VerticalPanel>
<!-- components -->
</gwt:VerticalPanel>
</gwt:Tab>
<gwt:Tab text="Tab.Title.other">
<gwt:VerticalPanel>
<!-- components -->
</gwt:VerticalPanel>
</gwt:Tab>
</gwt:TabPanel>
In all other cases (labels, table headers etc) I was able to extend component class and overload setText(String text) method. But for Tab there is only an interface and I'm not sure what to do with it to get desirable effect. Anyone knows the solution?
You should check out the i18n support for gwt this is probably exactly what you are looking for.
http://www.gwtproject.org/doc/latest/DevGuideUiBinderI18n.html

Categories

Resources