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

Bug 311599

Summary: [LinkedResources] TVT36:TCT115: FRA - Advanced button not working
Product: [Eclipse Project] Platform Reporter: CDE Administration <cdeadmin>
Component: UIAssignee: Serge Beauchamp <serge>
Status: CLOSED FIXED QA Contact: Serge Beauchamp <serge>
Severity: normal    
Priority: P3 CC: camle, kitlo, pawel.pogorzelski1, Szymon.Brandys
Version: 3.6Flags: Szymon.Brandys: review+
pawel.pogorzelski1: review+
Target Milestone: 3.6 RC2   
Hardware: PC   
OS: Windows XP   
URL: 115
Whiteboard:
Attachments:
Description Flags
08.000.280_AdvanceButtonNotWorking.gif
none
Patch for NPE in CreateLinkedResourceGroup in plugin org.eclipse.ui.ide
none
Additional fix
none
Final patch
none
Patch
none
New_SQL_File_dialog_error.GIF
none
Potential cause none

Description CDE Administration CLA 2010-05-04 14:16:56 EDT
<response_by> martine marin at 2010.05.03.08.10.21 </response_by>
Hi,

Build: 20100426-1300

When I click on Advanced button, nothing happens. This button is not working.

Steps to reproduce

1)  Start Eclipse and change the Perspective to Database Development Perspective from Window->Open Perspective->Other?
2)  When the Database Development Perspective opens, verify the Data Source Explorer (DSE) opens.  It should contain the Databases folder
3)  Open the Project Explorer View by selecting Window -> Show View -> Other... expand the General folder and select Project Explorer
4)  Create a project named test by selecting File -> New -> Project... expand the General folder and select Project.
5)  Go to File -> New -> Other-> SQL Development-> SQL File
6)  Click Next

Is it working as designed?

Thanks,

Martine

<response_by> Kit Lo at 2010.05.03.22.44.15 </response_by>
This article was reassigned from Category:''TVT/Testing,Product/Functional Issues''.

<response_by> Katia Milekhina at 2010.05.04.01.36.31 </response_by>
Same problem for Russia.

Regards,
Katia

<response_by> Kathy Li at 2010.05.04.12.59.34 </response_by>
We have verified English application with build 20100426-1300, the following problem happens in English application as well.

<response_by> nguyer at 2010.05.04.13.07.03 </response_by>
This article was reassigned from Category:''TVT/Testing,Inbox''.
Comment 1 CDE Administration CLA 2010-05-04 14:17:06 EDT
Created attachment 167003 [details]
08.000.280_AdvanceButtonNotWorking.gif
Comment 2 CDE Administration CLA 2010-05-04 14:17:10 EDT
<cde:tctdetail>
Testcase: 08.000.280 - DTP - NEW SQL FILE DIALOG/WINDOWS
Project: WSW36
Component: Xfer - Data Tools/SQL Editor Framework
Priority: 2
Subject: FRA - Advanced button not working
Article ID: 115
Originator: mmarin@fr.ibm.com
</cde:tctdetail>
Comment 3 Brian Payton CLA 2010-05-10 16:00:11 EDT
This appears to be a Eclipse platform bug.  The code where the NPE is thrown is in the org.eclipse.ui.ide plugin, in the CreateLinkedResourceGroup class.  

The constructor for the class allows a null to be passed as the "updatableResourceName" parameter, as shown here:

	/**
	 * Creates a link target group
	 * 
	 * @param type
	 *            specifies the type of resource to link to.
	 *            <code>IResource.FILE</code> or <code>IResource.FOLDER</code>
	 * @param listener
	 *            listener to notify when one of the widgets' value is changed.
	 * @param updatableResourceName
	 *            an updatable string value that will be updated to reflect the
	 *            link target's last segment, or <code>null</code>. Updating
	 *            will only happen if the current value of that string is null
	 *            or the empty string, or if it has not been changed since the
	 *            last time it was updated.
	 */
	public CreateLinkedResourceGroup(int type, Listener listener,
			IStringValue updatableResourceName) {
		this.type = type;
		this.listener = listener;
		this.updatableResourceName = updatableResourceName;
		if (updatableResourceName != null) {
			lastUpdatedValue = updatableResourceName.getValue();
		}
	}

