« lucid orca 4.7 にアップグレード | トップページ | orca version 4.7 api (xml2) 対応 »

2013年3月 7日 (木)

monsiaj-20130115 の改造

orca 4.7 移行にあたって,今まで使っていた monsiaj-20120806 が使えなくなってしまった。最新版の monsiaj-20130115 を使うことにしたが,例によってソースをダウンロードして改造して使用している。ソースは bitbucket さんにアップした。主な変更点は以下の通り。

 

build.xml

build.xml の javac のプロパティーに encoding="utf-8" を入れないとビルドできなかった。

<javac srcdir="${src.dir}" destdir="${build.dir}" source="1.6"
  target="1.6" encoding="utf-8"
  debug="${javac.debug}" debuglevel="${javac.debuglevel}">

JavaApplicationStub

最初の起動時,/System/Library/Frameworks/JavaVM.framework/Resources/MacOS/
JavaApplicationStub
を複製して,名前を JMAReceipt に変更して,オリジナルの resources/JMAReceipt と入れ替えないと動かなかったが,1回動いてしまうと,オリジナルの JMAReceipt に戻しても動くようになった。謎である。

 

CListMarshaller.java

罫線が出るように改造

 

PandaTable.java

診療行為画面に PandaTable が導入されたのに伴って,編集時の操作感覚が変わってしまっていた。4.6 に近い感覚になるように変更した。

  1. シングルクリックでセルを選択,選択されたセルは自動的に編集モードになる。
    addFocusListener(new FocusListener() {
    
      public void focusGained(FocusEvent e) {
        // do nothing
        //pns フォーカスを取ったら必ず編集する
        editCell();
      }
     :
     :
    //pns 選択が起きたら必ず編集する
    @Override
    public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
      super.changeSelection(rowIndex, columnIndex, toggle, extend);
      if (isEditing()) {
        // selection が変わったので前の editor は消す
        getCellEditor().cancelCellEditing();
      } else {
        // 非編集状態なら editor を立ち上げる
        editCell();
      }
    }
        
    //pns セル編集時に CellEditor にフォーカスさせる editCell
    private void editCell() {
      editCellAt(getSelectedRow(), getSelectedColumn());
            
      final DefaultCellEditor ce = (DefaultCellEditor)getDefaultEditor(Object.class);        
      SwingUtilities.invokeLater(new Runnable(){
        @Override
        public void run() {
          ce.getComponent().requestFocusInWindow();
        }
      });
    }
    
    
  2. 親の PandaTable にキーイベントをそのまま送ると,上下の矢印キーで上下のセル移動,タブまたはシフト+タブで左右のセル移動となる。
    ce.getComponent().addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent e) {
        if (e.getKeyCode() == KeyEvent.VK_ENTER) {
          PandaTable.this.setEnterPressed(true);
    
        //pns 上下キーとタブの KeyEvent は,親の Table に伝える
        } else if (e.getKeyCode() == KeyEvent.VK_DOWN
            || e.getKeyCode() == KeyEvent.VK_UP
            || e.getKeyCode() == KeyEvent.VK_TAB) {
          Component parent = ((Component) e.getSource()).getParent();
          KeyEvent pass = new KeyEvent(parent, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar());
          parent.dispatchEvent(pass);
          e.consume();
        }
      }
    
  3. セルの高さ調整。これは monsia.pandatable.rowheight でセットすることもできる。
    int rowheight = 20; //pns テーブルの高さをコンパクトに
    if (System.getProperty("monsia.pandatable.rowheight") != null) {
      rowheight = Integer.parseInt(System.getProperty("monsia.pandatable.rowheight"));
    }
    
  4. mac では isCompositionEnabled() はサポートされておらず,Exception を出してしまうので,mac の場合は途中で帰る。
    protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
      boolean retValue = super.processKeyBinding(ks, e, condition, pressed);
            
      //pns "isCompositionEnabled()" で mac は止まる
      if (SystemEnvironment.isMacOSX()) { return retValue; } 
    

ダウンロード

« lucid orca 4.7 にアップグレード | トップページ | orca version 4.7 api (xml2) 対応 »

ORCA」カテゴリの記事