|
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 |
} |