However, code further on, in the "resolveVariable" method does not check for a null before trying to use the variable, as shown here:

	/**
	 * Tries to resolve the value entered in the link target field as a
	 * variable, if the value is a relative path. Displays the resolved value if
	 * the entered value is a variable.
	 */
	private void resolveVariable() {
		IPathVariableManager pathVariableManager;
		// use the resolved link target name
		if (updatableResourceName.getResource() != null)
			pathVariableManager = updatableResourceName.getResource().getPathVariableManager();
		else
			pathVariableManager = ResourcesPlugin
									.getWorkspace().getPathVariableManager();
		boolean isURL = true;
         etc....

I would think somebody else would have already found and reported this bug on the platform, but I did a Bugzilla search on bugs with "CreateLinkedResourceGroup" or "resolveVariable" in the title but did not find anything.
Comment 4 Brian Payton CLA 2010-05-10 17:04:27 EDT
Here's the exception traceback that occurs when the Advanced button on the New SQL File wizard page is clicked:

!ENTRY org.eclipse.ui 4 0 2010-05-10 14:02:07.296
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
	at org.eclipse.ui.internal.ide.dialogs.CreateLinkedResourceGroup.resolveVariable(CreateLinkedResourceGroup.java:562)
	at org.eclipse.ui.internal.ide.dialogs.CreateLinkedResourceGroup.access$2(CreateLinkedResourceGroup.java:559)
	at org.eclipse.ui.internal.ide.dialogs.CreateLinkedResourceGroup$2.modifyText(CreateLinkedResourceGroup.java:277)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:173)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1076)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
	at org.eclipse.swt.widgets.Text.wmCommandChild(Text.java:2526)
	at org.eclipse.swt.widgets.Control.WM_COMMAND(Control.java:4296)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4162)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4873)
	at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2362)
	at org.eclipse.swt.widgets.Text.callWindowProc(Text.java:255)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4250)
	at org.eclipse.swt.widgets.Text.windowProc(Text.java:2170)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4873)
	at org.eclipse.swt.internal.win32.OS.SetWindowTextW(Native Method)
	at org.eclipse.swt.internal.win32.OS.SetWindowText(OS.java:3318)
	at org.eclipse.swt.widgets.Text.setText(Text.java:1961)
	at org.eclipse.ui.internal.ide.dialogs.CreateLinkedResourceGroup.createLinkLocationGroup(CreateLinkedResourceGroup.java:327)
	at org.eclipse.ui.internal.ide.dialogs.CreateLinkedResourceGroup.createContents(CreateLinkedResourceGroup.java:208)
	at org.eclipse.ui.internal.ide.dialogs.CreateLinkedResourceGroup.createContents(CreateLinkedResourceGroup.java:157)
	at org.eclipse.datatools.sqltools.common.ui.resource.WizardNewFileCreationPage.handleAdvancedButtonSelect(WizardNewFileCreationPage.java:496)
	at org.eclipse.datatools.sqltools.common.ui.resource.WizardNewFileCreationPage$1.widgetSelected(WizardNewFileCreationPage.java:158)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
	at org.eclipse.jface.window.Window.open(Window.java:801)
	at org.eclipse.ui.internal.handlers.WizardHandler$New.executeHandler(WizardHandler.java:254)
	at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:274)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
	at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:157)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2601)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2565)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2399)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:669)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:662)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
	at java.lang.reflect.Method.invoke(Method.java:600)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Comment 5 Brian Payton CLA 2010-05-10 17:17:19 EDT
Here's the Eclipse projects needed to set up a DTP (Helios) environment to recreate this problem:

- Eclipse platform (v3.6)
- EMF (org.eclipse.emf.ecore) (v2.5.0)
- GEF (v3.5.2)
- DTP (v1.8)
Comment 6 Brian Payton CLA 2010-05-10 17:41:21 EDT
Created attachment 167831 [details]
Patch for NPE in CreateLinkedResourceGroup in plugin org.eclipse.ui.ide
Comment 7 Brian Payton CLA 2010-05-10 17:42:09 EDT
Added a simple patch that avoids the NPE and allows the Advanced button to work.
Comment 8 Serge Beauchamp CLA 2010-05-11 09:41:56 EDT
The patch is fine, thanks.

Do you want me to flag my review and commit it yourself, or for me to commit it after your review flag set?
Comment 9 Brian Payton CLA 2010-05-11 11:27:28 EDT
Hi Serge, I'm not sure if your comment is addressed to me... If so, please commit the change, since I am not a committer on the component in question.
Comment 10 Serge Beauchamp CLA 2010-05-11 12:25:25 EDT
No problem, I'll ask Szymon to review it.
Comment 11 Szymon Brandys CLA 2010-05-12 05:09:35 EDT
I found another way to blow up the Advanced button.

Steps:
1) Open the NewFile wizard
2) Clear 'Enter or select the parent folder:'
3) Click 'Advanced'

It used to work in 3.5.
Comment 12 Serge Beauchamp CLA 2010-05-13 05:02:45 EDT
Created attachment 168360 [details]
Additional fix

