Changeset 7202


Ignore:
Timestamp:
Oct 17, 2016, 2:59:28 PM (6 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #2032: Annotation importer should have a configuration setting for item type

It is now possible to select which item types (multiple choice) an annotation import configuration is valid for.

The setting is only used for hiding configurations that should not be used in a given context. If no item types are specified the configuration can be used everywhere.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plugins/core/net/sf/basedb/plugins/AnnotationFlatFileImporter.java

    r7150 r7202  
    8181import net.sf.basedb.core.signal.ThreadSignalHandler;
    8282import net.sf.basedb.plugins.util.Parameters;
     83import net.sf.basedb.util.Enumeration;
    8384import net.sf.basedb.util.Values;
    8485import net.sf.basedb.util.error.ClassMapErrorHandler;
     
    375376    return guiContexts;
    376377  }
     378 
     379  @SuppressWarnings("unchecked")
    377380  @Override
    378381  public String isInContext(GuiContext context, Object item)
    379382  {
    380     return null;
     383    List<String> itemTypes = (List<String>)configuration.getValues("itemTypes");
     384    Item itemType = context.getItem();
     385
     386    if (itemTypes == null || itemTypes.isEmpty() || itemTypes.contains(itemType.name()))
     387    {
     388      return null;
     389    }
     390   
     391    return "Not used for " + itemType.toString().toLowerCase() + " items";
    381392  }
    382393  @Override
     
    440451          // Store column headers for use in the next configuration step
    441452          columnHeaders = parser.getColumnHeaders();
     453        }
     454        else
     455        {
     456          storeValues(configuration, request, ri.getParameter("itemTypes"));
    442457        }
    443458
     
    10271042        parameters.add(fileParameter);
    10281043      }
     1044      else
     1045      {
     1046        Enumeration<String, String> items = new Enumeration<String, String>();
     1047        for (GuiContext ctx : getGuiContexts())
     1048        {
     1049          Item i = ctx.getItem();
     1050          ctx.getItem().name();
     1051          items.add(i.name(), i.toString());
     1052        }
     1053        items.sortValues();
     1054       
     1055        PluginParameter<String> itemTypesParameter =
     1056          new PluginParameter<String>("itemTypes", "Item types",
     1057            "Specify which types of items this file format is used for. If " +
     1058            "not specified it will be used for all types.",
     1059          new StringParameterType(255, null, false, 0, 0, 0, items));
     1060       
     1061        parameters.add(itemTypesParameter);
     1062      }
    10291063
    10301064      // Parser regular expressions
Note: See TracChangeset for help on using the changeset viewer.