Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333196

Summary: New member filter dialogue keep popping up when creating a shared member filter.
Product: [Tools] Target Management Reporter: San <sansu>
Component: RSEAssignee: David McKnight <dmcknigh>
Status: RESOLVED FIXED QA Contact: Martin Oberhuber <mober.at+eclipse>
Severity: normal    
Priority: P3 CC: dmcknigh
Version: unspecified   
Target Milestone: 3.3 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 333593    
Attachments:
Description Flags
patch to not refresh when item not found none

Description San CLA 2010-12-24 10:27:22 EST
Steps to reproduce the problem:

1. Launch RDp with a new workspace
2. Create more than 2 connections to two different IBMi hosts.
3. Expand the first connection and create a member filter without the "Only create filter in this connection" option. That means the filter will be created for all the connections. If prompted to signon, cancel out. 
4. Collapse all the nodes in the RSE tree, then exit workbench
5. launch the same workspace and expand the object node in the first connection
6. create a member filter without the "Only create filter in this connection" option. 
7. when click Finish, the "new member filter" dialogue will be popped up again.



The call stack that does a refresh that is triggering this problem is below. Line 4255 in SystemView.findAndUpdateFilterParent() is "refresh();".

Thread [main] (Suspended (breakpoint at line 4255 in SystemView))	
	SystemView.findAndUpdateFilterParent(ISystemResourceChangeEvent, int) line: 4255	
	SystemView$ResourceChangedJob.runInUIThread(IProgressMonitor) line: 1913	
	SystemView.systemResourceChanged(ISystemResourceChangeEvent) line: 1792	
	SystemResourceChangeManager.notify(ISystemResourceChangeEvent) line: 97	
	SystemRegistry.fireEvent(ISystemResourceChangeEvent) line: 2452	
	QSYSObjectSubSystemConfiguration(SubSystemConfiguration).fireEvent(SystemResourceChangeEvent) line: 1867	
	QSYSObjectSubSystemConfiguration(SubSystemConfiguration).fireSubSystemEvent(SystemResourceChangeEvent, ISubSystem) line: 1914	
	QSYSObjectSubSystemConfiguration(SubSystemConfiguration).fireSubSystemFilterEvent(SystemResourceChangeEvent, ISystemFilter) line: 2000	
	QSYSObjectSubSystemConfiguration(SubSystemConfiguration).fireSubSystemFilterEvent(int, ISystemFilter) line: 1946	
	QSYSObjectSubSystemConfiguration(SubSystemConfiguration).filterEventFilterCreated(ISystemFilter) line: 2122	
	SystemFilterPoolManager.doCreateSystemFilter(ISystemFilterContainer, String, String[], String, boolean) line: 727	
	SystemFilterPoolManager.createSystemFilter(ISystemFilterContainer, String, List, String, boolean) line: 632	
	SystemFilterPoolManager.createSystemFilter(ISystemFilterContainer, String, List, String) line: 640	
	SystemNewFilterWizard.createNewFilter(Shell, ISystemFilterContainer, String, Vector, String) line: 641	
	SystemNewFilterWizard.performFinish() line: 504	
	SystemWizardDialog(WizardDialog).finishPressed() line: 811	
	SystemWizardDialog(WizardDialog).buttonPressed(int) line: 430	
	Dialog$2.widgetSelected(SelectionEvent) line: 624	
	TypedListener.handleEvent(Event) line: 234	
	EventTable.sendEvent(Event) line: 84	
	Button(Widget).sendEvent(Event) line: 1053	
	Display.runDeferredEvents() line: 4066	
	Display.readAndDispatch() line: 3657	
	SystemWizardDialog(Window).runEventLoop(Shell) line: 825	
	SystemWizardDialog(Window).open() line: 801	
	QSYSNewMemberFilterAction(SystemBaseDialogAction).run() line: 299	
	QSYSNewMemberFilterAction(QSYSNewFilterAction).run() line: 80	
	QSYSObjectSubSystemConfigurationAdapter.createFilterByPrompting(ISubSystemConfiguration, ISystemFilterReference, Shell) line: 388	
	SystemViewFilterReferenceAdapter$1.run() line: 336	
	UILockListener.doPendingWork() line: 164	
	UISynchronizer$3.run() line: 158	
	RunnableLock.run() line: 35	
	UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 134	
	Display.runAsyncMessages(boolean) line: 4041	
	Display.readAndDispatch() line: 3660	
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2640	
	Workbench.runUI() line: 2604	
	Workbench.access$4(Workbench) line: 2438	
	Workbench$7.run() line: 671	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 664	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	IDEApplication.start(IApplicationContext) line: 115	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 110	
	EclipseAppLauncher.start(Object) line: 79	
	EclipseStarter.run(Object) line: 369	
	EclipseStarter.run(String[], Runnable) line: 179	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
	Method.invoke(Object, Object...) line: 597	
	Main.invokeFramework(String[], URL[]) line: 619	
	Main.basicRun(String[]) line: 574	
	Main.run(String[]) line: 1407	
	Main.main(String[]) line: 1383	

	
	
