use of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo in project webtools.sourceediting by eclipse.
the class NamespaceInfoTable method performNew.
public void performNew() {
NamespaceInfo info = new NamespaceInfo();
EditNamespaceInfoDialog dialog = invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, info);
if (dialog.getReturnCode() == Window.OK) {
namespaceInfoList.add(info);
performDelayedUpdate();
}
}
use of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo in project webtools.sourceediting by eclipse.
the class NamespaceInfoTable method performEdit.
public void performEdit() {
ISelection selection = tableViewer.getSelection();
Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null;
if (selectedObject instanceof NamespaceInfo) {
invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, (NamespaceInfo) selectedObject);
performDelayedUpdate();
}
}
use of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo in project webtools.sourceediting by eclipse.
the class CommonAddNamespacesControl method getNamespaceInfoList.
public List getNamespaceInfoList() {
List list = new ArrayList();
if (radio1.getSelection()) {
TableItem[] items = tableViewer.getTable().getItems();
for (int i = 0; i < items.length; i++) {
TableItem item = items[i];
if (item.getChecked()) {
list.add(item.getData());
}
}
} else {
NamespaceInfo info = new NamespaceInfo();
info.prefix = editNamespaceControl.prefixField.getText();
info.uri = editNamespaceControl.uriField.getText();
info.locationHint = editNamespaceControl.locationHintField.getText();
list.add(info);
}
return list;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo in project webtools.sourceediting by eclipse.
the class CommonEditNamespacesDialog method updateButtonEnabledState.
public void updateButtonEnabledState() {
Object selection = getSelection(tableViewer.getSelection());
NamespaceInfo info = (NamespaceInfo) selection;
editButton.setEnabled(info != null);
// $NON-NLS-1$
deleteButton.setEnabled((info != null) && (info.getProperty("unremovable") == null));
}
use of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo in project webtools.sourceediting by eclipse.
the class EditNamespaceInfoDialog method performBrowse.
protected void performBrowse() {
// $NON-NLS-1$
String[] extensions = { ".xsd" };
SelectFileOrXMLCatalogIdDialog dialog = new SelectFileOrXMLCatalogIdDialog(getShell(), extensions);
dialog.create();
dialog.getShell().setText(XMLUIMessages._UI_LABEL_SELECT_FILE);
dialog.setBlockOnOpen(true);
dialog.open();
if (dialog.getReturnCode() == Window.OK) {
String grammarURI = null;
IFile file = dialog.getFile();
String id = dialog.getId();
if (file != null) {
String uri = null;
if (resourceLocation != null) {
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(resourceLocation);
if (resource != null) {
IPath location = resource.getLocation();
if (location != null) {
uri = URIHelper.getRelativeURI(file.getLocation(), location);
}
} else {
uri = URIHelper.getRelativeURI(file.getLocation(), resourceLocation);
}
grammarURI = file.getLocation().toOSString();
} else {
uri = file.getLocation().toOSString();
grammarURI = uri;
}
locationHintField.setText(uri);
} else if (id != null) {
locationHintField.setText(id);
URIResolver resolver = URIResolverPlugin.createResolver();
grammarURI = resolver.resolve(null, id, id);
}
// $NON-NLS-1$
CMDocument document = ContentModelManager.getInstance().createCMDocument(URIHelper.getURIForFilePath(grammarURI), "xsd");
if (document != null) {
// $NON-NLS-1$
List namespaceInfoList = (List) document.getProperty("http://org.eclipse.wst/cm/properties/namespaceInfo");
if (namespaceInfoList != null) {
NamespaceInfo info = (NamespaceInfo) namespaceInfoList.get(0);
if (info != null) {
if ((uriField.getText().trim().length() == 0) && (info.uri != null)) {
uriField.setText(info.uri);
}
if ((prefixField.getText().trim().length() == 0) && (info.prefix != null)) {
prefixField.setText(info.prefix);
}
}
}
}
}
}
Aggregations