View | Details | Raw Unified | Return to bug 203114 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/rse/internal/files/ui/propertypages/UniversalPreferencePage.java (-154 / +176 lines)
Lines 14-19 Link Here
14
 * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
14
 * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
15
 * David McKnight   (IBM)        - [207178] changing list APIs for file service and subsystems
15
 * David McKnight   (IBM)        - [207178] changing list APIs for file service and subsystems
16
 * David McKnight   (IBM)        - [208951] no longer used editor registry for file type associations
16
 * David McKnight   (IBM)        - [208951] no longer used editor registry for file type associations
17
 * David McKnight   (IBM)        - [203114] Usability improvements for file transfer mode prefs
17
 ********************************************************************************/
18
 ********************************************************************************/
18
19
19
package org.eclipse.rse.internal.files.ui.propertypages;
20
package org.eclipse.rse.internal.files.ui.propertypages;
Lines 26-36 Link Here
26
import org.eclipse.jface.preference.BooleanFieldEditor;
27
import org.eclipse.jface.preference.BooleanFieldEditor;
27
import org.eclipse.jface.preference.FieldEditorPreferencePage;
28
import org.eclipse.jface.preference.FieldEditorPreferencePage;
28
import org.eclipse.jface.preference.IPreferenceStore;
29
import org.eclipse.jface.preference.IPreferenceStore;
30
import org.eclipse.jface.resource.ImageDescriptor;
31
import org.eclipse.jface.viewers.CellEditor;
29
import org.eclipse.jface.viewers.ColumnLayoutData;
32
import org.eclipse.jface.viewers.ColumnLayoutData;
30
import org.eclipse.jface.viewers.ColumnPixelData;
33
import org.eclipse.jface.viewers.ColumnPixelData;
31
import org.eclipse.jface.viewers.ColumnWeightData;
34
import org.eclipse.jface.viewers.ColumnWeightData;
35
import org.eclipse.jface.viewers.ComboBoxCellEditor;
36
import org.eclipse.jface.viewers.DecorationOverlayIcon;
37
import org.eclipse.jface.viewers.ICellModifier;
32
import org.eclipse.jface.viewers.TableLayout;
38
import org.eclipse.jface.viewers.TableLayout;
39
import org.eclipse.jface.viewers.TableViewer;
40
import org.eclipse.jface.viewers.TextCellEditor;
33
import org.eclipse.jface.window.Window;
41
import org.eclipse.jface.window.Window;
42
import org.eclipse.rse.internal.files.ui.Activator;
34
import org.eclipse.rse.internal.files.ui.FileResources;
43
import org.eclipse.rse.internal.files.ui.FileResources;
35
import org.eclipse.rse.internal.subsystems.files.core.ISystemFilePreferencesConstants;
44
import org.eclipse.rse.internal.subsystems.files.core.ISystemFilePreferencesConstants;
36
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
45
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
Lines 64-72 Link Here
64
import org.eclipse.swt.widgets.TableColumn;
73
import org.eclipse.swt.widgets.TableColumn;
65
import org.eclipse.swt.widgets.TableItem;
74
import org.eclipse.swt.widgets.TableItem;
66
import org.eclipse.swt.widgets.Text;
75
import org.eclipse.swt.widgets.Text;
67
import org.eclipse.ui.IEditorRegistry;
68
import org.eclipse.ui.IFileEditorMapping;
69
import org.eclipse.ui.IPropertyListener;
70
import org.eclipse.ui.ISharedImages;
76
import org.eclipse.ui.ISharedImages;
71
import org.eclipse.ui.IWorkbench;
77
import org.eclipse.ui.IWorkbench;
72
import org.eclipse.ui.IWorkbenchPreferencePage;
78
import org.eclipse.ui.IWorkbenchPreferencePage;
Lines 81-87 Link Here
81
 */
87
 */
82
public class UniversalPreferencePage 
88
public class UniversalPreferencePage 
83
       extends FieldEditorPreferencePage 
89
       extends FieldEditorPreferencePage 
84
       implements IWorkbenchPreferencePage, Listener, IPropertyListener
90
       implements IWorkbenchPreferencePage, Listener, ICellModifier
85
{
91
{
86
92
87
93
Lines 90-97 Link Here
90
	protected Table resourceTypeTable;
96
	protected Table resourceTypeTable;
91
	protected Button addResourceTypeButton;
97
	protected Button addResourceTypeButton;
92
	protected Button removeResourceTypeButton;
98
	protected Button removeResourceTypeButton;
93
	protected Button binaryButton;
99
94
	protected Button textButton;
95
	protected Button doSuperTransferButton;
100
	protected Button doSuperTransferButton;
96
	
101
	
97
	protected Button defaultBinaryButton;
102
	protected Button defaultBinaryButton;
Lines 108-113 Link Here
108
	protected Text downloadBufferSize;
113
	protected Text downloadBufferSize;
109
	protected Text uploadBufferSize;
114
	protected Text uploadBufferSize;
110
	
115
	
116
	protected Image fileImage;
117
	protected Image binaryFileImage;
118
	
119
	protected String[] columnProperties = { "P_ICON", "P_TYPE", "P_CONTENT" };
120
	
111
	/**
121
	/**
112
	 * Constructor
122
	 * Constructor
113
	 */
123
	 */
Lines 129-135 Link Here
129
	protected void createFieldEditors() {
139
	protected void createFieldEditors() {
130
		
140
		
131
		modeRegistry = SystemFileTransferModeRegistry.getInstance();
141
		modeRegistry = SystemFileTransferModeRegistry.getInstance();
132
		//editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
133
		
142
		
134
		modeMappings = new ArrayList();
143
		modeMappings = new ArrayList();
135
		imagesToDispose = new ArrayList();
144
		imagesToDispose = new ArrayList();
Lines 200-235 Link Here
200
		removeResourceTypeButton.setLayoutData(data);
209
		removeResourceTypeButton.setLayoutData(data);
201
		
210
		
202
		
211
		
203
		// transfer mode 
212
		// default file transfer mode
204
		Group modeGroup = new Group(groupComponent, SWT.SHADOW_ETCHED_IN);
205
		modeGroup.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_LABEL);
206
		modeGroup.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TOOLTIP);
207
		
208
		layout = new GridLayout();
209
		layout.numColumns = 1;
210
		//layout.verticalSpacing = 10;
211
		layout.horizontalSpacing = 10;
212
		modeGroup.setLayout(layout);
213
		data = new GridData(GridData.FILL_BOTH);
214
		data.horizontalSpan = 2;		
215
		data.widthHint = 100;
216
		data.grabExcessHorizontalSpace = true;
217
		modeGroup.setLayoutData(data);
218
		
219
		// add the binary radio button
220
		binaryButton = new Button(modeGroup, SWT.RADIO);
221
		binaryButton.addListener(SWT.Selection, this);
222
		binaryButton.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL);
223
		binaryButton.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_TOOLTIP);
224
				
225
		// add the text radio button
226
		textButton = new Button(modeGroup, SWT.RADIO);
227
		textButton.addListener(SWT.Selection, this);
228
		textButton.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL);
229
		textButton.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_TOOLTIP);
230
231
	
232
//		 default file transfer mode
233
		Group defaultModeGroup = new Group(groupComponent, SWT.SHADOW_ETCHED_IN);
213
		Group defaultModeGroup = new Group(groupComponent, SWT.SHADOW_ETCHED_IN);
234
		defaultModeGroup.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_DEFAULT_MODE_LABEL);
214
		defaultModeGroup.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_DEFAULT_MODE_LABEL);
235
		defaultModeGroup.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_DEFAULT_MODE_TOOLTIP);
215
		defaultModeGroup.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_DEFAULT_MODE_TOOLTIP);
Lines 239-245 Link Here
239
		//layout.verticalSpacing = 10;
219
		//layout.verticalSpacing = 10;
240
		layout.horizontalSpacing = 10;
220
		layout.horizontalSpacing = 10;
241
		defaultModeGroup.setLayout(layout);
221
		defaultModeGroup.setLayout(layout);
242
		data = new GridData(GridData.FILL_BOTH);
222
		data = new GridData(GridData.FILL_HORIZONTAL);
243
		data.horizontalSpan = 2;
223
		data.horizontalSpan = 2;
244
		data.widthHint = 100;		
224
		data.widthHint = 100;		
245
		data.grabExcessHorizontalSpace = true;
225
		data.grabExcessHorizontalSpace = true;
Lines 383-390 Link Here
383
			resourceTypeTable.setSelection(0);
363
			resourceTypeTable.setSelection(0);
384
			resourceTypeTable.setFocus();
364
			resourceTypeTable.setFocus();
385
		}
365
		}
386
		
366
387
		fillMode();
388
		updateEnabledState();
367
		updateEnabledState();
389
		
368
		
