<?xml version="1.0" encoding="UTF-8" ?><rdf:RDF 
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xml:lang="ja">
  <channel rdf:about="http://w.atwiki.jp/eclipsepluginstudy/">
    <title>eclipseプラグインおべんきょう</title>
    <link>http://w.atwiki.jp/eclipsepluginstudy/</link>
    <atom:link href="https://w.atwiki.jp/eclipsepluginstudy/rss10.xml" rel="self" type="application/rss+xml" />
    <atom:link rel="hub" href="https://pubsubhubbub.appspot.com" />
    <description>eclipseプラグインおべんきょう</description>

    <dc:language>ja</dc:language>
    <dc:date>2012-03-12T13:11:01+09:00</dc:date>
    <utime>1331525461</utime>

    <items>
      <rdf:Seq>
                <rdf:li rdf:resource="https://w.atwiki.jp/eclipsepluginstudy/pages/23.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/eclipsepluginstudy/pages/22.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/eclipsepluginstudy/pages/21.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/eclipsepluginstudy/pages/20.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/eclipsepluginstudy/pages/19.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/eclipsepluginstudy/pages/18.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/eclipsepluginstudy/pages/17.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/eclipsepluginstudy/pages/16.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/eclipsepluginstudy/pages/15.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/eclipsepluginstudy/pages/14.html" />
              </rdf:Seq>
    </items>
	
		
    
  </channel>
    <item rdf:about="https://w.atwiki.jp/eclipsepluginstudy/pages/23.html">
    <title>Eclipseプラグイン/Tips</title>
    <link>https://w.atwiki.jp/eclipsepluginstudy/pages/23.html</link>
    <description>
      -&amp;link_aname(openInternalBrowser){Eclipse内部Webブラウザを起動する}

&amp;aname(openInternalBrowser){}
----
**Eclipse内部Webブラウザを起動する

Eclipse内のビューとしてInternal Web Browserを起動する方法。
#highlight(java){{
String url = &quot;http://www.google.co.jp/&quot;
IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
if (browserSupport.isInternalWebBrowserAvailable()) {
	IWebBrowser browser;
	try {
		browser = browserSupport.createBrowser(
			IWorkbenchBrowserSupport.LOCATION_BAR
			| IWorkbenchBrowserSupport.NAVIGATION_BAR
			| IWorkbenchBrowserSupport.AS_VIEW,
			&quot;id&quot;,&quot;title&quot;,&quot;toolTipName&quot;);
				browser.openURL(new URL(url));

		} catch (PartInitException e) {
			// エラー処理
		} catch (MalformedURLException e) {
			// エラー処理
		}
}
}}

エディタとして開きたい時は以下のようにする。
#highlight(java){

// ↑より抜粋
browser = browserSupport.createBrowser(
	IWorkbenchBrowserSupport.LOCATION_BAR
	| IWorkbenchBrowserSupport.NAVIGATION_BAR
	| IWorkbenchBrowserSupport.AS_EDITOR,
	&quot;id&quot;,&quot;title&quot;,&quot;too    </description>
    <dc:date>2012-03-12T13:11:01+09:00</dc:date>
    <utime>1331525461</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/eclipsepluginstudy/pages/22.html">
    <title>Eclipseプラグイン/エラー解決</title>
    <link>https://w.atwiki.jp/eclipsepluginstudy/pages/22.html</link>
    <description>
      -&amp;link_aname(ClassNotFoundException){ランタイムで動かした時、ClassNotFoundExceptionが発生}

&amp;aname(refreshWorkspace){}
----
**ランタイムで動かした時、ClassNotFoundExceptionが発生してビューやエディタが生成できない
-&amp;bold(){エラー}
&gt;java.lang.ClassNotFoundException

-&amp;bold(){原因}
ランタイムにjarのパスが通っていない。

-&amp;bold(){解決策}
新しくクラスパスを通したら、ランタイムにも同じようにjarのパスを通す。
plugin.xmlの「ランタイム」タブの「クラスパス」から通せます。


----








.    </description>
    <dc:date>2012-03-09T10:30:59+09:00</dc:date>
    <utime>1331256659</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/eclipsepluginstudy/pages/21.html">
    <title>Eclipseプラグイン/TreeViewer</title>
    <link>https://w.atwiki.jp/eclipsepluginstudy/pages/21.html</link>
    <description>
      -&amp;link_aname(findItem){ツリーから特定のアイテムを取得する}
-&amp;link_aname(expandItem){ツリーを展開する}
-&amp;link_aname(setSelectionItem){ツリーの特定アイテムを選択状態にする}

&amp;aname(findItem){}
----
**ツリーから特定のアイテムを取得する

特定のアイテムに対して操作したい、ということは多々あります。
そういうときには、getInput()で今表示しているリストを取得し、その中から探します。
※getInput()の戻りは、setInputした時の型でキャストできます。
#highlight(java){
// setInputした時
List&lt;TreeViewerModel&gt; modelList = new ArrayList&lt;TreeViewerModel&gt;();
・・・(modelListにアイテムをセット)
treeViewer.setInput(modelList);

// ↑のツリービューアからname属性と指定値nameが一致するアイテムを探す例
List&lt;TreeViewerModel&gt; modelList = (List&lt;TreeViewerModel&gt;) treeViewer.getInput();
	for(TreeViewerModel model : modelList){
			if(model.getName.equals(name)){
				return model;
			}
	}
}

