Revision 32780

View differences:

branches/v2_0_0_prep/libraries/libCorePlugin/src/org/gvsig/coreplugin/mdiManager/WindowStackSupport.java
54 54
 *
55 55
 */
56 56
public class WindowStackSupport {
57
	/* arrays for dynamically assigned shortcut keys */
58
	private boolean[] key_free;
59
	private String[] key;
60
	
57 61
	private Vector vistas = new Vector();
58 62

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

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

Also available in: Unified diff