Topcoder エディタプラグイン作成 メモ2

(とりいそぎで記述.あとで書く部分多数.)
前:http://d.hatena.ne.jp/nise_nabe/20101029/1288343389

以前setProblemComponent()メソッドが動かないと書いていたが、実のところは単にLanguageが間違ってLangaugeとなっていただけだった.公式のページをコピペしたはずなので公式が間違っていたということに.
あと、以前は解凍したら勝手にログ出力されると勘違いしてたけど本当はcontent.confにeditor.debug = true/falseという文言を追加する必要があっただけかもしれない.ちょっと未確認.

ということで改めて、setProblemComponent()メソッドを実装した版を以下に示す.

コード

import javax.swing.JPanel;

import com.topcoder.client.contestant.ProblemComponentModel;
import com.topcoder.shared.problem.ProblemComponent;
import com.topcoder.shared.problem.Renderer;
import com.topcoder.shared.language.Language;

public class Main{
	public JPanel getEditorPanel(){
		return new JPanel() {};
	}
	
	public String getSource(){
		return "";
	}

	public void setSource(String source){
		
	}
	public void setProblemComponent(ProblemComponentModel component, Language language, Renderer renderer){
		ProblemComponent comp = component.getComponent();
	}
}

自分の環境ではこれでcomponentからいろいろな情報が取得できるようになった.このProblemComponentModelは以下のようなインターフェースになっている.
あとでまとめるけどとりあえずコード貼っとく.

package com.topcoder.client.contestant;

import com.topcoder.netCommon.contestantMessages.response.data.ComponentChallengeData;
import com.topcoder.shared.problem.Constraint;
import com.topcoder.shared.problem.DataType;
import com.topcoder.shared.problem.Element;
import com.topcoder.shared.problem.ProblemComponent;
import com.topcoder.shared.problem.TestCase;

public interface ProblemComponentModel
{
  public Long getID();
  public Integer getComponentTypeID();
  public ProblemModel getProblem();
  public Double getPoints();
  public ProblemComponent getComponent();
  public boolean hasSignature();
  public String getClassName();
  public String getMethodName();
  public DataType getReturnType();
  public DataType[] getParamTypes();
  public String[] getParamNames();
  public ComponentChallengeData getComponentChallengeData();
  public boolean hasStatement();
  public boolean hasIntro();
  public Element getIntro();
  public boolean hasSpec();
  public Element getSpec();
  public boolean hasNotes();
  public Element[] getNotes();
  public boolean hasConstraints();
  public Constraint[] getConstraints();
  public boolean hasTestCases();
  public TestCase[] getTestCases();
  public boolean hasDefaultSolution();
  public String getDefaultSolution();
}

このなかで,問題の内容を表すオブジェクトを返すのがProblemCompontを返すgetProblemComponent()だと思う.
とりあえずgetterとか情報を表しているものなどを以下には列挙.精査や動作確認してないのであとでやる.
これだけあればとりあえずなんとかなるはず.

package com.topcoder.shared.problem;

import com.topcoder.shared.netCommon.CustomSerializable;

public class ProblemComponent extends BaseElement
  implements Element, Serializable, Cloneable, CustomSerializable
{
  public boolean isUnsafe()
  public boolean isValid()
  public ArrayList getMessages()
  public Element getIntro()
  public Element getSpec()
  public String getExposedClassName()
  public String getMethodName()
  public String getMethodName(int paramInt)
  public String getExposedMethodName(int paramInt)
  public DataType getReturnType()
  public DataType[] getParamTypes()
  public DataType[] getParamTypes(int paramInt)
  public DataType[] getExposedParamTypes()
  public DataType[] getExposedParamTypes(int paramInt)
  public String[] getParamNames()
  public String[] getParamNames(int paramInt)
  public String[] getExposedParamNames()
  public String[] getExposedParamNames(int paramInt)
  public Element[] getNotes()
  public Constraint[] getConstraints()
  public TestCase[] getTestCases()
  public WebService[] getWebServices()
  public int getMemLimitMB()
  public int getRoundType()
  public int getCodeLengthLimit()
  public static String handleTextElement(String paramString, Element paramElement)
  public int getComponentTypeID()
  public final int getComponentId()
  public final String getDefaultSolution()
  public int getProblemId()
  public String getReturnType(int paramInt)
  public DataType[] getAllReturnTypes()
  public String[] getAllMethodNames()
  public DataType[][] getAllParamTypes()
  public String[][] getAllParamNames()
  public DataType[] getAllExposedReturnTypes()
  public String[] getAllExposedMethodNames()
  public DataType[][] getAllExposedParamTypes()
  public String[][] getAllExposedParamNames()
  public ArrayList getCategories()

  public String toXML()
  public String toString()
}

今のところは以上.