&amp;aname(expandItem){}
----
**ツリーを展開する

expandメソッドを使用する。
・全展開する場合
#highlight(java){
treeViewer.expandAll();
}
・特定の階層だけ展開する場合
#highlight(java){
treeViewer.expandToLevel(int level)
}
・特定のアイテム以下だけ展開する場合
#highlight(java){
treeViewer.expandToLevel(Object elementOrTreePath, int level)
}
    </description>
    <dc:date>2012-03-05T16:43:43+09:00</dc:date>
    <utime>1330933423</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/eclipsepluginstudy/pages/20.html">
    <title>Eclipseプラグイン/SWT</title>
    <link>https://w.atwiki.jp/eclipsepluginstudy/pages/20.html</link>
    <description>
      -&amp;link_aname(createButton){ボタン、チェックボックス、ラジオボタンを作る}
-&amp;link_aname(setVisible){部品を不可視にする}
-&amp;link_aname(setEnable){部品を非活性にする}

&amp;aname(createButton){}
----
**ボタン、チェックボックス、ラジオボタンを作る
押しボタンとチェックボックスとラジオボタンは全てButtonウィジェットです。
Button生成時に、第二引数でボタンのスタイルを指定します。PUSHが押しボタン、CHECKがチェックボタン、RADIOがラジオボタン。
※parentは親Composite
#highlight(){
Button button = new Button(parent, SWT.PUSH);
button.setText(&quot;ボタン名&quot;);

Button checkButton = new Button(parent, SWT.CHECK);
checkButton.setText(&quot;チェックボタン名&quot;);

Button radioButton = new Button(parent, SWT.RADIO);
radioButton.setText(&quot;ラジオボタン名&quot;);
}
#image(2_ボタン作成.png)

&amp;aname(setVisible){}
----
**部品を不可視にする
ボタンやテキストなどのSWTコントロールは可視⇔不可視を切り替えられます。falseで不可視、trueで可視。
#highlight(){
button.setVisible(false);
}

false
#image(1_ボタンvisiblefalse.png)
true
#image(1_ボタンvisibletrue.png)

&amp;aname(setEnable){}
----
**部品を非活性にする
ボタンやテキストなどのSWTコントロールは活性⇔非活性を切り替えられます。falseで非活性、trueで活性。
#highlight(){
button.setEnabled(false);
}

false
#image(1_ボタンenabledfals    </description>
    <dc:date>2012-03-02T15:06:11+09:00</dc:date>
    <utime>1330668371</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/eclipsepluginstudy/pages/19.html">
    <title>Eclipseプラグイン/エディタ</title>
    <link>https://w.atwiki.jp/eclipsepluginstudy/pages/19.html</link>
    <description>
      -&amp;link_aname(getEditorDoc){エディタ内に現在入力されているテキストを取得する}
-&amp;link_aname(openEditorFileOutsideWorkspace){【未解決】ワークスペース外のファイルをエディタで開く}

&amp;aname(getEditorDoc){}
----
**エディタ内に現在入力されているテキストを取得する

#highlight(){
IDocument doc =this.getDocumentProvider().getDocument(this.getEditorInput());
}