The relevant part of the code is:

protected void findAndUpdateFilterParent(ISystemResourceChangeEvent event, int type) {
		ISubSystem ss = (ISubSystem) event.getGrandParent();
        ...
        
		Widget item = findItem(ss);
		if (item == null) {
			refresh();

			if (debug) logDebugMsg("...Did not find ss " + ss.getName()); //$NON-NLS-1$
			return;
		}
		
The workspace has 2 connections. When I create the member filter, the option "Only create a filter in this connection" is not checked so
the wizard attempts to create the filter for both connections. The filter for the first connection gets created without any problems.
When the filter for the second connection is created, findItem(ss) returns null. The reason a null is returned is because the 
second connection was never expanded so the tree item for the sub-system object does not exist yet. So the code does a refresh of the
entire tree causing the filter wizard dialog (from the first connection) to be shown again. 

It's not clear to me why a refresh of the tree is necessary since it does not actually create the tree item for the sub-system object. If a refresh has
to be done, I think it should be done only for the connection that where the ss item could not be found.
I propose this fix:

protected void findAndUpdateFilterParent(ISystemResourceChangeEvent event, int type) {
		ISubSystem ss = (ISubSystem) event.getGrandParent();
        ...
        
		Widget item = findItem(ss);
		if (item == null) {
			//refresh();
			IHost host = ss.getHost();
			if (host != null) {
				Widget hostWidget = findItem(host);
				if (hostWidget != null ) {
					refresh(host);
				}
			}
			

			if (debug) logDebugMsg("...Did not find ss " + ss.getName()); //$NON-NLS-1$
			return;
		}


A second solution is to remove the refresh() although since it does not appear to do anything. I tried this and it fixes the immediate problem as well.
Comment 1 David McKnight CLA 2011-01-05 11:47:23 EST
I looked at the code and it's not clear to me why the SystemView needs the refresh() when the subsystem item isn't found.  Since the host item hasn't been expanded, it currently has no child items so I don't think the refresh(host) will actually do anything.  It may be better to get rid of the refresh entirely - although there may have been a reason for the refresh() at least at one point in time.
Comment 2 David McKnight CLA 2011-01-05 11:53:05 EST
Created attachment 186103 [details]
patch to not refresh when item not found

San, could you try with this patch?
Comment 3 San CLA 2011-01-05 13:12:40 EST
I tried the patch and it works fine.
Comment 4 San CLA 2011-01-05 13:17:17 EST
Can this fix be ported back to the R3_2_maintenance stream? We want to include it in a fix pack if possible.
Comment 5 David McKnight CLA 2011-01-05 14:07:53 EST
I've committed the fix to cvs and opened bug 333593 for the backport.