Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 318829 - [Wizards] User should be able to copy default project location in New Project wizard
Summary: [Wizards] User should be able to copy default project location in New Project...
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7   Edit
Assignee: Platform UI Triaged CLA
QA Contact: Prakash Rangaraj CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-04 18:58 EDT by kvn_m CLA
Modified: 2010-10-25 04:06 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kvn_m CLA 2010-07-04 18:58:45 EDT
Build Identifier: I20100608-0911

This issue relates to the New Project wizard (activated by "New" -> "General" -> "Project").  Specifically, the wizard classes in question are "org.eclipse.ui.dialogs.WizardNewProjectCreationPage", and its dependency "org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea".

The current implementation of selecting the "Use default location" button is to set the enabled state of the project location text control to false.  However, this state does not enable the user to see the entire path for very long pathnames and more importantly does not allow the user to copy the default location.  Therefore, for abnormally long pathnames on systems with limited screen area, the user is unable to determine the value of the default location path.

I have implemented a simple solution that fixes this bug - someone just needs to insert the code into the Eclipse code base.  Essentially, it recreates the project location text control upon every selection of the "Use default location" button, toggling between SWT.READ_ONLY text styles.  Here are the main code snippets, which I have verified to work:

// following code is to replace creation of text field
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Text textField = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);  // initialize to read-only
textField.setFont(parent.getFont());
textField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GridData gd = new GridData();
gd.horizontalAlignment = GridData.FILL;
gd.grabExcessHorizontalSpace = true;
textField.setLayoutData(gd);

// following code is modified from org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea
useDefaultsButton.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				boolean useDefaults = useDefaultsButton.getSelection();

				textField = recreateProjectTextField(textField, composite, useDefaults);
				String error = checkValidLocation();
				errorReporter.reportError(error,
						error != null && error.equals(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectLocationEmpty));
// !!! The following function need to be modified to remove reference to text field !!!
				setUserAreaEnabled(!useDefaults);
			}
});

// new function to recreate location text in its own composite when default button is toggled
Text recreateProjectTextField(Text text, Composite parent, boolean defaultSelected) {
    	int options = SWT.NONE;
    	String newTextContents;
    	if (defaultSelected) {
    		options = SWT.READ_ONLY;
    		userPath = text.getText();
    		newTextContents = TextProcessor.process(getDefaultPathDisplayString());
    	} else {
    		newTextContents = TextProcessor.process(userPath);
    	}
    	text.dispose();  // dispose the text field
    	textField = new Text(parent, SWT.SINGLE | SWT.BORDER | options);
	textField.setFont(parent.getFont());
	textField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	GridData gd = new GridData();
	gd.horizontalAlignment = GridData.FILL;
	gd.grabExcessHorizontalSpace = true;
	textField.setLayoutData(gd);
    	newText.setText(newTextContents);
    	parent.layout(); // text field won't reappear without this line
    	return newText;
}

Reproducible: Always
Comment 1 Prakash Rangaraj CLA 2010-07-29 02:49:03 EDT
kvn_m,

    Appreciate you looking into the code and suggesting a fix. Would you like to contribute a proper patch for the code? Check http://wiki.eclipse.org/Platform_UI/How_to_Contribute for more info on contributing patches.
Comment 2 Prakash Rangaraj CLA 2010-10-25 04:06:07 EDT
Had a look into this. No plans to fix this one.