How to add Drag and Drop over SWT CommonNavigator - java

I have a CommonNavigator view and unable to add drag and drop support on it by tradition way of addDrag&Dropsupport method.
I want to drop some files from File Systen over the CommonNavigator.
After searching I found , I just needed to hook the dropAgent and it will work. So I did like following-
point="org.eclipse.ui.navigator.navigatorContent">
<navigatorContent
contentProvider="com.infineon.stt.session.explorer.ui.SessionContentProvider"
id="com.infineon.stt.session.explorer.ui.navigatorContent"
labelProvider="com.infineon.stt.session.explorer.ui.SessionLabelProvider"
name="Session Navigation Content">
<dropAssistant
class="com.infineon.stt.session.explorer.ui.ResourceDropAdapterAssistant"
id="org.eclipse.ui.navigator.resources.resourceDropAdapter">
<possibleDropTargets>
<or>
<adapt type="org.eclipse.core.resources.IProject"/>
<adapt type="org.eclipse.core.resources.IFolder"/>
<adapt type="org.eclipse.core.resources.IFile"/>
<adapt type="org.eclipse.core.resources.IWorkspaceRoot"/>
</or>
</possibleDropTargets>
</dropAssistant>
<triggerPoints>
<instanceof
value="com.infineon.stt.session.model.SessionRoot">
</instanceof>
</triggerPoints>
</navigatorContent>
But even it didn't work.
Any suggestion to make the scenario work.
I followed up this example-
https://github.com/aptana/studio3/blob/4cada2cfef2969d11bd62fcce7d630a05b6cab64/plugins/com.aptana.explorer/plugin.xml

The solution was very simple.
I was committing a mistake of restricting the drag and drop to specific type.
To allow any kind if Object , I just need to pass possibledroptarget as object-
<possibleDropTargets>
<or>
<adapt type="java.lang.Object"/>
</or>
</possibleDropTargets>

Related

Izpack toggel Checkbox on Install Location

I have a checkbox for Windows Service installation in a UserInput Panel and i would want to make this dependent with the installation path.
If the installation path is local drive, then the "install windows service" checkbox should appear.
But if the installation path is a Network Shared location or a mounted Drive , the checkbox shouldnt appear.
For this i tried using Dynamic variable along with a Condition
Here is the snippet from install.xml
<conditions>
<condition type="variable" id="install.path.condition">
<name>$INSTALL_PATH</name>
<value>//</value>
</condition>
</conditions>
<dynamicvariables>
<variable name="windowsservice" value="false" condition="install.path.condition" />
<variable name="windowsservice" value="true" condition="!install.path.condition" />
</dynamicvariables>
The target field in install_userinputspec.xml
<field align="left" type="check" variable="windowsservice" conditionid="install.path.condition" revalidate="true">
<os family="windows"/>
<spec txt="Install as Windows Service" id="windowsServiceCheckbox" true="on" false="off"
set="false" />
</field>
I tried my luck getting this work, but it wont. Please help
Change $INSTALL_PATH to INSTALL_PATH
<name>INSTALL_PATH</name>
If you're not sure about the exact value that will be entered for the INSTALL_PATH then instead of using a condition of type="variable" use type="contains"with a nested <variable> tag, such as:
<condition type="contains" id="...">
<variable>INSTALL_PATH</variable>
<value>a substring to match in the value of INSTALL_PATH</string>
</condition>
IzPack doc contains cond.
Use revalidate="yes" as an attribute of the <spec> tag and not the <field> tag itself.
First, try to make your <condition> work. Once you've tested that, the check field can be linked to the condition directly for enabling/disabling and as such, you do not need to use <dynamicvariables> in this case, unless you need it for something other than checkbox-enable-disable-based-by-INSTALL_PATH.

How to disable global(File-->Rename) menu in RCP application

I am stuck with this issue since yesterday. I want to disable (or hide) the default eclipse rename menu item under file contextual menu.
I was able to hide the one under right click menu using activities like:
<extension point="org.eclipse.ui.activities">
<activity id="rename.disable" name="Hidden activities">
<enabledWhen>
<not> <reference definitionId="DataEnginePlugin.testProjectNatureExtension"/></not>
</enabledWhen>
</activity>
<activityPatternBinding activityId="rename.disable" pattern="org.eclipse.ui.edit.rename"/>
</extension>
But, i am not able to disable the global one under File menu (F2).
Any ideas please!!
Thanks
The format of the pattern for the activityPatternBinding is 'contributing plugin id / item id'. Also the default pattern is a regular expression, you want an exact match here. So you want:
<activityPatternBinding
isEqualityPattern="true"
activityId="rename.disable"
pattern="org.eclipse.ui/org.eclipse.ui.edit.rename"/>

How do I make JPA POJO classes + Netbeans forms play well together?

I started using netbeans to design forms to edit the instances of various classes I have made in a small app I am writing. Basically, the app starts, an initial set of objects is selected from the DB and presented in a list, then an item in the list can be selected for editing. When the editor comes up it has form fields for many of the data fields in the class.
The problem I run into is that I have to create a controller that maps each of the data elements to the correct form element, and create an inordinate number of small conversion mapping lines of code to convert numbers into strings and set the correct element in a dropdown, then another inordinate amount of code to go back and update the underlying object with all the values from the form when the save button is clicked.
My question is; is there a more directly way to make the editing of the form directly modify the contents of my class instance? I would like to be able to have a default mapping "controller" that I can configure, then override the getter/setter for a particular field if needed. Ideally, there would be standard field validation for things like phone numbers, integers, floats, zip codes, etc...
I'm not averse to writing this myself, I would just like to see if it is already out there and use the right tool for the right job.
There are many approaches,
JBoss Seam, for instance, uses an Ant (And whether you do not know, NetBeans uses Ant behind the scenes) tool called hbmtemplate. It is a Template based Engine in which can be controlled by a user provided template or class. Along with Freemarker Template (.flt extension), it generates all of Application. If you want to see how see how Seam generates its Applications, Take a look at <SEAM_HOME>/seam-gen/view. There, you can see o lot of Freemarker Template.
Here is how Seam generates its Application
<hibernate templatepath="${templates.dir}">
<jpaconfiguration persistenceunit="${project.name}"/>
<classpath>
<dirset dir="${project.home}/exploded-archives">
<include name="*.war/WEB-INF/classes" if="project.war"/>
<include name="*.war/WEB-INF/dev" if="project.war"/>
<include name="*.jar" if="project.ear"/>
</dirset>
</classpath>
<property key="hibernatetool.util.toolclass" value="org.jboss.seam.tool.Util"/>
<hbmtemplate filepattern="{class-name}List.xhtml" template="view/list.xhtml.ftl" destdir="${project.home}/view" foreach="entity"/>
<hbmtemplate filepattern="{class-name}.xhtml" template="view/view.xhtml.ftl" destdir="${project.home}/view" foreach="entity"/>
<hbmtemplate filepattern="{class-name}.page.xml" template="view/view.page.xml.ftl" destdir="${project.home}/view" foreach="entity"/>
<hbmtemplate filepattern="{class-name}Edit.xhtml" template="view/edit.xhtml.ftl" destdir="${project.home}/view" foreach="entity"/>
<hbmtemplate filepattern="{class-name}Edit.page.xml" template="view/edit.page.xml.ftl" destdir="${project.home}/view" foreach="entity"/>
<hbmtemplate filepattern="${action.dir}/{class-name}List.java" template="src/EntityList.java.ftl" destdir="${project.home}/src" foreach="entity">
<property key="actionPackage" value="${action.package}"/>
</hbmtemplate>
<hbmtemplate filepattern="{class-name}List.page.xml" template="view/list.page.xml.ftl" destdir="${project.home}/view" foreach="entity"/>
<hbmtemplate filepattern="${action.dir}/{class-name}Home.java" template="src/EntityHome.java.ftl" destdir="${project.home}/src" foreach="entity">
<property key="actionPackage" value="${action.package}"/>
</hbmtemplate>
<hbmtemplate filepattern="menu.xhtml" template="view/layout/menu.xhtml.ftl" destdir="${project.home}/view/layout" foreach="entity"/>
</hibernate>
Here goes some code, not all, from FreeMarket Template view.xhtml.ftl
<#foreach property in pojo.allPropertiesIterator>
<#if !c2h.isCollection(property) && !isToOne(property) && property != pojo.versionProperty!>
<#include "viewproperty.xhtml.ftl">
</#if>
</#foreach>
I hope it can be useful to you
See my answer to your other question here. (In short: using beans binding would help a bit I hope)

Using nameFilters for excluding a particular type of items

In eclipse's plugin extentions we can have pop up menus applicable for particular item depending on the type we specify in the nameFilter field. But now i want it to be reversed,
means I want this pop up menu not to be shown for some types of items(based on its extensions).
So is it possible. Need help badly.
Thanks
I haven't try it, but...
<viewerContribution
id="IlexGuiConsole.viewerContribution2"
targetID="IlexGuiConsole.viewerContribution2">
<action
class="ilexguiconsole.Action2"
id="IlexGuiConsole.action2"
label="label">
<enablement>
<not>
<objectClass
name="ilexguiconsole.Object2">
</objectClass>
</not>
</enablement>
</action>
</viewerContribution>

Eclipse-Plugin with submenu. How to handle JavaProjects and Projects?

I want to write an Eclipse-plugin that performs an Action with a selected Project. I used the plugin Template with submenu. My plugin.xml looks like this :
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.core.internal.resources.Project"
id="testplugin2.contribution1">
<menu
label="Propertie Manager"
path="additions"
id="testplugin2.menu1">
<separator
name="group1">
</separator>
</menu>
<action
label="list all *.properties"
class="testplugin2.popup.actions.ListPropertiesAction"
menubarPath="testplugin2.menu1/group1"
enablesFor="1"
id="testplugin2.projectAction">
</action>
</objectContribution>
</extension>
this works fine for everything but javaProjects. It turns out that javaProjects are not Projects. I want this Action to appear when a javaProjects or a normal Projects is selected and not if something else is selected.
How can I make the submenu appeare exactly if a javaProject or a Project is selected?
I didn't test it, but maybe this works:
<objectcontribution ...>
<visibility>
<objectClass
name="org.eclipse.jdt.core.IJavaProject" />
</visibility>
</objectContribution>
You can also try "enablement" instead of "visibility".
eclipse help pages on popup menus
Make sure the adaptable property of your object contribution is set to true (it defaults to false):
adaptable="true"
#iain suggestion to target the interface is also good practice.
Just tried your example and the menus were showing as expected on a Java project.
Always bear in mind adpatability to org.eclipse.core.resources.IResource in general to ensure your menus, actions to be consistently displayed and enabled (whatever the explorer or actual object class being rendered).
Finally, beware that the org.eclipse.ui.popupMenus extension point is deprecated.
Though in my experience using it is faster and easier than the recommended org.eclipse.ui.commands, you may end up having a hard time migrating all your menus when it is removed (that is, if it is removed at some point).
Cheers,
You should not reference the internal class in you object class. You should use the public interface instead
objectClass="org.eclipse.core.internal.resources.Project"
Try
objectClass="org.eclipse.core.IProject"
I haven't tried this but IJavaProject should adapt to the IProject, so this should work for both.

Categories

Resources