390
        (new Mnemonics()).setOnPreferencePage(true).setMnemonics(parent);	
369
        (new Mnemonics()).setOnPreferencePage(true).setMnemonics(parent);	
Lines 411-434 Link Here
411
	 */
390
	 */
412
	protected void fillResourceTypeTable() {
391
	protected void fillResourceTypeTable() {
413
		
392
		
393
		
394
		
414
		// Setup the columns (icon, type)
395
		// Setup the columns (icon, type)
415
		TableLayout tableLayout = new TableLayout();
396
		TableLayout tableLayout = new TableLayout();
416
		resourceTypeTable.setLayout(tableLayout);
397
		resourceTypeTable.setLayout(tableLayout);
417
		resourceTypeTable.setHeaderVisible(true);
398
		resourceTypeTable.setHeaderVisible(true);
418
399
		resourceTypeTable.setLinesVisible(true);
400
		
401
		// cell modifier stuff so that we can change the transfer
402
		// mode directly from the cell
403
		TableViewer tableViewer = new TableViewer(resourceTypeTable);
404
		tableViewer.setCellModifier(this);
405
		
419
		ColumnLayoutData layoutData = new ColumnPixelData(20, false);
406
		ColumnLayoutData layoutData = new ColumnPixelData(20, false);
420
		tableLayout.addColumnData(layoutData);
407
		tableLayout.addColumnData(layoutData);
421
		TableColumn tableCol = new TableColumn(resourceTypeTable, SWT.NONE);
408
		TableColumn tableCol = new TableColumn(resourceTypeTable, SWT.NONE, 0);
422
		tableCol.setResizable(false);
409
		tableCol.setResizable(false);
423
		tableCol.setText(""); //$NON-NLS-1$
410
		tableCol.setText(""); //$NON-NLS-1$
424
411
425
		layoutData = new ColumnWeightData(40, false);
412
		layoutData = new ColumnWeightData(40, true);
426
		tableLayout.addColumnData(layoutData);
413
		tableLayout.addColumnData(layoutData);
427
		tableCol = new TableColumn(resourceTypeTable, SWT.NONE);
414
		tableCol = new TableColumn(resourceTypeTable, SWT.NONE, 1);
428
		tableCol.setResizable(false);
415
		tableCol.setResizable(true);
429
		tableCol.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_TABLECOL_LABEL);
416
		tableCol.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_TABLECOL_LABEL);
430
417
431
		ISystemFileTransferModeMapping[] mappings =  modeRegistry.getModeMappings();
418
		layoutData = new ColumnWeightData(60, true);
419
		tableLayout.addColumnData(layoutData);
420
		tableCol = new TableColumn(resourceTypeTable, SWT.NONE, 2);
421
		tableCol.setResizable(true);
422
		tableCol.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_LABEL);
423
		
424
	
425
		String[] contentTypes = new String[2];
426
		contentTypes[0] = FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL;
427
		contentTypes[1] = FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL;
428
		
429
	    CellEditor editors[] = new CellEditor[3];
430
	    editors[0] = null;
431
	    editors[1] = new TextCellEditor(resourceTypeTable);
432
	    editors[2] = new ComboBoxCellEditor(resourceTypeTable, contentTypes, SWT.READ_ONLY); 
433
	    
434
	    
435
	    tableViewer.setColumnProperties(columnProperties);
436
	    tableViewer.setCellEditors(editors);
437
		
438
		ISystemFileTransferModeMapping[] mappings =  getModeMappings();
432
		
439
		
433
		for (int i = 0; i < mappings.length; i++) {
440
		for (int i = 0; i < mappings.length; i++) {
434
			newResourceTableItem(mappings[i], i, false);
441
			newResourceTableItem(mappings[i], i, false);
Lines 442-448 Link Here
442
		else if (defaultFileTransferMode == ISystemFilePreferencesConstants.FILETRANSFERMODE_TEXT)
449
		else if (defaultFileTransferMode == ISystemFilePreferencesConstants.FILETRANSFERMODE_TEXT)
443
		{		
450
		{		
444
			defaultTextButton.setSelection(true);
451
			defaultTextButton.setSelection(true);
452
		}		
453
	}
454
	
455
	protected ISystemFileTransferModeMapping[] getModeMappings()
456
	{
457
		// cloning the registry ones so that we can restore later	
458
		ISystemFileTransferModeMapping[] mappings = modeRegistry.getModeMappings();
459
		
460
		ISystemFileTransferModeMapping[] clonedMappings = new ISystemFileTransferModeMapping[mappings.length];
461
		for (int i = 0; i < mappings.length; i++){
462
			SystemFileTransferModeMapping mapping = (SystemFileTransferModeMapping)mappings[i];
463
			clonedMappings[i] = (ISystemFileTransferModeMapping)mapping.clone();			
445
		}
464
		}
465
		return clonedMappings;
446
	}
466
	}
