1 19 20 21 package org.netbeans.core.windows.actions; 22 23 24 import org.netbeans.core.windows.ModeImpl; 25 import org.netbeans.core.windows.WindowManagerImpl; 26 import org.openide.util.NbBundle; 27 import org.openide.windows.TopComponent; 28 29 import javax.swing.*; 30 import java.awt.event.ActionEvent ; 31 import java.util.List ; 32 33 34 35 40 public class NextTabAction extends AbstractAction { 41 42 43 public NextTabAction() { 44 putValue(NAME, NbBundle.getMessage(NextTabAction.class, "CTL_NextTabAction")); 45 } 46 47 48 public void actionPerformed(ActionEvent evt) { 49 TopComponent tc = TopComponent.getRegistry().getActivated(); 50 if(tc == null) { 51 return; 52 } 53 54 ModeImpl mode = (ModeImpl)WindowManagerImpl.getInstance().findMode(tc); 55 56 List openedTcs = mode.getOpenedTopComponents(); 57 58 int index = openedTcs.indexOf(tc); 59 60 if(index == -1) { 61 return; 62 } 63 64 index++; 66 if(index >= openedTcs.size()) { 67 index = 0; 68 } 69 70 TopComponent select = (TopComponent)openedTcs.get(index); 71 if(select == null) { 72 return; 73 } 74 75 mode.setSelectedTopComponent(select); 76 } 77 } 78 79 | Popular Tags |