How to find resources with label decorator's value in eclipse - eclipse

I am working on an eclipse plugin in which I have used decorators to decorate my resources with different text as a prefix. Now I want to search these resources with the text which I have used while decorating the resources.
What I exactly want is to extend eclipse's open resource dialogue so that I can enter the text which I have used to decorate resources to find them.
So how could I achieve this...
Many thanks..

The Open Resource dialog is not really customizable.
The dialog class is org.eclipse.ui.internal.ide.dialogs.OpenResourceDialog. This extends FilteredResourcesSelectionDialog which contains most of the label providers and the like which you would have to change. However this class is not designed to be modified and would be hard to change.
FilteredResourcesSelectionDialog in turn is derived from FilteredItemsSelectionDialog which can be extended more easily, but you would have to duplicate a lot of code from OpenResourceDialog and FilteredResourcesSelectionDialog.

Related

Liferay 7.2 Customize Documents And Media Porlet

I have Liferay 7.2
I want to customize the html of the layout of the widget Documents AND Media
I tried to create a hook to document and media but it seems that is not the right way.
How can i do that?
First, the fact that you're talking about a hook tells me that you're coming from Liferay 6 or earlier. Forget the old module types ("war-style modules"), embrace the new "jar-style modules" or "OSGi modules", which leverage the OSGi methods and mechanisms in the foundation. The new module type that comes closest to the functionality of hooks would be a "module fragment".
Alternatively, if you want to create one module that overrides the JSPs of more than one other module (or overrides JSPs as a side effect to its main purpose), you may want to look into "JSP Bags".
Still, both methods are discouraged and should be taken as a last resort, according to Liferay's "Introduction to Customizing JSPs".
The preferred method would be to use Dynamic Includes (albeit they only work if the target portlet has been written to include inclusion points) or Portlet Filters (which basically allow you to programmatically edit the request to and response from the standard Portlet classes and JSPs).
Still, if you're aiming to replace most of the JSPs of the standard document and media widget (keep in mind: Widgets are still Portlets, they just have been renamed in the frontend), a module fragment still seems to the best way forward.
To identify the correct module, here are the necessary steps. I'll show it using the DLAdmin portlet from the control panel as an example:
Identify the portlet you want to edit: Look into the HTML using the DOM inspector of your browser. Look for section tags with IDs like <section class="portlet" id="portlet_com_liferay_document_library_web_portlet_DLAdminPortlet"> around the area of interest.
Now translate that ID into a package path with portlet class: com.liferay.document.library.web.portlet.DLAdminPortlet. Search for that class in the Liferay github repository. (Go there, press T, enter the class name, find its Java class source file. In case of multiple hits, you need to check the package path, too.)
Once you opened the source file, go back up in the file tree to the parent folder of the src folder. There's a bnd.bnd file. Take a look into it, it will tell you the Bundle-SymbolicName.
Use the Liferay IDE or Blade CLI (depending on your development environment) to create a module fragment for the module identified by the Bundle-SymbolicName.

Papyrus: Hide/remove base_Class property from stereotypes

Is there a way to hide or remove the various base_Class properties that appear together with the properties defined for a stereotype? I am close to deploy a profile and I am pretty sure this will generate some confusion among the users.
Actually you really don't want to remove the 'base_*' properties as these indicate the meta class that your stereotypes extend. When a user goes to apply your profile, the meta class extension allows the UML editor e.g. Papyrus to display appropriate stereotypes for the target UML element. So if a user wants to apply your profile to a UML Class element, without the 'base_Class' property, nothing will show up. These extensions are linked to other elements within your profile so just removing them will cause your profile to "break" elsewhere. Other typical meta class extensions might be Property i.e. a 'base_Property' will show up. There are many others.
Oh ok cool. So when your users apply the profile to a model this takes place, as you know, primarily under the Profile->Applied stereotypes area of the Properties editor. The meta class extension properties are definitely not visible there, at least on my Papyrus version. Using Modeling Luna 4.4.0

Which eclipse listener should I use to add annotations to a text editor

