mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 13:05:22 +02:00
[203114] Usability improvements for file transfer mode prefs
This commit is contained in:
parent
c5349f903c
commit
a1e17ba244
1 changed files with 176 additions and 154 deletions
|
@ -14,6 +14,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
|
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
|
||||||
* David McKnight (IBM) - [207178] changing list APIs for file service and subsystems
|
* David McKnight (IBM) - [207178] changing list APIs for file service and subsystems
|
||||||
* David McKnight (IBM) - [208951] no longer used editor registry for file type associations
|
* David McKnight (IBM) - [208951] no longer used editor registry for file type associations
|
||||||
|
* David McKnight (IBM) - [203114] Usability improvements for file transfer mode prefs
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.files.ui.propertypages;
|
package org.eclipse.rse.internal.files.ui.propertypages;
|
||||||
|
@ -26,11 +27,19 @@ import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.jface.viewers.CellEditor;
|
||||||
import org.eclipse.jface.viewers.ColumnLayoutData;
|
import org.eclipse.jface.viewers.ColumnLayoutData;
|
||||||
import org.eclipse.jface.viewers.ColumnPixelData;
|
import org.eclipse.jface.viewers.ColumnPixelData;
|
||||||
import org.eclipse.jface.viewers.ColumnWeightData;
|
import org.eclipse.jface.viewers.ColumnWeightData;
|
||||||
|
import org.eclipse.jface.viewers.ComboBoxCellEditor;
|
||||||
|
import org.eclipse.jface.viewers.DecorationOverlayIcon;
|
||||||
|
import org.eclipse.jface.viewers.ICellModifier;
|
||||||
import org.eclipse.jface.viewers.TableLayout;
|
import org.eclipse.jface.viewers.TableLayout;
|
||||||
|
import org.eclipse.jface.viewers.TableViewer;
|
||||||
|
import org.eclipse.jface.viewers.TextCellEditor;
|
||||||
import org.eclipse.jface.window.Window;
|
import org.eclipse.jface.window.Window;
|
||||||
|
import org.eclipse.rse.internal.files.ui.Activator;
|
||||||
import org.eclipse.rse.internal.files.ui.FileResources;
|
import org.eclipse.rse.internal.files.ui.FileResources;
|
||||||
import org.eclipse.rse.internal.subsystems.files.core.ISystemFilePreferencesConstants;
|
import org.eclipse.rse.internal.subsystems.files.core.ISystemFilePreferencesConstants;
|
||||||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||||
|
@ -64,9 +73,6 @@ import org.eclipse.swt.widgets.Table;
|
||||||
import org.eclipse.swt.widgets.TableColumn;
|
import org.eclipse.swt.widgets.TableColumn;
|
||||||
import org.eclipse.swt.widgets.TableItem;
|
import org.eclipse.swt.widgets.TableItem;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
import org.eclipse.ui.IEditorRegistry;
|
|
||||||
import org.eclipse.ui.IFileEditorMapping;
|
|
||||||
import org.eclipse.ui.IPropertyListener;
|
|
||||||
import org.eclipse.ui.ISharedImages;
|
import org.eclipse.ui.ISharedImages;
|
||||||
import org.eclipse.ui.IWorkbench;
|
import org.eclipse.ui.IWorkbench;
|
||||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||||
|
@ -81,7 +87,7 @@ import org.eclipse.ui.internal.dialogs.FileExtensionDialog;
|
||||||
*/
|
*/
|
||||||
public class UniversalPreferencePage
|
public class UniversalPreferencePage
|
||||||
extends FieldEditorPreferencePage
|
extends FieldEditorPreferencePage
|
||||||
implements IWorkbenchPreferencePage, Listener, IPropertyListener
|
implements IWorkbenchPreferencePage, Listener, ICellModifier
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,8 +96,7 @@ public class UniversalPreferencePage
|
||||||
protected Table resourceTypeTable;
|
protected Table resourceTypeTable;
|
||||||
protected Button addResourceTypeButton;
|
protected Button addResourceTypeButton;
|
||||||
protected Button removeResourceTypeButton;
|
protected Button removeResourceTypeButton;
|
||||||
protected Button binaryButton;
|
|
||||||
protected Button textButton;
|
|
||||||
protected Button doSuperTransferButton;
|
protected Button doSuperTransferButton;
|
||||||
|
|
||||||
protected Button defaultBinaryButton;
|
protected Button defaultBinaryButton;
|
||||||
|
@ -108,6 +113,11 @@ public class UniversalPreferencePage
|
||||||
protected Text downloadBufferSize;
|
protected Text downloadBufferSize;
|
||||||
protected Text uploadBufferSize;
|
protected Text uploadBufferSize;
|
||||||
|
|
||||||
|
protected Image fileImage;
|
||||||
|
protected Image binaryFileImage;
|
||||||
|
|
||||||
|
protected String[] columnProperties = { "P_ICON", "P_TYPE", "P_CONTENT" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
|
@ -129,7 +139,6 @@ public class UniversalPreferencePage
|
||||||
protected void createFieldEditors() {
|
protected void createFieldEditors() {
|
||||||
|
|
||||||
modeRegistry = SystemFileTransferModeRegistry.getInstance();
|
modeRegistry = SystemFileTransferModeRegistry.getInstance();
|
||||||
//editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
|
|
||||||
|
|
||||||
modeMappings = new ArrayList();
|
modeMappings = new ArrayList();
|
||||||
imagesToDispose = new ArrayList();
|
imagesToDispose = new ArrayList();
|
||||||
|
@ -200,36 +209,7 @@ public class UniversalPreferencePage
|
||||||
removeResourceTypeButton.setLayoutData(data);
|
removeResourceTypeButton.setLayoutData(data);
|
||||||
|
|
||||||
|
|
||||||
// transfer mode
|
// default file transfer mode
|
||||||
Group modeGroup = new Group(groupComponent, SWT.SHADOW_ETCHED_IN);
|
|
||||||
modeGroup.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_LABEL);
|
|
||||||
modeGroup.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TOOLTIP);
|
|
||||||
|
|
||||||
layout = new GridLayout();
|
|
||||||
layout.numColumns = 1;
|
|
||||||
//layout.verticalSpacing = 10;
|
|
||||||
layout.horizontalSpacing = 10;
|
|
||||||
modeGroup.setLayout(layout);
|
|
||||||
data = new GridData(GridData.FILL_BOTH);
|
|
||||||
data.horizontalSpan = 2;
|
|
||||||
data.widthHint = 100;
|
|
||||||
data.grabExcessHorizontalSpace = true;
|
|
||||||
modeGroup.setLayoutData(data);
|
|
||||||
|
|
||||||
// add the binary radio button
|
|
||||||
binaryButton = new Button(modeGroup, SWT.RADIO);
|
|
||||||
binaryButton.addListener(SWT.Selection, this);
|
|
||||||
binaryButton.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL);
|
|
||||||
binaryButton.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_TOOLTIP);
|
|
||||||
|
|
||||||
// add the text radio button
|
|
||||||
textButton = new Button(modeGroup, SWT.RADIO);
|
|
||||||
textButton.addListener(SWT.Selection, this);
|
|
||||||
textButton.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL);
|
|
||||||
textButton.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_TOOLTIP);
|
|
||||||
|
|
||||||
|
|
||||||
// default file transfer mode
|
|
||||||
Group defaultModeGroup = new Group(groupComponent, SWT.SHADOW_ETCHED_IN);
|
Group defaultModeGroup = new Group(groupComponent, SWT.SHADOW_ETCHED_IN);
|
||||||
defaultModeGroup.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_DEFAULT_MODE_LABEL);
|
defaultModeGroup.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_DEFAULT_MODE_LABEL);
|
||||||
defaultModeGroup.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_DEFAULT_MODE_TOOLTIP);
|
defaultModeGroup.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_DEFAULT_MODE_TOOLTIP);
|
||||||
|
@ -239,7 +219,7 @@ public class UniversalPreferencePage
|
||||||
//layout.verticalSpacing = 10;
|
//layout.verticalSpacing = 10;
|
||||||
layout.horizontalSpacing = 10;
|
layout.horizontalSpacing = 10;
|
||||||
defaultModeGroup.setLayout(layout);
|
defaultModeGroup.setLayout(layout);
|
||||||
data = new GridData(GridData.FILL_BOTH);
|
data = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
data.horizontalSpan = 2;
|
data.horizontalSpan = 2;
|
||||||
data.widthHint = 100;
|
data.widthHint = 100;
|
||||||
data.grabExcessHorizontalSpace = true;
|
data.grabExcessHorizontalSpace = true;
|
||||||
|
@ -384,7 +364,6 @@ public class UniversalPreferencePage
|
||||||
resourceTypeTable.setFocus();
|
resourceTypeTable.setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
fillMode();
|
|
||||||
updateEnabledState();
|
updateEnabledState();
|
||||||
|
|
||||||
(new Mnemonics()).setOnPreferencePage(true).setMnemonics(parent);
|
(new Mnemonics()).setOnPreferencePage(true).setMnemonics(parent);
|
||||||
|
@ -411,24 +390,52 @@ public class UniversalPreferencePage
|
||||||
*/
|
*/
|
||||||
protected void fillResourceTypeTable() {
|
protected void fillResourceTypeTable() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Setup the columns (icon, type)
|
// Setup the columns (icon, type)
|
||||||
TableLayout tableLayout = new TableLayout();
|
TableLayout tableLayout = new TableLayout();
|
||||||
resourceTypeTable.setLayout(tableLayout);
|
resourceTypeTable.setLayout(tableLayout);
|
||||||
resourceTypeTable.setHeaderVisible(true);
|
resourceTypeTable.setHeaderVisible(true);
|
||||||
|
resourceTypeTable.setLinesVisible(true);
|
||||||
|
|
||||||
|
// cell modifier stuff so that we can change the transfer
|
||||||
|
// mode directly from the cell
|
||||||
|
TableViewer tableViewer = new TableViewer(resourceTypeTable);
|
||||||
|
tableViewer.setCellModifier(this);
|
||||||
|
|
||||||
ColumnLayoutData layoutData = new ColumnPixelData(20, false);
|
ColumnLayoutData layoutData = new ColumnPixelData(20, false);
|
||||||
tableLayout.addColumnData(layoutData);
|
tableLayout.addColumnData(layoutData);
|
||||||
TableColumn tableCol = new TableColumn(resourceTypeTable, SWT.NONE);
|
TableColumn tableCol = new TableColumn(resourceTypeTable, SWT.NONE, 0);
|
||||||
tableCol.setResizable(false);
|
tableCol.setResizable(false);
|
||||||
tableCol.setText(""); //$NON-NLS-1$
|
tableCol.setText(""); //$NON-NLS-1$
|
||||||
|
|
||||||
layoutData = new ColumnWeightData(40, false);
|
layoutData = new ColumnWeightData(40, true);
|
||||||
tableLayout.addColumnData(layoutData);
|
tableLayout.addColumnData(layoutData);
|
||||||
tableCol = new TableColumn(resourceTypeTable, SWT.NONE);
|
tableCol = new TableColumn(resourceTypeTable, SWT.NONE, 1);
|
||||||
tableCol.setResizable(false);
|
tableCol.setResizable(true);
|
||||||
tableCol.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_TABLECOL_LABEL);
|
tableCol.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_TABLECOL_LABEL);
|
||||||
|
|
||||||
ISystemFileTransferModeMapping[] mappings = modeRegistry.getModeMappings();
|
layoutData = new ColumnWeightData(60, true);
|
||||||
|
tableLayout.addColumnData(layoutData);
|
||||||
|
tableCol = new TableColumn(resourceTypeTable, SWT.NONE, 2);
|
||||||
|
tableCol.setResizable(true);
|
||||||
|
tableCol.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_LABEL);
|
||||||
|
|
||||||
|
|
||||||
|
String[] contentTypes = new String[2];
|
||||||
|
contentTypes[0] = FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL;
|
||||||
|
contentTypes[1] = FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL;
|
||||||
|
|
||||||
|
CellEditor editors[] = new CellEditor[3];
|
||||||
|
editors[0] = null;
|
||||||
|
editors[1] = new TextCellEditor(resourceTypeTable);
|
||||||
|
editors[2] = new ComboBoxCellEditor(resourceTypeTable, contentTypes, SWT.READ_ONLY);
|
||||||
|
|
||||||
|
|
||||||
|
tableViewer.setColumnProperties(columnProperties);
|
||||||
|
tableViewer.setCellEditors(editors);
|
||||||
|
|
||||||
|
ISystemFileTransferModeMapping[] mappings = getModeMappings();
|
||||||
|
|
||||||
for (int i = 0; i < mappings.length; i++) {
|
for (int i = 0; i < mappings.length; i++) {
|
||||||
newResourceTableItem(mappings[i], i, false);
|
newResourceTableItem(mappings[i], i, false);
|
||||||
|
@ -445,6 +452,19 @@ public class UniversalPreferencePage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ISystemFileTransferModeMapping[] getModeMappings()
|
||||||
|
{
|
||||||
|
// cloning the registry ones so that we can restore later
|
||||||
|
ISystemFileTransferModeMapping[] mappings = modeRegistry.getModeMappings();
|
||||||
|
|
||||||
|
ISystemFileTransferModeMapping[] clonedMappings = new ISystemFileTransferModeMapping[mappings.length];
|
||||||
|
for (int i = 0; i < mappings.length; i++){
|
||||||
|
SystemFileTransferModeMapping mapping = (SystemFileTransferModeMapping)mappings[i];
|
||||||
|
clonedMappings[i] = (ISystemFileTransferModeMapping)mapping.clone();
|
||||||
|
}
|
||||||
|
return clonedMappings;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used during reset defaults
|
* Used during reset defaults
|
||||||
*/
|
*/
|
||||||
|
@ -455,7 +475,7 @@ public class UniversalPreferencePage
|
||||||
resourceTypeTable.setRedraw(false);
|
resourceTypeTable.setRedraw(false);
|
||||||
resourceTypeTable.removeAll();
|
resourceTypeTable.removeAll();
|
||||||
|
|
||||||
ISystemFileTransferModeMapping[] mappings = modeRegistry.getModeMappings();
|
ISystemFileTransferModeMapping[] mappings = getModeMappings();
|
||||||
for (int i = 0; i < mappings.length; i++)
|
for (int i = 0; i < mappings.length; i++)
|
||||||
{
|
{
|
||||||
newResourceTableItem(mappings[i], i, false);
|
newResourceTableItem(mappings[i], i, false);
|
||||||
|
@ -472,7 +492,6 @@ public class UniversalPreferencePage
|
||||||
resourceTypeTable.setFocus();
|
resourceTypeTable.setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
fillMode();
|
|
||||||
updateEnabledState();
|
updateEnabledState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,11 +509,32 @@ public class UniversalPreferencePage
|
||||||
uploadBufferSize.setText(ISystemFilePreferencesConstants.DEFAULT_DOWNLOAD_BUFFER_SIZE + ""); //$NON-NLS-1$
|
uploadBufferSize.setText(ISystemFilePreferencesConstants.DEFAULT_DOWNLOAD_BUFFER_SIZE + ""); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
private Image getImageDescriptor(ISystemFileTransferModeMapping mapping)
|
|
||||||
|
private Image applyBinaryDecoration(Image source) {
|
||||||
|
ImageDescriptor binaryOverlay = Activator.getImageDescriptor("/icons/full/ovr16/binary_ovr.gif");
|
||||||
|
DecorationOverlayIcon icon = new DecorationOverlayIcon(source, binaryOverlay, 3);
|
||||||
|
return icon.createImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Image getImageFor(ISystemFileTransferModeMapping mapping)
|
||||||
{
|
{
|
||||||
//String extension = mapping.getExtension();
|
if (fileImage == null){
|
||||||
|
fileImage = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJ_FILE).createImage();
|
||||||
|
}
|
||||||
|
if (binaryFileImage == null)
|
||||||
|
{
|
||||||
|
binaryFileImage = applyBinaryDecoration(fileImage);
|
||||||
|
}
|
||||||
|
|
||||||
// for now just always using the same image
|
// for now just always using the same image
|
||||||
return WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJ_FILE).createImage();
|
if (mapping.isBinary())
|
||||||
|
{
|
||||||
|
return binaryFileImage;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return fileImage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -505,15 +545,19 @@ public class UniversalPreferencePage
|
||||||
|
|
||||||
modeMappings.add(index, mapping);
|
modeMappings.add(index, mapping);
|
||||||
|
|
||||||
Image image = getImageDescriptor(mapping);
|
Image image = getImageFor(mapping);
|
||||||
|
|
||||||
if (image != null)
|
if (image != null)
|
||||||
imagesToDispose.add(image);
|
imagesToDispose.add(image);
|
||||||
|
|
||||||
TableItem item = new TableItem(resourceTypeTable, SWT.NULL, index);
|
TableItem item = new TableItem(resourceTypeTable, SWT.NULL, index);
|
||||||
|
item.setData(mapping);
|
||||||
item.setImage(0, image);
|
item.setImage(0, image);
|
||||||
item.setText(1, mapping.getLabel());
|
item.setText(1, mapping.getLabel());
|
||||||
|
|
||||||
|
boolean binary = mapping.isBinary();
|
||||||
|
item.setText(2, binary ? FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL : FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL);
|
||||||
|
|
||||||
|
|
||||||
if (selected)
|
if (selected)
|
||||||
resourceTypeTable.setSelection(index);
|
resourceTypeTable.setSelection(index);
|
||||||
|
|
||||||
|
@ -547,21 +591,12 @@ public class UniversalPreferencePage
|
||||||
*/
|
*/
|
||||||
public void handleEvent(Event event) {
|
public void handleEvent(Event event) {
|
||||||
|
|
||||||
if ((event.widget == resourceTypeTable) && ((event.type == SWT.Selection) || (event.type == SWT.DefaultSelection))) {
|
|
||||||
fillMode();
|
|
||||||
}
|
|
||||||
if ((event.widget == addResourceTypeButton) && (event.type == SWT.Selection)) {
|
if ((event.widget == addResourceTypeButton) && (event.type == SWT.Selection)) {
|
||||||
promptForResourceType();
|
promptForResourceType();
|
||||||
}
|
}
|
||||||
else if ((event.widget == removeResourceTypeButton) && (event.type == SWT.Selection)) {
|
else if ((event.widget == removeResourceTypeButton) && (event.type == SWT.Selection)) {
|
||||||
removeSelectedResourceType();
|
removeSelectedResourceType();
|
||||||
}
|
}
|
||||||
else if ((event.widget == binaryButton) && (event.type == SWT.Selection)) {
|
|
||||||
binaryButtonSelected();
|
|
||||||
}
|
|
||||||
else if ((event.widget == textButton) && (event.type == SWT.Selection)) {
|
|
||||||
textButtonSelected();
|
|
||||||
}
|
|
||||||
else if ((event.widget == doSuperTransferButton) && (event.type == SWT.Selection))
|
else if ((event.widget == doSuperTransferButton) && (event.type == SWT.Selection))
|
||||||
{
|
{
|
||||||
doSuperTransferButtonSelected();
|
doSuperTransferButtonSelected();
|
||||||
|
@ -570,28 +605,6 @@ public class UniversalPreferencePage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fill the mode widgets
|
|
||||||
*/
|
|
||||||
public void fillMode() {
|
|
||||||
|
|
||||||
int index = resourceTypeTable.getSelectionIndex();
|
|
||||||
SystemFileTransferModeMapping modeMapping = getModeMapping(index);
|
|
||||||
|
|
||||||
if (modeMapping !=null)
|
|
||||||
{
|
|
||||||
if (modeMapping.isBinary()) {
|
|
||||||
binaryButton.setSelection(true);
|
|
||||||
textButton.setSelection(false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
binaryButton.setSelection(false);
|
|
||||||
textButton.setSelection(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prompt for file type
|
* Prompt for file type
|
||||||
*/
|
*/
|
||||||
|
@ -700,41 +713,21 @@ public class UniversalPreferencePage
|
||||||
|
|
||||||
// Create the new type and insert it
|
// Create the new type and insert it
|
||||||
mapping = new SystemFileTransferModeMapping(newName,newExtension);
|
mapping = new SystemFileTransferModeMapping(newName,newExtension);
|
||||||
|
|
||||||
|
// default to default
|
||||||
|
if (defaultBinaryButton.getSelection()) {
|
||||||
|
mapping.setAsBinary();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mapping.setAsText();
|
||||||
|
}
|
||||||
|
|
||||||
newResourceTableItem(mapping, i, true);
|
newResourceTableItem(mapping, i, true);
|
||||||
|
|
||||||
resourceTypeTable.setFocus();
|
resourceTypeTable.setFocus();
|
||||||
fillMode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper method to configure things when binary mode radio button
|
|
||||||
* is selected
|
|
||||||
*/
|
|
||||||
private void binaryButtonSelected() {
|
|
||||||
//binaryButton.setSelection(true); // causes hang on linux
|
|
||||||
//textButton.setSelection(false);
|
|
||||||
|
|
||||||
int index = resourceTypeTable.getSelectionIndex();
|
|
||||||
SystemFileTransferModeMapping modeMapping = getModeMapping(index);
|
|
||||||
if (modeMapping != null)
|
|
||||||
modeMapping.setAsBinary();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper method to configure things when text mode is selected
|
|
||||||
*/
|
|
||||||
private void textButtonSelected() {
|
|
||||||
// textButton.setSelection(true); // causes hang on linux
|
|
||||||
// binaryButton.setSelection(false);
|
|
||||||
|
|
||||||
int index = resourceTypeTable.getSelectionIndex();
|
|
||||||
SystemFileTransferModeMapping modeMapping = getModeMapping(index);
|
|
||||||
if (modeMapping != null)
|
|
||||||
modeMapping.setAsText();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doSuperTransferButtonSelected()
|
private void doSuperTransferButtonSelected()
|
||||||
{
|
{
|
||||||
if (doSuperTransferButton.getSelection())
|
if (doSuperTransferButton.getSelection())
|
||||||
|
@ -747,16 +740,6 @@ public class UniversalPreferencePage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the mode mapping given the editor mapping selected
|
|
||||||
*/
|
|
||||||
private SystemFileTransferModeMapping getModeMapping(int index) {
|
|
||||||
|
|
||||||
if (index >=0 && index < modeMappings.size())
|
|
||||||
return (SystemFileTransferModeMapping)(modeMappings.get(index));
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -927,38 +910,77 @@ public class UniversalPreferencePage
|
||||||
*/
|
*/
|
||||||
private static void savePreferenceStore()
|
private static void savePreferenceStore()
|
||||||
{
|
{
|
||||||
/* DY: This was causing ClassCastException in 2.0
|
|
||||||
* getPreferenceStore retutrns CompatibilityPreferenceStore now
|
|
||||||
PreferenceStore store = (PreferenceStore)RSEUIPlugin.getDefault().getPreferenceStore();
|
|
||||||
try {
|
|
||||||
store.save();
|
|
||||||
} catch (Exception exc)
|
|
||||||
{
|
|
||||||
System.out.println("Error saving preferences: " + exc.getMessage() + ": " + exc.getClass().getName());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// ok, a couple hours of research leads me to believe this is now the new
|
|
||||||
// thing to do... phil
|
|
||||||
RSEUIPlugin.getDefault().savePluginPreferences();
|
RSEUIPlugin.getDefault().savePluginPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public boolean canModify(Object element, String property) {
|
||||||
* Listen for changes to the Editor Registry content.
|
if (property.equals(columnProperties[2]))
|
||||||
* Update our registry by changing the hashmap and saving the new
|
{
|
||||||
* mappings on disk.
|
return true;
|
||||||
* @see IPropertyListener#propertyChanged(Object, int)
|
}
|
||||||
*/
|
else if (property.equals(columnProperties[1]))
|
||||||
public void propertyChanged(Object source, int propId) {
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ((source instanceof IEditorRegistry) && (propId == IEditorRegistry.PROP_CONTENTS)) {
|
public Object getValue(Object element, String property) {
|
||||||
|
SystemFileTransferModeMapping mapping = (SystemFileTransferModeMapping)element;
|
||||||
|
if (property.equals(columnProperties[2])){
|
||||||
|
return mapping.isBinary() ? new Integer(0) : new Integer(1);
|
||||||
|
}
|
||||||
|
else if (property.equals(columnProperties[1])){
|
||||||
|
return mapping.getLabel();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// the OK button was pressed, and we need to incorporate changes from the File Editors preference page
|
public void modify(Object element, String property, Object value)
|
||||||
IEditorRegistry registry = (IEditorRegistry)source;
|
{
|
||||||
|
TableItem item = (TableItem)element;
|
||||||
|
SystemFileTransferModeMapping mapping = (SystemFileTransferModeMapping)item.getData();
|
||||||
|
if (mapping != null)
|
||||||
|
{
|
||||||
|
if (property.equals(columnProperties[2])){
|
||||||
|
|
||||||
IFileEditorMapping[] editorMappingArray = registry.getFileEditorMappings();
|
if (value instanceof Integer)
|
||||||
|
{
|
||||||
|
int index = ((Integer)value).intValue();
|
||||||
|
if (index == 0)
|
||||||
|
{
|
||||||
|
mapping.setAsBinary();
|
||||||
|
item.setText(2, FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL);
|
||||||
|
item.setImage(getImageFor(mapping));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mapping.setAsText();
|
||||||
|
item.setText(2, FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL);
|
||||||
|
item.setImage(getImageFor(mapping));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < editorMappingArray.length; i++) {
|
}
|
||||||
|
else if (property.equals(columnProperties[1])){
|
||||||
|
if (value instanceof String)
|
||||||
|
{
|
||||||
|
String nameExtension = (String)value;
|
||||||
|
|
||||||
|
int dotIndex = nameExtension.lastIndexOf('.');
|
||||||
|
if (dotIndex != -1)
|
||||||
|
{
|
||||||
|
String name = nameExtension.substring(0, dotIndex);
|
||||||
|
|
||||||
|
String ext = nameExtension.substring(dotIndex + 1);
|
||||||
|
|
||||||
|
mapping.setName(name);
|
||||||
|
mapping.setExtension(ext);
|
||||||
|
item.setText(1, nameExtension);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue