1. What the popup menu looks like in an eclipse editor?
This tutorial shows how to add a popup menu item to an editor context. In this example, a menu item called “ShowIFile” is added like the following:
Month: February 2013
Eclipse Design Patterns – Singleton in Platform
Actually this is the simplest pattern in this Eclipse Design Patterns series. The basic idea of a Singleton pattern is there is always only one instance for a target object. The following simply gives several examples from commonly used Eclipse API. Note that not all methods are from org.eclipse.core.runtime.Platform. Platform.getAdapterManager(); //only one AdapterManagerPlatform.getAdapterManager(); //only one … Read more
Eclipse RCP Tutorial: Add a Popup Menu
The following are snapshots of every step involved when creating a popup menu by using PDE.
Eclipse RCP Tutorial: Add a menu item to the popup menu when right click a file
The following tutorial shows how to add a menu item to the popup menu when right click a .java file in Package Explorer View.
If you know how to create a typical plug-in project, you can skip the first step.
Eclipse RCP Tutorial: How to install PDE
PDE is what you need for developing Eclipse Plug-in projects. Installing PDE is the first step for doing RCP development. It can be installed in two different ways. 1. Download an eclipse version with PDE Download site URL: http://www.eclipse.org/downloads/ The version you will need is “Eclipse for RCP and RAP Developers”. 2. Install PDE as … Read more
Java Design Pattern: Interpreter
Major revision in progress … Please come back later. Interpreter pattern is used when some context needs to be interpreted. The following example is a very simple Interpreter implementation. It interpretes letter “a” and “b” to “1” and “2”. Class Diagram Note that: the dependency is also shown in diagram to make the structure more … Read more
Java Design Pattern: Iterator
Iterator pattern is used to iterate through a collection of objects. It is a commonly used pattern, you probably have used it before. Whenever you sees something like hasNext() and next(), it is probably a iterator pattern. For example, you may iterate through a list of database query record. Iterator Pattern Class Diagram Iterator Pattern … Read more
LeetCode – Inorder Successor in BST II (Java)
Given a binary search tree and a node in it, find the in-order successor of that node in the BST. The successor of a node p is the node with the smallest key greater than p.val. You will have direct access to the node but not to the root of the tree. Each node will … Read more
Java Design Pattern: Flyweight
Flyweight pattern is used for minimizing memory usage. What it does is sharing as much data as possible with other similar objects. 1. Flyweight Pattern Class Diagram 2. Flyweight Pattern Java Code // Flyweight object interface interface ICoffee { public void serveCoffee(CoffeeContext context); }// Flyweight object interface interface ICoffee { public void serveCoffee(CoffeeContext context); } … Read more
How to answer coding questions for your interview?
I have been interviewing companies recently. Here I summarize what I learned from my experience. Interview is just a show in which you perform to the best of your ability. If the interviewer like your show, you win; otherwise, you lose. There is a chance that you play better than what you are, this is … Read more
Java Design Pattern: Prototype
Prototype design pattern is used when very similar objects are frequently created. Prototype pattern clones objects and set the changed feature. In this way, less resources are consumed. 1. Prototype Pattern Class Diagram 2. Prototype Pattern Java Example package designpatterns.prototype; //prototype interface Prototype { void setSize(int x); void printSize(); } // a concrete … Read more
Java Design Pattern: Chain of Responsibility
The main idea of Chain of Responsibility design pattern is to build a chain of processing unit, each unit handle the request if threshold is satisfied. Since a chain is built, if one unit is not satisfied, it’s next unit will be tested, and so on. Each request will be process along the chain. Chain … Read more
Java Design Pattern: Memento
In future, time travel will be invented. Memento is the key to time travel. Basically, what it does is to allow an object to go back to a state. In the following example, You can time travel to any era for your Life, and You can restore to a previous era you have been to. … Read more
Java Design Pattern: Builder
The key feature of Builder pattern is that it involves a step-by-step process to build something, i.e., every produce will follow the same process even though each step is different. In the following example, we can define a drink builder called StarbucksBuilder which will build a Starbucks drink. StarbucksBuilder has several steps to build a … Read more
Java Design Pattern: Mediator
Mediator design pattern is used to collaborate a set of colleagues. Those colleagues do not communicate with each other directly, but through the mediator. In the example below, Colleague A want to talk, and Colleague B wants to fight. When they do some action(i.e., doSomething()), they invoke mediator to do that. Mediator Class Diagram Mediator … Read more