mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
FileListControl adjustments
* Changed button bar layout to be et the end, rather some-what in the middle * Make SelectPathInputDialog remeber previously entered path * Make workspace selection dialog set proper initial selection, even if this widget runs without cdt context Change-Id: I04caec8c05b644977ec0dda622beefa2b8c9eba2 Signed-off-by: Alena Laskavaia <elaskavaia.cdt@gmail.com> Reviewed-on: https://git.eclipse.org/r/37032 Tested-by: Hudson CI
This commit is contained in:
parent
8c6bad3c80
commit
8bc2e3a81b
1 changed files with 51 additions and 10 deletions
|
@ -28,6 +28,7 @@ import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -37,6 +38,7 @@ import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.variables.IStringVariableManager;
|
import org.eclipse.core.variables.IStringVariableManager;
|
||||||
import org.eclipse.core.variables.VariablesPlugin;
|
import org.eclipse.core.variables.VariablesPlugin;
|
||||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||||
|
import org.eclipse.jface.dialogs.IDialogSettings;
|
||||||
import org.eclipse.jface.dialogs.IInputValidator;
|
import org.eclipse.jface.dialogs.IInputValidator;
|
||||||
import org.eclipse.jface.dialogs.InputDialog;
|
import org.eclipse.jface.dialogs.InputDialog;
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
|
@ -58,6 +60,7 @@ import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Button;
|
import org.eclipse.swt.widgets.Button;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.swt.widgets.DirectoryDialog;
|
import org.eclipse.swt.widgets.DirectoryDialog;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.FileDialog;
|
import org.eclipse.swt.widgets.FileDialog;
|
||||||
|
@ -151,6 +154,34 @@ public class FileListControl {
|
||||||
this.type = browseType;
|
this.type = browseType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getInitialValue(String initialValue) {
|
||||||
|
IDialogSettings dialogSettings = CUIPlugin.getDefault().getDialogSettings();
|
||||||
|
// restore file
|
||||||
|
String sfile = dialogSettings.get(FileListControl.class.getName());
|
||||||
|
if (sfile != null && (initialValue == null || initialValue.isEmpty())) {
|
||||||
|
return sfile;
|
||||||
|
}
|
||||||
|
return initialValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void saveWidgetValues() {
|
||||||
|
IDialogSettings dialogSettings = CUIPlugin.getDefault().getDialogSettings();
|
||||||
|
// save file name
|
||||||
|
dialogSettings.put(FileListControl.class.getName(), getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean close() {
|
||||||
|
saveWidgetValues();
|
||||||
|
return super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Control createContents(Composite parent) {
|
||||||
|
Control area = super.createContents(parent);
|
||||||
|
getText().setText(getInitialValue(getValue()));
|
||||||
|
return area;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns true if the value has been set by a browse dialog.
|
* Returns true if the value has been set by a browse dialog.
|
||||||
*/
|
*/
|
||||||
|
@ -217,17 +248,28 @@ public class FileListControl {
|
||||||
|
|
||||||
// Try to resolve the currentPathText
|
// Try to resolve the currentPathText
|
||||||
IVariableSubstitutor varSubs = new SupplierBasedCdtVariableSubstitutor(contextInfo, "", ""); //$NON-NLS-1$//$NON-NLS-2$
|
IVariableSubstitutor varSubs = new SupplierBasedCdtVariableSubstitutor(contextInfo, "", ""); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
String value = CdtVariableResolver.resolveToString(currentPathText, varSubs);
|
currentPathText = CdtVariableResolver.resolveToString(currentPathText,
|
||||||
if (!"".equals(value)) { //$NON-NLS-1$
|
varSubs);
|
||||||
IResource rs[] = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(URIUtil.toURI(value));
|
|
||||||
if (rs == null || rs.length == 0)
|
|
||||||
resource = ResourceLookup.selectFileForLocation(new Path(value), null);
|
|
||||||
else
|
|
||||||
resource = rs[0];
|
|
||||||
}
|
|
||||||
} catch (CdtVariableException e) {
|
} catch (CdtVariableException e) {
|
||||||
// It's OK not to find the project... carry on as before
|
// It's OK not to find the project... carry on as before
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
currentPathText = variableManager.performStringSubstitution(currentPathText,
|
||||||
|
false);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!currentPathText.isEmpty()) {
|
||||||
|
IResource rs[] = ResourcesPlugin.getWorkspace().getRoot()
|
||||||
|
.findContainersForLocationURI(URIUtil.toURI(currentPathText));
|
||||||
|
if (rs == null || rs.length == 0)
|
||||||
|
resource = ResourceLookup.selectFileForLocation(new Path(currentPathText),
|
||||||
|
null);
|
||||||
|
else
|
||||||
|
resource = rs[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create workspace folder/file selection dialog and
|
/* Create workspace folder/file selection dialog and
|
||||||
|
@ -593,8 +635,7 @@ public class FileListControl {
|
||||||
moveDownItem.setImage(IMG_MOVEDOWN);
|
moveDownItem.setImage(IMG_MOVEDOWN);
|
||||||
moveDownItem.setToolTipText(MOVEDOWN_STR);
|
moveDownItem.setToolTipText(MOVEDOWN_STR);
|
||||||
moveDownItem.addSelectionListener(getSelectionListener());
|
moveDownItem.addSelectionListener(getSelectionListener());
|
||||||
grid3 = new GridData(GridData.FILL_HORIZONTAL
|
grid3 = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END);
|
||||||
| GridData.HORIZONTAL_ALIGN_BEGINNING);
|
|
||||||
buttonPanel.setLayoutData(grid3);
|
buttonPanel.setLayoutData(grid3);
|
||||||
// list control
|
// list control
|
||||||
list = new ClipboardList(filePanel, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.MULTI);
|
list = new ClipboardList(filePanel, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.MULTI);
|
||||||
|
|
Loading…
Add table
Reference in a new issue