Pencarian

Rss Posts

 

 

 

Roy Ganor: if-ify, for-ify, foreach-ify and func-ify

Feb 19, 2012

A common question?among developers is how to surround the current selection in the editor with a parent statement. For example if you start coding a statement that validates an expression and then want to iterate over an array of expressions and do the same to all its elements.
For this end Eclipse?templates provide two variables “line_selection” and “word_selection” that help you build custom selection-based wrappers.
In this example three new templates were added to simplify this scenario:

You can import these templates (xml below) to your IDE via Preferences > PHP > Editor > Templates > Import…

EclipseLive: Upcoming Event: Reminder – C/C++ Development Tooling for Eclipse Indigo

Apr 19, 2011

Event Date: April 21, 2011 4:00 pm GMT-8

Register Now

Doug Schaefer (Wind River)
?
Abstract:

The CDT Project provides professional strength tools for C/C++ developers. Doug Schaefer, lead of the Eclipse CDT project, will present an overview of the CDT and demo the latest work for the Indigo release, coming at the end of June. Topics will include support for Android native development, refactoring, CODAN static analsis, Visual C++ integration, support for desktop and embedded development and what’s next for the project.

Total running time will be approximately 1 hour

9:00 am PST / 12:00 pm EST / 4:00 pm UTC / 6:00 pm CET – Convert to other time zones

Thanks to Adobe for contributing their Adobe Acrobat Connect product to host this webinar.


delicious delicious | digg digg | dzone dzone

Kai Toedter: Dynamic modular Web Applications with Vaadin and OSGi

Jan 02, 2011

I am a big fan of both OSGi and GWT (Google Web Toolkit). Unfortunately these two technologies don?t fit together very well. When you want to run OSGi on the server, RAP (Rich Ajax Platform) is one proven approach to go. While I like RAP a lot, you have to have quite a lot of Eclipse RCP know how for using it. Another alternative, if your want to run OSGi on the server and provide a modular, dynamic UI is Vaadin. Btw, Vaadin is the Finnish word for female reindeer. Vaadin is a server side RIA framework that uses GWT as rendering engine. In the last couple of days a played a bit around with Vaadin and I have to admit, I like it a lot. So, I wrote a little dynamic OSGi Vaadin demo (Download link and instructions are below). My goals for the demo were:

  • Provide Bundles that contribute directly to the web application?s UI
  • Just starting and stopping bundles should contribute/remove UI elements and functionality
  • I wanted to implement something similar to my dynamic Swing OSGi demo

Before I started with Vaadin, I found a few interesting reads and code sample regarding OSGi and Vaadin:

But back to the demo, here is a screen shot running the application in Firefox:

The idea is to support two kinds of UI contributions: views and actions. The views are inserted in a tab folder, the actions appear in the toolbar and the Action menu. I implemented a little OSGi agent as a view (Bundle View). This view shows a selection of bundles currently available. By checking/unchecking a bundle, it will be activated/stopped on the server side. If you press ?Deselect All?, all bundles go to resolved state and all the UI contributions disappear immediately:

Of course you could start and stop bundles from the OSGi console directly, then you would have to refresh the browser to get the changes displayed. To get the demo running on your local machine, follow these steps:

  • Make sure you have an Eclipse IDE installed
  • Download the demo sources and target platform osgi-vaadin-demo.zip (6.8 MB)
  • Import all projects from the zip file into Eclipse
  • Open the project ?com.siemens.ct.osgi.vaadin.target?
  • Double-click vaadin.target (That opens the target platform definition in an editor)
  • Click on ?Set as Target Platform? in the right top corner of the editor
  • Now everything should compile
  • Start the Run Configuration ?OSGi Vaadin Demo?
  • Open the following URL in your favorite browser ?http://localhost/com.siemens.ct.osgi.vaadin.pm.main?
  • If everything went well, you see the demo in your browser
  • Play around with it, activate/stop bundles and watch the console log

In the next weeks I plan to go a little bit more into details of the demo, how OSGi declarative services are used, how to contribute to Vaadin Themes, etc.

Stay tuned and have fun!

Kai

Follow me on Twitter

flattr this!

Hendy Irawan: How to Dump/Inspect Object or Variable in Java

Dec 26, 2010

Scala (console) has a very useful feature to inspect or dump variables / object values :

scala> def b = Map("name" -> "Yudha", "age" -> 27)
b: scala.collection.immutable.Map[java.lang.String,Any]

scala> b
res1: scala.collection.immutable.Map[java.lang.String,Any] = Map((name,Yudha), (age,27))

Inside our application, especially in Java programming language (although the techniques below obviously works with any JVM language like Scala and Groovy) sometimes we want to inspect/dump the content of an object/value. Probably for debugging or logging purposes.

My two favorite techniques is just to serialize the Java object to JSON and/or XML. An added benefit is that it’s possible to deserialize the dumped object representation back to an actual object if you want.

JSON Serialization with Jackson

Depend on Jackson (using Maven):
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.6.3</version>
</dependency>
Then use it:
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

..
Logger logger = LoggerFactory.getLogger(getClass());

@Test
public void level() throws ServiceException, JsonGenerationException, JsonMappingException, IOException {
MagentoServiceLocator locator = new MagentoServiceLocator();
Mage_Api_Model_Server_HandlerPortType port = locator.getMage_Api_Model_Server_HandlerPort();
String sessionId = port.login("...", "...");
logger.info(String.format("Session ID = %s", sessionId));
Map[] categories = (Map[]) port.call(sessionId, "catalog_category.level", new Object[] { null, null, 2 } );
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
logger.info( mapper.writeValueAsString(categories) );
}

Example output :

6883 [main] INFO id.co.bippo.shop.magentoclient.AppTest - [ {
? "position" : "1",
? "level" : "2",
? "is_active" : "1",
? "name" : "Gamis",
? "category_id" : "3",
? "parent_id" : 2
}, {
? "position" : "2",
? "level" : "2",
? "is_active" : "1",
? "name" : "Celana",
? "category_id" : "5",
? "parent_id" : 2
} ]

XML Serialization with XStream

As a pre-note, XStream can also handle JSON with either Jettison or its own JSON driver, however people usually prefer Jackson than XStream for JSON serialization.

Maven dependency for XStream:
<dependency>
<groupId>xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.2.2</version>
</dependency>
Use it:
import java.io.IOException;
import java.rmi.RemoteException;
import java.util.Map;

import javax.xml.rpc.ServiceException;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.thoughtworks.xstream.XStream;
...
@Test
public void infoXml() throws ServiceException, RemoteException {
MagentoServiceLocator locator = new MagentoServiceLocator();
Mage_Api_Model_Server_HandlerPortType port = locator.getMage_Api_Model_Server_HandlerPort();
String sessionId = port.login("...", "...");
logger.info(String.format("Session ID = %s", sessionId));
Map category = (Map) port.call(sessionId, "catalog_category.info",
new Object[] { 3 } );
XStream xstream = new XStream();
logger.info( xstream.toXML(category) );
}

Sample output:

5949 [main] INFO id.co.bippo.shop.magentoclient.AppTest - <map>
? <entry>
??? <string>position</string>
??? <string>1</string>
? </entry>
? <entry>
??? <string>custom_design</string>
??? <string></string>
? </entry>
? <entry>
??? <string>custom_use_parent_settings</string>
??? <string>0</string>
? </entry>
? <entry>
??? <string>custom_layout_update</string>
??? <string></string>
? </entry>
? <entry>
??? <string>include_in_menu</string>
??? <string>1</string>
? </entry>
? <entry>
??? <string>custom_apply_to_products</string>
??? <string>0</string>
? </entry>
? <entry>
??? <string>meta_keywords</string>
??? <string>gamis, busana muslim</string>
? </entry>
? <entry>
??? <string>available_sort_by</string>
??? <string></string>
? </entry>
? <entry>
??? <string>url_path</string>
??? <string>gamis.html</string>
? </entry>
? <entry>
??? <string>children</string>
??? <string></string>
? </entry>
? <entry>
??? <string>landing_page</string>
??? <null/>
? </entry>
? <entry>
??? <string>display_mode</string>
??? <string>PRODUCTS</string>
? </entry>
? <entry>
??? <string>level</string>
??? <string>2</string>
? </entry>
? <entry>
??? <string>description</string>
??? <string>Gamis untuk muslimah</string>
? </entry>
? <entry>
??? <string>name</string>
??? <string>Gamis</string>
? </entry>
? <entry>
??? <string>path</string>
??? <string>1/2/3</string>
? </entry>
? <entry>
??? <string>created_at</string>
??? <string>2010-12-24 11:37:41</string>
? </entry>
? <entry>
??? <string>children_count</string>
??? <string>0</string>
? </entry>
? <entry>
??? <string>is_anchor</string>
??? <string>1</string>
? </entry>
? <entry>
??? <string>url_key</string>
??? <string>gamis</string>
? </entry>
? <entry>
??? <string>parent_id</string>
??? <int>2</int>
? </entry>
? <entry>
??? <string>filter_price_range</string>
??? <null/>
? </entry>
? <entry>
??? <string>all_children</string>
??? <string>3</string>
? </entry>
? <entry>
??? <string>is_active</string>
??? <string>1</string>
? </entry>
? <entry>
??? <string>page_layout</string>
??? <string></string>
? </entry>
? <entry>
??? <string>image</string>
??? <null/>
? </entry>
? <entry>
??? <string>category_id</string>
??? <string>3</string>
? </entry>
? <entry>
??? <string>default_sort_by</string>
??? <null/>
? </entry>
? <entry>
??? <string>custom_design_from</string>
??? <null/>
? </entry>
? <entry>
??? <string>updated_at</string>
??? <string>2010-12-24 11:37:41</string>
? </entry>
? <entry>
??? <string>meta_description</string>
??? <string>Jual baju gamis untuk muslim</string>
? </entry>
? <entry>
??? <string>custom_design_to</string>
??? <null/>
? </entry>
? <entry>
??? <string>path_in_store</string>
??? <null/>
? </entry>
? <entry>
??? <string>meta_title</string>
??? <string>Gamis</string>
? </entry>
? <entry>
??? <string>increment_id</string>
??? <null/>
? </entry>
</map>

Which one is better?

I personally prefer JSON, but fortunately, you always have a choice. :-)

Dave Carver: Developer Culture Shock

Dec 15, 2010

Corporate developers seem to struggle a bit more when a company open sources their internally developed code. It’s not so much the development or coding aspect of it, but more the interaction and community building aspects they struggle with.

Some common items they struggle with:

  1. No knowledge silos. An open source project can’t afford to have knowledge silos. A successful project needs a team that can work on any piece of the project. This goes against most corporate training where people have very specific roles and responsibilities.
  2. No Testing Team. Developers are required to write their own unit tests, and integration tests. Many corporate developers seem to struggle with this. They have never had to do it, it’s always been the responsibility of the QA team to write the tests.
  3. Maintaining the Build. Again, many are used to just writing and submitting the code. Another team takes care of building the software. Note: This isn’t just a corporate problem, many open source projects struggle with this as well.
  4. Answering and Responding to forum/mailing lists. Typically a developer may never actually communicate with the person that filed a bug report. Part of growing a community is timely responses to questions and bugs.
  5. Marketing and Promotion. That’s the job of everybody on the team, not just the team leader. Again many aren’t used to having to do this, as the Marketing Department will handle promotion, press releases, etc.

None of these are simple things to address, but when choosing the initial team, look for those team members that may already be involved in open source projects. Seed the team with some of these people, and the initial growing pains for the project will be less severe. The biggest thing though, the team has to be willing to adapt and change, what they did in the corporate environment more than likely will not work with their open source project.

Bob Balfe: Google contributes GUI designer tool to Eclipse!

Dec 15, 2010

Wow, perfect timing for our Lotusphere presentation. You can download the tool right from Google or you can read about the functionality it brings.

Tools being donated include the WindowBuilder Java UI design tool as well as CodePro Profiler, a runtime Java analysis gauging factors like memory leaks. Both tools became Google property when the company bought Instantiations in August; they will now become open source projects at Eclipse. WindowBuilder has been used for development related to Standard Widget Toolkit, GWT (Google Web Toolkit), and Swing.

Check out the full article on InfoWorld.

Eclipse Labs – Most Active Project: Eclipse Labs Projects Update for the week of September 17th 2010

Sep 17, 2010


Most Active Projects

code-recommenders – IDE 2.0: Bringing Collective Intelligence into Software Development
anyedittools – AnyEdit plugin adds several new tools to the context menu of text based Eclipse editors, to Eclipse main menu and editor toolbar
birt-functions-lib – A collection of BIRT Aggregate and Script Function Extensions for use in your project
birt-controls-lib – A collection of BIRT ReportItems created through the ReportItem extension point.
wascana – Wascana Eclipse C/C++ IDE for Windows Developers
ostool – Central metadata repository for unstructured data supports records and knowledge management for small and medium-sized organisations.
onotoa – Onotoa is a visual editor for the Topic Maps Constraint Language.

New Projects

java-toto – sweepstake application
multiproperties – MultiProperties is an Eclipse editor for multiple Java properties files editing simultaneously
splendor023 – splendor023
mc920-reconhecimento-facial – Realce da face
smartedu1 – Education management
smartedu – Education management
hypeerweb – BYU CS 340 Project

Heiko Seeberger: How to setup a Scala project with SBT and IDEA

Aug 07, 2010

Today I helped my mate Bernd Kolb setting up a simple Scala project. He had been struggling far too long with various options like Maven, SBT, Eclipse and Intellij IDEA. If I remember correctly it only took a 30 minutes conf call to setup a simple Scala and Lift project with SBT and IDEA. But there are quite a few things to know in order to be successful which I am going to describe here in a step-by-step tutorial. I hope you find it useful. Please let me know any issues.

Why SBT and IDEA?

Why not Maven and Eclipse? Or Ant and Netbeans? Or …? First, we have to make a choice. Second, SBT and IDEA are currently the best build tool and the best IDE for Scala. SBT is written specifically for Scala and offers very fast compilation, interactive mode for continuous compilation, testing, etc., integration for Scala test tools like specs and ScalaTest, cross compiling against different Scala versions and many more. While the Scala IDE for Eclipse recently has made nice progress and the Netbeans plugin looks good, IDEA still offers the best Scala plugin with many features known from a Java IDE, e.g. refactroings, code completion, code navigation, etc.

Preparations

Java 5 or 6 is assumed. Get the SBT launcher and follow the instructions to set it up. Install IDEA 9.0.3 and use its plugin manager to install the Scala plugin. Here we go!

1. Create a SBT project

Create a folder for your project, cd there and run SBT. You will be asked the following questions. Answer like I did or chose different values (except for the Scala version).

Project does not exist, create new project? (y/N/s) y

Name: simple

Organization: localhost

Version [1.0]:

Scala version [2.7.7]: 2.8.0

sbt version [0.7.4]:

Now SBT will download Scala 2.7.7 as well as some other libraries for internal use. And it will download Scala 2.8.0 which is used to build your project.

As soon as the downloads are finished, you are in SBT’s interactive mode. At the prompt enter compile, then ~test (press enter to leave the triggered mode) and then help to make yourself familiar with the features.

Looking at your project in the file system, you will notice a layout similar to Maven: Scala sources go into src/main/scala, Scala tests go into src/test/scala and artifacts go into target. If your project looks different from the one at the right, you probably did not run compile or test. But as it is important to run your project against the same version as it was compiled against, there is a Scala_2.8.0 folder between the target and the classes, test-classes etc.

Update

Thanks to Comments from Bart and Mikko I looked into the sbt-idea-plugin which makes it possible to create the project files for IDEA from SBT. While it is still under active development and there are some minor issues, the current snapshot release 0.1 already produces usable IDEA project files. So you could just go for that plugin and skip the next two steps.

2. Create an IDEA project

Now you have to create an IDEA project on top of your SBT project.

Choose File > New Project …, select Create project from scratch and continue.

Then pick your project folder for Project files location and continue.

Then enter src/main/scala as path for the source directory and continue.

Now it is getting a little tricky!

Select Scala from the list of technologies.

Ignore the erroneous combo for the Version.

Choose Pick files from disk and select scala-compiler.jar and scala-library.jar form project/boot/scala-2.8.0/lib.

Then change the Name to scala-2.8.0 and click Finish.

3. Adjust IDEA project settings

Now you have make some adjustments to align SBT’s and IDEA’s project layout.

Choose Modules on the left and navigate to the Sources tab. Add src/main/resources to the Sources (blue) and src/test/scala and src/test/resources to the Test Sources (green). Exclude (red) .idea, lib, project/boot and target.

?

Next go to the Paths tab and select target/scala_2.8.0/classes for the Output path and target/scala_2.8.0/test-classes for the Test output path.

?

Then choose the Scala facet from the mid column (below the one and only module simple) and unchek Use Scala compilers ….

That’s it! Now you are ready to go.

4. Give it a try

In IDEA go to the src/main/scala folder and choose New > Scala Class from the context menu. Call it Hello and make it an Object.

In the editor delete the package statement and enter the following code:

object Hello {

??def main(args: Array[String]) {

????println(“Hello!”)

??}

}

From the context menu choose Run Hello.main(). IDEA will build your project and then run this object.

After that go to SBT and enter ~run. Watch the output and look for the Hello! message. Then change the message in the code, e.g. to Hello, world!. As you have told SBT to use triggered run by prefixing whith the tilda, your project will be incrementally built and the Hello object run again: Watch the output.

Have fun with Scala, SBT and IDEA!

Ketan Padegaonkar: Code Complexity Visualization for Ruby

Jul 21, 2010

Only Valid Measure of Code Quality

Only Valid Measure of Code Quality

Image from http://www.osnews.com/story/19266/WTFs_m

WTF implies lack of clarity. Clear code is easier to understand, easier to maintain and easier to extend.

Announcing saikuro_treemap ? an easy to setup tool to generate complexity treemaps of ruby code.

See a demo for yourself.

Complexity Visualization of Rake

Wayne Beaton: Eclipse is? Open Source Projects

Jul 14, 2010

One of the great things about Eclipse is that?unlike the celestial event and the unfortunately-named movie?everybody gets to see it; regardless of your location on earth, you have access to Eclipse.

Peanuts

But, like Linus, some people are confused as to the nature of Eclipse. To try and help people better understand Eclipse, I?ve created a ?What is Eclipse?? talk that takes an audience step-by-step from what is commonly understood through a voyage of discovery of the true greatness of Eclipse. More specifically, I start by introducing Eclipse as a Java IDE. This is generally easy for the sorts of audiences that I speak with to understand: folks in the software industry understand IDEs (though there are still a few emacs hermits out there; and I mean ?hermit? in a wholly-endearing way). I spend the next couple of slides broadening the technical horizon by introducing Eclipse as a platform for building IDEs, tools, desktop applications, server applications and runtimes, and more.

All this technology is wonderful. But technology is only part of the Eclipse not-so-secret sauce. All of that technology comes from the many open source projects at Eclipse.

We have a lot of projects at Eclipse. A lot of projects. Up to this point in the presentation, most of the discussion has been around just a small handful of projects. The ?Eclipse? Project is responsible for creating most of what people think of when they think of Eclipse. Specifically, the Eclipse Project creates what we try very hard to consistently refer to as the ?Eclipse SDK? (that is, a software development kit for building Eclipse-based applications). The Eclipse Project leverages the work of several other projects (Equinox comes immediately to mind) to provide important bits of information, but most of the bits that people think of when they think ?Eclipse is a Java IDE? comes from the Eclipse Project.

Now this is where things start to get a little weird. The Eclipse Project is what we call a ?Top-Level Project?. It is?effectively?a container for several smaller-scale projects. Each of these smaller scale projects, often referred to as simply ?projects? or ?subprojects?) is a distinct entity that contributes parts to the greater whole. The Platform Project, for example, produces the UI, workbench, and many other fundamental services and frameworks; the Java development tools (JDT) project produces the Java compiler, editors, debugger, and such; the Plugin-Development Environment (PDE) produces tools to aid in the construction of plug-ins; and more. All these Projects have distinct development teams, web sites, and other resources.

The Eclipse Project is just one of the top-level projects at Eclipse. There are currently twelve top-level projects that organize dozens of projects. Top-level projects provide more than simple organization of projects. Each top-level project has a ?Project Management Committee? (PMC) that is responsible for providing oversight and guidance to the projects in their care. Each top-level project is a little different from the others, reflecting different values and technical areas. Some top-level projects tightly organize their projects; others allow greater levels of flexibility.

The fact of the matter is that we have a heck of a lot of projects at Eclipse. At last count we had more than 250 projects (I can hear you gasp at that number). The project is the finest-grained organizational unit at Eclipse. Each project has its own group of developers (called ?committers?), its own website, forums, mailing lists, source code repositories, downloads and more. Some projects provide aggregations of other projects; a project can, for example, have subprojects of its own.

It?s left to the project teams to decide how they want to organize. Typically, mid-level projects tend to be used to provide some hierarchical organization for related projects. Very often mid-level projects (and top-level projects in some cases) provide handy aggregate builds and downloads of the software produced by the projects they contain. The Web Tools Platform Project, much like the Eclipse Project, is a good example of this. Web Tools contains multiple separate projects (e.g. Dali and EJB Tools), but distributes downloads and updates under the top-level project. As an outsider-looking-in, Web Tools comes across as a single source of software (the fact that it is really multiple projects under the covers is a bit of an implementation detail).

So anyway? we have a lot of projects. They?re organized under top-level projects that provide oversight and guidance. Chances are very good that we have something going on at Eclipse that interests you.

But Eclipse is more than just technology and projects. Eclipse is? a Community.