ユーザーコントロールを作成して、パレットカテゴリを登録する

  テスト用のプロジェクトを作成( PaletteCategory )



新しい Java プロジェクトを作成して、ビジュアル・クラスを JFrame で作成します



JFrame 内の JPanel のレイアウト設定を null ( 位置指定 ) に変更します





  ユーザコントロール用パッケージを作成( myswing )



サンプルとして、JButton、JCheckBox、JRadioButton を継承したユーザーコントロールを作成し、
Bean の選択 で、Visual Editor 上で使用できる事を確かめます



  
package myswing;

import javax.swing.*;

@SuppressWarnings("serial")
public class LboxButton extends JButton {

	private int group;

	public int getLboxGroup() {

		return this.group;

	}

	public void setLboxGroup(int arg) {

		this.group = arg;

	}

	public void setLboxWidth(int width) {

		int height;

		height = this.getHeight();
		this.setSize(width,height);

	}
}
  

  
package myswing;

import javax.swing.*;

@SuppressWarnings("serial")
public class LboxCheck extends JCheckBox {

	private int group;

	public int getLboxGroup() {

		return this.group;

	}

	public void setLboxGroup(int arg) {

		this.group = arg;

	}

	public void setLboxCheck(boolean arg) {

		this.setSelected(arg);

	}

	public boolean getLboxCheck() {

		Object[] value;
		value = this.getSelectedObjects();

		if ( value == null ) {
			return false;
		}
		else {
			return true;
		}

	}

}
  

  
package myswing;

import javax.swing.*;

@SuppressWarnings("serial")
public class LboxRadio extends JRadioButton {

	private int group;

	public int getLboxGroup() {

		return this.group;

	}

	public void setLboxGroup(int arg) {

		this.group = arg;

	}

	public void setLboxCheck(boolean arg) {

		this.setSelected(arg);

	}

	public boolean getLboxCheck() {

		Object[] value;
		value = this.getSelectedObjects();

		if ( value == null ) {
			return false;
		}
		else {
			return true;
		}

	}

}
  



  myswing を jar ファイルとして エクスポート





この後、2回ダイアログが表示されますが、今回は何も設定する必要はありません。



  新しいプロジェクト( PaletteCategoryTest )を作成して、Bean として選択できる事を確認

今作成した myswing.jar を、Java プロジェクトを作成時に、「外部 JAR の追加」 で参照します




  パレットカテゴリが定義されている jar を解凍して、定義を記述

7zip で解凍しています

dropins\VisualEditor\eclipse\plugins\org.eclipse.ve.jfc_1.4.0.200807092330.jar

org.eclipse.ve.jfc_1.4.0.200807092330\palette\palette.properties
  
###############################################################################
# Copyright (c) 2003, 2005 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
# 
# Contributors:
#     IBM Corporation - initial API and implementation
###############################################################################
#
# $Source: /cvsroot/tools/org.eclipse.ve.jfc/palette/palette.properties,v $
# $Revision: 1.3 $  $Date: 2005/08/24 23:38:13 $
#


Palette.Category.AWTControls      = AWT Controls
Palette.Category.AWTMenus         = AWT Menus
Palette.Category.SwingContainers  = Swing Containers
Palette.Category.SwingComponents  = Swing Components
Palette.Category.SwingMenus       = Swing Menus
## ENTRY ##
Palette.Entry.JTableOnJScrollPane = JTable on JScrollPane
Palette.Category.LightboxComponents = lightbox
  

127行の次に以下を挿入
org.eclipse.ve.jfc_1.4.0.200807092330\palette\javavisualbeanscats.xmi
  
  <org.eclipse.ve.internal.cde.palette:Drawer icon16Name="platform:/plugin/org.eclipse.ve.jfc/icons/full/pal/swing_components.gif">
    <entryLabel xsi:type="org.eclipse.ve.internal.cde.utility:TranslatableString" key="Palette.Category.LightboxComponents"
        bundle="#bundle"/>
    <children xsi:type="org.eclipse.ve.internal.cde.palette:EMFCreationToolEntry" icon16Name="platform:/plugin/org.eclipse.ve.jfc/icons/full/clcl16/button_obj.gif"
        creationClassURI="java:/myswing#LboxButton">
      <entryLabel xsi:type="org.eclipse.ve.internal.cde.utility:ConstantString" string="LboxButton"/>
      <keyedValues xsi:type="ecore:EStringToStringMapEntry" key="org.eclipse.ve.internal.cde.core.nameincomposition"
          value="lboxButton"/>
    </children>
    <children xsi:type="org.eclipse.ve.internal.cde.palette:EMFCreationToolEntry" icon16Name="platform:/plugin/org.eclipse.ve.jfc/icons/full/clcl16/button_obj.gif"
        creationClassURI="java:/myswing#LboxCheck">
      <entryLabel xsi:type="org.eclipse.ve.internal.cde.utility:ConstantString" string="LboxCheck"/>
      <keyedValues xsi:type="ecore:EStringToStringMapEntry" key="org.eclipse.ve.internal.cde.core.nameincomposition"
          value="lboxCheck"/>
    </children>
    <children xsi:type="org.eclipse.ve.internal.cde.palette:EMFCreationToolEntry" icon16Name="platform:/plugin/org.eclipse.ve.jfc/icons/full/clcl16/button_obj.gif"
        creationClassURI="java:/myswing#LboxRadio">
      <entryLabel xsi:type="org.eclipse.ve.internal.cde.utility:ConstantString" string="LboxRadio"/>
      <keyedValues xsi:type="ecore:EStringToStringMapEntry" key="org.eclipse.ve.internal.cde.core.nameincomposition"
          value="lboxRadio"/>
    </children>
  </org.eclipse.ve.internal.cde.palette:Drawer>
  



  jar に変更部分を追加

Eclipse を終了して、dropins\VisualEditor\eclipse\plugins ディレクトリでコマンドプロンプトを開けて、以下を実行

  
"C:\Program Files\Java\jdk1.6.0_06\bin\jar" -uvf org.eclipse.ve.jfc_1.4.0.200807092330.jar -C org.eclipse.ve.jfc_1.4.0.200807092330 palette\javavisualbeanscats.xmi -C org.eclipse.ve.jfc_1.4.0.200807092330 palette\palette.properties
  




  Eclipse を clean 実行

eclipse.exe -clean.cmd を実行して下さい。




※ コントロール画像変えるのを忘れました・・・










  infoboard   管理者用   
このエントリーをはてなブックマークに追加





フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