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 97676
Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/dialogs/FileExtensionDialog.java (+15 lines)
Lines 40-45 Link Here
40
	private static final String DIALOG_SETTINGS_SECTION = "FileExtensionDialogSettings"; //$NON-NLS-1$
40
	private static final String DIALOG_SETTINGS_SECTION = "FileExtensionDialogSettings"; //$NON-NLS-1$
41
	
41
	
42
    private String filename = ""; //$NON-NLS-1$
42
    private String filename = ""; //$NON-NLS-1$
43
    
44
    private String initialValue;
43
45
44
    private Text filenameField;
46
    private Text filenameField;
45
47
Lines 80-85 Link Here
80
				.setText(WorkbenchMessages.FileExtension_fileTypeLabel);
82
				.setText(WorkbenchMessages.FileExtension_fileTypeLabel);
81
83
82
		filenameField = new Text(contents, SWT.SINGLE | SWT.BORDER);
84
		filenameField = new Text(contents, SWT.SINGLE | SWT.BORDER);
85
		if (initialValue != null) {
86
			filenameField.setText(initialValue);
87
		}
83
		filenameField.addModifyListener(new ModifyListener() {
88
		filenameField.addModifyListener(new ModifyListener() {
84
			public void modifyText(ModifyEvent event) {
89
			public void modifyText(ModifyEvent event) {
85
				if (event.widget == filenameField) {
90
				if (event.widget == filenameField) {
Lines 192-197 Link Here
192
        return filename.substring(0, index);
197
        return filename.substring(0, index);
193
    }
198
    }
194
    
199
    
200
    /**
201
	 * Sets the initial value that should be prepopulated in this dialog.
202
	 * 
203
	 * @param initialValue
204
	 *            the value to be displayed to the user
205
	 * @since 3.4
206
	 */
207
    public void setInitialValue(String initialValue) {
208
    	this.initialValue = initialValue;
209
    }
195
   
210
   
196
    /* (non-Javadoc)
211
    /* (non-Javadoc)
197
     * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
212
     * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
(-)Eclipse UI/org/eclipse/ui/internal/dialogs/ContentTypesPreferencePage.java (-2 / +59 lines)
Lines 77-82 Link Here
77
	private TreeViewer contentTypesViewer;
77
	private TreeViewer contentTypesViewer;
78
78
79
	private Button addButton;
79
	private Button addButton;
80
	
81
	private Button editButton;
80
82
81
	private Text charsetField;
83
	private Text charsetField;
82
84
Lines 422-427 Link Here
422
							IStructuredSelection selection = (IStructuredSelection) event
424
							IStructuredSelection selection = (IStructuredSelection) event
423
									.getSelection();
425
									.getSelection();
424
							if (selection.isEmpty()) {
426
							if (selection.isEmpty()) {
427
								editButton.setEnabled(false);
425
								removeButton.setEnabled(false);
428
								removeButton.setEnabled(false);
426
								return;
429
								return;
427
							}
430
							}
Lines 433-438 Link Here
433
									enabled = false;
436
									enabled = false;
434
								}
437
								}
435
							}
438
							}
439
							editButton.setEnabled(enabled && selection.size() == 1);
436
							removeButton.setEnabled(enabled);
440
							removeButton.setEnabled(enabled);
437
						}
441
						}
438
					});
442
					});
Lines 481-487 Link Here
481
									StatusManager.SHOW, shell);
485
									StatusManager.SHOW, shell);
482
							WorkbenchPlugin.log(ex);
486
							WorkbenchPlugin.log(ex);
483
						} finally {
487
						} finally {
484
							fileAssociationViewer.setInput(selectedContentType);
488
							fileAssociationViewer.refresh(false);
489
						}
490
					}
491
				}
492
			});
493
494
			editButton = new Button(buttonArea, SWT.PUSH);
495
			editButton.setFont(composite.getFont());
496
			editButton
497
					.setText(WorkbenchMessages.ContentTypes_fileAssociationsEditLabel);
498
			editButton.setEnabled(false);
499
			setButtonLayoutData(editButton);
500
			editButton.addSelectionListener(new SelectionAdapter() {
501
				public void widgetSelected(SelectionEvent e) {
502
					Shell shell = composite.getShell();
503
					IContentType selectedContentType = getSelectedContentType();
504
					Spec spec = getSelectedSpecs()[0];
505
					FileExtensionDialog dialog = new FileExtensionDialog(shell);
506
					if (spec.name == null) {
507
						dialog.setInitialValue("*." + spec.ext); //$NON-NLS-1$
508
					} else {
509
						dialog.setInitialValue(spec.name);
510
					}
511
					if (dialog.open() == Window.OK) {
512
						String name = dialog.getName();
513
						String extension = dialog.getExtension();
514
						try {
515
							// remove the original spec
516
							if (spec.name != null) {
517
								selectedContentType.removeFileSpec(spec.name,
518
										IContentType.FILE_NAME_SPEC);
519
							} else if (spec.ext != null) {
520
								selectedContentType.removeFileSpec(spec.ext,
521
										IContentType.FILE_EXTENSION_SPEC);
522
							}
523
524
							// add the new one
525
							if (name.equals("*")) { //$NON-NLS-1$
526
								selectedContentType.addFileSpec(extension,
527
										IContentType.FILE_EXTENSION_SPEC);
528
							} else {
529
								selectedContentType
530
										.addFileSpec(
531
												name
532
														+ (extension.length() > 0 ? ('.' + extension)
533
																: ""), //$NON-NLS-1$
534
												IContentType.FILE_NAME_SPEC);
535
							}
536
						} catch (CoreException ex) {
537
							StatusUtil.handleStatus(ex.getStatus(),
538
									StatusManager.SHOW, shell);
539
							WorkbenchPlugin.log(ex);
540
						} finally {
541
							fileAssociationViewer.refresh(false);
485
						}
542
						}
486
					}
543
					}
487
				}
544
				}
Lines 523-529 Link Here
523
						StatusUtil.handleStatus(result, StatusManager.SHOW,
580
						StatusUtil.handleStatus(result, StatusManager.SHOW,
524
								composite.getShell());
581
								composite.getShell());
525
					}
582
					}
526
					fileAssociationViewer.setInput(contentType);
583
					fileAssociationViewer.refresh(false);
527
				}
584
				}
528
			});
585
			});
529
		}
586
		}
(-)Eclipse UI/org/eclipse/ui/internal/messages.properties (+1 lines)
Lines 933-938 Link Here
933
ContentTypes_characterSetUpdateLabel = &Update
933
ContentTypes_characterSetUpdateLabel = &Update
934
ContentTypes_fileAssociationsLabel = &File associations:
934
ContentTypes_fileAssociationsLabel = &File associations:
935
ContentTypes_fileAssociationsAddLabel = &Add...
935
ContentTypes_fileAssociationsAddLabel = &Add...
936
ContentTypes_fileAssociationsEditLabel = E&dit...
936
ContentTypes_fileAssociationsRemoveLabel = &Remove
937
ContentTypes_fileAssociationsRemoveLabel = &Remove
937
ContentTypes_contentTypesLabel = &Content types:
938
ContentTypes_contentTypesLabel = &Content types:
938
ContentTypes_errorDialogMessage = There was an error removing content type file association(s).
939
ContentTypes_errorDialogMessage = There was an error removing content type file association(s).
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java (+1 lines)
Lines 933-938 Link Here
933
    public static String ContentTypes_characterSetUpdateLabel;
933
    public static String ContentTypes_characterSetUpdateLabel;
934
    public static String ContentTypes_fileAssociationsLabel;
934
    public static String ContentTypes_fileAssociationsLabel;
935
    public static String ContentTypes_fileAssociationsAddLabel;
935
    public static String ContentTypes_fileAssociationsAddLabel;
936
    public static String ContentTypes_fileAssociationsEditLabel;
936
    public static String ContentTypes_fileAssociationsRemoveLabel;
937
    public static String ContentTypes_fileAssociationsRemoveLabel;
937
    public static String ContentTypes_contentTypesLabel;
938
    public static String ContentTypes_contentTypesLabel;
938
    public static String ContentTypes_errorDialogMessage;
939
    public static String ContentTypes_errorDialogMessage;

Return to bug 97676