// Path: engine/jprol-gui/src/main/java/com/igormaznitsa/jprol/easygui/AbstractProlEditor.java
// public final static class PropertyLink {
// 
//   private final Object ownerObject;
//   private final Class<?> ownerClass;
//   private final String name;
//   private final String property;
// 
//   public PropertyLink(final Object object, final String name, final String property) {
//     this.name = name;
//     this.ownerObject = object;
//     this.ownerClass = object.getClass();
//     this.property = property;
//   }
// 
//   public Object getOwner() {
//     return ownerObject;
//   }
// 
//   @SuppressWarnings("unchecked")
//   public Object getProperty() {
//     try {
//       Method meth = ownerClass.getMethod("get" + property, (Class[]) null);
//       return meth.invoke(ownerObject);
//     } catch (Throwable thr) {
//       throw new RuntimeException("Can't read property", thr);
//     }
//   }
// 
//   @SuppressWarnings("unchecked")
//   public void setProperty(final Object obj) {
//     try {
//       ownerClass.getMethod("set" + property, new Class<?>[] {obj.getClass()}).invoke(ownerObject, obj);
//     } catch (Throwable thr) {
//       throw new RuntimeException("Can't set property", thr);
//     }
//   }
// 
//   @Override
//   public String toString() {
//     String str = this.name;
//     final Object val = getProperty();
//     if (val instanceof Boolean) {
//       str += " (" + val.toString() + ")";
//     }
// 
//     return str;
//   }
// }


import java.util.ArrayList;
import java.util.Arrays;
import com.igormaznitsa.jprol.easygui.AbstractProlEditor.PropertyLink;
import javax.swing.*;
import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
                        .addComponent(buttonCloseDialog, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
    );

    layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonCloseDialog, buttonEditOption});

    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 349, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonEditOption)
                    .addComponent(buttonCloseDialog))
                .addContainerGap())
    );

    pack();
  }// </editor-fold>//GEN-END:initComponents

  private void buttonCloseDialogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCloseDialogActionPerformed
    dispose();
  }//GEN-LAST:event_buttonCloseDialogActionPerformed

  private void buttonEditOptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEditOptionActionPerformed
    final TreePath path = optionsTree.getSelectionPath();
    if (path == null) {
      return;
    }
// Path: engine/jprol-gui/src/main/java/com/igormaznitsa/jprol/easygui/AbstractProlEditor.java
// public final static class PropertyLink {
// 
//   private final Object ownerObject;
//   private final Class<?> ownerClass;
//   private final String name;
//   private final String property;
// 
//   public PropertyLink(final Object object, final String name, final String property) {
//     this.name = name;
//     this.ownerObject = object;
//     this.ownerClass = object.getClass();
//     this.property = property;
//   }
// 
//   public Object getOwner() {
//     return ownerObject;
//   }
// 
//   @SuppressWarnings("unchecked")
//   public Object getProperty() {
//     try {
//       Method meth = ownerClass.getMethod("get" + property, (Class[]) null);
//       return meth.invoke(ownerObject);
//     } catch (Throwable thr) {
//       throw new RuntimeException("Can't read property", thr);
//     }
//   }
// 
//   @SuppressWarnings("unchecked")
//   public void setProperty(final Object obj) {
//     try {
//       ownerClass.getMethod("set" + property, new Class<?>[] {obj.getClass()}).invoke(ownerObject, obj);
//     } catch (Throwable thr) {
//       throw new RuntimeException("Can't set property", thr);
//     }
//   }
// 
//   @Override
//   public String toString() {
//     String str = this.name;
//     final Object val = getProperty();
//     if (val instanceof Boolean) {
//       str += " (" + val.toString() + ")";
//     }
// 
//     return str;
//   }
// }


// Path: engine/jprol-gui/src/main/java/com/igormaznitsa/jprol/easygui/OptionsDialog.java
import java.util.ArrayList;
import java.util.Arrays;
import com.igormaznitsa.jprol.easygui.AbstractProlEditor.PropertyLink;
import javax.swing.*;
import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

                        .addComponent(buttonCloseDialog, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
    );

    layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonCloseDialog, buttonEditOption});

    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 349, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonEditOption)
                    .addComponent(buttonCloseDialog))
                .addContainerGap())
    );

    pack();
  }// </editor-fold>//GEN-END:initComponents

  private void buttonCloseDialogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCloseDialogActionPerformed
    dispose();
  }//GEN-LAST:event_buttonCloseDialogActionPerformed

  private void buttonEditOptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEditOptionActionPerformed
    final TreePath path = optionsTree.getSelectionPath();
    if (path == null) {
      return;
    }
    final AbstractProlEditor.PropertyLink prop = (PropertyLink) path.getLastPathComponent();