Add custom properties to eclipse's project class - eclipse

I have a custom project nature and created a new project that has this new custom nature.
What I am trying to do now, is extend the properties of that project, so when it is selected e.g. in package explorer view, not only the standard project properties are shown in the (standard) property-view but also customized ones (like the nature of the selected project - but only for a project that has my custom nature)
Is this possible with standard eclipse extension points?
I have doubts since I don't have my own class where I could register a property-descriptor, just a new nature.

You should be able to define a project properties page without a project class, as I've done in the Haskell plugin:
<page
name="%projectFlagsPP_name"
class="net.sf.eclipsefp.haskell.ui.properties.UserFlagsPP"
id="net.sf.eclipsefp.haskell.ui.properties.UserFlagsPP">
<filter
name="nature"
value="net.sf.eclipsefp.haskell.core.project.HaskellNature">
</filter>
<filter
name="open"
value="true">
</filter>
<enabledWhen>
<adapt type="org.eclipse.core.resources.IProject" />
</enabledWhen>
</page>
And then the java code starts like:
public class UserFlagsPP extends PropertyPage implements
IWorkbenchPreferencePage {
This says that the property page will appear for a IProject that has the Haskell Nature...

Related

Uno Platform ViewModelLocator

I'm testing uno platform solution to see if it's flexible enough and can integrate pre existing autofac (6.2.0) and Autofac.Extras.CommonServiceLocator(6.0.1) stuff in it.
I want to add the ViewModelLocator to auto resolve view models. it's working with UWP and wpf project, but not with droid or WASM.
I added in shared app.xaml the resource
<Application
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- #Region MVM light view model locator -->
<ResourceDictionary>
<local:ViewModelLocator x:Key="ViewModelLocator" d:IsDataSource="True" />
</ResourceDictionary>
<!-- #Endregion -->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
In the mainpage.xaml
DataContext="{Binding [TestViewModel], Source={StaticResource ViewModelLocator}}"
whit this configuration the constructor is called at startup where I also want to set up Inversion of control stuff
public ViewModelLocator()
{
this._container = IOCContainerConfig.Configure();
var serviceLocator = new AutofacServiceLocator(this._container);
ServiceLocator.SetLocatorProvider(() => serviceLocator);
//this._dbContext = serviceLocator.GetInstance<IContext>();
//TestDbConnection(this._dbContext);
}
As said this is not working with other kind of projects like droid or wasm the constructor of the locator is never called but I don-t have errors, just page is loaded without the viewmodel behind.
Any ideas or tips to make it working for all projects?
Depending on the type of resource, Uno Platform is initializing some resources in a ResourceDictionary lazily only when they are accessed. This is done as a performance optimization.
To guarantee that the ViewModelLocator constructor is always called on all platforms, it may be better to call it from code, eg from the App constructor in App.xaml.cs.

View does not displayed

I have made Hello World RCP application and got the following class structure:
ApplicationActionBarAdvisor.java
ApplicationWorkbenchAdvisor.java
ApplicationWorkbenchWindowAdvisor.java
Application.java
Perspective.java
Further I tried to add some view to the perspective.
Add extension point to my plugin.xml:
<extension point="org.eclipse.ui.views">
<view
class="first.rcp.application.MainView"
id="first.rcp.application.MainView"
name="name"
restorable="true">
</view>
</extension>
and created class MainView.java.
Add additional code to Perspective.createInitialLayout():
layout.addStandaloneView(MainView.ID, true, IPageLayout.LEFT, 1.0f, layout.getEditorArea());
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
try {
activePage.showView(MainView.ID);
} catch (PartInitException e) {
e.printStackTrace();
}
But view does not displayed.
I set breakpoint into Perspective.createInitialLayout() and found that it is not performed.
I tried to add showPerspective() method to ApplicationWorkbenchWindowAdvisor() and set PERSPECTIVE_ID in ApplicationWorkbenchAdvisor to the id of my perspective.
But the code into Perspective.createInitialLayout() still not performed.
Which point it should be called from?
Eclipse IDE have Java perspective with number of views opened by default. I.e. createInitialLayout() of the Java perspective is called during launching of eclipse IDE. How is it implemented? May be there are some configuration file?
My perspective declaration is:
<extension point="org.eclipse.ui.perspectives">
<perspective
name="RCP Perspective"
class="first.rcp.application.Perspective"
id="first.rcp.application.Perspective">
</perspective>
</extension>
The code in ApplicationWorkbenchAdvisor.getInitialWindowPerspectiveId() is:
public String getInitialWindowPerspectiveId() {
return PERSPECTIVE_ID;
}
private static final String PERSPECTIVE_ID = "first.rcp.application.Perspective";
Solution №1.
Go through the New Plug-in project wizard, make sure 'would you like to create a rich client application' is set to Yes, make sure 'Generate an activator, a Java class that controls the plug-in lifecycle' is cheked and select 'Hello RCP' on the Available Template page.
Go to MANIFEST.MF, Extensions. Add new extension 'org.eclipse.ui.views', add an appropriate class.
Add new extension 'org.eclipse.ui.perspectiveExtensions' with the view. Specify view id to the id of the previously created view.
Solution №2.
Go through the New Plug-in project wizard, make sure 'would you like to create a rich client application' is set to Yes, make sure 'Generate an activator, a Java class that controls the plug-in lifecycle' is cheked and select 'RCP application with a view' on the Available Template page.

Add dynamic team actions in Eclipse

I am developing an Eclipse Team Plugin. I want to contribute the Team popup menu, so I have defined an action in my plugin.xml file:
<plugin>
<extension point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="true"
id="com.myexample.ui.ResourceContributions"
objectClass="org.eclipse.core.resources.IResource">
<action
class="com.myexample.ui.actions.MyAction"
id="com.myexample.ui.actions.MyActionId"
label="Execute action" />
</objectContribution>
</extension
</plugin>
Also have an implementation for the action:
public class MyAction extends TeamAction {
...
}
At this point all is ok, my action is shown and I can execute it.
Now, what I want is to change the text of the action dynamically, when the selection changes, depending in some properties of the selected objects.
Is this possible? How could I do it? Could I do it programmatically?
Here is what I would try:
Override TeamAction.selectionChanged(IAction action, ISelection selection) in your MyAction class
Invoke IAction.setText(String text) in your overridden method.

Extend Teamsite actions

I was wondering if it possible to extend Teamsite functionality? For example, I would like to add my own button under Actions -> MyAction which would perform my java based operation (update pages or something)?
For custom menu actions you'll need to make modifications to
<iw-home>/local/config/lib/content_center/customer_src/etc/conf/customer/ui_custom.xml
There should be some examples in the file unless you've erased the contents. The basic format is as follows:
<action-list id="iw.ccpro.filesys.menubar">
<menu id="iw.ccpro.action.menu">
<link id="company.ccpro.list_directory.custMenuAction.link"
label="Custom Action"
description="Custom Action Description"
url="/iw-bin/custom_menu_action.ipl"
target="_blank"
icon="/base/images/customIcon.gif"
/>
</menu>
</action-list>
For a Java based operation you would just change the url to your servlet path.
For example:
url="<iw-hostname>/iw-cc/command/customJavaAction"

How to create customise property page for custom navigator

Hi friends I m new to eclipse plugin. I need to create a new custom navigator and depending on the selection of the elements in the navigator i want to display the corresponding property sheet for it. I had gone through various tutorials but m not finding how to do it. Thanks.
Basically, you have to provide an Adapter for the model objects added into the custom navigator. The simplest way to do that is to register an Adapter factory extension point something like that:
<extension
point="org.eclipse.core.runtime.adapters">
<factory
adaptableType="the type from the model navigator"
class="«your adapter factory class»">
<adapter
type="org.eclipse.ui.views.properties.IPropertySource">
</adapter>
</factory>
</extension>
If you have the adaptable factory, you could follow the article Take control of your properties.