Révision 2257

tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/SWTChartsComponentsProvider.java (revision 2257)
24 24
import org.eclipse.swt.widgets.ToolBar;
25 25
import org.eclipse.swt.widgets.ToolItem;
26 26
import org.eclipse.swt.widgets.Widget;
27
import org.eclipse.ui.IWorkbenchPart;
27 28
import org.eclipse.ui.PlatformUI;
28 29
import org.txm.chartsengine.core.ChartsEngine;
29 30
import org.txm.chartsengine.core.ChartsEnginesManager;
......
435 436

  
436 437
		Event eevent = (Event)event.getTrigger();
437 438
		Widget widget = eevent.widget;
439
		
440
		IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
438 441
		// Toolbars
439 442
		if(event != null && widget instanceof ToolItem)	{
440 443
			ToolItem to = (ToolItem) widget;
......
447 450
			}
448 451
		}
449 452
		// Context menu, multi pages editor
450
		else if(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart() instanceof TXMMultiPageEditor)	{
453
		else if(part instanceof TXMMultiPageEditor)	{
454
			TXMMultiPageEditor mpart = (TXMMultiPageEditor) part;
451 455
			// Main editor
452
			if(((TXMMultiPageEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()).getMainEditorPart() instanceof ChartEditor
453
					&& ((ChartEditor)((TXMMultiPageEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()).getMainEditorPart()).hasFocus())	{
454
				chartEditor = (ChartEditor)((TXMMultiPageEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()).getMainEditorPart();
456
			if(mpart.getMainEditorPart() instanceof ChartEditor
457
					&& ((ChartEditor)mpart.getMainEditorPart()).hasFocus())	{
458
				chartEditor = (ChartEditor)mpart.getMainEditorPart();
455 459
			}
456 460
			// FIXME: SJ: became useless?
457 461
//			else if(((MultiPageEditorPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getSelectedPage() instanceof ChartEditor
......
460 464
//			}
461 465
		}
462 466
		// Context menu, Normal editor
463
		else if(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart() instanceof ChartEditor)	{
464
			chartEditor = (ChartEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();	
467
		else if(part instanceof ChartEditor)	{
468
			chartEditor = (ChartEditor) part;	
465 469
		}
466 470
		return chartEditor;
467 471
	}

Formats disponibles : Unified diff