447
	
467
	
448
	/**
468
	/**
Lines 455-461 Link Here
455
		resourceTypeTable.setRedraw(false);
475
		resourceTypeTable.setRedraw(false);
456
		resourceTypeTable.removeAll();
476
		resourceTypeTable.removeAll();
457
				
477
				
458
		ISystemFileTransferModeMapping[] mappings = modeRegistry.getModeMappings();
478
		ISystemFileTransferModeMapping[] mappings = getModeMappings();
459
		for (int i = 0; i < mappings.length; i++) 
479
		for (int i = 0; i < mappings.length; i++) 
460
		{
480
		{
461
		 newResourceTableItem(mappings[i], i, false);
481
		 newResourceTableItem(mappings[i], i, false);
Lines 471-478 Link Here
471
			resourceTypeTable.setSelection(0);
491
			resourceTypeTable.setSelection(0);
472
			resourceTypeTable.setFocus();
492
			resourceTypeTable.setFocus();
473
		}
493
		}
474
		
494
475
		fillMode();
476
		updateEnabledState();
495
		updateEnabledState();
477
	}
496
	}
478
	
497
	
Lines 490-500 Link Here
490
	    uploadBufferSize.setText(ISystemFilePreferencesConstants.DEFAULT_DOWNLOAD_BUFFER_SIZE + ""); //$NON-NLS-1$
509
	    uploadBufferSize.setText(ISystemFilePreferencesConstants.DEFAULT_DOWNLOAD_BUFFER_SIZE + ""); //$NON-NLS-1$
491
	}
510
	}
492
	
511
	
493
	private Image getImageDescriptor(ISystemFileTransferModeMapping mapping)
512
	
513
	private Image applyBinaryDecoration(Image source) {
514
		ImageDescriptor binaryOverlay = Activator.getImageDescriptor("/icons/full/ovr16/binary_ovr.gif");
515
		DecorationOverlayIcon icon = new DecorationOverlayIcon(source, binaryOverlay, 3);
516
		return icon.createImage();
517
	}
518
	
519
	private Image getImageFor(ISystemFileTransferModeMapping mapping)
494
	{
520
	{
495
		//String extension = mapping.getExtension();
521
		if (fileImage == null){
522
			fileImage = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJ_FILE).createImage();
523
		}
524
		if (binaryFileImage == null)
525
		{
526
			binaryFileImage = applyBinaryDecoration(fileImage);
527
		}
528
		
496
		// for now just always using the same image
529
		// for now just always using the same image
497
		return WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJ_FILE).createImage();
530
		if (mapping.isBinary())
531
		{
532
			return binaryFileImage;
533
		}
534
		else
535
		{
536
			return fileImage;
537
		}
498
	}
538
	}
499
	
539
	
500
	/**
540
	/**
Lines 504-519 Link Here
504
	protected TableItem newResourceTableItem(ISystemFileTransferModeMapping mapping, int index, boolean selected) {
544
	protected TableItem newResourceTableItem(ISystemFileTransferModeMapping mapping, int index, boolean selected) {
505
		
545
		
506
		modeMappings.add(index, mapping);
546
		modeMappings.add(index, mapping);
507
				
508
		Image image = getImageDescriptor(mapping);
509
		
547
		
548
		Image image = getImageFor(mapping);
510
		if (image != null)
549
		if (image != null)
511
			imagesToDispose.add(image);
550
			imagesToDispose.add(image);
512
	
551
	
513
		TableItem item = new TableItem(resourceTypeTable, SWT.NULL, index);
552
		TableItem item = new TableItem(resourceTypeTable, SWT.NULL, index);
553
		item.setData(mapping);
514
		item.setImage(0, image);
554
		item.setImage(0, image);
515
		item.setText(1, mapping.getLabel());
555
		item.setText(1, mapping.getLabel());
516
		
556
		
557
		boolean binary = mapping.isBinary();
558
		item.setText(2, binary ? FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL : FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL);
559
				
560
		
517
		if (selected)
561
		if (selected)
518
			resourceTypeTable.setSelection(index);
562
			resourceTypeTable.setSelection(index);
519
				
563
				
Lines 547-567 Link Here
547
	 */
