diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyCellEditor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyCellEditor.java index e8b5e13..ce530a7 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyCellEditor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyCellEditor.java @@ -7,6 +7,7 @@ import javax.swing.*; import java.awt.*; +import java.awt.event.MouseEvent; import java.util.EventObject; public class DependencyCellEditor extends FlowCellEditor { @@ -17,9 +18,47 @@ @Override public void startEditing(Object cellObj, EventObject eventObj) { + // セルがnull、または頂点以外なら編集しない + if (cellObj == null || !(cellObj instanceof mxCell)) { + return; + } + mxCell cell = (mxCell) cellObj; + + // エッジの場合もスキップ + if (cell.isEdge()) { + return; + } + + // ダブルクリック以外では編集しない + if (eventObj instanceof MouseEvent) { + MouseEvent e = (MouseEvent) eventObj; + if (e.getClickCount() < 2) { + return; + } + } + + // 現在のラベルを取得 + String currentName = (cell.getValue() != null) ? cell.getValue().toString() : ""; + + // 入力ダイアログを表示 + String newName = JOptionPane.showInputDialog( + null, + "Edit Interface Name:", + currentName + ); + + // OKが押されて、入力が空でなければラベルを更新 + if (newName != null && !newName.trim().isEmpty()) { + graphComponent.getGraph().getModel().beginUpdate(); + try { + cell.setValue(newName); + } finally { + graphComponent.getGraph().getModel().endUpdate(); + } + graphComponent.refresh(); + } } - @Override public void stopEditing(boolean cancel) {