(In reply to comment #11)
> I found another way to blow up the Advanced button.
> 
> Steps:
> 1) Open the NewFile wizard
> 2) Clear 'Enter or select the parent folder:'
> 3) Click 'Advanced'
> 
> It used to work in 3.5.

Now fixed with this patch.
Comment 13 Szymon Brandys CLA 2010-05-14 08:22:17 EDT
I compared the fix with WizardNewFolderMainPage#createAdvancedControls line 212.

In WizardNewFolderMainPage, around line 203 always a non-null resource is returned. WizardNewFileCreationPage with the fix may return null, if the file name is empty.
I noticed that later the returned resource is used to find Path Variable Manager, so when null is returned, the result may be inappropriate.
Comment 14 Serge Beauchamp CLA 2010-05-18 06:07:38 EDT
(In reply to comment #13)
> I compared the fix with WizardNewFolderMainPage#createAdvancedControls line
> 212.
> 
> In WizardNewFolderMainPage, around line 203 always a non-null resource is
> returned. WizardNewFileCreationPage with the fix may return null, if the file
> name is empty.
> I noticed that later the returned resource is used to find Path Variable
> Manager, so when null is returned, the result may be inappropriate.

Hi, 

First, returning null is proper for that interface definition, and it is handled properly by the caller (see CreateLinkedResourceGroup#getPathVariableManager().

So with this new patch, the WizardNewFolderMainPage now behaves the same way (return null) when the string is empty - it used to return the IWorkspace as the IResource, which ends up being interpreted the same way as null - but null is less misleading.
Comment 15 Serge Beauchamp CLA 2010-05-18 06:08:40 EDT
Created attachment 168891 [details]
Final patch

Can you please review it?  Thanks.
Comment 16 Serge Beauchamp CLA 2010-05-18 08:53:34 EDT
Created attachment 168918 [details]
Patch

once more, with correction by Szymon
Comment 17 Szymon Brandys CLA 2010-05-18 09:11:31 EDT
Looks good. Just the copyright date should be updated.
Comment 18 Serge Beauchamp CLA 2010-05-18 10:40:00 EDT
Thanks, now fixed on head.
Comment 19 CDE Administration CLA 2010-05-25 16:05:59 EDT
<response_by> rewagner at 2010.05.25.14.54.00 </response_by>
I am having trouble with this button.  Whenever I click it, at first nothing happens, but when I resize the dialog window, the checkbox to Link to file in file system and the other stuff shows up.  But also if I click Advanced multiple times, it adds those things again and again.  Is this how its supposed to work?  I'm guessing no.  I'll attach a screen shot to show you what I see.

Thanks,
Ross
Comment 20 CDE Administration CLA 2010-05-25 16:06:02 EDT
Created attachment 169892 [details]
New_SQL_File_dialog_error.GIF
Comment 21 Serge Beauchamp CLA 2010-05-26 05:23:34 EDT
(In reply to comment #19)
> <response_by> rewagner at 2010.05.25.14.54.00 </response_by>
> I am having trouble with this button.  Whenever I click it, at first nothing
> happens, but when I resize the dialog window, the checkbox to Link to file in
> file system and the other stuff shows up.  But also if I click Advanced
> multiple times, it adds those things again and again.  Is this how its supposed
> to work?  I'm guessing no.  I'll attach a screen shot to show you what I see.
> 
> Thanks,
> Ross

I'm not able to reproduce this with the normal 'New File Wizard', but you are using the 'New SQL File' wizard.

What plugins do I need to install to be able to reproduce it?
Comment 22 Szymon Brandys CLA 2010-05-26 10:18:37 EDT
(In reply to comment #21)
> What plugins do I need to install to be able to reproduce it?

Data Tools from the Helios update site.
Comment 23 Szymon Brandys CLA 2010-05-26 10:24:18 EDT
Created attachment 169999 [details]
Potential cause
Comment 24 Szymon Brandys CLA 2010-05-26 10:35:41 EDT
I can see the same problem on the latest IBuild with Data Tools installed. It was introduced by the fix for bug 312888.
Comment 25 Szymon Brandys CLA 2010-05-26 10:47:57 EDT
I opened bug 314475 scheduled for 3.6 RC3 to address the problem.
Comment 26 CDE Administration CLA 2010-06-01 07:35:41 EDT
<response_by> martine marin at 2010.06.01.06.21.39 </response_by>
Pb fixed in build 20100529-2200 for the testcase mentionned File > New > Other >SQL Development >SQL File.
Closing
Thanks,
Martine
Comment 27 CDE Administration CLA 2010-06-03 03:25:46 EDT
<response_by> Katia Milekhina at 2010.06.03.02.22.24 </response_by>
Fixed for Russia in the build 20100602.

Thanks,
Katia