Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 208951
Collapse All | Expand All

(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 1-7 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.rse.subsystems.files.core
4
Bundle-SymbolicName: org.eclipse.rse.subsystems.files.core;singleton:=true
5
Bundle-Version: 3.0.0.qualifier
5
Bundle-Version: 3.0.0.qualifier
6
Bundle-Activator: org.eclipse.rse.internal.subsystems.files.core.Activator
6
Bundle-Activator: org.eclipse.rse.internal.subsystems.files.core.Activator
7
Bundle-Localization: plugin
7
Bundle-Localization: plugin
(-)src/org/eclipse/rse/subsystems/files/core/model/SystemFileTransferModeRegistry.java (-2 / +119 lines)
Lines 13-18 Link Here
13
 * 
13
 * 
14
 * Contributors:
14
 * Contributors:
15
 * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin
15
 * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin
16
 * David McKnight   (IBM)        - [208951] Use remoteFileTypes extension point to determine file types
16
 *******************************************************************************/
17
 *******************************************************************************/
17
18
18
package org.eclipse.rse.subsystems.files.core.model;
19
package org.eclipse.rse.subsystems.files.core.model;
Lines 29-36 Link Here
29
import java.util.List;
30
import java.util.List;
30
import java.util.SortedSet;
31
import java.util.SortedSet;
31
import java.util.TreeSet;
32
import java.util.TreeSet;
33
import java.util.Vector;
32
34
33
import org.eclipse.core.resources.IFile;
35
import org.eclipse.core.resources.IFile;
36
import org.eclipse.core.runtime.IConfigurationElement;
37
import org.eclipse.core.runtime.IExtensionRegistry;
38
import org.eclipse.core.runtime.Platform;
34
import org.eclipse.jface.preference.IPreferenceStore;
39
import org.eclipse.jface.preference.IPreferenceStore;
35
import org.eclipse.rse.internal.subsystems.files.core.ISystemFilePreferencesConstants;
40
import org.eclipse.rse.internal.subsystems.files.core.ISystemFilePreferencesConstants;
36
import org.eclipse.rse.services.clientserver.SystemEncodingUtil;
41
import org.eclipse.rse.services.clientserver.SystemEncodingUtil;
Lines 41-48 Link Here
41
import org.eclipse.ui.IFileEditorMapping;
46
import org.eclipse.ui.IFileEditorMapping;
42
import org.eclipse.ui.IMemento;
47
import org.eclipse.ui.IMemento;
43
import org.eclipse.ui.IPropertyListener;
48
import org.eclipse.ui.IPropertyListener;
44
import org.eclipse.ui.IWorkbench;
45
import org.eclipse.ui.PlatformUI;
46
import org.eclipse.ui.XMLMemento;
49
import org.eclipse.ui.XMLMemento;
47
50
48
51
Lines 70-75 Link Here
70
	private static final String BINARY_VALUE = "binary";  //$NON-NLS-1$
73
	private static final String BINARY_VALUE = "binary";  //$NON-NLS-1$
71
	private static final String TEXT_VALUE = "text"; //$NON-NLS-1$
74
	private static final String TEXT_VALUE = "text"; //$NON-NLS-1$
72
75
76
	
73
77
74
	/**
78
	/**
75
	 * Constructor for SystemFileTransferModeRegistry
79
	 * Constructor for SystemFileTransferModeRegistry
Lines 102-107 Link Here
102
		// load our current associations (if any)
106
		// load our current associations (if any)
103
		loadAssociations();
107
		loadAssociations();
104
		
108
		
109
		
110
		// lists to hold the information from the extensions to our
111
		// extension point
112
		Vector extTextList = new Vector();
113
		Vector extBinaryList = new Vector();
114
		
115
		// get reference to the extension registry
116
		IExtensionRegistry extRegistry = Platform.getExtensionRegistry();
117
118
		// get extensions to our extension point
119
		IConfigurationElement[] elements = extRegistry.getConfigurationElementsFor("org.eclipse.rse.subsystems.files.core", "remoteFileTypes");
120
121
		// go through all extensions
122
		for (int i = 0; i < elements.length; i++) {
123
			IConfigurationElement element = elements[i];
124
125
			// get the extension attribute value
126
			String extension = element.getAttribute("extension");
127
128
			if (extension != null && !extension.equals("")) {
129
130
				// get the type attribute value
131
				String type = element.getAttribute("type");
132
133
				if (type != null && !type.equals("")) {
134
135
					// add extension to list of text types
136
					if (type.equalsIgnoreCase("text")) {
137
138
						// if the extension is not already part of our text
139
						// types list
140
						if (!extTextList.contains(extension)) {
141
142
							// add to list
143
							extTextList.add(extension);
144
145
							// create an editor mapping
146
							// FileEditorMapping mapping = new FileEditorMapping("*", extension);
147
148
							// add to editor mapping list
149
							// editorMappings.add(mapping);
150
						}
151
					}
152
					// add extension to list of binary types
153
					if (type.equalsIgnoreCase("binary")) {
154
155
						// if the extension is not already part of our
156
						// binary types list
157
						if (!extBinaryList.contains(extension)) {
158
159
							// add to list
160
							extBinaryList.add(extension);
161
162
							// create an editor mapping
163
							// FileEditorMapping mapping = new FileEditorMapping("*", extension);
164
165
							// add to editor mapping list
166
							// editorMappings.add(mapping);
167
						}
168
					}
169
					else {
170
						continue;
171
					}
172
				}
173
			}
174
			else {
175
				continue;
176
			}
177
		}
178
		
179
		// add text extension to the mappings list
180
		for (int t = 0; t < extTextList.size(); t++)
181
		{
182
			String extension = (String)extTextList.get(t);
183
			SystemFileTransferModeMapping mapping = new SystemFileTransferModeMapping(extension);
184
			
185
			String key = getMappingKey(mapping);
186
			if (!typeModeMappings.containsKey(key))
187
			{
188
				mapping.setAsText();		
189
				typeModeMappings.put(key, mapping);
190
			}
191
		}
192
		
193
		// add binary extension to the mappings list
194
		for (int b = 0; b < extBinaryList.size(); b++)
195
		{
196
			String extension = (String)extBinaryList.get(b);
197
			SystemFileTransferModeMapping mapping = new SystemFileTransferModeMapping(extension);
198
			
199
			
200
			String key = getMappingKey(mapping);
201
			if (!typeModeMappings.containsKey(key))
202
			{
203
				mapping.setAsBinary();		
204
				typeModeMappings.put(key, mapping);
205
			}
206
		}
207
		
208
		/*
105
		// now we need to ensure that our mapping is in sync with the
209
		// now we need to ensure that our mapping is in sync with the
106
		// editor registry. We can be out of sync because we may not have
210
		// editor registry. We can be out of sync because we may not have
107
		// been listening for editor registry changes (e.g. if our plugin wasn't
211
		// been listening for editor registry changes (e.g. if our plugin wasn't
Lines 124-129 Link Here
124
		
228
		
125
			registry.addPropertyListener(this);
229
			registry.addPropertyListener(this);
126
		}
230
		}
231
		*/
127
	}
232
	}
128
	
233
	
129
	
234
	
Lines 385-390 Link Here
385
		
490
		
386
		SystemFileTransferModeMapping mapping = new SystemFileTransferModeMapping(name, extension);		
491
		SystemFileTransferModeMapping mapping = new SystemFileTransferModeMapping(name, extension);		
387
	
492
	
493
		/*
494
		// if the extension is part of the extension text type list
495
		if (extTextList.contains(extension)) {
496
			mapping.setAsText();
497
			return mapping;			
498
		}
499
		// if the extension is part of the extension binary type list
500
		else if (extBinaryList.contains(extension)) {
501
			mapping.setAsBinary();
502
			return mapping;			
503
		}
504
		*/
388
	
505
	
389
		// check if it's a default text file name
506
		// check if it's a default text file name
390
		for (int i = 0; i < DEFAULT_TEXT_FILE_NAMES.length; i++) 
507
		for (int i = 0; i < DEFAULT_TEXT_FILE_NAMES.length; i++) 
(-)plugin.xml (+16 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.0"?>
3
<plugin>
4
<!-- ================================================================= -->
5
<!-- 		Define Remote File Types extension point -->
6
<!-- ================================================================= -->
7
   <extension-point id="remoteFileTypes" name="%extPoint.remoteFileTypes" schema="schema/remoteFileTypes.exsd"/>
8
9
10
11
<extension point="org.eclipse.rse.subsystems.files.core.remoteFileTypes">
12
  <remoteFileTypes extension="txt" type="text"/>
13
  <remoteFileTypes extension="gif" type="binary"/>
14
</extension>
15
16
</plugin>
(-)schema/remoteFileTypes.exsd (+120 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.rse.subsystems.files.core">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.rse.subsystems.files.core" id="remoteFileTypes" name="%extPoint.remoteFileTypes"/>
7
      </appInfo>
8
      <documentation>
9
         This extension point is used to register information about whether particular file types should be considered text or binary. This information is important as it will determine how files will be transferred.
10
11
Providers may provide an extension for this extension point. No code beyond the XML extension declaration is required.
12
      </documentation>
13
   </annotation>
14
15
   <element name="extension">
16
      <complexType>
17
         <sequence minOccurs="1" maxOccurs="unbounded">
18
            <element ref="remoteFileTypes"/>
19
         </sequence>
20
         <attribute name="point" type="string" use="required">
21
            <annotation>
22
               <documentation>
23
                  
24
               </documentation>
25
            </annotation>
26
         </attribute>
27
         <attribute name="id" type="string">
28
            <annotation>
29
               <documentation>
30
                  
31
               </documentation>
32
            </annotation>
33
         </attribute>
34
         <attribute name="name" type="string">
35
            <annotation>
36
               <documentation>
37
                  
38
               </documentation>
39
               <appInfo>
40
                  <meta.attribute translatable="true"/>
41
               </appInfo>
42
            </annotation>
43
         </attribute>
44
      </complexType>
45
   </element>
46
47
   <element name="remoteFileTypes">
48
      <complexType>
49
         <attribute name="extension" type="string" use="required">
50
            <annotation>
51
               <documentation>
52
                  
53
               </documentation>
54
            </annotation>
55
         </attribute>
56
         <attribute name="type" type="string" use="required">
57
            <annotation>
58
               <documentation>
59
                  
60
               </documentation>
61
            </annotation>
62
         </attribute>
63
      </complexType>
64
   </element>
65
66
   <annotation>
67
      <appInfo>
68
         <meta.section type="since"/>
69
      </appInfo>
70
      <documentation>
71
         3.0
72
      </documentation>
73
   </annotation>
74
75
   <annotation>
76
      <appInfo>
77
         <meta.section type="examples"/>
78
      </appInfo>
79
      <documentation>
80
         &lt;extension point=&quot;org.eclipse.rse.subsystems.files.core.remoteFileTypes&quot;&gt;
81
 &lt;remoteFileTypes extension=&quot;txt&quot; type=&quot;text&quot;/&gt;
82
 &lt;remoteFileTypes extension=&quot;gif&quot; type=&quot;binary&quot;/&gt;
83
&lt;/extension&gt;
84
      </documentation>
85
   </annotation>
86
87
   <annotation>
88
      <appInfo>
89
         <meta.section type="apiInfo"/>
90
      </appInfo>
91
      <documentation>
92
         There is no code to implement for this extension point.
93
      </documentation>
94
   </annotation>
95
96
   <annotation>
97
      <appInfo>
98
         <meta.section type="implementation"/>
99
      </appInfo>
100
      <documentation>
101
         
102
      </documentation>
103
   </annotation>
104
105
   <annotation>
106
      <appInfo>
107
         <meta.section type="copyright"/>
108
      </appInfo>
109
      <documentation>
110
      Copyright (c) 2006, 2007 IBM Corporation. All Rights Reserved.
111
This program and the accompanying materials are made available under the terms
112
of the Eclipse Public License v1.0 which accompanies this distribution, and is 
113
available at http://www.eclipse.org/legal/epl-v10.html
114
115
Contributors:
116
IBM Corporation - initial API and implementation
117
      </documentation>
118
   </annotation>
119
120
</schema>
(-)src/org/eclipse/rse/internal/files/ui/propertypages/UniversalPreferencePage.java (-18 / +33 lines)
Lines 35-40 Link Here
35
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
35
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
36
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
36
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
37
import org.eclipse.rse.services.clientserver.messages.SystemMessageFile;
37
import org.eclipse.rse.services.clientserver.messages.SystemMessageFile;
38
import org.eclipse.rse.subsystems.files.core.model.ISystemFileTransferModeMapping;
38
import org.eclipse.rse.subsystems.files.core.model.SystemFileTransferModeMapping;
39
import org.eclipse.rse.subsystems.files.core.model.SystemFileTransferModeMapping;
39
import org.eclipse.rse.subsystems.files.core.model.SystemFileTransferModeRegistry;
40
import org.eclipse.rse.subsystems.files.core.model.SystemFileTransferModeRegistry;
40
import org.eclipse.rse.ui.ISystemMessages;
41
import org.eclipse.rse.ui.ISystemMessages;
Lines 65-75 Link Here
65
import org.eclipse.ui.IEditorRegistry;
66
import org.eclipse.ui.IEditorRegistry;
66
import org.eclipse.ui.IFileEditorMapping;
67
import org.eclipse.ui.IFileEditorMapping;
67
import org.eclipse.ui.IPropertyListener;
68
import org.eclipse.ui.IPropertyListener;
69
import org.eclipse.ui.ISharedImages;
68
import org.eclipse.ui.IWorkbench;
70
import org.eclipse.ui.IWorkbench;
69
import org.eclipse.ui.IWorkbenchPreferencePage;
71
import org.eclipse.ui.IWorkbenchPreferencePage;
70
import org.eclipse.ui.PlatformUI;
72
import org.eclipse.ui.PlatformUI;
73
import org.eclipse.ui.internal.WorkbenchImages;
71
import org.eclipse.ui.internal.dialogs.FileExtensionDialog;
74
import org.eclipse.ui.internal.dialogs.FileExtensionDialog;
72
import org.eclipse.ui.internal.registry.EditorRegistry;
73
import org.eclipse.ui.internal.registry.FileEditorMapping;
75
import org.eclipse.ui.internal.registry.FileEditorMapping;
74
76
75
/**
77
/**
Lines 96-102 Link Here
96
	protected Button defaultTextButton;
98
	protected Button defaultTextButton;
97
	
99
	
98
	protected SystemFileTransferModeRegistry modeRegistry;
100
	protected SystemFileTransferModeRegistry modeRegistry;
99
	protected IEditorRegistry editorRegistry;
101
	//protected IEditorRegistry editorRegistry;
100
	
102
	
101
	protected ArrayList modeMappings; 
103
	protected ArrayList modeMappings; 
102
	protected ArrayList editorMappings;
104
	protected ArrayList editorMappings;
Lines 129-135 Link Here
129
	protected void createFieldEditors() {
131
	protected void createFieldEditors() {
130
		
132
		
131
		modeRegistry = SystemFileTransferModeRegistry.getInstance();
133
		modeRegistry = SystemFileTransferModeRegistry.getInstance();
132
		editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
134
		//editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
133
		
135
		
134
		modeMappings = new ArrayList();
136
		modeMappings = new ArrayList();
135
		editorMappings = new ArrayList();
137
		editorMappings = new ArrayList();
Lines 429-438 Link Here
429
		tableCol.setResizable(false);
431
		tableCol.setResizable(false);
430
		tableCol.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_TABLECOL_LABEL);
432
		tableCol.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_TABLECOL_LABEL);
431
		
433
		
432
		IFileEditorMapping[] mappingArray = editorRegistry.getFileEditorMappings();
433
		
434
		
434
		for (int i = 0; i < mappingArray.length; i++) {
435
		//IFileEditorMapping[] mappingArray = editorRegistry.getFileEditorMappings();
435
			newResourceTableItem(mappingArray[i], i, false);
436
		ISystemFileTransferModeMapping[] mappings =  modeRegistry.getModeMappings();
437
		
438
		for (int i = 0; i < mappings.length; i++) {
439
			newResourceTableItem(mappings[i], i, false);
436
		}
440
		}
437
		
441
		
438
		int defaultFileTransferMode = getFileTransferModeDefaultPreference();
442
		int defaultFileTransferMode = getFileTransferModeDefaultPreference();
Lines 458-467 Link Here
458
		resourceTypeTable.removeAll();
462
		resourceTypeTable.removeAll();
459
		
463
		
460
		
464
		
461
		IFileEditorMapping[] mappingArray = editorRegistry.getFileEditorMappings();
465
		ISystemFileTransferModeMapping[] mappings = modeRegistry.getModeMappings();
462
		for (int i = 0; i < mappingArray.length; i++) 
466
		//IFileEditorMapping[] mappingArray = editorRegistry.getFileEditorMappings();
467
		for (int i = 0; i < mappings.length; i++) 
463
		{
468
		{
464
		 newResourceTableItem(mappingArray[i], i, false);
469
		 newResourceTableItem(mappings[i], i, false);
465
		}
470
		}
466
		resourceTypeTable.setRedraw(true);
471
		resourceTypeTable.setRedraw(true);
467
472
Lines 493-508 Link Here
493
	    uploadBufferSize.setText(ISystemFilePreferencesConstants.DEFAULT_DOWNLOAD_BUFFER_SIZE + ""); //$NON-NLS-1$
498
	    uploadBufferSize.setText(ISystemFilePreferencesConstants.DEFAULT_DOWNLOAD_BUFFER_SIZE + ""); //$NON-NLS-1$
494
	}
499
	}
495
	
500
	
501
	private Image getImageDescriptor(ISystemFileTransferModeMapping mapping)
502
	{
503
		String extension = mapping.getExtension();
504
		return WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJ_FILE).createImage();
505
	}
506
	
496
	/**
507
	/**
497
 	 * Create a new <code>TableItem</code> to represent the resource
508
 	 * Create a new <code>TableItem</code> to represent the resource
498
 	 * type editor description supplied.
509
 	 * type editor description supplied.
499
 	 */
510
 	 */
500
	protected TableItem newResourceTableItem(IFileEditorMapping mapping, int index, boolean selected) {
511
	protected TableItem newResourceTableItem(ISystemFileTransferModeMapping mapping, int index, boolean selected) {
501
		
502
		editorMappings.add(index, ((FileEditorMapping)mapping).clone());
503
		modeMappings.add(index, modeRegistry.getMapping(mapping).clone());
504
		
512
		
505
		Image image = mapping.getImageDescriptor().createImage(false);
513
	//	editorMappings.add(index, ((FileEditorMapping)mapping).clone());
514
		modeMappings.add(index, mapping);
515
				
516
		Image image = getImageDescriptor(mapping);
506
		
517
		
507
		if (image != null)
518
		if (image != null)
508
			imagesToDispose.add(image);
519
			imagesToDispose.add(image);
Lines 514-519 Link Here
514
		if (selected)
525
		if (selected)
515
			resourceTypeTable.setSelection(index);
526
			resourceTypeTable.setSelection(index);
516
527
528
		
529
		
517
		return item;
530
		return item;
518
	}
531
	}
519
	
532
	
Lines 691-697 Link Here
691
704
692
		// Create the new type and insert it
705
		// Create the new type and insert it
693
		resourceType = new FileEditorMapping(newName, newExtension);
706
		resourceType = new FileEditorMapping(newName, newExtension);
694
		newResourceTableItem(resourceType, i, true);
707
		SystemFileTransferModeMapping mapping = modeRegistry.getMapping(resourceType);
708
			
709
		newResourceTableItem(mapping, i, true);
695
		resourceTypeTable.setFocus();
710
		resourceTypeTable.setFocus();
696
		fillMode();
711
		fillMode();
697
	}
712
	}
