Versions Compared

Key

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

Anchor
top
top
 



動的なUIを設定したい場合、UIPに以下の機能を含めることで、依存パラメーターやオプションパラメーター、ボタンコールバックのような、より複雑なUIインタラクションを実現することができます。

 



 




public String buttonPressed(String key)

ボタン押下コールバック関数です。こちらの関数は、「key」に指定されたボタンパラメーターが押下された場合に呼び出されます。モーダルポップアップに、ユーザーに表示するメッセージを返します。

 



例:

こちらの例は、ボタンを押下することで「ボタンを押下しました」、というメッセージをポップアップします。

 



Code Block
languagejava
@Override
protected void setupParameters() {
   Parameter p = new Parameter();
   p1.setUniqueKey("MESSAGE");
   p1.setDisplayType(DISPLAY_BUTTON);
   ...
   addParameter(p);
}
 
@Override
public String buttonPressed(String key) {
   if ("MESSAGE".equals(key)) {
      return "You pressed the button!";
   }
}

 

...

 







public boolean isParameterRequired(String key)

指定されたパラメーターを表示する必要がある場合はtrueを返します。Subclassは、他のパラメーターの値に基づく不必要なパラメーターを無効にするために、このメソッドを上書きすることができます。デフォルトの実装では、trueを返します。

 



例:

以下の例では、パラメーターは、他のパラメーターが、追加構成の必要な値を持つ場合にのみ表示されます。例えば、必要な時にサブ構成のみを表示することで、プラグインのUIの整頓に役立てることができます。 



Code Block
languagejava
@Override
public boolean isParameterRequired(String key) {
   Object otherValue = getParameterValue("OTHER_KEY");
   if (parameterIsRequiredBasedOnOtherValue(key, otherValue)) {
      return true;
   }
   return false;
}

 

 

...







public boolean hasDependentParameters(String key)

指定されたパラメーターに依存する他のパラメーターがある場合にtrueを返します。Subclassはパラメーター間の依存関係を設定するために、このメソッドを上書きすることができます。デフォルトの実装では、falseを返します。

...

isParameterRequired」を使用した、このメソッドの例です。 



Code Block
languagejava
@Override
protected void setupParameters() {
   // p1 is a toggle which controls whether or not we are choosing a dog
   Parameter p1 = new Parameter();
   p1.setUniqueKey("CHOOSEDOG");
   p1.setDisplayType(DISPLAY_CHECKBOX);
   ...
 
   // p2 is a dropdown for which dog we will choose, only to be displayed when p1 is checked
   Parameter p2 = new Parameter();
   p1.setUniqueKey("DOGCHOICE");
   p1.setDisplayType(DISPLAY_SELECT);
   p1.addOption("LAB", "Labrador");
   p1.addOption("HUSKY", "Husky");
   ...
 
    addParameter(p);
}
 
@Override
public boolean isParameterRequired(String key) {
   if ("DOGCHOICE".equals(key)) {
      Boolean choiceVal = (Boolean)getParameterValue("CHOOSEDOG");
    if (choiceVal == null || choiceVal != true) {
         return false; // don't show this parameter unless the other parameter is true
      }
   }
   return true;
}
 
@Override
public boolean hasDependentParameters(String key) {
   if ("CHOOSEDOG".equals(key)) {
      return true;
   }
   return false;
}

 

 

 

...



...

width40%

前項:基礎的なUIのセットアップ

...

width30%

...


...

width30%

後項:付録

...