mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-04 15:45:25 +02:00
[176206] From preference page Remote Systems > Files, users can now add file transfer mode for filenames with no extension.
This commit is contained in:
parent
3a5af83306
commit
5c799eff71
3 changed files with 46 additions and 40 deletions
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
|
||||
* Copyright (c) 2002, 2007 IBM Corporation. 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
|
||||
|
@ -602,9 +602,8 @@ public class UniversalPreferencePage
|
|||
String name = dialog.getName();
|
||||
String extension = dialog.getExtension();
|
||||
|
||||
if (extension.length() > 0) {
|
||||
addResourceType(name, extension);
|
||||
}
|
||||
// add the resource type
|
||||
addResourceType(name, extension);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -632,19 +631,10 @@ public class UniversalPreferencePage
|
|||
* This is typically called after the extension dialog is shown to the user.
|
||||
*/
|
||||
public void addResourceType(String newName, String newExtension) {
|
||||
|
||||
// no extension is provided
|
||||
if (newExtension == null || newExtension.length() < 1) {
|
||||
// Note by DWD - this path is never taken because the dialog that gathers resource types checks for this condition
|
||||
SystemMessageFile mf = RSEUIPlugin.getPluginMessageFile();
|
||||
Shell shell = getControl().getShell();
|
||||
SystemMessage message = mf.getMessage(ISystemMessages.MSG_ERROR_EXTENSION_EMPTY);
|
||||
SystemMessageDialog.displayErrorMessage(shell, message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (newName == null || newName.length() < 1)
|
||||
if (newName == null || newName.length() < 1) {
|
||||
newName = "*"; //$NON-NLS-1$
|
||||
}
|
||||
else {
|
||||
|
||||
int index = newName.indexOf('*');
|
||||
|
@ -664,7 +654,15 @@ public class UniversalPreferencePage
|
|||
}
|
||||
|
||||
// Find the index at which to insert the new entry.
|
||||
String newFilename = (newName + "." + newExtension).toUpperCase(); //$NON-NLS-1$
|
||||
String newFileName = null;
|
||||
|
||||
if (newExtension == null || newExtension.length() < 1) {
|
||||
newFileName = newName.toUpperCase();
|
||||
}
|
||||
else {
|
||||
newFileName = (newName + "." + newExtension).toUpperCase(); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
IFileEditorMapping resourceType;
|
||||
boolean found = false;
|
||||
int i = 0;
|
||||
|
@ -673,7 +671,7 @@ public class UniversalPreferencePage
|
|||
|
||||
resourceType = (FileEditorMapping)(editorMappings.get(i));
|
||||
|
||||
int result = newFilename.compareTo(resourceType.getLabel().toUpperCase());
|
||||
int result = newFileName.compareTo(resourceType.getLabel().toUpperCase());
|
||||
|
||||
// if the type already exists
|
||||
if (result == 0) {
|
||||
|
|
|
@ -22,27 +22,24 @@ package org.eclipse.rse.subsystems.files.core.model;
|
|||
* An internal class. Clients must not instantiate or subclass it.
|
||||
*/
|
||||
|
||||
public class SystemFileTransferModeMapping
|
||||
implements ISystemFileTransferModeMapping, Cloneable {
|
||||
|
||||
|
||||
|
||||
public class SystemFileTransferModeMapping implements ISystemFileTransferModeMapping, Cloneable {
|
||||
|
||||
private String name;
|
||||
private String extension;
|
||||
private boolean isBinary = true;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for SystemFileTransferModeMapping
|
||||
* Constructor for SystemFileTransferModeMapping. The name is set to <code>*</code>.
|
||||
* @param extension the extension. Can be <code>null</code>.
|
||||
*/
|
||||
public SystemFileTransferModeMapping(String extension) {
|
||||
this("*", extension); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for SystemFileTransferModeMapping
|
||||
* Constructor for SystemFileTransferModeMapping.
|
||||
* @param name the name. If the name is <code>null</code> or if it is an empty string, it is set to <code>*</code>.
|
||||
* @param extension the extension. Can be <code>null</code>.
|
||||
*/
|
||||
public SystemFileTransferModeMapping(String name, String extension) {
|
||||
|
||||
|
@ -70,7 +67,13 @@ public class SystemFileTransferModeMapping
|
|||
* @see ISystemFileTransferModeMapping#getLabel()
|
||||
*/
|
||||
public String getLabel() {
|
||||
return (name + "." + extension); //$NON-NLS-1$
|
||||
|
||||
if (extension != null) {
|
||||
return (name + "." + extension); //$NON-NLS-1$
|
||||
}
|
||||
else {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -51,11 +51,7 @@ import org.eclipse.ui.XMLMemento;
|
|||
* An internal class. Clients must not instantiate or subclass it.
|
||||
*/
|
||||
|
||||
public class SystemFileTransferModeRegistry
|
||||
implements ISystemFileTransferModeRegistry, IPropertyListener {
|
||||
|
||||
|
||||
|
||||
public class SystemFileTransferModeRegistry implements ISystemFileTransferModeRegistry, IPropertyListener {
|
||||
|
||||
private static SystemFileTransferModeRegistry instance;
|
||||
|
||||
|
@ -312,20 +308,29 @@ public class SystemFileTransferModeRegistry
|
|||
//DY int extIndex = fileName.indexOf('.');
|
||||
int extIndex = fileName.lastIndexOf('.');
|
||||
|
||||
String name = null;
|
||||
String extension = null;
|
||||
|
||||
// if there is no extension
|
||||
if ((extIndex == -1) || (extIndex == (fileName.length() - 1))) {
|
||||
return null;
|
||||
name = fileName;
|
||||
}
|
||||
else {
|
||||
name = fileName.substring(0, extIndex);
|
||||
extension = fileName.substring(extIndex + 1);
|
||||
}
|
||||
|
||||
// check if the name and extension combination exists already
|
||||
SystemFileTransferModeMapping mapping = (SystemFileTransferModeMapping)(typeModeMappings.get(getMappingKey(new SystemFileTransferModeMapping(name, extension))));
|
||||
|
||||
// if not, check only for the extension
|
||||
if (mapping == null) {
|
||||
mapping = (SystemFileTransferModeMapping)(typeModeMappings.get(getMappingKey(new SystemFileTransferModeMapping(extension))));
|
||||
}
|
||||
|
||||
|
||||
String name = fileName.substring(0, extIndex);
|
||||
String extension = fileName.substring(extIndex + 1);
|
||||
|
||||
SystemFileTransferModeMapping mapping = (SystemFileTransferModeMapping)(typeModeMappings.get(getMappingKey(new SystemFileTransferModeMapping(extension))));
|
||||
|
||||
if (mapping == null)
|
||||
if (mapping == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
SystemFileTransferModeMapping fileMapping = new SystemFileTransferModeMapping(name, extension);
|
||||
|
|
Loading…
Add table
Reference in a new issue