Lines 778-784 Link Here
778
		super.performOk();
793
		super.performOk();
779
		if (modeMappings != null)
794
		if (modeMappings != null)
780
		{
795
		{
781
			IFileEditorMapping[] originalMappingArray = editorRegistry.getFileEditorMappings();
796
			//IFileEditorMapping[] originalMappingArray = editorRegistry.getFileEditorMappings();
782
			
797
			
783
			// first save the transfer mode registry
798
			// first save the transfer mode registry
784
			Object[] array1 = modeMappings.toArray();
799
			Object[] array1 = modeMappings.toArray();
Lines 799-806 Link Here
799
				mappingArray2[j] = (FileEditorMapping)(array2[j]);
814
				mappingArray2[j] = (FileEditorMapping)(array2[j]);
800
			}
815
			}
801
			
816
			
802
			((EditorRegistry)editorRegistry).setFileEditorMappings(mappingArray2);
817
			//((EditorRegistry)editorRegistry).setFileEditorMappings(mappingArray2);
803
			((EditorRegistry)editorRegistry).saveAssociations();
818
			//((EditorRegistry)editorRegistry).saveAssociations();
804
			
819
			
805
			
820
			
806
			// editorRegistry.removePropertyListener(this);
821
			// editorRegistry.removePropertyListener(this);

Return to bug 208951