piątek, 19 listopada 2010

Eclipse Marketplace and Subclipse (no SVNkit bundled)

Today's morning I had a need to configure brand-new PDT environment (Helios SR1). As I am using SVN for versioning the Subclipse plugin is what I usually use. Couple times before I successfully employed Eclipse Marketplace to do the job. Same was this time, but to my surprise this time I was not able to switch SVN interface to SVNKit. The only available was JavaHL implementation. I hope this will be fixed in future, but for now one need to do additional steps to install SVNKit - traditional way of installing plugins.
Help -> Install New Software -> select Subclipse repository and 
check all the available options

The version I worked with were: PDT (Helios SR1) and Subclipse 1.6.15

niedziela, 7 listopada 2010

ActionScript 3.0 - How to limit frames per second of flash animation

The simples way seems to be use SWF meta tag.
Example:

package myPackage {

import required.imports.*;

[SWF(backgroundColor=0xEEEADB,frameRate="5")]

public class MyClass {
..
}

}

sobota, 30 października 2010

How to set human readable address for your facebook profile

It may be not very obvious how to make your profile has human readable address, but actually it is quite easy.
Account -> Account Settings -> Settings -> Username

Note: After setting chosen username you can not change it again!!

HTML site layout with DIV tag and CSS - 1st attempt



ITEM1 | ITEM2 | ITEM3 | ITEM4

How to build simple site layout with DIV tags


In order to see implementation details please look at source of this site ;>.

wtorek, 17 sierpnia 2010

Menu based on commands (org.eclipse.ui.menus - menuContribution)

Extension point: org.eclipse.ui.menus

In order to add new menu menuContribution entry is used.

locationURI property determines where menu will be added.

Examplary locationURI:
→ popup:org.eclipse.ui.popup.any?after=additions
→ toolbar:org.eclipse.ui.views.ContentOutline?after=additions
→ popup:org.eclipse.jdt.ui.PackageExplorer?before=additions

→ menu:sourceMenuId?before=sourceBegin
→ popup:sourcePopupMenuId?before=sourceBegin
→ menu:sourceMenuId?after=sourceBegin
→ popup:sourcePopupMenuId?after=sourceBegin
→ menu:org.eclipse.ui.main.menu?after=sourceMenuId


Where in that cases sourceMenuId and sourcePopupMenuId are menus registered with org.eclipse.ui.actionSets extension point.

Typically menuContribution entries contain command entries.

Command entries can define visibleWhen and properties.
Example:
<menucontribution locationURI="menu:sourceMenuId?before=sourceBegin">
 <command commandId="org.eclipse.php.ui.edit.text.add.description"
  id="AddDescription" mnemonic="%command.mnemonic" style="push">
 <visiblewhen checkEnabled="false">
 <reference definitionId="org.eclipse.php.ui.phpContentType.definition" />
 </visibleWhen>
 </command>
 </menuContribution>
VisibleWhen among others allow to specify reference property which references to definition regristered with org.eclipse.core.expressions.definitions extension point.

Example:
<extension point="org.eclipse.core.expressions.definitions">
<definition id="org.eclipse.php.ui.phpContentType.definition">
<with variable="activeContexts">
<iterate operator="or">
<equals value="org.eclipse.php.core.phpsource" />
</iterate>
</with>
</definition>
</extension>
Other option can be specifying with property.

Example:
<visiblewhen>
<with variable="selection">
<iterate>
<or>
<instanceof value="o.e.editors.OutlineContentProvider$Sources">
</instanceof>
<instanceof value="o.e.editors.OutlineContentProvider$Targets">
</instanceof>
</or>
</iterate>
</with>
</visibleWhen>
or:
<with variable="selection">
<iterate>
<instanceof
             value="c.c.model.VisualizableBlock">
</instanceof>
</iterate>
</with>

poniedziałek, 19 lipca 2010

Build SWT application with maven

There are couple of issues when trying to use SWT with application using Maven for building and deploying. The most fundamental is that you have to deliver separate application per architecture and windowing system. Another one is the fact there are no up-to-date releases of SWT in common Maven repositories. And finally when trying one platform independent binary all handles platforms must be include particular SWT implementations, but here another issue appears: how to put appropriate SWT on class path.

First lets populate our local maven repository with SWT libraries. The first step is to obtain desirable swt implementation for os/ws/arch triples. Lets assume that for needs of this example we limit supported triples to linux/gtk/x86_64, win32/win32/x86, win32/win32/x86_64.

Best can be use p2 director to grab libraries. There is not easy way for importing all swt implementations into one location therefore here you are somewhat weird workaround - each impl needs to be grabbed into separate location.

director/director -consolelog -r http://download.eclipse.org/releases/helios 
-d SWT_GTK -i org.eclipse.swt.gtk.linux.x86
director/director -consolelog -r http://download.eclipse.org/releases/helios 
-d SWT_GTK64 -i org.eclipse.swt.gtk.linux.x86_64
director/director -consolelog -r http://download.eclipse.org/releases/helios 
-d SWT_WIN -i org.eclipse.swt.win32.win32.x86 -p2.os win32 -p2.ws win32 -p2.arch x86
director/director -consolelog -r http://download.eclipse.org/releases/helios 
-d SWT_WIN64 -i org.eclipse.swt.win32.win32.x86_64 -p2.os win32 -p2.ws win32 -p2.arch x86_64

Note that specifying profile details is needed for non-native implementations.

In order to use eclipse:to-maven target we need to mimic eclipse installation with plugin folder. For Linux users:

/tmp/SWTLIBS$ find SWT* -name "org.eclipse.swt.*.jar" | xargs -I{} cp {} SWTLIBS/plugins/
/tmp/SWTLIBS$ ls SWTLIBS/plugins
org.eclipse.swt.gtk.linux.x86_3.6.0.v3650b.jar     org.eclipse.swt.win32.win32.x86_3.6.0.v3650b.jar
org.eclipse.swt.gtk.linux.x86_64_3.6.0.v3650b.jar  org.eclipse.swt.win32.win32.x86_64_3.6.0.v3650b.jar

Once done install jars to the maven repository:
mvn eclipse:to-maven -DdeployTo=eclipse.org::default::file:///home/krma/.m2/repository 
-DeclipseDir=. -DstripQualifier=true

After that we can receive following dependency entries:

 <groupid>org.eclipse.swt.gtk.linux</groupId>
 <artifactid>x86_64</artifactId>
 <version>3.6.0</version>
</dependency>
<dependency>
 <groupid>org.eclipse.swt.win32.win32</groupId>
 <artifactid>x86_64</artifactId>
 <version>3.6.0</version>
</dependency>
<dependency>
 <groupid>org.eclipse.swt.win32.win32</groupId>
 <artifactid>x86</artifactId>
 <version>3.6.0</version>
</dependency>
<dependency>
 <groupid>org.eclipse.swt.win32.win32</groupId>
 <artifactid>x86_64</artifactId>
 <version>3.6.0</version>
</dependency>

But with such configuration there will be one problem. First of all all the SWT implementation will be included to our build. But this is actually not really true as our artifact names are duplicated.

The solution is to force other naming for artifactID by manual installing each jar into local maven repository
mvn install:install-file -Dfile=org.eclipse.swt.gtk.linux.x86_3.6.0.v3650b.jar -DgroupId=org.eclipse -DartifactId=swt.gtk.linux.x86 -Dversion=3.6.0 -Dpackaging=jar -DgeneratePom=true -Dmaven.repo.local=/path/to/mvnrepo

Now the following can be used:
<dependency>
 <groupid>org.eclipse</groupId>
 <artifactid>swt.gtk.linux.x86</artifactId>
 <version>3.6.0</version>
</dependency>
<dependency>
 <groupid>org.eclipse</groupId>
 <artifactid>swt.gtk.win32.win32</artifactId>
 <version>3.6.0</version>
</dependency>

piątek, 28 maja 2010

How to setup Trac for LDAP authentication

First all of I'd like mentioned i'm not Apache master thus do not take responsibility for potential damages whilst following this tutor. But don't be afraid nothing wrong should happen ;).

But to the point. When we decide to install Trac as Apache/httpd application it comes with some basic authentication based on unix password. The following is typical configuration:

<virtualHost *:80>

  ServerName trac.example.com

  <location />
    SetHandler mod_python
    PythonHandler trac.web.modpython_frontend
    PythonOption TracEnv /var/www/trac
    PythonOption TracUriRoot /
  </location>
  <location "/login">
    AuthType Basic
    AuthName "trac"
    AuthUserFile /var/www/trac/auth-file
    Require valid-user
  </location>

</virtualHost>

For switching to LDAP authentication use following:

<virtualhost *:80 >

 ServerName trac.example.com

 <location />
  SetHandler mod_python
  PythonHandler trac.web.modpython_frontend
  PythonOption TracEnv /var/www/trac
  PythonOption TracUriRoot /
 </location>

 <location "/login" >
   AuthType Basic
   AuthBasicProvider ldap
   AuthzLDAPAuthoritative off
   AuthLDAPBindDN "DOMAIN\\BINDUSER"
   AuthLDAPBindPassword PASSWORD
   AuthLDAPUrl LDAPUTL
   AuthName "Authorization required"
   Require valid-user
 </location>

</VirtualHost>


BindDN - the Distinguished Name binddn to bind to the LDAP directory

DOMAIN - name of the domain
BINDUSER - special bind user for accessing non-public data
PASSWORD - password for BINDUSER
LDAPURL - ldap://HOST:389/SEARCHBASE?sAMAccountName?sub

SEARCHBASE - the starting point for the search

The following command can be used to test your LDAP connection:

ldapsearch -h HOST -b "SEARCHBASE" -D "DOMAIN\\BINDUSER" -s sub -x -w PASSWORD "(givenName=K*)"