}
protected void handleBrowserLayout(Text textControl) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(Display.getCurrent().getActiveShell(), new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
IFile syncInfo = ((IFileEditorInput)getEditorInput()).getFile();
WGADesignStructureHelper helper = new WGADesignStructureHelper(syncInfo);
dialog.setInput(helper.getTmlRoot());
dialog.setAllowMultiple(false);
dialog.setHelpAvailable(false);
dialog.setTitle("TML layout selection");
dialog.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
if (selection != null && selection.length == 1) {
if (selection[0] instanceof IFile) {
return new Status(Status.OK, Plugin.PLUGIN_ID, ((IFile)selection[0]).getFullPath().toString());
}
}
return new Status(Status.ERROR, Plugin.PLUGIN_ID, "Please select a tml layout file.");
}
});
// first try to find reference in medium "html" - otherwise check all available mediaKeys in design
IFile preSelection = helper.findReferencedTMLModule(textControl.getText(), "html");
if (preSelection == null) {
for (String mediaKey : helper.getMediaKeys()) {
preSelection = helper.findReferencedTMLModule(textControl.getText(), mediaKey);
if (preSelection != null) {
break;
}
}
}
if (preSelection != null) {
dialog.setInitialSelection(preSelection);
}
int result = dialog.open();
if (result == Dialog.OK) {
IFile selection = (IFile) dialog.getFirstResult();
textControl.setText(helper.computeTMLReference(selection));
}
}