Browse DevX
Sign up for e-mail newsletters from DevX


Divided Loyalty, Part 2: Creating Views and Deploying Plugins in Eclipse and NetBeans : Page 2

Views are an important aspect of any IDE but Eclipse and NetBeans users can write their own custom views and deploy them using each product's unique plugin architecture. Find out how to integrate a single view into either Eclipse, NetBeans, or both.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Integrate the View into NetBeans
In contrast to Eclipse, NetBeans doesn't provide any framework in their module manifest file to help with views. The developer is responsible for creating the shortcut to the view and instantiating the view. In order to get your view to open correctly in NetBeans, you first need to create the action that will open your view. In the article, "Divided Loyalty Part I," I described the process of creating an action for NetBeans, which you can now use as a template to integrate this action for launching the view.

In the class that implements the action, you need to create the view. To do this, use the window manager and find the "mode" (place to attach the view), then dock your newly created view into the mode. For my layout view, I wanted to dock it into the output mode—this area of the screen is along the bottom of a fresh NetBeans install. Now, I need to call the open method on my view to make the view visible.

public class PropertiesViewAction extends CallableSystemAction { public void performAction() { PropertiesView view = PropertiesView.getInstance(); //get window manager WindowManager manager = WindowManager.getDefault(); Mode mode = manager.findMode("output"); mode.dockInto(view); view.open(); } }

Instantiating the View Source Code
NetBeans provides a base class called ExplorerPanel that is needed to create a view. As shown below, I implement my layout view in the singleton pattern, which protects a class from being instantiated more than once (I only want one class to be created for the entire time the IDE is running). To create the singleton pattern for my class, I made my constructor "private" and provided access to the class through a public getInstance() method. Then, I synchronized the getInstance() method to protect it against different threads inadvertently creating more than one instance of my class. Now in my Constructor, I was required to initialize my views UI; this is where you add your code to create the UI for the view. The view will not be displayed until the open method is called.

public class LayoutView extends ExplorerPanel { /** Creates a new instance of LayoutView */ private LayoutView() { initialize(); } public static synchronized PropertiesView getInstance() { if (_instance == null) { _instance = new PropertiesView(); } return _instance; } //create the view's contents private initialize() { Panel panel = new Panel(); add(panel, BorderLayout.CENTER); } protected void updateTitle() { setName("Nexaweb Layout View"); } }

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date