• Home
  • Nous contacter

Le blog d'Adfab

Le blog d'Adfab

Le blog d'Adfab

Le blog d'Adfab
e-Commerce Outils

Magento plugin for NetBeans IDE (part. 1)

NetBeans IDE is an open-source software which is intended for development in JAVA (at the first versions) but also supports the others languages such as C/C++, PHP, HTML5/CSS3 and Javascript. NetBeans IDE is a cross-platform softwareand  runs on Microsoft Windows, Mac OS, Linux, Solaris. NetBeans IDE  supports PHP since version 6.5 and more and more features are included in its PHP bundle:

  • Syntax highlighting, code completion
  • PHP code debugging with xdebug
  • Testing with PHPUnit
  • Support PHP frameworks: Symfony 1/2, Zend, Yii

This tutorial is built on the version 8.2. If you are using an older version, try to update to the latest version to avoid the errors while going through the tutorial. There are the bundles separated for the programming languages particular but to build a plugin, it requires the NetBeans Platform SDK so we suggest you to download the bundle « all ». You can disable the unused features in the installation.

0_bundles

Create a Module project

We start by creating an empty module project in NetBeans Platforms SDK.

  1. Choose File → New Project.
    1. In Categories: choose NetBeans Modules.
    2. In Projects: choose Module.1_new_project
  2. Name and Location:
    1. Enter “MageBeans” in Project Name field.
    2. In Project Location field, choose the directory on your computer where the module will be stored.
    3. Choose Standalone Module mode.
    4. Click “Next” button.1_new_project_2
  3. Basic Module Configuration:
    1. Type “fr.adfab.magebeans” in Code Name Base field. This is the unique string identifying the module. The code name base is also used as the main package of the module.
    2. We use the default NetBeans module system so do not need to check the “Generate OSGi Bundle”.
    3. The source code will be created after clicking the “Finish” button.1_new_project_3

Implementing the module

We will create some Java packages in the main package created within previous step to make our source code well structured:

  • fr.adfab.magebeans.actions: Will contain all the Actions. An Action is a piece of code which handles the event invoked by the user to do something in the NetBeans IDE. An Action can be invoked from a click on menu item, toolbar icon, context menu item or by keyboard shortcut.
  • fr.adfab.magebeans.guis: This package contains all the GUI Java form design. These form allow the module to get user data to create a module, a model or other class.
  • fr.adfab.magebeans.processes: Where we store all the Java classes which are the main processes. Ex: the process of creating the folder structure for a module, the process of generating the configuration files, etc. These Java classes are independent with NetBeans Platform SDK so we can reuse these classes to create a plugin of other PHP IDE like PhpStorm or Eclipse.

Our source code structure like this2_project_structure

Create the Action

  1. Right click on package fr.adfab.magebeans.actions, choose New → Action.
  2. Action Type panel:
    1. Choose Conditionally Enabled → Cookie class: Project. We need to make sure that a project is selected before calling the Action.2_new_action
  3. GUI Registration
    1. In Category: Enter “MageBeans” to create new category action group. We will use this category for the further actions.
    2. Select Global Menu Item → Menu: Source → Position: Here – Format. A menu item will be created in the main menu Source.
    3. Select Global Toolbar Button → Toolbar: File → Position: Save All – Here. A button will be added to the toolbar menu.2_gui
  4. Name, Icon and Location
    1. The Class Name will be used to create the Java class source so it requires a unique name. Here, we choose “CreateModuleAction”.
    2. The Display Name is the text will be displayed in Main menu.
    3. Because we already chose “Global Toolbar Button” so an icon image is required. Icon image need to have size of 16×16. You can add also an additional icon with size of 24×24 for a big toolbar by put another image file with name ended by 24 in same folder. You can find this image in the list of created files below.
    4. The Project & Package are already filled but if you can change the package where the Java class file will be created.2_name_icon

A Java class source file will be created


@ActionID(
    category = "MageBeans",
    id = "fr.adfab.magebeans.actions.CreateModuleAction"
)
@ActionRegistration(
    iconBase = "fr/adfab/magebeans/actions/magebeans.png",
    displayName = "Create Magento Module"
)
@ActionReferences({
    @ActionReference(path = "Menu/Source", position = 200, separatorAfter = 250),
    @ActionReference(path = "Toolbars/File", position = 500)
})
public final class CreateModuleAction implements ActionListener {

    private final Project context;

    public CreateModuleAction(Project context) {
        this.context = context;
    }

    @Override
    public void actionPerformed(ActionEvent ev) {
        // TODO use context
    }
}

The most important function is actionPerformed. This function will be called when the menu item or toolbar button is clicked.

In the next tutorial, we will implement this function to display an input form which allows user to choose the location of module, the name of module and some other additions feature.

22/12/2016 40 MIN READ TAGS: Backend Development, E-Commerce, Magento, Netbeans BY: Van Thiep Nguyen 0 COMMENT
SHARE
LIRE LA SUITE

Van Thiep Nguyen

Magento : import de masse avec Magmi

CakePHP is the shit

VOUS POURRIEZ AIMER

Outils Compte rendu du Velocity Europe 2013 – Jour 2

L'actualité AdFab Outils Migration d’un projet de SVN à GIT

Outils Répéter une tâche, ou automatiser?

Backend Développement Outils Strapi v3, une mise à jour majeure

Outils DG Mediamind : premiers pas !

DevOps Outils GitLab [6/6] : GitLab Runner

A propos d’Adfab

Nous sommes un studio de production digitales et d’innovation digitales au service des agences et des annonceurs
Nous recherchons le scintillement dans les regards et le plaisir de réalisations sur-performantes
Nous sommes techno-agnostiques
Nous sommes Adfab

Le blog d'Adfab
Copyright © 2018 Adfab Connect