&amp;aname(openEditorFileOutsideWorkspace){}
----
**【未解決】ワークスペース外のファイルをエディタで開く
-&amp;bold(){概要}
エディタを開くIDE.openEditorには複数のオーバーロードメソッドがありますが、ほとんどがparamにIFileを必要とします。
IFileとはFile実体ではなく、Eclipseの世界の中で扱うリソースのため、&amp;bold(){ワークスペース外のファイルをIFile化できない}。
これが解決しない以上、ワークスペース外のファイルをエディタで開くには、paramにIFileを必要としないメソッドを使うしかない。
例えば、IDE.openEditor((IWorkbenchPage, IEditorInput, String)。(最後のStringはエディタID)
しかし今度はIEditorInputの取得方法がわからず……。
既に開いているファイルなら、IEditorPart.getEditorInputで取れるのですが。
なので、ここまでで断念。

-&amp;bold(){参考}
[[Javaの道掲示板（IFileの使い方）&gt;http://www.javaroad.jp/bbs/answer.jsp?q_id=20060306215443154]]
この通りにやってみましたが、ExternalFileEditorInputの実装をどうしたら良いかわからず断念。

----








.    </description>
    <dc:date>2012-03-02T12:01:06+09:00</dc:date>
    <utime>1330657266</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/eclipsepluginstudy/pages/18.html">
    <title>Eclipseプラグイン/リソース取得</title>
    <link>https://w.atwiki.jp/eclipsepluginstudy/pages/18.html</link>
    <description>
      -&amp;link_aname(refreshWorkspace){ワークスペースをリフレッシュする}
-&amp;link_aname(getPluginDir){自プラグインのディレクトリを取得する}

&amp;aname(refreshWorkspace){}
----
**ワークスペースをリフレッシュする

以下で出来ます。
#highlight(java){
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, IProgressMonitor);
}

↓のようなメソッドをUtil化するとべんりです。
#highlight(java){{
public static void refreshWorkSpace(IProgressMonitor monitor) {
	try {
		ResourcesPlugin.getWorkspace().getRoot().refreshLocal(
		IResource.DEPTH_INFINITE, monitor);
	} catch (CoreException e) {
		e.printStackTrace();
	}
}
}}

refreshLocalメソッドの引数：IProgressMonitorをnullにすると、進行状況のプログレスバーが表示されないようです。
#highlight(java){
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE,null);
}

リフレッシュ動作は正常に行われている様子。
プログレスバーを出すとそれなりに処理が遅くなる気がします。。。

&amp;aname(getPluginDir){}
----
**自プラグインのディレクトリを取得する

