mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 23:25:26 +02:00
Bug 148977: New Filter dialog should propose a default filter name on the 2nd page
https://bugs.eclipse.org/bugs/show_bug.cgi?id=148977
This commit is contained in:
parent
8896f1d83e
commit
e207aecd08
2 changed files with 44 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2002, 2010 IBM Corporation and others. All rights reserved.
|
||||
* This program and the accompanying materials are made available under the terms
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
|
@ -15,6 +15,7 @@
|
|||
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
|
||||
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
|
||||
* David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
|
||||
* David Dykstal (IBM) - [148977] New Filter dialog should propose a default filter name on the 2nd page
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.widgets;
|
||||
|
@ -862,4 +863,24 @@ public class SystemFileFilterStringEditPane
|
|||
return super.canSaveImplicitly();
|
||||
}
|
||||
}
|
||||
|
||||
public String getDefaultFilterName()
|
||||
{
|
||||
String defaultFilterName = ""; //$NON-NLS-1$
|
||||
if (folderCombo != null) {
|
||||
String folderName = folderCombo.getText().trim();
|
||||
if (folderName.length() > 0) {
|
||||
String separator = inputSubsystemConfiguration.getSeparator();
|
||||
if (folderName.endsWith(separator)) {
|
||||
folderName = folderName.substring(0, folderName.length() - separator.length());
|
||||
}
|
||||
int p = folderName.lastIndexOf(separator);
|
||||
p += separator.length();
|
||||
if (p < folderName.length()) {
|
||||
defaultFilterName = folderName.substring(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
return defaultFilterName;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2002, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -16,6 +16,7 @@
|
|||
* David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
|
||||
* David McKnight (IBM) - [226948] [api][regression] SystemNewFilterWizard.createNamePage() is no longer available
|
||||
* David McKnight (IBM) - [249482] Duplicate Filters can be created if changing the filter pool
|
||||
* David Dykstal (IBM) - [148977] New Filter dialog should propose a default filter name on the 2nd page
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.ui.filters.dialogs;
|
||||
|
@ -160,8 +161,8 @@ public class SystemNewFilterWizardNamePage
|
|||
|
||||
SystemWidgetHelpers.createVerbiage(composite_prompts, configurator.getPage2NameVerbiage(), nbrColumns, false, 200);
|
||||
nameText = SystemWidgetHelpers.createLabeledTextField(composite_prompts, null, configurator.getPage2NamePromptLabel(), configurator.getPage2NamePromptTooltip());
|
||||
|
||||
addSeparatorLine(composite_prompts, nbrColumns);
|
||||
|
||||
addSeparatorLine(composite_prompts, nbrColumns);
|
||||
addFillerLine(composite_prompts, nbrColumns);
|
||||
|
||||
// allow the user to create this filter uniquely for this connection, which means putting it in a
|
||||
|
@ -537,10 +538,26 @@ public class SystemNewFilterWizardNamePage
|
|||
if (!userEditedName && (nameText!=null))
|
||||
{
|
||||
String defaultName = ((SystemNewFilterWizard)getWizard()).getDefaultFilterName();
|
||||
if (defaultName != null)
|
||||
{
|
||||
if (defaultName != null) {
|
||||
if (defaultName.length() > 0) {
|
||||
if (nameValidator != null) {
|
||||
String nameProposal = defaultName;
|
||||
boolean invalid = true;
|
||||
int times = 0;
|
||||
while (invalid && times < 20) { // try only 20 times
|
||||
if (nameValidator.validate(nameProposal) != null) {
|
||||
times++;
|
||||
nameProposal = defaultName + " " + times; //$NON-NLS-1$
|
||||
} else {
|
||||
invalid = false;
|
||||
defaultName = nameProposal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ignoreChanges = true;
|
||||
nameText.setText(defaultName);
|
||||
nameText.selectAll();
|
||||
ignoreChanges = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue