Eclipse plug-in: nameFilter of propertyPages takes a strange effect - eclipse-plugin

I use Eclipse SDK Mars.1(4.5.1). I create a propertyPages plug-in.
In plugin.xml:
If I change value of “nameFilter” to “.txt”, then only when I select .txt file, the propertyPage item can appear in left of the properties dialog;
If I change value of “nameFilter” to “.java” or “.xml” or even “.*”, then still only when I select .txt file, the propertyPage item can appear.
Here is my plugin.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.propertyPages">
<page
id="com.def.btp_property_3.properties.BTPPropertyPage"
name="BTP Page"
class="com.def.btp_property_3.properties.BTPPropertyPage"
nameFilter="*.java">
<enabledWhen>
<instanceof
value="org.eclipse.core.resources.IFile">
</instanceof>
</enabledWhen>
</page>
</extension>
</plugin>
Can anyone tell me the reason and give me a solution.

For the enableWhen use:
<enabledWhen>
<or>
<instanceof
value="org.eclipse.core.resources.IFile">
</instanceof>
<adapt
type="org.eclipse.core.resources.IFile">
</adapt>
</or>
</enabledWhen>
User interface elements in views are often not instances of IFile, instead they are some other object which can be 'adapted' to IFile. This enabledWhen deals with this case.

Related

Enable plugin only on certain folder (Eclipse RCP)

I created a simple Eclipse plugin, to launch a wizard and create some files, everything is working, I also added an option lo launch the wizard from the New > Mi Wizard menu, but now I want to display this option only when I right click an specific folder in a project, this is what I have so far:
This is my wizard:
<extension point="org.eclipse.ui.newWizards">
<category
name="My Category"
id="com.test.myCategory">
</category>
<wizard
name="My Wizard"
icon="icons/wizard1.gif"
category="com.test.myCategory"
class="com.test.myWizard"
id="com.test.myWizard">
</wizard>
</extension>
And this is how I'm adding the wizard to the New menu:
<extension point="org.eclipse.ui.navigator.navigatorContent">
<commonWizard
type="new"
wizardId="com.test.myWizard"
menuGroupId="testGroup">
<enablement>
<adapt type="org.eclipse.core.resources.IFolder">
<test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="myFacet:1.3" forcePluginActivation="true"/>
</adapt>
</enablement>
</commonWizard>
</extension>
The option in the New menu is displayed correctly, but it is displayed when I right click all folders, is there a way to display the option only when I right click a certain folder, specifically the WebContent folder?
You can use the org.eclipse.core.resources.name property tester to test the resource name:
<adapt type="org.eclipse.core.resources.IFolder">
<and>
<test property="org.eclipse.core.resources.name" value="WebContent"/>
<test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="myFacet:1.3" forcePluginActivation="true"/>
</and>
</adapt>

Izpack simple installation just to copy files

I am trying to make a very simplistic installer using IzPack. It should do the following two things
1. Copy and paste all the content of dist directory to UserHome/MyApp dir.
2. Execute a batch file to edit registry entry to start the jar file on user logon.
But I am stuck at the first step only! nothing is installed if I use the following XML and generate the installer. Generated installer runs and does show the InstallPanel but nothing is copied to the user_home directory.
From what it seems like I am not able to assign value to Install_path variable.
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<installation version="1.0">
<variables>
<variable name="INSTALL_PATH" value="$USER_HOME/MyApp"/>
</variables>
<info>
<appname>My App</appname>
<appversion>1.0</appversion>
<authors>
<author name="My APP Author" email="support#myapp.com"/>
</authors>
<url>http://SomeURL.net</url>
</info>
<guiprefs width="640" height="480" resizable="yes"/>
<locale>
<langpack iso3="eng"/>
</locale>
<panels>
<panel classname="InstallPanel"/>
</panels>
<packs>
<pack name="Base" required="yes">
<description>The base files</description>
<fileset dir="dist" targetdir="$INSTALL_PATH"/>
</pack>
</packs>
</installation>
UPDATE
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<installation version="1.0">
<variables>
<variable name="TargetPanel.dir.windows" value="$USER_HOME\MyTeamNinja"/>
<variable name="TargetPanel.dir.mac" value="$USER_HOME/MyTeamNinja"/>
</variables>
<info>
<appname>My App</appname>
<appversion>1.0</appversion>
<authors>
<author name="MyTeamNinja" email="support#MyTeamNinja.com"/>
</authors>
<url>http://myteam.ninja</url>
</info>
<guiprefs width="640" height="480" resizable="yes"/>
<locale>
<langpack iso3="eng"/>
</locale>
<panels>
<panel classname="DefaultTargetPanel"/>
<panel classname="InstallPanel"/>
<panel classname="SimpleFinishPanel"/>
</panels>
<packs>
<pack name="Base" required="yes">
<description>The base files</description>
<fileset dir="dist" targetdir="$INSTALL_PATH"/>
</pack>
</packs>
</installation>
Now as soon as I click the installer it starts the install but in c:\program files\My App\
what you need is a TargetPanel. it allows the user to select the destination dir. to install the files. the location selected in this panel sets the value of $INSTALL_PATH.
however, you may also override the default value of the $INSTALL_PATH.in order to override the default value of $INSTALL_PATH, you may do the following:
<variables>
<variable name="TargetPanel.dir.windows" value="$USER_HOME/MyApp"/>
<variable name="TargetPanel.dir.unix" value="$USER_HOME/MyApp"/>
</variables>
or,
<variables>
<variable name="DEFAULT_INSTALL_PATH" value="$USER_HOME/MyApp"/>
</variables>
and also, remember to include the TargetPanel before the InstallPanel in case you choose to allow the user to select the target loc. for the installation.
<panels>
<panel classname="TargetPanel"/>
<panel classname="InstallPanel"/>
</panels>
See HERE for more on this.
UPDATE:
place the entry for TargetPanel before the InstallPanel in the <panels> section.
remove the <resources> section:
<resources>
<res id="TargetPanel.dir.windows" src="$USER_HOME/MyApp"/>
<res id="TargetPanel.dir.unix" src="$USER_HOME/MyApp"/>
</resources> This is where the error is being generated. Instead use <variables> to specify default values for ${INSTALL_PATH} (see in my answer above).
also, to set a value for ${INSTALL_PATH} through <variables> you need to use name="DEFAULT_INSTALL_PATH" or TargetPanel.dir.windows/unix
UPDATE 2: The following piece of code installs in the correct location (as specified by you in the defaultInstallDir.txt).
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<installation version="1.0">
<!-- variables>
<variable name="TargetPanel.dir.windows" value="$USER_HOME\MyTeamNinja"/>
<variable name="TargetPanel.dir.mac" value="$USER_HOME/MyTeamNinja"/>
</variables -->
<!-- remove the above <varible> section and include the REQUIRED defaultInstallDir.txt to set the value for the DefaultTargetPanel -->
<resources>
<res id="TargetPanel.dir" src="defaultInstallDir.txt"/>
</resources>
<info>
<appname>My App</appname>
<appversion>1.0</appversion>
<authors>
<author name="MyTeamNinja" email="support#MyTeamNinja.com"/>
</authors>
<url>http://myteam.ninja</url>
</info>
<guiprefs width="640" height="480" resizable="yes"/>
<locale>
<langpack iso3="eng"/>
</locale>
<panels>
<panel classname="DefaultTargetPanel"/>
<panel classname="InstallPanel"/>
<panel classname="SimpleFinishPanel"/>
</panels>
<packs>
<pack name="Base" required="yes">
<description>The base files</description>
<fileset dir="dist" targetdir="$INSTALL_PATH"/>
</pack>
</packs>
</installation>
now, create a file named defaultInstallDir.txt and simply write the following within this file :
$USER_HOME/MyApp
just make sure that you include this file correctly in the installer through the src=".." attribute of the <resources> section and you're good to go.
double clicking on the installer directly installs the files in $USER_HOME/MyApp (in my case: at C:\Users\Sunny\MyApp)

setup installer script in magento module

Hi i am developing a little magento module.
below is my directory structure of module
app/code/local/Xyz/Total
/var/www/magext/app/code/local/Xyz/Total/Block/Prototal.php
/var/www/magext/app/code/local/Xyz/Total/controllers/IndexController.php
/var/www/magext/app/code/local/Xyz/Total/etc/config.xml
/var/www/magext/app/code/local/Xyz/Total/Model/Price/Observer.php
below is my config file code
<?xml version="1.0"?>
<config>
<global>
<blocks>
<total>
<class>Xyz_Total_Block</class>
</total>
</blocks>
<models>
<xyztotal>
<class>Xyz_Total_Model</class>
</xyztotal>
</models>
<events>
<sales_order_place_after>
<observers>
<xyz_total_price_observer>
<type>singleton</type>
<class>Xyz_Total_Model_Price_Observer</class>
<method>apply_discount_percent</method>
</xyz_total_price_observer>
</observers>
</sales_order_place_after>
</events>
</global>
<frontend>
<routers>
<total>
<use>standard</use>
<args>
<module>Xyz_Total</module>
<frontName>newcatalog</frontName>
</args>
</total>
</routers>
<layout>
<updates>
<total>
<file>total.xml</file>
</total>
</updates>
</layout>
</frontend>
</config>
now what i need to install a product attribute through my module
.But i cant understand understand where should i put my installer
script and how to modify config file.
please suggest.
I saw your config.xml i am not able to find xml vesrion.
So you need to give xml version like below example:
<config>
<modules>
<Xyz_Total>
<version>0.1.0</version> <!-- Version of module -->
</Xyz_Total>
</modules>
</config>
Now create the file app/code/local/Xyz/Total/sql/total_setup/mysql4-install-0.1.0.ph‌​p
After that reinstall the module And check it.
You also have to add below code in config.xml under config tag.
<global>
<resources> <!-- These are resource setting giving access to module, read/write permission on database -->
<total_setup>
<setup>
<module>Xyz_Total</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</total_setup>
<total_write>
<connection>
<use>core_write</use>
</connection>
</total_write>
<total_read>
<connection>
<use>core_read</use>
</connection>
</total_read>
</resources>
</global>
After that reinstall module.
Take a look # Adding custom product attributes in Magento using setup script
<modules>
<Xyz_Total>
<version>0.1.0</version>
</Xyz_Total>
</modules>
<global>
....
<models>
<xyztotal>
<class>Xyz_Total_Model</class>
<resourceModel>total_setup</resourceModel>
</xyztotal>
</models>
<resources>
<catalog_setup>
<setup>
<module>Mage_Catalog</module>
<class>Mage_Catalog_Model_Resource_Setup</class><!-- that line !-->
</setup>
</catalog_setup>
</resources>
...
In
app/code/local/Xyz/Total/sql/total_setup/mysql4-install-0.1.0.ph‌​p
$installer->addAttribute('catalog_product', 'offer_type', array(
'backend' => '',
...
));

Eclipse conflicting handlers

On developing an eclipse plugin i created a command in the Manifest extensions with id crtc_v4.session with a default handler crtc_v4.handlers.StartSession , I added a handler in the manifest for this command this handler enables the command according to the variable crtc_v4.sessionvar.
The problem which appears on the console is :
!MESSAGE Conflicting handlers for crtc_v4.session: {crtc_v4.handlers.StartSession#98bc5c} vs {crtc_v4.handlers.StartSession#1265d09}
But it doesn't block running the plugin. I'm asking about the solution for this problem, and whether it affects the performance of my plugin in general ?
Edit :
The snippet that define the command :
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="toolbar:org.eclipse.ui.main.toolbar">
<toolbar
id="crtc_v5.crtctoolbar">
<command
commandId="crtc_v5.session"
icon="icons/neutral.png"
label="Start Session"
style="push">
</command>
</toolbar>
</menuContribution>
The snippet that define the handler :
</extension>
<command
defaultHandler="crtc_v5.handlers.StartSession"
id="crtc_v5.session"
name="session">
</command>
</extension>
And here is the enablement against sessionvar :
<extension
point="org.eclipse.ui.handlers">
<handler
class="crtc_v5.handlers.StartSession"
commandId="crtc_v5.session">
<enabledWhen>
<with
variable="crtc_v5.sessionvar">
<equals
value="LOGGEDIN">
</equals>
</with>
</enabledWhen>
</handler>
You've defined a default handler in the command and another one in the org.eclipse.ui.handlers extension. If you want to use enabledWhen, simply remove the defaultHandler attribute (since both instances provide the same handler, crtc_v5.handlers.StartSession).
When you want to have different handlers provide the behaviour for your command depending on the application state, you would use activeWhen in the org.eclipse.ui.handlers definition, but that doesn't seem to be the case here.

How do I use "org.eclipse.debug.ui.launchShortcuts"?

I have written a custom launcher in Eclipse which I can access via the "Run As" and "Debug As" menu options on the toolbar. I also want to be able to launch via the package explorer and via right clicking on the editor of a file to be launched. I followed the tutorial here to add the shortcut but nothing happens, it does not enter my handling code, nor does it complain regarding the configuration of the extension point.
Here is a snippet from my plugin.xml
<extension point="org.eclipse.debug.ui.launchShortcuts">
<shortcut
id = "org.mylauncher.launchCalcShortcut"
class = "org.mylauncher.LaunchCalcShortcut"
description="Execute calculations"
icon="icons/launch_16_16.png"
label="Calculate"
modes="run, debug" >
<configurationType id="org.mylauncher.launchCalc"/>
</shortcut>
I have also played with removing the (optional) icon attribute, and have separately validated the path of the icon.
I've been modifying this configuration for hours now with no good result and it is impossible to debug as it is not running in my own code at all.
Thanks.
It seems that the correct answer to this problem is to specify a contextual launch shortcut. Here is my working configuration:
<extension
point="org.eclipse.debug.ui.launchShortcuts">
<shortcut
class="com.xxxx.CalcLaunchShortcut"
icon="calc.png"
id="com.xxxx.CalcLaunchShortcut"
label="Calc"
modes="run, debug">
<contextualLaunch>
<contextLabel mode="run" label="Run Calculator" />
<contextLabel mode="debug" label="Debug Calculator" />
<enablement >
<with variable="selection">
<count value="1"/>
<iterate>
<adapt type="org.eclipse.core.resources.IResource">
<and>
<test property="org.eclipse.core.resources.name" value="*.calc"/>
</and>
</adapt>
</iterate>
</with>
</enablement>
</contextualLaunch>
</shortcut>