591
	 */
548
	public void handleEvent(Event event) {
592
	public void handleEvent(Event event) {
549
		
593
		
550
		if ((event.widget == resourceTypeTable) && ((event.type == SWT.Selection) || (event.type == SWT.DefaultSelection))) {
551
			fillMode();
552
		}
553
		if ((event.widget == addResourceTypeButton) && (event.type == SWT.Selection)) {
594
		if ((event.widget == addResourceTypeButton) && (event.type == SWT.Selection)) {
554
			promptForResourceType();
595
			promptForResourceType();
555
		}
596
		}
556
		else if ((event.widget == removeResourceTypeButton) && (event.type == SWT.Selection)) {
597
		else if ((event.widget == removeResourceTypeButton) && (event.type == SWT.Selection)) {
557
			removeSelectedResourceType();
598
			removeSelectedResourceType();
558
		}
599
		}
559
		else if ((event.widget == binaryButton) && (event.type == SWT.Selection)) {
560
			binaryButtonSelected();
561
		}
562
		else if ((event.widget == textButton) && (event.type == SWT.Selection)) {
563
			textButtonSelected();
564
		}
565
		else if ((event.widget == doSuperTransferButton) && (event.type == SWT.Selection))
600
		else if ((event.widget == doSuperTransferButton) && (event.type == SWT.Selection))
566
		{
601
		{
567
		    doSuperTransferButtonSelected();
602
		    doSuperTransferButtonSelected();
Lines 571-598 Link Here
571
	
606
	
572
	
607
	
573
	/**
608
	/**
574
	 * Fill the mode widgets
575
	 */
576
	public void fillMode() {
577
		
578
		int index = resourceTypeTable.getSelectionIndex();
579
		SystemFileTransferModeMapping modeMapping = getModeMapping(index);
580
		
581
		if (modeMapping !=null)
582
		{
583
			if (modeMapping.isBinary()) {
584
				binaryButton.setSelection(true);
585
				textButton.setSelection(false);
586
			}
587
			else {
588
				binaryButton.setSelection(false);
589
				textButton.setSelection(true);
590
			}
591
		}
592
	}
593
	
594
	
595
	/**
596
	 * Prompt for file type
609
	 * Prompt for file type
597
	 */
610
	 */
598
	public void promptForResourceType() {
611
	public void promptForResourceType() {
Lines 699-739 Link Here
699
712
700
		
713
		
701
		// Create the new type and insert it
714
		// Create the new type and insert it
702
		mapping = new SystemFileTransferModeMapping(newName,newExtension);			
715
		mapping = new SystemFileTransferModeMapping(newName,newExtension);	
716
		
717
		// default to default
718
		if (defaultBinaryButton.getSelection()) {
719
			mapping.setAsBinary();
720
		}
721
		else {
722
			mapping.setAsText();
723
		}
724
		
703
		newResourceTableItem(mapping, i, true);
725
		newResourceTableItem(mapping, i, true);
704
		
726
		
705
		resourceTypeTable.setFocus();
727
		resourceTypeTable.setFocus();
706
		fillMode();
707
	}
708
	
709
	
710
	/**
711
	 * Helper method to configure things when binary mode radio button
712
	 * is selected
713
	 */
714
	private void binaryButtonSelected() {
715
		//binaryButton.setSelection(true); // causes hang on linux
716
		//textButton.setSelection(false);
717
		
718
		int index = resourceTypeTable.getSelectionIndex();
719
		SystemFileTransferModeMapping modeMapping = getModeMapping(index);
720
		if (modeMapping != null)
721
			modeMapping.setAsBinary();
722
	}
728
	}
723
	
724
	
725
	/**
726
	 * Helper method to configure things when text mode is selected
727
	 */
728
	private void textButtonSelected() {
729
	//	textButton.setSelection(true); // causes hang on linux
730
	//	binaryButton.setSelection(false);
731
		
729
		
732
		int index = resourceTypeTable.getSelectionIndex();
733
		SystemFileTransferModeMapping modeMapping = getModeMapping(index);
734
		if (modeMapping != null)
735
			modeMapping.setAsText();
736
	}		
737
	
730
	
738
	private void doSuperTransferButtonSelected()
731
	private void doSuperTransferButtonSelected()
739
	{
732
	{
Lines 746-762 Link Here
746
	        archiveTypeCombo.setEnabled(false);
739
	        archiveTypeCombo.setEnabled(false);
747
	    }
740
	    }
748
	}
741
	}
749
	
742
750
	/**
751
	 * Gets the mode mapping given the editor mapping selected
752
	 */
753
	private SystemFileTransferModeMapping getModeMapping(int index) {
754
		
755
		if (index >=0 && index < modeMappings.size())
756
			return (SystemFileTransferModeMapping)(modeMappings.get(index));
757
		else
758
			return null;
759
	}
760
	
743
	
761
	
744
	
762
	/**
745
	/**
Lines 927-964 Link Here
927
	 */
910
	 */
928
	private static void savePreferenceStore()
911
	private static void savePreferenceStore()
929
	{	 
912
	{	 
930
		/* DY:  This was causing ClassCastException in 2.0
931
		 *      getPreferenceStore retutrns CompatibilityPreferenceStore now
932
		PreferenceStore store = (PreferenceStore)RSEUIPlugin.getDefault().getPreferenceStore();				
933
		try {
934
			store.save();
935
		} catch (Exception exc)
936
		{
937
			System.out.println("Error saving preferences: " + exc.getMessage() + ": " + exc.getClass().getName());
938
		}
939
		*/
940
		// ok, a couple hours of research leads me to believe this is now the new
941
		// thing to do... phil
942
		RSEUIPlugin.getDefault().savePluginPreferences();
913
		RSEUIPlugin.getDefault().savePluginPreferences();
943
	}
914
	}
915
916
	public boolean canModify(Object element, String property) {
917
		if (property.equals(columnProperties[2]))
918
		{
919
			return true;
920
		}
921
		else if (property.equals(columnProperties[1]))
922
		{
923
			return true;
924
		}
925
		return false;
926
	}
927
928
	public Object getValue(Object element, String property) {
929
		SystemFileTransferModeMapping mapping = (SystemFileTransferModeMapping)element;
930
		if (property.equals(columnProperties[2])){
931
			return mapping.isBinary() ? new Integer(0) : new Integer(1);
932
		}
933
		else if (property.equals(columnProperties[1])){
934
			return mapping.getLabel();		
935
		}
936
		return null;
937
	}
938
939
	public void modify(Object element, String property, Object value) 
940
	{
941
		TableItem item = (TableItem)element;
942
		SystemFileTransferModeMapping mapping = (SystemFileTransferModeMapping)item.getData();
943
		if (mapping != null)
944
		{
945
			if (property.equals(columnProperties[2])){
944
	
946
	
945
	/**
947
				if (value instanceof Integer)
946
	 * Listen for changes to the Editor Registry content.
948
				{
947
	 * Update our registry by changing the hashmap and saving the new
949
					int index = ((Integer)value).intValue();
948
	 * mappings on disk.
950
					if (index == 0)
949
	 * @see IPropertyListener#propertyChanged(Object, int)
951
					{
950
	 */
952
						mapping.setAsBinary();
951
	public void propertyChanged(Object source, int propId) {
953
						item.setText(2, FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL);
952
	
954
						item.setImage(getImageFor(mapping));
953
		if ((source instanceof IEditorRegistry) && (propId == IEditorRegistry.PROP_CONTENTS)) {
955
					}
954
			
956
					else
955
			// the OK button was pressed, and we need to incorporate changes from the File Editors preference page
957
					{
956
			IEditorRegistry registry = (IEditorRegistry)source;
958
						mapping.setAsText();
957
			
959
						item.setText(2, FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL);
958
			IFileEditorMapping[] editorMappingArray = registry.getFileEditorMappings();
960
						item.setImage(getImageFor(mapping));
959
		
961
					}
960
			for (int i = 0; i < editorMappingArray.length; i++) {
962
				}
963
				
964
			}
965
			else if (property.equals(columnProperties[1])){
966
				if (value instanceof String)
967
				{
968
					String nameExtension = (String)value;
969
					
970
					int dotIndex = nameExtension.lastIndexOf('.');
971
					if (dotIndex != -1)
972
					{
973
						String name = nameExtension.substring(0, dotIndex);					
974
						
975
						String ext = nameExtension.substring(dotIndex + 1);
976
977
						mapping.setName(name);
978
						mapping.setExtension(ext);
979
						item.setText(1, nameExtension);
980
					}
981
				}
961
			}
982
			}
962
		}
983
		}
963
	}
984
	}
985
	
964
}
986
}

Return to bug 203114