Add dialogs for element configurations

Create new plug-in project.

Create new class (for example LoginConfigurations) and make it extend CorePlugin.

Implement method run. This method must verify if the attribute is the desired and if it is return the new PropertyDescriptor as may be seen below for the Login configurations example:

public class LoginConfigurations extends CorePlugin{
   @Override
   public IPropertyDescriptor run() {
      if (pkg.getLogin_Entries().equals(feature)) {
         return new LoginEntryPropertyDescriptor(object, itemPropertyDescriptor);
      }
      else {
         return null;
      }
   }
}

IMPORTANT: Else with return null must always be present.

LoginEntryPropertyDescriptor is another class that must also be created (não com este nome, mas com outro que se entenda adequado). This class extends PropertyDescriptor and will be similar to:

public class LoginEntryPropertyDescriptor extends PropertyDescriptor {
   public LoginEntryPropertyDescriptor(Object object, IItemPropertyDescriptor itemPropertyDescriptor) {
      super(object, itemPropertyDescriptor);
   }
 
   @Override
   public CellEditor createPropertyEditor(Composite parent) {
      return new ExtendedDialogCellEditor(parent, getLabelProvider()) {
         @Override
         protected Object openDialogBox(Control cellEditorWindow) {
            // Here you are free to open a custom dialog that you have
            // created. In this example, we simply open an
            // ElementListSelectionDialog
 
            Login login = (Login) object;
            List<LoginEntry> list = login.getEntries();
 
            LoginEntriesDialog dialog = new LoginEntriesDialog(Display.getCurrent().getActiveShell(), list);
            dialog.create();
            int result = dialog.open();
            if(result == Window.OK && !dialog.getItems().isEmpty()){
               return dialog.getItems();
            }
            else if(result == Window.CANCEL && !dialog.getItems().isEmpty()){
               return list;
            }
            else{
               return new ArrayList<LoginEntry>();
            }
         }
      };
   }
}

Attention to the dialog creation in line:

LoginEntriesDialog dialog = new LoginEntriesDialog(Display.getCurrent().getActiveShell(), list);

This dialog must also be created by the developer, afterall, that is the goal, have a customized configuration dialog.

After creating all the neccessary classes, select project Paradigm.pluginLoader and the project recently created and in the context menu choose “export…” and next “Java→JAR File”.

  • Select all elements of both projects mentioned before.
  • Select the options “Export generated class files and resources”, “compress the contents of the jar file” and “add directory entries”.
  • Choose the path to save the Jar file to be created and press “Next>”.
  • Select “Export class files with compile errors” and “Export class files with compile warnings” and press “Next>”.
  • Select “Generate Manifest File” and “Seal some packages”.
  • Press “Finish”.

After creating the Jar file, place it in the lib folder of Paradigm.edit.ui

Next, reference the Jar in the project, to do this:

  • in the “java build path” press “add jar” and add the desired jar.
  • in MANIFEST.MF add lib/nomeDoJar.jar em Bundle-ClassPath.
  • in build.properties add lib/JarName.jar in bin.includes

The newly created configuration dialog is ready to use.

<< Script generation


Programmer manual

paradigmme/programmer_manual/configuration_creation.txt · Last modified: 2013/04/04 19:01 by tiago