项目:Decoder-Improved
文件:EncodingSelectionDialog.java
private void init() {
// Close the dialog when Esc is pressed
String cancelName = "cancel";
InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(Keystroke.getKeystroke(KeyEvent.VK_ESCAPE,0),cancelName);
ActionMap actionMap = getRootPane().getActionMap();
actionMap.put(cancelName,new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
doClose(RET_CANCEL);
}
});
DefaultComboBoxModel<String> comboBoxModel = (DefaultComboBoxModel<String>) encodingComboBox.getModel();
for (Map.Entry<String,Charset> entry : Charset.availableCharsets().entrySet()) {
if (!"UTF-8".equals(entry.getKey())) {
comboBoxModel.addElement(entry.getValue().name());
}
}
}
项目:JavaGraph
文件:Groove.java
/** Converts an action map to a string representation. */
static public String toString(ActionMap am) {
StringBuilder result = new StringBuilder();
LinkedHashMap<Object,Object> map = new LinkedHashMap<>();
for (Object key : am.allKeys()) {
map.put(key,am.get(key));
}
result.append(map);
result.append('\n');
ActionMap parent = am.getParent();
if (parent != null) {
result.append("Parent: ");
result.append(toString(parent));
}
return result.toString();
}
项目:incubator-netbeans
文件:AddModulePanel.java
private static void exchangeCommands(String[][] commandsToExchange,final JComponent target,final JComponent source) {
InputMap targetBindings = target.getInputMap();
Keystroke[] targetBindingKeys = targetBindings.allKeys();
ActionMap targetActions = target.getActionMap();
InputMap sourceBindings = source.getInputMap();
ActionMap sourceActions = source.getActionMap();
for (int i = 0; i < commandsToExchange.length; i++) {
String commandFrom = commandsToExchange[i][0];
String commandTo = commandsToExchange[i][1];
final Action orig = targetActions.get(commandTo);
if (orig == null) {
continue;
}
sourceActions.put(commandTo,new AbstractAction() {
public void actionPerformed(ActionEvent e) {
orig.actionPerformed(new ActionEvent(target,e.getID(),e.getActionCommand(),e.getWhen(),e.getModifiers()));
}
});
for (int j = 0; j < targetBindingKeys.length; j++) {
if (targetBindings.get(targetBindingKeys[j]).equals(commandFrom)) {
sourceBindings.put(targetBindingKeys[j],commandTo);
}
}
}
}
项目:Pogamut3
文件:MVMapElement.java
MVMapElement(TLDataObject dataObject) {
// Hack
if (Beans.isDesignTime()) {
Beans.setDesignTime(false);
}
this.dataObject = dataObject;
glPanel = new TLMapGLPanel(dataObject.getDatabase().getMap(),dataObject.getDatabase());
slider = new TLSlider(dataObject.getDatabase());
elementPanel = new JPanel(new BorderLayout());
elementPanel.add(glPanel,BorderLayout.CENTER);
elementPanel.add(slider,BorderLayout.PAGE_END);
ActionMap map = new ActionMap();
map.put("save",SystemAction.get(SaveAction.class));
elementPanel.setActionMap(map);
lookupContent = new InstanceContent();
lookup = new ProxyLookup(dataObject.getLookup(),new AbstractLookup(lookupContent));
}
@RandomlyFails // NB-Core-Build #7816: expected:<0> but was:<1>
public void testPropertychangelistenersDetachedAtFinalizeIssue58100() throws Exception {
class MyAction extends AbstractAction
implements ActionPerformer {
public void actionPerformed(ActionEvent ev) {
}
public void performAction(SystemAction a) {
}
}
MyAction action = new MyAction();
ActionMap map = new ActionMap();
CallbackSystemAction systemaction = (CallbackSystemAction)SystemAction.get(SimpleCallbackAction.class);
map.put(systemaction.getActionMapKey(),action);
Lookup context = Lookups.singleton(map);
Action delegateaction = systemaction.createContextAwareInstance(context);
assertTrue("Action is expected to have a Propertychangelistener attached",action.getPropertychangelisteners().length > 0);
Reference actionref = new WeakReference(systemaction);
systemaction = null;
delegateaction = null;
assertGC("CallbackSystemAction is supposed to be GCed",actionref);
assertEquals("Action is expected to have no Propertychangelistener attached",action.getPropertychangelisteners().length);
}
项目:incubator-netbeans
文件:NavigationTreeViewTest.java
private void sendAction(final Object key) throws Exception {
class Process implements Runnable {
@Override
public void run() {
final ActionMap map = treeView.tree.getActionMap();
Action a = map.get(key);
String all = Arrays.toString(map.allKeys()).replace(',','\n');
assertNotNull("Action for key " + key + " found: " + all,a);
a.actionPerformed(new ActionEvent(treeView.tree,null));
}
}
Process processEvent = new Process();
LOG.log(Level.INFO,"Sending action {0}",key);
SwingUtilities.invokeAndWait(processEvent);
LOG.log(Level.INFO,"Action {0} send",key);
}
项目:incubator-netbeans
文件:CloneableEditorInitializer.java
private boolean initactionMapInEDT() {
// Init action map: cut,copy,delete,paste actions.
javax.swing.ActionMap am = editor.getActionMap();
//#43157 - editor actions need to be accessible from outside using the TopComponent.getLookup(ActionMap.class) call.
// used in main menu enabling/disabling logic.
javax.swing.ActionMap paneMap = pane.getActionMap();
// o.o.windows.DelegateActionMap.setParent() leads to CloneableEditor.getEditorPane()
provideUnfinishedPane = true;
try {
am.setParent(paneMap);
} finally {
provideUnfinishedPane = false;
}
//#41223 set the defaults befor the custom editor + kit get initialized,giving them opportunity to
// override defaults..
paneMap.put(DefaultEditorKit.cutAction,getAction(DefaultEditorKit.cutAction));
paneMap.put(DefaultEditorKit.copyAction,getAction(DefaultEditorKit.copyAction));
paneMap.put("delete",getAction(DefaultEditorKit.deleteNextCharaction)); // NOI18N
paneMap.put(DefaultEditorKit.pasteAction,getAction(DefaultEditorKit.pasteAction));
return true;
}
项目:incubator-netbeans
文件:Outline.java
private void init() {
initialized = true;
setDefaultRenderer(Object.class,new DefaultOutlineCellRenderer());
ActionMap am = getActionMap();
//make rows expandable with left/rigt arrow keys
Action a = am.get("selectNextColumn"); //NOI18N
am.put("selectNextColumn",new ExpandAction(true,a)); //NOI18N
a = am.get("selectPrevIoUsColumn"); //NOI18N
am.put("selectPrevIoUsColumn",new ExpandAction(false,a)); //NOI18N
getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (getSelectedRowCount() == 1) {
selectedRow = getSelectedRow();
} else {
selectedRow = -1;
}
}
});
}
项目:incubator-netbeans
文件:TemplatesPanel.java
/** Creates new form TemplatesPanel */
public TemplatesPanel (String pathToSelect) {
ActionMap map = getActionMap ();
map.put (DefaultEditorKit.copyAction,ExplorerUtils.actioncopy (getExplorerManager ()));
map.put (DefaultEditorKit.cutAction,ExplorerUtils.actionCut (getExplorerManager ()));
map.put (DefaultEditorKit.pasteAction,ExplorerUtils.actionPaste (getExplorerManager ()));
map.put ("delete",ExplorerUtils.actionDelete (getExplorerManager (),true)); // NOI18N
initComponents ();
createTemplateView ();
treePanel.add (view,BorderLayout.CENTER);
associateLookup (ExplorerUtils.createLookup (getExplorerManager (),map));
initialize (pathToSelect);
}
项目:incubator-netbeans
文件:ResultPanelTree.java
ResultPanelTree(ResultdisplayHandler displayHandler,StatisticsPanel statPanel) {
super(new BorderLayout());
treeView = new ResultTreeView();
treeView.getAccessibleContext().setAccessibleName(Bundle.ACSN_TestResults());
treeView.getAccessibleContext().setAccessibleDescription(Bundle.ACSD_TestResults());
treeView.setBorder(BorderFactory.createEtchedBorder());
// resultBar.setPassedPercentage(0.0f);
JToolBar toolBar = new JToolBar();
toolBar.setFloatable(false);
toolBar.add(resultBar);
toolBar.setBorder(BorderFactory.createEtchedBorder());
add(toolBar,BorderLayout.norTH);
add(treeView,BorderLayout.CENTER);
explorerManager = new ExplorerManager();
explorerManager.setRootContext(rootNode = new RootNode(displayHandler.getSession(),filterMask));
explorerManager.addPropertychangelistener(this);
initaccessibility();
this.displayHandler = displayHandler;
this.statPanel = statPanel;
displayHandler.setLookup(ExplorerUtils.createLookup(explorerManager,new ActionMap()));
}
项目:incubator-netbeans
文件:QueryBuilder.java
/** Opened for the first time */
@Override
protected void componentOpened() {
Log.getLogger().entering("QueryBuilder","componentOpened");
activateActions();
ActionMap map = getActionMap();
InputMap keys = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
installActions(map,keys);
// QueryBuilder does not need to listen to VSE,because it will notify us
// directly if something changes. The sqlCommandCustomizer needs to listen
// to VSE,because that's the only way it is notified of changes to the command
// sqlStatement.addPropertychangelistener(sqlStatementListener) ;
// vse.addPropertychangelistener(sqlStatementListener) ;
// do NOT force a parse here. It's done in componentShowing().
// populate( sqlStatement.getCommand()) ;
}
项目:incubator-netbeans
文件:ErrorNavigatorProviderImpl.java
public JComponent getComponent() {
if (panel == null) {
final BeanTreeView view = new BeanTreeView();
view.setRootVisible(false);
view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
class Panel extends JPanel implements ExplorerManager.Provider,Lookup.Provider {
// Make sure action context works correctly:
private final Lookup lookup = ExplorerUtils.createLookup(manager,new ActionMap());
{
setLayout(new BorderLayout());
add(view,BorderLayout.CENTER);
}
public ExplorerManager getExplorerManager() {
return manager;
}
public Lookup getLookup() {
return lookup;
}
}
panel = new Panel();
}
return panel;
}
项目:incubator-netbeans
文件:ElementNavigatorProviderImpl.java
public JComponent getComponent() {
if (panel == null) {
final BeanTreeView view = new BeanTreeView();
view.setRootVisible(true);
view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
class Panel extends JPanel implements ExplorerManager.Provider,BorderLayout.CENTER);
}
public ExplorerManager getExplorerManager() {
return manager;
}
public Lookup getLookup() {
return lookup;
}
}
panel = new Panel();
}
return panel;
}
项目:incubator-netbeans
文件:DelegateActionMapTest.java
/**
* Test of allKeys method,of class DelegateActionMap.
*/
@Test
public void testNPEinAllKeys() {
System.out.println( "allKeys" );
TopComponent tc = new TopComponent();
ActionMap delegate = new ActionMap();
delegate.put( "test",new AbstractAction() {
@Override
public void actionPerformed( ActionEvent e ) {
throw new UnsupportedOperationException( "Not supported yet." ); //To change body of generated methods,choose Tools | Templates.
}
});
assertNotNull( delegate.allKeys() );
DelegateActionMap instance = new DelegateActionMap( tc,delegate );
Object[] result = instance.allKeys();
assertNotNull( result );
instance.clear();
result = instance.allKeys();
assertNotNull( result );
}
项目:incubator-netbeans
文件:TreeNavigatorProviderImpl.java
public JComponent getComponent() {
if (panel == null) {
final BeanTreeView view = new BeanTreeView();
view.setRootVisible(true);
view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
class Panel extends JPanel implements ExplorerManager.Provider,BorderLayout.CENTER);
}
public ExplorerManager getExplorerManager() {
return manager;
}
public Lookup getLookup() {
return lookup;
}
}
panel = new Panel();
}
return panel;
}
项目:incubator-netbeans
文件:LicensePanel.java
/** Creates new form LicensePanel */
public LicensePanel(URL url) {
this.url = url;
initComponents();
initaccessibility();
try {
jEditorPane1.setPage(url);
} catch (IOException exc) {
//Problem with locating file
System.err.println("Exception: " + exc.getMessage()); //NOI18N
exc.printstacktrace();
}
ActionMap actionMap = jEditorPane1.getActionMap();
actionMap.put(DefaultEditorKit.upAction,new ScrollAction(-1));
actionMap.put(DefaultEditorKit.downAction,new ScrollAction(1));
}
项目:incubator-netbeans
文件:CatalogPanel.java
/** Creates new form CatalogPanel */
public CatalogPanel() {
ActionMap map = getActionMap();
map.put(DefaultEditorKit.copyAction,ExplorerUtils.actioncopy(getExplorerManager()));
map.put(DefaultEditorKit.cutAction,ExplorerUtils.actionCut(getExplorerManager()));
map.put(DefaultEditorKit.pasteAction,ExplorerUtils.actionPaste(getExplorerManager()));
map.put("delete",ExplorerUtils.actionDelete(getExplorerManager(),true)); // NOI18N
initComponents();
createCatalogView();
treePanel.add(view,BorderLayout.CENTER);
associateLookup(ExplorerUtils.createLookup(getExplorerManager(),map));
initialize();
}
项目:incubator-netbeans
文件:AbstractDesignEditor.java
private void init() {
manager = new ExplorerManager();
helpAction = new HelpAction();
final ActionMap map = AbstractDesignEditor.this.getActionMap();
getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
Keystroke.getKeystroke(java.awt.event.KeyEvent.VK_F1,ACTION_INVOKE_HELP);
map.put(ACTION_INVOKE_HELP,helpAction);
SaveAction act = (SaveAction) org.openide.util.actions.SystemAction.get(SaveAction.class);
Keystroke stroke = Keystroke.getKeystroke(java.awt.event.KeyEvent.VK_S,java.awt.Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(stroke,"save"); //NOI18N
map.put("save",act); //NOI18N
associateLookup(ExplorerUtils.createLookup(manager,map));
manager.addPropertychangelistener(new NodeselectedListener());
setLayout(new BorderLayout());
}
项目:incubator-netbeans
文件:ListViewNavigatorPanel.java
public ListViewNavigatorPanel () {
manager = new ExplorerManager();
ActionMap map = getActionMap();
copyAction = ExplorerUtils.actioncopy(manager);
map.put(DefaultEditorKit.copyAction,copyAction);
map.put(DefaultEditorKit.cutAction,ExplorerUtils.actionCut(manager));
map.put(DefaultEditorKit.pasteAction,ExplorerUtils.actionPaste(manager));
map.put("delete",ExplorerUtils.actionDelete(manager,true)); // or false
lookup = ExplorerUtils.createLookup(manager,map);
listView = new ListView();
fillListView(listView);
add(listView);
}
项目:incubator-netbeans
文件:PreventNeedlessChangesOfActionMapTest.java
public void testChangeOfNodeDoesNotFireChangeInActionMap() {
ActionMap am = (ActionMap)tc.getLookup().lookup(ActionMap.class);
assertNotNull(am);
Node m1 = new AbstractNode(Children.LEAF);
m1.setName("old m1");
Node m2 = new AbstractNode(Children.LEAF);
m2.setName("new m2");
tc.setActivatednodes(new Node[] { m1 });
assertEquals("No change in ActionMap 1",cnt);
tc.setActivatednodes(new Node[] { m2 });
assertEquals("No change in ActionMap 2",cnt);
tc.setActivatednodes(new Node[0]);
assertEquals("No change in ActionMap 3",cnt);
tc.setActivatednodes(null);
assertEquals("No change in ActionMap 4",cnt);
ActionMap am2 = (ActionMap)tc.getLookup().lookup(ActionMap.class);
assertEquals("Still the same action map",am,am2);
}
项目:incubator-netbeans
文件:GlobalManager.java
/** Change all that do not survive ActionMap change */
@Override
public final void resultChanged(org.openide.util.LookupEvent ev) {
Collection<? extends Lookup.Item<? extends ActionMap>> all = result.allItems();
ActionMap a = all.isEmpty() ? null : all.iterator().next().getInstance();
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE,"changed map : {0}",a); // NOI18N
LOG.log(Level.FINE,"prevIoUs map: {0}",actionMap.get()); // NOI18N
}
final ActionMap prev = actionMap.get();
if (a == prev) {
return;
}
final ActionMap newMap = newMap(prev,a);
actionMap = new WeakReference<ActionMap>(newMap);
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("clearactionPerformers"); // NOI18N
}
Mutex.EVENT.readAccess(new Runnable() {
@Override
public void run() {
notifyListeners(prev,newMap);
}
});
}
项目:jmt
文件:ExactTable.java
protected void installKeyboard() {
InputMap im = getInputMap();
ActionMap am = getActionMap();
installKeyboardAction(im,copY_ACTION);
installKeyboardAction(im,CUT_ACTION);
installKeyboardAction(im,PASTE_ACTION);
installKeyboardAction(im,FILL_ACTION);
installKeyboardAction(im,CLEAR_ACTION);
}
项目:powertext
文件:MatchedBracketPopup.java
/**
* Adds key bindings to this popup.
*/
private void installKeyBindings() {
InputMap im = getRootPane().getInputMap(
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
ActionMap am = getRootPane().getActionMap();
Keystroke escapeKS = Keystroke.getKeystroke(KeyEvent.VK_ESCAPE,0);
im.put(escapeKS,"onescape");
am.put("onescape",new EscapeAction());
}
private void assertActionMap () {
ActionMap map = lookup.lookup(ActionMap.class);
assertNotNull ("Map has to be there",map);
javax.swing.Action action = map.get (KEY);
assertEquals ("It is really our action",sampleAction,action);
}
项目:incubator-netbeans
文件:MultiViewTopComponentLookup.java
@Override
public Lookup.Item lookupItem(Lookup.Template template) {
Lookup.Item retValue;
if (template.getType() == ActionMap.class || (template.getId() != null && template.getId().equals("javax.swing.ActionMap"))) {
return initial.lookupItem(template);
}
// do something here??
retValue = super.lookupItem(template);
return retValue;
}
public void actionPerformed(ActionEvent e) {
//TEdit.saveOld();
//TEdit.updateTextArea("","Untitled");
ActionMap m = TEdit.getActionMap();
m.get(DefaultEditorKit.copyAction).actionPerformed(e);
TEdit.setEnabled("Save",e);
}
项目:incubator-netbeans
文件:ActionProcessorTest.java
public void testSurviveFocusChangeBehavior() throws Exception {
class MyAction extends AbstractAction {
public int cntEnabled;
public int cntPerformed;
@Override
public boolean isEnabled() {
cntEnabled++;
return true;
}
@Override
public void actionPerformed(ActionEvent ev) {
cntPerformed++;
}
}
MyAction myAction = new MyAction();
ActionMap disable = new ActionMap();
ActionMap enable = new ActionMap();
InstanceContent ic = new InstanceContent();
AbstractLookup al = new AbstractLookup(ic);
ContextAwareAction temp = (ContextAwareAction) Actions.forID("Windows","my.survival.action");
Action a = temp.createContextAwareInstance(al);
enable.put(SURVIVE_KEY,myAction);
ic.add(enable);
assertTrue("MyAction is enabled",a.isEnabled());
ic.set(Collections.singletonList(disable),null);
assertTrue("Remains enabled on other component",a.isEnabled());
ic.remove(disable);
}
项目:incubator-netbeans
文件:CallbackActionTest.java
public void testWithFallback() throws Exception {
MyAction myAction = new MyAction();
MyAction fallAction = new MyAction();
ActionMap other = new ActionMap();
ActionMap tc = new ActionMap();
tc.put("somekey",myAction);
InstanceContent ic = new InstanceContent();
AbstractLookup al = new AbstractLookup(ic);
ic.add(tc);
ContextAwareAction a = callback("somekey",fallAction,al,false);
CntListener l = new CntListener();
a.addPropertychangelistener(l);
assertTrue("My action is on",myAction.isEnabled());
assertTrue("Callback is on",a.isEnabled());
l.assertCnt("No change yet",0);
ic.remove(tc);
assertTrue("fall is on",fallAction.isEnabled());
assertTrue("My is on as well",a.isEnabled());
l.assertCnt("Still enabled,so no change",0);
fallAction.setEnabled(false);
l.assertCnt("Now there was one change",1);
assertFalse("fall is off",fallAction.isEnabled());
assertFalse("My is off as well",a.isEnabled());
Action a2 = a.createContextAwareInstance(Lookup.EMPTY);
assertEquals("Both actions are equal",a,a2);
assertEquals("and have the same hash",a.hashCode(),a2.hashCode());
}
项目:incubator-netbeans
文件:MultiViewActionMapTest.java
public void testActionMapChangesForElementsWithComponentShowingInit() throws Exception {
Action act1 = new TestAction("MultiViewAction1");
Action act2 = new TestAction("MultiViewAction2");
MVElemTopComponent elem1 = new ComponentShowingElement("testAction",act1);
MVElemTopComponent elem2 = new ComponentShowingElement("testAction",act2);
MVElem elem3 = new MVElem();
MultiViewDescription desc1 = new MVDesc("desc1",null,elem1);
MultiViewDescription desc2 = new MVDesc("desc2",elem2);
MultiViewDescription desc3 = new MVDesc("desc3",elem3);
MultiViewDescription[] descs = new MultiViewDescription[] { desc1,desc2,desc3 };
TopComponent tc = MultiViewFactory.createMultiView(descs,desc1);
Lookup.Result result = tc.getLookup().lookup(new Lookup.Template(ActionMap.class));
LookListener2 list = new LookListener2();
result.addLookupListener(list);
result.allInstances().size();
list.setCorrectValues("testAction",act1);
// WARNING: as anything else the first element's action map is set only after the tc is opened..
tc.open();
assertEquals(1,list.getCount());
MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
// test related hack,easy establishing a connection from Desc->perspective
Accessor.DEFAULT.createPerspective(desc2);
list.setCorrectValues("testAction",act2);
handler.requestVisible(Accessor.DEFAULT.createPerspective(desc2));
assertEquals(2,list.getCount());
Accessor.DEFAULT.createPerspective(desc3);
list.setCorrectValues("testAction",null);
handler.requestVisible(Accessor.DEFAULT.createPerspective(desc3));
assertEquals(3,list.getCount());
}
项目:incubator-netbeans
文件:TopComponentLookupToNodesBridge.java
/** Setup component with lookup.
*/
protected void setUp() {
System.setProperty("org.openide.util.Lookup","-");
map = new ActionMap();
ic = new InstanceContent();
ic.add(map);
lookup = new AbstractLookup(ic);
top = new TopComponent(lookup);
}
项目:incubator-netbeans
文件:ComponentInspector.java
final javax.swing.ActionMap setupActionMap(javax.swing.ActionMap map) {
map.put(DefaultEditorKit.copyAction,copyActionPerformer);
map.put(DefaultEditorKit.cutAction,cutActionPerformer);
//map.put(DefaultEditorKit.pasteAction,ExplorerUtils.actionPaste(explorerManager));
map.put("delete",deleteActionPerformer); // NOI18N
return map;
}
项目:incubator-netbeans
文件:PopupManager.java
private void consumeIfKeyPressInActionMap(KeyEvent e) {
// get popup's registered keyboard actions
ActionMap am = popup.getActionMap();
InputMap im = popup.getInputMap();
// check whether popup registers keystroke
// If we consumed key pressed,we need to consume other key events as well:
Keystroke ks = Keystroke.getKeystrokeForEvent(
new KeyEvent((Component) e.getSource(),KeyEvent.KEY_pressed,e.getModifiers(),KeyEvent.getExtendedKeyCodeForChar(e.getKeyChar()),e.getKeyChar(),e.getKeyLocation())
);
Object obj = im.get(ks);
if (obj != null && !obj.equals("tooltip-no-action") //NOI18N ignore ToolTipSupport installed actions
) {
// if yes,if there is a popup's action,consume key event
Action action = am.get(obj);
if (action != null && action.isEnabled()) {
// actionPerformed on key press only.
e.consume();
}
}
}
项目:incubator-netbeans
文件:ToolTipSupport.java
private static void filterBindings(ActionMap actionMap) {
for(Object key : actionMap.allKeys()) {
String actionName = key.toString().toLowerCase(Locale.ENGLISH);
LOG.log(Level.FINER,"Action-name: {0}",actionName); //NOI18N
if (actionName.contains("delete") || actionName.contains("insert") || //NOI18N
actionName.contains("paste") || actionName.contains("default") || //NOI18N
actionName.contains("cut") //NOI18N
) {
actionMap.put(key,NO_ACTION);
}
}
}
项目:Logisim
文件:TableTabCaret.java
TableTabCaret(TableTab table) {
this.table = table;
cursorRow = 0;
cursorCol = 0;
markRow = 0;
markCol = 0;
table.getTruthTable().addTruthTableListener(listener);
table.addMouseListener(listener);
table.addMouseMotionListener(listener);
table.addKeyListener(listener);
table.addFocusListener(listener);
InputMap imap = table.getInputMap();
ActionMap amap = table.getActionMap();
AbstractAction nullAction = new AbstractAction() {
/**
*
*/
private static final long serialVersionUID = 7932515593155479627L;
@Override
public void actionPerformed(ActionEvent e) {
}
};
String nullKey = "null";
amap.put(nullKey,nullAction);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_DOWN,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_UP,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_LEFT,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_RIGHT,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_PAGE_DOWN,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_PAGE_UP,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_HOME,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_END,nullKey);
imap.put(Keystroke.getKeystroke(KeyEvent.VK_ENTER,nullKey);
}
项目:incubator-netbeans
文件:Tab.java
/** Creates */
private Tab() {
this.manager = new ExplorerManager();
ActionMap map = this.getActionMap ();
map.put(DefaultEditorKit.copyAction,ExplorerUtils.actioncopy(manager));
map.put(DefaultEditorKit.cutAction,ExplorerUtils.actionDelete (manager,true)); // or false
// following line tells the top component which lookup should be associated with it
associateLookup (ExplorerUtils.createLookup (manager,map));
}
public Action findGlobalAction(Object key,boolean surviveFocusChange) {
// search action in all action maps from global context
Action a = null;
for (Reference<ActionMap> ref : actionMaps) {
ActionMap am = ref.get();
a = am == null ? null : am.get(key);
if (a != null) {
break;
}
}
if (surviveFocusChange) {
if (a == null) {
a = survive.get(key);
if (a != null) {
a = ((WeakAction) a).getDelegate();
}
if (err.isLoggable(Level.FINE)) {
err.fine("No action for key: " + key + " using delegate: " + a); // NOI18N
}
} else {
if (err.isLoggable(Level.FINE)) {
err.fine("New action for key: " + key + " put: " + a);
}
survive.put(key,new WeakAction(a));
}
}
if (err.isLoggable(Level.FINE)) {
err.fine("Action for key: " + key + " is: " + a); // NOI18N
}
return a;
}
项目:incubator-netbeans
文件:MainMenuAction.java
protected final ActionMap getContextActionMap() {
if (globalActionMap == null) {
globalActionMap = org.openide.util.Utilities.actionsGlobalContext().lookupResult(ActionMap.class);
globalActionMap.addLookupListener(WeakListeners.create(LookupListener.class,this,globalActionMap));
}
Collection<? extends ActionMap> am = globalActionMap.allInstances();
return am.size() > 0 ? am.iterator().next() : null;
}
项目:incubator-netbeans
文件:PreventNeedlessChangesOfActionMapTest.java
protected void setUp() throws Exception {
tc = new TopComponent();
res = tc.getLookup().lookup(new Lookup.Template<ActionMap> (ActionMap.class));
assertEquals("One instance",1,res.allItems().size());
res.addLookupListener(this);
}
项目:incubator-netbeans
文件:ExplorerPanel.java
public ExplorerPanel() {
manager = new ExplorerManager();
ActionMap map = getActionMap();
map.put(DefaultEditorKit.copyAction,true));
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。