/*
- * Dialog for WebIPC
+ * Dialog for Desktop
*
* License : The MIT License
* Copyright(c) 2009 olyutorskii
package jp.sfjp.jindolf.dxchg;
import java.awt.Container;
+import java.awt.Desktop;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.TransferHandler;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
-import jp.sfjp.jindolf.JreChecker;
import jp.sfjp.jindolf.VerInfo;
import jp.sfjp.jindolf.util.GUIUtils;
import jp.sfjp.jindolf.util.Monodizer;
* Webブラウザ起動用の専用ダイアログ。
*/
@SuppressWarnings("serial")
-public class WebIPCDialog
- extends JDialog
- implements ActionListener {
+public class WebIPCDialog extends JDialog {
- private static final String TITLE_WWW =
- VerInfo.getFrameTitle("URLへのアクセス確認");
+ private static final Logger LOGGER = Logger.getAnonymousLogger();
+ private static final String CMD_BROWSE = "browse";
+ private static final String CMD_CLIPCOPY = "clipcopy";
+ private static final String CMD_CANCEL = "cancel";
- private static final Logger LOGGER = Logger.getAnonymousLogger();
+ private static final String TITLE_WWW =
+ VerInfo.getFrameTitle("URLへのアクセス確認");
private final String warnMessage;
private final JButton cancel =
new JButton("閉じる");
- private final WebIPC ipc;
+ private final Desktop desktop;
private URI uri;
GUIUtils.modifyWindowAttributes(this, true, false, true);
- WebIPC webipc = null;
- if(WebIPC.isDesktopSupported()){
- webipc = WebIPC.getWebIPC();
- if( ! webipc.isSupported(WebIPC.Action.BROWSE) ){
+ Desktop webipc = null;
+ if(Desktop.isDesktopSupported()){
+ webipc = Desktop.getDesktop();
+ if( ! webipc.isSupported(Desktop.Action.BROWSE) ){
webipc = null;
}
}
- this.ipc = webipc;
-
- if(this.ipc == null){
- if( ! JreChecker.has16Runtime() ){
- this.warnMessage =
- "この機能を利用するには、JRE1.6以上が必要です";
- }else{
- this.warnMessage =
- "何らかの理由でこの機能は利用不可になっています";
- }
+ this.desktop = webipc;
+
+ if(this.desktop == null){
+ this.warnMessage =
+ "何らかの理由でこの機能は利用不可になっています";
}else{
this.warnMessage = "";
}
- Border inside =
- BorderFactory.createEmptyBorder(1, 4, 1, 4);
- Border outside =
- BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
- Border border =
- BorderFactory.createCompoundBorder(outside, inside);
- this.urltext.setBorder(border);
- this.urltext.setEditable(false);
- this.urltext.setLineWrap(true);
- this.urltext.setComponentPopupMenu(new TextPopup());
- Monodizer.monodize(this.urltext);
-
- this.dndLabel.setIcon(GUIUtils.getWWWIcon());
- this.dndLabel.setHorizontalTextPosition(SwingConstants.LEFT);
- this.dndLabel.setTransferHandler(new DnDHandler());
- this.dndLabel.addMouseListener(new DragIgniter());
+ buildDnDIcon();
+ buildUrlLabel();
+ buildButton();
Container container = getContentPane();
design(container);
- this.browse .addActionListener(this);
- this.clipcopy.addActionListener(this);
- this.cancel .addActionListener(this);
-
- getRootPane().setDefaultButton(this.browse);
- this.browse.requestFocusInWindow();
-
- if(this.ipc == null){
+ if(this.desktop == null){
this.browse.setToolTipText(this.warnMessage);
}
return;
}
+
/**
* Webブラウザ起動用のモーダルダイアログを表示する。
* @param owner オーナーフレーム
return true;
}
+
+ /**
+ * DragAndDropアイコンを構成する。
+ */
+ private void buildDnDIcon(){
+ this.dndLabel.setIcon(GUIUtils.getWWWIcon());
+ this.dndLabel.setHorizontalTextPosition(SwingConstants.LEFT);
+ this.dndLabel.setTransferHandler(new DnDHandler());
+ this.dndLabel.addMouseListener(new DragIgniter());
+ return;
+ }
+
+ /**
+ * URL表示部を構成する。
+ */
+ private void buildUrlLabel(){
+ Border inside =
+ BorderFactory.createEmptyBorder(1, 4, 1, 4);
+ Border outside =
+ BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
+ Border border =
+ BorderFactory.createCompoundBorder(outside, inside);
+
+ this.urltext.setBorder(border);
+
+ this.urltext.setEditable(false);
+ this.urltext.setLineWrap(true);
+ this.urltext.setComponentPopupMenu(new TextPopup());
+
+ Monodizer.monodize(this.urltext);
+
+ return;
+ }
+
+ /**
+ * ボタンを構成する。
+ */
+ private void buildButton(){
+ this.browse .setActionCommand(CMD_BROWSE);
+ this.clipcopy.setActionCommand(CMD_CLIPCOPY);
+ this.cancel .setActionCommand(CMD_CANCEL);
+
+ ActionListener btnListsner = new ButtonListener();
+ this.browse .addActionListener(btnListsner);
+ this.clipcopy.addActionListener(btnListsner);
+ this.cancel .addActionListener(btnListsner);
+
+ getRootPane().setDefaultButton(this.browse);
+ this.browse.requestFocusInWindow();
+
+ return;
+ }
+
/**
* レイアウトを行う。
* @param container レイアウトコンテナ
}
/**
- * ボタン押下リスナ。
- * @param event ボタン押下イベント
- */
- @Override
- public void actionPerformed(ActionEvent event){
- Object source = event.getSource();
- if(source == this.browse){
- actionBrowse();
- }else if(source == this.clipcopy){
- actionClipboardCopy();
- }else if(source == this.cancel){
- actionCancel();
- }
- return;
- }
-
- /**
* WebブラウザでURLを表示。
*/
private void actionBrowse(){
return;
}
- if(this.ipc == null){
- String title;
- if( ! JreChecker.has16Runtime() ){
- title = "新しいJavaを入手しましょう";
- }else{
- title = "報告";
- }
+ if(this.desktop == null){
+ String title = "報告";
JOptionPane.showMessageDialog(
this,
this.warnMessage, title,
try{
try{
- this.ipc.browse(this.uri);
+ this.desktop.browse(this.uri);
}catch(NullPointerException e){
assert false;
- }catch(UnsupportedOperationException e){
- // NOTHING
- }catch(IOException e){
- // NOTHING
- }catch(SecurityException e){
- // NOTHING
- }catch(IllegalArgumentException e){
+ }catch( UnsupportedOperationException
+ | IOException
+ | SecurityException
+ | IllegalArgumentException e
+ ){
// NOTHING
}
String logmsg = "URL "
return;
}
+
+ /**
+ * ボタンリスナ。
+ */
+ private class ButtonListener implements ActionListener{
+
+ /**
+ * ボタン押下リスナ。
+ * @param event ボタン押下イベント
+ */
+ @Override
+ public void actionPerformed(ActionEvent event){
+ String cmd = event.getActionCommand();
+ if(CMD_BROWSE.equals(cmd)){
+ actionBrowse();
+ }else if(CMD_CLIPCOPY.equals(cmd)){
+ actionClipboardCopy();
+ }else if(CMD_CANCEL.equals(cmd)){
+ actionCancel();
+ }
+ return;
+ }
+
+ }
+
+
/**
* Drag&Dropの転送処理を管理。
*/
}
+
/**
* ドラッグ開始イベント処理。
*/