申請書の作成に 1 か月を費やした後、私は奇妙なことを発見しました。すべての TopComponents がある Viewer モジュールと、すべてのツールバー アクションを保持する MenuToolbar モジュールがあります。これが私の追加です:
package com.demo.toolbar;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.openide.awt.ActionRegistration;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionID;
import org.openide.util.NbBundle.Messages;
@ActionID(category = "Edit",
id = "com.demo.toolbar.AddAction")
@ActionRegistration(iconBase = "com/demo/toolbar/icons/add.png",
displayName = "#CTL_AddAction")
@ActionReferences({
@ActionReference(path = "Toolbars/AddEditDelete", position = 1),
@ActionReference(path = "Shortcuts", name = "D-A")
})
@Messages("CTL_AddAction=Add")
public final class AddAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
//code here
}
}
このショートカットは CTRL+A でアクティブになり、TopComponent を追加モードにします。CTRL+D コマンドでアクティブ化される DeleteAction もあります。人が CTRL + A を押すと、次のことが起こります。
List<Component> c = new ArrayList<Component>();
c.addAll(Arrays.asList(ToolbarPool.getDefault().findToolbar("AddEditDelete").getComponents()));
if (mode.equals("add")) {
for (Component component : c) {
component.setEnabled(false);
}
c.get(13).setEnabled(true);
c.get(14).setEnabled(true);
}
基本的に、ユーザーがツールバーの [追加] ボタンをクリックすると、他のすべてのボタン (削除を含む) が無効になるため、ユーザーは追加モードでこれらのアクションを実行できません。
ただし、CTRL+D を押して削除することはできます。これは大きなノーノーです...
この動作を修正するにはどうすればよいですか?