<?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/2.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/eclipsepluginstudy/pages/17.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/eclipsepluginstudy/pages/22.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/eclipsepluginstudy/pages/14.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/eclipsepluginstudy/pages/21.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/eclipsepluginstudy/pages/3.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: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;toolTipName&quot;);
	browser.openURL(new URL(url));
}

----







.    </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/2.html">
    <title>メニュー</title>
    <link>https://w.atwiki.jp/eclipsepluginstudy/pages/2.html</link>
    <description>
      **メニュー
-[[トップページ]]
----

[[Eclipseプラグイン]]
-[[Eclipseプラグイン/SWT]]
-[[Eclipseプラグイン/エディタ]]
-[[Eclipseプラグイン/TreeViewer]]
-[[Eclipseプラグイン/リソース取得]]
-[[Eclipseプラグイン/エラー解決]]
-[[Eclipseプラグイン/Tips]]

[[EclipseRCP]]
-[[EclipseRCP/エラー解決]]
-[[EclipseRCP/Tips]]
-[[メモ]]


----

**リンク
-[[きのさいと&gt;&gt;http://www.masatom.in/pukiwiki/index.php?FrontPage]]
-[[Eclipseプラグイン開発&gt;&gt;http://yoichiro.cocolog-nifty.com/eclipse/]]

// リンク方法：[[ページ名&gt;&gt;ページURL]]


//**更新履歴
//#recent(20)

&amp;link_editmenu(text=メニューを編集)    </description>
    <dc:date>2012-03-12T11:35:55+09:00</dc:date>
    <utime>1331519755</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/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/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>
    <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)
}
※↑のelementOrTreePathは、TreeViewerにセットしたモデル型でOK。
現在表示している一覧を取得→目的のアイテムを探す→探したアイテムをexpand　の流れ。
目的のアイテムの探し方は→&amp;link_aname(findItem){ツリーから特定のアイテムを取得する}


&amp;aname(setSelectionItem){}
----
**ツリーの特定アイテムを選択状態にする

特定アイテムを選択状態(背景ハイライト)にしたいときはsetSelection(ISelection selection)を使います。
#highlight(java){
IStructuredSelection selection =  new StructuredSelection(model);
treeViewer.setSelection(selection);
}
特定アイテム(この場合のmodel)の取得方法は→&amp;link_aname(findItem){ツリーから特定のアイテムを取得する}
----







.    </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/3.html">
    <title>右メニュー</title>
    <link>https://w.atwiki.jp/eclipsepluginstudy/pages/3.html</link>
    <description>
      // **更新履歴
// #recent(20)


// &amp;link_editmenu2(text=ここを編集)    </description>
    <dc:date>2012-03-02T15:09:06+09:00</dc:date>
    <utime>1330668546</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_ボタンenabledfalse.png)
true
#image(1_ボタンvisibletrue.png)

----








.    </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(entry).getPath();
}

以下のようなutilメソッドを作成しておくと便利。
#highlight(java){{
public static String getPluginDir() {
	String pluginDirectory = &quot;&quot;;
	try {
		URL entry = Activator.getDefault().getBundle().getEntry(StringUtil.SLASH);
		pluginDirectory = FileLocator.resolve(entry).getPath();
	} catch (IOException e) {
		// Exception処理
	}
	return pluginDirectory;
}
}}

----








.    </description>
    <dc:date>2012-03-02T11:57:45+09:00</dc:date>
    <utime>1330657065</utime>
  </item>
  </rdf:RDF>