以下で出来ます。
#highlight(java){
URL entry = Activator.getDefault().getBundle().getEntry(&quot;/&quot;);
pluginDirectory = FileLocator.resolve(en    </description>
    <dc:date>2012-03-02T11:57:45+09:00</dc:date>
    <utime>1330657065</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/eclipsepluginstudy/pages/17.html">
    <title>Eclipseプラグイン</title>
    <link>https://w.atwiki.jp/eclipsepluginstudy/pages/17.html</link>
    <description>
      -[[Eclipseプラグイン/SWT]]
-[[Eclipseプラグイン/エディタ]]
-[[Eclipseプラグイン/TreeViewer]]
-[[Eclipseプラグイン/リソース取得]]
-[[Eclipseプラグイン/エラー解決]]    </description>
    <dc:date>2012-03-12T11:35:07+09:00</dc:date>
    <utime>1331519707</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/eclipsepluginstudy/pages/16.html">
    <title>Eclipseプラグインエラー解決</title>
    <link>https://w.atwiki.jp/eclipsepluginstudy/pages/16.html</link>
    <description>
      -&amp;link_aname(increasePerspective){ツールで作ったパースペクティブが増殖していく}
-&amp;link_aname(canNotReadFile){ランタイムでは参照できていたファイルが、プラグイン化したら参照できなくなった}

&amp;aname(increasePerspective){}
----
**ツールで作ったパースペクティブが増殖していく
-&amp;bold(){現象}
　ツールを消したり入れ直したりした時、
　次にEclipseを起動すると、&lt;hogeパースペクティブ&gt;　のようにカッコが付いて表示されることがある。
-&amp;bold(){原因}
　前回Eclipseを終了する際のパースペクティブが、消したツールのパースペクティブだった場合に発生する。
　ワークスペースが前回のパースペクティブを覚えており、参照しようとするため。
　参照出来ないと、復元できる範囲でマネしたパースペクティブを作るようです。
　(例えば、ツール独自のビューやエディタは復元できないが、エクスプローラビューや問題ビューなどは復元する)
　&lt;&lt;hoge&gt;&gt;⇒&lt;&lt;&lt;hoge&gt;&gt;&gt;･･･と、ツールを消す度にどんどんカッコ付きパースペクティブが増えていきます。
-&amp;bold(){予防}
　ツールを消すときは、消すツール以外のパースペクティブにした状態でEclipseを閉じてから消す
-&amp;bold(){対策}
　増えてしまった場合は、ウィンドウ＞設定＞パースペクティブで文字列検索　から、不要パースペクティブを削除する
-&amp;bold(){備考}
　ツール側で、毎回終了時にパースペクティブ情報を消すべきか？などいろいろ模索しましたが、わからず＆できず。
　findbugsのようなプラグインでも同様の現象が起きたため、プラグインとはこういうものなのかもしれません。

&amp;aname(canNotReadFile){}
----
**ランタイムでは参照できていたファイルが、プラグイン化したら参照できなくなった
-&amp;bold(){現象}
　resourceファイルなど、プラグイン下のファイルが参照できずエラーが発生する。
-&amp;bold(){原因}
　プラグインがjar化されていると、中のファイルを参照できない。
-&amp;bold(){    </description>
    <dc:date>2012-03-02T11:19:21+09:00</dc:date>
    <utime>1330654761</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/eclipsepluginstudy/pages/15.html">
    <title>EclipseRCPTips</title>
    <link>https://w.atwiki.jp/eclipsepluginstudy/pages/15.html</link>
    <description>
      -&amp;link_aname(rcpTranslation){RCPアプリをexe化した時もプレアデスの日本語翻訳をさせたい}

&amp;aname(rcpTranslation){}
----
**RCPアプリをexe化した時もプレアデスの日本語翻訳をさせたい
-&amp;bold(){解決策}
エクスポート時にプレアデスのjarも含むようにして、起動時の引数に指定する。

-&amp;bold(){手順}
1.productファイルの「依存関係」タブで「追加」を押し、プレアデスを選択。
　(jp.sourceforge.mergedoc.pleiades)
2.productファイルの「起動」タブで「VM引数」にプレアデスのjarを選択。
　(私の環境は-javaagent:plugins/jp.sourceforge.mergedoc.pleiades_1.3.3/pleiades.jar)

----











.    </description>
    <dc:date>2012-03-02T11:15:59+09:00</dc:date>
    <utime>1330654559</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/eclipsepluginstudy/pages/14.html">
    <title>EclipseRCP/エラー解決</title>
    <link>https://w.atwiki.jp/eclipsepluginstudy/pages/14.html</link>
    <description>
      -&amp;link_aname(couldNotCreateView){exe化したツール内でビューが作成されず、「Could not create the view: Argument cannot be null」エラー発生}

&amp;aname(couldNotCreateView){}
----
**exe化したツール内でビューが作成されず、「Could not create the view: Argument cannot be null」エラー発生
-&amp;bold(){エラー}
&gt;java.lang.IllegalArgumentException: Argument cannot be null

-&amp;bold(){原因}
1.SWTのコントロールにsetTextでnullを渡すと落ちる。
2.ツールエクスポート(exe化)時のエンコーディング設定が不正で文字列が取得出来ていない。

-&amp;bold(){解決策}
1.nullを渡さない。
2.nullではなく文字列を渡すようにコーディングしていても上記エラーが発生する場合、exe化する前にも同様に落ちるかどうか調査。
　exe化した後のみ落ちてしまう場合は、build.propertiesに以下の記述を加える。
&gt;javacDefaultEncoding.. = UTF-8

-&amp;bold(){備考}
ウィジェットにnullがうっかりsetされないように手段を講じるべきです。
TextやLabelを継承した自作クラスでsetTextをラップし、検査してからsetするとか。
setTextの引数に渡す時には、必ずString加工メソッドを通すようにするとか。
絶対にnullを入れないためにはその方が堅牢で良いかと。

----











.    </description>
    <dc:date>2012-03-09T10:28:12+09:00</dc:date>
    <utime>1331256492</utime>
  </item>
  </rdf:RDF>