I am an eclipse newbie. I have a long term goal which is to add my own annotations to the java editor: a bit like FindBugs. I want my own static code analysers, and to be able to add markers/annotations to resources.
So I have read a lot of excellent documentation, and undertaken a load of tutorials. The most helpful was probably http://www.ibm.com/developerworks/opensource/tutorials/os-ecl-commplgin2/section9.html. A lot of the Lars Vogel documents have been useful too. I can now make TextEditors with syntax highlighters. I am however struggling with the best approach for adding annotations.
I understand roughly how to do this: the text editor has a DocumentProvider. The DocumentProvider has an AnnotationModel. It is possible to add annotations to the annotation model.
My question is "where do I put this code" specifically the code that scans the text in the editor and updates the annotation model. It seems clear that this should be in response to a listener...but which one?
I have tried a ResourceChangeListener. This seems to only fire on a save option, rather than when text is typed. In addition I don't know how to get the editor from the resource. ("The" editor is probably a misnomer as presumably the resource can be open in multiple editors). I can find the current editor via IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor(), but this seems the wrong approach, as I want to update all relevant annotation models.
I have tried adding an ElementStateListener to the text editor. None of the events seem to be the one I want.
I've looked at DamageRepairers...these seem to nearly be what I want, except that long term I want to tie into the JavaEditor, so I don't want to change the default DamageRepair.
Thanks for all the help
I found that this question can be answered, by mentioning the following resource: www.ibm.com/developerworks/opensource/tutorials/os-eclipse-plugin-guide/index.html
The question author also mentions here:
I add the annotations to the resource, and the annotations are
auto-magically added to the editor.
So when my plugin starts I run through the active resources, add
annotations to them if needed, then add a resource changed listener
which adds them as the resource is opened.

Eclipse SWT - WizardPage widgets validation

What is the best way to validate Text, Combo and any other SWT widget included in Eclipse Wizard? Recently, I got into a project in which there are many different wizards. I tried to add FocusListeners, ModifyListeners etc. however the size of code and it's complexity was not what I expected.
Let's say there are two Text elements in WizardPage. They both cannot be empty and should contain only small letters. How to write a validator which checks if fields are empty or contain unexpected characters and display an error message in case something went wrong.
The way it has to be done must be sophisticated, elegant and useful.
I would recommend using JFace databindings (I use them myself). You will be able to add validators to particular binding and automatically show validation errors/warnings in the wizard.
In addition to Eugene I can recommend following site for a nice JFace databinding example in context with wizard pages.
http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet014WizardDialog.java?view=markup
But don't miss to insert those plugins into your plugin.xml
org.eclipse.core.databinding
org.eclipse.core.databinding.beans
org.eclipse.jface.databinding
org.eclipse.core.databinding.property

Adding a list to a PreferencePage

Update:
So far I found class ListEditor which provides the functionality I'm searching for except the 'edit' button and only for one column.
The 'Proxy bypass' Page extends directly from PreferencePage. So there is no proper Base Class I could use.
--
The standard PDE way of adding Preference is to use field editors (for Boolean, String, Integer..) and subclass FieldEditorPreferencePage.
I'd like to integrate a list similar to the 'Network Connections' List in Preferences.
Network Connections Preferences http://img13.imageshack.us/img13/4489/screencapturegw.png
Is there a Standard List Class with Add/Edit/Remove Button I could use or is extending the PreferencePage and do all loading/saving manually the way to go?
the m2Eclipse Plugin also has a List m2Eclipse http://img695.imageshack.us/img695/1972/screencapture1.png
it uses TemplatePreferencePage, which has too much functionality
I remember looking for something similar to edit a list of classpaths and did not find it. JDT had something but it was too much for what I needed. I think you have to do it on your own. If you do something generic, you could file an enhancement request to platform UI at Eclipse and contribute it. Doing it on my own was not too much work.
My conclusion is there is no proper Base Class I could use.
However the Proxy Bypass Page is an example how to implement such a feature, it extends directly from PreferencePage