Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
JNIEXPORT jobject JNICALL Java_com_graebert_userinput_Properties_GetProperties( JNIEnv * env, jclass clazz )
{
    CFxDocument* pDocument = ACTIVE_DOCUMENT();
    if ( pDocument == nullptr )
        return nullptr;

    CFxSelectionSet* pSelection = pDocument->GetFxMainSelectionSet();
    if ( pSelection->GetLength() != 1 )
        return nullptr;

    OdDbObjectId idSelected = pSelection->GetId( 0 );
    OdDbEntityPtr pSelectedEntity = idSelected.openObject();
    if ( pSelectedEntity.isNull() )
        return nullptr;

    auto properties = GetEntityProperties( pSelectedEntity );

    CFxObjectConstructor arrayCreator( "android/util/ArrayMap" );
    arrayCreator.Call();
    jobject arrayHandle = arrayCreator.GetResult();

    CFxObjectInvocation insertInvocation( "android/util/ArrayMap", "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;" );
    for ( auto& property : properties )
    {
        CFxJavaString key( property.first );
        CFxJavaString value( property.second );

        insertInvocation.Call( arrayHandle, key.GetJString(), value.GetJString() );
    }

    return GET_JAVA()->NewGlobalRef( arrayHandle );
}

ARESDelegate.java

Code Block
languagejava
@Override
public void mainSelectionSetChanged(boolean isEmpty, String commonObjectDxfClassName)
{
   final ArrayMap<String, String> res = Properties.GetProperties();
   if ( res != null && res.size() > 0 )
   {
       CFxARESInstance.instance().runOnUiThread(new Runnable()
       {
           @Override
           public void run()
           {
               m_Host.DisplayProperties( res );
           }
       });
   }
}

...