Revision 32718 trunk/libraries/libCorePlugin/src/com/iver/core/mdiManager/WindowStackSupport.java

View differences:

WindowStackSupport.java
53 53
 *
54 54
 */
55 55
public class WindowStackSupport {
56
	/* arrays for dynamically assigned shortcut keys */
57
	private boolean[] key_free;
58
	private String[] key;
59
	
56 60
	private Vector vistas = new Vector();
57 61

  
58 62
	private WindowInfoSupport vis;
......
64 68
	 */
65 69
	public WindowStackSupport(WindowInfoSupport vis) {
66 70
		this.vis = vis;
71
		
72
		/* restart window key shortcut numbering */
73
		key_free = new boolean[10];
74
		for ( int i = 0; i < 10; i ++ ) {
75
			key_free[i] = true;
76
		}
77
		key = new java.lang.String[10];
78
		key[0] = "1";
79
		key[1] = "2";
80
		key[2] = "3";
81
		key[3] = "4";
82
		key[4] = "5";
83
		key[5] = "6";
84
		key[6] = "7";
85
		key[7] = "8";
86
		key[8] = "9";
87
		key[9] = "0";
67 88
	}
68 89

  
69 90
	public void add(IWindow v, final ActionListener listener) {
......
74 95
		m.setActionCommand(""+id);
75 96
		m.setTooltip(PluginServices.getText(this, "activa_la_ventana"));
76 97
		m.setText("Ventana/"+vi.getTitle());
98
		/* get the first free mnemonic (if any) and assign */
99
		for ( int i=0; i < 10; i++) {
100
			if ( key_free[i]) {
101
				m.setKey(key[i]);
102
				key_free[i] = false;
103
				break;
104
			}
105
		}
77 106
		viewMenu.put(v, m);
78 107
		PluginServices.getMainFrame().addMenu(m, listener, PluginServices.getPluginServices(this).getClassLoader() );
79 108
	}
......
81 110
	public void remove(IWindow v){
82 111
		Menu m = (Menu) viewMenu.get(v);
83 112
		if (m == null) return;
113
		/* free keyboard shortut taken by this window (if any) */
114
		if ( m.getKey() != null ) {
115
			for ( int i=0; i < 10; i++ ) {
116
				if ( m.getKey() == key[i]) {
117
					key_free[i] = true;
118
					break;
119
				}
120
			}
121
		}
84 122
		PluginServices.getMainFrame().removeMenu(m);
85 123
		viewMenu.remove(v);
86 124
		vistas.remove(v);

Also available in: Unified diff