Hexagon Geospatial
MENU

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Contributor
Posts: 47
Registered: ‎11-12-2015

Java plugin - custom editing function

I would like to implement my own editing function for GMSC using java plugin. I want to see this function in the editing pane with default functions like move, split line etc.

 

Which classes/methods should I implement/use? I have already tried to create action class like that 

 

public class MyEditAction extends EditAction
implements Runnable, MeasurementListener
{...}

 

then plugin with Action like that

 

@Action(
conditions=@Condition(actionCondition=EditActionConditionFactory.class,parameters={@Parameter(name="minimumSelection",defaultValue="1",description=""),@Parameter(name="geometryTypes",defaultValue="EditPolyline",description="")}))
public void GE_MYEDITFN(com.intergraph.tools.utils.disptach.RPAction a)
{
EditAction action = new MyEditAction(this.editPlugin);
action.run();
}

 

and I tried to programatically starts editing with EditSettings settings.setActions(ActionConfiguration.parseMapActions("GE_MYEDITFN"));

 

Editing starts but without my editing function - I got 16:51:24 WARNING: GE_INTERPOLATELINE isn't a known action!

 

I have two questions:

1) Is this the correct way to implement own editing function and if it is, what else should I do to make it work?

2) If the answer to 1) is NO, where should I start (which classes/methods should I implement) to create custom editing function? (Just need to know where to start)

 

Thanks

 

Tereza

Technical Evangelist
Posts: 133
Registered: ‎10-20-2015

Re: Java plugin - custom editing function

Hi Tereza,

I never tried to add a custom EditAction by using a GMSC plugin but from my current point of view it should work.

 

Your code itself looks good, but you missed one special thing. GMSC has a so-called ActionDispatcher is able to call methods which are marked by the com.intergraph.tools.utils.disptach.annotations.Action annotation.

 

The ActionDispatcher is powerful but this class isn't able to find @Action marked methods without your help, because you have to tell the ActionDispatcher which classes contain such marked methods.

 

The GMSC framework contains two AbstractActionDispatcher implementations:

  1. The global ActionDispatcher - hold's actions which are populated to the whole application
  2. the MiniDispatcher - can be used for more local stuff, like dialogs

 

The EditPlugin itself uses a MiniDispatcher and therefore you have to do the following:

  1. Get the EditPlugin's MiniDispatcher
  2. Register all actiosn of your MyEditAction class

The following code sould do that for you.

 ApplicationContext.getPluginCurator().getByType(EditPlugin.class).ifPresent(p -> {
      p.getDataModelHandler().getMiniDispatcher().registerAllActions(MyEditAction.class);
    });

Best Regards,

Steve

Contributor
Posts: 47
Registered: ‎11-12-2015

Re: Java plugin - custom editing function

Hi Steve,

 

thanks for the answer. I tried to apply proposed solution, but it gave me the error: 

 

30.11.2015 12:29:10 SEVERE: Can't start edit! --> 
java.lang.IllegalStateException: state is NOTINITIALIZED but a state > PREPARING was expected!
at com.intergraph.web.plugin.edit.EditPlugin.getDataModelHandler(EditPlugin.java:276)

 

The problem is that the action has to be registered BEFORE start of editing, but  EditDataModelHandler and MiniDispatcher are initialized AFTER editing started. I guess I need to register the action somewhere earlier. 

 

Regards,

Tereza

Staff
Posts: 890
Registered: ‎10-18-2015

Re: Java plugin - custom editing function

Hi Tereza,

 

We checked the problem and unfortunately that was the only chance we had to do something like that.

Another solution would be to write your own Action which is visible in your tab, map-context or favorits.

 

Best regards,

Stefano

Stefano Turcato
Presale Engineer
Hexagon Geospatial
Highlighted
Contributor
Posts: 47
Registered: ‎11-12-2015

Re: Java plugin - custom editing function

Hi Stefano,

 

thanks for the answer, I will try a different solution.

 

Regards

Tereza

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.