Révision 2049

tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/SwingChartComposite.java (revision 2049)
117 117
		this.rootPanel.setBackground(Color.WHITE);
118 118
		this.rootPanel.setBorder(new LineBorder(Color.WHITE, 1));
119 119
		
120
		 // FIXME: SJ: temporary workaround to Linux focus bugs
121
		// part #1: release the focus at mouse exited on the rootPanel, needed for empty charts, eg. Progression
122
		// it breaks all the key events in charts (zoom, pan, selection, etc.) but 
123
		// stops the conflict between AWT and SWT events that freezes the SWT Spinner, TextFields, etc.
124
		// (Progression query, Specificities chart banality, etc.)
125
		// see: http://forge.cbp.ens-lyon.fr/redmine/issues/2548
126
		if (OSDetector.isFamilyUnix()) {
127
			this.rootPanel.addMouseListener(new MouseListener() {
128

  
129
				@Override
130
				public void mouseReleased(MouseEvent e) {
131
					// TODO Auto-generated method stub
132

  
133
				}
134

  
135
				@Override
136
				public void mousePressed(MouseEvent e) {
137
					// TODO Auto-generated method stub
138

  
139
				}
140

  
141
				@Override
142
				public void mouseExited(MouseEvent e) {
143
					// FIXME: SJ: temporary workaround to Linux focus bugs
144
					// it breaks all the key events in charts (zoom, pan, selection, etc.) but
145
					// stops the conflict between AWT and SWT events that freezes the SWT Spinner,
146
					// TextFields, etc.
147
					// (Progression query, Specificities chart banality, etc.)
148
					// see: http://forge.cbp.ens-lyon.fr/redmine/issues/2548
149
					if (frame.isFocusOwner() || rootPanel.isFocusOwner()) {
150
						frame.setVisible(false);
151
						// Log.finest("SwingChartComposite.initEventsListeners().new MouseListener()
152
						// {...}.mouseExited()");
153
						frame.setVisible(true);
154

  
155
						Display.getDefault().asyncExec(new Runnable() {
156

  
157
							@Override
158
							public void run() {
159
								SwingChartComposite.this.chartEditor.getShell().forceActive();
160
							}
161
						});
162

  
163
					}
164
				}
165

  
166
				@Override
167
				public void mouseEntered(MouseEvent e) {
168
					// TODO Auto-generated method stub
169

  
170
				}
171

  
172
				@Override
173
				public void mouseClicked(MouseEvent e) {
174
					// TODO Auto-generated method stub
175

  
176
				}
177
			});
178
		}
120 179
		
121 180
		// SJ: Workaround to fix a bug with some Java version and some OS where the focus of an embedded Swing component does not delegate to SWT, eg. the Part is not activated.
122 181
		// After some tests, doesn't seem to work on Linux and Mac
......
589 648
			public void mouseExited(java.awt.event.MouseEvent e) {
590 649
				
591 650
				 // FIXME: SJ: temporary workaround to Linux focus bugs
651
				// part #2: release the focus at mouse exited on the AWT/SWing chart component
592 652
				// it breaks all the key events in charts (zoom, pan, selection, etc.) but 
593 653
				// stops the conflict between AWT and SWT events that freezes the SWT Spinner, TextFields, etc.
594 654
				// (Progression query, Specificities chart banality, etc.)
......
617 677
						// KeyboardFocusManager.getCurrentKeyboardFocusManager().clearFocusOwner();
618 678
						// KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
619 679

  
680
						//setVisible(false);
620 681
						frame.setVisible(false);
621 682
						Log.finest("SwingChartComposite.initEventsListeners().new MouseListener() {...}.mouseExited()");
622 683
						frame.setVisible(true);
684
						//setVisible(true);
623 685

  
624 686
						Display.getDefault().asyncExec(new Runnable() {
625 687

  
626 688
							@Override
627 689
							public void run() {
690
//								setVisible(false);
691
//								setVisible(true);
628 692
								// TODO Auto-generated method stub
629 693
								// shell.setMinimized(true);
630 694
								// shell.setMinimized(false);
631 695
								// shell.setActive();
632
								getChartComponent().getChartEditor().getShell().forceActive();
696
								//getChartComponent().getChartEditor().getShell().forceActive();
697
								SwingChartComposite.this.chartEditor.getShell().forceActive();
633 698
							}
634 699
						});
635 700

  
......
1004 1069
	 * @param eventType
1005 1070
	 * @return
1006 1071
	 */
1007
	// TODO : this method is incomplete
1072
	// TODO : SJ: this method is incomplete
1008 1073
	public static org.eclipse.swt.widgets.Event swingEventToSWT(Composite swtComposite, JComponent swingComponent, AWTEvent e, int eventType)	{
1009 1074

  
1010 1075
		Event event = new Event();

Formats disponibles : Unified diff