내 응용 프로그램에서 한 달 동안 작업 한 후, 나는 특이한 것을 발견했습니다. 모든 TopComponents가있는 Viewer 모듈과 모든 툴바 작업을 유지하는 MenuToolbar 모듈이 있습니다. 여기에 내 추가 내용이 있습니다 :NetBeans 플랫폼 : 작업이 비활성화되었지만 바로 가기가 활성화되었습니다.
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를 눌러 삭제할 수 있습니다. 큰 노 - 노입니다 ...
어떻게이 문제를 해결할 수 있습니까?
약 일주일 후에 시도해 보았지만 여전히 원격으로 작동하는 프로토 타입조차도 만들 수 없었습니다. 내 목표는 Action1, Action2 및 Action3 (NB Wizard로 생성 된 모든 사용자 정의 액션)을 갖는 것입니다. Action1을 클릭하면 action1 및 action2가 비활성화되고 Action3을 클릭하면 1 및 2가 활성화되지만 3은 비활성화됩니다. 정렬에 대한 링크가있는 경우 API보다 더 철저한 방법으로 CookieAction 구현을 보여주는 튜토리얼은 매우 감사하겠습니다. 나는 일종의 globalcontext를 사용하는 것이 행동을 직접 제어하는 것보다 낫다는 것에 동의한다. –