« 当院のコンピュータ | トップページ | 検査データ表示 »

2008年8月28日 (木)

メモのタイトル

当院では,文書や写真は全て情報フォルダに入れて管理している。その情報フォルダ (/Volumes/documents/${id}) に文書が入っているときは「文書あり」,検査が入っているときは「検査あり」,写真があるときは「写真あり」と,メモのタイトルに表示する。さらに,そこをクリックすると,ファインダで対応するフォルダが開く。

Photo_2 Photo_2 添書や検査結果などが入っている場合,「文書あり」または「検査あり」と出る。
Photo Photo_4 写真(jpg)ファイルが入っている場合は「写真あり」とでる。
  • client/PatientInspector.java の編集
    private void layoutRow(JPanel content, String itype) {
        
    if (itype.equals("メモ")) {
    
    ////↓ もし関連文書(/Volumes/documents/${id})があれば,メモタイトルを変える
    String path = "/Volumes/documents/" + context.getKarte().getPatient().getPatientId();
    File infoFolder = new File (path); 
    // jpeg ファイルフィルタ
    FileFilter ffjpg = new FileFilter() {
        public boolean accept (File file) {
            return file.getName().toLowerCase().endsWith(".jpg");
        }
    };
    // 検査 ファイルフィルタ
    FileFilter ffexam = new FileFilter() {
        public boolean accept (File file) {
            return file.getName().toLowerCase().contains("検査");
        }
    };
    
    // 情報ファイルのフォルダがあるかどうか
    if (infoFolder.exists()) {
        int flg = 0;
        String mTitle = "メモ";
        Color mColor = Color.black;                
        
        // jpg があれば,第1ビットをたてる
        if (infoFolder.listFiles(ffjpg).length > 0) flg = flg | 1;
        // 検査ファイル があれば,第2ビットをたてる
        if (infoFolder.listFiles(ffexam).length > 0) flg = flg | 2;
    
        switch (flg) {
        case 0: // 写真,検査以外の物(添書等)
            mTitle = "メモ [文書あり]";
            mColor = Color.blue;
            break;
                
        case 1: // jpg だけ
            mTitle = "メモ [写真あり]";
            mColor = Color.red;
            break;
                
        case 2: // 検査 がある
            mTitle = "メモ [検査あり]";
            mColor = Color.red;
            break;
        
        case 3: // 写真も検査もある
            mTitle = "メモ [写真・検査あり]";
            mColor = Color.red;
            break;
        }
    
        memoInspector.getPanel().setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createEtchedBorder(),
            mTitle,
            TitledBorder.LEFT,
            TitledBorder.TOP,
            new Font ("SansSerif",Font.BOLD,12),
            mColor));
        // mouse click でフォルダを開く
        memoInspector.getPanel().addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                (new KickAppleScript()).openPatientFolder(path);
            }
        });
    } else {
        // フォルダ自体がない
        memoInspector.getPanel().setBorder(BorderFactory.createTitledBorder("メモ"));
    }
    ////↑ここまで
    
    content.add(memoInspector.getPanel());
    bMemo = true;
    
  • ついでにサイズ微調整
    private void initComponents() {
     ・
     ・
    ////↓   サイズ微調整
      docHistory.getPanel().setPreferredSize(new Dimension(prefW, 350));
      patientVisitInspector.getPanel().setPreferredSize(new Dimension(prefW, 190));
      patientVisitInspector.getPanel().setMinimumSize(new Dimension(prefW, 190));
      patientVisitInspector.getPanel().setMaximumSize(new Dimension(prefW, 190));
      memoInspector.getPanel().setPreferredSize(new Dimension(prefW, 70));
      memoInspector.getPanel().setPreferredSize(new Dimension(prefW, 70));
    ////↑
    
  • client/KickAppleScript.java の作成
    package open.dolphin.client;
    
    import java.io.IOException;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    
    /**
     *
     */
    public class KickAppleScript {
        
        private String aScriptPath = "/Applications/AppleScript/scripts/";
            
        public KickAppleScript() {
        }
    
        public void openPatientFolder(String path) {
            StringBuffer cmd = new StringBuffer();
            cmd.append("/usr/bin/osascript ");
            cmd.append(aScriptPath);
            cmd.append("dolphin.scpt ");
            cmd.append(path);
            try {
                Runtime.getRuntime().exec(cmd.toString());
            } catch (IOException ex) {
                Logger.getLogger(KickAppleScript.class.getName()).log(Level.SEVERE, null, ex);
            }
    
        }
    }
    
  • /Applications/AppleScript/scripts/dolphin.scpt の作成
    on run argv
    	set POSIXPath to item 1 of argv
    	set targetFolder to (POSIX file POSIXPath)
    	
    	if (count of argv) is equal to 0 then return
    	tell application "Finder"
                    select folder targetFolder
    		open selection
    		set win to Finder window 1
    		set toolbar visible of win to false
    		set current view of win to flow view
    		set bounds of win to {900, 60, 1600, 800} --x1, y1, x2, y2
    	end tell
    end run
    

« 当院のコンピュータ | トップページ | 検査データ表示 »

OpenDolphin」カテゴリの記事