removed unused import, applied standard "cleanup" profile
diff --git a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/PatternMatcher.java b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/PatternMatcher.java index 7590f57..fa518e8 100644 --- a/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/PatternMatcher.java +++ b/bundles/org.eclipse.wst.xml.core/src-search/org/eclipse/wst/xml/core/internal/search/matching/PatternMatcher.java
@@ -14,7 +14,6 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.wst.common.core.search.SearchMatch; -import org.eclipse.wst.common.core.search.SearchParticipant; import org.eclipse.wst.common.core.search.SearchRequestor; import org.eclipse.wst.common.core.search.pattern.SearchPattern; import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; @@ -29,10 +28,10 @@ * <p> * Subclasses of the PatternMatches should be set as adapters for the patterns that they match. * </p> - * An implementation of {@link SearchParticipant#selectDocumentLocations()} will call + * An implementation of {@link org.eclipse.wst.common.core.search.SearchParticipant#selectDocumentLocations()} will call * { @link PatternMatcher#matches() } on the adapter on pattern matcher. * - * An implementation of {@link SearchParticipant#locateMatches()} will call + * An implementation of {@link org.eclipse.wst.common.core.search.SearchParticipant#locateMatches()} will call * { @link PatternMatcher#locateMatches() } on the adapter on pattern matcher. * */
diff --git a/bundles/org.eclipse.wst.xml.ui/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.wst.xml.ui/.settings/org.eclipse.jdt.ui.prefs index 301c7ad..0ece7b5 100644 --- a/bundles/org.eclipse.wst.xml.ui/.settings/org.eclipse.jdt.ui.prefs +++ b/bundles/org.eclipse.wst.xml.ui/.settings/org.eclipse.jdt.ui.prefs
@@ -1,4 +1,51 @@ -#Mon Apr 17 01:48:39 EDT 2006 +#Wed Nov 22 23:23:01 EST 2006 +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=false +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_serial_version_id=true +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=true +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.format_comment=true +cleanup.format_javadoc=true +cleanup.format_multi_line_comment=true +cleanup.format_single_line_comment=true +cleanup.format_source_code=true +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=true +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=false +cleanup.organize_imports=true +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=true +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=true +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_parentheses_in_expressions=true +cleanup.use_this_for_non_static_field_access=false +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=false +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup_profile=_SSE Team Styles +cleanup_settings_version=2 eclipse.preferences.version=1 internal.default.compliance=default org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<templates/>
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/AdvancedOptionsDialog.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/AdvancedOptionsDialog.java index bddc5fe..b2ae409 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/AdvancedOptionsDialog.java +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/AdvancedOptionsDialog.java
@@ -44,212 +44,186 @@ import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog; import org.eclipse.wst.xml.ui.internal.XMLUIPlugin; -public class AdvancedOptionsDialog extends Dialog -{ - protected ICatalog workingUserCatalog; +public class AdvancedOptionsDialog extends Dialog { + protected ICatalog workingUserCatalog; - public AdvancedOptionsDialog(Shell parentShell, ICatalog workingUserCatalog) - { - super(parentShell); - setShellStyle(getShellStyle() | SWT.RESIZE); - this.workingUserCatalog = workingUserCatalog; - } + public AdvancedOptionsDialog(Shell parentShell, ICatalog workingUserCatalog) { + super(parentShell); + setShellStyle(getShellStyle() | SWT.RESIZE); + this.workingUserCatalog = workingUserCatalog; + } - protected void createButtonsForButtonBar(Composite parent) - { - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - } + protected void createButtonsForButtonBar(Composite parent) { + createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); + } - protected Control createDialogArea(Composite parent) - { - Composite dialogArea = (Composite)super.createDialogArea(parent); -// WorkbenchHelp.setHelp(dialogArea, new ControlContextComputer(dialogArea, XMLBuilderContextIds.XMLP_PROJECT_DIALOG)); - - Composite composite = new Composite(dialogArea, SWT.NONE); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + protected Control createDialogArea(Composite parent) { + Composite dialogArea = (Composite) super.createDialogArea(parent); + // WorkbenchHelp.setHelp(dialogArea, new + // ControlContextComputer(dialogArea, + // XMLBuilderContextIds.XMLP_PROJECT_DIALOG)); - Label label = new Label(composite, SWT.NONE); - label.setText(XMLCatalogMessages.UI_LABEL_DIALOG_DESCRIPTION); - - Composite buttonComposite = new Composite(composite, SWT.NONE); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 3; - buttonComposite.setLayout(gridLayout); - buttonComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite placeHolder = new Composite(buttonComposite, SWT.NONE); - placeHolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite buttonGroup = new Composite(buttonComposite, SWT.NONE); - gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - gridLayout.makeColumnsEqualWidth = true; - buttonGroup.setLayout(gridLayout); - buttonGroup.setLayoutData(createGridData()); + Composite composite = new Composite(dialogArea, SWT.NONE); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - Button importButton = new Button(buttonGroup, SWT.PUSH | SWT.CENTER); - importButton.setText(" " + XMLCatalogMessages.UI_BUTTON_IMPORT + " "); //$NON-NLS-1$ //$NON-NLS-2$ + Label label = new Label(composite, SWT.NONE); + label.setText(XMLCatalogMessages.UI_LABEL_DIALOG_DESCRIPTION); - Button exportButton = new Button(buttonGroup, SWT.PUSH | SWT.CENTER); - exportButton.setText(" " + XMLCatalogMessages.UI_BUTTON_EXPORT + " "); //$NON-NLS-1$ //$NON-NLS-2$ + Composite buttonComposite = new Composite(composite, SWT.NONE); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 3; + buttonComposite.setLayout(gridLayout); + buttonComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - placeHolder = new Composite(buttonComposite, SWT.NONE); - placeHolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + Composite placeHolder = new Composite(buttonComposite, SWT.NONE); + placeHolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - // add importButton listener - SelectionListener importButtonSelectionListener = new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - invokeImportDialog(); - } - }; - importButton.addSelectionListener(importButtonSelectionListener); - - // add exportButton listener - SelectionListener exportButtonSelectionListener = new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - invokeExportDialog(); - } - }; - exportButton.addSelectionListener(exportButtonSelectionListener); + Composite buttonGroup = new Composite(buttonComposite, SWT.NONE); + gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + gridLayout.makeColumnsEqualWidth = true; + buttonGroup.setLayout(gridLayout); + buttonGroup.setLayoutData(createGridData()); - return dialogArea; - } - - protected GridData createGridData() - { - GridData gd = new GridData(GridData.CENTER); - gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_CENTER; - gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER; - return gd; - } - - - protected void invokeImportDialog() - { - SelectSingleFileDialog dialog = new SelectSingleFileDialog(getShell(), null, true); - String[] extensions = {".xmlcatalog", ".xml"}; //$NON-NLS-1$ //$NON-NLS-2$ - dialog.addFilterExtensions(extensions); - dialog.create(); - dialog.getShell().setText(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_TITLE); - dialog.setTitle(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_HEADING); - dialog.setMessage(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_MESSAGE); - dialog.setBlockOnOpen(true); - int rc = dialog.open(); - if (rc == Window.OK) - { - IFile file = dialog.getFile(); - if (file != null) - { - String fileName = file.getLocation().toFile().toURI().toString(); - try - { - CatalogSet tempResourceSet = new CatalogSet(); - ICatalog newCatalog = tempResourceSet.lookupOrCreateCatalog("temp", fileName); //$NON-NLS-1$ - workingUserCatalog.addEntriesFromCatalog(newCatalog); - } - catch (Exception e) - { - //TODO... give error message - } - } - close(); - } - } - + Button importButton = new Button(buttonGroup, SWT.PUSH | SWT.CENTER); + importButton.setText(" " + XMLCatalogMessages.UI_BUTTON_IMPORT + " "); //$NON-NLS-1$ //$NON-NLS-2$ - protected void invokeExportDialog() - { - IPath originalFilePath = null; - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - if (projects.length > 0) - { - originalFilePath = projects[0].getFullPath().append(".xmlcatalog"); //$NON-NLS-1$ - } - - SaveAsDialog dialog = new SaveAsDialog(getShell()); - if (originalFilePath != null) - { - IFile originalFile = ResourcesPlugin.getWorkspace().getRoot().getFile(originalFilePath); - dialog.setOriginalFile(originalFile); - } - dialog.create(); + Button exportButton = new Button(buttonGroup, SWT.PUSH | SWT.CENTER); + exportButton.setText(" " + XMLCatalogMessages.UI_BUTTON_EXPORT + " "); //$NON-NLS-1$ //$NON-NLS-2$ - dialog.getShell().setText(XMLCatalogMessages.UI_LABEL_EXPORT_DIALOG_TITLE); - dialog.setTitle(XMLCatalogMessages.UI_LABEL_EXPORT_DIALOG_HEADING); - dialog.setMessage(XMLCatalogMessages.UI_LABEL_EXPORT_DIALOG_MESSAGE); + placeHolder = new Composite(buttonComposite, SWT.NONE); + placeHolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - dialog.setBlockOnOpen(true); - int rc = dialog.open(); - if (rc == Window.OK) - { - IPath path = dialog.getResult(); - if (path != null) - { - IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); - String fileName = file.getLocation().toFile().toURI().toString(); - - // here we save the catalog entries to the selected file - try - { - createFileIfRequired(file); - workingUserCatalog.setLocation(fileName); - workingUserCatalog.save(); - } - catch (Exception ex) - { - try - { - String title = XMLCatalogMessages.UI_LABEL_CATALOG_SAVE_ERROR; - String briefMessage = XMLCatalogMessages.UI_LABEL_CATALOG_COULD_NOT_BE_SAVED; - String reason = file.isReadOnly() ? - NLS.bind(XMLCatalogMessages.UI_LABEL_FILE_IS_READ_ONLY, fileName) : - NLS.bind(XMLCatalogMessages.ERROR_SAVING_FILE, fileName); - String details = NLS.bind(XMLCatalogMessages.ERROR_SAVING_FILE, fileName); - - ErrorDialog.openError(Display.getCurrent().getActiveShell(), title, briefMessage, createStatus(reason, details)); - } - catch (Exception ex2) - { - } - } - close(); - } - } - } - - // TODO... This was copied from WindowUtility. Is there an easier way to create a status object? - // If not, we should open an eclipse bug or add a similar utility to baseExtensionsUI. - // - private static IStatus createStatus(String reason, String msg) - { - String pluginId = XMLUIPlugin.getDefault().getBundle().getSymbolicName(); - MultiStatus multiStatus = new MultiStatus(pluginId, 0, reason, null); - Status status = new Status(IStatus.ERROR, pluginId, 0, msg, null); - multiStatus.add(status); - return multiStatus; - } - + // add importButton listener + SelectionListener importButtonSelectionListener = new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + invokeImportDialog(); + } + }; + importButton.addSelectionListener(importButtonSelectionListener); - protected void createFileIfRequired(IFile file) - { - try - { - if (file != null && !file.exists()) - { - ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[0]); - file.create(inputStream, true, null); - //createEmptyXMLCatalog(file); - } - } - catch (Exception e) - { - } - } + // add exportButton listener + SelectionListener exportButtonSelectionListener = new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + invokeExportDialog(); + } + }; + exportButton.addSelectionListener(exportButtonSelectionListener); + + return dialogArea; + } + + protected GridData createGridData() { + GridData gd = new GridData(GridData.CENTER); + gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_CENTER; + gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER; + return gd; + } + + + protected void invokeImportDialog() { + SelectSingleFileDialog dialog = new SelectSingleFileDialog(getShell(), null, true); + String[] extensions = {".xmlcatalog", ".xml"}; //$NON-NLS-1$ //$NON-NLS-2$ + dialog.addFilterExtensions(extensions); + dialog.create(); + dialog.getShell().setText(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_TITLE); + dialog.setTitle(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_HEADING); + dialog.setMessage(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_MESSAGE); + dialog.setBlockOnOpen(true); + int rc = dialog.open(); + if (rc == Window.OK) { + IFile file = dialog.getFile(); + if (file != null) { + String fileName = file.getLocation().toFile().toURI().toString(); + try { + CatalogSet tempResourceSet = new CatalogSet(); + ICatalog newCatalog = tempResourceSet.lookupOrCreateCatalog("temp", fileName); //$NON-NLS-1$ + workingUserCatalog.addEntriesFromCatalog(newCatalog); + } + catch (Exception e) { + // TODO... give error message + } + } + close(); + } + } + + + protected void invokeExportDialog() { + IPath originalFilePath = null; + IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); + if (projects.length > 0) { + originalFilePath = projects[0].getFullPath().append(".xmlcatalog"); //$NON-NLS-1$ + } + + SaveAsDialog dialog = new SaveAsDialog(getShell()); + if (originalFilePath != null) { + IFile originalFile = ResourcesPlugin.getWorkspace().getRoot().getFile(originalFilePath); + dialog.setOriginalFile(originalFile); + } + dialog.create(); + + dialog.getShell().setText(XMLCatalogMessages.UI_LABEL_EXPORT_DIALOG_TITLE); + dialog.setTitle(XMLCatalogMessages.UI_LABEL_EXPORT_DIALOG_HEADING); + dialog.setMessage(XMLCatalogMessages.UI_LABEL_EXPORT_DIALOG_MESSAGE); + + dialog.setBlockOnOpen(true); + int rc = dialog.open(); + if (rc == Window.OK) { + IPath path = dialog.getResult(); + if (path != null) { + IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); + String fileName = file.getLocation().toFile().toURI().toString(); + + // here we save the catalog entries to the selected file + try { + createFileIfRequired(file); + workingUserCatalog.setLocation(fileName); + workingUserCatalog.save(); + } + catch (Exception ex) { + try { + String title = XMLCatalogMessages.UI_LABEL_CATALOG_SAVE_ERROR; + String briefMessage = XMLCatalogMessages.UI_LABEL_CATALOG_COULD_NOT_BE_SAVED; + String reason = file.isReadOnly() ? NLS.bind(XMLCatalogMessages.UI_LABEL_FILE_IS_READ_ONLY, fileName) : NLS.bind(XMLCatalogMessages.ERROR_SAVING_FILE, fileName); + String details = NLS.bind(XMLCatalogMessages.ERROR_SAVING_FILE, fileName); + + ErrorDialog.openError(Display.getCurrent().getActiveShell(), title, briefMessage, createStatus(reason, details)); + } + catch (Exception ex2) { + } + } + close(); + } + } + } + + // TODO... This was copied from WindowUtility. Is there an easier way to + // create a status object? + // If not, we should open an eclipse bug or add a similar utility to + // baseExtensionsUI. + // + private static IStatus createStatus(String reason, String msg) { + String pluginId = XMLUIPlugin.getDefault().getBundle().getSymbolicName(); + MultiStatus multiStatus = new MultiStatus(pluginId, 0, reason, null); + Status status = new Status(IStatus.ERROR, pluginId, 0, msg, null); + multiStatus.add(status); + return multiStatus; + } + + + protected void createFileIfRequired(IFile file) { + try { + if ((file != null) && !file.exists()) { + ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[0]); + file.create(inputStream, true, null); + // createEmptyXMLCatalog(file); + } + } + catch (Exception e) { + } + } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/CatalogFileTypeRegistryReader.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/CatalogFileTypeRegistryReader.java index ce4a8d8..8bbb158 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/CatalogFileTypeRegistryReader.java +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/CatalogFileTypeRegistryReader.java
@@ -36,8 +36,9 @@ static final String TAG_NAME = "fileType"; //$NON-NLS-1$ private static CatalogFileTypeRegistryReader getInstance() { - if (_instance == null) + if (_instance == null) { _instance = new CatalogFileTypeRegistryReader(); + } return _instance; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/EditCatalogEntryDialog.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/EditCatalogEntryDialog.java index 376674e..13731d9 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/EditCatalogEntryDialog.java +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/EditCatalogEntryDialog.java
@@ -88,27 +88,29 @@ if (errorMessage == null) { String fileName = resourceLocationField.getText(); if (fileName.trim().length() > 0) { - if (fileName.indexOf("..") != -1 || fileName.indexOf("./") != -1 || fileName.indexOf("/.") != -1 || fileName.indexOf(".\\") != -1 || fileName.indexOf("\\.") != -1) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + if ((fileName.indexOf("..") != -1) || (fileName.indexOf("./") != -1) || (fileName.indexOf("/.") != -1) || (fileName.indexOf(".\\") != -1) || (fileName.indexOf("\\.") != -1)) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ errorMessage = XMLCatalogMessages.UI_WARNING_URI_MUST_NOT_HAVE_DOTS; } String uri = fileName; if (!URIHelper.hasProtocol(uri)) { - URIHelper.isAbsolute(uri); + URIHelper.isAbsolute(uri); uri = (URIHelper.isAbsolute(uri)) ? URIHelper.prependFileProtocol(uri) : URIHelper.prependPlatformResourceProtocol(uri); } - if (errorMessage == null && !URIHelper.isReadableURI(uri, false)) { + if ((errorMessage == null) && !URIHelper.isReadableURI(uri, false)) { errorMessage = XMLCatalogMessages.UI_WARNING_URI_NOT_FOUND_COLON + fileName; } - } else { + } + else { // this an error that is not actaully // reported ... OK is just disabled - errorMessage = ""; //$NON-NLS-1$ + errorMessage = ""; //$NON-NLS-1$ } - // Make sure the key is a fully qualified URI in the cases where the key type is "System ID" or "Schema location" - if (keyField.getText().length() > 0 && getKeyType() == ICatalogEntry.ENTRY_TYPE_SYSTEM ) { + // Make sure the key is a fully qualified URI in the cases + // where the key type is "System ID" or "Schema location" + if ((keyField.getText().length() > 0) && (getKeyType() == ICatalogEntry.ENTRY_TYPE_SYSTEM)) { URI uri = URI.createURI(keyField.getText()); if (uri.scheme() == null) { warningMessage = XMLCatalogMessages.UI_WARNING_SHOULD_BE_FULLY_QUALIFIED_URI; @@ -116,16 +118,16 @@ } } - if (errorMessage == null && checkboxButton.getSelection() && webAddressField.getText().trim().length() == 0) { + if ((errorMessage == null) && checkboxButton.getSelection() && (webAddressField.getText().trim().length() == 0)) { // this an error that is not actaully // reported ... OK is just disabled - errorMessage = ""; //$NON-NLS-1$ + errorMessage = ""; //$NON-NLS-1$ } - if (errorMessage == null && keyField.getText().trim().length() == 0) { + if ((errorMessage == null) && (keyField.getText().trim().length() == 0)) { // this an error that is not actaully // reported ... OK is just disabled - errorMessage = ""; //$NON-NLS-1$ + errorMessage = ""; //$NON-NLS-1$ } } @@ -172,7 +174,7 @@ gd.horizontalAlignment = SWT.FILL; gd.grabExcessHorizontalSpace = true; resourceLocationField.setLayoutData(gd); - + resourceLocationField.setText(getDisplayValue(URIHelper.URIToLocation(getEntry().getURI()))); // WorkbenchHelp.setHelp(resourceLocationField, @@ -286,7 +288,7 @@ protected ICatalogEntry getEntry() { if (catalogEntry == null) { - if (fCatalogElement != null && fCatalogElement.getType() == ICatalogElement.TYPE_ENTRY) { + if ((fCatalogElement != null) && (fCatalogElement.getType() == ICatalogElement.TYPE_ENTRY)) { catalogEntry = (ICatalogEntry) fCatalogElement; } else { @@ -302,7 +304,10 @@ switch (keyTypeCombo.getSelectionIndex()) { case 0 : if ("schema".equals(keyTypeCombo.getData("keyType"))) { //$NON-NLS-1$ //$NON-NLS-2$ - return ICatalogEntry.ENTRY_TYPE_URI; // xsd namespace is URI type key + return ICatalogEntry.ENTRY_TYPE_URI; // xsd + // namespace + // is URI type + // key } return ICatalogEntry.ENTRY_TYPE_PUBLIC; case 1 : @@ -349,14 +354,11 @@ } } if (keyTypeCombo.getItemCount() == 0) { - keyTypeCombo.add(XMLCatalogMessages. - UI_KEY_TYPE_DESCRIPTION_DTD_PUBLIC); - keyTypeCombo.add(XMLCatalogMessages. - UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM); - keyTypeCombo.add(XMLCatalogMessages. - UI_KEY_TYPE_DESCRIPTION_URI); + keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_PUBLIC); + keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM); + keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_URI); } - + switch (type) { case ICatalogEntry.ENTRY_TYPE_PUBLIC : keyTypeCombo.select(0); @@ -364,9 +366,12 @@ case ICatalogEntry.ENTRY_TYPE_SYSTEM : keyTypeCombo.select(1); break; - case ICatalogEntry.ENTRY_TYPE_URI: // handle XML Schema, where namespace name is mapped to URI situation + case ICatalogEntry.ENTRY_TYPE_URI : // handle XML Schema, + // where namespace name is + // mapped to URI situation if ("schema".equals(keyTypeCombo.getData("keyType"))) { //$NON-NLS-1$ //$NON-NLS-2$ - keyTypeCombo.select(0); // namespace name as URI key type + keyTypeCombo.select(0); // namespace name as URI key + // type } else { keyTypeCombo.select(2); // URI key type @@ -503,7 +508,7 @@ if (errorMessage == null) { String fileName = catalogLocationField.getText(); if (fileName.trim().length() > 0) { - if (fileName.indexOf("..") != -1 || fileName.indexOf("./") != -1 || fileName.indexOf("/.") != -1 || fileName.indexOf(".\\") != -1 || fileName.indexOf("\\.") != -1) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + if ((fileName.indexOf("..") != -1) || (fileName.indexOf("./") != -1) || (fileName.indexOf("/.") != -1) || (fileName.indexOf(".\\") != -1) || (fileName.indexOf("\\.") != -1)) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ errorMessage = XMLCatalogMessages.UI_WARNING_URI_MUST_NOT_HAVE_DOTS; } @@ -512,12 +517,12 @@ uri = URIHelper.isAbsolute(uri) ? URIHelper.prependFileProtocol(uri) : URIHelper.prependPlatformResourceProtocol(uri); } - if (errorMessage == null && !URIHelper.isReadableURI(uri, false)) { + if ((errorMessage == null) && !URIHelper.isReadableURI(uri, false)) { errorMessage = XMLCatalogMessages.UI_WARNING_URI_NOT_FOUND_COLON + fileName; } } else { - // this an error that is not actually + // this an error that is not actually // reported ... OK is just disabled errorMessage = ""; //$NON-NLS-1$ } @@ -580,7 +585,7 @@ protected INextCatalog getNextCatalog() { if (nextCatalog == null) { - if (fCatalogElement != null && fCatalogElement.getType() == ICatalogElement.TYPE_NEXT_CATALOG) { + if ((fCatalogElement != null) && (fCatalogElement.getType() == ICatalogElement.TYPE_NEXT_CATALOG)) { nextCatalog = (INextCatalog) fCatalogElement; } else { @@ -647,7 +652,7 @@ protected ICatalogElement fCatalogElement; protected String errorMessage; - + protected String warningMessage; protected Button okButton; @@ -659,7 +664,7 @@ // protected TreeViewer treeViewer; protected ToolBar toolBar; - + protected Color color; public EditCatalogEntryDialog(Shell parentShell, ICatalog aCatalog) { @@ -750,7 +755,7 @@ return composite1; } return createMainComponentWithToolbar(composite); - + } protected Composite createMainComponentWithToolbar(Composite composite) { @@ -826,7 +831,7 @@ XMLCatalogFileType fileType = null; for (Iterator i = CatalogFileTypeRegistryReader.getXMLCatalogFileTypes().iterator(); i.hasNext();) { XMLCatalogFileType theFileType = (XMLCatalogFileType) i.next(); - if (theFileType.description != null && theFileType.description.equals(description)) { + if ((theFileType.description != null) && theFileType.description.equals(description)) { fileType = theFileType; } } @@ -845,11 +850,15 @@ } protected void updateErrorMessageLabel(Label errorMessageLabel) { - if(errorMessage != null) - errorMessageLabel.setText(errorMessage); - else if (warningMessage != null) + if (errorMessage != null) { + errorMessageLabel.setText(errorMessage); + } + else if (warningMessage != null) { errorMessageLabel.setText(warningMessage); - else errorMessageLabel.setText(""); + } + else { + errorMessageLabel.setText(""); + } } protected void updateOKButtonState() { @@ -960,7 +969,7 @@ void invokeFileSelectionDialog() { FileDialog dialog = new FileDialog(getShell(), SWT.SINGLE); String file = dialog.open(); - if (control instanceof Text && file != null) { + if ((control instanceof Text) && (file != null)) { ((Text) control).setText(file); } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ElementNodePage.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ElementNodePage.java index dae891b..b42db2e 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ElementNodePage.java +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ElementNodePage.java
@@ -18,21 +18,21 @@ public abstract class ElementNodePage { - + Control fControl; - + public ElementNodePage() { super(); - + } - + public abstract Control createControl(Composite parent); - - public Control getControl(){ + + public Control getControl() { return fControl; } - + public abstract void saveData(); - + public abstract ICatalogElement getData(); }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ImageFactory.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ImageFactory.java index 1c48654..a38ba6f 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ImageFactory.java +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ImageFactory.java
@@ -22,184 +22,180 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.wst.xml.ui.internal.XMLUIPlugin; -public class ImageFactory -{ - public static final int TOP_LEFT = 1; - public static final int TOP_RIGHT = 2; - public static final int BOTTOM_LEFT = 3; - public static final int BOTTOM_RIGHT = 4; +public class ImageFactory { + public static final int TOP_LEFT = 1; + public static final int TOP_RIGHT = 2; + public static final int BOTTOM_LEFT = 3; + public static final int BOTTOM_RIGHT = 4; - protected static final int[][] OVERLAY_COORDINATE = {{0,0},{0,2},{2,0},{2,2}}; - - protected static ImageFactory INSTANCE = new ImageFactory(); + protected static final int[][] OVERLAY_COORDINATE = {{0, 0}, {0, 2}, {2, 0}, {2, 2}}; - protected Hashtable compositeImageTable = new Hashtable(); + protected static ImageFactory INSTANCE = new ImageFactory(); - public ImageFactory() - { - super(); - } - - public Image getImage(String iconName) - { - ImageRegistry imageRegistry = XMLUIPlugin.getDefault().getImageRegistry(); - - if (imageRegistry.get(iconName) != null) - { - return imageRegistry.get(iconName); - } - else - { - imageRegistry.put(iconName, ImageDescriptor.createFromFile(getClass(), iconName)); - return imageRegistry.get(iconName); - } + protected Hashtable compositeImageTable = new Hashtable(); + + public ImageFactory() { + super(); } - public Image createCompositeImage(Image base, Image overlay, int overlayPosition) - { - String key = base + "*" + overlay + "*" + overlayPosition; //$NON-NLS-1$ //$NON-NLS-2$ - Image result = (Image)compositeImageTable.get(key); - if (result == null) - { - ImageDescriptor overlays[][] = new ImageDescriptor[3][3]; - int[] coord = OVERLAY_COORDINATE[overlayPosition]; - overlays[coord[1]][coord[0]] = new ImageBasedImageDescriptor(overlay); - OverlayIcon icon = new OverlayIcon(new ImageBasedImageDescriptor(base), overlays, new Point(16, 16)); - result = icon.createImage(); - compositeImageTable.put(key, result); - } - return result; - } + public Image getImage(String iconName) { + ImageRegistry imageRegistry = XMLUIPlugin.getDefault().getImageRegistry(); + + if (imageRegistry.get(iconName) != null) { + return imageRegistry.get(iconName); + } + else { + imageRegistry.put(iconName, ImageDescriptor.createFromFile(getClass(), iconName)); + return imageRegistry.get(iconName); + } + } + + public Image createCompositeImage(Image base, Image overlay, int overlayPosition) { + String key = base + "*" + overlay + "*" + overlayPosition; //$NON-NLS-1$ //$NON-NLS-2$ + Image result = (Image) compositeImageTable.get(key); + if (result == null) { + ImageDescriptor overlays[][] = new ImageDescriptor[3][3]; + int[] coord = OVERLAY_COORDINATE[overlayPosition]; + overlays[coord[1]][coord[0]] = new ImageBasedImageDescriptor(overlay); + OverlayIcon icon = new OverlayIcon(new ImageBasedImageDescriptor(base), overlays, new Point(16, 16)); + result = icon.createImage(); + compositeImageTable.put(key, result); + } + return result; + } - public static ImageDescriptor createImageDescriptorWrapper(Image image) - { - return new ImageBasedImageDescriptor(image); - } + public static ImageDescriptor createImageDescriptorWrapper(Image image) { + return new ImageBasedImageDescriptor(image); + } - /** - * An OverlayIcon consists of a main icon and several adornments. - */ - class OverlayIcon extends CompositeImageDescriptor { + /** + * An OverlayIcon consists of a main icon and several adornments. + */ + class OverlayIcon extends CompositeImageDescriptor { - static final int DEFAULT_WIDTH = 22; + static final int DEFAULT_WIDTH = 22; - static final int DEFAULT_HEIGHT = 16; + static final int DEFAULT_HEIGHT = 16; - private Point fSize = null; + private Point fSize = null; - private ImageDescriptor fBase; + private ImageDescriptor fBase; - private ImageDescriptor fOverlays[][]; + private ImageDescriptor fOverlays[][]; - public OverlayIcon(ImageDescriptor base, ImageDescriptor[][] overlays, - Point size) { - fBase = base; - fOverlays = overlays; - fSize = size; - } + public OverlayIcon(ImageDescriptor base, ImageDescriptor[][] overlays, Point size) { + fBase = base; + fOverlays = overlays; + fSize = size; + } - protected void drawBottomLeft(ImageDescriptor[] overlays) { - if (overlays == null) - return; - int length = overlays.length; - int x = 0; - for (int i = 0; i < 3; i++) { - if (i < length && overlays[i] != null) { - ImageData id = overlays[i].getImageData(); - drawImage(id, x, getSize().y - id.height); - x += id.width; - } - } - } + protected void drawBottomLeft(ImageDescriptor[] overlays) { + if (overlays == null) { + return; + } + int length = overlays.length; + int x = 0; + for (int i = 0; i < 3; i++) { + if ((i < length) && (overlays[i] != null)) { + ImageData id = overlays[i].getImageData(); + drawImage(id, x, getSize().y - id.height); + x += id.width; + } + } + } - protected void drawBottomRight(ImageDescriptor[] overlays) { - if (overlays == null) - return; - int length = overlays.length; - int x = getSize().x; - for (int i = 2; i >= 0; i--) { - if (i < length && overlays[i] != null) { - ImageData id = overlays[i].getImageData(); - x -= id.width; - drawImage(id, x, getSize().y - id.height); - } - } - } + protected void drawBottomRight(ImageDescriptor[] overlays) { + if (overlays == null) { + return; + } + int length = overlays.length; + int x = getSize().x; + for (int i = 2; i >= 0; i--) { + if ((i < length) && (overlays[i] != null)) { + ImageData id = overlays[i].getImageData(); + x -= id.width; + drawImage(id, x, getSize().y - id.height); + } + } + } - /** - * @see CompositeImageDescriptor#drawCompositeImage(int, int) - */ - protected void drawCompositeImage(int width, int height) { - ImageData bg; - if (fBase == null || (bg = fBase.getImageData()) == null) - bg = DEFAULT_IMAGE_DATA; - drawImage(bg, 0, 0); + /** + * @see CompositeImageDescriptor#drawCompositeImage(int, int) + */ + protected void drawCompositeImage(int width, int height) { + ImageData bg; + if ((fBase == null) || ((bg = fBase.getImageData()) == null)) { + bg = DEFAULT_IMAGE_DATA; + } + drawImage(bg, 0, 0); - if (fOverlays != null) { - if (fOverlays.length > 0) - drawTopRight(fOverlays[0]); + if (fOverlays != null) { + if (fOverlays.length > 0) { + drawTopRight(fOverlays[0]); + } - if (fOverlays.length > 1) - drawBottomRight(fOverlays[1]); + if (fOverlays.length > 1) { + drawBottomRight(fOverlays[1]); + } - if (fOverlays.length > 2) - drawBottomLeft(fOverlays[2]); + if (fOverlays.length > 2) { + drawBottomLeft(fOverlays[2]); + } - if (fOverlays.length > 3) - drawTopLeft(fOverlays[3]); - } - } + if (fOverlays.length > 3) { + drawTopLeft(fOverlays[3]); + } + } + } - protected void drawTopLeft(ImageDescriptor[] overlays) { - if (overlays == null) - return; - int length = overlays.length; - int x = 0; - for (int i = 0; i < 3; i++) { - if (i < length && overlays[i] != null) { - ImageData id = overlays[i].getImageData(); - drawImage(id, x, 0); - x += id.width; - } - } - } + protected void drawTopLeft(ImageDescriptor[] overlays) { + if (overlays == null) { + return; + } + int length = overlays.length; + int x = 0; + for (int i = 0; i < 3; i++) { + if ((i < length) && (overlays[i] != null)) { + ImageData id = overlays[i].getImageData(); + drawImage(id, x, 0); + x += id.width; + } + } + } - protected void drawTopRight(ImageDescriptor[] overlays) { - if (overlays == null) - return; - int length = overlays.length; - int x = getSize().x; - for (int i = 2; i >= 0; i--) { - if (i < length && overlays[i] != null) { - ImageData id = overlays[i].getImageData(); - x -= id.width; - drawImage(id, x, 0); - } - } - } + protected void drawTopRight(ImageDescriptor[] overlays) { + if (overlays == null) { + return; + } + int length = overlays.length; + int x = getSize().x; + for (int i = 2; i >= 0; i--) { + if ((i < length) && (overlays[i] != null)) { + ImageData id = overlays[i].getImageData(); + x -= id.width; + drawImage(id, x, 0); + } + } + } - /** - * @see CompositeImageDescriptor#getSize() - */ - protected Point getSize() { - return fSize; - } - } + /** + * @see CompositeImageDescriptor#getSize() + */ + protected Point getSize() { + return fSize; + } + } - static class ImageBasedImageDescriptor extends ImageDescriptor - { - protected Image image; + static class ImageBasedImageDescriptor extends ImageDescriptor { + protected Image image; - public ImageBasedImageDescriptor(Image image) - { - this.image = image; - } + public ImageBasedImageDescriptor(Image image) { + this.image = image; + } - public ImageData getImageData() - { - return image.getImageData(); - } - } + public ImageData getImageData() { + return image.getImageData(); + } + } } -
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntriesView.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntriesView.java index 45706a2..829d595 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntriesView.java +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntriesView.java
@@ -36,271 +36,249 @@ -public class XMLCatalogEntriesView extends Composite -{ - protected Button newButton; - protected Button editButton; - protected Button deleteButton; - protected XMLCatalogTreeViewer tableViewer; - protected ICatalog workingUserCatalog; - protected ICatalog systemCatalog; - //protected boolean isPageEnabled = true; +public class XMLCatalogEntriesView extends Composite { + protected Button newButton; + protected Button editButton; + protected Button deleteButton; + protected XMLCatalogTreeViewer tableViewer; + protected ICatalog workingUserCatalog; + protected ICatalog systemCatalog; - public XMLCatalogEntriesView(Composite parent, ICatalog workingUserCatalog, ICatalog systemCatalog) - { - super(parent, SWT.NONE); - this.workingUserCatalog = workingUserCatalog; - this.systemCatalog = systemCatalog; + // protected boolean isPageEnabled = true; - GridLayout gridLayout = new GridLayout(); - this.setLayout(gridLayout); + public XMLCatalogEntriesView(Composite parent, ICatalog workingUserCatalog, ICatalog systemCatalog) { + super(parent, SWT.NONE); + this.workingUserCatalog = workingUserCatalog; + this.systemCatalog = systemCatalog; - tableViewer = createTableViewer(this); - tableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); - tableViewer.setInput("dummy"); //$NON-NLS-1$ - tableViewer.expandToLevel(2); - tableViewer.reveal(XMLCatalogTreeViewer.USER_SPECIFIED_ENTRIES_OBJECT); + GridLayout gridLayout = new GridLayout(); + this.setLayout(gridLayout); - ISelectionChangedListener listener = new ISelectionChangedListener() - { - public void selectionChanged(SelectionChangedEvent event) - { - updateWidgetEnabledState(); - } - }; - tableViewer.addSelectionChangedListener(listener); + tableViewer = createTableViewer(this); + tableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); + tableViewer.setInput("dummy"); //$NON-NLS-1$ + tableViewer.expandToLevel(2); + tableViewer.reveal(XMLCatalogTreeViewer.USER_SPECIFIED_ENTRIES_OBJECT); - createButtons(this); - } + ISelectionChangedListener listener = new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + updateWidgetEnabledState(); + } + }; + tableViewer.addSelectionChangedListener(listener); - public static String removeLeadingSlash(String uri) - { - // remove leading slash from the value to avoid the whole leading slash ambiguity problem - // - if (uri != null) - { - while (uri.startsWith("/") || uri.startsWith("\\")) //$NON-NLS-1$ //$NON-NLS-2$ - { - uri = uri.substring(1); - } - } - return uri; - } + createButtons(this); + } - protected XMLCatalogTreeViewer createTableViewer(Composite parent) - { - String headings[] = new String[2]; - headings[0] = XMLCatalogMessages.UI_LABEL_KEY; - headings[1] = XMLCatalogMessages.UI_LABEL_URI; + public static String removeLeadingSlash(String uri) { + // remove leading slash from the value to avoid the whole leading + // slash ambiguity problem + // + if (uri != null) { + while (uri.startsWith("/") || uri.startsWith("\\")) //$NON-NLS-1$ //$NON-NLS-2$ + { + uri = uri.substring(1); + } + } + return uri; + } - XMLCatalogTreeViewer theTableViewer = new XMLCatalogTreeViewer(parent, workingUserCatalog, systemCatalog); - return theTableViewer; - } + protected XMLCatalogTreeViewer createTableViewer(Composite parent) { + String headings[] = new String[2]; + headings[0] = XMLCatalogMessages.UI_LABEL_KEY; + headings[1] = XMLCatalogMessages.UI_LABEL_URI; - protected void createButtons(Composite parent) - { - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 7; - gridLayout.makeColumnsEqualWidth = true; - composite.setLayout(gridLayout); + XMLCatalogTreeViewer theTableViewer = new XMLCatalogTreeViewer(parent, workingUserCatalog, systemCatalog); + return theTableViewer; + } - GridData gd = new GridData(); - gd.horizontalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; - gd.horizontalSpan = 4; + protected void createButtons(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 7; + gridLayout.makeColumnsEqualWidth = true; + composite.setLayout(gridLayout); - Button hiddenButton = new Button(composite, SWT.NONE); - hiddenButton.setLayoutData(gd); - hiddenButton.setVisible(false); - hiddenButton.setEnabled(false); + GridData gd = new GridData(); + gd.horizontalAlignment = GridData.FILL; + gd.grabExcessHorizontalSpace = true; + gd.horizontalSpan = 4; - SelectionListener selectionListener = new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - if (e.widget == newButton) - { - performNew(); - } - else if (e.widget == editButton) - { - performEdit(); - } - else if (e.widget == deleteButton) - { - performDelete(); - } - } - }; + Button hiddenButton = new Button(composite, SWT.NONE); + hiddenButton.setLayoutData(gd); + hiddenButton.setVisible(false); + hiddenButton.setEnabled(false); - // add the "New..." button - // - gd = new GridData(); - gd.horizontalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; + SelectionListener selectionListener = new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + if (e.widget == newButton) { + performNew(); + } + else if (e.widget == editButton) { + performEdit(); + } + else if (e.widget == deleteButton) { + performDelete(); + } + } + }; - newButton = new Button(composite, SWT.NONE); - newButton.setText(XMLCatalogMessages.UI_BUTTON_NEW); - //WorkbenchHelp.setHelp(newButton, XMLBuilderContextIds.XMLP_MAPPING_NEW); - newButton.setLayoutData(gd); - newButton.addSelectionListener(selectionListener); + // add the "New..." button + // + gd = new GridData(); + gd.horizontalAlignment = GridData.FILL; + gd.grabExcessHorizontalSpace = true; - // add the "Edit..." button - // - gd = new GridData(); - gd.horizontalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; - editButton = new Button(composite, SWT.NONE); - editButton.setText(XMLCatalogMessages.UI_BUTTON_EDIT); - //WorkbenchHelp.setHelp(editButton, XMLBuilderContextIds.XMLP_MAPPING_EDIT); - editButton.setLayoutData(gd); - editButton.addSelectionListener(selectionListener); + newButton = new Button(composite, SWT.NONE); + newButton.setText(XMLCatalogMessages.UI_BUTTON_NEW); + // WorkbenchHelp.setHelp(newButton, + // XMLBuilderContextIds.XMLP_MAPPING_NEW); + newButton.setLayoutData(gd); + newButton.addSelectionListener(selectionListener); - // add the "Delete" button - // - gd = new GridData(); - gd.horizontalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; - deleteButton = new Button(composite, SWT.NONE); - deleteButton.setText(XMLCatalogMessages.UI_BUTTON_DELETE); - //WorkbenchHelp.setHelp(deleteButton, XMLBuilderContextIds.XMLP_MAPPING_DELETE); - deleteButton.setLayoutData(gd); - deleteButton.addSelectionListener(selectionListener); + // add the "Edit..." button + // + gd = new GridData(); + gd.horizontalAlignment = GridData.FILL; + gd.grabExcessHorizontalSpace = true; + editButton = new Button(composite, SWT.NONE); + editButton.setText(XMLCatalogMessages.UI_BUTTON_EDIT); + // WorkbenchHelp.setHelp(editButton, + // XMLBuilderContextIds.XMLP_MAPPING_EDIT); + editButton.setLayoutData(gd); + editButton.addSelectionListener(selectionListener); - // a cruddy hack so that the PreferenceDialog doesn't close every time we press 'enter' - // - getShell().setDefaultButton(hiddenButton); - updateWidgetEnabledState(); - } + // add the "Delete" button + // + gd = new GridData(); + gd.horizontalAlignment = GridData.FILL; + gd.grabExcessHorizontalSpace = true; + deleteButton = new Button(composite, SWT.NONE); + deleteButton.setText(XMLCatalogMessages.UI_BUTTON_DELETE); + // WorkbenchHelp.setHelp(deleteButton, + // XMLBuilderContextIds.XMLP_MAPPING_DELETE); + deleteButton.setLayoutData(gd); + deleteButton.addSelectionListener(selectionListener); - public void refresh() - { - tableViewer.refresh();//XMLCatalogTreeViewer.USER_SPECIFIED_ENTRIES_OBJECT); - } + // a cruddy hack so that the PreferenceDialog doesn't close every time + // we press 'enter' + // + getShell().setDefaultButton(hiddenButton); + updateWidgetEnabledState(); + } - protected EditCatalogEntryDialog invokeDialog(String title, ICatalogElement entry) - { - Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell(); - EditCatalogEntryDialog dialog = new EditCatalogEntryDialog(shell, entry); - dialog.create(); - dialog.getShell().setText(title); - dialog.setBlockOnOpen(true); - dialog.open(); - return dialog; - } - - protected EditCatalogEntryDialog invokeDialog(String title, ICatalog catalog) - { - Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell(); - EditCatalogEntryDialog dialog = new EditCatalogEntryDialog(shell, catalog); - dialog.create(); - dialog.getShell().setText(title); - dialog.setBlockOnOpen(true); - dialog.open(); - return dialog; - } - + public void refresh() { + tableViewer.refresh();// XMLCatalogTreeViewer.USER_SPECIFIED_ENTRIES_OBJECT); + } - protected void performNew() - { + protected EditCatalogEntryDialog invokeDialog(String title, ICatalogElement entry) { + Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell(); + EditCatalogEntryDialog dialog = new EditCatalogEntryDialog(shell, entry); + dialog.create(); + dialog.getShell().setText(title); + dialog.setBlockOnOpen(true); + dialog.open(); + return dialog; + } - //ICatalogEntry newEntry = (ICatalogEntry)workingUserCatalog.createCatalogElement(ICatalogElement.TYPE_ENTRY); - EditCatalogEntryDialog dialog = invokeDialog(XMLCatalogMessages.UI_LABEL_NEW_DIALOG_TITLE, workingUserCatalog); - ICatalogElement element = dialog.getCatalogElement(); - if (dialog.getReturnCode() == Window.OK) - { - workingUserCatalog.addCatalogElement(element); - tableViewer.setSelection(new StructuredSelection(element), true); - tableViewer.refresh(); - } - } + protected EditCatalogEntryDialog invokeDialog(String title, ICatalog catalog) { + Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell(); + EditCatalogEntryDialog dialog = new EditCatalogEntryDialog(shell, catalog); + dialog.create(); + dialog.getShell().setText(title); + dialog.setBlockOnOpen(true); + dialog.open(); + return dialog; + } - protected void performEdit() - { - ISelection selection = tableViewer.getSelection(); - Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null; - if (selectedObject instanceof ICatalogElement) - { - ICatalogElement oldEntry = (ICatalogElement) selectedObject; - ICatalogElement newEntry = (ICatalogElement)((CatalogElement)oldEntry).clone(); + protected void performNew() { - EditCatalogEntryDialog dialog = invokeDialog(XMLCatalogMessages.UI_LABEL_EDIT_DIALOG_TITLE, newEntry); - if (dialog.getReturnCode() == Window.OK) - { - // delete the old value if the 'mapFrom' has changed - // - workingUserCatalog.removeCatalogElement(oldEntry); + // ICatalogEntry newEntry = + // (ICatalogEntry)workingUserCatalog.createCatalogElement(ICatalogElement.TYPE_ENTRY); + EditCatalogEntryDialog dialog = invokeDialog(XMLCatalogMessages.UI_LABEL_NEW_DIALOG_TITLE, workingUserCatalog); + ICatalogElement element = dialog.getCatalogElement(); + if (dialog.getReturnCode() == Window.OK) { + workingUserCatalog.addCatalogElement(element); + tableViewer.setSelection(new StructuredSelection(element), true); + tableViewer.refresh(); + } + } - // update the new mapping - // - workingUserCatalog.addCatalogElement(newEntry); - tableViewer.setSelection(new StructuredSelection(newEntry)); - } - } - } + protected void performEdit() { + ISelection selection = tableViewer.getSelection(); + Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null; - protected void performDelete() - { - ISelection selection = tableViewer.getSelection(); - Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null; + if (selectedObject instanceof ICatalogElement) { + ICatalogElement oldEntry = (ICatalogElement) selectedObject; + ICatalogElement newEntry = (ICatalogElement) ((CatalogElement) oldEntry).clone(); - if (selectedObject instanceof ICatalogElement) - { - ICatalogElement catalogElement = (ICatalogElement) selectedObject; - workingUserCatalog.removeCatalogElement(catalogElement); - } - } + EditCatalogEntryDialog dialog = invokeDialog(XMLCatalogMessages.UI_LABEL_EDIT_DIALOG_TITLE, newEntry); + if (dialog.getReturnCode() == Window.OK) { + // delete the old value if the 'mapFrom' has changed + // + workingUserCatalog.removeCatalogElement(oldEntry); - protected void updateWidgetEnabledState() - { - boolean isEditable = false; - ISelection selection = tableViewer.getSelection(); - Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null; - - if (selectedObject instanceof ICatalogElement) - { - ICatalogElement[] elements = ((Catalog)workingUserCatalog).getCatalogElements(); - //dw List entriesList = new ArrayList(elements.length); - for (int i = 0; i < elements.length; i++) - { - ICatalogElement element = elements[i]; - isEditable = selectedObject.equals(element); - if(isEditable) break; - } - } - - //if (isPageEnabled) - { - editButton.setEnabled(isEditable); - deleteButton.setEnabled(isEditable); - } - } + // update the new mapping + // + workingUserCatalog.addCatalogElement(newEntry); + tableViewer.setSelection(new StructuredSelection(newEntry)); + } + } + } -/* - public void setPageEnabled(boolean enabled) - { - isPageEnabled = enabled; + protected void performDelete() { + ISelection selection = tableViewer.getSelection(); + Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null; - tableViewer.getControl().setEnabled(isPageEnabled); + if (selectedObject instanceof ICatalogElement) { + ICatalogElement catalogElement = (ICatalogElement) selectedObject; + workingUserCatalog.removeCatalogElement(catalogElement); + } + } - newButton.setEnabled(isPageEnabled); - editButton.setEnabled(isPageEnabled); - deleteButton.setEnabled(isPageEnabled); - } -*/ - public void updatePage() - { - refresh(); - updateWidgetEnabledState(); - } + protected void updateWidgetEnabledState() { + boolean isEditable = false; + ISelection selection = tableViewer.getSelection(); + Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null; - public Viewer getViewer() - { - return tableViewer; - } - + if (selectedObject instanceof ICatalogElement) { + ICatalogElement[] elements = ((Catalog) workingUserCatalog).getCatalogElements(); + // dw List entriesList = new ArrayList(elements.length); + for (int i = 0; i < elements.length; i++) { + ICatalogElement element = elements[i]; + isEditable = selectedObject.equals(element); + if (isEditable) { + break; + } + } + } + + // if (isPageEnabled) + { + editButton.setEnabled(isEditable); + deleteButton.setEnabled(isEditable); + } + } + + /* + * public void setPageEnabled(boolean enabled) { isPageEnabled = enabled; + * + * tableViewer.getControl().setEnabled(isPageEnabled); + * + * newButton.setEnabled(isPageEnabled); + * editButton.setEnabled(isPageEnabled); + * deleteButton.setEnabled(isPageEnabled); } + */ + public void updatePage() { + refresh(); + updateWidgetEnabledState(); + } + + public Viewer getViewer() { + return tableViewer; + } + }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntryDetailsView.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntryDetailsView.java index 53433e3..f48788e 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntryDetailsView.java +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntryDetailsView.java
@@ -25,97 +25,87 @@ - -public class XMLCatalogEntryDetailsView -{ - protected Text detailsText; - protected ScrollBar verticalScroll, horizontalScroll; +public class XMLCatalogEntryDetailsView { + protected Text detailsText; + protected ScrollBar verticalScroll, horizontalScroll; - public XMLCatalogEntryDetailsView(Composite parent) - { - Color color = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND); - - detailsText = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); + public XMLCatalogEntryDetailsView(Composite parent) { + Color color = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND); - GridData data = new GridData(GridData.FILL_BOTH); - data.heightHint = 85; - detailsText.setLayoutData(data); + detailsText = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - verticalScroll = detailsText.getVerticalBar(); - //verticalScroll.setVisible(false); - horizontalScroll = detailsText.getHorizontalBar(); - detailsText.setEditable(false); - detailsText.setBackground(color); - } + GridData data = new GridData(GridData.FILL_BOTH); + data.heightHint = 85; + detailsText.setLayoutData(data); - public void setCatalogElement(ICatalogEntry entry) - { - - String value = getDisplayValue(entry != null ? entry.getURI() : ""); //$NON-NLS-1$ - String line1 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_COLON + "\t\t" + value; //$NON-NLS-1$ + verticalScroll = detailsText.getVerticalBar(); + // verticalScroll.setVisible(false); + horizontalScroll = detailsText.getHorizontalBar(); + detailsText.setEditable(false); + detailsText.setBackground(color); + } - String line0; - if (value.startsWith("jar:file:")) { - String jarFile = URIHelper.URIToLocation(URIHelper.ensureURIProtocolFormat(value.substring("jar:".length(), value.indexOf('!')))); - String internalFile = URIHelper.URIToLocation(URIHelper.ensureURIProtocolFormat("file://" + value.substring(value.indexOf('!') + 1))); - line0 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t" + internalFile + " " + XMLCatalogMessages.UI_LABEL_DETAILS_IN_JAR_FILE + " " + jarFile; - } - else { - value = URIHelper.URIToLocation(value); - line0 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t" + value; //$NON-NLS-1$ - - } - - value = entry != null ? getKeyTypeValue(entry) : ""; //$NON-NLS-1$ - String line2 = XMLCatalogMessages.UI_KEY_TYPE_DETAILS_COLON + "\t" + value; //$NON-NLS-1$ + public void setCatalogElement(ICatalogEntry entry) { - value = getDisplayValue(entry != null ? entry.getKey() : ""); //$NON-NLS-1$ - String line3 = XMLCatalogMessages.UI_LABEL_DETAILS_KEY_COLON + "\t\t" + value; //$NON-NLS-1$ + String value = getDisplayValue(entry != null ? entry.getURI() : ""); //$NON-NLS-1$ + String line1 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_COLON + "\t\t" + value; //$NON-NLS-1$ - String entireString = "\n" + line0 + "\n" + line1 + "\n" + line2 + "\n" + line3; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - detailsText.setText(entireString); - } - - public void setCatalogElement(INextCatalog nextCatalog) - { - String value = getDisplayValue(nextCatalog != null ? nextCatalog.getCatalogLocation() : ""); //$NON-NLS-1$ - String line1 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_COLON + "\t\t" + value; //$NON-NLS-1$ - - String line0 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t" + URIHelper.URIToLocation(value); - - String entireString = "\n" + line0 + "\n" + line1; //$NON-NLS-1$ - detailsText.setText(entireString); - } + String line0; + if (value.startsWith("jar:file:")) { + String jarFile = URIHelper.URIToLocation(URIHelper.ensureURIProtocolFormat(value.substring("jar:".length(), value.indexOf('!')))); + String internalFile = URIHelper.URIToLocation(URIHelper.ensureURIProtocolFormat("file://" + value.substring(value.indexOf('!') + 1))); + line0 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t" + internalFile + " " + XMLCatalogMessages.UI_LABEL_DETAILS_IN_JAR_FILE + " " + jarFile; + } + else { + value = URIHelper.URIToLocation(value); + line0 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t" + value; //$NON-NLS-1$ - protected String getDisplayValue(String string) - { - return string != null ? string : ""; //$NON-NLS-1$ - } + } - protected String getKeyTypeValue(ICatalogEntry entry) - { - String result = null; - if (entry.getURI() != null && entry.getURI().endsWith("xsd")) //$NON-NLS-1$ - { - result = (entry.getEntryType() == ICatalogEntry.ENTRY_TYPE_URI) ? - XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_XSD_PUBLIC : - XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_XSD_SYSTEM; - } - else - { - switch (entry.getEntryType()) { - case ICatalogEntry.ENTRY_TYPE_PUBLIC: - result = XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_PUBLIC; - break; - case ICatalogEntry.ENTRY_TYPE_SYSTEM: - result = XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM; - break; - default: - result = XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_URI; - break; + value = entry != null ? getKeyTypeValue(entry) : ""; //$NON-NLS-1$ + String line2 = XMLCatalogMessages.UI_KEY_TYPE_DETAILS_COLON + "\t" + value; //$NON-NLS-1$ + + value = getDisplayValue(entry != null ? entry.getKey() : ""); //$NON-NLS-1$ + String line3 = XMLCatalogMessages.UI_LABEL_DETAILS_KEY_COLON + "\t\t" + value; //$NON-NLS-1$ + + String entireString = "\n" + line0 + "\n" + line1 + "\n" + line2 + "\n" + line3; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + detailsText.setText(entireString); + } + + public void setCatalogElement(INextCatalog nextCatalog) { + String value = getDisplayValue(nextCatalog != null ? nextCatalog.getCatalogLocation() : ""); //$NON-NLS-1$ + String line1 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_COLON + "\t\t" + value; //$NON-NLS-1$ + + String line0 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t" + URIHelper.URIToLocation(value); + + String entireString = "\n" + line0 + "\n" + line1; //$NON-NLS-1$ + detailsText.setText(entireString); + } + + protected String getDisplayValue(String string) { + return string != null ? string : ""; //$NON-NLS-1$ + } + + protected String getKeyTypeValue(ICatalogEntry entry) { + String result = null; + if ((entry.getURI() != null) && entry.getURI().endsWith("xsd")) //$NON-NLS-1$ + { + result = (entry.getEntryType() == ICatalogEntry.ENTRY_TYPE_URI) ? XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_XSD_PUBLIC : XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_XSD_SYSTEM; + } + else { + switch (entry.getEntryType()) { + case ICatalogEntry.ENTRY_TYPE_PUBLIC : + result = XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_PUBLIC; + break; + case ICatalogEntry.ENTRY_TYPE_SYSTEM : + result = XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM; + break; + default : + result = XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_URI; + break; } - } - return result; - } + } + return result; + } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogFileType.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogFileType.java index c2cadf8..609ebf6 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogFileType.java +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogFileType.java
@@ -20,37 +20,31 @@ import org.eclipse.swt.graphics.Image; -public class XMLCatalogFileType -{ - public String description; - public List extensions = new ArrayList(); - public String iconFileName; - public Image icon; - - public void addExtensions(String contributedExtensions) - { - List list = parseExtensions(contributedExtensions); - for (Iterator i = list.iterator(); i.hasNext(); ) - { - String extension = (String)i.next(); - if (!extensions.contains(extension)) - { - extensions.add(extension); - } +public class XMLCatalogFileType { + public String description; + public List extensions = new ArrayList(); + public String iconFileName; + public Image icon; + + public void addExtensions(String contributedExtensions) { + List list = parseExtensions(contributedExtensions); + for (Iterator i = list.iterator(); i.hasNext();) { + String extension = (String) i.next(); + if (!extensions.contains(extension)) { + extensions.add(extension); + } + } } - } - - protected List parseExtensions(String string) - { - List list = new ArrayList(); - for (StringTokenizer st = new StringTokenizer(string, ", "); st.hasMoreTokens(); ) //$NON-NLS-1$ - { - String token = st.nextToken(); - if (token != null) - { - list.add(token); - } - } - return list; - } + + protected List parseExtensions(String string) { + List list = new ArrayList(); + for (StringTokenizer st = new StringTokenizer(string, ", "); st.hasMoreTokens();) //$NON-NLS-1$ + { + String token = st.nextToken(); + if (token != null) { + list.add(token); + } + } + return list; + } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java index 3461ea5..b8cfad4 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java
@@ -18,10 +18,10 @@ */ public class XMLCatalogMessages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.wst.xml.ui.internal.catalog.XMLCatalogResources";//$NON-NLS-1$ - + public static String UI_WIZARD_SCHEMA_AND_NAME_SPACE_INFO; public static String UI_LABEL_NAME_SPACE_PREFIX; - public static String UI_LABEL_NAME_SPACE_URI; + public static String UI_LABEL_NAME_SPACE_URI; public static String UI_LABEL_XSD_LOCATION; public static String UI_LABEL_DOCTYPE_INFORMATION; public static String UI_LABEL_SYSTEM_ID; @@ -59,13 +59,13 @@ public static String UI_WARNING_SHOULD_BE_FULLY_QUALIFIED_URI; - //NewModelWizard + // NewModelWizard public static String UI_INVALID_GRAMMAR_ERROR; public static String UI_BUTTON_BROWSE; - //XMLCatalogIdMappingPage + // XMLCatalogIdMappingPage public static String UI_LABEL_MAP_TO; - public static String UI_LABEL_MAP_FROM ; + public static String UI_LABEL_MAP_FROM; public static String UI_BUTTON_NEW; public static String UI_BUTTON_EDIT; public static String UI_BUTTON_DELETE; @@ -82,18 +82,18 @@ public static String UI_LABEL_SELECT_PROJECT; public static String UI_LABEL_SPECIFY_PROJECT_DESCRIPTION; public static String UI_WARNING_NO_PROJECTS_CREATED; - public static String UI_WARNING_PROJECT_NOT_SPECIFIED ; - public static String UI_WARNING_PROJECT_DOES_NOT_EXIST ; - public static String UI_LABEL_PROJECT_TO_USE ; + public static String UI_WARNING_PROJECT_NOT_SPECIFIED; + public static String UI_WARNING_PROJECT_DOES_NOT_EXIST; + public static String UI_LABEL_PROJECT_TO_USE; public static String UI_LABEL_CATALOG_SAVE_ERROR; public static String UI_LABEL_CATALOG_COULD_NOT_BE_SAVED; public static String UI_LABEL_ADVANCED; - public static String UI_LABEL_ADVANCED_XML_CATALOG_PREFS; + public static String UI_LABEL_ADVANCED_XML_CATALOG_PREFS; public static String UI_LABEL_SPECIFY_PERSISTENCE_FILE; public static String UI_LABEL_SAVE_CATALOG_DIALOG_TITLE; - public static String UI_LABEL_SAVE_CATALOG_DIALOG_DESC; + public static String UI_LABEL_SAVE_CATALOG_DIALOG_DESC; public static String UI_LABEL_BROWSE_CATALOG_FILE_TITLE; - public static String UI_LABEL_BROWSE_CATALOG_FILE_DESC; + public static String UI_LABEL_BROWSE_CATALOG_FILE_DESC; public static String UI_LABEL_DETAILS; public static String UI_LABEL_USER_SPECIFIED_ENTRIES; public static String UI_LABEL_PLUGIN_SPECIFIED_ENTRIES; @@ -102,7 +102,7 @@ // AdvancedOptionsDialog public static String UI_BUTTON_IMPORT; public static String UI_BUTTON_EXPORT; - + public static String UI_LABEL_IMPORT_DIALOG_TITLE; public static String UI_LABEL_IMPORT_DIALOG_HEADING; public static String UI_LABEL_IMPORT_DIALOG_MESSAGE; @@ -120,15 +120,14 @@ public static String UI_BUTTON_MENU_BROWSE_FILE_SYSTEM; public static String UI_LABEL_SELECT_FILE_FILTER_CONTROL; public static String UI_TEXT_SELECT_FILE_FILTER_CONTROL; - - + static { // load message values from bundle file NLS.initializeMessages(BUNDLE_NAME, XMLCatalogMessages.class); } - + private XMLCatalogMessages() { // cannot create new instance }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogPreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogPreferencePage.java index 16947b9..383d57c 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogPreferencePage.java +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogPreferencePage.java
@@ -38,232 +38,198 @@ import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogListener; import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog; -public class XMLCatalogPreferencePage extends PreferencePage implements - IWorkbenchPreferencePage, ICatalogListener -{ +public class XMLCatalogPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, ICatalogListener { - protected XMLCatalogEntriesView catalogEntriesView; + protected XMLCatalogEntriesView catalogEntriesView; - protected ICatalog workingUserCatalog; + protected ICatalog workingUserCatalog; - protected ICatalog systemCatalog; + protected ICatalog systemCatalog; - protected ICatalog userCatalog; + protected ICatalog userCatalog; - protected ICatalog defaultCatalog; + protected ICatalog defaultCatalog; - protected Button advancedButton; + protected Button advancedButton; - public XMLCatalogPreferencePage() - { - defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog(); - INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs(); - for (int i = 0; i < nextCatalogs.length; i++) - { - INextCatalog catalog = nextCatalogs[i]; - ICatalog referencedCatalog = catalog.getReferencedCatalog(); - if (referencedCatalog != null) - { - if (XMLCorePlugin.SYSTEM_CATALOG_ID - .equals(referencedCatalog.getId())) - { - systemCatalog = referencedCatalog; - } else if (XMLCorePlugin.USER_CATALOG_ID - .equals(referencedCatalog.getId())) - { - userCatalog = referencedCatalog; - } - } - } - } + public XMLCatalogPreferencePage() { + defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog(); + INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs(); + for (int i = 0; i < nextCatalogs.length; i++) { + INextCatalog catalog = nextCatalogs[i]; + ICatalog referencedCatalog = catalog.getReferencedCatalog(); + if (referencedCatalog != null) { + if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) { + systemCatalog = referencedCatalog; + } + else if (XMLCorePlugin.USER_CATALOG_ID.equals(referencedCatalog.getId())) { + userCatalog = referencedCatalog; + } + } + } + } - public void dispose() - { - super.dispose(); - workingUserCatalog.removeListener(this); - } + public void dispose() { + super.dispose(); + workingUserCatalog.removeListener(this); + } - /** - * Refresh the view in responce to an event sent by the Catalog - */ - public void catalogChanged(ICatalogEvent event) - { - catalogEntriesView.updatePage(); - } + /** + * Refresh the view in responce to an event sent by the Catalog + */ + public void catalogChanged(ICatalogEvent event) { + catalogEntriesView.updatePage(); + } - /** - * Creates preference page controls on demand. - * - * @param parent - * the parent for the preference page - */ - protected Control createContents(Composite parent) - { - // we create a working copy of the 'User Settings' for the Catalog - // that we can modify - CatalogSet tempCatalogSet = new CatalogSet(); - workingUserCatalog = tempCatalogSet.lookupOrCreateCatalog("working", ""); //$NON-NLS-1$ //$NON-NLS-2$ - - // TODO: add entries from the nested catalogs as well - workingUserCatalog.addEntriesFromCatalog(userCatalog); - workingUserCatalog.addListener(this); - noDefaultAndApplyButton(); - Composite composite = new Composite(parent, SWT.NULL); - // WorkbenchHelp.setHelp(composite, new - // ControlContextComputer(composite, - // XMLBuilderContextIds.XMLP_CATALOG_PAGE)); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - createCatalogEntriesView(composite); - createCatalogDetailsView(composite); - createAdvancedButton(composite); - // catalogEntriesView.updatePage(); - applyDialogFont(composite); - - return composite; - } + /** + * Creates preference page controls on demand. + * + * @param parent + * the parent for the preference page + */ + protected Control createContents(Composite parent) { + // we create a working copy of the 'User Settings' for the Catalog + // that we can modify + CatalogSet tempCatalogSet = new CatalogSet(); + workingUserCatalog = tempCatalogSet.lookupOrCreateCatalog("working", ""); //$NON-NLS-1$ //$NON-NLS-2$ - protected void createAdvancedButton(Composite composite) - { - Composite panel = new Composite(composite, SWT.NONE); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 3; - panel.setLayout(gridLayout); - panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - // TODO... is there a better way to expand the page width? - // This invisible label is created to force the width of the page to be - // wide enough to show - // the rather long uri and key fields of a catalog entry. - Label widthFudger = new Label(panel, SWT.NONE); - String widthFudgerString = ""; //$NON-NLS-1$ - for (int i = 0; i < 55; i++) - { - widthFudgerString += "x"; //$NON-NLS-1$ - } - widthFudger.setText(widthFudgerString); - widthFudger.setVisible(false); - Composite placeHolder = new Composite(panel, SWT.NONE); - placeHolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - advancedButton = new Button(panel, SWT.NONE); - advancedButton.setText(XMLCatalogMessages.UI_LABEL_ADVANCED); - SelectionListener selectionListener = new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - AdvancedOptionsDialog dialog = new AdvancedOptionsDialog( - getShell(), workingUserCatalog); - dialog.create(); - dialog - .getShell() - .setText( - XMLCatalogMessages.UI_LABEL_ADVANCED_XML_CATALOG_PREFS); - dialog.setBlockOnOpen(true); - dialog.open(); - } - }; - advancedButton.addSelectionListener(selectionListener); - } + // TODO: add entries from the nested catalogs as well + workingUserCatalog.addEntriesFromCatalog(userCatalog); + workingUserCatalog.addListener(this); + noDefaultAndApplyButton(); + Composite composite = new Composite(parent, SWT.NULL); + // WorkbenchHelp.setHelp(composite, new + // ControlContextComputer(composite, + // XMLBuilderContextIds.XMLP_CATALOG_PAGE)); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + createCatalogEntriesView(composite); + createCatalogDetailsView(composite); + createAdvancedButton(composite); + // catalogEntriesView.updatePage(); + applyDialogFont(composite); - public boolean isSameFileName(String a, String b) - { - boolean result = false; - if (a == null && b == null) - { - result = true; - } else if (a != null && b != null) - { - result = a.equals(b); - } - return result; - } + return composite; + } - protected void createCatalogEntriesView(Composite parent) - { - Group group = new Group(parent, SWT.NONE); - group.setLayout(new GridLayout()); - group.setLayoutData(new GridData(GridData.FILL_BOTH)); - group.setText(XMLCatalogMessages.UI_LABEL_USER_ENTRIES); - group.setToolTipText(XMLCatalogMessages.UI_LABEL_USER_ENTRIES_TOOL_TIP); - // WorkbenchHelp.setHelp(userEntriesGroup, new - // ControlContextComputer(userEntriesGroup, - // XMLBuilderContextIds.XMLP_CATALOG_USER_GROUP)); - catalogEntriesView = new XMLCatalogEntriesView(group, - workingUserCatalog, systemCatalog); - catalogEntriesView.setLayoutData(new GridData(GridData.FILL_BOTH)); - } + protected void createAdvancedButton(Composite composite) { + Composite panel = new Composite(composite, SWT.NONE); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 3; + panel.setLayout(gridLayout); + panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + // TODO... is there a better way to expand the page width? + // This invisible label is created to force the width of the page to + // be + // wide enough to show + // the rather long uri and key fields of a catalog entry. + Label widthFudger = new Label(panel, SWT.NONE); + String widthFudgerString = ""; //$NON-NLS-1$ + for (int i = 0; i < 55; i++) { + widthFudgerString += "x"; //$NON-NLS-1$ + } + widthFudger.setText(widthFudgerString); + widthFudger.setVisible(false); + Composite placeHolder = new Composite(panel, SWT.NONE); + placeHolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + advancedButton = new Button(panel, SWT.NONE); + advancedButton.setText(XMLCatalogMessages.UI_LABEL_ADVANCED); + SelectionListener selectionListener = new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + AdvancedOptionsDialog dialog = new AdvancedOptionsDialog(getShell(), workingUserCatalog); + dialog.create(); + dialog.getShell().setText(XMLCatalogMessages.UI_LABEL_ADVANCED_XML_CATALOG_PREFS); + dialog.setBlockOnOpen(true); + dialog.open(); + } + }; + advancedButton.addSelectionListener(selectionListener); + } - protected void createCatalogDetailsView(Composite parent) - { - Group detailsGroup = new Group(parent, SWT.NONE); - detailsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - detailsGroup.setLayout(new GridLayout()); - detailsGroup.setText(XMLCatalogMessages.UI_LABEL_DETAILS); - final XMLCatalogEntryDetailsView detailsView = new XMLCatalogEntryDetailsView( - detailsGroup); - ISelectionChangedListener listener = new ISelectionChangedListener() - { - public void selectionChanged(SelectionChangedEvent event) - { - ISelection selection = event.getSelection(); - Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection) - .getFirstElement() - : null; - if (selectedObject instanceof ICatalogEntry) - { - ICatalogEntry entry = (ICatalogEntry) selectedObject; - detailsView.setCatalogElement(entry); - } - else if (selectedObject instanceof INextCatalog) - { - INextCatalog entry = (INextCatalog) selectedObject; - detailsView.setCatalogElement(entry); - } - else { - detailsView.setCatalogElement((ICatalogEntry) null); - } - - } - }; - catalogEntriesView.getViewer().addSelectionChangedListener(listener); - } + public boolean isSameFileName(String a, String b) { + boolean result = false; + if ((a == null) && (b == null)) { + result = true; + } + else if ((a != null) && (b != null)) { + result = a.equals(b); + } + return result; + } - /** - * Do anything necessary because the OK button has been pressed. - * - * @return whether it is okay to close the preference page - */ - public boolean performOk() - { - return storeValues(); - } + protected void createCatalogEntriesView(Composite parent) { + Group group = new Group(parent, SWT.NONE); + group.setLayout(new GridLayout()); + group.setLayoutData(new GridData(GridData.FILL_BOTH)); + group.setText(XMLCatalogMessages.UI_LABEL_USER_ENTRIES); + group.setToolTipText(XMLCatalogMessages.UI_LABEL_USER_ENTRIES_TOOL_TIP); + // WorkbenchHelp.setHelp(userEntriesGroup, new + // ControlContextComputer(userEntriesGroup, + // XMLBuilderContextIds.XMLP_CATALOG_USER_GROUP)); + catalogEntriesView = new XMLCatalogEntriesView(group, workingUserCatalog, systemCatalog); + catalogEntriesView.setLayoutData(new GridData(GridData.FILL_BOTH)); + } - /** - * @see IWorkbenchPreferencePage - */ - public void init(IWorkbench workbench) - { - } + protected void createCatalogDetailsView(Composite parent) { + Group detailsGroup = new Group(parent, SWT.NONE); + detailsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + detailsGroup.setLayout(new GridLayout()); + detailsGroup.setText(XMLCatalogMessages.UI_LABEL_DETAILS); + final XMLCatalogEntryDetailsView detailsView = new XMLCatalogEntryDetailsView(detailsGroup); + ISelectionChangedListener listener = new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + ISelection selection = event.getSelection(); + Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null; + if (selectedObject instanceof ICatalogEntry) { + ICatalogEntry entry = (ICatalogEntry) selectedObject; + detailsView.setCatalogElement(entry); + } + else if (selectedObject instanceof INextCatalog) { + INextCatalog entry = (INextCatalog) selectedObject; + detailsView.setCatalogElement(entry); + } + else { + detailsView.setCatalogElement((ICatalogEntry) null); + } - /** - * Stores the values of the controls back to the preference store. - */ - private boolean storeValues() - { - //dw Object fileObject = null; - try - { - // update the userCatalog so that its the same as the working - // catalog - userCatalog.clear(); - // TODO add entries from the nested catalogs? - userCatalog.addEntriesFromCatalog(workingUserCatalog); - // now save the userCatalog - userCatalog.save(); - } catch (Exception e) - { - } - return true; - } - - + } + }; + catalogEntriesView.getViewer().addSelectionChangedListener(listener); + } + + /** + * Do anything necessary because the OK button has been pressed. + * + * @return whether it is okay to close the preference page + */ + public boolean performOk() { + return storeValues(); + } + + /** + * @see IWorkbenchPreferencePage + */ + public void init(IWorkbench workbench) { + } + + /** + * Stores the values of the controls back to the preference store. + */ + private boolean storeValues() { + // dw Object fileObject = null; + try { + // update the userCatalog so that its the same as the working + // catalog + userCatalog.clear(); + // TODO add entries from the nested catalogs? + userCatalog.addEntriesFromCatalog(workingUserCatalog); + // now save the userCatalog + userCatalog.save(); + } + catch (Exception e) { + } + return true; + } + + }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogTreeViewer.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogTreeViewer.java index f09cf4d..f6932ca 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogTreeViewer.java +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogTreeViewer.java
@@ -80,11 +80,12 @@ } else if (object instanceof INextCatalog) { INextCatalog nextCatalog = (INextCatalog) object; - //result = nextCatalog.getCatalogLocation(); + // result = nextCatalog.getCatalogLocation(); result = URIHelper.URIToLocation(nextCatalog.getCatalogLocation()); if (nextCatalog.getCatalogLocation().startsWith("file:")) { result += " (" + XMLCatalogMessages.UI_LABEL_FILE_SYSTEM_RESOURCE + ")"; - } else if (nextCatalog.getCatalogLocation().startsWith("platform:")) { + } + else if (nextCatalog.getCatalogLocation().startsWith("platform:")) { result += " (" + XMLCatalogMessages.UI_LABEL_PLATFORM_RESOURCE + ")"; } } @@ -125,12 +126,11 @@ } return result; } - + public void dispose() { super.dispose(); - for (Iterator it = imageTable.values().iterator(); it.hasNext();) - { - ((Image)it.next()).dispose(); + for (Iterator it = imageTable.values().iterator(); it.hasNext();) { + ((Image) it.next()).dispose(); } } } @@ -146,7 +146,7 @@ } public boolean isRoot(Object object) { - return object instanceof String || object instanceof INextCatalog; + return (object instanceof String) || (object instanceof INextCatalog); } public Object[] getElements(Object element) { @@ -176,7 +176,7 @@ Comparator comparator = new Comparator() { public int compare(Object o1, Object o2) { int result = 0; - if (o1 instanceof ICatalogEntry && o2 instanceof ICatalogEntry) { + if ((o1 instanceof ICatalogEntry) && (o2 instanceof ICatalogEntry)) { ICatalogEntry entry1 = (ICatalogEntry) o1; ICatalogEntry entry2 = (ICatalogEntry) o2; result = Collator.getInstance().compare(entry1.getKey(), entry2.getKey()); @@ -192,7 +192,7 @@ List nextCatalogsList = Arrays.asList(nextCatalogs); result.addAll(nextCatalogsList); - return result.toArray(new ICatalogElement[result.size()]); + return result.toArray(new ICatalogElement[result.size()]); } public Object getParent(Object element) { @@ -249,8 +249,7 @@ } } } - else if ( element.equals(XMLCatalogTreeViewer.PLUGIN_SPECIFIED_ENTRIES_OBJECT ) || - element.equals(XMLCatalogTreeViewer.USER_SPECIFIED_ENTRIES_OBJECT) ) { + else if (element.equals(XMLCatalogTreeViewer.PLUGIN_SPECIFIED_ENTRIES_OBJECT) || element.equals(XMLCatalogTreeViewer.USER_SPECIFIED_ENTRIES_OBJECT)) { return true; } return result;
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLQuickScan.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLQuickScan.java index dc09758..8f68d7a 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLQuickScan.java +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLQuickScan.java
@@ -24,69 +24,58 @@ import org.xml.sax.helpers.DefaultHandler; /** - * + * */ -public class XMLQuickScan -{ - public static String getTargetNamespaceURIForSchema(String uri) - { - String result = null; - try - { - URL url = new URL(uri); - InputStream inputStream = url.openStream(); - result = XMLQuickScan.getTargetNamespaceURIForSchema(inputStream); - } - catch (Exception e) - { - } - return result; - } +public class XMLQuickScan { + public static String getTargetNamespaceURIForSchema(String uri) { + String result = null; + try { + URL url = new URL(uri); + InputStream inputStream = url.openStream(); + result = XMLQuickScan.getTargetNamespaceURIForSchema(inputStream); + } + catch (Exception e) { + } + return result; + } - public static String getTargetNamespaceURIForSchema(InputStream input) - { - TargetNamespaceURIContentHandler handler = new TargetNamespaceURIContentHandler(); - ClassLoader prevClassLoader = Thread.currentThread().getContextClassLoader(); - try - { - Thread.currentThread().setContextClassLoader(XMLQuickScan.class.getClassLoader()); - SAXParserFactory factory = SAXParserFactory.newInstance(); - factory.setNamespaceAware(true); - SAXParser parser = factory.newSAXParser(); - parser.parse(new InputSource(input), handler); - } - catch (Exception e) - { - } - finally - { - Thread.currentThread().setContextClassLoader(prevClassLoader); - } - return handler.targetNamespaceURI; - } + public static String getTargetNamespaceURIForSchema(InputStream input) { + TargetNamespaceURIContentHandler handler = new TargetNamespaceURIContentHandler(); + ClassLoader prevClassLoader = Thread.currentThread().getContextClassLoader(); + try { + Thread.currentThread().setContextClassLoader(XMLQuickScan.class.getClassLoader()); + SAXParserFactory factory = SAXParserFactory.newInstance(); + factory.setNamespaceAware(true); + SAXParser parser = factory.newSAXParser(); + parser.parse(new InputSource(input), handler); + } + catch (Exception e) { + } + finally { + Thread.currentThread().setContextClassLoader(prevClassLoader); + } + return handler.targetNamespaceURI; + } - protected static class TargetNamespaceURIContentHandler extends DefaultHandler - { - public String targetNamespaceURI; + protected static class TargetNamespaceURIContentHandler extends DefaultHandler { + public String targetNamespaceURI; - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException - { - if (localName.equals("schema")) //$NON-NLS-1$ - { - int nAttributes = attributes.getLength(); - for (int i = 0; i < nAttributes; i++) - { - if (attributes.getLocalName(i).equals("targetNamespace")) //$NON-NLS-1$ - { - targetNamespaceURI = attributes.getValue(i); - break; - } - } - } - // todo there's a nice way to do this I'm sure - // here I intentially cause an exception... - String x = null; - x.length(); - } - } + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + if (localName.equals("schema")) //$NON-NLS-1$ + { + int nAttributes = attributes.getLength(); + for (int i = 0; i < nAttributes; i++) { + if (attributes.getLocalName(i).equals("targetNamespace")) //$NON-NLS-1$ + { + targetNamespaceURI = attributes.getValue(i); + break; + } + } + } + // todo there's a nice way to do this I'm sure + // here I intentially cause an exception... + String x = null; + x.length(); + } + } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/DOMPropertyDescriptorFactory.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/DOMPropertyDescriptorFactory.java index 754d9bb..341fb6d 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/DOMPropertyDescriptorFactory.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/DOMPropertyDescriptorFactory.java
@@ -43,7 +43,7 @@ CMAttributeDeclaration ad = mq.getCMAttributeDeclaration(attr); if (ad != null) { String[] valuesArray = mq.getPossibleDataTypeValues(attr.getOwnerElement(), ad); - if (valuesArray != null && valuesArray.length > 0) { + if ((valuesArray != null) && (valuesArray.length > 0)) { result = new EnumeratedStringPropertyDescriptor(attributeName, attributeName, valuesArray); } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/IDesignViewer.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/IDesignViewer.java index 8569407..2a53891 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/IDesignViewer.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/IDesignViewer.java
@@ -18,6 +18,6 @@ String getTitle(); void setDocument(IDocument document); - + ISelectionProvider getSelectionProvider(); } \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourceEditorActionBarContributor.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourceEditorActionBarContributor.java index f30e1ee..1b5821f 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourceEditorActionBarContributor.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourceEditorActionBarContributor.java
@@ -51,26 +51,31 @@ } protected void initDesignViewerActionBarContributor(IActionBars actionBars) { - if (designViewerActionBarContributor != null) + if (designViewerActionBarContributor != null) { designViewerActionBarContributor.init(actionBars, getPage()); + } } protected void initSourceViewerActionContributor(IActionBars actionBars) { - if (sourceViewerActionContributor != null) + if (sourceViewerActionContributor != null) { sourceViewerActionContributor.init(actionBars, getPage()); + } } public void dispose() { super.dispose(); - if (designViewerActionBarContributor != null) + if (designViewerActionBarContributor != null) { designViewerActionBarContributor.dispose(); + } - if (sourceViewerActionContributor != null) + if (sourceViewerActionContributor != null) { sourceViewerActionContributor.dispose(); + } - if (extendedContributor != null) + if (extendedContributor != null) { extendedContributor.dispose(); + } } /** @@ -81,8 +86,9 @@ addToMenu(menu); - if (extendedContributor != null) + if (extendedContributor != null) { extendedContributor.contributeToMenu(menu); + } } protected void addToMenu(IMenuManager menu) { @@ -95,8 +101,9 @@ addToPopupMenu(menu); - if (extendedContributor != null) + if (extendedContributor != null) { extendedContributor.contributeToPopupMenu(menu); + } } protected void addToPopupMenu(IMenuManager menu) { @@ -110,8 +117,9 @@ addToToolBar(toolBarManager); - if (extendedContributor != null) + if (extendedContributor != null) { extendedContributor.contributeToToolBar(toolBarManager); + } } protected void addToToolBar(IToolBarManager toolBarManager) { @@ -125,8 +133,9 @@ addToStatusLine(manager); - if (extendedContributor != null) + if (extendedContributor != null) { extendedContributor.contributeToStatusLine(manager); + } } protected void addToStatusLine(IStatusLineManager manager) { @@ -136,8 +145,9 @@ * @see IExtendedContributor#updateToolbarActions() */ public void updateToolbarActions() { - if (extendedContributor != null) + if (extendedContributor != null) { extendedContributor.updateToolbarActions(); + } } public void setActiveEditor(IEditorPart targetEditor) { @@ -147,15 +157,17 @@ // activeEditor) // multiPageEditor is needed in setActivePage(IEditorPart // activeEditor) - if (targetEditor instanceof XMLMultiPageEditorPart) + if (targetEditor instanceof XMLMultiPageEditorPart) { multiPageEditor = (XMLMultiPageEditorPart) targetEditor; + } super.setActiveEditor(targetEditor); updateToolbarActions(); - if (extendedContributor != null) + if (extendedContributor != null) { extendedContributor.setActiveEditor(targetEditor); + } } public void setActivePage(IEditorPart activeEditor) { @@ -164,10 +176,12 @@ // other editors, the following // check is added. if (multiPageEditor != null) { - if (activeEditor != null && activeEditor instanceof StructuredTextEditor) + if ((activeEditor != null) && (activeEditor instanceof StructuredTextEditor)) { activateSourcePage(activeEditor); - else + } + else { activateDesignPage(activeEditor); + } } updateToolbarActions(); @@ -180,16 +194,17 @@ } protected void activateDesignPage(IEditorPart activeEditor) { - if (designViewerActionBarContributor != null && designViewerActionBarContributor instanceof IDesignViewerActionBarContributor) { + if ((designViewerActionBarContributor != null) && (designViewerActionBarContributor instanceof IDesignViewerActionBarContributor)) { designViewerActionBarContributor.setActiveEditor(multiPageEditor); } - if (sourceViewerActionContributor != null && sourceViewerActionContributor instanceof ISourceViewerActionBarContributor) { + if ((sourceViewerActionContributor != null) && (sourceViewerActionContributor instanceof ISourceViewerActionBarContributor)) { // if design page is not really an IEditorPart, activeEditor == // null, so pass in multiPageEditor instead (d282414) if (activeEditor == null) { sourceViewerActionContributor.setActiveEditor(multiPageEditor); - } else { + } + else { sourceViewerActionContributor.setActiveEditor(activeEditor); } ((ISourceViewerActionBarContributor) sourceViewerActionContributor).setViewerSpecificContributionsEnabled(false); @@ -197,11 +212,11 @@ } protected void activateSourcePage(IEditorPart activeEditor) { - if (designViewerActionBarContributor != null && designViewerActionBarContributor instanceof IDesignViewerActionBarContributor) { + if ((designViewerActionBarContributor != null) && (designViewerActionBarContributor instanceof IDesignViewerActionBarContributor)) { designViewerActionBarContributor.setActiveEditor(multiPageEditor); } - if (sourceViewerActionContributor != null && sourceViewerActionContributor instanceof ISourceViewerActionBarContributor) { + if ((sourceViewerActionContributor != null) && (sourceViewerActionContributor instanceof ISourceViewerActionBarContributor)) { sourceViewerActionContributor.setActiveEditor(activeEditor); ((ISourceViewerActionBarContributor) sourceViewerActionContributor).setViewerSpecificContributionsEnabled(true); }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourcePageActionContributor.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourcePageActionContributor.java index c283c27..f450a97 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourcePageActionContributor.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourcePageActionContributor.java
@@ -42,7 +42,7 @@ * * @param bars * the action bars - * + * */ public void init(IActionBars bars) { fBars = bars;
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeContentHelper.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeContentHelper.java index 68657fe..11a4dd6 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeContentHelper.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeContentHelper.java
@@ -41,7 +41,7 @@ * For example : - white space text nodes are ommited from the 'UI' tree - * adjacent Text and EntityReference nodes are combined into a single 'UI' * node - Elements with 'text only' children are diplayed without children - * + * */ public class TreeContentHelper { @@ -52,14 +52,14 @@ protected int style = HIDE_WHITE_SPACE_TEXT_NODES | COMBINE_ADJACENT_TEXT_AND_ENTITY_REFERENCES | HIDE_ELEMENT_CHILD_TEXT_NODES; /** - * + * */ public boolean hasStyleFlag(int flag) { return (style & flag) != 0; } /** - * + * */ public Object[] getChildren(Object element) { Object[] result = null; @@ -91,7 +91,7 @@ } if (includeNode && hasStyleFlag(COMBINE_ADJACENT_TEXT_AND_ENTITY_REFERENCES)) { - if (isTextOrEntityReferenceNode(childNode) && prevIncludedNode != null && isTextOrEntityReferenceNode(prevIncludedNode)) { + if (isTextOrEntityReferenceNode(childNode) && (prevIncludedNode != null) && isTextOrEntityReferenceNode(prevIncludedNode)) { // we only show the first of a list of adjacent text // or entity reference node in the tree // so we filter out this subsequent one @@ -100,7 +100,7 @@ } if (hasStyleFlag(HIDE_ELEMENT_CHILD_TEXT_NODES)) { - if (childNodeType != Node.TEXT_NODE && childNodeType != Node.ENTITY_REFERENCE_NODE) { + if ((childNodeType != Node.TEXT_NODE) && (childNodeType != Node.ENTITY_REFERENCE_NODE)) { textContentOnly = false; } } @@ -113,7 +113,8 @@ if (hasStyleFlag(HIDE_ELEMENT_CHILD_TEXT_NODES) && textContentOnly) { result = new Object[0]; - } else { + } + else { result = list.toArray(); } } @@ -121,26 +122,26 @@ } /** - * + * */ protected boolean isTextOrEntityReferenceNode(Node node) { - return node.getNodeType() == Node.TEXT_NODE || node.getNodeType() == Node.ENTITY_REFERENCE_NODE; + return (node.getNodeType() == Node.TEXT_NODE) || (node.getNodeType() == Node.ENTITY_REFERENCE_NODE); } /** - * + * */ public boolean isIgnorableText(Node node) { boolean result = false; if (node.getNodeType() == Node.TEXT_NODE) { String data = ((Text) node).getData(); - result = (data == null || data.trim().length() == 0); + result = ((data == null) || (data.trim().length() == 0)); } return result; } /** - * + * */ public boolean isCombinedTextNode(Node node) { boolean result = false; @@ -151,14 +152,15 @@ result = true; } } - } else if (node.getNodeType() == Node.ENTITY_REFERENCE_NODE) { + } + else if (node.getNodeType() == Node.ENTITY_REFERENCE_NODE) { result = true; } return result; } /** - * + * */ public List getCombinedTextNodeList(Node theNode) { List list = new Vector(); @@ -168,43 +170,44 @@ if (nodeType == Node.ENTITY_REFERENCE_NODE) { prevIsEntity = true; list.add(node); - } else if (nodeType == Node.TEXT_NODE && (prevIsEntity || node == theNode)) { + } + else if ((nodeType == Node.TEXT_NODE) && (prevIsEntity || (node == theNode))) { prevIsEntity = false; list.add(node); - } else { + } + else { break; } } return list; } - public String getElementTextValue(Element element) - { - List list = _getElementTextContent(element); - return list != null ? getValueForTextContent(list) : null; - } - - public void setElementTextValue(Element element, String value) - { - setElementNodeValue(element, value); - } - - private List _getElementTextContent(Element element) { - List result = null; + public String getElementTextValue(Element element) { + List list = _getElementTextContent(element); + return list != null ? getValueForTextContent(list) : null; + } - for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) { - if (node.getNodeType() == Node.TEXT_NODE || node.getNodeType() == Node.ENTITY_REFERENCE_NODE) { - if (result == null) { - result = new Vector(); - } - result.add(node); - } else { - result = null; - break; - } - } - return result; - } + public void setElementTextValue(Element element, String value) { + setElementNodeValue(element, value); + } + + private List _getElementTextContent(Element element) { + List result = null; + + for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) { + if ((node.getNodeType() == Node.TEXT_NODE) || (node.getNodeType() == Node.ENTITY_REFERENCE_NODE)) { + if (result == null) { + result = new Vector(); + } + result.add(node); + } + else { + result = null; + break; + } + } + return result; + } /** * If the element is has 'text only' content this method will return the @@ -218,9 +221,9 @@ return result; } - + /** - * + * */ public String getNodeValue(Node node) { String result = null; @@ -231,7 +234,7 @@ break; } case Node.CDATA_SECTION_NODE : - // drop thru + // drop thru case Node.COMMENT_NODE : { result = ((CharacterData) node).getData(); break; @@ -245,7 +248,7 @@ break; } case Node.ENTITY_REFERENCE_NODE : - // drop thru + // drop thru case Node.TEXT_NODE : { result = getTextNodeValue(node); break; @@ -259,7 +262,7 @@ } /** - * + * */ public void setNodeValue(Node node, String value) { int nodeType = node.getNodeType(); @@ -270,7 +273,7 @@ break; } case Node.CDATA_SECTION_NODE : - // drop thru + // drop thru case Node.COMMENT_NODE : { ((CharacterData) node).setData(value); break; @@ -280,7 +283,7 @@ break; } case Node.ENTITY_REFERENCE_NODE : - // drop thru + // drop thru case Node.TEXT_NODE : { setTextNodeValue(node, value); break; @@ -290,10 +293,12 @@ break; } } - } catch (DOMException e) { + } + catch (DOMException e) { Display d = getDisplay(); - if (d != null) + if (d != null) { d.beep(); + } } } @@ -304,14 +309,14 @@ /** - * + * */ protected String getDocumentTypeValue(DocumentType documentType) { return DOMWriter.getDocumentTypeData(documentType); } /** - * + * */ protected String getElementNodeValue(Element element) { String result = null; @@ -323,13 +328,14 @@ } /** - * + * */ protected void setElementNodeValue(Element element, String value) { List list = getElementTextContent(element); if (list != null) { setValueForTextContent(list, value); - } else { + } + else { Document document = element.getOwnerDocument(); Text text = document.createTextNode(value); element.appendChild(text); @@ -337,14 +343,15 @@ } /** - * + * */ protected String getTextNodeValue(Node node) { String result = null; List list = null; if (isCombinedTextNode(node)) { list = getCombinedTextNodeList(node); - } else { + } + else { list = new Vector(); list.add(node); } @@ -353,13 +360,14 @@ } /** - * + * */ protected void setTextNodeValue(Node node, String value) { List list = null; if (isCombinedTextNode(node)) { list = getCombinedTextNodeList(node); - } else { + } + else { list = new Vector(); list.add(node); } @@ -379,7 +387,7 @@ } /** - * + * */ protected String getValueForTextContent(List list) { String result = null; @@ -391,7 +399,8 @@ int end = last.getEndOffset(); try { result = model.getStructuredDocument().get(start, end - start); - } catch (Exception e) { + } + catch (Exception e) { } } @@ -405,10 +414,10 @@ } /** - * + * */ protected void setValueForTextContent(List list, String value) { - //String oldValue = getValueForTextContent(); + // String oldValue = getValueForTextContent(); // we worry about preserving trimmed text if (list.size() > 0) { IDOMNode first = (IDOMNode) list.get(0); @@ -420,28 +429,28 @@ } /** - * + * */ public boolean isEditable(Node node) { int nodeType = node.getNodeType(); boolean result = false; switch (nodeType) { case Node.ATTRIBUTE_NODE : - // drop thru + // drop thru case Node.CDATA_SECTION_NODE : - // drop thru + // drop thru case Node.COMMENT_NODE : - // drop thru + // drop thru case Node.ENTITY_REFERENCE_NODE : - // drop thru + // drop thru case Node.TEXT_NODE : - // drop thru + // drop thru case Node.PROCESSING_INSTRUCTION_NODE : { result = true; break; } case Node.ELEMENT_NODE : { - result = getElementTextContent((Element) node) != null || node.getChildNodes().getLength() == 0; + result = (getElementTextContent((Element) node) != null) || (node.getChildNodes().getLength() == 0); break; } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeExtension.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeExtension.java index ea03d96..0dc8437 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeExtension.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeExtension.java
@@ -106,7 +106,7 @@ for (Iterator i = list.iterator(); i.hasNext();) { TreeItem item = (TreeItem) i.next(); Rectangle r = item.getBounds(); - if (r != null && px >= r.x && py >= r.y && py <= r.y + r.height) { + if ((r != null) && (px >= r.x) && (py >= r.y) && (py <= r.y + r.height)) { result = item; } } @@ -120,7 +120,7 @@ protected Cursor cursor = null; public void mouseMove(MouseEvent e) { - if (e.x > columnPosition - columnHitWidth && e.x < columnPosition + columnHitWidth) { + if ((e.x > columnPosition - columnHitWidth) && (e.x < columnPosition + columnHitWidth)) { if (cursor == null) { cursor = new Cursor(fTree.getDisplay(), SWT.CURSOR_SIZEWE); fTree.setCursor(cursor); @@ -150,7 +150,7 @@ columnDragged = -1; editManager.deactivateCellEditor(); - if (e.x > columnPosition - columnHitWidth && e.x < columnPosition + columnHitWidth) { + if ((e.x > columnPosition - columnHitWidth) && (e.x < columnPosition + columnHitWidth)) { columnDragged = 0; } @@ -379,7 +379,7 @@ // No edit if more than one row is selected. if (items.length == 1) { Rectangle bounds = items[0].getBounds(); - if (bounds != null && e.y >= bounds.y && e.y <= bounds.y + bounds.height) { + if ((bounds != null) && (e.y >= bounds.y) && (e.y <= bounds.y + bounds.height)) { int columnToEdit = 1; activateCellEditor(items[0], columnToEdit); } @@ -413,11 +413,13 @@ tree.addMouseListener(theMouseAdapter); tree.addKeyListener(keyListener); ScrollBar hBar = tree.getHorizontalBar(); - if (hBar != null) + if (hBar != null) { hBar.addSelectionListener(selectionListener); + } ScrollBar vBar = tree.getVerticalBar(); - if (vBar != null) + if (vBar != null) { vBar.addSelectionListener(selectionListener); + } } public boolean isCellEditorActive() { @@ -425,7 +427,7 @@ } public void applyCellEditorValue() { - if (cellEditorState != null && cellModifier != null) { + if ((cellEditorState != null) && (cellModifier != null)) { TreeItem treeItem = cellEditorState.fTreeItem; // The area below the cell editor needs to be explicity
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java index 785ddfa..2675e46 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java
@@ -26,14 +26,15 @@ setImageDescriptor(e_imageDescriptor); setDisabledImageDescriptor(d_imageDescriptor); - setToolTipText(XMLUIMessages._UI_INFO_EXPAND_ALL); //$NON-NLS-1$ - } else { + setToolTipText(XMLUIMessages._UI_INFO_EXPAND_ALL); + } + else { ImageDescriptor e_imageDescriptor = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_ETOOL_COLLAPSEALL); ImageDescriptor d_imageDescriptor = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_DTOOL_COLLAPSEALL); setImageDescriptor(e_imageDescriptor); setDisabledImageDescriptor(d_imageDescriptor); - setToolTipText(XMLUIMessages._UI_INFO_COLLAPSE_ALL); //$NON-NLS-1$ + setToolTipText(XMLUIMessages._UI_INFO_COLLAPSE_ALL); } } @@ -50,7 +51,8 @@ if (isExpandAction) { viewer.expandAll(); - } else { + } + else { viewer.collapseAll(); } @@ -60,4 +62,3 @@ } } } -
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorActionDefinitionIds.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorActionDefinitionIds.java index f7568ca..dcf9dcb 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorActionDefinitionIds.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorActionDefinitionIds.java
@@ -15,14 +15,15 @@ /** * Defines the definitions ids for the XML editor actions. * - * @deprecated Use org.eclipse.wst.sse.ui.edit.util.ActionDefinitionIds instead + * @deprecated Use org.eclipse.wst.sse.ui.edit.util.ActionDefinitionIds + * instead */ public interface XMLEditorActionDefinitionIds { public final static String CLEANUP_DOCUMENT = "org.eclipse.wst.sse.ui.edit.ui.cleanup.document";//$NON-NLS-1$ public final static String FORMAT_DOCUMENT = "org.eclipse.wst.sse.ui.edit.ui.format.document";//$NON-NLS-1$ public final static String FORMAT_ACTIVE_ELEMENTS = "org.eclipse.wst.sse.ui.edit.ui.format.active.elements";//$NON-NLS-1$ public final static String OPEN_FILE = "org.eclipse.wst.sse.ui.edit.ui.open.file.from.source";//$NON-NLS-1$ - // public final static String INFORMATION = + // public final static String INFORMATION = // "org.eclipse.wst.sse.ui.edit.ui.show.tooltip.information";//$NON-NLS-1$ public final static String INFORMATION = "org.eclipse.jdt.ui.edit.text.java.show.javadoc";//$NON-NLS-1$ public final static String ADD_BREAKPOINTS = "org.eclipse.wst.sse.ui.edit.ui.add.breakpoints";//$NON-NLS-1$
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorMessages.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorMessages.java index 36d0be8..86dc4b8 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorMessages.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorMessages.java
@@ -43,7 +43,7 @@ // load message values from bundle file NLS.initializeMessages(BUNDLE_NAME, XMLEditorMessages.class); } - + private XMLEditorMessages() { // cannot create new instance }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginHOLD_OLD.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginHOLD_OLD.java index 6fa19db..e2830c7 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginHOLD_OLD.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginHOLD_OLD.java
@@ -15,8 +15,8 @@ import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistryImpl; /** - * @deprecated This plugin has combined with the org.eclipse.wst.xml.ui plugin. - * Use XMLUIPlugin instead. + * @deprecated This plugin has combined with the org.eclipse.wst.xml.ui + * plugin. Use XMLUIPlugin instead. */ public class XMLEditorPluginHOLD_OLD extends AbstractUIPlugin {
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginImageHelper.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginImageHelper.java index 4b5f8d3..d491c5e 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginImageHelper.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginImageHelper.java
@@ -31,7 +31,7 @@ private final String PLUGINID = XMLUIPlugin.ID; private static XMLEditorPluginImageHelper instance = null; - // save a descriptor for each image + // save a descriptor for each image private HashMap fImageDescRegistry = null; /** @@ -40,8 +40,9 @@ * @return Returns a XMLEditorPluginImageHelper */ public synchronized static XMLEditorPluginImageHelper getInstance() { - if (instance == null) + if (instance == null) { instance = new XMLEditorPluginImageHelper(); + } return instance; } @@ -80,9 +81,10 @@ ImageDescriptor imageDescriptor = null; Object o = getImageDescriptorRegistry().get(resource); if (o == null) { - //create a descriptor + // create a descriptor imageDescriptor = createImageDescriptor(resource); - } else { + } + else { imageDescriptor = (ImageDescriptor) o; } return imageDescriptor; @@ -94,8 +96,9 @@ * @return HashMap - image descriptor registry for this plugin */ private HashMap getImageDescriptorRegistry() { - if (fImageDescRegistry == null) + if (fImageDescRegistry == null) { fImageDescRegistry = new HashMap(); + } return fImageDescRegistry; } @@ -123,8 +126,9 @@ image = desc.createImage(); // dont add the missing image descriptor image to the image // registry - if (!desc.equals(ImageDescriptor.getMissingImageDescriptor())) + if (!desc.equals(ImageDescriptor.getMissingImageDescriptor())) { getImageRegistry().put(resource, image); + } } return image; } @@ -143,7 +147,8 @@ ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(PLUGINID, imageFilePath); if (imageDescriptor != null) { getImageDescriptorRegistry().put(imageFilePath, imageDescriptor); - } else { + } + else { imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorActionBarContributor.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorActionBarContributor.java index 4683c54..e4fb564 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorActionBarContributor.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorActionBarContributor.java
@@ -26,36 +26,39 @@ protected void initDesignViewerActionBarContributor(IActionBars actionBars) { super.initDesignViewerActionBarContributor(actionBars); - if (designViewerActionBarContributor != null) - if (designViewerActionBarContributor instanceof IDesignViewerActionBarContributor) + if (designViewerActionBarContributor != null) { + if (designViewerActionBarContributor instanceof IDesignViewerActionBarContributor) { ((IDesignViewerActionBarContributor) designViewerActionBarContributor).initViewerSpecificContributions(actionBars); + } + } } protected void activateDesignPage(IEditorPart activeEditor) { - if (sourceViewerActionContributor != null && sourceViewerActionContributor instanceof ISourceViewerActionBarContributor) { + if ((sourceViewerActionContributor != null) && (sourceViewerActionContributor instanceof ISourceViewerActionBarContributor)) { // if design page is not really an IEditorPart, activeEditor == // null, so pass in multiPageEditor instead (d282414) if (activeEditor == null) { sourceViewerActionContributor.setActiveEditor(multiPageEditor); - } else { + } + else { sourceViewerActionContributor.setActiveEditor(activeEditor); } ((ISourceViewerActionBarContributor) sourceViewerActionContributor).setViewerSpecificContributionsEnabled(false); } - if (designViewerActionBarContributor != null && designViewerActionBarContributor instanceof IDesignViewerActionBarContributor) { + if ((designViewerActionBarContributor != null) && (designViewerActionBarContributor instanceof IDesignViewerActionBarContributor)) { designViewerActionBarContributor.setActiveEditor(multiPageEditor); ((IDesignViewerActionBarContributor) designViewerActionBarContributor).setViewerSpecificContributionsEnabled(true); } } protected void activateSourcePage(IEditorPart activeEditor) { - if (designViewerActionBarContributor != null && designViewerActionBarContributor instanceof IDesignViewerActionBarContributor) { + if ((designViewerActionBarContributor != null) && (designViewerActionBarContributor instanceof IDesignViewerActionBarContributor)) { designViewerActionBarContributor.setActiveEditor(multiPageEditor); ((IDesignViewerActionBarContributor) designViewerActionBarContributor).setViewerSpecificContributionsEnabled(false); } - if (sourceViewerActionContributor != null && sourceViewerActionContributor instanceof ISourceViewerActionBarContributor) { + if ((sourceViewerActionContributor != null) && (sourceViewerActionContributor instanceof ISourceViewerActionBarContributor)) { sourceViewerActionContributor.setActiveEditor(activeEditor); ((ISourceViewerActionBarContributor) sourceViewerActionContributor).setViewerSpecificContributionsEnabled(true); }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java index 074c0e0..fc55a2d 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java
@@ -136,8 +136,9 @@ * editor. */ void handleActivation() { - if (fIsHandlingActivation || getTextEditor() == null) + if (fIsHandlingActivation || (getTextEditor() == null)) { return; + } if (fActivePart == XMLMultiPageEditorPart.this) { fIsHandlingActivation = true; @@ -215,7 +216,7 @@ } public void selectionChanged(SelectionChangedEvent event) { - if (fDesignViewer != null && ((getActivePage() != fDesignPageIndex) || !XMLMultiPageEditorPart.this.equals(getSite().getPage().getActivePart()))) { + if ((fDesignViewer != null) && ((getActivePage() != fDesignPageIndex) || !XMLMultiPageEditorPart.this.equals(getSite().getPage().getActivePart()))) { if (forcePostSelection) { selection = event.getSelection(); schedule(200); @@ -289,8 +290,9 @@ } public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { - if (fDesignViewer != null && newInput != null) + if ((fDesignViewer != null) && (newInput != null)) { fDesignViewer.setDocument(newInput); + } } } @@ -442,7 +444,7 @@ start = ((ITextSelection) selection).getOffset(); length = ((ITextSelection) selection).getLength(); } - if (start > -1 && length > -1) { + if ((start > -1) && (length > -1)) { getTextEditor().selectAndReveal(start, length); } } @@ -514,7 +516,7 @@ } int activePageIndex = getPreferenceStore().getInt(IXMLPreferenceNames.LAST_ACTIVE_PAGE); - if (activePageIndex >= 0 && activePageIndex < getPageCount()) { + if ((activePageIndex >= 0) && (activePageIndex < getPageCount())) { setActivePage(activePageIndex); } else { @@ -597,7 +599,7 @@ fActivationListener = null; } - if (fTextEditor != null && fPropertyListener != null) { + if ((fTextEditor != null) && (fPropertyListener != null)) { fTextEditor.removePropertyListener(fPropertyListener); } @@ -661,8 +663,9 @@ private IDocument getDocument() { IDocument document = null; - if (fTextEditor != null) + if (fTextEditor != null) { document = fTextEditor.getDocumentProvider().getDocument(fTextEditor.getEditorInput()); + } return document; } @@ -724,7 +727,7 @@ * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed() */ public boolean isSaveAsAllowed() { - return fTextEditor != null && fTextEditor.isSaveAsAllowed(); + return (fTextEditor != null) && fTextEditor.isSaveAsAllowed(); } /* @@ -734,8 +737,9 @@ */ public boolean isSaveOnCloseNeeded() { // overriding super class since it does a lowly isDirty! - if (fTextEditor != null) + if (fTextEditor != null) { return fTextEditor.isSaveOnCloseNeeded(); + } return isDirty(); } @@ -775,8 +779,9 @@ // with the input just yet. We'll rely on later notification from the // TextViewer to set us straight super.setInput(input); - if (fDesignViewer != null) + if (fDesignViewer != null) { fDesignViewer.setDocument(getDocument()); + } setPartName(input.getName()); } } \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java index 855c7a2..5c7b0f9 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java
@@ -37,7 +37,7 @@ import org.w3c.dom.Document; /** - * + * */ public class XMLTableTreeActionBarContributor implements IDesignViewerActionBarContributor { @@ -52,7 +52,7 @@ protected ToggleEditModeAction toggleAction; protected ReloadGrammarAction reloadGrammarAction; - // protected ValidateXMLAction validateXMLAction; + // protected ValidateXMLAction validateXMLAction; protected ViewerExpandCollapseAction expandAction; protected ViewerExpandCollapseAction collapseAction; protected ViewerExpandCollapseAction xmlMenuExpandAction; @@ -70,7 +70,8 @@ doRemove(manager, TOGGLE_EDIT_MODE_ID); doRemove(manager, EXPAND_ALL_ID); doRemove(manager, COLLAPSE_ALL_ID); - } catch (Exception e) { + } + catch (Exception e) { } } @@ -79,7 +80,8 @@ if (manager.find(id) != null) { manager.remove(id); } - } catch (Exception e) { + } + catch (Exception e) { } } @@ -95,7 +97,8 @@ if (xmlMenu == null) { xmlMenu = new MenuManager(XMLEditorMessages.XMLTableTreeActionBarContributor_0, "org.eclipse.core.runtime.xml.design.xmlmenu"); //$NON-NLS-1$ bars.getMenuManager().insertBefore(IWorkbenchActionConstants.M_WINDOW, xmlMenu); - } else { + } + else { removeContributions(xmlMenu); } @@ -108,11 +111,11 @@ // have a DAD validator contribution (in the case of the DAD editor). // This hack will be removed when defect 212448 is fixed. // - // if (tbm.find("validate.dad.validateDAD") == null) { - // validateXMLAction = new ValidateXMLAction(); - // tbm.add(validateXMLAction); - // xmlMenu.add(validateXMLAction); - // } + // if (tbm.find("validate.dad.validateDAD") == null) { + // validateXMLAction = new ValidateXMLAction(); + // tbm.add(validateXMLAction); + // xmlMenu.add(validateXMLAction); + // } // ToggleEditModeAction // @@ -134,13 +137,13 @@ // xmlMenuExpandAction = new ViewerExpandCollapseAction(true); xmlMenuExpandAction.setId(EXPAND_ALL_ID); - xmlMenuExpandAction.setText(XMLEditorMessages.XMLTableTreeActionBarContributor_1); //$NON-NLS-1$ + xmlMenuExpandAction.setText(XMLEditorMessages.XMLTableTreeActionBarContributor_1); xmlMenu.add(xmlMenuExpandAction); xmlMenuCollapseAction = new ViewerExpandCollapseAction(false); xmlMenuCollapseAction.setId(COLLAPSE_ALL_ID); xmlMenuCollapseAction.setId(EXPAND_ALL_ID); - xmlMenuCollapseAction.setText(XMLEditorMessages.XMLTableTreeActionBarContributor_2); //$NON-NLS-1$ + xmlMenuCollapseAction.setText(XMLEditorMessages.XMLTableTreeActionBarContributor_2); xmlMenu.add(xmlMenuCollapseAction); } @@ -229,7 +232,7 @@ } /** - * + * */ public class ToggleEditModeAction extends Action { protected ImageDescriptor onImage = SharedXMLEditorPluginImageHelper.getImageDescriptor(SharedXMLEditorPluginImageHelper.IMG_ETOOL_CONSTRAINON); @@ -257,12 +260,13 @@ public void setAppearanceForEditMode(int editMode) { if (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) { - setToolTipText(XMLEditorMessages.XMLTableTreeActionBarContributor_3); //$NON-NLS-1$ - setText(XMLEditorMessages.XMLTableTreeActionBarContributor_4); //$NON-NLS-1$ + setToolTipText(XMLEditorMessages.XMLTableTreeActionBarContributor_3); + setText(XMLEditorMessages.XMLTableTreeActionBarContributor_4); setImageDescriptor(onImage); - } else { - setToolTipText(XMLEditorMessages.XMLTableTreeActionBarContributor_5); //$NON-NLS-1$ - setText(XMLEditorMessages.XMLTableTreeActionBarContributor_6); //$NON-NLS-1$ + } + else { + setToolTipText(XMLEditorMessages.XMLTableTreeActionBarContributor_5); + setText(XMLEditorMessages.XMLTableTreeActionBarContributor_6); setImageDescriptor(offImage); } } @@ -271,7 +275,8 @@ int result = -1; if (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) { result = ModelQuery.EDIT_MODE_UNCONSTRAINED; - } else { + } + else { result = ModelQuery.EDIT_MODE_CONSTRAINED_STRICT; } return result; @@ -279,7 +284,7 @@ } /** - * + * */ public class ReloadGrammarAction extends Action { protected IStructuredModel model; @@ -287,8 +292,8 @@ public ReloadGrammarAction() { setDisabledImageDescriptor(SharedXMLEditorPluginImageHelper.getImageDescriptor(SharedXMLEditorPluginImageHelper.IMG_DTOOL_RLDGRMR)); setImageDescriptor(SharedXMLEditorPluginImageHelper.getImageDescriptor(SharedXMLEditorPluginImageHelper.IMG_ETOOL_RLDGRMR)); - setToolTipText(XMLEditorMessages.XMLTableTreeActionBarContributor_7); //$NON-NLS-1$ - setText(XMLEditorMessages.XMLTableTreeActionBarContributor_8); //$NON-NLS-1$ + setToolTipText(XMLEditorMessages.XMLTableTreeActionBarContributor_7); + setText(XMLEditorMessages.XMLTableTreeActionBarContributor_8); } public void setModel(IStructuredModel newModel) { @@ -299,11 +304,11 @@ if (model != null) { ModelQuery modelQuery = ModelQueryUtil.getModelQuery(model); Document document = ((IDOMModel) model).getDocument(); - if (modelQuery != null && modelQuery.getCMDocumentManager() != null) { + if ((modelQuery != null) && (modelQuery.getCMDocumentManager() != null)) { modelQuery.getCMDocumentManager().getCMDocumentCache().clear(); // TODO... need to figure out how to access the // DOMObserver via ModelQuery - // ...why? + // ...why? CMDocumentLoader loader = new InferredGrammarBuildingCMDocumentLoader(document, modelQuery); loader.loadCMDocuments(); }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeContentProvider.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeContentProvider.java index 2e72f98..eb0d462 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeContentProvider.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeContentProvider.java
@@ -64,7 +64,7 @@ } public void cacheUpdated(CMDocumentCache cache, final String uri, int oldStatus, int newStatus, CMDocument cmDocument) { - if (newStatus == CMDocumentCache.STATUS_LOADED || newStatus == CMDocumentCache.STATUS_ERROR) { + if ((newStatus == CMDocumentCache.STATUS_LOADED) || (newStatus == CMDocumentCache.STATUS_ERROR)) { doDelayedRefreshForViewers(); } } @@ -73,10 +73,10 @@ } private void doDelayedRefreshForViewers() { - if (fViewer != null && !fViewer.getControl().isDisposed()) { + if ((fViewer != null) && !fViewer.getControl().isDisposed()) { fViewer.getControl().getDisplay().asyncExec(new Runnable() { public void run() { - if (fViewer != null && !fViewer.getControl().isDisposed()) { + if ((fViewer != null) && !fViewer.getControl().isDisposed()) { fViewer.refresh(true); } } @@ -85,8 +85,9 @@ } public Object[] getChildren(Object element) { - if (element instanceof INodeNotifier) + if (element instanceof INodeNotifier) { ((INodeNotifier) element).getAdapterFor(IJFaceNodeAdapter.class); + } return treeContentHelper.getChildren(element); } @@ -102,7 +103,7 @@ if (column == 0) { result = getText(object); } - else if (column == 1 && object instanceof Node) { + else if ((column == 1) && (object instanceof Node)) { result = treeContentHelper.getNodeValue((Node) object); } return result != null ? result : ""; //$NON-NLS-1$ @@ -113,8 +114,9 @@ } public Image getImage(Object object) { - if (object instanceof INodeNotifier) + if (object instanceof INodeNotifier) { ((INodeNotifier) object).getAdapterFor(IJFaceNodeAdapter.class); + } Image image = null; if (object instanceof Node) { @@ -167,8 +169,9 @@ } public Object getParent(Object o) { - if (o instanceof INodeNotifier) + if (o instanceof INodeNotifier) { ((INodeNotifier) o).getAdapterFor(IJFaceNodeAdapter.class); + } Object result = null; if (o instanceof Node) { @@ -196,8 +199,9 @@ } public String getText(Object object) { - if (object instanceof INodeNotifier) + if (object instanceof INodeNotifier) { ((INodeNotifier) object).getAdapterFor(IJFaceNodeAdapter.class); + } String result = null; if (object instanceof Node) { @@ -241,7 +245,7 @@ } } - if (oldInput != null && oldInput instanceof IDOMNode) { + if ((oldInput != null) && (oldInput instanceof IDOMNode)) { IJFaceNodeAdapterFactory factory = (IJFaceNodeAdapterFactory) ((IDOMNode) oldInput).getModel().getFactoryRegistry().getFactoryFor(IJFaceNodeAdapter.class); if (factory != null) { factory.removeListener(viewer); @@ -255,7 +259,7 @@ fViewer = (StructuredViewer) viewer; } - if (newInput != null && newInput instanceof IDOMNode) { + if ((newInput != null) && (newInput instanceof IDOMNode)) { IJFaceNodeAdapterFactory factory = (IJFaceNodeAdapterFactory) ((IDOMNode) newInput).getModel().getFactoryRegistry().getFactoryFor(IJFaceNodeAdapter.class); if (factory != null) { factory.addListener(viewer); @@ -288,7 +292,7 @@ try { if (node.getNodeType() == Node.TEXT_NODE) { String data = ((Text) node).getData(); - result = (data == null || data.trim().length() == 0); + result = ((data == null) || (data.trim().length() == 0)); } } catch (Exception e) {
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeHelpContextIds.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeHelpContextIds.java index 4c9a381..816bc9d 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeHelpContextIds.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeHelpContextIds.java
@@ -20,7 +20,7 @@ * This interface contains constants only; it is not intended to be * implemented or extended. * </p> - * + * */ public interface XMLTableTreeHelpContextIds { // org.eclipse.wst.xml.ui.
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreePropertyDescriptorFactory.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreePropertyDescriptorFactory.java index cffc2be..cab6e65 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreePropertyDescriptorFactory.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreePropertyDescriptorFactory.java
@@ -42,7 +42,7 @@ if (mq != null) { valuesArray = mq.getPossibleDataTypeValues(element, cmNode); } - if (valuesArray != null && valuesArray.length > 0) { + if ((valuesArray != null) && (valuesArray.length > 0)) { result = new EnumeratedStringPropertyDescriptor(name, name, valuesArray); } else { @@ -55,7 +55,7 @@ public IPropertyDescriptor createTextPropertyDescriptor(Text text) { IPropertyDescriptor result = null; Node parentNode = text.getParentNode(); - if (parentNode != null && parentNode.getNodeType() == Node.ELEMENT_NODE) { + if ((parentNode != null) && (parentNode.getNodeType() == Node.ELEMENT_NODE)) { Element parentElement = (Element) parentNode; ModelQuery mq = ModelQueryUtil.getModelQuery(text.getOwnerDocument()); CMElementDeclaration ed = null;
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeViewer.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeViewer.java index 912a8df..c7a1229 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeViewer.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeViewer.java
@@ -110,13 +110,13 @@ treeExtension.resetCachedData(); super.refresh(o); } - + public void refresh(boolean updateLabels) { treeExtension.resetCachedData(); super.refresh(updateLabels); getControl().redraw(); } - + public void refresh(Object element, boolean updateLabels) { treeExtension.resetCachedData(); super.refresh(element, updateLabels); @@ -131,7 +131,7 @@ try { model = StructuredModelManager.getModelManager().getExistingModelForRead(document); - if (model != null && model instanceof IDOMModel) { + if ((model != null) && (model instanceof IDOMModel)) { Document domDoc = null; domDoc = ((IDOMModel) model).getDocument(); setInput(domDoc);
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java index 2775fae..2d9ab17 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java
@@ -83,7 +83,7 @@ string = (String) modifier.getValue(object, VALUE_PROPERTY); color = f1; } - if (string.length() == 0 && object instanceof Element) { + if ((string.length() == 0) && (object instanceof Element)) { string = getElementValueHelper((Element) object); color = f2; } @@ -96,7 +96,7 @@ protected void paintItem(GC gc, TreeItem item, Rectangle bounds) { super.paintItem(gc, item, bounds); Object[] data = computeTreeExtensionData(item.getData()); - if (data != null && data.length == 2) { + if ((data != null) && (data.length == 2)) { gc.setClipping(columnPosition, bounds.y + 1, controlWidth, bounds.height); gc.setForeground((Color) data[1]); gc.drawString((String) data[0], columnPosition + 5, bounds.y + 1); @@ -118,9 +118,9 @@ String result = null; ModelQuery mq = ModelQueryUtil.getModelQuery(element.getOwnerDocument()); - if (result == null && mq != null) { + if ((result == null) && (mq != null)) { CMElementDeclaration ed = mq.getCMElementDeclaration(element); - if (ed != null && !Boolean.TRUE.equals(ed.getProperty("isInferred"))) { //$NON-NLS-1$ + if ((ed != null) && !Boolean.TRUE.equals(ed.getProperty("isInferred"))) { //$NON-NLS-1$ result = decriptionBuilder.buildDescription(ed); } } @@ -135,7 +135,7 @@ boolean result = false; if (element instanceof Node) { Node node = (Node) element; - result = property == VALUE_PROPERTY && treeContentHelper.isEditable(node); + result = (property == VALUE_PROPERTY) && treeContentHelper.isEditable(node); } return result; } @@ -153,7 +153,7 @@ Item item = (Item) element; String oldValue = treeContentHelper.getNodeValue((Node) item.getData()); String newValue = value.toString(); - if (newValue != null && !newValue.equals(oldValue)) { + if ((newValue != null) && !newValue.equals(oldValue)) { treeContentHelper.setNodeValue((Node) item.getData(), value.toString()); } // enableNodeSelectionListener(true);
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorActionDelegate.java b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorActionDelegate.java index 96457cd..bf39406 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorActionDelegate.java +++ b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorActionDelegate.java
@@ -27,134 +27,106 @@ import org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage; import org.eclipse.wst.xml.ui.internal.validation.XMLValidationUIMessages; -public class ReferencedFileErrorActionDelegate extends ActionDelegate implements IObjectActionDelegate -{ - protected IMarker selectedMarker; +public class ReferencedFileErrorActionDelegate extends ActionDelegate implements IObjectActionDelegate { + protected IMarker selectedMarker; - /** - * - */ - public ReferencedFileErrorActionDelegate() - { - super(); - } - - public void run(IAction action) - { - if (selectedMarker != null) - { - try - { - - Map map = (Map) selectedMarker.getResource().getSessionProperty(ValidationMessage.ERROR_MESSAGE_MAP_QUALIFIED_NAME); - if (map == null) - { - String infoUnavailable = XMLValidationUIMessages._UI_DETAILS_INFORMATION_UNAVAILABLE; - String revalidateToRegenerateErrors = XMLValidationUIMessages._UI_DETAILS_INFO_REVALIDATE_TO_REGENERATE; - MessageDialog.openInformation(Display.getCurrent().getActiveShell(), infoUnavailable, revalidateToRegenerateErrors); - } - else - { - String uri = null; - - String groupName = (String) selectedMarker.getAttribute("groupName"); //$NON-NLS-1$ - if (groupName.startsWith("referencedFileError")) //$NON-NLS-1$ - { - int index1 = groupName.indexOf("("); //$NON-NLS-1$ - int index2 = groupName.lastIndexOf(")"); //$NON-NLS-1$ - if (index1 != -1 && index2 > index1) - { - uri = groupName.substring(index1 + 1, index2); - } - } - - if (uri != null) - { - List list = Collections.EMPTY_LIST; - - ValidationMessage message = (ValidationMessage) map.get(uri); - if (message != null) - { - list = message.getNestedMessages(); - } - - String validatedFileURI = selectedMarker.getResource().getLocation().toOSString();//URIHelper.normalize(selectedMarker.getResource().getLocation().toOSString()); - validatedFileURI = "file:/" + validatedFileURI; //$NON-NLS-1$ - - ReferencedFileErrorDialog dialog = new ReferencedFileErrorDialog(Display.getCurrent().getActiveShell(), list, validatedFileURI, uri); - dialog.createAndOpen(); - } - } - } - catch (CoreException e) - { - // Do nothing. - } - } - } - - public void selectionChanged(IAction action, ISelection selection) - { - super.selectionChanged(action, selection); - selectedMarker = null; - if (selection instanceof IStructuredSelection) - { - try - { - Object first = ((IStructuredSelection) selection).getFirstElement(); - - IMarker marker = (IMarker)first; - selectedMarker = marker; -// String groupName = (String) marker.getAttribute("groupName"); -// if (groupName.startsWith("referencedFileError")) -// { -// selectedMarker = marker; -// } - } - catch (Exception e) - { - // Do nothing. - } - } - } - /* (non-Javadoc) - * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) - { - //dw int i = 0; - } -} - -/* - private static void printMap(Map map) - { - for (Iterator i = map.keySet().iterator(); i.hasNext();) - { - String key = (String) i.next(); - System.out.println("entry : " + key + " = " + map.get(key)); - } + /** + * + */ + public ReferencedFileErrorActionDelegate() { + super(); } - - private void printErrorMap(Map map) - { - for (Iterator i = map.keySet().iterator(); i.hasNext();) - { - String key = (String) i.next(); - ErrorMessage message = (ErrorMessage) map.get(key); - if (message != null) - { - printErrorMessage(message); + + public void run(IAction action) { + if (selectedMarker != null) { + try { + + Map map = (Map) selectedMarker.getResource().getSessionProperty(ValidationMessage.ERROR_MESSAGE_MAP_QUALIFIED_NAME); + if (map == null) { + String infoUnavailable = XMLValidationUIMessages._UI_DETAILS_INFORMATION_UNAVAILABLE; + String revalidateToRegenerateErrors = XMLValidationUIMessages._UI_DETAILS_INFO_REVALIDATE_TO_REGENERATE; + MessageDialog.openInformation(Display.getCurrent().getActiveShell(), infoUnavailable, revalidateToRegenerateErrors); + } + else { + String uri = null; + + String groupName = (String) selectedMarker.getAttribute("groupName"); //$NON-NLS-1$ + if (groupName.startsWith("referencedFileError")) //$NON-NLS-1$ + { + int index1 = groupName.indexOf("("); //$NON-NLS-1$ + int index2 = groupName.lastIndexOf(")"); //$NON-NLS-1$ + if ((index1 != -1) && (index2 > index1)) { + uri = groupName.substring(index1 + 1, index2); + } + } + + if (uri != null) { + List list = Collections.EMPTY_LIST; + + ValidationMessage message = (ValidationMessage) map.get(uri); + if (message != null) { + list = message.getNestedMessages(); + } + + String validatedFileURI = selectedMarker.getResource().getLocation().toOSString();// URIHelper.normalize(selectedMarker.getResource().getLocation().toOSString()); + validatedFileURI = "file:/" + validatedFileURI; //$NON-NLS-1$ + + ReferencedFileErrorDialog dialog = new ReferencedFileErrorDialog(Display.getCurrent().getActiveShell(), list, validatedFileURI, uri); + dialog.createAndOpen(); + } + } + } + catch (CoreException e) { + // Do nothing. } } } - - private void printErrorMessage(ErrorMessage errorMessage) - { - System.out.println(errorMessage.getText()); - for (Iterator i = errorMessage.getNestedErrors().iterator(); i.hasNext();) - { - printErrorMessage((ErrorMessage) i.next()); + + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + selectedMarker = null; + if (selection instanceof IStructuredSelection) { + try { + Object first = ((IStructuredSelection) selection).getFirstElement(); + + IMarker marker = (IMarker) first; + selectedMarker = marker; + // String groupName = (String) + // marker.getAttribute("groupName"); + // if (groupName.startsWith("referencedFileError")) + // { + // selectedMarker = marker; + // } + } + catch (Exception e) { + // Do nothing. + } } } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, + * org.eclipse.ui.IWorkbenchPart) + */ + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + // dw int i = 0; + } +} + +/* + * private static void printMap(Map map) { for (Iterator i = + * map.keySet().iterator(); i.hasNext();) { String key = (String) i.next(); + * System.out.println("entry : " + key + " = " + map.get(key)); } } + * + * private void printErrorMap(Map map) { for (Iterator i = + * map.keySet().iterator(); i.hasNext();) { String key = (String) i.next(); + * ErrorMessage message = (ErrorMessage) map.get(key); if (message != null) { + * printErrorMessage(message); } } } + * + * private void printErrorMessage(ErrorMessage errorMessage) { + * System.out.println(errorMessage.getText()); for (Iterator i = + * errorMessage.getNestedErrors().iterator(); i.hasNext();) { + * printErrorMessage((ErrorMessage) i.next()); } } */ \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorDialog.java b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorDialog.java index dc465c6..d3e8790 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorDialog.java +++ b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorDialog.java
@@ -35,251 +35,220 @@ import org.eclipse.wst.xml.ui.internal.validation.XMLValidationUIMessages; -public class ReferencedFileErrorDialog extends Dialog -{ - protected TaskListTableViewer tableViewer; - protected List errorList; - protected String markedUpDetailsMessage; - protected String contextFile; - protected String referencedFile; - protected StyledText styledText; - protected Text fullFileNameField; +public class ReferencedFileErrorDialog extends Dialog { + protected TaskListTableViewer tableViewer; + protected List errorList; + protected String markedUpDetailsMessage; + protected String contextFile; + protected String referencedFile; + protected StyledText styledText; + protected Text fullFileNameField; - public ReferencedFileErrorDialog(Shell parentShell, List errorList, String contextFile, String referencedFile) - { - super(parentShell); + public ReferencedFileErrorDialog(Shell parentShell, List errorList, String contextFile, String referencedFile) { + super(parentShell); - int styleBits = getShellStyle() | SWT.RESIZE; - styleBits &= ~SWT.APPLICATION_MODAL; + int styleBits = getShellStyle() | SWT.RESIZE; + styleBits &= ~SWT.APPLICATION_MODAL; - setShellStyle(styleBits); - this.errorList = errorList; + setShellStyle(styleBits); + this.errorList = errorList; - this.referencedFile = referencedFile; - this.contextFile = contextFile; - this.markedUpDetailsMessage = getMarkedUpDetailsMessage(); - } + this.referencedFile = referencedFile; + this.contextFile = contextFile; + this.markedUpDetailsMessage = getMarkedUpDetailsMessage(); + } - public int createAndOpen() - { - create(); - getShell().setText(XMLValidationUIMessages._UI_REF_FILE_ERROR_DETAILS); - - setBlockOnOpen(false); - return open(); - } + public int createAndOpen() { + create(); + getShell().setText(XMLValidationUIMessages._UI_REF_FILE_ERROR_DETAILS); + + setBlockOnOpen(false); + return open(); + } - protected Control createButtonBar(Composite parent) - { - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout(2, false)); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + protected Control createButtonBar(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(new GridLayout(2, false)); + composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - fullFileNameField = new Text(composite, SWT.NONE); - fullFileNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - fullFileNameField.setBackground(parent.getBackground()); - fullFileNameField.setEditable(false); + fullFileNameField = new Text(composite, SWT.NONE); + fullFileNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + fullFileNameField.setBackground(parent.getBackground()); + fullFileNameField.setEditable(false); - super.createButtonBar(composite); + super.createButtonBar(composite); - return composite; - } + return composite; + } - protected Control createDialogArea(Composite parent) - { - Composite dialogArea = (Composite) super.createDialogArea(parent); - dialogArea.setLayout(new GridLayout()); + protected Control createDialogArea(Composite parent) { + Composite dialogArea = (Composite) super.createDialogArea(parent); + dialogArea.setLayout(new GridLayout()); - Composite c = new Composite(dialogArea, SWT.NONE); - c.setLayout(new GridLayout()); - c.setLayoutData(createGridData(true, -1, 200)); + Composite c = new Composite(dialogArea, SWT.NONE); + c.setLayout(new GridLayout()); + c.setLayoutData(createGridData(true, -1, 200)); - styledText = new StyledText(c, SWT.MULTI | SWT.WRAP); - styledText.setBackground(c.getBackground()); - setStyledText(styledText, markedUpDetailsMessage); - styledText.setEditable(false); - styledText.setLayoutData(createGridData(false, 650, -1)); + styledText = new StyledText(c, SWT.MULTI | SWT.WRAP); + styledText.setBackground(c.getBackground()); + setStyledText(styledText, markedUpDetailsMessage); + styledText.setEditable(false); + styledText.setLayoutData(createGridData(false, 650, -1)); - MouseListener mouseListener = new MouseListener(); - styledText.addMouseMoveListener(mouseListener); + MouseListener mouseListener = new MouseListener(); + styledText.addMouseMoveListener(mouseListener); - tableViewer = new TaskListTableViewer(c, 10); - tableViewer.setInput(errorList); - tableViewer.addSelectionChangedListener(new InternalSelectionListener()); - tableViewer.getControl().setLayoutData(createGridData(true, 700, -1)); - return dialogArea; - } + tableViewer = new TaskListTableViewer(c, 10); + tableViewer.setInput(errorList); + tableViewer.addSelectionChangedListener(new InternalSelectionListener()); + tableViewer.getControl().setLayoutData(createGridData(true, 700, -1)); + return dialogArea; + } - String getFullURI(int offset) - { - String uri = ""; //$NON-NLS-1$ - int index = getIndex(offset); - if (index != -1) - { - if (index == 0 || index == 2 || index == 3) - { - uri = referencedFile; - } - else - { - uri = contextFile; - } - } - return uri; - } + String getFullURI(int offset) { + String uri = ""; //$NON-NLS-1$ + int index = getIndex(offset); + if (index != -1) { + if ((index == 0) || (index == 2) || (index == 3)) { + uri = referencedFile; + } + else { + uri = contextFile; + } + } + return uri; + } - private int getIndex(int offset) - { - int result = -1; - StyleRange[] range = styledText.getStyleRanges(); - for (int i = 0; i < range.length; i++) - { - int l = range[i].start; - int r = l + range[i].length; - if (l <= offset && r >= offset) - { - result = i; - break; - } - } - return result; - } + private int getIndex(int offset) { + int result = -1; + StyleRange[] range = styledText.getStyleRanges(); + for (int i = 0; i < range.length; i++) { + int l = range[i].start; + int r = l + range[i].length; + if ((l <= offset) && (r >= offset)) { + result = i; + break; + } + } + return result; + } - class MouseListener implements MouseMoveListener - { - public void mouseMove(MouseEvent event) - { - String toolTipText = ""; //$NON-NLS-1$ - try - { + class MouseListener implements MouseMoveListener { + public void mouseMove(MouseEvent event) { + String toolTipText = ""; //$NON-NLS-1$ + try { - int offset = styledText.getOffsetAtLocation(new Point(event.x, event.y)); - toolTipText = getFullURI(offset); + int offset = styledText.getOffsetAtLocation(new Point(event.x, event.y)); + toolTipText = getFullURI(offset); - } - catch (Exception e) - { - // Do nothing. - } - styledText.setToolTipText(toolTipText); - if (toolTipText != null && toolTipText.length() > 0) - { - fullFileNameField.setText(toolTipText); - } - } - } + } + catch (Exception e) { + // Do nothing. + } + styledText.setToolTipText(toolTipText); + if ((toolTipText != null) && (toolTipText.length() > 0)) { + fullFileNameField.setText(toolTipText); + } + } + } - private String getMarkedUpDetailsMessage() - { - String detailsMessage = ""; //$NON-NLS-1$ - // TODO... need to move '_UI_REF_FILE_ERROR_DESCRIPTION' to this plugin's properties file - // - String string = XMLValidationUIMessages._UI_REF_FILE_ERROR_DESCRIPTION; - // TODO... need to edit the properties file to remove "'" characters from the string - // I'm using these characters to markup the bold font. It's safer if I add these programtically. - // - string = removePattern(string, "'"); //$NON-NLS-1$ + private String getMarkedUpDetailsMessage() { + String detailsMessage = ""; //$NON-NLS-1$ + // TODO... need to move '_UI_REF_FILE_ERROR_DESCRIPTION' to this + // plugin's properties file + // + String string = XMLValidationUIMessages._UI_REF_FILE_ERROR_DESCRIPTION; + // TODO... need to edit the properties file to remove "'" characters + // from the string + // I'm using these characters to markup the bold font. It's safer if I + // add these programtically. + // + string = removePattern(string, "'"); //$NON-NLS-1$ - String c = "'" + getLastSegment(contextFile) + "'"; //$NON-NLS-1$ //$NON-NLS-2$ - String r = "'" + getLastSegment(referencedFile) + "'"; //$NON-NLS-1$ //$NON-NLS-2$ + String c = "'" + getLastSegment(contextFile) + "'"; //$NON-NLS-1$ //$NON-NLS-2$ + String r = "'" + getLastSegment(referencedFile) + "'"; //$NON-NLS-1$ //$NON-NLS-2$ - detailsMessage = NLS.bind(string, new Object[] { r, c, r, c }); - return detailsMessage; - } + detailsMessage = NLS.bind(string, new Object[]{r, c, r, c}); + return detailsMessage; + } - private String removePattern(String string, String pattern) - { - while (true) - { - int index = string.indexOf(pattern); - if (index != -1) - { - string = string.substring(0, index) + string.substring(index + pattern.length()); - } - else - { - break; - } - } - return string; - } + private String removePattern(String string, String pattern) { + while (true) { + int index = string.indexOf(pattern); + if (index != -1) { + string = string.substring(0, index) + string.substring(index + pattern.length()); + } + else { + break; + } + } + return string; + } - private void setStyledText(StyledText styledText, String text) - { - String visibleMessage = ""; //$NON-NLS-1$ - for (StringTokenizer st = new StringTokenizer(markedUpDetailsMessage, "'", false); st.hasMoreTokens();) //$NON-NLS-1$ - { - String token = st.nextToken(); - visibleMessage += token; - } + private void setStyledText(StyledText styledText, String text) { + String visibleMessage = ""; //$NON-NLS-1$ + for (StringTokenizer st = new StringTokenizer(markedUpDetailsMessage, "'", false); st.hasMoreTokens();) //$NON-NLS-1$ + { + String token = st.nextToken(); + visibleMessage += token; + } - styledText.setText(visibleMessage); - //dw Font font = styledText.getFont(); + styledText.setText(visibleMessage); + // dw Font font = styledText.getFont(); - boolean inQuote = false; - int position = 0; - for (StringTokenizer st = new StringTokenizer(markedUpDetailsMessage, "'", true); st.hasMoreTokens();) //$NON-NLS-1$ - { - String token = st.nextToken(); + boolean inQuote = false; + int position = 0; + for (StringTokenizer st = new StringTokenizer(markedUpDetailsMessage, "'", true); st.hasMoreTokens();) //$NON-NLS-1$ + { + String token = st.nextToken(); - if (token.equals("'")) //$NON-NLS-1$ - { - inQuote = !inQuote; - } - else - { - if (inQuote) - { - try - { + if (token.equals("'")) //$NON-NLS-1$ + { + inQuote = !inQuote; + } + else { + if (inQuote) { + try { - StyleRange style = new StyleRange(position, token.length(), styledText.getForeground(), styledText.getBackground(), SWT.BOLD); - styledText.setStyleRange(style); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - position = position + token.length(); - } - } - } + StyleRange style = new StyleRange(position, token.length(), styledText.getForeground(), styledText.getBackground(), SWT.BOLD); + styledText.setStyleRange(style); + } + catch (Exception e) { + e.printStackTrace(); + } + } + position = position + token.length(); + } + } + } - private static GridData createGridData(boolean fillBoth, int w, int h) - { - GridData gd = new GridData(fillBoth ? GridData.FILL_BOTH : GridData.FILL_HORIZONTAL); - gd.widthHint = w; - gd.heightHint = h; - return gd; - } - - private static String getLastSegment(String uri) - { - String result = uri; - int index = Math.max(uri.lastIndexOf("/"), uri.lastIndexOf("\\")); //$NON-NLS-1$ //$NON-NLS-2$ - if (index != -1) - { - result = uri.substring(index + 1); - } - return result; - } + private static GridData createGridData(boolean fillBoth, int w, int h) { + GridData gd = new GridData(fillBoth ? GridData.FILL_BOTH : GridData.FILL_HORIZONTAL); + gd.widthHint = w; + gd.heightHint = h; + return gd; + } - protected class InternalSelectionListener implements ISelectionChangedListener - { - public void selectionChanged(SelectionChangedEvent event) - { - ISelection selection = event.getSelection(); - if (selection instanceof StructuredSelection) - { - ValidationMessage validationMessage = (ValidationMessage) ((StructuredSelection) selection).getFirstElement(); - if (validationMessage != null) - { - String uristring = validationMessage.getUri(); - ReferencedFileErrorUtility.openEditorAndGotoError(uristring, validationMessage.getLineNumber(), validationMessage.getColumnNumber()); - } - } - } - } + private static String getLastSegment(String uri) { + String result = uri; + int index = Math.max(uri.lastIndexOf("/"), uri.lastIndexOf("\\")); //$NON-NLS-1$ //$NON-NLS-2$ + if (index != -1) { + result = uri.substring(index + 1); + } + return result; + } + + protected class InternalSelectionListener implements ISelectionChangedListener { + public void selectionChanged(SelectionChangedEvent event) { + ISelection selection = event.getSelection(); + if (selection instanceof StructuredSelection) { + ValidationMessage validationMessage = (ValidationMessage) ((StructuredSelection) selection).getFirstElement(); + if (validationMessage != null) { + String uristring = validationMessage.getUri(); + ReferencedFileErrorUtility.openEditorAndGotoError(uristring, validationMessage.getLineNumber(), validationMessage.getColumnNumber()); + } + } + } + } } \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorUtility.java b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorUtility.java index b30df8c..11c186c 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorUtility.java +++ b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorUtility.java
@@ -31,101 +31,83 @@ import org.eclipse.wst.xml.ui.internal.XMLUIPlugin; -public class ReferencedFileErrorUtility -{ - public static void openEditorAndGotoError(String uristring, final int line, final int column) - { - if (uristring != null) - { - try - { - URL uri = new URL(uristring); - if (uri != null) - { - if ("file".equals(uri.getProtocol())) //$NON-NLS-1$ - { - String pathString = uri.getPath(); - IPath path = new Path(pathString); - String device = path.getDevice(); - if (device != null && device.startsWith("/")) //$NON-NLS-1$ - { - path = path.setDevice(device.substring(1)); - } - IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path); - if (file != null && file.exists()) - { - //WorkbenchUtility.openEditor(file); - // Open the editor for this file. - final IFile iFile = file; - IWorkbench workbench = XMLUIPlugin.getInstance().getWorkbench(); - final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); +public class ReferencedFileErrorUtility { + public static void openEditorAndGotoError(String uristring, final int line, final int column) { + if (uristring != null) { + try { + URL uri = new URL(uristring); + if (uri != null) { + if ("file".equals(uri.getProtocol())) //$NON-NLS-1$ + { + String pathString = uri.getPath(); + IPath path = new Path(pathString); + String device = path.getDevice(); + if ((device != null) && device.startsWith("/")) //$NON-NLS-1$ + { + path = path.setDevice(device.substring(1)); + } + IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path); + if ((file != null) && file.exists()) { + // WorkbenchUtility.openEditor(file); + // Open the editor for this file. + final IFile iFile = file; + IWorkbench workbench = XMLUIPlugin.getInstance().getWorkbench(); + final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - Display.getDefault().asyncExec - (new Runnable() - { - public void run() - { - try - { - IEditorDescriptor descriptor = XMLUIPlugin.getInstance().getWorkbench().getEditorRegistry().getDefaultEditor(iFile.getName()); - String editorId; - if(descriptor != null) - { - editorId = descriptor.getId(); - } - else - { - editorId = XMLUIPlugin.getInstance().getWorkbench().getEditorRegistry().getDefaultEditor(iFile.getName() + ".txt").getId(); //$NON-NLS-1$ - } - workbenchWindow.getActivePage().openEditor(new FileEditorInput(iFile), editorId); - } - catch (PartInitException ex) - { - LoggerFactory.getLoggerInstance().logError("Exception encountered when attempting to open file: " + iFile + "\n\n", ex); //$NON-NLS-1$ //$NON-NLS-2$ - //B2BGUIPlugin.getPlugin().getMsgLogger().write("Exception encountered when attempting to open file: " + iFile + "\n\n" + ex); - } - } - }); - - Runnable runnable = new Runnable() - { - public void run() - { - //IEditorPart editorPart = WorkbenchUtility.getActiveEditor(); - IEditorPart editorPart = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - gotoError(editorPart, line, column); - } - }; - Display.getCurrent().asyncExec(runnable); - } - } - } - } - catch (Exception e) - { - // Do nothing. - } - } - } + Display.getDefault().asyncExec(new Runnable() { + public void run() { + try { + IEditorDescriptor descriptor = XMLUIPlugin.getInstance().getWorkbench().getEditorRegistry().getDefaultEditor(iFile.getName()); + String editorId; + if (descriptor != null) { + editorId = descriptor.getId(); + } + else { + editorId = XMLUIPlugin.getInstance().getWorkbench().getEditorRegistry().getDefaultEditor(iFile.getName() + ".txt").getId(); //$NON-NLS-1$ + } + workbenchWindow.getActivePage().openEditor(new FileEditorInput(iFile), editorId); + } + catch (PartInitException ex) { + LoggerFactory.getLoggerInstance().logError("Exception encountered when attempting to open file: " + iFile + "\n\n", ex); //$NON-NLS-1$ //$NON-NLS-2$ + // B2BGUIPlugin.getPlugin().getMsgLogger().write("Exception + // encountered when attempting to open + // file: " + iFile + "\n\n" + ex); + } + } + }); - static void gotoError(IEditorPart editorPart, int line, int column) - { - if (editorPart != null) - { - TextEditor textEditor = (TextEditor) editorPart.getAdapter(TextEditor.class); - if (textEditor != null) - { - try - { - IDocumentProvider dp = textEditor.getDocumentProvider(); - IDocument document = (dp != null) ? dp.getDocument(textEditor.getEditorInput()) : null; - textEditor.selectAndReveal(document.getLineOffset(line - 1) + column - 1, 0); - } - catch (BadLocationException x) - { - // marker refers to invalid text position -> do nothing - } - } - } - } + Runnable runnable = new Runnable() { + public void run() { + // IEditorPart editorPart = + // WorkbenchUtility.getActiveEditor(); + IEditorPart editorPart = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + gotoError(editorPart, line, column); + } + }; + Display.getCurrent().asyncExec(runnable); + } + } + } + } + catch (Exception e) { + // Do nothing. + } + } + } + + static void gotoError(IEditorPart editorPart, int line, int column) { + if (editorPart != null) { + TextEditor textEditor = (TextEditor) editorPart.getAdapter(TextEditor.class); + if (textEditor != null) { + try { + IDocumentProvider dp = textEditor.getDocumentProvider(); + IDocument document = (dp != null) ? dp.getDocument(textEditor.getEditorInput()) : null; + textEditor.selectAndReveal(document.getLineOffset(line - 1) + column - 1, 0); + } + catch (BadLocationException x) { + // marker refers to invalid text position -> do nothing + } + } + } + } } \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/TaskListTableViewer.java b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/TaskListTableViewer.java index 55a5610..1421e53 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/TaskListTableViewer.java +++ b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/TaskListTableViewer.java
@@ -33,150 +33,127 @@ -public class TaskListTableViewer extends TableViewer -{ - protected static final int COLUMN_ICON = 0; - protected static final int COLUMN_DESCRIPTION = 1; - protected static final int COLUMN_RESOURCE = 3; - protected static final int COLUMN_LOCATION = 2; +public class TaskListTableViewer extends TableViewer { + protected static final int COLUMN_ICON = 0; + protected static final int COLUMN_DESCRIPTION = 1; + protected static final int COLUMN_RESOURCE = 3; + protected static final int COLUMN_LOCATION = 2; - protected static final String LABEL_ICON = ""; //$NON-NLS-1$ - protected static final String LABEL_DESCRIPTION = XMLValidationUIMessages.TaskListTableViewer_0; - protected static final String LABEL_RESOURCE = XMLValidationUIMessages.TaskListTableViewer_1; - protected static final String LABEL_LOCATION = XMLValidationUIMessages.TaskListTableViewer_2; + protected static final String LABEL_ICON = ""; //$NON-NLS-1$ + protected static final String LABEL_DESCRIPTION = XMLValidationUIMessages.TaskListTableViewer_0; + protected static final String LABEL_RESOURCE = XMLValidationUIMessages.TaskListTableViewer_1; + protected static final String LABEL_LOCATION = XMLValidationUIMessages.TaskListTableViewer_2; - protected int visibleRows = -1; + protected int visibleRows = -1; - protected int getColumnWidth(int column) - { - int result = 0; - switch (column) - { - case COLUMN_ICON : - { - result = 1; - break; - } - case COLUMN_DESCRIPTION : - { - result = 20; - break; - } - case COLUMN_RESOURCE : - { - result = 3; - break; - } - case COLUMN_LOCATION : - { - result = 3; - break; - } - } - return result; - } + protected int getColumnWidth(int column) { + int result = 0; + switch (column) { + case COLUMN_ICON : { + result = 1; + break; + } + case COLUMN_DESCRIPTION : { + result = 20; + break; + } + case COLUMN_RESOURCE : { + result = 3; + break; + } + case COLUMN_LOCATION : { + result = 3; + break; + } + } + return result; + } - public TaskListTableViewer(Composite parent, int visibleRows) - { - this(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER, visibleRows); - } + public TaskListTableViewer(Composite parent, int visibleRows) { + this(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER, visibleRows); + } - public TaskListTableViewer(Composite parent, int style, int visibleRows) - { - super(new Table(parent, style)); - getTable().setLinesVisible(true); + public TaskListTableViewer(Composite parent, int style, int visibleRows) { + super(new Table(parent, style)); + getTable().setLinesVisible(true); - Provider provider = new Provider(); - setContentProvider(provider); - setLabelProvider(provider); + Provider provider = new Provider(); + setContentProvider(provider); + setLabelProvider(provider); - String[] columnPropertiesArray = { LABEL_ICON, LABEL_DESCRIPTION, LABEL_LOCATION }; - setColumnProperties(columnPropertiesArray); + String[] columnPropertiesArray = {LABEL_ICON, LABEL_DESCRIPTION, LABEL_LOCATION}; + setColumnProperties(columnPropertiesArray); - Table table = getTable(); - table.setHeaderVisible(true); - table.setLayoutData(new GridData(GridData.FILL_BOTH)); + Table table = getTable(); + table.setHeaderVisible(true); + table.setLayoutData(new GridData(GridData.FILL_BOTH)); - TableLayout layout = new TableLayout(); + TableLayout layout = new TableLayout(); - for (int i = 0; i < columnPropertiesArray.length; i++) - { - TableColumn column = new TableColumn(table, i); - column.setText(columnPropertiesArray[i]); - column.setAlignment(SWT.LEFT); - layout.addColumnData(new ColumnWeightData(getColumnWidth(i), true)); - } + for (int i = 0; i < columnPropertiesArray.length; i++) { + TableColumn column = new TableColumn(table, i); + column.setText(columnPropertiesArray[i]); + column.setAlignment(SWT.LEFT); + layout.addColumnData(new ColumnWeightData(getColumnWidth(i), true)); + } - table.setLayout(layout); - - this.visibleRows = visibleRows; - } + table.setLayout(layout); - /** - * NamespaceInfoTableLabelProvider - */ - protected class Provider extends LabelProvider implements ITableLabelProvider, IStructuredContentProvider - { - Viewer viewer; - Image errorImage; - Image warnImage; - - public Provider() - { - errorImage = XMLUIPlugin.getInstance().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); - - warnImage = XMLUIPlugin.getInstance().getImage(ISharedImages.IMG_OBJS_WARN_TSK); - } + this.visibleRows = visibleRows; + } - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - this.viewer = viewer; - } + /** + * NamespaceInfoTableLabelProvider + */ + protected class Provider extends LabelProvider implements ITableLabelProvider, IStructuredContentProvider { + Viewer viewer; + Image errorImage; + Image warnImage; - public Object[] getElements(Object inputElement) - { - List list = (List) viewer.getInput(); - return list != null ? list.toArray() : null; - } + public Provider() { + errorImage = XMLUIPlugin.getInstance().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); - public Image getColumnImage(Object object, int columnIndex) - { - ValidationMessage validationMessage = (ValidationMessage) object; - Image result = null; - if (columnIndex == 0) - { - int severity = validationMessage.getSeverity(); - if (severity == IMessage.HIGH_SEVERITY || - severity == IMessage.NORMAL_SEVERITY) - { - result = errorImage; - } - else - { - result = warnImage; - } - } - return result; - } + warnImage = XMLUIPlugin.getInstance().getImage(ISharedImages.IMG_OBJS_WARN_TSK); + } - public String getColumnText(Object object, int column) - { - ValidationMessage errorMessage = (ValidationMessage) object; - String result = ""; //$NON-NLS-1$ - switch (column) - { - case COLUMN_DESCRIPTION : - { - result = errorMessage.getMessage(); - break; - } - case COLUMN_LOCATION : - { - result = XMLValidationUIMessages.TaskListTableViewer_3 + errorMessage.getLineNumber(); - break; - } - } - return result; - } - } + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + this.viewer = viewer; + } + + public Object[] getElements(Object inputElement) { + List list = (List) viewer.getInput(); + return list != null ? list.toArray() : null; + } + + public Image getColumnImage(Object object, int columnIndex) { + ValidationMessage validationMessage = (ValidationMessage) object; + Image result = null; + if (columnIndex == 0) { + int severity = validationMessage.getSeverity(); + if ((severity == IMessage.HIGH_SEVERITY) || (severity == IMessage.NORMAL_SEVERITY)) { + result = errorImage; + } + else { + result = warnImage; + } + } + return result; + } + + public String getColumnText(Object object, int column) { + ValidationMessage errorMessage = (ValidationMessage) object; + String result = ""; //$NON-NLS-1$ + switch (column) { + case COLUMN_DESCRIPTION : { + result = errorMessage.getMessage(); + break; + } + case COLUMN_LOCATION : { + result = XMLValidationUIMessages.TaskListTableViewer_3 + errorMessage.getLineNumber(); + break; + } + } + return result; + } + } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/ExampleProjectCreationOperation.java b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/ExampleProjectCreationOperation.java index 5212cc2..69c4b51 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/ExampleProjectCreationOperation.java +++ b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/ExampleProjectCreationOperation.java
@@ -112,7 +112,7 @@ } String open = desc.getAttribute("open"); //$NON-NLS-1$ - if (open != null && open.length() > 0) { + if ((open != null) && (open.length() > 0)) { IResource fileToOpen = proj.findMember(new Path(open)); if (fileToOpen != null) { elementToOpen = fileToOpen; @@ -125,7 +125,7 @@ try { IPath destPath; String name = curr.getAttribute("dest"); //$NON-NLS-1$ - if (name == null || name.length() == 0) { + if ((name == null) || (name.length() == 0)) { destPath = project.getFullPath(); } else { @@ -153,8 +153,9 @@ private String getContributingPlugin(IConfigurationElement configurationElement) { Object parent = configurationElement; while (parent != null) { - if (parent instanceof IExtension) + if (parent instanceof IExtension) { return ((IExtension) parent).getNamespace(); + } parent = ((IConfigurationElement) parent).getParent(); } return null;
diff --git a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/ExampleProjectCreationWizard.java b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/ExampleProjectCreationWizard.java index 0f39284..45c9e34 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/ExampleProjectCreationWizard.java +++ b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/ExampleProjectCreationWizard.java
@@ -96,10 +96,11 @@ public void addPages() { super.addPages(); - if (exampleConfigElement == null) + if (exampleConfigElement == null) { return; + } IConfigurationElement[] children = exampleConfigElement.getChildren("projectsetup"); //$NON-NLS-1$ - if (children == null || children.length == 0) { + if ((children == null) || (children.length == 0)) { Logger.log(Logger.ERROR, "descriptor must contain one ore more projectsetup tags"); //$NON-NLS-1$ return; } @@ -111,8 +112,8 @@ addPage(pages[i]); } } - - public void init(IWorkbench workbench, IStructuredSelection currentSelection) { + + public void init(IWorkbench workbench, IStructuredSelection currentSelection) { if (exampleConfigElement != null) { String banner = exampleConfigElement.getAttribute("banner"); //$NON-NLS-1$ if (banner != null) { @@ -121,7 +122,7 @@ setDefaultPageImageDescriptor(desc); } } - } + } protected IConfigurationElement[] getExtendedConfigurationElements() { IExtensionRegistry registry = Platform.getExtensionRegistry(); @@ -150,7 +151,7 @@ Logger.logException(target); } } - + private void openResource(final IResource resource) { if (resource.getType() != IResource.FILE) { return; @@ -212,12 +213,12 @@ if (title != null) { setWindowTitle(title); } - String wizardId = getWizardExtensionId(); //$NON-NLS-1$ + String wizardId = getWizardExtensionId(); IConfigurationElement[] exampleWizardCEs = getExtendedConfigurationElements(); for (int i = 0; i < exampleWizardCEs.length; i++) { IConfigurationElement element = exampleWizardCEs[i]; String extWizardId = element.getAttribute("id"); //$NON-NLS-1$ - if (wizardId != null && extWizardId != null && wizardId.equals(extWizardId)) { + if ((wizardId != null) && (extWizardId != null) && wizardId.equals(extWizardId)) { exampleConfigElement = element; } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/ExampleProjectCreationWizardPage.java b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/ExampleProjectCreationWizardPage.java index a411368..ddf8df0 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/ExampleProjectCreationWizardPage.java +++ b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/ExampleProjectCreationWizardPage.java
@@ -81,12 +81,14 @@ * @see org.eclipse.ui.dialogs.WizardNewProjectCreationPage#validatePage() */ protected boolean validatePage() { - if (!super.validatePage()) + if (!super.validatePage()) { return false; + } String projectName = getProjectName(); - if (projectName == null) + if (projectName == null) { return false; + } IWizard wizard = getWizard(); if (wizard instanceof ExampleProjectCreationWizard) {
diff --git a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NamespaceInfoContentBuilder.java b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NamespaceInfoContentBuilder.java index 5817c01..cb109bb 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NamespaceInfoContentBuilder.java +++ b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NamespaceInfoContentBuilder.java
@@ -19,39 +19,33 @@ import org.eclipse.wst.xml.core.internal.contentmodel.util.ContentBuilder; import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo; -public class NamespaceInfoContentBuilder extends ContentBuilder - { - protected int count = 1; - public List list = new Vector(); - protected Hashtable table = new Hashtable(); +public class NamespaceInfoContentBuilder extends ContentBuilder { + protected int count = 1; + public List list = new Vector(); + protected Hashtable table = new Hashtable(); - public NamespaceInfoContentBuilder() - { - super(); - } - - public void visitCMElementDeclaration(CMElementDeclaration ed) - { - if (ed.getProperty("http://org.eclipse.wst/cm/properties/definitionInfo") != null) //$NON-NLS-1$ - { - super.visitCMElementDeclaration(ed); - } - } + public NamespaceInfoContentBuilder() { + super(); + } - protected void createAnyElementNode(CMAnyElement anyElement) - { - String uri = anyElement.getNamespaceURI(); - if (uri != null && !uri.startsWith("##")) //$NON-NLS-1$ - { - if (table.get(uri) == null) - { - NamespaceInfo info = new NamespaceInfo(); - info.uri = uri; - info.prefix = "p" + count++; //$NON-NLS-1$ - table.put(uri, info); - list.add(info); - } - } - } - } + public void visitCMElementDeclaration(CMElementDeclaration ed) { + if (ed.getProperty("http://org.eclipse.wst/cm/properties/definitionInfo") != null) //$NON-NLS-1$ + { + super.visitCMElementDeclaration(ed); + } + } + protected void createAnyElementNode(CMAnyElement anyElement) { + String uri = anyElement.getNamespaceURI(); + if ((uri != null) && !uri.startsWith("##")) //$NON-NLS-1$ + { + if (table.get(uri) == null) { + NamespaceInfo info = new NamespaceInfo(); + info.uri = uri; + info.prefix = "p" + count++; //$NON-NLS-1$ + table.put(uri, info); + list.add(info); + } + } + } +}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewModelWizard.java b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewModelWizard.java index 809f9d9..9cfcd23 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewModelWizard.java +++ b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewModelWizard.java
@@ -43,313 +43,283 @@ import org.eclipse.ui.dialogs.WizardNewFileCreationPage; import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML; -public class NewModelWizard extends Wizard implements INewWizard -{ - - protected IStructuredSelection fSelection; - protected IWorkbench fWorkbench; - protected String fCurrentDirectory; +public class NewModelWizard extends Wizard implements INewWizard { - public NewModelWizard() - { - super(); - } + protected IStructuredSelection fSelection; + protected IWorkbench fWorkbench; + protected String fCurrentDirectory; - public void init(IWorkbench workbench, IStructuredSelection selection) - { - this.fWorkbench = workbench; - this.fSelection = selection; - } + public NewModelWizard() { + super(); + } - public boolean performFinish() - { - boolean result = true; - WizardPage currentPage = (WizardPage)getContainer().getCurrentPage(); - if (currentPage != null) - { - result = currentPage.isPageComplete(); - } - return result; - } + public void init(IWorkbench workbench, IStructuredSelection selection) { + this.fWorkbench = workbench; + this.fSelection = selection; + } - /** - * showFileDialog - */ - public FileDialog showFileDialog(Shell shell, String defaultDirectory, String defaultFile, String [] filterExtensions) - { - FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); - - // Get the last visit directory if we haven't defined a particular one here. - if (defaultDirectory == null || defaultDirectory.length() == 0) - { - //defaultDirectory = Locate.instance(this).getLastSelectedDirectory(getResourcePath()); - } - - if (defaultDirectory != null && defaultDirectory.length() != 0) - { - fileDialog.setFilterPath(defaultDirectory); - } - - fileDialog.setFileName(defaultFile); - fileDialog.setFilterExtensions(filterExtensions); - - fileDialog.open(); - - return fileDialog; - } - - - public void setCurrentDirectory(String currentDirectory1) - { - this.fCurrentDirectory = currentDirectory1; - } - - - public void createWorkbenchResource(IContainer container, String fileName) - { - IPath path = container.getFullPath(); - path = path.append(fileName); - IFile file = container.getWorkspace().getRoot().getFile(path); - if (!file.exists()) - { - try - { - file.create(null, true, null); - } - catch (CoreException e) - { - //XMLBuilderPlugin.getPlugin().getMsgLogger().write("Encountered exception creating file: " + e.getMessage()); - } - } - } - - /** - * StartPage - */ - public class StartPage extends WizardPage implements Listener - { - protected int selectedButton; - protected String[] radioButtonLabel; - protected Button[] radioButton; - - public StartPage(String pageName, String[] radioButtonLabel) - { - super(pageName); - this.radioButtonLabel = radioButtonLabel; - radioButton = new Button[radioButtonLabel.length]; - } - - public Button getRadioButtonAtIndex(int i) - { - Button result = null; - if (i >= 0 && i < radioButton.length) - { - result = radioButton[i]; - } - return result; - } - - public int getSelectedRadioButtonIndex() - { - int result = -1; - for (int i = 0; i < radioButton.length; i++) - { - if (radioButton[i].getSelection()) - { - result = i; - } - } - return result; - } - - public void createControl(Composite parent) - { - Composite base = new Composite(parent, SWT.NONE); - base.setLayout(new GridLayout()); - - //radio buttons' container - Composite radioButtonsGroup = new Composite(base, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.makeColumnsEqualWidth = true; - layout.marginWidth = 0; - - radioButtonsGroup.setLayout(layout); - GridData gd = new GridData(GridData.FILL_BOTH); - gd.heightHint = 300; - gd.widthHint = 400; - radioButtonsGroup.setLayoutData(gd); - - for (int i = 0; i < radioButtonLabel.length; i++) - { - radioButton[i] = new Button(radioButtonsGroup, SWT.RADIO); - radioButton[i].setText(radioButtonLabel[i]); - radioButton[i].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - //radioButton[i].addListener(SWT.Modify, this); - } - setControl(base); - setPageComplete(isPageComplete()); - Dialog.applyDialogFont(parent); - } - - public void handleEvent(Event event) - { - if (event.type == SWT.Modify) - { - setPageComplete(isPageComplete()); - } - } - } - - - /** - * NewFilePage - */ - public class NewFilePage extends WizardNewFileCreationPage - { - public String defaultName = "NewFile"; //$NON-NLS-1$ - public String defaultFileExtension = ".txt"; //$NON-NLS-1$ - public String[] filterExtensions = { "*.txt"}; //$NON-NLS-1$ - private List fValidExtensions = null; - - public NewFilePage(IStructuredSelection selection) - { - super("", selection); //$NON-NLS-1$ - } - - protected String computeDefaultFileName() - { - int count = 0; - String fileName = defaultName + defaultFileExtension; - IPath containerFullPath = getContainerFullPath(); - if (containerFullPath != null) - { - while (true) - { - IPath path = containerFullPath.append(fileName); - if (ResourcesPlugin.getWorkspace().getRoot().exists(path)) - { - count++; - fileName = defaultName + count + defaultFileExtension; - } - else - { - break; - } - } - } - return fileName; - } - - // returns true if file of specified name exists in any case for selected container - protected String existsFileAnyCase(String fileName) - { - if ( (getContainerFullPath() != null) && (getContainerFullPath().isEmpty() == false) - && (fileName.compareTo("") != 0)) //$NON-NLS-1$ - { - //look through all resources at the specified container - compare in upper case - IResource parent = ResourcesPlugin.getWorkspace().getRoot().findMember(getContainerFullPath()); - if (parent instanceof IContainer) - { - IContainer container = (IContainer) parent; - try - { - IResource[] members = container.members(); - String enteredFileUpper = fileName.toUpperCase(); - for (int i=0; i<members.length; i++) - { - String resourceUpperName = members[i].getName().toUpperCase(); - if (resourceUpperName.equals(enteredFileUpper)) - { - return members[i].getName(); - } - } - } - catch (CoreException e) - { - } - } - } - return null; - } - - - protected boolean validatePage() { - String fullFileName = getFileName(); - if (!extensionValidForContentType(fullFileName)) { - setErrorMessage(NLS.bind(XMLWizardsMessages._ERROR_BAD_FILENAME_EXTENSION, getValidExtensions().toString())); - return false; + public boolean performFinish() { + boolean result = true; + WizardPage currentPage = (WizardPage) getContainer().getCurrentPage(); + if (currentPage != null) { + result = currentPage.isPageComplete(); } - // no fileExtension, let's check for this file with default file extension - fullFileName += defaultFileExtension; - if ((getContainerFullPath() != null) && (getContainerFullPath().isEmpty() == false) && (getFileName().compareTo("") != 0)) //$NON-NLS-1$ - { - Path fullPath = new Path(getContainerFullPath().toString() + '/' + fullFileName); - IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(fullPath); - if (resource != null) { - setErrorMessage(XMLWizardsMessages._ERROR_FILE_ALREADY_EXISTS); + return result; + } + + /** + * showFileDialog + */ + public FileDialog showFileDialog(Shell shell, String defaultDirectory, String defaultFile, String[] filterExtensions) { + FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); + + // Get the last visit directory if we haven't defined a particular one + // here. + if ((defaultDirectory == null) || (defaultDirectory.length() == 0)) { + // defaultDirectory = + // Locate.instance(this).getLastSelectedDirectory(getResourcePath()); + } + + if ((defaultDirectory != null) && (defaultDirectory.length() != 0)) { + fileDialog.setFilterPath(defaultDirectory); + } + + fileDialog.setFileName(defaultFile); + fileDialog.setFilterExtensions(filterExtensions); + + fileDialog.open(); + + return fileDialog; + } + + + public void setCurrentDirectory(String currentDirectory1) { + this.fCurrentDirectory = currentDirectory1; + } + + + public void createWorkbenchResource(IContainer container, String fileName) { + IPath path = container.getFullPath(); + path = path.append(fileName); + IFile file = container.getWorkspace().getRoot().getFile(path); + if (!file.exists()) { + try { + file.create(null, true, null); + } + catch (CoreException e) { + // XMLBuilderPlugin.getPlugin().getMsgLogger().write("Encountered + // exception creating file: " + e.getMessage()); + } + } + } + + /** + * StartPage + */ + public class StartPage extends WizardPage implements Listener { + protected int selectedButton; + protected String[] radioButtonLabel; + protected Button[] radioButton; + + public StartPage(String pageName, String[] radioButtonLabel) { + super(pageName); + this.radioButtonLabel = radioButtonLabel; + radioButton = new Button[radioButtonLabel.length]; + } + + public Button getRadioButtonAtIndex(int i) { + Button result = null; + if ((i >= 0) && (i < radioButton.length)) { + result = radioButton[i]; + } + return result; + } + + public int getSelectedRadioButtonIndex() { + int result = -1; + for (int i = 0; i < radioButton.length; i++) { + if (radioButton[i].getSelection()) { + result = i; + } + } + return result; + } + + public void createControl(Composite parent) { + Composite base = new Composite(parent, SWT.NONE); + base.setLayout(new GridLayout()); + + // radio buttons' container + Composite radioButtonsGroup = new Composite(base, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 1; + layout.makeColumnsEqualWidth = true; + layout.marginWidth = 0; + + radioButtonsGroup.setLayout(layout); + GridData gd = new GridData(GridData.FILL_BOTH); + gd.heightHint = 300; + gd.widthHint = 400; + radioButtonsGroup.setLayoutData(gd); + + for (int i = 0; i < radioButtonLabel.length; i++) { + radioButton[i] = new Button(radioButtonsGroup, SWT.RADIO); + radioButton[i].setText(radioButtonLabel[i]); + radioButton[i].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + // radioButton[i].addListener(SWT.Modify, this); + } + setControl(base); + setPageComplete(isPageComplete()); + Dialog.applyDialogFont(parent); + } + + public void handleEvent(Event event) { + if (event.type == SWT.Modify) { + setPageComplete(isPageComplete()); + } + } + } + + + /** + * NewFilePage + */ + public class NewFilePage extends WizardNewFileCreationPage { + public String defaultName = "NewFile"; //$NON-NLS-1$ + public String defaultFileExtension = ".txt"; //$NON-NLS-1$ + public String[] filterExtensions = {"*.txt"}; //$NON-NLS-1$ + private List fValidExtensions = null; + + public NewFilePage(IStructuredSelection selection) { + super("", selection); //$NON-NLS-1$ + } + + protected String computeDefaultFileName() { + int count = 0; + String fileName = defaultName + defaultFileExtension; + IPath containerFullPath = getContainerFullPath(); + if (containerFullPath != null) { + while (true) { + IPath path = containerFullPath.append(fileName); + if (ResourcesPlugin.getWorkspace().getRoot().exists(path)) { + count++; + fileName = defaultName + count + defaultFileExtension; + } + else { + break; + } + } + } + return fileName; + } + + // returns true if file of specified name exists in any case for + // selected container + protected String existsFileAnyCase(String fileName) { + if ((getContainerFullPath() != null) && (getContainerFullPath().isEmpty() == false) && (fileName.compareTo("") != 0)) //$NON-NLS-1$ + { + // look through all resources at the specified container - + // compare in upper case + IResource parent = ResourcesPlugin.getWorkspace().getRoot().findMember(getContainerFullPath()); + if (parent instanceof IContainer) { + IContainer container = (IContainer) parent; + try { + IResource[] members = container.members(); + String enteredFileUpper = fileName.toUpperCase(); + for (int i = 0; i < members.length; i++) { + String resourceUpperName = members[i].getName().toUpperCase(); + if (resourceUpperName.equals(enteredFileUpper)) { + return members[i].getName(); + } + } + } + catch (CoreException e) { + } + } + } + return null; + } + + + protected boolean validatePage() { + String fullFileName = getFileName(); + if (!extensionValidForContentType(fullFileName)) { + setErrorMessage(NLS.bind(XMLWizardsMessages._ERROR_BAD_FILENAME_EXTENSION, getValidExtensions().toString())); return false; } - } - - // check for file should be case insensitive - String sameName = existsFileAnyCase(fullFileName); - if (sameName != null) { - //ISSUE: is qualitifedFileName not needed, or is it supposed to be used in error message? - //String qualifiedFileName = getContainerFullPath().toString() + '/' + fullFileName; - setErrorMessage(XMLWizardsMessages._ERROR_FILE_ALREADY_EXISTS + " " + sameName); //$NON-NLS-1$ - return false; - } - - return super.validatePage(); - } - - public void createControl(Composite parent) - { - // inherit default container and name specification widgets - super.createControl(parent); - this.setFileName(computeDefaultFileName()); - setPageComplete(validatePage()); - } - - /** - * Get list of valid extensions for XML Content type - * - * @return List - */ - List getValidExtensions() { - if (fValidExtensions == null) { - IContentType type = Platform.getContentTypeManager().getContentType(ContentTypeIdForXML.ContentTypeID_XML); - fValidExtensions = new ArrayList(Arrays.asList(type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC))); - } - return fValidExtensions; - } - - /** - * Verifies if fileName is valid name for content type. Takes base content - * type into consideration. - * - * @param fileName - * @return true if extension is valid for this content type - */ - boolean extensionValidForContentType(String fileName) { - boolean valid = false; - - IContentType type = Platform.getContentTypeManager().getContentType(ContentTypeIdForXML.ContentTypeID_XML); - // there is currently an extension - if (fileName.lastIndexOf('.') != -1) { - // check what content types are associated with current extension - IContentType[] types = Platform.getContentTypeManager().findContentTypesFor(fileName); - int i = 0; - while (i < types.length && !valid) { - valid = types[i].isKindOf(type); - ++i; + // no fileExtension, let's check for this file with default file + // extension + fullFileName += defaultFileExtension; + if ((getContainerFullPath() != null) && (getContainerFullPath().isEmpty() == false) && (getFileName().compareTo("") != 0)) //$NON-NLS-1$ + { + Path fullPath = new Path(getContainerFullPath().toString() + '/' + fullFileName); + IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(fullPath); + if (resource != null) { + setErrorMessage(XMLWizardsMessages._ERROR_FILE_ALREADY_EXISTS); + return false; + } } - } - else - valid = true; // no extension so valid - return valid; - } - } -} + // check for file should be case insensitive + String sameName = existsFileAnyCase(fullFileName); + if (sameName != null) { + // ISSUE: is qualitifedFileName not needed, or is it supposed + // to be used in error message? + // String qualifiedFileName = + // getContainerFullPath().toString() + '/' + fullFileName; + setErrorMessage(XMLWizardsMessages._ERROR_FILE_ALREADY_EXISTS + " " + sameName); //$NON-NLS-1$ + return false; + } + + return super.validatePage(); + } + + public void createControl(Composite parent) { + // inherit default container and name specification widgets + super.createControl(parent); + this.setFileName(computeDefaultFileName()); + setPageComplete(validatePage()); + } + + /** + * Get list of valid extensions for XML Content type + * + * @return List + */ + List getValidExtensions() { + if (fValidExtensions == null) { + IContentType type = Platform.getContentTypeManager().getContentType(ContentTypeIdForXML.ContentTypeID_XML); + fValidExtensions = new ArrayList(Arrays.asList(type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC))); + } + return fValidExtensions; + } + + /** + * Verifies if fileName is valid name for content type. Takes base + * content type into consideration. + * + * @param fileName + * @return true if extension is valid for this content type + */ + boolean extensionValidForContentType(String fileName) { + boolean valid = false; + + IContentType type = Platform.getContentTypeManager().getContentType(ContentTypeIdForXML.ContentTypeID_XML); + // there is currently an extension + if (fileName.lastIndexOf('.') != -1) { + // check what content types are associated with current + // extension + IContentType[] types = Platform.getContentTypeManager().findContentTypesFor(fileName); + int i = 0; + while ((i < types.length) && !valid) { + valid = types[i].isKindOf(type); + ++i; + } + } + else { + valid = true; // no extension so valid + } + return valid; + } + } +}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLGenerator.java b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLGenerator.java index 6ef29f3..c4bbb88 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLGenerator.java +++ b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLGenerator.java
@@ -78,7 +78,7 @@ CMDocument cmDocument = null; if (URIHelper.isReadableURI(uri, true)) { - // (cs) assume the uri has been provided in a normalized form + // (cs) assume the uri has been provided in a normalized form cmDocument = ContentModelManager.getInstance().createCMDocument(uri, null); if (uri.endsWith(".dtd")) { //$NON-NLS-1$ @@ -178,25 +178,28 @@ Document xmlDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); DOMContentBuilderImpl contentBuilder = new DOMContentBuilderImpl(xmlDocument); - - // this 'uglyTempHack' flag is required in order to supress the creation a default encoding - // we'll handle this later in the domWriter.print() method used below - // - contentBuilder.supressCreationOfDoctypeAndXMLDeclaration = true; + + // this 'uglyTempHack' flag is required in order to supress the + // creation a default encoding + // we'll handle this later in the domWriter.print() method used below + // + contentBuilder.supressCreationOfDoctypeAndXMLDeclaration = true; contentBuilder.setBuildPolicy(buildPolicy); contentBuilder.setExternalCMDocumentSupport(new MyExternalCMDocumentSupport(namespaceInfoList, xmlFileName)); contentBuilder.createDefaultRootContent(cmDocument, cmElementDeclaration, namespaceInfoList); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream, charset); - + DOMWriter domWriter = new DOMWriter(outputStreamWriter); - - // TODO... instead of relying on file extensions, we need to keep track of the grammar type - // better yet we should reate an SSE document so that we can format it nicely before saving - // then we won't need the DOMWriter at all - // - domWriter.print(xmlDocument, charset, cmDocument.getNodeName(), getNonWhitespaceString(getPublicId()), getNonWhitespaceString(getSystemId())); + + // TODO... instead of relying on file extensions, we need to keep + // track of the grammar type + // better yet we should reate an SSE document so that we can format it + // nicely before saving + // then we won't need the DOMWriter at all + // + domWriter.print(xmlDocument, charset, cmDocument.getNodeName(), getNonWhitespaceString(getPublicId()), getNonWhitespaceString(getSystemId())); outputStream.flush(); outputStream.close(); @@ -206,7 +209,7 @@ public void createNamespaceInfoList() { List result = new Vector(); - if (cmDocument != null) { + if (cmDocument != null) { result = (List) cmDocument.getProperty("http://org.eclipse.wst/cm/properties/namespaceInfo"); //$NON-NLS-1$ if (result != null) { int size = result.size(); @@ -258,7 +261,7 @@ public String[] getNamespaceInfoErrors() { String[] errorList = null; - if (namespaceInfoList != null && isMissingNamespaceLocation()) { + if ((namespaceInfoList != null) && isMissingNamespaceLocation()) { String title = XMLWizardsMessages._UI_LABEL_NO_LOCATION_HINT; String message = XMLWizardsMessages._UI_WARNING_MSG_NO_LOCATION_HINT_1 + " " + XMLWizardsMessages._UI_WARNING_MSG_NO_LOCATION_HINT_2 + "\n\n" + XMLWizardsMessages._UI_WARNING_MSG_NO_LOCATION_HINT_3; //$NON-NLS-1$ //$NON-NLS-2$ @@ -347,7 +350,7 @@ public CMDocument getCMDocument(Element element, String namespaceURI) { CMDocument result = null; - if (namespaceURI != null && namespaceURI.trim().length() > 0) { + if ((namespaceURI != null) && (namespaceURI.trim().length() > 0)) { String locationHint = null; for (Iterator i = namespaceInfoList1.iterator(); i.hasNext();) { NamespaceInfo info = (NamespaceInfo) i.next();
diff --git a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLTemplatesWizardPage.java b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLTemplatesWizardPage.java index b6cd467..0fa3940 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLTemplatesWizardPage.java +++ b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLTemplatesWizardPage.java
@@ -270,8 +270,9 @@ Template left = (Template) object1; Template right = (Template) object2; int result = left.getName().compareToIgnoreCase(right.getName()); - if (result != 0) + if (result != 0) { return result; + } return left.getDescription().compareToIgnoreCase(right.getDescription()); } return super.compare(viewer, object1, object2); @@ -361,10 +362,12 @@ if (!enabled) { // save last selected template Template template = getSelectedTemplate(); - if (template != null) + if (template != null) { fLastSelectedTemplateName = template.getName(); - else + } + else { fLastSelectedTemplateName = ""; //$NON-NLS-1$ + } fTableViewer.setSelection(null); } @@ -437,7 +440,7 @@ */ private void loadLastSavedPreferences() { String templateName = XMLUIPlugin.getDefault().getPreferenceStore().getString(XMLUIPreferenceNames.NEW_FILE_TEMPLATE_NAME); - if (templateName == null || templateName.length() == 0) { + if ((templateName == null) || (templateName.length() == 0)) { fLastSelectedTemplateName = ""; //$NON-NLS-1$ fUseTemplateButton.setSelection(false); } @@ -473,7 +476,7 @@ private void setSelectedTemplate(String templateName) { Object template = null; - if (templateName != null && templateName.length() > 0) { + if ((templateName != null) && (templateName.length() > 0)) { // pick the last used template template = fTemplateStore.findTemplate(templateName, TemplateContextTypeIdsXML.NEW); }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLWizard.java b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLWizard.java index 9b88c0f..94d9171 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLWizard.java +++ b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLWizard.java
@@ -108,7 +108,8 @@ public static void showDialog(Shell shell, IFile file, IStructuredSelection structuredSelection) { String[] errorInfo = new String[2]; - // (cs) the URI argument to createCMDocument needs to be a fully qualified URI + // (cs) the URI argument to createCMDocument needs to be a fully + // qualified URI // CMDocument cmDocument = NewXMLGenerator.createCMDocument(URIHelper.getPlatformURI(file), errorInfo); if (errorInfo[0] == null) { @@ -163,7 +164,7 @@ newFilePage.defaultName = (grammarURI != null) ? URIHelper.removeFileExtension(URIHelper.getLastSegment(grammarURI)) : "NewFile"; //$NON-NLS-1$ Preferences preference = XMLCorePlugin.getDefault().getPluginPreferences(); String ext = preference.getString(XMLCorePreferenceNames.DEFAULT_EXTENSION); - newFilePage.defaultFileExtension = "."+ext; //$NON-NLS-1$ + newFilePage.defaultFileExtension = "." + ext; //$NON-NLS-1$ newFilePage.filterExtensions = filePageFilterExtensions; addPage(newFilePage); @@ -247,7 +248,7 @@ IWizardPage currentPage = getContainer().getCurrentPage(); - if ((startPage != null && startPage.getSelectedRadioButtonIndex() == CREATE_FROM_SCRATCH && currentPage == fNewXMLTemplatesWizardPage) || (currentPage == selectRootElementPage)) { + if (((startPage != null) && (startPage.getSelectedRadioButtonIndex() == CREATE_FROM_SCRATCH) && (currentPage == fNewXMLTemplatesWizardPage)) || (currentPage == selectRootElementPage)) { result = currentPage.isPageComplete(); } return result; @@ -314,8 +315,9 @@ try { if (dw != null) { IWorkbenchPage page = dw.getActivePage(); - if (page != null) + if (page != null) { page.openEditor(new FileEditorInput(file), editorId, true); + } } } catch (PartInitException e) { @@ -358,7 +360,7 @@ } }; panel.setListener(listener); - Dialog.applyDialogFont(parent); + Dialog.applyDialogFont(parent); } public void setVisible(boolean visible) { @@ -393,7 +395,7 @@ } public boolean isPageComplete() { - return getURI() != null && getErrorMessage() == null; + return (getURI() != null) && (getErrorMessage() == null); } public String getXMLCatalogId() { @@ -557,7 +559,7 @@ cmDocumentErrorMessage = errorInfo[1]; } - if (generator.getCMDocument() != null && cmDocumentErrorMessage == null) { + if ((generator.getCMDocument() != null) && (cmDocumentErrorMessage == null)) { CMNamedNodeMap nameNodeMap = generator.getCMDocument().getElements(); Vector nameNodeVector = new Vector(); @@ -583,7 +585,7 @@ String elementName = (String) nameNodeArray[i]; combo.add(elementName); - if (defaultRootName != null && defaultRootName.equals(elementName)) { + if ((defaultRootName != null) && defaultRootName.equals(elementName)) { defaultRootIndex = i; } } @@ -604,7 +606,7 @@ // Provide default namespace prefix if none for (int i = 0; i < generator.namespaceInfoList.size(); i++) { NamespaceInfo nsinfo = (NamespaceInfo) generator.namespaceInfoList.get(i); - if ((nsinfo.prefix == null || nsinfo.prefix.trim().length() == 0) && (nsinfo.uri != null && nsinfo.uri.trim().length() != 0)) { + if (((nsinfo.prefix == null) || (nsinfo.prefix.trim().length() == 0)) && ((nsinfo.uri != null) && (nsinfo.uri.trim().length() != 0))) { nsinfo.prefix = getDefaultPrefix(generator.namespaceInfoList); } } @@ -631,14 +633,16 @@ private String getDefaultPrefix(List nsInfoList) { String defaultPrefix = "p"; //$NON-NLS-1$ - if (nsInfoList == null) + if (nsInfoList == null) { return defaultPrefix; + } Vector v = new Vector(); for (int i = 0; i < nsInfoList.size(); i++) { NamespaceInfo nsinfo = (NamespaceInfo) nsInfoList.get(i); - if (nsinfo.prefix != null) + if (nsinfo.prefix != null) { v.addElement(nsinfo.prefix); + } } if (v.contains(defaultPrefix)) { @@ -652,7 +656,7 @@ } public boolean isPageComplete() { - boolean complete = (generator.getRootElementName() != null && generator.getRootElementName().length() > 0) && getErrorMessage() == null; + boolean complete = ((generator.getRootElementName() != null) && (generator.getRootElementName().length() > 0)) && (getErrorMessage() == null); if (complete) { /* @@ -661,14 +665,18 @@ * DOMContentBuilder.BUILD_ALL_CONTENT; */ int buildPolicy = 0; - if (radioButton[0].getSelection()) + if (radioButton[0].getSelection()) { buildPolicy = buildPolicy | DOMContentBuilder.BUILD_OPTIONAL_ATTRIBUTES; - if (radioButton[1].getSelection()) + } + if (radioButton[1].getSelection()) { buildPolicy = buildPolicy | DOMContentBuilder.BUILD_OPTIONAL_ELEMENTS; - if (radioButton[2].getSelection()) + } + if (radioButton[2].getSelection()) { buildPolicy = buildPolicy | DOMContentBuilder.BUILD_FIRST_CHOICE | DOMContentBuilder.BUILD_FIRST_SUBSTITUTION; - if (radioButton[3].getSelection()) + } + if (radioButton[3].getSelection()) { buildPolicy = buildPolicy | DOMContentBuilder.BUILD_TEXT_NODES; + } generator.setBuildPolicy(buildPolicy); } @@ -682,7 +690,7 @@ if (cmDocumentErrorMessage != null) { errorMessage = cmDocumentErrorMessage; } - else if (generator.getRootElementName() == null || generator.getRootElementName().length() == 0) { + else if ((generator.getRootElementName() == null) || (generator.getRootElementName().length() == 0)) { errorMessage = XMLWizardsMessages._ERROR_ROOT_ELEMENT_MUST_BE_SPECIFIED; } @@ -737,7 +745,7 @@ Composite co = new Composite(this, SWT.NONE); co.setLayout(new GridLayout()); - if (newFilePage != null && newFilePage.getContainerFullPath() != null) { + if ((newFilePage != null) && (newFilePage.getContainerFullPath() != null)) { // todo... this is a nasty mess. I need to revist this code. // String resourceURI = "platform:/resource" + newFilePage.getContainerFullPath().toString() + "/dummy"; //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLImportActionDelegate.java b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLImportActionDelegate.java index 932dd24..1370c0e 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLImportActionDelegate.java +++ b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLImportActionDelegate.java
@@ -21,66 +21,58 @@ // TODO cs... rename this class NewXMLActionDelegate // we need to re-add pre-validation using the validation framework API's -// since we also need to add validation to the 'New XML' case, this prevalidation +// since we also need to add validation to the 'New XML' case, this +// prevalidation // function should really go into the NewWizard somewhere // -public class XMLImportActionDelegate implements IActionDelegate -{ - /** - * Checks the current selection and runs the separate browser - * to show the content of the Readme file. This code shows how - * to launch separate browsers that are not VA/Base desktop parts. - * - * @param action the action that was performed - */ - public void run(IAction action) - { - IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - ISelection selection = workbenchWindow.getSelectionService().getSelection(); - Object selectedObject = getSelection(selection); +public class XMLImportActionDelegate implements IActionDelegate { + /** + * Checks the current selection and runs the separate browser to show the + * content of the Readme file. This code shows how to launch separate + * browsers that are not VA/Base desktop parts. + * + * @param action + * the action that was performed + */ + public void run(IAction action) { + IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + ISelection selection = workbenchWindow.getSelectionService().getSelection(); + Object selectedObject = getSelection(selection); - if (selectedObject instanceof IFile && selection instanceof IStructuredSelection) - { - IFile file = (IFile)selectedObject; - IStructuredSelection structuredSelection = (IStructuredSelection)selection; - try - { - NewXMLWizard.showDialog(workbenchWindow.getShell(), file, structuredSelection); - } - catch (Exception e) - { - //XMLCorePlugin.getDefault().getLog().log(); - } - } - } + if ((selectedObject instanceof IFile) && (selection instanceof IStructuredSelection)) { + IFile file = (IFile) selectedObject; + IStructuredSelection structuredSelection = (IStructuredSelection) selection; + try { + NewXMLWizard.showDialog(workbenchWindow.getShell(), file, structuredSelection); + } + catch (Exception e) { + // XMLCorePlugin.getDefault().getLog().log(); + } + } + } - /** - * unused - */ - public void selectionChanged(IAction action, ISelection selection) - { - // unused - } + /** + * unused + */ + public void selectionChanged(IAction action, ISelection selection) { + // unused + } - // scammed from WindowUtility - // - public static Object getSelection(ISelection selection) - { - if (selection == null) - { - return null; - } // end of if () + // scammed from WindowUtility + // + public static Object getSelection(ISelection selection) { + if (selection == null) { + return null; + } // end of if () - Object result = null; - if (selection instanceof IStructuredSelection) - { - IStructuredSelection es= (IStructuredSelection)selection; - Iterator i= es.iterator(); - if (i.hasNext()) - { - result= i.next(); - } - } - return result; - } + Object result = null; + if (selection instanceof IStructuredSelection) { + IStructuredSelection es = (IStructuredSelection) selection; + Iterator i = es.iterator(); + if (i.hasNext()) { + result = i.next(); + } + } + return result; + } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLSchemaValidationChecker.java b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLSchemaValidationChecker.java index aec4a35..bf157c8 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLSchemaValidationChecker.java +++ b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLSchemaValidationChecker.java
@@ -21,25 +21,26 @@ String xsdFileName = ifile.getLocation().toString(); return isValid(xsdFileName); } + /** - * Should this be implemented as a Validator and simply called as such with - * a reporter that only checks the results for severity = error? Or should - * the Xerces requirement be broken using a plug-in extension? + * Should this be implemented as a Validator and simply called as such + * with a reporter that only checks the results for severity = error? Or + * should the Xerces requirement be broken using a plug-in extension? */ public boolean isValid(String xsdFileName) { -// DOMASBuilderImpl builder = new DOMASBuilderImpl(); -// DOMErrorHandler errorHandler = new DOMErrorHandler(); -// builder.setErrorHandler(errorHandler); + // DOMASBuilderImpl builder = new DOMASBuilderImpl(); + // DOMErrorHandler errorHandler = new DOMErrorHandler(); + // builder.setErrorHandler(errorHandler); try { - //String uri = - URIHelper.getURIForFilePath(xsdFileName); -// ASModel model = builder.parseASURI(uri); -// if (errorHandler.hasError()) -// return false; + // String uri = + URIHelper.getURIForFilePath(xsdFileName); + // ASModel model = builder.parseASURI(uri); + // if (errorHandler.hasError()) + // return false; } catch (Exception e) // invalid schema - { + { return false; } @@ -57,9 +58,11 @@ public void error(SAXParseException err) { hasError = true; } + public void fatalError(SAXParseException exception) throws SAXException { hasError = true; } + public void warning(SAXParseException exception) throws SAXException { // not an error }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLWizard.java b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLWizard.java index 10cafe6..a5900b1 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLWizard.java +++ b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLWizard.java
@@ -16,28 +16,25 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.jface.resource.ImageDescriptor; -public class XMLWizard -{ - protected static XMLWizard instance = new XMLWizard(); +public class XMLWizard { + protected static XMLWizard instance = new XMLWizard(); - public synchronized static XMLWizard getInstance() { - return instance; - } - - public XMLWizard() - { - instance = this; + public synchronized static XMLWizard getInstance() { + return instance; + } - } - - public ImageDescriptor getImageDescriptor(String name) - { - try { - URL url= new URL(Platform.getBundle("org.eclipse.wst.xml.ui").getEntry("/"), name); //$NON-NLS-1$ //$NON-NLS-2$ - return ImageDescriptor.createFromURL(url); - } - catch (MalformedURLException e) { - return ImageDescriptor.getMissingImageDescriptor(); - } - } + public XMLWizard() { + instance = this; + + } + + public ImageDescriptor getImageDescriptor(String name) { + try { + URL url = new URL(Platform.getBundle("org.eclipse.wst.xml.ui").getEntry("/"), name); //$NON-NLS-1$ //$NON-NLS-2$ + return ImageDescriptor.createFromURL(url); + } + catch (MalformedURLException e) { + return ImageDescriptor.getMissingImageDescriptor(); + } + } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLWizardsMessages.java b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLWizardsMessages.java index 97584f2..41e9648 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLWizardsMessages.java +++ b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLWizardsMessages.java
@@ -71,7 +71,7 @@ public static String ExampleProjectCreationWizard_overwritequery_title; public static String ExampleProjectCreationWizard_overwritequery_message; public static String ExampleProjectCreationWizardPage_error_alreadyexists; - + public static String NewXMLTemplatesWizardPage_0; public static String NewXMLTemplatesWizardPage_1; public static String NewXMLTemplatesWizardPage_2;
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/StructuredTextViewerConfigurationXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/StructuredTextViewerConfigurationXML.java index 8bf1f56..70b63dd 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/StructuredTextViewerConfigurationXML.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/StructuredTextViewerConfigurationXML.java
@@ -135,16 +135,19 @@ public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) { ITextDoubleClickStrategy doubleClickStrategy = null; - if (contentType.compareTo(IXMLPartitions.XML_DEFAULT) == 0) + if (contentType.compareTo(IXMLPartitions.XML_DEFAULT) == 0) { doubleClickStrategy = new XMLDoubleClickStrategy(); - else + } + else { doubleClickStrategy = super.getDoubleClickStrategy(sourceViewer, contentType); + } return doubleClickStrategy; } public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) { - if (sourceViewer == null || !fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED)) + if ((sourceViewer == null) || !fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED)) { return null; + } List allDetectors = new ArrayList(0); allDetectors.add(new XMLHyperlinkDetector()); @@ -173,18 +176,22 @@ boolean appendTab = false; if (useSpaces) { - for (int j = 0; j + i < indentationWidth; j++) + for (int j = 0; j + i < indentationWidth; j++) { prefix.append(' '); + } - if (i != 0) + if (i != 0) { appendTab = true; + } } else { - for (int j = 0; j < i; j++) + for (int j = 0; j < i; j++) { prefix.append(' '); + } - if (i != indentationWidth) + if (i != indentationWidth) { appendTab = true; + } } if (appendTab) { @@ -213,7 +220,7 @@ public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) { LineStyleProvider[] providers = null; - if (partitionType == IXMLPartitions.XML_DEFAULT || partitionType == IXMLPartitions.XML_CDATA || partitionType == IXMLPartitions.XML_COMMENT || partitionType == IXMLPartitions.XML_DECLARATION || partitionType == IXMLPartitions.XML_PI) { + if ((partitionType == IXMLPartitions.XML_DEFAULT) || (partitionType == IXMLPartitions.XML_CDATA) || (partitionType == IXMLPartitions.XML_COMMENT) || (partitionType == IXMLPartitions.XML_DECLARATION) || (partitionType == IXMLPartitions.XML_PI)) { providers = new LineStyleProvider[]{getLineStyleProviderForXML()}; } @@ -221,8 +228,9 @@ } private LineStyleProvider getLineStyleProviderForXML() { - if (fLineStyleProviderForXML == null) + if (fLineStyleProviderForXML == null) { fLineStyleProviderForXML = new LineStyleProviderForXML(); + } return fLineStyleProviderForXML; } @@ -236,21 +244,24 @@ TextHoverManager manager = SSEUIPlugin.getDefault().getTextHoverManager(); TextHoverManager.TextHoverDescriptor[] hoverDescs = manager.getTextHovers(); int i = 0; - while (i < hoverDescs.length && textHover == null) { - if (hoverDescs[i].isEnabled() && EditorUtility.computeStateMask(hoverDescs[i].getModifierString()) == stateMask) { + while ((i < hoverDescs.length) && (textHover == null)) { + if (hoverDescs[i].isEnabled() && (EditorUtility.computeStateMask(hoverDescs[i].getModifierString()) == stateMask)) { String hoverType = hoverDescs[i].getId(); - if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType)) + if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType)) { textHover = manager.createBestMatchHover(new XMLTagInfoHoverProcessor()); - else if (TextHoverManager.DOCUMENTATION_HOVER.equalsIgnoreCase(hoverType)) + } + else if (TextHoverManager.DOCUMENTATION_HOVER.equalsIgnoreCase(hoverType)) { textHover = new XMLTagInfoHoverProcessor(); + } } i++; } } // no appropriate text hovers found, try super - if (textHover == null) + if (textHover == null) { textHover = super.getTextHover(sourceViewer, contentType, stateMask); + } return textHover; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java index 6f65976..7418d2d 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java
@@ -159,7 +159,7 @@ adapter.connect(fDocument); ModelQuery modelQuery = ModelQueryUtil.getModelQuery(fDocument); - if (modelQuery != null && modelQuery.getCMDocumentManager() != null) { + if ((modelQuery != null) && (modelQuery.getCMDocumentManager() != null)) { CMDocumentManager cmDocumentManager = modelQuery.getCMDocumentManager(); cmDocumentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD, false); } @@ -177,7 +177,7 @@ public void invokeCMDocumentLoad() { ModelQuery modelQuery = ModelQueryUtil.getModelQuery(fDocument); - if (modelQuery != null && modelQuery.getCMDocumentManager() != null) { + if ((modelQuery != null) && (modelQuery.getCMDocumentManager() != null)) { CMDocumentLoader loader = isGrammarInferenceEnabled ? new InferredGrammarBuildingCMDocumentLoader(fDocument, modelQuery) : new CMDocumentLoader(fDocument, modelQuery); loader.loadCMDocuments(); }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/Logger.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/Logger.java index eaa667f..81062f9 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/Logger.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/Logger.java
@@ -28,7 +28,7 @@ */ public class Logger { private static final String PLUGIN_ID = "org.eclipse.wst.xml.ui"; //$NON-NLS-1$ - + public static final int ERROR = IStatus.ERROR; // 4 public static final int ERROR_DEBUG = 200 + ERROR; public static final int INFO = IStatus.INFO; // 1 @@ -54,9 +54,10 @@ * exception thrown */ protected static void _log(int level, String message, Throwable exception) { - if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) { - if (!isDebugging()) + if ((level == OK_DEBUG) || (level == INFO_DEBUG) || (level == WARNING_DEBUG) || (level == ERROR_DEBUG)) { + if (!isDebugging()) { return; + } } int severity = IStatus.OK; @@ -76,8 +77,9 @@ message = (message != null) ? message : "null"; //$NON-NLS-1$ Status statusObj = new Status(severity, PLUGIN_ID, severity, message, exception); Bundle bundle = Platform.getBundle(PLUGIN_ID); - if (bundle != null) + if (bundle != null) { Platform.getLog(bundle).log(statusObj); + } } /** @@ -94,8 +96,9 @@ message = (message != null) ? message : "null"; //$NON-NLS-1$ Status statusObj = new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, exception); Bundle bundle = Platform.getBundle(PLUGIN_ID); - if (bundle != null) + if (bundle != null) { Platform.getLog(bundle).log(statusObj); + } } } @@ -113,8 +116,9 @@ * @return true if tracing category, false otherwise */ public static boolean isTracing(String category) { - if (!isDebugging()) + if (!isDebugging()) { return false; + } String traceFilter = Platform.getDebugOption(PLUGIN_ID + TRACEFILTER_LOCATION); if (traceFilter != null) {
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java index 7026279..07a68e2 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java
@@ -301,8 +301,9 @@ public static ResourceBundle getResourceBundle() { try { - if (fResourceBundle == null) + if (fResourceBundle == null) { fResourceBundle = ResourceBundle.getBundle(BUNDLE_NAME); + } } catch (MissingResourceException x) { fResourceBundle = null;
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPlugin.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPlugin.java index 491d881..18af2f7 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPlugin.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPlugin.java
@@ -69,13 +69,12 @@ */ public TemplateStore getTemplateStore() { if (fTemplateStore == null) { - fTemplateStore = new ContributionTemplateStore( - getTemplateContextRegistry(), getPreferenceStore(), - XMLUIPreferenceNames.TEMPLATES_KEY); + fTemplateStore = new ContributionTemplateStore(getTemplateContextRegistry(), getPreferenceStore(), XMLUIPreferenceNames.TEMPLATES_KEY); try { fTemplateStore.load(); - } catch (IOException e) { + } + catch (IOException e) { Logger.logException(e); } } @@ -101,16 +100,18 @@ return fContextTypeRegistry; } + /** - * Get an image from the registry. - * - * *This method is used by the referencingfile dialog and should be - * removed when the dialog is moved to anothercomponent. - * - * @param imageName The name of the image. - * @return The image registered for the given name. - */ - public Image getImage(String imageName){ - return getWorkbench().getSharedImages().getImage(imageName); + * Get an image from the registry. + * + * *This method is used by the referencingfile dialog and should be + * removed when the dialog is moved to anothercomponent. + * + * @param imageName + * The name of the image. + * @return The image registered for the given name. + */ + public Image getImage(String imageName) { + return getWorkbench().getSharedImages().getImage(imageName); } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractCommentActionXMLDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractCommentActionXMLDelegate.java index 13eee15..c583842 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractCommentActionXMLDelegate.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractCommentActionXMLDelegate.java
@@ -57,8 +57,9 @@ if (document != null) { // get current text selection ITextSelection textSelection = getCurrentSelection(); - if (textSelection.isEmpty()) + if (textSelection.isEmpty()) { return; + } processAction(document, textSelection); } @@ -78,8 +79,9 @@ ISelectionProvider provider = ((ITextEditor) fEditor).getSelectionProvider(); if (provider != null) { ISelection selection = provider.getSelection(); - if (selection instanceof ITextSelection) + if (selection instanceof ITextSelection) { return (ITextSelection) selection; + } } } return TextSelection.emptySelection();
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractNodeActionManager.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractNodeActionManager.java index 10bb371..2dab601 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractNodeActionManager.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractNodeActionManager.java
@@ -71,7 +71,7 @@ String text = getLabel(parent, cmnode); setText(text); description = text; - undoDescription = XMLUIMessages._UI_MENU_ADD + " " + text; //$NON-NLS-1$ //$NON-NLS-2$ + undoDescription = XMLUIMessages._UI_MENU_ADD + " " + text; //$NON-NLS-1$ ImageDescriptor descriptor = CMImageUtil.getImageDescriptor(cmnode); if (descriptor == null) { descriptor = imageDescriptorCache.getImageDescriptor(cmnode); @@ -87,23 +87,23 @@ switch (nodeType) { case Node.COMMENT_NODE : { - description = XMLUIMessages._UI_MENU_COMMENT; //$NON-NLS-1$ - undoDescription = XMLUIMessages._UI_MENU_ADD_COMMENT; //$NON-NLS-1$ + description = XMLUIMessages._UI_MENU_COMMENT; + undoDescription = XMLUIMessages._UI_MENU_ADD_COMMENT; break; } case Node.PROCESSING_INSTRUCTION_NODE : { - description = XMLUIMessages._UI_MENU_PROCESSING_INSTRUCTION; //$NON-NLS-1$ - undoDescription = XMLUIMessages._UI_MENU_ADD_PROCESSING_INSTRUCTION; //$NON-NLS-1$ + description = XMLUIMessages._UI_MENU_PROCESSING_INSTRUCTION; + undoDescription = XMLUIMessages._UI_MENU_ADD_PROCESSING_INSTRUCTION; break; } case Node.CDATA_SECTION_NODE : { - description = XMLUIMessages._UI_MENU_CDATA_SECTION; //$NON-NLS-1$ - undoDescription = XMLUIMessages._UI_MENU_ADD_CDATA_SECTION; //$NON-NLS-1$ + description = XMLUIMessages._UI_MENU_CDATA_SECTION; + undoDescription = XMLUIMessages._UI_MENU_ADD_CDATA_SECTION; break; } case Node.TEXT_NODE : { - description = XMLUIMessages._UI_MENU_PCDATA; //$NON-NLS-1$ - undoDescription = XMLUIMessages._UI_MENU_ADD_PCDATA; //$NON-NLS-1$ + description = XMLUIMessages._UI_MENU_PCDATA; + undoDescription = XMLUIMessages._UI_MENU_ADD_PCDATA; break; } } @@ -125,11 +125,11 @@ boolean format = true; switch (nodeType) { case Node.COMMENT_NODE : { - newChildNode = document.createComment(XMLUIMessages._UI_COMMENT_VALUE); //$NON-NLS-1$ + newChildNode = document.createComment(XMLUIMessages._UI_COMMENT_VALUE); break; } case Node.PROCESSING_INSTRUCTION_NODE : { - newChildNode = document.createProcessingInstruction(XMLUIMessages._UI_PI_TARGET_VALUE, XMLUIMessages._UI_PI_DATA_VALUE); //$NON-NLS-1$ //$NON-NLS-2$ + newChildNode = document.createProcessingInstruction(XMLUIMessages._UI_PI_TARGET_VALUE, XMLUIMessages._UI_PI_DATA_VALUE); break; } case Node.CDATA_SECTION_NODE : { @@ -160,7 +160,8 @@ beginNodeAction(this); if (cmnode != null) { addNodeForCMNode(); - } else { + } + else { addNodeForNodeType(); } endNodeAction(this); @@ -175,18 +176,18 @@ protected List list; public DeleteAction(List list) { - setText(XMLUIMessages._UI_MENU_REMOVE); //$NON-NLS-1$ + setText(XMLUIMessages._UI_MENU_REMOVE); this.list = list; } public DeleteAction(Node node) { - setText(XMLUIMessages._UI_MENU_REMOVE); //$NON-NLS-1$ + setText(XMLUIMessages._UI_MENU_REMOVE); list = new Vector(); list.add(node); } public String getUndoDescription() { - return XMLUIMessages.DELETE; //$NON-NLS-1$ + return XMLUIMessages.DELETE; } public void run() { @@ -197,11 +198,12 @@ if (node.getNodeType() == Node.ATTRIBUTE_NODE) { Attr attr = (Attr) node; attr.getOwnerElement().removeAttributeNode(attr); - } else { + } + else { Node parent = node.getParentNode(); if (parent != null) { Node previousSibling = node.getPreviousSibling(); - if (previousSibling != null && isWhitespaceTextNode(previousSibling)) { + if ((previousSibling != null) && isWhitespaceTextNode(previousSibling)) { parent.removeChild(previousSibling); } parent.removeChild(node); @@ -230,11 +232,14 @@ switch (cmnode.getNodeType()) { case CMNode.ATTRIBUTE_DECLARATION : { result = CMImageUtil.getImageDescriptor(cmnode); - if (result == null) - if (((CMAttributeDeclaration) cmnode).getUsage() == CMAttributeDeclaration.REQUIRED) + if (result == null) { + if (((CMAttributeDeclaration) cmnode).getUsage() == CMAttributeDeclaration.REQUIRED) { result = attributeReqImage; - else + } + else { result = attributeImage; + } + } break; } case CMNode.DATA_TYPE : { @@ -243,8 +248,9 @@ } case CMNode.ELEMENT_DECLARATION : { result = CMImageUtil.getImageDescriptor(cmnode); - if (result == null) + if (result == null) { result = elementImage; + } break; } case CMNode.GROUP : { @@ -252,7 +258,8 @@ break; } } - } else if (object instanceof Integer) { + } + else if (object instanceof Integer) { Integer integer = (Integer) object; switch (integer.intValue()) { case Node.COMMENT_NODE : { @@ -294,19 +301,19 @@ this.parent = parent; switch (nodeType) { case Node.COMMENT_NODE : { - description = XMLUIMessages._UI_MENU_COMMENT; //$NON-NLS-1$ + description = XMLUIMessages._UI_MENU_COMMENT; break; } case Node.PROCESSING_INSTRUCTION_NODE : { - description = XMLUIMessages._UI_MENU_PROCESSING_INSTRUCTION; //$NON-NLS-1$ + description = XMLUIMessages._UI_MENU_PROCESSING_INSTRUCTION; break; } case Node.CDATA_SECTION_NODE : { - description = XMLUIMessages._UI_MENU_CDATA_SECTION; //$NON-NLS-1$ + description = XMLUIMessages._UI_MENU_CDATA_SECTION; break; } case Node.TEXT_NODE : { - description = XMLUIMessages._UI_MENU_PCDATA; //$NON-NLS-1$ + description = XMLUIMessages._UI_MENU_PCDATA; break; } } @@ -324,7 +331,7 @@ } public String getUndoDescription() { - return XMLUIMessages._UI_MENU_ADD + " " + description; //$NON-NLS-1$ //$NON-NLS-2$ + return XMLUIMessages._UI_MENU_ADD + " " + description; //$NON-NLS-1$ } public void run() { @@ -335,11 +342,11 @@ boolean format = true; switch (nodeType) { case Node.COMMENT_NODE : { - newChildNode = document.createComment(XMLUIMessages._UI_COMMENT_VALUE); //$NON-NLS-1$ + newChildNode = document.createComment(XMLUIMessages._UI_COMMENT_VALUE); break; } case Node.PROCESSING_INSTRUCTION_NODE : { - newChildNode = document.createProcessingInstruction(XMLUIMessages._UI_PI_TARGET_VALUE, XMLUIMessages._UI_PI_DATA_VALUE); //$NON-NLS-1$ //$NON-NLS-2$ + newChildNode = document.createProcessingInstruction(XMLUIMessages._UI_PI_TARGET_VALUE, XMLUIMessages._UI_PI_DATA_VALUE); break; } case Node.CDATA_SECTION_NODE : { @@ -386,7 +393,7 @@ } public String getUndoDescription() { - String result = XMLUIMessages._UI_LABEL_UNDO_REPLACE_DESCRIPTION; //$NON-NLS-1$ + String result = XMLUIMessages._UI_LABEL_UNDO_REPLACE_DESCRIPTION; result += " " + getLabel(parent, cmnode); //$NON-NLS-1$ return result; } @@ -394,7 +401,7 @@ public void run() { beginNodeAction(this); - if (parent != null && cmnode != null) { + if ((parent != null) && (cmnode != null)) { remove(parent, startIndex, endIndex); insert(parent, cmnode, startIndex); } @@ -419,8 +426,9 @@ protected Action createAddAttributeAction(Element parent, CMAttributeDeclaration ad) { Action action = null; if (ad == null) { - action = new EditAttributeAction(this, parent, null, XMLUIMessages._UI_MENU_NEW_ATTRIBUTE, XMLUIMessages._UI_MENU_NEW_ATTRIBUTE_TITLE); //$NON-NLS-1$ //$NON-NLS-2$ - } else { + action = new EditAttributeAction(this, parent, null, XMLUIMessages._UI_MENU_NEW_ATTRIBUTE, XMLUIMessages._UI_MENU_NEW_ATTRIBUTE_TITLE); + } + else { action = new AddNodeAction(ad, parent, -1); } return action; @@ -438,15 +446,16 @@ protected Action createAddDoctypeAction(Document document, int index) { - return new EditDoctypeAction(fModel, document, fModel.getBaseLocation(), XMLUIMessages._UI_MENU_ADD_DTD_INFORMATION); //$NON-NLS-1$ + return new EditDoctypeAction(fModel, document, fModel.getBaseLocation(), XMLUIMessages._UI_MENU_ADD_DTD_INFORMATION); } protected Action createAddElementAction(Node parent, CMElementDeclaration ed, int index) { Action action = null; if (ed == null) { - action = new EditElementAction(this, parent, index, XMLUIMessages._UI_MENU_NEW_ELEMENT, XMLUIMessages._UI_MENU_NEW_ELEMENT_TITLE); //$NON-NLS-1$ //$NON-NLS-2$ - } else { + action = new EditElementAction(this, parent, index, XMLUIMessages._UI_MENU_NEW_ELEMENT, XMLUIMessages._UI_MENU_NEW_ELEMENT_TITLE); + } + else { action = new AddNodeAction(ed, parent, index); } return action; @@ -457,7 +466,8 @@ Action action = null; if (dataType == null) { action = new AddNodeAction(Node.TEXT_NODE, parent, index); - } else { + } + else { action = new AddNodeAction(dataType, parent, index); } return action; @@ -466,14 +476,14 @@ protected Action createAddProcessingInstructionAction(Node parent, int index) { Node refChild = getRefChildNodeAtIndex(parent, index); - Action action = new EditProcessingInstructionAction(this, parent, refChild, XMLUIMessages._UI_MENU_ADD_PROCESSING_INSTRUCTION, XMLUIMessages.ADD_PROCESSING_INSTRUCTION); //$NON-NLS-1$ //$NON-NLS-2$ + Action action = new EditProcessingInstructionAction(this, parent, refChild, XMLUIMessages._UI_MENU_ADD_PROCESSING_INSTRUCTION, XMLUIMessages.ADD_PROCESSING_INSTRUCTION); action.setImageDescriptor(imageDescriptorCache.getImageDescriptor(new Integer(Node.PROCESSING_INSTRUCTION_NODE))); return action; } protected Action createAddSchemaInfoAction(Element element) { - return new EditSchemaInfoAction(this, element.getOwnerDocument(), fModel.getBaseLocation(), XMLUIMessages._UI_MENU_ADD_SCHEMA_INFORMATION); //$NON-NLS-1$ + return new EditSchemaInfoAction(this, element.getOwnerDocument(), fModel.getBaseLocation(), XMLUIMessages._UI_MENU_ADD_SCHEMA_INFORMATION); } @@ -491,29 +501,29 @@ protected Action createEditAttributeAction(Attr attr, CMAttributeDeclaration ad) { - return new EditAttributeAction(this, attr.getOwnerElement(), attr, XMLUIMessages._UI_MENU_EDIT_ATTRIBUTE, XMLUIMessages._UI_MENU_EDIT_ATTRIBUTE_TITLE); //$NON-NLS-1$ //$NON-NLS-2$ + return new EditAttributeAction(this, attr.getOwnerElement(), attr, XMLUIMessages._UI_MENU_EDIT_ATTRIBUTE, XMLUIMessages._UI_MENU_EDIT_ATTRIBUTE_TITLE); } protected Action createEditDoctypeAction(DocumentType doctype) { - return new EditDoctypeAction(fModel, doctype, fModel.getBaseLocation(), XMLUIMessages._UI_MENU_EDIT_DOCTYPE); //$NON-NLS-1$ + return new EditDoctypeAction(fModel, doctype, fModel.getBaseLocation(), XMLUIMessages._UI_MENU_EDIT_DOCTYPE); } protected Action createEditProcessingInstructionAction(ProcessingInstruction pi) { - return new EditProcessingInstructionAction(this, pi, XMLUIMessages._UI_MENU_EDIT_PROCESSING_INSTRUCTION, XMLUIMessages._UI_MENU_EDIT_PROCESSING_INSTRUCTION_TITLE); //$NON-NLS-1$ //$NON-NLS-2$ + return new EditProcessingInstructionAction(this, pi, XMLUIMessages._UI_MENU_EDIT_PROCESSING_INSTRUCTION, XMLUIMessages._UI_MENU_EDIT_PROCESSING_INSTRUCTION_TITLE); } protected Action createEditSchemaInfoAction(Element element) { - return new EditSchemaInfoAction(this, element.getOwnerDocument(), fModel.getBaseLocation(), XMLUIMessages._UI_MENU_EDIT_NAMESPACES); //$NON-NLS-1$ + return new EditSchemaInfoAction(this, element.getOwnerDocument(), fModel.getBaseLocation(), XMLUIMessages._UI_MENU_EDIT_NAMESPACES); } protected Action createRenameAction(Node node) { Action result = null; if (node instanceof Element) { - result = new EditElementAction(this, (Element) node, XMLUIMessages._UI_MENU_RENAME, XMLUIMessages._UI_MENU_RENAME_TITLE); //$NON-NLS-1$ //$NON-NLS-2$ + result = new EditElementAction(this, (Element) node, XMLUIMessages._UI_MENU_RENAME, XMLUIMessages._UI_MENU_RENAME_TITLE); } return result; } @@ -540,13 +550,14 @@ } contributeActions(menuManager, selectionList); - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); } } /** - * + * */ public String getLabel(Node parent, CMNode cmnode) { String result = "?" + cmnode + "?"; //$NON-NLS-1$ //$NON-NLS-2$ @@ -556,7 +567,8 @@ if (cmnode.getNodeType() == CMNode.GROUP) { CMDescriptionBuilder descriptionBuilder = new CMDescriptionBuilder(); result = descriptionBuilder.buildDescription(cmnode); - } else { + } + else { result = DOMNamespaceHelper.computeName(cmnode, parent, null); } } @@ -612,7 +624,8 @@ if (newNode.getNodeType() == Node.ATTRIBUTE_NODE) { Element parentElement = (Element) parent; parentElement.setAttributeNode((Attr) newNode); - } else { + } + else { parent.insertBefore(newNode, refChild); } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ActionContributorXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ActionContributorXML.java index 6aaa8b1..6590c05 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ActionContributorXML.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ActionContributorXML.java
@@ -65,23 +65,23 @@ ResourceBundle resourceBundle = XMLUIMessages.getResourceBundle(); // edit commands - fShowTooltipAction = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ + fShowTooltipAction = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ fShowTooltipAction.setActionDefinitionId(ActionDefinitionIds.INFORMATION); - fContentAssist = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ + fContentAssist = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ fContentAssist.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); - fQuickFix = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ + fQuickFix = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ fQuickFix.setActionDefinitionId(ActionDefinitionIds.QUICK_FIX); // source commands - fCleanupDocument = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ + fCleanupDocument = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ fCleanupDocument.setActionDefinitionId(ActionDefinitionIds.CLEANUP_DOCUMENT); - fFormatDocument = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ + fFormatDocument = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ fFormatDocument.setActionDefinitionId(ActionDefinitionIds.FORMAT_DOCUMENT); - fFormatActiveElements = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ + fFormatActiveElements = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ fFormatActiveElements.setActionDefinitionId(ActionDefinitionIds.FORMAT_ACTIVE_ELEMENTS); fFormatMenu = new MenuManager(XMLUIMessages.FormatMenu_label); @@ -89,10 +89,10 @@ fFormatMenu.add(fFormatActiveElements); // navigate commands - fOpenFileAction = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ + fOpenFileAction = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ fOpenFileAction.setActionDefinitionId(ActionDefinitionIds.OPEN_FILE); - fFindOccurrences = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ + fFindOccurrences = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$ fFindOccurrences.setActionDefinitionId(ActionDefinitionIds.FIND_OCCURRENCES); } @@ -150,8 +150,9 @@ * @see org.eclipse.ui.IEditorActionBarContributor#setActiveEditor(IEditorPart) */ public void setActiveEditor(IEditorPart activeEditor) { - if (getActiveEditorPart() == activeEditor) + if (getActiveEditorPart() == activeEditor) { return; + } super.setActiveEditor(activeEditor); IActionBars actionBars = getActionBars(); @@ -172,9 +173,9 @@ fCleanupDocument.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_CLEANUP_DOCUMENT)); fFormatDocument.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT)); fFormatActiveElements.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS)); - fCleanupDocument.setEnabled(textEditor != null && textEditor.isEditable()); - fFormatDocument.setEnabled(textEditor != null && textEditor.isEditable()); - fFormatActiveElements.setEnabled(textEditor != null && textEditor.isEditable()); + fCleanupDocument.setEnabled((textEditor != null) && textEditor.isEditable()); + fFormatDocument.setEnabled((textEditor != null) && textEditor.isEditable()); + fFormatActiveElements.setEnabled((textEditor != null) && textEditor.isEditable()); fOpenFileAction.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_OPEN_FILE)); @@ -194,8 +195,8 @@ fQuickFix.setEnabled(enabled); // cleanup and format document actions do not rely on source viewer // being enabled - // fCleanupDocument.setEnabled(enabled); - // fFormatDocument.setEnabled(enabled); + // fCleanupDocument.setEnabled(enabled); + // fFormatDocument.setEnabled(enabled); fFormatActiveElements.setEnabled(enabled); fOpenFileAction.setEnabled(enabled);
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXMLDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXMLDelegate.java index 5521493..a6d28b8 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXMLDelegate.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXMLDelegate.java
@@ -43,20 +43,23 @@ IndexedRegion selectionStartIndexedRegion = model.getIndexedRegion(textSelection.getOffset()); IndexedRegion selectionEndIndexedRegion = model.getIndexedRegion(textSelection.getOffset() + textSelection.getLength()); - if (selectionStartIndexedRegion == null) + if (selectionStartIndexedRegion == null) { return; - if (selectionEndIndexedRegion == null && textSelection.getLength() > 0) { + } + if ((selectionEndIndexedRegion == null) && (textSelection.getLength() > 0)) { selectionEndIndexedRegion = model.getIndexedRegion(textSelection.getOffset() + textSelection.getLength() - 1); } - if (selectionEndIndexedRegion == null) + if (selectionEndIndexedRegion == null) { return; + } int openCommentOffset = selectionStartIndexedRegion.getStartOffset(); int closeCommentOffset = selectionEndIndexedRegion.getEndOffset() + OPEN_COMMENT.length(); - if (textSelection.getLength() == 0 && selectionStartIndexedRegion instanceof CommentImpl) + if ((textSelection.getLength() == 0) && (selectionStartIndexedRegion instanceof CommentImpl)) { return; + } model.beginRecording(this, XMLUIMessages.AddBlockComment_tooltip); model.aboutToChangeModel();
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/BaseNodeActionManager.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/BaseNodeActionManager.java index 9eef9a0..e7ba5eb 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/BaseNodeActionManager.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/BaseNodeActionManager.java
@@ -94,8 +94,9 @@ break; } } - } else if (action.getKind() == ModelQueryAction.REPLACE) { - if (action.getParent() != null && action.getCMNode() != null) { + } + else if (action.getKind() == ModelQueryAction.REPLACE) { + if ((action.getParent() != null) && (action.getCMNode() != null)) { actionList.add(createReplaceAction(action.getParent(), action.getCMNode(), action.getStartIndex(), action.getEndIndex())); } } @@ -159,8 +160,8 @@ // Element element = (Element) node; - IMenuManager addAttributeMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_ATTRIBUTE); //$NON-NLS-1$ - IMenuManager addChildMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_CHILD); //$NON-NLS-1$ + IMenuManager addAttributeMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_ATTRIBUTE); + IMenuManager addChildMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_CHILD); menu.add(addAttributeMenu); menu.add(addChildMenu); @@ -195,7 +196,7 @@ protected void contributeAddDocumentChildActions(IMenuManager menu, Document document, int ic, int vc) { - IMenuManager addChildMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_CHILD); //$NON-NLS-1$ + IMenuManager addChildMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_CHILD); menu.add(addChildMenu); // add PI and COMMENT @@ -207,8 +208,8 @@ protected void contributeAddSiblingActions(IMenuManager menu, Node node, int ic, int vc) { - IMenuManager addBeforeMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_BEFORE); //$NON-NLS-1$ - IMenuManager addAfterMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_AFTER); //$NON-NLS-1$ + IMenuManager addBeforeMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_BEFORE); + IMenuManager addAfterMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_AFTER); menu.add(addBeforeMenu); menu.add(addAfterMenu); @@ -241,7 +242,8 @@ // add NEW ELEMENT before and after contributeUnconstrainedAddElementAction(addBeforeMenu, parentElement, parentED, index); contributeUnconstrainedAddElementAction(addAfterMenu, parentElement, parentED, index + 1); - } else if (parentNode.getNodeType() == Node.DOCUMENT_NODE) { + } + else if (parentNode.getNodeType() == Node.DOCUMENT_NODE) { Document document = (Document) parentNode; CMDocument cmDocument = modelQuery.getCorrespondingCMDocument(parentNode); if (cmDocument != null) { @@ -284,7 +286,8 @@ if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) { contributeAction(menu, createEditProcessingInstructionAction((ProcessingInstruction) node)); - } else if (node.getNodeType() == Node.ATTRIBUTE_NODE) { + } + else if (node.getNodeType() == Node.ATTRIBUTE_NODE) { contributeAction(menu, createEditAttributeAction((Attr) node, null)); } } @@ -302,7 +305,7 @@ contributeAction(menu, createEditDoctypeAction((DocumentType) node)); } - if (doctype == null && getRootElement(document) != null) { + if ((doctype == null) && (getRootElement(document) != null)) { contributeAction(menu, createEditSchemaInfoAction(getRootElement(document))); } } @@ -316,7 +319,7 @@ protected void contributePIAndCommentActions(IMenuManager menu, Element parentElement, CMElementDeclaration parentEd, int index) { - if (parentEd == null || isCommentAllowed(parentEd)) { + if ((parentEd == null) || isCommentAllowed(parentEd)) { contributeAction(menu, createAddCommentAction(parentElement, index)); contributeAction(menu, createAddProcessingInstructionAction(parentElement, index)); } @@ -326,13 +329,13 @@ protected void contributeReplaceActions(IMenuManager menu, List selectedNodeList, int ic, int vc) { // 'Replace With...' actions // - IMenuManager replaceWithMenu = new MyMenuManager(XMLUIMessages._UI_MENU_REPLACE_WITH); //$NON-NLS-1$ + IMenuManager replaceWithMenu = new MyMenuManager(XMLUIMessages._UI_MENU_REPLACE_WITH); menu.add(replaceWithMenu); - if (modelQuery.getEditMode() == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT && selectedNodeList.size() > 0) { + if ((modelQuery.getEditMode() == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) && (selectedNodeList.size() > 0)) { Node node = (Node) selectedNodeList.get(0); Node parentNode = node.getParentNode(); - if (parentNode != null && parentNode.getNodeType() == Node.ELEMENT_NODE) { + if ((parentNode != null) && (parentNode.getNodeType() == Node.ELEMENT_NODE)) { Element parentElement = (Element) parentNode; CMElementDeclaration parentED = modelQuery.getCMElementDeclaration(parentElement); if (parentED != null) { @@ -345,7 +348,7 @@ } protected void contributeTextNodeActions(IMenuManager menu, Element parentElement, CMElementDeclaration parentEd, int index) { - if (parentEd == null || isTextAllowed(parentEd)) { + if ((parentEd == null) || isTextAllowed(parentEd)) { CMDataType dataType = parentEd != null ? parentEd.getDataType() : null; contributeAction(menu, createAddPCDataAction(parentElement, dataType, index)); contributeAction(menu, createAddCDataSectionAction(parentElement, index)); @@ -366,15 +369,16 @@ if (nodeType == Node.DOCUMENT_TYPE_NODE) { doctypeIndex = i; break; - } else if (nodeType == Node.PROCESSING_INSTRUCTION_NODE) { + } + else if (nodeType == Node.PROCESSING_INSTRUCTION_NODE) { ProcessingInstruction pi = (ProcessingInstruction) node; - if (pi.getTarget().equalsIgnoreCase("xml") && xmlDeclarationIndex == -1) { //$NON-NLS-1$ + if (pi.getTarget().equalsIgnoreCase("xml") && (xmlDeclarationIndex == -1)) { //$NON-NLS-1$ xmlDeclarationIndex = i; } } } - if ((xmlDeclarationIndex == -1 || index > xmlDeclarationIndex) && (doctypeIndex == -1 || index > doctypeIndex)) { + if (((xmlDeclarationIndex == -1) || (index > xmlDeclarationIndex)) && ((doctypeIndex == -1) || (index > doctypeIndex))) { contributeAction(menu, createAddElementAction(document, null, index)); } } @@ -384,7 +388,7 @@ protected void contributeUnconstrainedAddElementAction(IMenuManager menu, Element parentElement, CMElementDeclaration parentEd, int index) { if (isUnconstrainedActionAllowed()) { - if (parentEd == null || parentEd.getProperty("isInferred") == Boolean.TRUE || (modelQuery.getEditMode() != ModelQuery.EDIT_MODE_CONSTRAINED_STRICT && isElementAllowed(parentEd))) { //$NON-NLS-1$ + if ((parentEd == null) || (parentEd.getProperty("isInferred") == Boolean.TRUE) || ((modelQuery.getEditMode() != ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) && isElementAllowed(parentEd))) { //$NON-NLS-1$ contributeAction(menu, createAddElementAction(parentElement, null, index)); } } @@ -393,7 +397,7 @@ protected void contributeUnconstrainedAttributeActions(IMenuManager menu, Element parentElement, CMElementDeclaration parentEd) { if (isUnconstrainedActionAllowed()) { - if (parentEd == null || parentEd.getProperty("isInferred") == Boolean.TRUE || modelQuery.getEditMode() != ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) { //$NON-NLS-1$ + if ((parentEd == null) || (parentEd.getProperty("isInferred") == Boolean.TRUE) || (modelQuery.getEditMode() != ModelQuery.EDIT_MODE_CONSTRAINED_STRICT)) { //$NON-NLS-1$ contributeAction(menu, createAddAttributeAction(parentElement, null)); } } @@ -446,7 +450,7 @@ public Node getRefChildNodeAtIndex(Node parent, int index) { NodeList nodeList = parent.getChildNodes(); - Node refChild = (index >= 0 && index < nodeList.getLength()) ? nodeList.item(index) : null; + Node refChild = ((index >= 0) && (index < nodeList.getLength())) ? nodeList.item(index) : null; return refChild; } @@ -476,7 +480,8 @@ if (includeTextNodes) { result.add(object); } - } else { + } + else { result.add(node); } } @@ -487,19 +492,19 @@ protected boolean isCommentAllowed(CMElementDeclaration parentEd) { int contentType = parentEd.getContentType(); - return contentType == CMElementDeclaration.ELEMENT || contentType == CMElementDeclaration.MIXED || contentType == CMElementDeclaration.PCDATA || contentType == CMElementDeclaration.ANY; + return (contentType == CMElementDeclaration.ELEMENT) || (contentType == CMElementDeclaration.MIXED) || (contentType == CMElementDeclaration.PCDATA) || (contentType == CMElementDeclaration.ANY); } protected boolean isElementAllowed(CMElementDeclaration parentEd) { int contentType = parentEd.getContentType(); - return contentType == CMElementDeclaration.ELEMENT || contentType == CMElementDeclaration.MIXED || contentType == CMElementDeclaration.ANY; + return (contentType == CMElementDeclaration.ELEMENT) || (contentType == CMElementDeclaration.MIXED) || (contentType == CMElementDeclaration.ANY); } protected boolean isTextAllowed(CMElementDeclaration parentEd) { int contentType = parentEd.getContentType(); - return contentType == CMElementDeclaration.MIXED || contentType == CMElementDeclaration.PCDATA || contentType == CMElementDeclaration.ANY; + return (contentType == CMElementDeclaration.MIXED) || (contentType == CMElementDeclaration.PCDATA) || (contentType == CMElementDeclaration.ANY); }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXMLDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXMLDelegate.java index 81ddbd2..1991a6a 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXMLDelegate.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXMLDelegate.java
@@ -78,12 +78,14 @@ IStructuredModel model = null; try { model = StructuredModelManager.getModelManager().getExistingModelForEdit(editor.getDocumentProvider().getDocument(editor.getEditorInput())); - if (model != null) + if (model != null) { cleanupProcessor.cleanupModel(model); + } } finally { - if (model != null) + if (model != null) { model.releaseFromEdit(); + } } } } @@ -96,7 +98,7 @@ if (model != null) { // begin recording ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection(); - model.beginRecording(this, SSEUIMessages.Cleanup_Document_UI_, SSEUIMessages.Cleanup_Document_UI_, selection.getOffset(), selection.getLength()); //$NON-NLS-1$ //$NON-NLS-2$ + model.beginRecording(this, SSEUIMessages.Cleanup_Document_UI_, SSEUIMessages.Cleanup_Document_UI_, selection.getOffset(), selection.getLength()); // tell the model that we are about to make a big // model change @@ -128,8 +130,9 @@ } IStructuredCleanupProcessor getCleanupProcessor() { - if (fCleanupProcessor == null) + if (fCleanupProcessor == null) { fCleanupProcessor = new CleanupProcessorXML(); + } return fCleanupProcessor; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupDialogXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupDialogXML.java index 3e170a0..5aef2e1 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupDialogXML.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupDialogXML.java
@@ -126,8 +126,9 @@ fRadioButtonConvertEOLWindows.setEnabled(enable); fRadioButtonConvertEOLUnix.setEnabled(enable); fRadioButtonConvertEOLMac.setEnabled(enable); - if (!fRadioButtonConvertEOLWindows.getSelection() && !fRadioButtonConvertEOLUnix.getSelection() && !fRadioButtonConvertEOLMac.getSelection()) + if (!fRadioButtonConvertEOLWindows.getSelection() && !fRadioButtonConvertEOLUnix.getSelection() && !fRadioButtonConvertEOLMac.getSelection()) { fRadioButtonConvertEOLWindows.setSelection(true); + } } } @@ -144,12 +145,15 @@ fCheckBoxFormatSource.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.FORMAT_SOURCE)); fCheckBoxConvertEOLCodes.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.CONVERT_EOL_CODES)); String EOLCode = getModelPreferences().getString(XMLCorePreferenceNames.CLEANUP_EOL_CODE); - if (EOLCode.compareTo(CommonEncodingPreferenceNames.LF) == 0) + if (EOLCode.compareTo(CommonEncodingPreferenceNames.LF) == 0) { fRadioButtonConvertEOLUnix.setSelection(true); - else if (EOLCode.compareTo(CommonEncodingPreferenceNames.CR) == 0) + } + else if (EOLCode.compareTo(CommonEncodingPreferenceNames.CR) == 0) { fRadioButtonConvertEOLMac.setSelection(true); - else + } + else { fRadioButtonConvertEOLWindows.setSelection(true); + } enableEOLCodeRadios(fCheckBoxConvertEOLCodes.getSelection()); } @@ -174,9 +178,11 @@ getModelPreferences().setValue(XMLCorePreferenceNames.CONVERT_EOL_CODES, fCheckBoxConvertEOLCodes.getSelection()); if (fRadioButtonConvertEOLUnix.getSelection()) { getModelPreferences().setValue(XMLCorePreferenceNames.CLEANUP_EOL_CODE, CommonEncodingPreferenceNames.LF); - } else if (fRadioButtonConvertEOLMac.getSelection()) { + } + else if (fRadioButtonConvertEOLMac.getSelection()) { getModelPreferences().setValue(XMLCorePreferenceNames.CLEANUP_EOL_CODE, CommonEncodingPreferenceNames.CR); - } else { + } + else { getModelPreferences().setValue(XMLCorePreferenceNames.CLEANUP_EOL_CODE, CommonEncodingPreferenceNames.CRLF); } // explicitly save plugin preferences so values are stored @@ -190,8 +196,9 @@ public void widgetSelected(SelectionEvent e) { - getButton(OK).setEnabled((fRadioButtonTagNameCaseLower != null && (fRadioButtonTagNameCaseLower.getSelection() || fRadioButtonTagNameCaseUpper.getSelection())) || (fRadioButtonAttrNameCaseLower != null && (fRadioButtonAttrNameCaseLower.getSelection() || fRadioButtonAttrNameCaseUpper.getSelection())) || fCheckBoxInsertMissingTags.getSelection() || fCheckBoxQuoteAttrValues.getSelection() || fCheckBoxFormatSource.getSelection() || fCheckBoxConvertEOLCodes.getSelection() || (fRadioButtonConvertEOLUnix != null && (fRadioButtonConvertEOLUnix.getSelection() || fRadioButtonConvertEOLMac.getSelection() || fRadioButtonConvertEOLWindows.getSelection()))); - if (e.widget == fCheckBoxConvertEOLCodes) + getButton(OK).setEnabled(((fRadioButtonTagNameCaseLower != null) && (fRadioButtonTagNameCaseLower.getSelection() || fRadioButtonTagNameCaseUpper.getSelection())) || ((fRadioButtonAttrNameCaseLower != null) && (fRadioButtonAttrNameCaseLower.getSelection() || fRadioButtonAttrNameCaseUpper.getSelection())) || fCheckBoxInsertMissingTags.getSelection() || fCheckBoxQuoteAttrValues.getSelection() || fCheckBoxFormatSource.getSelection() || fCheckBoxConvertEOLCodes.getSelection() || ((fRadioButtonConvertEOLUnix != null) && (fRadioButtonConvertEOLUnix.getSelection() || fRadioButtonConvertEOLMac.getSelection() || fRadioButtonConvertEOLWindows.getSelection()))); + if (e.widget == fCheckBoxConvertEOLCodes) { enableEOLCodeRadios(fCheckBoxConvertEOLCodes.getSelection()); + } } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditAttributeAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditAttributeAction.java index 5e3a984..f0b41f4 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditAttributeAction.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditAttributeAction.java
@@ -77,4 +77,3 @@ manager.endNodeAction(this); } } -
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditDoctypeAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditDoctypeAction.java index 0a7c2bf..f4b78e3 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditDoctypeAction.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditDoctypeAction.java
@@ -92,7 +92,7 @@ break; } } - return rootElement != null ? rootElement.getNodeName() : XMLUIMessages._UI_LABEL_ROOT_ELEMENT_VALUE; //$NON-NLS-1$ + return rootElement != null ? rootElement.getNodeName() : XMLUIMessages._UI_LABEL_ROOT_ELEMENT_VALUE; } public String getUndoDescription() { @@ -106,21 +106,22 @@ int nodeListLength = nodeList.getLength(); for (int i = 0; i < nodeListLength; i++) { Node childNode = nodeList.item(i); - if (childNode.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE || childNode.getNodeType() == Node.COMMENT_NODE) { + if ((childNode.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) || (childNode.getNodeType() == Node.COMMENT_NODE)) { // continue on to the nextNode - } else { + } + else { refChild = childNode; break; } } document.insertBefore(doctype, refChild); - //manager.reformat(doctype, false); + // manager.reformat(doctype, false); } public void run() { model.beginRecording(this, getUndoDescription()); - //Shell shell = + // Shell shell = // XMLCommonUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell(); Shell shell = getDisplay().getActiveShell(); EditDoctypeDialog dialog = showEditDoctypeDialog(shell); @@ -128,7 +129,8 @@ if (dialog.getReturnCode() == Window.OK) { if (doctype != null) { updateDoctype(dialog, doctype); - } else if (document != null) { + } + else if (document != null) { DocumentType doctype = createDoctype(dialog, document); if (doctype != null) { insertDoctype(doctype, document); @@ -144,19 +146,20 @@ if (doctype != null) { dialog = new EditDoctypeDialog(shell, doctype); if (title == null) { - title = XMLUIMessages._UI_LABEL_EDIT_DOCTYPE; //$NON-NLS-1$ + title = XMLUIMessages._UI_LABEL_EDIT_DOCTYPE; } - } else if (document != null) { + } + else if (document != null) { String rootElementName = getRootElementName(document); dialog = new EditDoctypeDialog(shell, rootElementName, "", rootElementName + ".dtd"); //$NON-NLS-1$ //$NON-NLS-2$ if (title == null) { - title = XMLUIMessages._UI_MENU_ADD_DTD_INFORMATION_TITLE; //$NON-NLS-1$ + title = XMLUIMessages._UI_MENU_ADD_DTD_INFORMATION_TITLE; } } - dialog.setComputeSystemId(doctype == null || doctype.getSystemId() == null || doctype.getSystemId().trim().length() == 0); + dialog.setComputeSystemId((doctype == null) || (doctype.getSystemId() == null) || (doctype.getSystemId().trim().length() == 0)); - dialog.setErrorChecking(false);//!model.getType().equals(IStructuredModel.HTML)); + dialog.setErrorChecking(false);// !model.getType().equals(IStructuredModel.HTML)); dialog.create(); dialog.getShell().setText(title); dialog.setBlockOnOpen(true); @@ -173,14 +176,15 @@ if (doctypeImpl.getName().equals(dialog.getName())) { doctypeImpl.setPublicId(dialog.getPublicId()); doctypeImpl.setSystemId(dialog.getSystemId()); - } else { + } + else { // we need to create a new one and remove the old // Document document = doctype.getOwnerDocument(); DocumentType newDoctype = createDoctype(dialog, document); document.insertBefore(newDoctype, doctype); document.removeChild(doctype); - //manager.reformat(newDoctype, false); + // manager.reformat(newDoctype, false); } } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditElementAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditElementAction.java index 9084fa9..ddd736a 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditElementAction.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditElementAction.java
@@ -90,11 +90,12 @@ setStructuredDocumentRegionElementName(model, elementImpl.getStartStructuredDocumentRegion(), oldName, newName); setStructuredDocumentRegionElementName(model, elementImpl.getEndStructuredDocumentRegion(), oldName, newName); } - } else { + } + else { Element newElement = document.createElement(dialog.getElementName()); NodeList nodeList = parent.getChildNodes(); int nodeListLength = nodeList.getLength(); - Node refChild = insertionIndex < nodeListLength && insertionIndex >= 0 ? nodeList.item(insertionIndex) : null; + Node refChild = (insertionIndex < nodeListLength) && (insertionIndex >= 0) ? nodeList.item(insertionIndex) : null; parent.insertBefore(newElement, refChild); manager.reformat(newElement, false); manager.setViewerSelection(newElement); @@ -114,4 +115,3 @@ } } } -
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditProcessingInstructionAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditProcessingInstructionAction.java index cf1cc1d..afc1c7d 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditProcessingInstructionAction.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditProcessingInstructionAction.java
@@ -64,8 +64,9 @@ EditProcessingInstructionDialog dialog = null; if (pi != null) { dialog = new EditProcessingInstructionDialog(shell, pi); - } else { - dialog = new EditProcessingInstructionDialog(shell, XMLUIMessages._UI_PI_TARGET_VALUE, XMLUIMessages._UI_PI_DATA_VALUE); //$NON-NLS-1$ //$NON-NLS-2$ + } + else { + dialog = new EditProcessingInstructionDialog(shell, XMLUIMessages._UI_PI_TARGET_VALUE, XMLUIMessages._UI_PI_DATA_VALUE); } dialog.create();
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditSchemaInfoAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditSchemaInfoAction.java index 391931b..9a7ac24 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditSchemaInfoAction.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditSchemaInfoAction.java
@@ -87,7 +87,8 @@ Element result = null; if (node.getNodeType() == Node.ELEMENT_NODE) { result = (Element) node; - } else if (node.getNodeType() == Node.DOCUMENT_NODE) { + } + else if (node.getNodeType() == Node.DOCUMENT_NODE) { result = getRootElement((Document) node); } return result; @@ -136,8 +137,8 @@ dialog.setNamespaceInfoList(namespaceInfoList); dialog.create(); - //dialog.getShell().setSize(500, 300); - dialog.getShell().setText(XMLUIMessages._UI_MENU_EDIT_SCHEMA_INFORMATION_TITLE); //$NON-NLS-1$ + // dialog.getShell().setSize(500, 300); + dialog.getShell().setText(XMLUIMessages._UI_MENU_EDIT_SCHEMA_INFORMATION_TITLE); dialog.setBlockOnOpen(true); dialog.open(); @@ -153,7 +154,8 @@ manager.getModel().aboutToChangeModel(); ReplacePrefixAction replacePrefixAction = new ReplacePrefixAction(manager, element, prefixMapping); replacePrefixAction.run(); - } finally { + } + finally { manager.getModel().changedModel(); } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/MenuBuilder.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/MenuBuilder.java index ed716d7..f735d1c 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/MenuBuilder.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/MenuBuilder.java
@@ -40,10 +40,10 @@ IAction action = (IAction) o; result = action.getText(); } - //else if (o instanceof MenuData) - //{ - // result = "z" + ((MenuData)o).name; - //} + // else if (o instanceof MenuData) + // { + // result = "z" + ((MenuData)o).name; + // } return result; } }; @@ -84,7 +84,8 @@ for (int i = 0; i < array.length; i++) { menu.add((Action) array[i]); } - } else { + } + else { createAlphebeticalGrouping(menu, actionList); } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXMLDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXMLDelegate.java index a762cea..1578508 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXMLDelegate.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXMLDelegate.java
@@ -35,8 +35,9 @@ IndexedRegion selectionStartIndexedRegion = model.getIndexedRegion(textSelection.getOffset()); IndexedRegion selectionEndIndexedRegion = model.getIndexedRegion(textSelection.getOffset() + textSelection.getLength()); - if (selectionStartIndexedRegion == null || selectionEndIndexedRegion == null) + if ((selectionStartIndexedRegion == null) || (selectionEndIndexedRegion == null)) { return; + } int openCommentOffset = selectionStartIndexedRegion.getStartOffset(); int closeCommentOffset = selectionEndIndexedRegion.getEndOffset() - OPEN_COMMENT.length() - CLOSE_COMMENT.length();
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXMLDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXMLDelegate.java index 5c6710f..d0ec90b 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXMLDelegate.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXMLDelegate.java
@@ -47,8 +47,9 @@ int selectionEndOffset = textSelection.getOffset() + textSelection.getLength(); // adjust selection end line - if (selectionEndLine > selectionStartLine && selectionEndLineOffset == selectionEndOffset) + if ((selectionEndLine > selectionStartLine) && (selectionEndLineOffset == selectionEndOffset)) { selectionEndLine--; + } } catch (BadLocationException e) { @@ -64,8 +65,9 @@ // extra check if commenting from beginning of line int selectionStartLineOffset = document.getLineOffset(selectionStartLine); - if (textSelection.getLength() > 0 && selectionStartLineOffset == textSelection.getOffset() && !isCommentLine(document, selectionStartLine)) + if ((textSelection.getLength() > 0) && (selectionStartLineOffset == textSelection.getOffset()) && !isCommentLine(document, selectionStartLine)) { updateStartOffset = true; + } } catch (BadLocationException e) { Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); @@ -121,7 +123,7 @@ try { IRegion region = document.getLineInformation(line); String string = document.get(region.getOffset(), region.getLength()).trim(); - isComment = string.length() >= OPEN_COMMENT.length() + CLOSE_COMMENT.length() && string.startsWith(OPEN_COMMENT) && string.endsWith(CLOSE_COMMENT); + isComment = (string.length() >= OPEN_COMMENT.length() + CLOSE_COMMENT.length()) && string.startsWith(OPEN_COMMENT) && string.endsWith(CLOSE_COMMENT); } catch (BadLocationException e) { Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); @@ -155,10 +157,12 @@ // update the selection if text selection changed if (selectionPosition != null) { ITextSelection selection = null; - if (updateStartOffset) + if (updateStartOffset) { selection = new TextSelection(document, selectionPosition.getOffset() - OPEN_COMMENT.length(), selectionPosition.getLength() + OPEN_COMMENT.length()); - else + } + else { selection = new TextSelection(document, selectionPosition.getOffset(), selectionPosition.getLength()); + } ISelectionProvider provider = ((ITextEditor) fEditor).getSelectionProvider(); if (provider != null) { provider.setSelection(selection);
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/AutoEditStrategyForTabs.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/AutoEditStrategyForTabs.java index bc7fece..fe2ea28 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/AutoEditStrategyForTabs.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/AutoEditStrategyForTabs.java
@@ -35,16 +35,18 @@ * AutoEditStrategy to handle characters inserted when Tab key is pressed */ public class AutoEditStrategyForTabs implements IAutoEditStrategy { - private final String TAB_CHARACTER = "\t"; //$NON-NLS-1$ - + private final String TAB_CHARACTER = "\t"; //$NON-NLS-1$ + public void customizeDocumentCommand(IDocument document, DocumentCommand command) { // if not in smart insert mode just ignore - if (!isSmartInsertMode()) + if (!isSmartInsertMode()) { return; - + } + // spaces for tab character - if (command.length == 0 && command.text != null && command.text.length() > 0 && command.text.indexOf(TAB_CHARACTER) != -1) + if ((command.length == 0) && (command.text != null) && (command.text.length() > 0) && (command.text.indexOf(TAB_CHARACTER) != -1)) { smartInsertForTab(command, document); + } } /** @@ -65,7 +67,8 @@ try { IRegion lineInfo = document.getLineInformationOfOffset(command.offset); lineOffset = command.offset - lineInfo.getOffset(); - } catch (BadLocationException e) { + } + catch (BadLocationException e) { Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); } @@ -81,7 +84,8 @@ if (lineTracker != null) { try { lineTracker.replace(index, 1, indent); - } catch (BadLocationException e) { + } + catch (BadLocationException e) { // if something goes wrong with replacing text, just // reset to current string lineTracker.set(newText.toString()); @@ -105,26 +109,31 @@ if (lineTracker != null) { try { IRegion lineInfo = lineTracker.getLineInformationOfOffset(index); - if (lineInfo.getOffset() == 0 && lineOffset > -1) + if ((lineInfo.getOffset() == 0) && (lineOffset > -1)) { offsetInLine = lineOffset + index; - else + } + else { offsetInLine = index - lineInfo.getOffset(); - } catch (BadLocationException e) { + } + } + catch (BadLocationException e) { Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); } - } else { + } + else { if (lineOffset > -1) { offsetInLine = lineOffset + index; } } - if (offsetInLine > -1 && indentationWidth > 0) { + if ((offsetInLine > -1) && (indentationWidth > 0)) { int remainder = offsetInLine % indentationWidth; indentSize = indentationWidth - remainder; } StringBuffer indent = new StringBuffer(); - for (int i = 0; i < indentSize; i++) + for (int i = 0; i < indentSize; i++) { indent.append(' '); + } return indent.toString(); } @@ -134,13 +143,13 @@ private ILineTracker getLineTracker(IDocument document, String originalText) { ConfigurableLineTracker lineTracker = null; int[] delims = TextUtilities.indexOf(document.getLegalLineDelimiters(), originalText, 0); - if (delims[0] != -1 || delims[1] != -1) { + if ((delims[0] != -1) || (delims[1] != -1)) { lineTracker = new ConfigurableLineTracker(document.getLegalLineDelimiters()); lineTracker.set(originalText); } return lineTracker; } - + /** * Return true if active editor is in smart insert mode, false otherwise * @@ -148,7 +157,7 @@ */ private boolean isSmartInsertMode() { boolean isSmartInsertMode = false; - + ITextEditor textEditor = null; IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { @@ -156,20 +165,23 @@ if (page != null) { IEditorPart editor = page.getActiveEditor(); if (editor != null) { - if (editor instanceof ITextEditor) - textEditor = (ITextEditor)editor; - else - textEditor = (ITextEditor)editor.getAdapter(ITextEditor.class); + if (editor instanceof ITextEditor) { + textEditor = (ITextEditor) editor; + } + else { + textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class); + } } } } - + // check if smart insert mode - if (textEditor instanceof ITextEditorExtension3 && ((ITextEditorExtension3) textEditor).getInsertMode() == ITextEditorExtension3.SMART_INSERT) + if ((textEditor instanceof ITextEditorExtension3) && (((ITextEditorExtension3) textEditor).getInsertMode() == ITextEditorExtension3.SMART_INSERT)) { isSmartInsertMode = true; + } return isSmartInsertMode; } - + /** * Returns indentation width if using spaces for indentation, -1 otherwise * @@ -179,8 +191,9 @@ int width = -1; Preferences preferences = XMLCorePlugin.getDefault().getPluginPreferences(); - if (XMLCorePreferenceNames.SPACE.equals(preferences.getString(XMLCorePreferenceNames.INDENTATION_CHAR))) + if (XMLCorePreferenceNames.SPACE.equals(preferences.getString(XMLCorePreferenceNames.INDENTATION_CHAR))) { width = preferences.getInt(XMLCorePreferenceNames.INDENTATION_SIZE); + } return width; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java index 591c0c9..6e24d93 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java
@@ -41,8 +41,9 @@ */ public void customizeDocumentCommand(IDocument document, DocumentCommand command) { Object textEditor = getActiveTextEditor(); - if (!(textEditor instanceof ITextEditorExtension3 && ((ITextEditorExtension3) textEditor).getInsertMode() == ITextEditorExtension3.SMART_INSERT)) + if (!((textEditor instanceof ITextEditorExtension3) && (((ITextEditorExtension3) textEditor).getInsertMode() == ITextEditorExtension3.SMART_INSERT))) { return; + } IStructuredModel model = null; try { @@ -55,22 +56,23 @@ } } finally { - if (model != null) + if (model != null) { model.releaseFromRead(); + } } } private boolean isCommentNode(IDOMNode node) { - return (node != null && node instanceof IDOMElement && ((IDOMElement) node).isCommentTag()); + return ((node != null) && (node instanceof IDOMElement) && ((IDOMElement) node).isCommentTag()); } private boolean isDocumentNode(IDOMNode node) { - return (node != null && node.getNodeType() == Node.DOCUMENT_NODE); + return ((node != null) && (node.getNodeType() == Node.DOCUMENT_NODE)); } private void smartInsertForComment(DocumentCommand command, IDocument document, IStructuredModel model) { try { - if (command.text.equals("-") && document.getLength() >= 3 && document.get(command.offset - 3, 3).equals("<!-")) { //$NON-NLS-1$ //$NON-NLS-2$ + if (command.text.equals("-") && (document.getLength() >= 3) && document.get(command.offset - 3, 3).equals("<!-")) { //$NON-NLS-1$ //$NON-NLS-2$ command.text += " -->"; //$NON-NLS-1$ command.shiftsCaret = false; command.caretOffset = command.offset + 2; @@ -85,11 +87,11 @@ private void smartInsertForEndTag(DocumentCommand command, IDocument document, IStructuredModel model) { try { - if (command.text.equals("/") && document.getLength() >= 1 && document.get(command.offset - 1, 1).equals("<")) { //$NON-NLS-1$ //$NON-NLS-2$ + if (command.text.equals("/") && (document.getLength() >= 1) && document.get(command.offset - 1, 1).equals("<")) { //$NON-NLS-1$ //$NON-NLS-2$ IDOMNode parentNode = (IDOMNode) ((IDOMNode) model.getIndexedRegion(command.offset - 1)).getParentNode(); if (isCommentNode(parentNode)) { // loop and find non comment node parent - while (parentNode != null && isCommentNode(parentNode)) { + while ((parentNode != null) && isCommentNode(parentNode)) { parentNode = (IDOMNode) parentNode.getParentNode(); } } @@ -129,11 +131,13 @@ if (page != null) { IEditorPart editor = page.getActiveEditor(); if (editor != null) { - if (editor instanceof ITextEditor) + if (editor instanceof ITextEditor) { return editor; + } ITextEditor textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class); - if (textEditor != null) + if (textEditor != null) { return textEditor; + } return editor; } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java index 09ee3e6..72c604e 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java
@@ -137,7 +137,7 @@ AttrImpl existingAttr = (AttrImpl) attrs.item(i); ITextRegion name = existingAttr.getNameRegion(); - if (sdRegion.getStartOffset(name) <= contentAssistRequest.getReplacementBeginPosition() && sdRegion.getStartOffset(name) + name.getLength() >= contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength() && existingAttr.getValueRegion() != null) { + if ((sdRegion.getStartOffset(name) <= contentAssistRequest.getReplacementBeginPosition()) && (sdRegion.getStartOffset(name) + name.getLength() >= contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength()) && (existingAttr.getValueRegion() != null)) { attrAtLocationHasValue = true; break; } @@ -148,7 +148,7 @@ if (attributes != null) { for (int i = 0; i < attributes.getLength(); i++) { CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attributes.item(i); - + int isRequired = 0; if (attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) { isRequired = XMLRelevanceConstants.R_REQUIRED; @@ -160,7 +160,7 @@ ITextRegion nameRegion = attr != null ? attr.getNameRegion() : null; // nameRegion.getEndOffset() + 1 is required to allow for // matches against the full name of an existing Attr - showAttribute = showAttribute && ((attr == null) || (nameRegion != null && sdRegion.getStartOffset(nameRegion) <= contentAssistRequest.getReplacementBeginPosition() && sdRegion.getStartOffset(nameRegion) + nameRegion.getLength() >= contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength())); + showAttribute = showAttribute && ((attr == null) || ((nameRegion != null) && (sdRegion.getStartOffset(nameRegion) <= contentAssistRequest.getReplacementBeginPosition()) && (sdRegion.getStartOffset(nameRegion) + nameRegion.getLength() >= contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength()))); if (showAttribute) { Image attrImage = CMImageUtil.getImage(attrDecl); if (attrImage == null) { @@ -179,24 +179,26 @@ if (attrAtLocationHasValue) { // only propose the name proposedText = getRequiredName(node, attrDecl); - proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), proposedText.length(), attrImage, proposedText, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME + isRequired, true); + proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), proposedText.length(), attrImage, proposedText, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME + isRequired, true); } // no attribute exists or is elsewhere, generate // minimally else { Attr existingAttrNode = (Attr) node.getAttributes().getNamedItem(getRequiredName(node, attrDecl)); String value = null; - if (existingAttrNode != null) + if (existingAttrNode != null) { value = existingAttrNode.getNodeValue(); - if (value != null && value.length() > 0) + } + if ((value != null) && (value.length() > 0)) { proposedText = getRequiredName(node, attrDecl); + } else { proposedText = getRequiredText(node, attrDecl); } proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), attrDecl.getNodeName().length() + 2, attrImage, // if the value isn't empty (no empty set of // quotes), show it - (showValues && proposedText.indexOf("\"\"") < 0) ? proposedText : getRequiredName(node, attrDecl), //$NON-NLS-1$ + (showValues && (proposedText.indexOf("\"\"") < 0)) ? proposedText : getRequiredName(node, attrDecl), //$NON-NLS-1$ null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME + isRequired); } contentAssistRequest.addProposal(proposal); @@ -210,7 +212,7 @@ } protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) { - + IDOMNode node = (IDOMNode) contentAssistRequest.getNode(); // Find the attribute region and name for which this position should @@ -218,13 +220,15 @@ IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion(); ITextRegionList openRegions = open.getRegions(); int i = openRegions.indexOf(contentAssistRequest.getRegion()); - if (i < 0) + if (i < 0) { return; + } ITextRegion nameRegion = null; while (i >= 0) { nameRegion = openRegions.get(i--); - if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) + if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) { break; + } } // the name region is REQUIRED to do anything useful @@ -258,7 +262,7 @@ String proposedInfo = null; Image image = CMImageUtil.getImage(attrDecl); if (image == null) { - if (attrDecl != null && attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) { + if ((attrDecl != null) && (attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED)) { image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATT_REQ_OBJ); } else { @@ -266,52 +270,52 @@ } } - if (attrDecl != null && attrDecl.getAttrType() != null) { + if ((attrDecl != null) && (attrDecl.getAttrType() != null)) { // attribute is known, prompt with values from the declaration proposedInfo = getAdditionalInfo(elementDecl, attrDecl); List possibleValues = getPossibleDataTypeValues(node, attrDecl); if (possibleValues.size() > 0) { // ENUMERATED VALUES String matchString = contentAssistRequest.getMatchString(); - if (matchString == null) + if (matchString == null) { matchString = ""; //$NON-NLS-1$ - if (matchString.length() > 0 && (matchString.startsWith("\"") || matchString.startsWith("'"))) //$NON-NLS-2$//$NON-NLS-1$ + } + if ((matchString.length() > 0) && (matchString.startsWith("\"") || matchString.startsWith("'"))) { matchString = matchString.substring(1); + } boolean currentValid = false; // d210858, if the region's a container, don't suggest the // enumerated values as they probably won't help - boolean existingComplicatedValue = contentAssistRequest.getRegion() != null && contentAssistRequest.getRegion() instanceof ITextRegionContainer; + boolean existingComplicatedValue = (contentAssistRequest.getRegion() != null) && (contentAssistRequest.getRegion() instanceof ITextRegionContainer); if (!existingComplicatedValue) { for (Iterator j = possibleValues.iterator(); j.hasNext();) { String possibleValue = (String) j.next(); currentValid = currentValid || possibleValue.equals(currentValue); - if (matchString.length() == 0 || possibleValue.startsWith(matchString)) { - + if ((matchString.length() == 0) || possibleValue.startsWith(matchString)) { + String rString = "\"" + possibleValue + "\""; //$NON-NLS-2$//$NON-NLS-1$ int rOffset = contentAssistRequest.getReplacementBeginPosition(); int rLength = contentAssistRequest.getReplacementLength(); int cursorAfter = possibleValue.length() + 1; String displayString = "\"" + possibleValue + "\""; //$NON-NLS-2$//$NON-NLS-1$ - + CustomCompletionProposal proposal = new CustomCompletionProposal(rString, rOffset, rLength, cursorAfter, image, displayString, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE); contentAssistRequest.addProposal(proposal); } } } } - else if ((attrDecl.getUsage() == CMAttributeDeclaration.FIXED || attrDecl.getAttrType().getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED) && attrDecl.getAttrType().getImpliedValue() != null) { + else if (((attrDecl.getUsage() == CMAttributeDeclaration.FIXED) || (attrDecl.getAttrType().getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED)) && (attrDecl.getAttrType().getImpliedValue() != null)) { // FIXED values String value = attrDecl.getAttrType().getImpliedValue(); - if (value != null && value.length() > 0) { + if ((value != null) && (value.length() > 0)) { String rValue = "\"" + value + "\"";//$NON-NLS-2$//$NON-NLS-1$ - CustomCompletionProposal proposal = new CustomCompletionProposal(rValue, - contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), rValue.length() + 1, image, rValue, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE); + CustomCompletionProposal proposal = new CustomCompletionProposal(rValue, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), rValue.length() + 1, image, rValue, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE); contentAssistRequest.addProposal(proposal); - if (currentValue.length() > 0 && !value.equals(currentValue)) { + if ((currentValue.length() > 0) && !value.equals(currentValue)) { rValue = "\"" + currentValue + "\""; //$NON-NLS-2$//$NON-NLS-1$ - proposal = new CustomCompletionProposal(rValue, - contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), rValue.length() + 1, image, rValue, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE); + proposal = new CustomCompletionProposal(rValue, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), rValue.length() + 1, image, rValue, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE); contentAssistRequest.addProposal(proposal); } } @@ -321,17 +325,16 @@ // unknown attribute, so supply nice empty values proposedInfo = getAdditionalInfo(null, elementDecl); CustomCompletionProposal proposal = null; - if (currentValue != null && currentValue.length() > 0) { + if ((currentValue != null) && (currentValue.length() > 0)) { String rValue = "\"" + currentValue + "\""; //$NON-NLS-2$//$NON-NLS-1$ - proposal = new CustomCompletionProposal(rValue, - contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 1, image, rValue, //$NON-NLS-2$//$NON-NLS-1$ - null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE); + proposal = new CustomCompletionProposal(rValue, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 1, image, rValue, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE); contentAssistRequest.addProposal(proposal); } } } - else + else { setErrorMessage(UNKNOWN_CONTEXT); + } } protected void addCommentProposal(ContentAssistRequest contentAssistRequest) { @@ -345,12 +348,14 @@ * big list. */ protected void addContent(List contentList, CMContent content) { - if (content == null) + if (content == null) { return; + } if (content instanceof CMGroup) { CMNodeList children = ((CMGroup) content).getChildNodes(); - if (children == null) + if (children == null) { return; + } for (int i = 0; i < children.getLength(); i++) { CMNode child = children.item(i); if (child.getNodeType() == CMNode.ELEMENT_DECLARATION) { @@ -374,8 +379,9 @@ protected void addDocTypeProposal(ContentAssistRequest contentAssistRequest) { // if a DocumentElement exists, use that for the root Element name String rootname = "unspecified"; //$NON-NLS-1$ - if (contentAssistRequest.getNode().getOwnerDocument().getDocumentElement() != null) + if (contentAssistRequest.getNode().getOwnerDocument().getDocumentElement() != null) { rootname = contentAssistRequest.getNode().getOwnerDocument().getDocumentElement().getNodeName(); + } String proposedText = "<!DOCTYPE " + rootname + " PUBLIC \"//UNKNOWN/\" \"unknown.dtd\">"; //$NON-NLS-1$ //$NON-NLS-2$ ICompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 10, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_DOCTYPE), "<!DOCTYPE ... >", //$NON-NLS-1$ @@ -407,18 +413,20 @@ ModelQuery modelQuery = ModelQueryUtil.getModelQuery(node.getOwnerDocument()); Node aNode = contentAssistRequest.getNode(); String matchString = contentAssistRequest.getMatchString(); - if (matchString.startsWith("</")) //$NON-NLS-1$ + if (matchString.startsWith("</")) { matchString = matchString.substring(2); + } while (aNode != null) { if (aNode.getNodeType() == Node.ELEMENT_NODE) { if (aNode.getNodeName().startsWith(matchString)) { IDOMNode aXMLNode = (IDOMNode) aNode; CMElementDeclaration ed = modelQuery.getCMElementDeclaration((Element) aNode); - if ((aXMLNode.getEndStructuredDocumentRegion() == null) && (ed == null || (ed.getContentType() != CMElementDeclaration.EMPTY))) { + if ((aXMLNode.getEndStructuredDocumentRegion() == null) && ((ed == null) || (ed.getContentType() != CMElementDeclaration.EMPTY))) { String proposedText = aNode.getNodeName(); String proposedInfo = (ed != null) ? getAdditionalInfo(null, ed) : null; - if (node.getNodeType() == Node.TEXT_NODE && !contentAssistRequest.getDocumentRegion().isEnded()) + if ((node.getNodeType() == Node.TEXT_NODE) && !contentAssistRequest.getDocumentRegion().isEnded()) { proposedText += ">"; //$NON-NLS-1$ + } CustomCompletionProposal proposal = null; // double check to see if the region acted upon is // a tag name; replace it if so @@ -456,22 +464,23 @@ if (isCommentNode(node)) { // loop and find non comment node parent - while (node != null && isCommentNode(node)) { + while ((node != null) && isCommentNode(node)) { node = (IDOMNode) node.getParentNode(); } } - + // node is already closed - if(node.isClosed()) { + if (node.isClosed()) { // loop and find non comment unclose node parent - while (node != null && node.isClosed()) { + while ((node != null) && node.isClosed()) { node = (IDOMNode) node.getParentNode(); } } // there were no unclosed tags - if(node == null) + if (node == null) { return; - + } + // data to create a CustomCompletionProposal String replaceText = node.getNodeName() + ">"; //$NON-NLS-1$ int replaceBegin = contentAssistRequest.getReplacementBeginPosition(); @@ -491,16 +500,17 @@ // skip backward to "<", "</", or the (unclosed) start tag, null // if not found String type = ""; //$NON-NLS-1$ - while (xmlEndTagOpen != null && (type = xmlEndTagOpen.getType()) != DOMRegionContext.XML_END_TAG_OPEN && type != DOMRegionContext.XML_TAG_CLOSE && !needsEndTag(xmlEndTagOpen) && type != DOMRegionContext.XML_TAG_OPEN) { + while ((xmlEndTagOpen != null) && ((type = xmlEndTagOpen.getType()) != DOMRegionContext.XML_END_TAG_OPEN) && (type != DOMRegionContext.XML_TAG_CLOSE) && !needsEndTag(xmlEndTagOpen) && (type != DOMRegionContext.XML_TAG_OPEN)) { xmlEndTagOpen = xmlEndTagOpen.getPrevious(); } - if (xmlEndTagOpen == null) + if (xmlEndTagOpen == null) { return; + } node = (IDOMNode) node.getModel().getIndexedRegion(xmlEndTagOpen.getStartOffset()); node = (IDOMNode) node.getParentNode(); - + if (isStartTag(xmlEndTagOpen)) { // this is the case for a start tag w/out end tag // eg: @@ -539,19 +549,19 @@ // should only be replacing white space... replaceLength = (replaceBegin > xmlEndTagOpen.getTextEndOffset()) ? replaceBegin - xmlEndTagOpen.getTextEndOffset() : 0; replaceBegin = xmlEndTagOpen.getTextEndOffset(); - displayString = NLS.bind(XMLUIMessages.End_with_, (new Object[]{"/" + node.getNodeName()})); //$NON-NLS-1$ + displayString = NLS.bind(XMLUIMessages.End_with_, (new Object[]{"/" + node.getNodeName()})); //$NON-NLS-1$ addProposal = true; } } // //////////////////////////////////////////////////////////////////////////////////// // sometimes the node is not null, but // getNodeValue() is null, put in a null check - else if (node.getNodeValue() != null && node.getNodeValue().indexOf("</") != -1) { //$NON-NLS-1$ + else if ((node.getNodeValue() != null) && (node.getNodeValue().indexOf("</") != -1)) { //$NON-NLS-1$ // the case where "</" is started, but the nodes comes in as a // text node (instead of element) // like this: <tag> </| Node parent = node.getParentNode(); - if (parent != null && parent.getNodeType() != Node.DOCUMENT_NODE) { + if ((parent != null) && (parent.getNodeType() != Node.DOCUMENT_NODE)) { replaceText = parent.getNodeName() + ">"; //$NON-NLS-1$ cursorOffset = replaceText.length(); displayString = NLS.bind(XMLUIMessages.End_with__, (new Object[]{parent.getNodeName()})); @@ -571,13 +581,15 @@ protected void addEntityProposals(ContentAssistRequest contentAssistRequest, int documentPosition, ITextRegion completionRegion, IDOMNode treeNode) { ICompletionProposal[] eps = computeEntityReferenceProposals(documentPosition, completionRegion, treeNode); - for (int i = 0; eps != null && i < eps.length; i++) + for (int i = 0; (eps != null) && (i < eps.length); i++) { contentAssistRequest.addProposal(eps[i]); + } } protected void addEntityProposals(Vector proposals, Properties map, String key, int nodeOffset, IStructuredDocumentRegion sdRegion, ITextRegion completionRegion) { - if (map == null) + if (map == null) { return; + } String entityName = ""; //$NON-NLS-1$ String entityValue = ""; //$NON-NLS-1$ Image entityIcon = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ENTITY_REFERENCE); @@ -585,7 +597,7 @@ String displayString = ""; //$NON-NLS-1$ Enumeration keys = map.keys(); - while (keys != null && keys.hasMoreElements()) { + while ((keys != null) && keys.hasMoreElements()) { entityName = (String) keys.nextElement(); entityValue = map.getProperty(entityName); // filter based on partial entity string... @@ -628,11 +640,11 @@ // make sure xmlpi is root element // don't want doctype proposal if XMLPI isn't first element... Node first = owningDocument.getFirstChild(); - boolean xmlpiIsFirstElement = (first != null && first.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE); + boolean xmlpiIsFirstElement = ((first != null) && (first.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE)); boolean insertDoctype = xmlpiIsFirstElement; for (Node child = owningDocument.getFirstChild(); child != null; child = child.getNextSibling()) { - boolean xmlpi = (child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE && child.getNodeName().equals("xml")); //$NON-NLS-1$ + boolean xmlpi = ((child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) && child.getNodeName().equals("xml")); //$NON-NLS-1$ xmlpiFound = xmlpiFound || xmlpi; if (xmlpiFound) { if (child instanceof IDOMNode) { @@ -640,12 +652,12 @@ // ((XMLNode)child).getEndOffset(); } // skip white space and text - while ((child = child.getNextSibling()) != null && (child.getNodeType() == Node.TEXT_NODE)) { + while (((child = child.getNextSibling()) != null) && (child.getNodeType() == Node.TEXT_NODE)) { // just skipping } // check if theres a node inbetween XMLPI and cursor position - if (child != null && child instanceof IDOMNode) { - if (contentAssistRequest.getReplacementBeginPosition() >= ((IDOMNode) child).getEndOffset() || !xmlpiIsFirstElement) { + if ((child != null) && (child instanceof IDOMNode)) { + if ((contentAssistRequest.getReplacementBeginPosition() >= ((IDOMNode) child).getEndOffset()) || !xmlpiIsFirstElement) { insertDoctype = false; } } @@ -653,7 +665,7 @@ } } - if (xmlpiFound && owningDocument.getDoctype() == null && isCursorAfterXMLPI(contentAssistRequest) && insertDoctype) { + if (xmlpiFound && (owningDocument.getDoctype() == null) && isCursorAfterXMLPI(contentAssistRequest) && insertDoctype) { addDocTypeProposal(contentAssistRequest); } } @@ -670,7 +682,7 @@ int contentType = (elementDecl != null) ? elementDecl.getContentType() : CMElementDeclaration.ANY; // if it's XML and content doesn't HAVE to be element, add "/>" // proposal. - boolean endWithSlashBracket = (getXML(node) && contentType != CMElementDeclaration.ELEMENT); + boolean endWithSlashBracket = (getXML(node) && (contentType != CMElementDeclaration.ELEMENT)); Image image = CMImageUtil.getImage(elementDecl); if (image == null) { @@ -678,18 +690,17 @@ } // is the start tag ended properly? - if (contentAssistRequest.getDocumentRegion() == node.getFirstStructuredDocumentRegion() && !(node.getFirstStructuredDocumentRegion()).isEnded()) { + if ((contentAssistRequest.getDocumentRegion() == node.getFirstStructuredDocumentRegion()) && !(node.getFirstStructuredDocumentRegion()).isEnded()) { setErrorMessage(null); // Is this supposed to be an empty tag? Note that if we can't // tell, we assume it's not. - if (elementDecl != null && elementDecl.getContentType() == CMElementDeclaration.EMPTY) { + if ((elementDecl != null) && (elementDecl.getContentType() == CMElementDeclaration.EMPTY)) { // prompt with a self-closing end character if needed CustomCompletionProposal proposal = new CustomCompletionProposal(getContentGenerator().getStartTagClose(node, elementDecl), contentAssistRequest.getReplacementBeginPosition(), // this is one of the few times to ignore the length -- // always insert // contentAssistRequest.getReplacementLength(), - 0, getContentGenerator().getStartTagClose(node, elementDecl).length(), image, NLS.bind(XMLUIMessages.Close_with___, (new Object[]{getContentGenerator().getStartTagClose(node, elementDecl)})), - null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG); + 0, getContentGenerator().getStartTagClose(node, elementDecl).length(), image, NLS.bind(XMLUIMessages.Close_with___, (new Object[]{getContentGenerator().getStartTagClose(node, elementDecl)})), null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG); contentAssistRequest.addProposal(proposal); } else { @@ -710,14 +721,13 @@ // is...(eg. <%@ vs. <jsp:directive) IStructuredDocumentRegion sdr = contentAssistRequest.getDocumentRegion(); String openingTagText = (sdr != null) ? sdr.getFullText() : ""; //$NON-NLS-1$ - if (openingTagText != null && openingTagText.indexOf(node.getNodeName()) != -1) { + if ((openingTagText != null) && (openingTagText.indexOf(node.getNodeName()) != -1)) { proposal = new CustomCompletionProposal("></" + node.getNodeName() + ">", //$NON-NLS-2$//$NON-NLS-1$ contentAssistRequest.getReplacementBeginPosition(), // this is one of the few times to // ignore the length -- always insert // contentAssistRequest.getReplacementLength(), - 0, 1, image, NLS.bind(XMLUIMessages.Close_with____, (new Object[]{node.getNodeName()})), - null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG); + 0, 1, image, NLS.bind(XMLUIMessages.Close_with____, (new Object[]{node.getNodeName()})), null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG); contentAssistRequest.addProposal(proposal); } } @@ -741,7 +751,7 @@ } } } - else if (contentAssistRequest.getDocumentRegion() == node.getLastStructuredDocumentRegion() && !node.getLastStructuredDocumentRegion().isEnded()) { + else if ((contentAssistRequest.getDocumentRegion() == node.getLastStructuredDocumentRegion()) && !node.getLastStructuredDocumentRegion().isEnded()) { setErrorMessage(null); // prompt with a closing end character for the end tag CustomCompletionProposal proposal = new CustomCompletionProposal(">", //$NON-NLS-1$ @@ -766,19 +776,20 @@ // (nsd) This is only valid at the document element level // only valid if it's XML (check added 2/17/2004) - if (parent != null && parent.getNodeType() == Node.DOCUMENT_NODE && ((IDOMDocument) parent).isXMLType() && !isCursorAfterXMLPI(contentAssistRequest)) { + if ((parent != null) && (parent.getNodeType() == Node.DOCUMENT_NODE) && ((IDOMDocument) parent).isXMLType() && !isCursorAfterXMLPI(contentAssistRequest)) { return; } // only want proposals if cursor is after doctype... - if (!isCursorAfterDoctype(contentAssistRequest)) + if (!isCursorAfterDoctype(contentAssistRequest)) { return; - + } + // fix for meta-info comment nodes.. they currently "hide" other // proposals because the don't // have a content model (so can't propose any children..) - if (parent != null && parent instanceof IDOMNode && isCommentNode((IDOMNode) parent)) { + if ((parent != null) && (parent instanceof IDOMNode) && isCommentNode((IDOMNode) parent)) { // loop and find non comment node? - while (parent != null && isCommentNode((IDOMNode) parent)) { + while ((parent != null) && isCommentNode((IDOMNode) parent)) { parent = parent.getParentNode(); } } @@ -809,32 +820,36 @@ } } } - if (parentDecl != null && parentDecl.getContentType() == CMElementDeclaration.PCDATA) { + if ((parentDecl != null) && (parentDecl.getContentType() == CMElementDeclaration.PCDATA)) { addPCDATAProposal(parentDecl.getNodeName(), contentAssistRequest); } else { - // retrieve the list of all possible children within this parent context - cmnodes = getAvailableChildElementDeclarations((Element)parent, childPosition, ModelQueryAction.INSERT); - - // retrieve the list of the possible children within this parent context and at this index - List strictCMNodeSuggestions = null; - if (XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_STRICT.equals(XMLUIPlugin.getInstance().getPreferenceStore().getString(XMLUIPreferenceNames.SUGGESTION_STRATEGY))) - { - strictCMNodeSuggestions = getValidChildElementDeclarations((Element)parent, childPosition, ModelQueryAction.INSERT); - } - Iterator nodeIterator = cmnodes.iterator(); + // retrieve the list of all possible children within this + // parent context + cmnodes = getAvailableChildElementDeclarations((Element) parent, childPosition, ModelQueryAction.INSERT); + + // retrieve the list of the possible children within this + // parent context and at this index + List strictCMNodeSuggestions = null; + if (XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_STRICT.equals(XMLUIPlugin.getInstance().getPreferenceStore().getString(XMLUIPreferenceNames.SUGGESTION_STRATEGY))) { + strictCMNodeSuggestions = getValidChildElementDeclarations((Element) parent, childPosition, ModelQueryAction.INSERT); + } + Iterator nodeIterator = cmnodes.iterator(); if (!nodeIterator.hasNext()) { - if (getCMElementDeclaration(parent) != null) + if (getCMElementDeclaration(parent) != null) { error = NLS.bind(XMLUIMessages._Has_no_available_child, (new Object[]{parent.getNodeName()})); - else + } + else { error = NLS.bind(XMLUIMessages.Element__is_unknown, (new Object[]{parent.getNodeName()})); + } } String matchString = contentAssistRequest.getMatchString(); // chop off any leading <'s and whitespace from the // matchstring - while ((matchString.length() > 0) && (Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString, "<"))) //$NON-NLS-1$ + while ((matchString.length() > 0) && (Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString, "<"))) { //$NON-NLS-1$ matchString = matchString.substring(1); + } while (nodeIterator.hasNext()) { Object o = nodeIterator.next(); if (o instanceof CMElementDeclaration) { @@ -842,45 +857,48 @@ // only add proposals for the child element's that // begin with the matchstring String tagname = getRequiredName(parent, elementDecl); - boolean isStrictCMNodeSuggestion = strictCMNodeSuggestions != null ? strictCMNodeSuggestions.contains(elementDecl) : false; - - Image image = CMImageUtil.getImage(elementDecl); - + boolean isStrictCMNodeSuggestion = strictCMNodeSuggestions != null ? strictCMNodeSuggestions.contains(elementDecl) : false; + + Image image = CMImageUtil.getImage(elementDecl); + if (image == null) { - if (strictCMNodeSuggestions != null) { - image = isStrictCMNodeSuggestion ? - XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC_EMPHASIZED) : - XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC_DEEMPHASIZED); - } - else { - image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC); - } - + if (strictCMNodeSuggestions != null) { + image = isStrictCMNodeSuggestion ? XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC_EMPHASIZED) : XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC_DEEMPHASIZED); + } + else { + image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC); + } + } - //int markupAdjustment = getContentGenerator().getMinimalStartTagLength(parent, elementDecl); + // int markupAdjustment = + // getContentGenerator().getMinimalStartTagLength(parent, + // elementDecl); if (beginsWith(tagname, matchString)) { String proposedText = getRequiredText(parent, elementDecl); - + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89811 // place cursor in first empty quotes int markupAdjustment = getCursorPositionForProposedText(proposedText); - + String proposedInfo = getAdditionalInfo(parentDecl, elementDecl); - int relevance = isStrictCMNodeSuggestion ? XMLRelevanceConstants.R_STRICTLY_VALID_TAG_INSERTION : XMLRelevanceConstants.R_TAG_INSERTION; + int relevance = isStrictCMNodeSuggestion ? XMLRelevanceConstants.R_STRICTLY_VALID_TAG_INSERTION : XMLRelevanceConstants.R_TAG_INSERTION; CustomCompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), markupAdjustment, image, tagname, null, proposedInfo, relevance); contentAssistRequest.addProposal(proposal); } } } if (contentAssistRequest.getProposals().size() == 0) { - if (error != null) + if (error != null) { setErrorMessage(error); - else if (contentAssistRequest.getMatchString() != null && contentAssistRequest.getMatchString().length() > 0) + } + else if ((contentAssistRequest.getMatchString() != null) && (contentAssistRequest.getMatchString().length() > 0)) { setErrorMessage(NLS.bind(XMLUIMessages.No_known_child_tag, (new Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()}))); - //$NON-NLS-1$ = "No known child tag names of <{0}> begin with \"{1}\"." - else + //$NON-NLS-1$ = "No known child tag names of <{0}> begin with \"{1}\"." + } + else { setErrorMessage(NLS.bind(XMLUIMessages.__Has_no_known_child, (new Object[]{parent.getNodeName()}))); + } } } } @@ -894,10 +912,11 @@ for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) { - boolean xmlpi = (child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE && child.getNodeName().equals("xml")); //$NON-NLS-1$ + boolean xmlpi = ((child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) && child.getNodeName().equals("xml")); //$NON-NLS-1$ boolean doctype = child.getNodeType() == Node.DOCUMENT_TYPE_NODE; - if (xmlpi || doctype && minimumOffset < 0) + if (xmlpi || (doctype && (minimumOffset < 0))) { minimumOffset = ((IDOMNode) child).getFirstStructuredDocumentRegion().getStartOffset() + ((IDOMNode) child).getFirstStructuredDocumentRegion().getTextLength(); + } xmlpiFound = xmlpiFound || xmlpi; doctypeFound = doctypeFound || doctype; } @@ -932,15 +951,18 @@ String matchString = contentAssistRequest.getMatchString(); if (parent.getNodeType() == Node.ELEMENT_NODE) { // retrieve the list of children - //validActions = getAvailableChildrenAtIndex((Element) parent, childPosition); - cmnodes = getAvailableChildElementDeclarations((Element)parent, childPosition, ModelQueryAction.INSERT); + // validActions = getAvailableChildrenAtIndex((Element) parent, + // childPosition); + cmnodes = getAvailableChildElementDeclarations((Element) parent, childPosition, ModelQueryAction.INSERT); Iterator nodeIterator = cmnodes.iterator(); // chop off any leading <'s and whitespace from the matchstring - while ((matchString.length() > 0) && (Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString, "<"))) //$NON-NLS-1$ + while ((matchString.length() > 0) && (Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString, "<"))) { //$NON-NLS-1$ matchString = matchString.substring(1); - if (!nodeIterator.hasNext()) + } + if (!nodeIterator.hasNext()) { error = NLS.bind(XMLUIMessages.__Has_no_known_child, (new Object[]{parent.getNodeName()})); + } while (nodeIterator.hasNext()) { CMNode elementDecl = (CMNode) nodeIterator.next(); if (elementDecl != null) { @@ -951,7 +973,7 @@ // do a check to see if partial attributes of partial tag // names are in list - if ((node != null && node.getAttributes() != null && node.getAttributes().getLength() > 0 && attributeInList(node, parent, elementDecl)) || ((node.getNodeType() != Node.TEXT_NODE) && node.getFirstStructuredDocumentRegion().isEnded())) { + if (((node != null) && (node.getAttributes() != null) && (node.getAttributes().getLength() > 0) && attributeInList(node, parent, elementDecl)) || ((node.getNodeType() != Node.TEXT_NODE) && node.getFirstStructuredDocumentRegion().isEnded())) { proposedText = getRequiredName(parent, elementDecl); cursorAdjustment = proposedText.length(); @@ -969,13 +991,17 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89811 StringBuffer sb = new StringBuffer(); getContentGenerator().generateTag(parent, ed, sb); - // since it's a name proposal, assume '<' is already there + // since it's a name proposal, assume '<' is + // already there // only return the rest of the tag proposedText = sb.toString().substring(1); cursorAdjustment = getCursorPositionForProposedText(proposedText); - - //cursorAdjustment = proposedText.length() + 1; - //proposedText += "></" + getRequiredName(parent, elementDecl) + ">"; //$NON-NLS-2$//$NON-NLS-1$ + + // cursorAdjustment = proposedText.length() + + // 1; + // proposedText += "></" + + // getRequiredName(parent, elementDecl) + ">"; + // //$NON-NLS-2$//$NON-NLS-1$ } } } @@ -991,35 +1017,40 @@ } } if (contentAssistRequest.getProposals().size() == 0) { - if (error != null) + if (error != null) { setErrorMessage(error); - else if (contentAssistRequest.getMatchString() != null && contentAssistRequest.getMatchString().length() > 0) + } + else if ((contentAssistRequest.getMatchString() != null) && (contentAssistRequest.getMatchString().length() > 0)) { setErrorMessage(NLS.bind(XMLUIMessages.No_known_child_tag_names, (new Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()}))); - //$NON-NLS-1$ = "No known child tag names of <{0}> begin with \"{1}\"" - else + //$NON-NLS-1$ = "No known child tag names of <{0}> begin with \"{1}\"" + } + else { setErrorMessage(NLS.bind(XMLUIMessages.__Has_no_known_child, (new Object[]{parent.getNodeName()}))); + } } } else if (parent.getNodeType() == Node.DOCUMENT_NODE) { List childElements = getAvailableRootChildren((Document) parent, childPosition); for (int i = 0; i < childElements.size(); i++) { CMNode ed = (CMNode) childElements.get(i); - if (ed == null) + if (ed == null) { continue; + } String proposedText = null; int cursorAdjustment = 0; - if(ed instanceof CMElementDeclaration) { + if (ed instanceof CMElementDeclaration) { // proposedText = getRequiredName(parent, ed); StringBuffer sb = new StringBuffer(); - getContentGenerator().generateTag(parent, (CMElementDeclaration)ed, sb); + getContentGenerator().generateTag(parent, (CMElementDeclaration) ed, sb); // tag starts w/ '<', but we want to compare to name proposedText = sb.toString().substring(1); - - if (!beginsWith(proposedText, matchString)) + + if (!beginsWith(proposedText, matchString)) { continue; - + } + cursorAdjustment = getCursorPositionForProposedText(proposedText); - + if (ed instanceof CMElementDeclaration) { CMElementDeclaration elementDecl = (CMElementDeclaration) ed; if (elementDecl.getContentType() == CMElementDeclaration.EMPTY) { @@ -1027,7 +1058,7 @@ cursorAdjustment = proposedText.length(); } } - + String proposedInfo = getAdditionalInfo(null, ed); Image image = CMImageUtil.getImage(ed); if (image == null) { @@ -1039,20 +1070,26 @@ } } } + /** - * this is the position the cursor should be in after the proposal is applied + * this is the position the cursor should be in after the proposal is + * applied + * * @param proposedText - * @return the position the cursor should be in after the proposal is applied + * @return the position the cursor should be in after the proposal is + * applied */ private int getCursorPositionForProposedText(String proposedText) { int cursorAdjustment; cursorAdjustment = proposedText.indexOf("\"\"") + 1; //$NON-NLS-1$ // otherwise, after the first tag - if(cursorAdjustment==0) + if (cursorAdjustment == 0) { cursorAdjustment = proposedText.indexOf('>') + 1; - if(cursorAdjustment==0) + } + if (cursorAdjustment == 0) { cursorAdjustment = proposedText.length() + 1; - + } + return cursorAdjustment; } @@ -1080,8 +1117,9 @@ * possible attributes from 'cmnodes' list. */ protected boolean attributeInList(IDOMNode node, Node parent, CMNode cmnode) { - if (node == null || parent == null || cmnode == null) + if ((node == null) || (parent == null) || (cmnode == null)) { return false; + } String elementMatchString = node.getNodeName(); String cmnodeName = getRequiredName(parent, cmnode);// cmnode.getNodeName(); if (node instanceof Element) { @@ -1089,7 +1127,7 @@ String attrMatchString = ""; //$NON-NLS-1$ CMNamedNodeMap cmattrMap = null; // iterate attribute possibilities for partially started node - for (int i = 0; map != null && i < map.getLength(); i++) { + for (int i = 0; (map != null) && (i < map.getLength()); i++) { attrMatchString = map.item(i).getNodeName(); // filter on whatever user typed for element name already if (beginsWith(cmnodeName, elementMatchString)) { @@ -1097,7 +1135,7 @@ cmattrMap = ((CMElementDeclaration) cmnode).getAttributes(); // iterate possible attributes from a cmnode in // proposal list - for (int k = 0; cmattrMap != null && k < cmattrMap.getLength(); k++) { + for (int k = 0; (cmattrMap != null) && (k < cmattrMap.getLength()); k++) { // check if name matches if (cmattrMap.item(k).getNodeName().equals(attrMatchString)) { return true; @@ -1111,8 +1149,9 @@ } protected boolean beginsWith(String aString, String prefix) { - if (aString == null || prefix == null) + if ((aString == null) || (prefix == null)) { return true; + } // (pa) matching independent of case to be consistant with Java // editor CA return aString.toLowerCase().startsWith(prefix.toLowerCase()); @@ -1132,7 +1171,7 @@ addAttributeNameProposals(contentAssistRequest); contentAssistRequest.setReplacementBeginPosition(documentPosition); contentAssistRequest.setReplacementLength(0); - if (node.getFirstStructuredDocumentRegion() != null && (!node.getFirstStructuredDocumentRegion().isEnded())) { + if ((node.getFirstStructuredDocumentRegion() != null) && (!node.getFirstStructuredDocumentRegion().isEnded())) { addTagCloseProposals(contentAssistRequest); } return contentAssistRequest; @@ -1141,18 +1180,18 @@ protected ContentAssistRequest computeAttributeValueProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) { ContentAssistRequest contentAssistRequest = null; IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition); - if (documentPosition > sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength() && sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength() != sdRegion.getStartOffset(completionRegion) + completionRegion.getLength()) { + if ((documentPosition > sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength()) && (sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength() != sdRegion.getStartOffset(completionRegion) + completionRegion.getLength())) { // setup to add a new attribute at the documentPosition IDOMNode actualNode = (IDOMNode) node.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion)); contentAssistRequest = newContentAssistRequest(actualNode, actualNode, sdRegion, completionRegion, documentPosition, 0, matchString); addAttributeNameProposals(contentAssistRequest); - if (actualNode.getFirstStructuredDocumentRegion() != null && !actualNode.getFirstStructuredDocumentRegion().isEnded()) { + if ((actualNode.getFirstStructuredDocumentRegion() != null) && !actualNode.getFirstStructuredDocumentRegion().isEnded()) { addTagCloseProposals(contentAssistRequest); } } else { // setup to replace the existing value - if (!nodeAtOffset.getFirstStructuredDocumentRegion().isEnded() && documentPosition < sdRegion.getStartOffset(completionRegion)) { + if (!nodeAtOffset.getFirstStructuredDocumentRegion().isEnded() && (documentPosition < sdRegion.getStartOffset(completionRegion))) { // if the IStructuredDocumentRegion isn't closed and the // cursor is in front of the value, add contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString); @@ -1172,7 +1211,7 @@ IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition); // Handle the most common and best supported cases - if (xmlnode.getNodeType() == Node.ELEMENT_NODE || xmlnode.getNodeType() == Node.DOCUMENT_NODE) { + if ((xmlnode.getNodeType() == Node.ELEMENT_NODE) || (xmlnode.getNodeType() == Node.DOCUMENT_NODE)) { if (regionType == DOMRegionContext.XML_TAG_OPEN) { contentAssistRequest = computeTagOpenProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode); } @@ -1185,7 +1224,7 @@ else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) { contentAssistRequest = computeEqualsProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode); } - else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE && documentPosition == sdRegion.getTextEndOffset() && (sdRegion.getText(completionRegion).endsWith("\"") || sdRegion.getText(completionRegion).endsWith("\'"))) //$NON-NLS-1$ //$NON-NLS-2$ + else if ((regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) && (documentPosition == sdRegion.getTextEndOffset()) && (sdRegion.getText(completionRegion).endsWith("\"") || sdRegion.getText(completionRegion).endsWith("\'"))) //$NON-NLS-1$ //$NON-NLS-2$ { // this is for when the cursor is at the end of the closing // quote for an attribute.. @@ -1202,14 +1241,14 @@ else if (regionType == DOMRegionContext.XML_END_TAG_OPEN) { contentAssistRequest = computeEndTagOpenProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode); } - else if (regionType == DOMRegionContext.XML_CONTENT || regionType == DOMRegionContext.XML_CHAR_REFERENCE || regionType == DOMRegionContext.XML_ENTITY_REFERENCE || regionType == DOMRegionContext.XML_PE_REFERENCE) { + else if ((regionType == DOMRegionContext.XML_CONTENT) || (regionType == DOMRegionContext.XML_CHAR_REFERENCE) || (regionType == DOMRegionContext.XML_ENTITY_REFERENCE) || (regionType == DOMRegionContext.XML_PE_REFERENCE)) { contentAssistRequest = computeContentProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode); } // These ITextRegion types begin DOM Elements as well and although // internally harder to assist, // text insertions directly before them can be made - else if (documentPosition == sdRegion.getStartOffset(completionRegion) && (regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_COMMENT_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DECLARATION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_EXPRESSION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_SCRIPTLET_OPEN) || regionType == DOMRegionContext.XML_DECLARATION_OPEN || regionType == DOMRegionContext.XML_PI_OPEN || regionType == DOMRegionContext.XML_COMMENT_OPEN || regionType == DOMRegionContext.XML_CDATA_OPEN)) { + else if ((documentPosition == sdRegion.getStartOffset(completionRegion)) && (regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_COMMENT_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DECLARATION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_EXPRESSION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_SCRIPTLET_OPEN) || (regionType == DOMRegionContext.XML_DECLARATION_OPEN) || (regionType == DOMRegionContext.XML_PI_OPEN) || (regionType == DOMRegionContext.XML_COMMENT_OPEN) || (regionType == DOMRegionContext.XML_CDATA_OPEN))) { contentAssistRequest = newContentAssistRequest(treeNode, xmlnode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString); addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(treeNode)); addStartDocumentProposals(contentAssistRequest); @@ -1219,10 +1258,11 @@ else if (isCloseRegion(completionRegion)) { contentAssistRequest = newContentAssistRequest(treeNode, xmlnode.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion) + completionRegion.getLength(), 0, matchString); addStartDocumentProposals(contentAssistRequest); - if (documentPosition >= sdRegion.getTextEndOffset(completionRegion)) + if (documentPosition >= sdRegion.getTextEndOffset(completionRegion)) { addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(treeNode) + 1); + } } - else if (documentPosition == sdRegion.getStartOffset(completionRegion) && (regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_COMMENT_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DECLARATION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_EXPRESSION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_SCRIPTLET_OPEN) || regionType == DOMRegionContext.XML_DECLARATION_OPEN || regionType == DOMRegionContext.XML_PI_OPEN || regionType == DOMRegionContext.XML_COMMENT_OPEN || regionType == DOMRegionContext.XML_CDATA_OPEN)) { + else if ((documentPosition == sdRegion.getStartOffset(completionRegion)) && (regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_COMMENT_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DECLARATION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_EXPRESSION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_SCRIPTLET_OPEN) || (regionType == DOMRegionContext.XML_DECLARATION_OPEN) || (regionType == DOMRegionContext.XML_PI_OPEN) || (regionType == DOMRegionContext.XML_COMMENT_OPEN) || (regionType == DOMRegionContext.XML_CDATA_OPEN))) { contentAssistRequest = newContentAssistRequest(treeNode, xmlnode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString); addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(treeNode)); addStartDocumentProposals(contentAssistRequest); @@ -1252,8 +1292,9 @@ IndexedRegion treeNode = ContentAssistUtils.getNodeAt(textViewer, documentPosition); Node node = (Node) treeNode; - while (node != null && node.getNodeType() == Node.TEXT_NODE && node.getParentNode() != null) + while ((node != null) && (node.getNodeType() == Node.TEXT_NODE) && (node.getParentNode() != null)) { node = node.getParentNode(); + } IDOMNode xmlnode = (IDOMNode) node; ContentAssistRequest contentAssistRequest = null; @@ -1265,7 +1306,7 @@ // Handle empty Documents if (completionRegion == null) { - if (((treeNode == null) || ((Node) treeNode).getNodeType() == Node.DOCUMENT_NODE) && completionRegion == null && (xmlnode == null || xmlnode.getChildNodes() == null || xmlnode.getChildNodes().getLength() == 0)) { + if (((treeNode == null) || (((Node) treeNode).getNodeType() == Node.DOCUMENT_NODE)) && (completionRegion == null) && ((xmlnode == null) || (xmlnode.getChildNodes() == null) || (xmlnode.getChildNodes().getLength() == 0))) { IStructuredModel sModel = StructuredModelManager.getModelManager().getExistingModelForRead(textViewer.getDocument()); try { if (sModel != null) { @@ -1275,8 +1316,9 @@ } } finally { - if (sModel != null) + if (sModel != null) { sModel.releaseFromRead(); + } } if (contentAssistRequest == null) { Logger.logException(new IllegalStateException("problem getting model")); //$NON-NLS-1$ @@ -1293,7 +1335,7 @@ // catch documents where no region can be determined - if (xmlnode.getNodeType() == Node.DOCUMENT_NODE && (completionRegion == null || xmlnode.getChildNodes() == null || xmlnode.getChildNodes().getLength() == 0)) { + if ((xmlnode.getNodeType() == Node.DOCUMENT_NODE) && ((completionRegion == null) || (xmlnode.getChildNodes() == null) || (xmlnode.getChildNodes().getLength() == 0))) { contentAssistRequest = computeStartDocumentProposals(documentPosition, matchString, completionRegion, (IDOMNode) treeNode, xmlnode); return contentAssistRequest.getCompletionProposals(); } @@ -1302,13 +1344,15 @@ contentAssistRequest = computeCompletionProposals(documentPosition, matchString, completionRegion, (IDOMNode) treeNode, xmlnode); if (contentAssistRequest == null) { contentAssistRequest = newContentAssistRequest((Node) treeNode, node.getParentNode(), sdRegion, completionRegion, documentPosition, 0, ""); //$NON-NLS-1$ - if (Debug.displayWarnings) + if (Debug.displayWarnings) { System.out.println(UNKNOWN_CONTEXT + " " + completionRegion.getType() + "@" + documentPosition); //$NON-NLS-2$//$NON-NLS-1$ + } setErrorMessage(UNKNOWN_CONTEXT); } - if (contentAssistRequest.getProposals().size() == 0) + if (contentAssistRequest.getProposals().size() == 0) { setErrorMessage(UNKNOWN_CONTEXT); + } return contentAssistRequest.getCompletionProposals(); } @@ -1318,8 +1362,9 @@ // setup to add children at the content node's position contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, getStructuredDocumentRegion(documentPosition), completionRegion, documentPosition, 0, matchString); - if (node != null && node.getNodeType() == Node.DOCUMENT_NODE && ((Document) node).getDoctype() == null) + if ((node != null) && (node.getNodeType() == Node.DOCUMENT_NODE) && (((Document) node).getDoctype() == null)) { addStartDocumentProposals(contentAssistRequest); + } addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(nodeAtOffset)); if (node.getNodeType() != Node.DOCUMENT_NODE) { addEndTagProposals(contentAssistRequest); @@ -1341,8 +1386,9 @@ * <code>null</code> if no context could be found */ public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { - if (fAttributeInfoProvider == null) + if (fAttributeInfoProvider == null) { fAttributeInfoProvider = new AttributeContextInformationProvider((IStructuredDocument) viewer.getDocument(), (AttributeContextInformationPresenter) getContextInformationValidator()); + } return fAttributeInfoProvider.getAttributeInformation(documentOffset); } @@ -1354,7 +1400,7 @@ IStructuredDocumentRegion sdRegionAtCompletionOffset = node.getStructuredDocument().getRegionAtCharacterOffset(completionRegionStart + completionRegionLength); ITextRegion regionAtEndOfCompletion = sdRegionAtCompletionOffset.getRegionAtCharacterOffset(completionRegionStart + completionRegionLength); - if (documentPosition != completionRegionStart && regionAtEndOfCompletion != null && regionAtEndOfCompletion.getType() == DOMRegionContext.XML_TAG_NAME) { + if ((documentPosition != completionRegionStart) && (regionAtEndOfCompletion != null) && (regionAtEndOfCompletion.getType() == DOMRegionContext.XML_TAG_NAME)) { ITextRegion nameRegion = regionAtEndOfCompletion; contentAssistRequest = newContentAssistRequest(nodeAtOffset, nodeAtOffset.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(nameRegion), nameRegion.getTextLength(), matchString); } @@ -1387,16 +1433,16 @@ // only handle XML content for now Vector proposals = new Vector(); // ICompletionProposals IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition); - if (completionRegion != null && completionRegion.getType() == DOMRegionContext.XML_CONTENT) { + if ((completionRegion != null) && (completionRegion.getType() == DOMRegionContext.XML_CONTENT)) { int nodeOffset = documentPosition - sdRegion.getStartOffset(completionRegion); String regionText = sdRegion.getFullText(completionRegion); // if directly to the right of a &, region will be null, need to // move to // the previous region...there might be a better way to do this - if (regionText != null && regionText.trim().equals("") && documentPosition > 0) { //$NON-NLS-1$ + if ((regionText != null) && regionText.trim().equals("") && (documentPosition > 0)) { //$NON-NLS-1$ IStructuredDocumentRegion prev = treeNode.getStructuredDocument().getRegionAtCharacterOffset(documentPosition - 1); - if (prev != null && prev.getFullText().trim().equals("&")) { //$NON-NLS-1$ + if ((prev != null) && prev.getFullText().trim().equals("&")) { //$NON-NLS-1$ completionRegion = prev; regionText = prev.getFullText(); nodeOffset = 1; @@ -1404,7 +1450,7 @@ } // string must start w/ & - if (regionText != null && regionText.startsWith("&")) { //$NON-NLS-1$ + if ((regionText != null) && regionText.startsWith("&")) { //$NON-NLS-1$ String key = (nodeOffset > 0) ? regionText.substring(1, nodeOffset) : ""; //$NON-NLS-1$ // get entity proposals, passing in the appropriate start @@ -1431,7 +1477,7 @@ entities.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$ entities.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$ } - addEntityProposals(proposals, entities, key, nodeOffset, sdRegion, completionRegion); //$NON-NLS-1$ + addEntityProposals(proposals, entities, key, nodeOffset, sdRegion, completionRegion); } } } @@ -1442,7 +1488,7 @@ ContentAssistRequest contentAssistRequest = null; IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition); ITextRegion valueRegion = node.getStartStructuredDocumentRegion().getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) + completionRegion.getLength()); - if (valueRegion != null && valueRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE && sdRegion.getStartOffset(valueRegion) <= documentPosition) { + if ((valueRegion != null) && (valueRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) && (sdRegion.getStartOffset(valueRegion) <= documentPosition)) { // replace the adjacent attribute value contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, valueRegion, sdRegion.getStartOffset(valueRegion), valueRegion.getTextLength(), matchString); } @@ -1470,22 +1516,23 @@ if ((node.getNodeType() == Node.DOCUMENT_NODE) || (documentPosition >= sdRegion.getEndOffset())) { // this is a content request as the documentPosition is AFTER the // end of the closing region - if (node == nodeAtOffset && node.getParentNode() != null) + if ((node == nodeAtOffset) && (node.getParentNode() != null)) { node = (IDOMNode) node.getParentNode(); + } contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString); addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(nodeAtOffset)); - if (node.getNodeType() != Node.DOCUMENT_NODE && node.getEndStructuredDocumentRegion() == null) { + if ((node.getNodeType() != Node.DOCUMENT_NODE) && (node.getEndStructuredDocumentRegion() == null)) { addEndTagProposals(contentAssistRequest); } } else { // at the start of the tag's close or within it ITextRegion closeRegion = sdRegion.getLastRegion(); - boolean insideTag = !sdRegion.isEnded() || documentPosition <= sdRegion.getStartOffset(closeRegion); + boolean insideTag = !sdRegion.isEnded() || (documentPosition <= sdRegion.getStartOffset(closeRegion)); if (insideTag) { // this is a request for completions within a tag contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString); - if (node.getNodeType() != Node.DOCUMENT_NODE && node.getEndStructuredDocumentRegion() != null) { + if ((node.getNodeType() != Node.DOCUMENT_NODE) && (node.getEndStructuredDocumentRegion() != null)) { addTagCloseProposals(contentAssistRequest); } if (sdRegion == nodeAtOffset.getFirstStructuredDocumentRegion()) { @@ -1511,8 +1558,9 @@ if (documentPosition > sdRegion.getStartOffset(completionRegion) + completionRegion.getLength()) { // it's attributes contentAssistRequest = newContentAssistRequest(actualNode, actualNode, sdRegion, completionRegion, documentPosition - matchString.length(), matchString.length(), matchString); - if (node.getStructuredDocument().getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) - 1).getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) - 1).getType() == DOMRegionContext.XML_TAG_OPEN) + if (node.getStructuredDocument().getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) - 1).getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) - 1).getType() == DOMRegionContext.XML_TAG_OPEN) { addAttributeNameProposals(contentAssistRequest); + } addTagCloseProposals(contentAssistRequest); } else { @@ -1597,7 +1645,7 @@ // (pa) ITextRegion refactor // if (name != null && name.containsOffset(documentPosition)) // { - if (name != null && (sdRegion.getStartOffset(name) <= documentPosition && sdRegion.getEndOffset(name) >= documentPosition)) { + if ((name != null) && ((sdRegion.getStartOffset(name) <= documentPosition) && (sdRegion.getEndOffset(name) >= documentPosition))) { // replace the existing name contentAssistRequest = newContentAssistRequest(node, node.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(name), name.getTextLength(), matchString); } @@ -1633,8 +1681,9 @@ } addlInfo = getInfoProvider().getInfo(cmnode); - if (addlInfo == null && parentOrOwner != null) + if ((addlInfo == null) && (parentOrOwner != null)) { addlInfo = getInfoProvider().getInfo(parentOrOwner); + } return addlInfo; } @@ -1663,19 +1712,22 @@ if (docType != null) { rootName = docType.getNodeName(); } - if (rootName == null) + if (rootName == null) { return new ArrayList(0); + } for (Node child = document.getFirstChild(); child != null; child = child.getNextSibling()) { // make sure the "root" Element isn't already present // is it required to be an Element? - if (child.getNodeType() == Node.ELEMENT_NODE && stringsEqual(child.getNodeName(), rootName)) { + if ((child.getNodeType() == Node.ELEMENT_NODE) && stringsEqual(child.getNodeName(), rootName)) { // if the node is missing either the start or end tag, don't // count it as present - if (child instanceof IDOMNode && (((IDOMNode) child).getStartStructuredDocumentRegion() == null || ((IDOMNode) child).getEndStructuredDocumentRegion() == null)) + if ((child instanceof IDOMNode) && ((((IDOMNode) child).getStartStructuredDocumentRegion() == null) || (((IDOMNode) child).getEndStructuredDocumentRegion() == null))) { continue; - if (Debug.displayInfo) + } + if (Debug.displayInfo) { System.out.println(rootName + " already present!"); //$NON-NLS-1$ + } setErrorMessage(NLS.bind(XMLUIMessages.The_document_element__, (new Object[]{rootName}))); return new ArrayList(0); } @@ -1695,30 +1747,36 @@ // supply the given document name anyway, even if it // is an error list.add(new SimpleCMElementDeclaration(rootName)); - if (Debug.displayInfo || Debug.displayWarnings) + if (Debug.displayInfo || Debug.displayWarnings) { System.out.println("No definition found for " + rootName + " in " + docType.getPublicId() + "/" + docType.getSystemId()); //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ + } String location = "" + (docType.getPublicId() != null ? docType.getPublicId() + "/" : "") + (docType.getSystemId() != null ? docType.getSystemId() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ - if (location.length() > 0) + if (location.length() > 0) { setErrorMessage(NLS.bind(XMLUIMessages.No_definition_for_in, (new Object[]{rootName, location}))); - else + } + else { setErrorMessage(NLS.bind(XMLUIMessages.No_definition_for, (new Object[]{rootName}))); + } } } } else { - if (Debug.displayInfo || Debug.displayWarnings) + if (Debug.displayInfo || Debug.displayWarnings) { System.out.println("No content model found."); //$NON-NLS-1$ + } //$NON-NLS-1$ //$NON-NLS-1$ String location = "" + (docType.getPublicId() != null ? docType.getPublicId() + "/" : "") + (docType.getSystemId() != null ? docType.getSystemId() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ - if (location.length() > 0) + if (location.length() > 0) { setErrorMessage(NLS.bind(XMLUIMessages.No_content_model_for, (new Object[]{location}))); - else + } + else { setErrorMessage(XMLUIMessages.No_content_model_found_UI_); + } } } @@ -1729,8 +1787,9 @@ CMElementDeclaration result = null; if (node.getNodeType() == Node.ELEMENT_NODE) { ModelQuery modelQuery = ModelQueryUtil.getModelQuery(node.getOwnerDocument()); - if (modelQuery != null) + if (modelQuery != null) { result = modelQuery.getCMElementDeclaration((Element) node); + } } return result; } @@ -1748,8 +1807,9 @@ protected ITextRegion getCompletionRegion(int offset, IStructuredDocumentRegion sdRegion) { ITextRegion region = sdRegion.getRegionAtCharacterOffset(offset); - if (region == null) + if (region == null) { return null; + } if (sdRegion.getStartOffset(region) == offset) { // The offset is at the beginning of the region @@ -1776,8 +1836,9 @@ // region? // If so, use the next region ITextRegion nextRegion = sdRegion.getRegionAtCharacterOffset(sdRegion.getStartOffset(region) + region.getLength()); - if (nextRegion != null) + if (nextRegion != null) { region = nextRegion; + } } else { // Is the offset within the important text for this region? @@ -1786,10 +1847,11 @@ } // valid WHITE_SPACE region handler (#179924) - if (region != null && region.getType() == DOMRegionContext.WHITE_SPACE) { + if ((region != null) && (region.getType() == DOMRegionContext.WHITE_SPACE)) { ITextRegion previousRegion = sdRegion.getRegionAtCharacterOffset(sdRegion.getStartOffset(region) - 1); - if (previousRegion != null) + if (previousRegion != null) { region = previousRegion; + } } return region; @@ -1802,8 +1864,9 @@ * following an '=' sign. */ protected ITextRegion getCompletionRegion(int documentPosition, Node domnode) { - if (domnode == null) + if (domnode == null) { return null; + } ITextRegion region = null; int offset = documentPosition; @@ -1811,8 +1874,9 @@ IDOMNode node = (IDOMNode) domnode; if (node.getNodeType() == Node.DOCUMENT_NODE) { - if (node.getStructuredDocument().getLength() == 0) + if (node.getStructuredDocument().getLength() == 0) { return null; + } ITextRegion result = node.getStructuredDocument().getRegionAtCharacterOffset(offset).getRegionAtCharacterOffset(offset); while (result == null) { offset--; @@ -1827,10 +1891,12 @@ // Determine if the offset is within the start // IStructuredDocumentRegion, end IStructuredDocumentRegion, or // somewhere within the Node's XML content. - if ((startTag != null) && (startTag.getStartOffset() <= offset) && (offset < startTag.getStartOffset() + startTag.getLength())) + if ((startTag != null) && (startTag.getStartOffset() <= offset) && (offset < startTag.getStartOffset() + startTag.getLength())) { flatNode = startTag; - else if ((endTag != null) && (endTag.getStartOffset() <= offset) && (offset < endTag.getStartOffset() + endTag.getLength())) + } + else if ((endTag != null) && (endTag.getStartOffset() <= offset) && (offset < endTag.getStartOffset() + endTag.getLength())) { flatNode = endTag; + } if (flatNode != null) { // the offset is definitely within the start or end tag, continue @@ -1843,12 +1909,12 @@ flatNode = node.getStructuredDocument().getRegionAtCharacterOffset(offset); // (pa) ITextRegion refactor // if (flatNode.contains(documentPosition)) { - if (flatNode.getStartOffset() <= documentPosition && flatNode.getEndOffset() >= documentPosition) { + if ((flatNode.getStartOffset() <= documentPosition) && (flatNode.getEndOffset() >= documentPosition)) { // we're interesting in completing/extending the previous // IStructuredDocumentRegion if the current // IStructuredDocumentRegion isn't plain content or if it's // preceded by an orphan '<' - if ((offset == flatNode.getStartOffset()) && (flatNode.getPrevious() != null) && (flatNode.getRegionAtCharacterOffset(documentPosition) != null && flatNode.getRegionAtCharacterOffset(documentPosition).getType() != DOMRegionContext.XML_CONTENT || flatNode.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_TAG_OPEN || flatNode.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN)) { + if ((offset == flatNode.getStartOffset()) && (flatNode.getPrevious() != null) && (((flatNode.getRegionAtCharacterOffset(documentPosition) != null) && (flatNode.getRegionAtCharacterOffset(documentPosition).getType() != DOMRegionContext.XML_CONTENT)) || (flatNode.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_TAG_OPEN) || (flatNode.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN))) { // Is the region also the start of the node? If so, the // previous IStructuredDocumentRegion is // where to look for a useful region. @@ -1857,8 +1923,9 @@ else if (flatNode.getEndOffset() == documentPosition) { region = flatNode.getLastRegion(); } - else + else { region = flatNode.getFirstRegion(); + } } else { // catch end of document positions where the docPosition isn't @@ -1877,8 +1944,9 @@ * @see AbstractContentAssistProcessor#getContentGenerator() */ public XMLContentModelGenerator getContentGenerator() { - if (fGenerator == null) + if (fGenerator == null) { fGenerator = new XMLContentModelGenerator(); + } return fGenerator; } @@ -1902,27 +1970,32 @@ * processor is incapable of computing context information */ public IContextInformationValidator getContextInformationValidator() { - if (fContextInformationPresenter == null) + if (fContextInformationPresenter == null) { fContextInformationPresenter = new AttributeContextInformationPresenter(); + } return fContextInformationPresenter; } protected int getElementPosition(Node child) { Node parent = child.getParentNode(); - if (parent == null) + if (parent == null) { return 0; + } NodeList children = parent.getChildNodes(); - if (children == null) + if (children == null) { return 0; + } int count = 0; for (int i = 0; i < children.getLength(); i++) { - if (children.item(i) == child) + if (children.item(i) == child) { return count; - else + } + else { // if (children.item(i).getNodeType() == Node.ELEMENT_NODE) count++; + } } return 0; } @@ -1962,33 +2035,38 @@ } protected String getMatchString(IStructuredDocumentRegion parent, ITextRegion aRegion, int offset) { - if (aRegion == null || isCloseRegion(aRegion)) + if ((aRegion == null) || isCloseRegion(aRegion)) { return ""; //$NON-NLS-1$ + } String matchString = null; String regionType = aRegion.getType(); - if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS || regionType == DOMRegionContext.XML_TAG_OPEN || (offset > parent.getStartOffset(aRegion) + aRegion.getTextLength())) { + if ((regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) || (regionType == DOMRegionContext.XML_TAG_OPEN) || (offset > parent.getStartOffset(aRegion) + aRegion.getTextLength())) { matchString = ""; //$NON-NLS-1$ } else if (regionType == DOMRegionContext.XML_CONTENT) { matchString = ""; //$NON-NLS-1$ } else { - if (parent.getText(aRegion).length() > 0 && parent.getStartOffset(aRegion) < offset) + if ((parent.getText(aRegion).length() > 0) && (parent.getStartOffset(aRegion) < offset)) { matchString = parent.getText(aRegion).substring(0, offset - parent.getStartOffset(aRegion)); - else + } + else { matchString = ""; //$NON-NLS-1$ + } } return matchString; } protected ITextRegion getNameRegion(IStructuredDocumentRegion flatNode) { - if (flatNode == null) + if (flatNode == null) { return null; + } Iterator regionList = flatNode.getRegions().iterator(); while (regionList.hasNext()) { ITextRegion region = (ITextRegion) regionList.next(); - if (isNameRegion(region)) + if (isNameRegion(region)) { return region; + } } return null; } @@ -2010,8 +2088,9 @@ dataTypeValues = modelQuery.getPossibleDataTypeValues(element, ad); } else { - if (ad.getAttrType() != null) + if (ad.getAttrType() != null) { dataTypeValues = ad.getAttrType().getEnumeratedValues(); + } } if (dataTypeValues != null) { list = new ArrayList(dataTypeValues.length); @@ -2027,7 +2106,7 @@ } protected String getRequiredName(Node parentOrOwner, CMNode cmnode) { - if (cmnode == null || parentOrOwner == null) { + if ((cmnode == null) || (parentOrOwner == null)) { if (Debug.displayWarnings) { new IllegalArgumentException("Null declaration!").printStackTrace(); //$NON-NLS-1$ } @@ -2085,54 +2164,60 @@ return name; } - // returns a list of CMNodes that are available within this parent context - // Given the grammar shown below and a snippet of XML code (where the '|' indicated the cursor position) - // the list would return all of the element declarations that are potential child elements of Foo. - // - // grammar : Foo -> (A, B, C) - // snippet : <Foo><A>| - // result : {A, B, C} - // - // TODO cs... do we need to pass in the 'kindOfAction'? Seems to me we could assume it's always an insert. - protected List getAvailableChildElementDeclarations(Element parent, int childPosition, int kindOfAction) - { - List modelQueryActions = getAvailableChildrenAtIndex(parent, childPosition, ModelQuery.VALIDITY_NONE); + // returns a list of CMNodes that are available within this parent context + // Given the grammar shown below and a snippet of XML code (where the '|' + // indicated the cursor position) + // the list would return all of the element declarations that are + // potential child elements of Foo. + // + // grammar : Foo -> (A, B, C) + // snippet : <Foo><A>| + // result : {A, B, C} + // + // TODO cs... do we need to pass in the 'kindOfAction'? Seems to me we + // could assume it's always an insert. + protected List getAvailableChildElementDeclarations(Element parent, int childPosition, int kindOfAction) { + List modelQueryActions = getAvailableChildrenAtIndex(parent, childPosition, ModelQuery.VALIDITY_NONE); Iterator iterator = modelQueryActions.iterator(); List cmnodes = new Vector(); while (iterator.hasNext()) { ModelQueryAction action = (ModelQueryAction) iterator.next(); - if (childPosition < 0 || (action.getStartIndex() <= childPosition && childPosition <= action.getEndIndex()) && action.getKind() == kindOfAction) { + if ((childPosition < 0) || (((action.getStartIndex() <= childPosition) && (childPosition <= action.getEndIndex())) && (action.getKind() == kindOfAction))) { CMNode actionCMNode = action.getCMNode(); - if (actionCMNode != null && !cmnodes.contains(actionCMNode)) + if ((actionCMNode != null) && !cmnodes.contains(actionCMNode)) { cmnodes.add(actionCMNode); + } } } return cmnodes; } - // returns a list of CMNodes that can be validly inserted at this childPosition - // Given the grammar shown below and a snippet of XML code (where the '|' indicated the cursor position) - // the list would return only the element declarations can be inserted while maintaing validity of the content. - // - // grammar : Foo -> (A, B, C) - // snippet : <Foo><A>| - // result : {B} - // - protected List getValidChildElementDeclarations(Element parent, int childPosition, int kindOfAction) - { - List modelQueryActions = getAvailableChildrenAtIndex(parent, childPosition, ModelQuery.VALIDITY_STRICT); - Iterator iterator = modelQueryActions.iterator(); - List cmnodes = new Vector(); - while (iterator.hasNext()) { - ModelQueryAction action = (ModelQueryAction) iterator.next(); - if (childPosition < 0 || (action.getStartIndex() <= childPosition && childPosition <= action.getEndIndex()) && action.getKind() == kindOfAction) { - CMNode actionCMNode = action.getCMNode(); - if (actionCMNode != null && !cmnodes.contains(actionCMNode)) - cmnodes.add(actionCMNode); - } - } - return cmnodes; - } + // returns a list of CMNodes that can be validly inserted at this + // childPosition + // Given the grammar shown below and a snippet of XML code (where the '|' + // indicated the cursor position) + // the list would return only the element declarations can be inserted + // while maintaing validity of the content. + // + // grammar : Foo -> (A, B, C) + // snippet : <Foo><A>| + // result : {B} + // + protected List getValidChildElementDeclarations(Element parent, int childPosition, int kindOfAction) { + List modelQueryActions = getAvailableChildrenAtIndex(parent, childPosition, ModelQuery.VALIDITY_STRICT); + Iterator iterator = modelQueryActions.iterator(); + List cmnodes = new Vector(); + while (iterator.hasNext()) { + ModelQueryAction action = (ModelQueryAction) iterator.next(); + if ((childPosition < 0) || (((action.getStartIndex() <= childPosition) && (childPosition <= action.getEndIndex())) && (action.getKind() == kindOfAction))) { + CMNode actionCMNode = action.getCMNode(); + if ((actionCMNode != null) && !cmnodes.contains(actionCMNode)) { + cmnodes.add(actionCMNode); + } + } + } + return cmnodes; + } /** * Similar to the call in HTMLContentAssistProcessor. Pass in a node, it @@ -2142,8 +2227,9 @@ * */ protected boolean getXML(Node node) { - if (node == null) + if (node == null) { return false; + } Document doc = null; doc = (node.getNodeType() != Node.DOCUMENT_NODE) ? node.getOwnerDocument() : ((Document) node); @@ -2166,7 +2252,7 @@ * shows up as an ELEMENT */ private boolean isCommentNode(IDOMNode node) { - return (node != null && node instanceof IDOMElement && ((IDOMElement) node).isCommentTag()); + return ((node != null) && (node instanceof IDOMElement) && ((IDOMElement) node).isCommentTag()); } /** @@ -2181,8 +2267,9 @@ int xmldoctypeNodePosition = -1; boolean isAfterDoctype = true; - if (parent == null) + if (parent == null) { return true; // blank document case + } for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) { if (child instanceof IDOMNode) { @@ -2209,11 +2296,12 @@ int xmlpiNodePosition = -1; boolean isAfterXMLPI = false; - if (parent == null) + if (parent == null) { return true; // blank document case + } for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) { - boolean xmlpi = (child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE && child.getNodeName().equals("xml")); //$NON-NLS-1$ + boolean xmlpi = ((child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) && child.getNodeName().equals("xml")); //$NON-NLS-1$ xmlpiFound = xmlpiFound || xmlpi; if (xmlpiFound) { if (child instanceof IDOMNode) { @@ -2234,7 +2322,7 @@ protected boolean isQuote(String string) { String trimmed = string.trim(); if (trimmed.length() > 0) { - return trimmed.charAt(0) == '\'' || trimmed.charAt(0) == '"'; + return (trimmed.charAt(0) == '\'') || (trimmed.charAt(0) == '"'); } return false; } @@ -2248,7 +2336,7 @@ boolean result = false; if (sdRegion.getRegions().size() > 0) { ITextRegion r = sdRegion.getRegions().get(0); - result = r.getType() == DOMRegionContext.XML_TAG_OPEN && sdRegion.isEnded(); + result = (r.getType() == DOMRegionContext.XML_TAG_OPEN) && sdRegion.isEnded(); } return result; } @@ -2274,19 +2362,24 @@ try { if (sModel != null) { IDOMNode xmlNode = (IDOMNode) sModel.getIndexedRegion(startTag.getStart()); - if (!isStartTag(startTag)) + if (!isStartTag(startTag)) { result = false; - else if (isSelfClosed(startTag)) + } + else if (isSelfClosed(startTag)) { result = false; - else if (!xmlNode.isContainer()) + } + else if (!xmlNode.isContainer()) { result = false; - else + } + else { result = xmlNode.getEndStructuredDocumentRegion() == null; + } } } finally { - if (sModel != null) + if (sModel != null) { sModel.releaseFromRead(); + } } return result; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentModelGenerator.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentModelGenerator.java index e97ac6c..9843915 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentModelGenerator.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentModelGenerator.java
@@ -32,8 +32,9 @@ protected void generateAttributes(CMElementDeclaration elementDecl, StringBuffer buffer) { CMNamedNodeMap attributes = elementDecl.getAttributes(); - if (attributes == null) + if (attributes == null) { return; + } for (int i = 0; i < attributes.getLength(); i++) { generateAttribute((CMAttributeDeclaration) attributes.item(i), buffer); } @@ -51,8 +52,9 @@ protected abstract void generateStartTag(String tagName, Node parentNode, CMElementDeclaration elementDecl, StringBuffer buffer); public void generateTag(Node parent, CMElementDeclaration elementDecl, StringBuffer buffer) { - if (elementDecl == null || buffer == null) + if ((elementDecl == null) || (buffer == null)) { return; + } String tagName = getRequiredName(parent, elementDecl); @@ -75,11 +77,13 @@ protected boolean requiresAttributes(CMElementDeclaration ed) { CMNamedNodeMap attributes = ed.getAttributes(); - if (attributes == null) + if (attributes == null) { return false; + } for (int i = 0; i < attributes.getLength(); i++) { - if (((CMAttributeDeclaration) attributes.item(i)).getUsage() == CMAttributeDeclaration.REQUIRED) + if (((CMAttributeDeclaration) attributes.item(i)).getUsage() == CMAttributeDeclaration.REQUIRED) { return true; + } } return false; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformation.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformation.java index 1987b65..62aafc3 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformation.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformation.java
@@ -81,8 +81,9 @@ * @see org.eclipse.jface.text.contentassist.IContextInformation#getContextDisplayString() */ public String getContextDisplayString() { - if (fContextDisplayString != null) + if (fContextDisplayString != null) { return fContextDisplayString; + } return fInformationDisplayString; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationPresenter.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationPresenter.java index f9cfdd1..173f797 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationPresenter.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationPresenter.java
@@ -70,7 +70,7 @@ IStructuredDocumentRegion startRegion = fModelUtil.getXMLNode(fDocumentPosition).getStartStructuredDocumentRegion(); int start = startRegion.getStartOffset(); int end = startRegion.getEndOffset(); - result = documentPosition < end && documentPosition > start + 1; + result = (documentPosition < end) && (documentPosition > start + 1); } return result; } @@ -82,8 +82,9 @@ public boolean updatePresentation(int documentPosition, TextPresentation presentation) { presentation.clear(); - if (!(fInfo instanceof AttributeContextInformation)) + if (!(fInfo instanceof AttributeContextInformation)) { return false; + } // iterate existing attributes from current node IDOMNode xmlNode = fModelUtil.getXMLNode(documentPosition); @@ -112,8 +113,9 @@ StyleRange sr = null; for (int i = 0; i < sorted.length; i++) { sr = sorted[i]; - if (sr != null) + if (sr != null) { presentation.addStyleRange(sr); + } } return true; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java index 8634ec4..19683f3 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java
@@ -57,13 +57,15 @@ /** * @param sdRegion - + * */ private boolean canProposeInfo(IStructuredDocumentRegion sdRegion) { - if (sdRegion != null && isEndTag(sdRegion)) + if ((sdRegion != null) && isEndTag(sdRegion)) { return false; - else + } + else { return true; + } } public IContextInformation[] getAttributeInformation(int offset) { @@ -74,8 +76,9 @@ IContextInformation[] results = EMPTY_CONTEXT_INFO; IStructuredDocumentRegion sdRegion = fModelUtil.getDocument().getRegionAtCharacterOffset(offset); - if (!canProposeInfo(sdRegion)) + if (!canProposeInfo(sdRegion)) { return EMPTY_CONTEXT_INFO; + } IDOMNode node = fModelUtil.getXMLNode(offset); if (node != null) { @@ -83,10 +86,10 @@ case Node.ELEMENT_NODE : results = getInfoForElement(node); break; - // future... - // case Node.TEXT_NODE : - // results = getInfoForText(node); - // break; + // future... + // case Node.TEXT_NODE : + // results = getInfoForText(node); + // break; } } return results; @@ -95,21 +98,22 @@ /** * Returns a comparator that compares CMAttributeDeclaration names. * - the comparator + * the comparator */ private Comparator getCMAttributeComparator() { - if (fComparator == null) + if (fComparator == null) { fComparator = new Comparator() { public int compare(Object o1, Object o2) { return ((CMAttributeDeclaration) o1).getAttrName().compareTo(((CMAttributeDeclaration) o2).getAttrName()); } }; + } return fComparator; } /** * @param node - + * */ private IContextInformation[] getInfoForElement(IDOMNode node) { IContextInformation[] results = EMPTY_CONTEXT_INFO; @@ -140,26 +144,28 @@ } if (i < attributes.getLength() - 1) { attrInfo.append(" "); //$NON-NLS-1$ - if (i != 0 && i % numPerLine == 0) + if ((i != 0) && (i % numPerLine == 0)) { attrInfo.append("\n "); //$NON-NLS-1$ + } } attrPosMap.put(name, new Position(pos, length)); } - if (!attrInfo.toString().trim().equals("")) //$NON-NLS-1$ + if (!attrInfo.toString().trim().equals("")) { return new IContextInformation[]{new AttributeContextInformation(attrContextString, attrInfo.toString(), attrPosMap)}; + } } return results; } /** * @param node - + * */ - IContextInformation[] getInfoForText(IDOMNode node) { + IContextInformation[] getInfoForText(IDOMNode node) { Node parent = node.getParentNode(); String contextString = node.getNodeName(); StringBuffer info = new StringBuffer(" "); //$NON-NLS-1$ - if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) { + if ((parent != null) && (parent.getNodeType() == Node.ELEMENT_NODE)) { CMElementDeclaration decl = fModelUtil.getModelQuery().getCMElementDeclaration((Element) parent); CMContent content = decl.getContent(); if (content instanceof CMGroup) { @@ -171,35 +177,39 @@ contextString = cmNode.getNodeName(); if (contextString != null) { info.append("<" + cmNode.getNodeName() + ">"); //$NON-NLS-1$ //$NON-NLS-2$ - if (i < children.getLength() - 1) + if (i < children.getLength() - 1) { info.append(" "); //$NON-NLS-1$ + } } } } } - if (!info.toString().trim().equals("")) //$NON-NLS-1$ + if (!info.toString().trim().equals("")) { return new IContextInformation[]{new ContextInformation(contextString, info.toString())}; - else + } + else { return EMPTY_CONTEXT_INFO; + } } /** * Returns sorted array of CMAttributeDeclarations. * * @param attributes - + * */ private CMAttributeDeclaration[] getSortedAttributes(CMNamedNodeMap attributes) { List sorted = new ArrayList(); - for (int i = 0; i < attributes.getLength(); i++) + for (int i = 0; i < attributes.getLength(); i++) { sorted.add(attributes.item(i)); + } Collections.sort(sorted, getCMAttributeComparator()); return (CMAttributeDeclaration[]) sorted.toArray(new CMAttributeDeclaration[sorted.size()]); } /** * @param sdRegion - + * */ private boolean isEndTag(IStructuredDocumentRegion sdRegion) { ITextRegionList regions = sdRegion.getRegions();
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContentAssistRequest.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContentAssistRequest.java index 2ee1bd1..b347dd5 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContentAssistRequest.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContentAssistRequest.java
@@ -37,8 +37,8 @@ protected int replacementBeginPosition; protected int replacementLength; - // private Boolean separate = null; // (pa) not used - // private Boolean sort = null; // (pa) not used + // private Boolean separate = null; // (pa) not used + // private Boolean sort = null; // (pa) not used /** * XMLContentAssistRequest constructor comment. */ @@ -63,7 +63,7 @@ public ICompletionProposal[] getCompletionProposals() { ICompletionProposal results[] = null; - if (getProposals().size() > 0 || getMacros().size() > 0) { + if ((getProposals().size() > 0) || (getMacros().size() > 0)) { List allProposals = new ArrayList(); if (!shouldSeparate()) { allProposals.addAll(getProposals()); @@ -71,7 +71,8 @@ // proposal list allProposals.addAll(getMacros()); allProposals = sortProposals(allProposals); - } else { + } + else { allProposals.addAll(sortProposals(getProposals())); allProposals.addAll(sortProposals(getMacros())); } @@ -149,20 +150,23 @@ } public int getStartOffset() { - if (getDocumentRegion() != null && getRegion() != null) + if ((getDocumentRegion() != null) && (getRegion() != null)) { return ((ITextRegionCollection) getDocumentRegion()).getStartOffset(getRegion()); + } return -1; } public String getText() { - if (getDocumentRegion() != null && getRegion() != null) + if ((getDocumentRegion() != null) && (getRegion() != null)) { return ((ITextRegionCollection) getDocumentRegion()).getText(getRegion()); + } return ""; //$NON-NLS-1$ } public int getTextEndOffset() { - if (getDocumentRegion() != null && getRegion() != null) + if ((getDocumentRegion() != null) && (getRegion() != null)) { return ((ITextRegionCollection) getDocumentRegion()).getTextEndOffset(getRegion()); + } return -1; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NoRegionContentAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NoRegionContentAssistProcessor.java index bea012b..f7aa83c 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NoRegionContentAssistProcessor.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NoRegionContentAssistProcessor.java
@@ -101,8 +101,9 @@ ICompletionProposal[] results = EMPTY_PROPOSAL_SET; p = guessContentAssistProcessor(viewer, documentOffset); - if (p != null) + if (p != null) { results = p.computeCompletionProposals(viewer, documentOffset); + } return (results != null) ? results : EMPTY_PROPOSAL_SET; } @@ -207,7 +208,7 @@ } } // working w/ viewer & document partition - if (p == null && viewer.getDocument().getLength() > 0) { + if ((p == null) && (viewer.getDocument().getLength() > 0)) { String prevPartitionType = getPartitionType((StructuredTextViewer) viewer, documentOffset - 1); // System.out.println("previous partition type is > " + // prevPartitionType); @@ -238,7 +239,7 @@ } protected void releaseMap(HashMap map) { - if (map != null && !map.isEmpty()) { + if ((map != null) && !map.isEmpty()) { Iterator it = map.keySet().iterator(); Object key = null; while (it.hasNext()) {
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ProposalComparator.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ProposalComparator.java index 7dda160..72c3fa1 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ProposalComparator.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ProposalComparator.java
@@ -25,7 +25,7 @@ public int compare(Object o1, Object o2) { int relevance = 0; - if (o1 instanceof IRelevanceCompletionProposal && o2 instanceof IRelevanceCompletionProposal) { + if ((o1 instanceof IRelevanceCompletionProposal) && (o2 instanceof IRelevanceCompletionProposal)) { // sort based on relevance IRelevanceCompletionProposal cp1 = (IRelevanceCompletionProposal) o1; IRelevanceCompletionProposal cp2 = (IRelevanceCompletionProposal) o2; @@ -33,13 +33,14 @@ relevance = cp2.getRelevance() - cp1.getRelevance(); // if same relevance, secondary sort (lexigraphically) - if (relevance == 0 && o1 instanceof ICompletionProposal && o2 instanceof ICompletionProposal) { + if ((relevance == 0) && (o1 instanceof ICompletionProposal) && (o2 instanceof ICompletionProposal)) { String displayString1 = ((ICompletionProposal) o1).getDisplayString(); String displayString2 = ((ICompletionProposal) o2).getDisplayString(); - if (displayString1 != null && displayString2 != null) - //relevance = displayString1.compareTo(displayString2); + if ((displayString1 != null) && (displayString2 != null)) { + // relevance = displayString1.compareTo(displayString2); // // this didn't mix caps w/ lowercase relevance = com.ibm.icu.text.Collator.getInstance().compare(displayString1, displayString2); + } } } // otherwise if it's not ISEDRelevanceCompletionProposal, don't sort
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ReplaceNameTemplateContext.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ReplaceNameTemplateContext.java index 9eb98c4..c371494 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ReplaceNameTemplateContext.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ReplaceNameTemplateContext.java
@@ -90,7 +90,7 @@ public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException { TemplateBuffer buffer = super.evaluate(template); if (buffer != null) { - if (fInsertOffset > -1 && fInsertOffset > getStart()) { + if ((fInsertOffset > -1) && (fInsertOffset > getStart())) { String prefix = getDocument().get(getStart(), fInsertOffset - getStart()); if (!template.getName().startsWith(prefix)) { // generate a new buffer that actually contains the
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SimpleCMElementDeclaration.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SimpleCMElementDeclaration.java index 137d6a6..0abd0e9 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SimpleCMElementDeclaration.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SimpleCMElementDeclaration.java
@@ -129,7 +129,7 @@ * @return int * * Returns one of : - * + * */ public int getNodeType() { return 0; @@ -141,7 +141,7 @@ * @return java.lang.Object * * Returns the object property desciped by the propertyName - * + * */ public Object getProperty(String propertyName) { return null; @@ -162,7 +162,7 @@ * @return boolean * * Returns true if the CMNode supports a specified property - * + * */ public boolean supports(String propertyName) { return false;
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistProcessor.java index 32b40df..895875e 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistProcessor.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistProcessor.java
@@ -37,27 +37,27 @@ public XMLContentAssistProcessor() { super(); } - + protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) { addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.ATTRIBUTE); super.addAttributeNameProposals(contentAssistRequest); } - + protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) { addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.ATTRIBUTE_VALUE); super.addAttributeValueProposals(contentAssistRequest); } - + protected void addEmptyDocumentProposals(ContentAssistRequest contentAssistRequest) { addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.NEW); super.addEmptyDocumentProposals(contentAssistRequest); } - + protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int childPosition) { addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.TAG); super.addTagInsertionProposals(contentAssistRequest, childPosition); } - + /** * Adds templates to the list of proposals * @@ -67,7 +67,7 @@ private void addTemplates(ContentAssistRequest contentAssistRequest, String context) { addTemplates(contentAssistRequest, context, contentAssistRequest.getReplacementBeginPosition()); } - + /** * Adds templates to the list of proposals * @@ -76,9 +76,10 @@ * @param startOffset */ private void addTemplates(ContentAssistRequest contentAssistRequest, String context, int startOffset) { - if (contentAssistRequest == null) + if (contentAssistRequest == null) { return; - + } + // if already adding template proposals for a certain context type, do // not add again if (!fTemplateContexts.contains(context)) { @@ -89,24 +90,30 @@ getTemplateCompletionProcessor().setContextType(context); ICompletionProposal[] proposals = getTemplateCompletionProcessor().computeCompletionProposals(fTextViewer, startOffset); for (int i = 0; i < proposals.length; ++i) { - if (useProposalList) + if (useProposalList) { contentAssistRequest.addProposal(proposals[i]); - else + } + else { contentAssistRequest.addMacro(proposals[i]); + } } } } } - + protected ContentAssistRequest computeCompletionProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode treeNode, IDOMNode xmlnode) { ContentAssistRequest request = super.computeCompletionProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode); - // bug115927 use original document position for all/any region templates + // bug115927 use original document position for all/any region + // templates addTemplates(request, TemplateContextTypeIdsXML.ALL, documentPosition); return request; } - - /* (non-Javadoc) - * @see org.eclipse.wst.xml.ui.contentassist.AbstractContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int) + + /* + * (non-Javadoc) + * + * @see org.eclipse.wst.xml.ui.contentassist.AbstractContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, + * int) */ public ICompletionProposal[] computeCompletionProposals(ITextViewer textViewer, int documentPosition) { fTemplateContexts.clear(); @@ -114,8 +121,9 @@ } protected IPreferenceStore getPreferenceStore() { - if (fPreferenceStore == null) + if (fPreferenceStore == null) { fPreferenceStore = XMLUIPlugin.getDefault().getPreferenceStore(); + } return fPreferenceStore; } @@ -134,7 +142,7 @@ public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); - if (property.compareTo(XMLUIPreferenceNames.AUTO_PROPOSE) == 0 || property.compareTo(XMLUIPreferenceNames.AUTO_PROPOSE_CODE) == 0) { + if ((property.compareTo(XMLUIPreferenceNames.AUTO_PROPOSE) == 0) || (property.compareTo(XMLUIPreferenceNames.AUTO_PROPOSE_CODE) == 0)) { reinit(); } } @@ -145,7 +153,8 @@ if (doAuto) { key = XMLUIPreferenceNames.AUTO_PROPOSE_CODE; completionProposalAutoActivationCharacters = getPreferenceStore().getString(key).toCharArray(); - } else { + } + else { completionProposalAutoActivationCharacters = null; } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistUtilities.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistUtilities.java index 16118e6..3f51aa8 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistUtilities.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistUtilities.java
@@ -38,11 +38,12 @@ * @author pavery */ public class XMLContentAssistUtilities extends ContentAssistUtils { - - /** - * ISSUE: this is a bit of hidden JSP knowledge that was implemented this - * way for expedency. Should be evolved in future to depend on "nestedContext". - */ + + /** + * ISSUE: this is a bit of hidden JSP knowledge that was implemented this + * way for expedency. Should be evolved in future to depend on + * "nestedContext". + */ private class DOMJSPRegionContextsPrivateCopy { private static final String JSP_CLOSE = "JSP_CLOSE"; //$NON-NLS-1$ private static final String JSP_DECLARATION_OPEN = "JSP_DECLARATION_OPEN"; //$NON-NLS-1$ @@ -74,7 +75,7 @@ * @param parentTagName * the tag on which you are checkin for an ending tag * @param imagePath - * content assist image relative path + * content assist image relative path * @return ICompletionProposal */ public static ICompletionProposal computeJSPEndTagProposal(ITextViewer viewer, int documentPosition, IndexedRegion indexedNode, String parentTagName, String imagePath) { @@ -88,11 +89,13 @@ if (indexedNode instanceof IDOMNode) { xnode = ((IDOMNode) indexedNode); // it's ended already... - if (xnode.getEndStructuredDocumentRegion() != null) + if (xnode.getEndStructuredDocumentRegion() != null) { return null; + } IDOMNode openNode = null; - if (!xnode.getNodeName().equalsIgnoreCase(parentTagName)) + if (!xnode.getNodeName().equalsIgnoreCase(parentTagName)) { openNode = (IDOMNode) xnode.getParentNode(); + } if (openNode != null) { if (openNode instanceof IDOMElement) { isJSPTag = ((IDOMElement) openNode).isJSPTag(); @@ -108,19 +111,19 @@ // create appropriate close tag text String proposedText = "</" + tagName; //$NON-NLS-1$ String viewerText = viewer.getTextWidget().getText(); - if (viewerText.length() >= documentPosition && viewerText.length() >= 2 && documentPosition >= 2) { + if ((viewerText.length() >= documentPosition) && (viewerText.length() >= 2) && (documentPosition >= 2)) { String last2chars = viewerText.substring(documentPosition - 2, documentPosition); - if (last2chars.endsWith("</")) //$NON-NLS-1$ + if (last2chars.endsWith("</")) { proposedText = tagName; - else if (last2chars.endsWith("<")) //$NON-NLS-1$ + } + else if (last2chars.endsWith("<")) { proposedText = "/" + tagName; //$NON-NLS-1$ + } } // create proposal p = new CustomCompletionProposal(proposedText + ">", //$NON-NLS-1$ - documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), //$NON-NLS-1$ - NLS.bind(XMLUIMessages.End_with_, (new Object[]{proposedText})), - null, null, XMLRelevanceConstants.R_END_TAG); + documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), NLS.bind(XMLUIMessages.End_with_, (new Object[]{proposedText})), null, null, XMLRelevanceConstants.R_END_TAG); } else if (!hasEndTag && isJSPTag) { @@ -130,23 +133,23 @@ // TODO (pa) make it smarter to add "%>" or just ">" if % is // already there... - if (viewerText.length() >= documentPosition && viewerText.length() >= 2) { + if ((viewerText.length() >= documentPosition) && (viewerText.length() >= 2)) { String last2chars = viewerText.substring(documentPosition - 2, documentPosition); String lastchar = viewerText.substring(documentPosition - 1, documentPosition); if (lastchar.equals("%")) //$NON-NLS-1$ { - if (last2chars.endsWith("<%")) //$NON-NLS-1$ + if (last2chars.endsWith("<%")) { proposedText = "%"; //$NON-NLS-1$ - else + } + else { proposedText = ""; //$NON-NLS-1$ + } } } // create proposal p = new CustomCompletionProposal(proposedText + ">", //$NON-NLS-1$ - documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), //$NON-NLS-1$ - NLS.bind(XMLUIMessages.End_with_, (new Object[]{proposedText})), - null, null, XMLRelevanceConstants.R_END_TAG); + documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), NLS.bind(XMLUIMessages.End_with_, (new Object[]{proposedText})), null, null, XMLRelevanceConstants.R_END_TAG); } return p; @@ -181,11 +184,13 @@ if (indexedNode instanceof IDOMNode) { xnode = ((IDOMNode) indexedNode); // it's ended already... - if (xnode.getEndStructuredDocumentRegion() != null) + if (xnode.getEndStructuredDocumentRegion() != null) { return null; + } IDOMNode styleNode = null; - if (!xnode.getNodeName().equalsIgnoreCase(parentTagName)) + if (!xnode.getNodeName().equalsIgnoreCase(parentTagName)) { styleNode = (IDOMNode) xnode.getParentNode(); + } if (styleNode != null) { tagName = styleNode.getNodeName(); hasEndTag = (styleNode.getEndStructuredDocumentRegion() != null); @@ -198,19 +203,19 @@ // create appropriate close tag text String proposedText = "</" + tagName; //$NON-NLS-1$ String viewerText = viewer.getTextWidget().getText(); - if (viewerText.length() >= documentPosition && viewerText.length() >= 2 && documentPosition >= 2) { + if ((viewerText.length() >= documentPosition) && (viewerText.length() >= 2) && (documentPosition >= 2)) { String last2chars = viewerText.substring(documentPosition - 2, documentPosition); - if (last2chars.endsWith("</")) //$NON-NLS-1$ + if (last2chars.endsWith("</")) { proposedText = tagName; - else if (last2chars.endsWith("<")) //$NON-NLS-1$ + } + else if (last2chars.endsWith("<")) { proposedText = "/" + tagName; //$NON-NLS-1$ + } } // create proposal p = new CustomCompletionProposal(proposedText + ">", //$NON-NLS-1$ - documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), //$NON-NLS-1$ - NLS.bind(XMLUIMessages.End_with_, (new Object[]{proposedText})), - null, null, XMLRelevanceConstants.R_END_TAG); + documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), NLS.bind(XMLUIMessages.End_with_, (new Object[]{proposedText})), null, null, XMLRelevanceConstants.R_END_TAG); } return p; } @@ -232,12 +237,15 @@ // ---------------------------------------------------------------------- for (child = doc.getFirstChild(); child != null; child = child.getNextSibling()) { - if (child.getNodeType() != Node.ELEMENT_NODE) + if (child.getNodeType() != Node.ELEMENT_NODE) { continue; - if (child.getNodeName().equalsIgnoreCase(META)) + } + if (child.getNodeName().equalsIgnoreCase(META)) { metas.add(child); - else if (child.getNodeName().equalsIgnoreCase(HTML)) + } + else if (child.getNodeName().equalsIgnoreCase(HTML)) { html = child; + } } // NodeList children = doc.getChildNodes(); // for(int i = 0; i < children.getLength(); i++) { @@ -252,11 +260,13 @@ // check for META tags under HEAD if (html != null) { - for (child = html.getFirstChild(); child != null && head == null; child = child.getNextSibling()) { - if (child.getNodeType() != Node.ELEMENT_NODE) + for (child = html.getFirstChild(); (child != null) && (head == null); child = child.getNextSibling()) { + if (child.getNodeType() != Node.ELEMENT_NODE) { continue; - if (child.getNodeName().equalsIgnoreCase(HEAD)) + } + if (child.getNodeName().equalsIgnoreCase(HEAD)) { head = child; + } } // children = html.getChildNodes(); // for(int i = 0; i < children.getLength() && head == null; i++) { @@ -270,10 +280,12 @@ if (head != null) { for (head.getFirstChild(); child != null; child = child.getNextSibling()) { - if (child.getNodeType() != Node.ELEMENT_NODE) + if (child.getNodeType() != Node.ELEMENT_NODE) { continue; - if (child.getNodeName().equalsIgnoreCase(META)) + } + if (child.getNodeName().equalsIgnoreCase(META)) { metas.add(child); + } } // children = head.getChildNodes(); // for(int i = 0 ; i < children.getLength(); i++) { @@ -307,8 +319,9 @@ contentScriptType = attributes.item(j).getNodeValue(); } } - if (httpEquiv && contentScriptType != null) + if (httpEquiv && (contentScriptType != null)) { return contentScriptType; + } } return null; } @@ -325,8 +338,9 @@ boolean specified = false; // try to find a scripting adapter for 'type' - if ((scriptNode == null) || (scriptNode.getAttributes() == null)) + if ((scriptNode == null) || (scriptNode.getAttributes() == null)) { return null; + } attr = scriptNode.getAttributes().getNamedItem("type");//$NON-NLS-1$ if (attr != null) { @@ -345,15 +359,17 @@ // check if one is specified by a META tag at the root level or inside // of HEAD String type = null; - if (!specified) + if (!specified) { type = getMetaScriptType(scriptNode.getOwnerDocument()); + } if (type != null) { specified = true; return lookupScriptType(type); } // return default - if (!specified) + if (!specified) { return ScriptLanguageKeys.JAVASCRIPT; + } return null; } @@ -365,8 +381,9 @@ * "nestedContext". */ public static boolean isJSPCloseDelimiter(IStructuredDocumentRegion fn) { - if (fn == null) + if (fn == null) { return false; + } return isJSPCloseDelimiter(fn.getType()); } @@ -376,8 +393,9 @@ * "nestedContext". */ public static boolean isJSPCloseDelimiter(String type) { - if (type == null) + if (type == null) { return false; + } return (type.equals(DOMJSPRegionContextsPrivateCopy.JSP_CLOSE) || type.equals(DOMRegionContext.XML_TAG_CLOSE)); } @@ -403,8 +421,9 @@ * "nestedContext". */ public static boolean isJSPDelimiter(String type) { - if (type == null) + if (type == null) { return false; + } return (isJSPOpenDelimiter(type) || isJSPCloseDelimiter(type)); } @@ -414,19 +433,21 @@ * Should be evolved in future to depend on "nestedContext". */ public static boolean isJSPOpenDelimiter(IStructuredDocumentRegion fn) { - if (fn == null) + if (fn == null) { return false; + } return isJSPOpenDelimiter(fn.getType()); } - /** + /** * ISSUE: this is a bit of hidden JSP knowledge that was implemented this * way for expedency. Should be evolved in future to depend on * "nestedContext". */ public static boolean isJSPOpenDelimiter(String type) { - if (type == null) + if (type == null) { return false; + } return (type.equals(DOMJSPRegionContextsPrivateCopy.JSP_SCRIPTLET_OPEN) || type.equals(DOMJSPRegionContextsPrivateCopy.JSP_DECLARATION_OPEN) || type.equals(DOMJSPRegionContextsPrivateCopy.JSP_EXPRESSION_OPEN)); } @@ -440,7 +461,7 @@ */ public static boolean isXMLJSPDelimiter(IStructuredDocumentRegion fn) { boolean isDelimiter = false; - if (fn != null && fn instanceof ITextRegionContainer) { + if ((fn != null) && (fn instanceof ITextRegionContainer)) { Object[] regions = ((ITextRegionContainer) fn).getRegions().toArray(); ITextRegion temp = null; String regionText = ""; //$NON-NLS-1$ @@ -448,8 +469,9 @@ temp = (ITextRegion) regions[i]; if (temp.getType() == DOMRegionContext.XML_TAG_NAME) { regionText = fn.getText(temp); - if (regionText.equalsIgnoreCase("jsp:scriptlet") || regionText.equalsIgnoreCase("jsp:expression") || regionText.equalsIgnoreCase("jsp:declaration")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + if (regionText.equalsIgnoreCase("jsp:scriptlet") || regionText.equalsIgnoreCase("jsp:expression") || regionText.equalsIgnoreCase("jsp:declaration")) { isDelimiter = true; + } } } } @@ -465,12 +487,14 @@ */ public static String lookupScriptLanguage(String language) { for (int i = 0; i < ScriptLanguageKeys.JAVASCRIPT_LANGUAGE_KEYS.length; i++) { - if (ScriptLanguageKeys.JAVASCRIPT_LANGUAGE_KEYS[i].equalsIgnoreCase(language)) + if (ScriptLanguageKeys.JAVASCRIPT_LANGUAGE_KEYS[i].equalsIgnoreCase(language)) { return ScriptLanguageKeys.JAVASCRIPT; + } } for (int i = 0; i < ScriptLanguageKeys.JAVA_LANGUAGE_KEYS.length; i++) { - if (ScriptLanguageKeys.JAVA_LANGUAGE_KEYS[i].equalsIgnoreCase(language)) + if (ScriptLanguageKeys.JAVA_LANGUAGE_KEYS[i].equalsIgnoreCase(language)) { return ScriptLanguageKeys.JAVA; + } } return language; } @@ -482,9 +506,11 @@ * @param type */ public static String lookupScriptType(String type) { - for (int i = 0; i < ScriptLanguageKeys.JAVASCRIPT_MIME_TYPE_KEYS.length; i++) - if (ScriptLanguageKeys.JAVASCRIPT_MIME_TYPE_KEYS[i].equalsIgnoreCase(type)) + for (int i = 0; i < ScriptLanguageKeys.JAVASCRIPT_MIME_TYPE_KEYS.length; i++) { + if (ScriptLanguageKeys.JAVASCRIPT_MIME_TYPE_KEYS[i].equalsIgnoreCase(type)) { return ScriptLanguageKeys.JAVASCRIPT; + } + } return type; } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentModelGenerator.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentModelGenerator.java index c3c87f3..6d01a9b 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentModelGenerator.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentModelGenerator.java
@@ -41,8 +41,9 @@ } public void generateAttribute(CMAttributeDeclaration attrDecl, StringBuffer buffer) { - if (attrDecl == null || buffer == null) + if ((attrDecl == null) || (buffer == null)) { return; + } int usage = attrDecl.getUsage(); if (usage == CMAttributeDeclaration.REQUIRED) { buffer.append(" "); //$NON-NLS-1$ @@ -54,16 +55,19 @@ } protected void generateEndTag(String tagName, Node parentNode, CMElementDeclaration elementDecl, StringBuffer buffer) { - if (elementDecl == null) + if (elementDecl == null) { return; - if (elementDecl.getContentType() != CMElementDeclaration.EMPTY) + } + if (elementDecl.getContentType() != CMElementDeclaration.EMPTY) { buffer.append("</" + tagName + ">");//$NON-NLS-2$//$NON-NLS-1$ + } return; } public void generateRequiredAttribute(Node ownerNode, CMAttributeDeclaration attrDecl, StringBuffer buffer) { - if (attrDecl == null || buffer == null) + if ((attrDecl == null) || (buffer == null)) { return; + } // attribute name String attributeName = getRequiredName(ownerNode, attrDecl); @@ -73,12 +77,12 @@ // attribute value if (attrType != null) { // insert any value that is implied - if (attrType.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE && attrType.getImpliedValue() != null) { + if ((attrType.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE) && (attrType.getImpliedValue() != null)) { buffer.append(attrType.getImpliedValue()); } // otherwise, if an enumerated list of values exists, use the // first value - else if (attrType.getEnumeratedValues() != null && attrType.getEnumeratedValues().length > 0) { + else if ((attrType.getEnumeratedValues() != null) && (attrType.getEnumeratedValues().length > 0)) { buffer.append(attrType.getEnumeratedValues()[0]); } } @@ -87,8 +91,9 @@ } protected void generateStartTag(String tagName, Node parentNode, CMElementDeclaration elementDecl, StringBuffer buffer) { - if (elementDecl == null || buffer == null) + if ((elementDecl == null) || (buffer == null)) { return; + } buffer.append("<" + tagName);//$NON-NLS-1$ generateAttributes(elementDecl, buffer); buffer.append(getStartTagClose(parentNode, elementDecl)); @@ -96,8 +101,9 @@ } public int getMinimalStartTagLength(Node node, CMElementDeclaration elementDecl) { - if (elementDecl == null) + if (elementDecl == null) { return 0; + } if (requiresAttributes(elementDecl)) { return getRequiredName(node, elementDecl).length() + 2; // < + // name + @@ -115,7 +121,7 @@ protected String getOtherClose(Node notATagNode) { if (notATagNode instanceof IDOMNode) { IStructuredDocumentRegion node = ((IDOMNode) notATagNode).getStartStructuredDocumentRegion(); - if (node != null && node.getNumberOfRegions() > 1 && node.getRegions().get(0).getType().equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_OPEN)) { + if ((node != null) && (node.getNumberOfRegions() > 1) && node.getRegions().get(0).getType().equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_OPEN)) { return "%>"; //$NON-NLS-1$ } } @@ -124,12 +130,15 @@ public String getStartTagClose(Node parentNode, CMElementDeclaration elementDecl) { String other = getOtherClose(parentNode); - if (other != null) + if (other != null) { return other; - if (elementDecl == null) + } + if (elementDecl == null) { return ">";//$NON-NLS-1$ - if (elementDecl.getContentType() == CMElementDeclaration.EMPTY) + } + if (elementDecl.getContentType() == CMElementDeclaration.EMPTY) { return "/>"; //$NON-NLS-1$ + } return ">"; //$NON-NLS-1$ } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLRelevanceConstants.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLRelevanceConstants.java index 1ac3554..5e41958 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLRelevanceConstants.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLRelevanceConstants.java
@@ -44,7 +44,7 @@ // CMVC 246618 int R_REQUIRED = 10; int R_TAG_INSERTION = 500; - int R_STRICTLY_VALID_TAG_INSERTION = 600; + int R_STRICTLY_VALID_TAG_INSERTION = 600; int R_TAG_NAME = 1200; int R_XML_ATTRIBUTE_NAME = 900; int R_XML_ATTRIBUTE_VALUE = 800;
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplateCompletionProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplateCompletionProcessor.java index b102d82..76c515d 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplateCompletionProcessor.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplateCompletionProcessor.java
@@ -63,14 +63,16 @@ ITextSelection selection = (ITextSelection) viewer.getSelectionProvider().getSelection(); // adjust offset to end of normalized selection - if (selection.getOffset() == offset) + if (selection.getOffset() == offset) { offset = selection.getOffset() + selection.getLength(); + } String prefix = extractPrefix(viewer, offset); Region region = new Region(offset - prefix.length(), prefix.length()); TemplateContext context = createContext(viewer, region, offset); - if (context == null) + if (context == null) { return new ICompletionProposal[0]; + } // name of the selection variables {line, word}_selection context.setVariable("selection", selection.getText()); //$NON-NLS-1$ @@ -86,8 +88,9 @@ catch (TemplateException e) { continue; } - if (template.matches(prefix, context.getContextType().getId())) + if (template.matches(prefix, context.getContextType().getId())) { matches.add(createProposal(template, context, (IRegion) region, getRelevance(template, prefix))); + } } Collections.sort(matches, fgProposalComparator); @@ -132,8 +135,9 @@ TemplateContextType type = null; ContextTypeRegistry registry = getTemplateContextRegistry(); - if (registry != null) + if (registry != null) { type = registry.getContextType(fContextTypeId); + } return type; } @@ -151,8 +155,9 @@ Template templates[] = null; TemplateStore store = getTemplateStore(); - if (store != null) + if (store != null) { templates = store.getTemplates(contextTypeId); + } return templates; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java index 02e4c46..fe84450 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java
@@ -42,7 +42,7 @@ private static boolean getDebugValue() { String value = Platform.getDebugOption("org.eclipse.wst.sse.ui/debug/outline"); //$NON-NLS-1$ - boolean result = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ + boolean result = (value != null) && value.equalsIgnoreCase("true"); //$NON-NLS-1$ return result; } @@ -119,8 +119,9 @@ ArrayList v = new ArrayList(); for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { Node n = child; - if (n.getNodeType() != Node.TEXT_NODE) + if (n.getNodeType() != Node.TEXT_NODE) { v.add(n); + } } return v.toArray(); } @@ -138,14 +139,15 @@ */ public Image getLabelImage(Object node) { Image image = CMImageUtil.getImage(CMImageUtil.getDeclaration((Node) node)); - if (image == null && JFaceResources.getImageRegistry() != null) { + if ((image == null) && (JFaceResources.getImageRegistry() != null)) { ImageRegistry imageRegistry = JFaceResources.getImageRegistry(); String nodeName = getNodeName(node); image = imageRegistry.get(nodeName); if (image == null) { image = createImage(node); - if (image != null) + if (image != null) { imageRegistry.put(nodeName, image); + } } } return image; @@ -176,8 +178,9 @@ } private synchronized RefreshStructureJob getRefreshJob() { - if (fRefreshJob == null) + if (fRefreshJob == null) { fRefreshJob = new RefreshStructureJob(); + } return fRefreshJob; } @@ -188,8 +191,9 @@ // nodeList(item) for O(n) vs. O(n*n) Node node = (Node) object; for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { - if (child.getNodeType() != Node.TEXT_NODE) + if (child.getNodeType() != Node.TEXT_NODE) { return true; + } } return false; } @@ -228,7 +232,7 @@ // StructuredViewer) && (eventType == // INodeNotifier.STRUCTURE_CHANGED || (eventType == // INodeNotifier.CHANGE && changedFeature == null))) { - if ((listener instanceof StructuredViewer) && (eventType == INodeNotifier.STRUCTURE_CHANGED || eventType == INodeNotifier.CONTENT_CHANGED || (eventType == INodeNotifier.CHANGE))) { + if ((listener instanceof StructuredViewer) && ((eventType == INodeNotifier.STRUCTURE_CHANGED) || (eventType == INodeNotifier.CONTENT_CHANGED) || (eventType == INodeNotifier.CHANGE))) { if (DEBUG) { System.out.println("JFaceNodeAdapter notified on event type > " + eventType); //$NON-NLS-1$ }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java index 8ee8b42..da090e3 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java
@@ -53,7 +53,7 @@ } public void cacheUpdated(CMDocumentCache cache, final String uri, int oldStatus, int newStatus, CMDocument cmDocument) { - if (newStatus == CMDocumentCache.STATUS_LOADED || newStatus == CMDocumentCache.STATUS_ERROR) { + if ((newStatus == CMDocumentCache.STATUS_LOADED) || (newStatus == CMDocumentCache.STATUS_ERROR)) { refreshViewers(); } } @@ -72,7 +72,7 @@ Job refresh = new UIJob(XMLUIMessages.refreshoutline_0) { public IStatus runInUIThread(IProgressMonitor monitor) { Control refreshControl = viewer.getControl(); - if (refreshControl != null && !refreshControl.isDisposed()) { + if ((refreshControl != null) && !refreshControl.isDisposed()) { viewer.refresh(true); } return Status.OK_STATUS; @@ -87,7 +87,7 @@ Job refresh = new UIJob(XMLUIMessages.refreshoutline_0) { public IStatus runInUIThread(IProgressMonitor monitor) { Control refreshControl = viewer.getControl(); - if (refreshControl != null && !refreshControl.isDisposed()) { + if ((refreshControl != null) && !refreshControl.isDisposed()) { viewer.refresh(); } return Status.OK_STATUS; @@ -151,7 +151,7 @@ ModelQueryAdapter mqadapter = (ModelQueryAdapter) node.getAdapterFor(ModelQueryAdapter.class); if (mqadapter != null) { ModelQuery mquery = mqadapter.getModelQuery(); - if (mquery != null && mquery.getCMDocumentManager() != null) { + if ((mquery != null) && (mquery.getCMDocumentManager() != null)) { cmDocumentManager = mquery.getCMDocumentManager(); fCMDocumentManagerListener = new CMDocumentManagerListenerImpl(); cmDocumentManager.addListener(fCMDocumentManagerListener); @@ -161,7 +161,7 @@ public void release() { // deregister from CMDocumentManager events - if (cmDocumentManager != null && fCMDocumentManagerListener != null) { + if ((cmDocumentManager != null) && (fCMDocumentManagerListener != null)) { cmDocumentManager.removeListener(fCMDocumentManagerListener); } fListeners.clear();
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java index 7327b15..7c8ea98 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java
@@ -49,8 +49,9 @@ protected IJFaceNodeAdapter getAdapter(Object adaptable) { if (adaptable instanceof INodeNotifier) { INodeAdapter adapter = ((INodeNotifier) adaptable).getAdapterFor(IJFaceNodeAdapter.class); - if (adapter instanceof IJFaceNodeAdapter) + if (adapter instanceof IJFaceNodeAdapter) { return (IJFaceNodeAdapter) adapter; + } } return null; } @@ -58,8 +59,9 @@ public Object[] getChildren(Object object) { IJFaceNodeAdapter adapter = getAdapter(object); - if (adapter != null) + if (adapter != null) { return adapter.getChildren(object); + } return new Object[0]; } @@ -68,13 +70,15 @@ // The root is usually an instance of an XMLStructuredModel in // which case we want to extract the document. Object topNode = object; - if (object instanceof IDOMModel) + if (object instanceof IDOMModel) { topNode = ((IDOMModel) object).getDocument(); + } IJFaceNodeAdapter adapter = getAdapter(topNode); - if (adapter != null) + if (adapter != null) { return adapter.getElements(topNode); + } return new Object[0]; } @@ -82,8 +86,9 @@ public Object getParent(Object object) { IJFaceNodeAdapter adapter = getAdapter(object); - if (adapter != null) + if (adapter != null) { return adapter.getParent(object); + } return null; } @@ -91,20 +96,21 @@ public boolean hasChildren(Object object) { IJFaceNodeAdapter adapter = getAdapter(object); - if (adapter != null) + if (adapter != null) { return adapter.hasChildren(object); + } return false; } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - if (oldInput != null && oldInput instanceof IStructuredModel) { + if ((oldInput != null) && (oldInput instanceof IStructuredModel)) { IJFaceNodeAdapterFactory factory = (IJFaceNodeAdapterFactory) ((IStructuredModel) oldInput).getFactoryRegistry().getFactoryFor(IJFaceNodeAdapter.class); if (factory != null) { factory.removeListener(viewer); } } - if (newInput != null && newInput instanceof IStructuredModel) { + if ((newInput != null) && (newInput instanceof IStructuredModel)) { IJFaceNodeAdapterFactory factory = (IJFaceNodeAdapterFactory) ((IStructuredModel) newInput).getFactoryRegistry().getFactoryFor(IJFaceNodeAdapter.class); if (factory != null) { factory.addListener(viewer);
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java index 7472df9..f5d6f6a 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java
@@ -38,8 +38,9 @@ protected IJFaceNodeAdapter getAdapter(Object adaptable) { if (adaptable instanceof INodeNotifier) { INodeAdapter adapter = ((INodeNotifier) adaptable).getAdapterFor(IJFaceNodeAdapter.class); - if (adapter instanceof IJFaceNodeAdapter) + if (adapter instanceof IJFaceNodeAdapter) { return (IJFaceNodeAdapter) adapter; + } } return null; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshStructureJob.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshStructureJob.java index 1f6309e..6960dbd 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshStructureJob.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshStructureJob.java
@@ -45,7 +45,7 @@ private static final long UPDATE_DELAY = 250; static { String value = Platform.getDebugOption("org.eclipse.wst.sse.ui/debug/refreshStructure"); //$NON-NLS-1$ - DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ + DEBUG = (value != null) && value.equalsIgnoreCase("true"); //$NON-NLS-1$ } /** List of refresh requests (Nodes) */ private final List fRequests; @@ -53,7 +53,7 @@ List fViewers = new ArrayList(3); public RefreshStructureJob() { - super(XMLUIMessages.refreshoutline_0); //$NON-NLS-1$ + super(XMLUIMessages.refreshoutline_0); setPriority(Job.LONG); setSystem(true); fRequests = new ArrayList(2); @@ -62,8 +62,8 @@ private synchronized void addRequest(Node newNodeRequest) { /* * note: the caller must NOT pass in null node request (which, since - * private method, we do not need to gaurd against here, as long - * as we gaurd against it in calling method. + * private method, we do not need to gaurd against here, as long as we + * gaurd against it in calling method. */ int size = fRequests.size(); for (int i = 0; i < size; i++) { @@ -73,14 +73,16 @@ * already have a request which equals the new request, discard * the new request */ - if (existingNodeRequest.equals(newNodeRequest)) + if (existingNodeRequest.equals(newNodeRequest)) { return; + } /* * If we already have a request which contains the new request, * discard the new request */ - if (contains(existingNodeRequest, newNodeRequest)) + if (contains(existingNodeRequest, newNodeRequest)) { return; + } /* * If new request contains any existing requests, replace it with * new request. ISSUE: technically, we should replace ALL @@ -131,31 +133,35 @@ // can't contain the child if it's null if (root == null) { - if (DEBUG) + if (DEBUG) { System.out.println("returning false: root is null"); //$NON-NLS-1$ + } return false; } // nothing can be parent of Document node if (possible instanceof Document) { - if (DEBUG) + if (DEBUG) { System.out.println("returning false: possible is Document node"); //$NON-NLS-1$ + } return false; } // document contains everything if (root instanceof Document) { - if (DEBUG) + if (DEBUG) { System.out.println("returning true: root is Document node"); //$NON-NLS-1$ + } return true; } // check parentage Node current = possible; // loop parents - while (current != null && current.getNodeType() != Node.DOCUMENT_NODE) { + while ((current != null) && (current.getNodeType() != Node.DOCUMENT_NODE)) { // found it if (root.equals(current)) { - if (DEBUG) + if (DEBUG) { System.out.println(" !!! found: " + possible.getNodeName() + " in subelement of: " + root.getNodeName()); //$NON-NLS-1$ //$NON-NLS-2$ + } return true; } current = current.getParentNode(); @@ -173,8 +179,9 @@ final Display display = PlatformUI.getWorkbench().getDisplay(); display.asyncExec(new Runnable() { public void run() { - if (DEBUG) + if (DEBUG) { System.out.println("refresh on: [" + node.getNodeName() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ + } for (int i = 0; i < viewers.length; i++) { if (!viewers[i].getControl().isDisposed()) { @@ -186,8 +193,9 @@ } } else { - if (DEBUG) + if (DEBUG) { System.out.println(" !!! skipped refreshing disposed viewer: " + viewers[i]); //$NON-NLS-1$ + } } } } @@ -217,8 +225,9 @@ * @param node */ public void refresh(StructuredViewer viewer, Node node) { - if (node == null) + if (node == null) { return; + } addViewer(viewer); addRequest(node); @@ -234,8 +243,9 @@ StructuredViewer[] viewers = (StructuredViewer[]) requests[1]; for (int i = 0; i < nodes.length; i++) { - if (monitor.isCanceled()) + if (monitor.isCanceled()) { throw new OperationCanceledException(); + } doRefresh(nodes[i], viewers); } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java index 4b3b00f..00c3e83 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java
@@ -35,7 +35,8 @@ // format selected node IStructuredFormatProcessor formatProcessor = new FormatProcessorXML(); formatProcessor.formatNode(newElement); - } finally { + } + finally { // tell the model that we are done with the big model change fModel.changedModel(); }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionProcessorXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionProcessorXML.java index 3234825..17778c4 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionProcessorXML.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionProcessorXML.java
@@ -27,15 +27,17 @@ } protected IQuickAssistProcessor getQuickAssistProcessor() { - if (fQuickAssistProcessor == null) + if (fQuickAssistProcessor == null) { fQuickAssistProcessor = new QuickAssistProcessorXML(); + } return fQuickAssistProcessor; } protected IQuickFixProcessor getQuickFixProcessor() { - if (fQuickFixProcessor == null) + if (fQuickFixProcessor == null) { fQuickFixProcessor = new QuickFixProcessorXML(); + } return fQuickFixProcessor; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/InsertRequiredAttrsQuickAssistProposal.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/InsertRequiredAttrsQuickAssistProposal.java index 1b90389..ba36316 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/InsertRequiredAttrsQuickAssistProposal.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/InsertRequiredAttrsQuickAssistProposal.java
@@ -80,11 +80,13 @@ CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) fRequiredAttrs.get(i); String requiredAttributeName = attrDecl.getAttrName(); String defaultValue = attrDecl.getDefaultValue(); - if (defaultValue == null) + if (defaultValue == null) { defaultValue = ""; //$NON-NLS-1$ + } String nameAndDefaultValue = " "; //$NON-NLS-1$ - if (i == 0 && lastRegion.getLength() > lastRegion.getTextLength()) + if ((i == 0) && (lastRegion.getLength() > lastRegion.getTextLength())) { nameAndDefaultValue = ""; //$NON-NLS-1$ + } nameAndDefaultValue += requiredAttributeName + "=\"" + defaultValue + "\""; //$NON-NLS-1$//$NON-NLS-2$ multiTextEdit.addChild(new InsertEdit(index, nameAndDefaultValue)); // BUG3381: MultiTextEdit applies all child TextEdit's basing @@ -109,7 +111,7 @@ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo() */ public String getAdditionalProposalInfo() { - return XMLUIMessages.InsertRequiredAttrsQuickAssistProposal_0; //$NON-NLS-1$ + return XMLUIMessages.InsertRequiredAttrsQuickAssistProposal_0; } /* @@ -127,7 +129,7 @@ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString() */ public String getDisplayString() { - return XMLUIMessages.InsertRequiredAttrsQuickAssistProposal_1; //$NON-NLS-1$ + return XMLUIMessages.InsertRequiredAttrsQuickAssistProposal_1; } /*
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java index 51fd960..ee99fbb 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java
@@ -54,16 +54,17 @@ */ protected void getInsertRequiredAttrs(ArrayList proposals, StructuredTextViewer viewer, int offset) { IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset); - if (node != null && node.getNodeType() == Node.ELEMENT_NODE) { + if ((node != null) && (node.getNodeType() == Node.ELEMENT_NODE)) { IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion(); - if (startStructuredDocumentRegion != null && startStructuredDocumentRegion.containsOffset(offset)) { + if ((startStructuredDocumentRegion != null) && startStructuredDocumentRegion.containsOffset(offset)) { IDOMNode cursorNode = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset); List requiredAttrs = getRequiredAttrs(cursorNode); if (requiredAttrs.size() > 0) { NamedNodeMap currentAttrs = node.getAttributes(); List insertAttrs = new ArrayList(); - if (currentAttrs.getLength() == 0) + if (currentAttrs.getLength() == 0) { insertAttrs.addAll(requiredAttrs); + } else { for (int i = 0; i < requiredAttrs.size(); i++) { String requiredAttrName = ((CMAttributeDeclaration) requiredAttrs.get(i)).getAttrName(); @@ -75,12 +76,14 @@ break; } } - if (!found) + if (!found) { insertAttrs.add(requiredAttrs.get(i)); + } } } - if (insertAttrs.size() > 0) + if (insertAttrs.size() > 0) { proposals.add(new InsertRequiredAttrsQuickAssistProposal(insertAttrs)); + } } } } @@ -98,22 +101,25 @@ ITextRegion region = null; int regionTextEndOffset = 0; - if (startStructuredDocumentRegion != null && startStructuredDocumentRegion.containsOffset(offset)) { + if ((startStructuredDocumentRegion != null) && startStructuredDocumentRegion.containsOffset(offset)) { region = startStructuredDocumentRegion.getRegionAtCharacterOffset(offset); regionTextEndOffset = startStructuredDocumentRegion.getTextEndOffset(region); - } else if (endStructuredDocumentRegion != null && endStructuredDocumentRegion.containsOffset(offset)) { + } + else if ((endStructuredDocumentRegion != null) && endStructuredDocumentRegion.containsOffset(offset)) { region = endStructuredDocumentRegion.getRegionAtCharacterOffset(offset); regionTextEndOffset = endStructuredDocumentRegion.getTextEndOffset(region); } - if (region != null && (region.getType() == DOMRegionContext.XML_TAG_NAME || region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) && offset <= regionTextEndOffset) + if ((region != null) && ((region.getType() == DOMRegionContext.XML_TAG_NAME) || (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)) && (offset <= regionTextEndOffset)) { proposals.add(new RenameInFileQuickAssistProposal()); + } } protected ModelQuery getModelQuery(Node node) { if (node.getNodeType() == Node.DOCUMENT_NODE) { return ModelQueryUtil.getModelQuery((Document) node); - } else { + } + else { return ModelQueryUtil.getModelQuery(node.getOwnerDocument()); } } @@ -163,7 +169,8 @@ */ protected void getSurroundWithNewElementQuickAssistProposal(ArrayList proposals, StructuredTextViewer viewer, int offset) { IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset); - if (node != null) + if (node != null) { proposals.add(new SurroundWithNewElementQuickAssistProposal()); + } } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickFixProcessorXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickFixProcessorXML.java index 6e65a97..dd6045d 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickFixProcessorXML.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickFixProcessorXML.java
@@ -61,7 +61,7 @@ } public Image getImage() { - //return + // return // JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_CORRECTION_CHANGE); } @@ -79,7 +79,7 @@ int problemID = tempAnnotation.getProblemID(); switch (problemID) { case ProblemIDsXML.EmptyTag : - proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_0, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_0, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ break; case ProblemIDsXML.MissingEndTag : String tagName = (String) ((Object[]) tempAnnotation.getAdditionalFixInfo())[0]; @@ -88,56 +88,56 @@ int startTagEndOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[3]).intValue(); int firstChildStartOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[4]).intValue(); int endOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[5]).intValue(); - proposals.add(new CompletionProposal(tagClose, tagCloseOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_1, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), startTagEndOffset - tempAnnotation.getPosition().getOffset(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_2, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - proposals.add(new CompletionProposal("</" + tagName + ">", firstChildStartOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_3, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - proposals.add(new CompletionProposal("</" + tagName + ">", endOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_4, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + proposals.add(new CompletionProposal(tagClose, tagCloseOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_1, null, "")); //$NON-NLS-1$ + proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), startTagEndOffset - tempAnnotation.getPosition().getOffset(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_2, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ + proposals.add(new CompletionProposal("</" + tagName + ">", firstChildStartOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_3, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + proposals.add(new CompletionProposal("</" + tagName + ">", endOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_4, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ break; case ProblemIDsXML.AttrsInEndTag : - proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_5, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_5, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ break; case ProblemIDsXML.MissingAttrValue : String defaultAttrValue = (String) ((Object[]) tempAnnotation.getAdditionalFixInfo())[0]; int insertOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[1]).intValue(); - proposals.add(new CompletionProposal("\"" + defaultAttrValue + "\"", tempAnnotation.getPosition().getOffset() + tempAnnotation.getPosition().getLength() + insertOffset, 0, defaultAttrValue.length() + 2, getImage(), XMLUIMessages.QuickFixProcessorXML_6, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + proposals.add(new CompletionProposal("\"" + defaultAttrValue + "\"", tempAnnotation.getPosition().getOffset() + tempAnnotation.getPosition().getLength() + insertOffset, 0, defaultAttrValue.length() + 2, getImage(), XMLUIMessages.QuickFixProcessorXML_6, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ break; case ProblemIDsXML.NoAttrValue : defaultAttrValue = (String) tempAnnotation.getAdditionalFixInfo(); - proposals.add(new CompletionProposal("=\"" + defaultAttrValue + "\"", tempAnnotation.getPosition().getOffset() + tempAnnotation.getPosition().getLength(), 0, defaultAttrValue.length() + 3, getImage(), XMLUIMessages.QuickFixProcessorXML_6, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + proposals.add(new CompletionProposal("=\"" + defaultAttrValue + "\"", tempAnnotation.getPosition().getOffset() + tempAnnotation.getPosition().getLength(), 0, defaultAttrValue.length() + 3, getImage(), XMLUIMessages.QuickFixProcessorXML_6, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ break; case ProblemIDsXML.SpacesBeforeTagName : - proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_8, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_8, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ break; case ProblemIDsXML.SpacesBeforePI : - proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_9, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_9, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ break; case ProblemIDsXML.NamespaceInPI : - proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_10, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_10, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ break; case ProblemIDsXML.UnknownElement : - proposals.add(new RemoveUnknownElementQuickFixProposal(tempAnnotation.getAdditionalFixInfo(), getImage(), XMLUIMessages.QuickFixProcessorXML_11)); //$NON-NLS-1$ + proposals.add(new RemoveUnknownElementQuickFixProposal(tempAnnotation.getAdditionalFixInfo(), getImage(), XMLUIMessages.QuickFixProcessorXML_11)); proposals.add(new RenameInFileQuickAssistProposal()); break; case ProblemIDsXML.UnknownAttr : - proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ proposals.add(new RenameInFileQuickAssistProposal()); break; case ProblemIDsXML.InvalidAttrValue : - proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_12, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_12, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ break; case ProblemIDsXML.MissingRequiredAttr : String requiredAttr = (String) ((Object[]) tempAnnotation.getAdditionalFixInfo())[0]; insertOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[1]).intValue(); - proposals.add(new CompletionProposal(requiredAttr, tempAnnotation.getPosition().getOffset() + insertOffset, 0, requiredAttr.length(), getImage(), XMLUIMessages.QuickFixProcessorXML_13, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ + proposals.add(new CompletionProposal(requiredAttr, tempAnnotation.getPosition().getOffset() + insertOffset, 0, requiredAttr.length(), getImage(), XMLUIMessages.QuickFixProcessorXML_13, null, "")); //$NON-NLS-1$ break; case ProblemIDsXML.AttrValueNotQuoted : String attrValue = (String) tempAnnotation.getAdditionalFixInfo(); - proposals.add(new CompletionProposal("\"" + attrValue + "\"", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), attrValue.length() + 2, getImage(), XMLUIMessages.QuickFixProcessorXML_14, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + proposals.add(new CompletionProposal("\"" + attrValue + "\"", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), attrValue.length() + 2, getImage(), XMLUIMessages.QuickFixProcessorXML_14, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ break; case ProblemIDsXML.MissingClosingBracket : - proposals.add(new CompletionProposal(">", tempAnnotation.getPosition().getOffset() + tempAnnotation.getPosition().getLength(), 0, 1, getImage(), XMLUIMessages.QuickFixProcessorXML_15, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + proposals.add(new CompletionProposal(">", tempAnnotation.getPosition().getOffset() + tempAnnotation.getPosition().getLength(), 0, 1, getImage(), XMLUIMessages.QuickFixProcessorXML_15, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ break; } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RemoveUnknownElementQuickFixProposal.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RemoveUnknownElementQuickFixProposal.java index 7dac576..256f552 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RemoveUnknownElementQuickFixProposal.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RemoveUnknownElementQuickFixProposal.java
@@ -107,8 +107,9 @@ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString() */ public String getDisplayString() { - if (fDisplayString == null) - fDisplayString = XMLUIMessages.QuickFixProcessorXML_11; //$NON-NLS-1$ + if (fDisplayString == null) { + fDisplayString = XMLUIMessages.QuickFixProcessorXML_11; + } return fDisplayString; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RenameInFileQuickAssistProposal.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RenameInFileQuickAssistProposal.java index 02330a6..890f259 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RenameInFileQuickAssistProposal.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RenameInFileQuickAssistProposal.java
@@ -66,29 +66,33 @@ if (region != null) { group.addPosition(new LinkedPosition(document, startStructuredDocumentRegion.getStartOffset() + region.getStart(), region.getTextLength(), 0)); - if (region.getType() == DOMRegionContext.XML_TAG_NAME && node.getEndStructuredDocumentRegion() != null) { + if ((region.getType() == DOMRegionContext.XML_TAG_NAME) && (node.getEndStructuredDocumentRegion() != null)) { region = node.getEndStructuredDocumentRegion().getRegions().get(1); - if (region != null) + if (region != null) { group.addPosition(new LinkedPosition(document, node.getEndStructuredDocumentRegion().getStartOffset() + region.getStart(), region.getTextLength(), 1)); + } } - } else { + } + else { IStructuredDocumentRegion endStructuredDocumentRegion = node.getEndStructuredDocumentRegion(); region = (endStructuredDocumentRegion == null) ? null : endStructuredDocumentRegion.getRegionAtCharacterOffset(offset); if (region != null) { - if (region.getType() == DOMRegionContext.XML_TAG_NAME && node.getStartStructuredDocumentRegion() != null) { + if ((region.getType() == DOMRegionContext.XML_TAG_NAME) && (node.getStartStructuredDocumentRegion() != null)) { ITextRegion startTagNameRegion = node.getStartStructuredDocumentRegion().getRegions().get(1); if (region != null) { group.addPosition(new LinkedPosition(document, node.getStartStructuredDocumentRegion().getStartOffset() + startTagNameRegion.getStart(), startTagNameRegion.getTextLength(), 0)); group.addPosition(new LinkedPosition(document, endStructuredDocumentRegion.getStartOffset() + region.getStart(), region.getTextLength(), 1)); } - } else + } + else { group.addPosition(new LinkedPosition(document, endStructuredDocumentRegion.getStartOffset() + region.getStart(), region.getTextLength(), 0)); + } } } // TODO CompletionProposalPopup#insertProposal() calls // IRewriteTarget.beginCompoundChange() - // which disables redraw in ITextViewer. Workaround for now. + // which disables redraw in ITextViewer. Workaround for now. ((StructuredTextViewer) viewer).setRedraw(true); } @@ -101,7 +105,8 @@ ui.enter(); fSelectedRegion = ui.getSelectedRegion(); - } catch (BadLocationException e) { + } + catch (BadLocationException e) { // log for now, unless find reason not to Logger.log(Logger.INFO, e.getMessage()); } @@ -113,7 +118,7 @@ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo() */ public String getAdditionalProposalInfo() { - return XMLUIMessages.RenameInFileQuickAssistProposal_0; //$NON-NLS-1$ + return XMLUIMessages.RenameInFileQuickAssistProposal_0; } /* @@ -131,7 +136,7 @@ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString() */ public String getDisplayString() { - return XMLUIMessages.RenameInFileQuickAssistProposal_1; //$NON-NLS-1$ + return XMLUIMessages.RenameInFileQuickAssistProposal_1; } /*
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/SurroundWithNewElementQuickAssistProposal.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/SurroundWithNewElementQuickAssistProposal.java index c7400a1..26c3223 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/SurroundWithNewElementQuickAssistProposal.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/SurroundWithNewElementQuickAssistProposal.java
@@ -45,8 +45,9 @@ if (startTagOffset == endTagOffset) { IDOMNode cursorNode = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset); // use parent node if text node is empty - if (cursorNode.getNodeType() == Node.TEXT_NODE && cursorNode.getNodeValue().trim().length() == 0) + if ((cursorNode.getNodeType() == Node.TEXT_NODE) && (cursorNode.getNodeValue().trim().length() == 0)) { cursorNode = (IDOMNode) cursorNode.getParentNode(); + } startTagOffset = cursorNode.getStartOffset(); endTagOffset = cursorNode.getEndOffset(); @@ -69,10 +70,12 @@ // rename new element super.apply(viewer, trigger, stateMask, newElementNode.getStartOffset() + 1); - } catch (MalformedTreeException e) { + } + catch (MalformedTreeException e) { // log for now, unless find reason not to Logger.log(Logger.INFO, e.getMessage()); - } catch (BadLocationException e) { + } + catch (BadLocationException e) { // log for now, unless find reason not to Logger.log(Logger.INFO, e.getMessage()); } @@ -84,7 +87,7 @@ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo() */ public String getAdditionalProposalInfo() { - return XMLUIMessages.SurroundWithNewElementQuickAssistProposal_0; //$NON-NLS-1$ + return XMLUIMessages.SurroundWithNewElementQuickAssistProposal_0; } /* @@ -93,7 +96,7 @@ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString() */ public String getDisplayString() { - return XMLUIMessages.SurroundWithNewElementQuickAssistProposal_1; //$NON-NLS-1$ + return XMLUIMessages.SurroundWithNewElementQuickAssistProposal_1; } /*
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditAttributeDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditAttributeDialog.java index bb44a52..4c171f1 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditAttributeDialog.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditAttributeDialog.java
@@ -86,7 +86,7 @@ composite.setLayoutData(new GridData(GridData.FILL_BOTH)); Label attributeNameLabel = new Label(composite, SWT.NONE); - attributeNameLabel.setText(XMLUIMessages._UI_LABEL_NAME_COLON); //$NON-NLS-1$ + attributeNameLabel.setText(XMLUIMessages._UI_LABEL_NAME_COLON); attributeNameField = new Text(composite, SWT.SINGLE | SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -96,7 +96,7 @@ attributeNameField.addModifyListener(this); Label attributeValueLabel = new Label(composite, SWT.NONE); - attributeValueLabel.setText(XMLUIMessages._UI_LABEL_VALUE_COLON); //$NON-NLS-1$ + attributeValueLabel.setText(XMLUIMessages._UI_LABEL_VALUE_COLON); String value = attribute != null ? attribute.getValue() : ""; //$NON-NLS-1$ int style = SWT.SINGLE | SWT.BORDER; @@ -112,7 +112,7 @@ // error message errorMessageLabel = new Label(composite, SWT.WRAP); - errorMessageLabel.setText(XMLUIMessages.error_message_goes_here); //$NON-NLS-1$ + errorMessageLabel.setText(XMLUIMessages.error_message_goes_here); gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = 200; gd.heightHint = Math.max(30, errorMessageLabel.computeSize(0, 0, false).y * 2); @@ -138,7 +138,7 @@ protected String getModelValue(String string) { String result = null; - if (string != null && string.trim().length() > 0) { + if ((string != null) && (string.trim().length() > 0)) { result = string; } return result; @@ -153,13 +153,15 @@ String name = attributeNameField.getText().trim(); if (name.length() > 0) { Attr matchingAttribute = ownerElement.getAttributeNode(name); - if (matchingAttribute != null && matchingAttribute != attribute) { - errorMessage = XMLUIMessages._ERROR_XML_ATTRIBUTE_ALREADY_EXISTS; //$NON-NLS-1$ - } else { - // TODO get checkName from Model - //errorMessage = ValidateHelper.checkXMLName(name); + if ((matchingAttribute != null) && (matchingAttribute != attribute)) { + errorMessage = XMLUIMessages._ERROR_XML_ATTRIBUTE_ALREADY_EXISTS; } - } else { + else { + // TODO get checkName from Model + // errorMessage = ValidateHelper.checkXMLName(name); + } + } + else { errorMessage = ""; //$NON-NLS-1$ }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditDoctypeDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditDoctypeDialog.java index 8990c94..6e071ba 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditDoctypeDialog.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditDoctypeDialog.java
@@ -104,7 +104,7 @@ // row 1 // Label rootElementNameLabel = new Label(composite, SWT.NONE); - rootElementNameLabel.setText(XMLUIMessages._UI_LABEL_ROOT_ELEMENT_NAME_COLON); //$NON-NLS-1$ + rootElementNameLabel.setText(XMLUIMessages._UI_LABEL_ROOT_ELEMENT_NAME_COLON); rootElementNameField = new Text(composite, SWT.SINGLE | SWT.BORDER); PlatformUI.getWorkbench().getHelpSystem().setHelp(rootElementNameField, XMLCommonUIContextIds.XCUI_DOCTYPE_ROOT); @@ -120,7 +120,7 @@ // row 2 // Label publicIdLabel = new Label(composite, SWT.NONE); - publicIdLabel.setText(XMLUIMessages._UI_LABEL_PUBLIC_ID_COLON); //$NON-NLS-1$ + publicIdLabel.setText(XMLUIMessages._UI_LABEL_PUBLIC_ID_COLON); publicIdField = new Text(composite, SWT.SINGLE | SWT.BORDER); PlatformUI.getWorkbench().getHelpSystem().setHelp(publicIdField, XMLCommonUIContextIds.XCUI_DOCTYPE_PUBLIC); @@ -140,12 +140,12 @@ }; publicIdBrowseButton = new Button(composite, SWT.NONE); - publicIdBrowseButton.setText(XMLUIMessages._UI_LABEL_BROWSE); //$NON-NLS-1$ + publicIdBrowseButton.setText(XMLUIMessages._UI_LABEL_BROWSE); publicIdBrowseButton.addSelectionListener(selectionListener); // row 3 Label systemIdLabel = new Label(composite, SWT.NONE); - systemIdLabel.setText(XMLUIMessages._UI_LABEL_SYSTEM_ID_COLON); //$NON-NLS-1$ + systemIdLabel.setText(XMLUIMessages._UI_LABEL_SYSTEM_ID_COLON); systemIdField = new Text(composite, SWT.SINGLE | SWT.BORDER); PlatformUI.getWorkbench().getHelpSystem().setHelp(systemIdField, XMLCommonUIContextIds.XCUI_DOCTYPE_SYSTEM); @@ -155,7 +155,7 @@ systemIdBrowseButton = new Button(composite, SWT.NONE); - systemIdBrowseButton.setText(XMLUIMessages._UI_LABEL_BROWSE); //$NON-NLS-1$ + systemIdBrowseButton.setText(XMLUIMessages._UI_LABEL_BROWSE); systemIdBrowseButton.addSelectionListener(selectionListener); // error message @@ -165,7 +165,7 @@ Color color = new Color(errorMessageLabel.getDisplay(), 200, 0, 0); errorMessageLabel.setForeground(color); - Dialog.applyDialogFont(parent); + Dialog.applyDialogFont(parent); return dialogControl; } @@ -188,7 +188,7 @@ protected String getModelValue(String string) { String result = null; - if (string != null && string.trim().length() > 0) { + if ((string != null) && (string.trim().length() > 0)) { result = string; } return result; @@ -222,10 +222,10 @@ if (errorChecking) { String errorMessage = null; if (getModelValue(systemIdField.getText()) == null) { - errorMessage = XMLUIMessages._UI_WARNING_SYSTEM_ID_MUST_BE_SPECIFIED; //$NON-NLS-1$ + errorMessage = XMLUIMessages._UI_WARNING_SYSTEM_ID_MUST_BE_SPECIFIED; } else if (getModelValue(rootElementNameField.getText()) == null) { - errorMessage = XMLUIMessages._UI_WARNING_ROOT_ELEMENT_MUST_BE_SPECIFIED; //$NON-NLS-1$ + errorMessage = XMLUIMessages._UI_WARNING_ROOT_ELEMENT_MUST_BE_SPECIFIED; } errorMessageLabel.setText(errorMessage != null ? errorMessage : ""); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditElementDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditElementDialog.java index 4e6098a..0d247cf 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditElementDialog.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditElementDialog.java
@@ -79,7 +79,7 @@ composite.setLayoutData(new GridData(GridData.FILL_BOTH)); Label elementNameLabel = new Label(composite, SWT.NONE); - elementNameLabel.setText(XMLUIMessages._UI_LABEL_ELEMENT_NAME); //$NON-NLS-1$ + elementNameLabel.setText(XMLUIMessages._UI_LABEL_ELEMENT_NAME); elementNameField = new Text(composite, SWT.SINGLE | SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); @@ -90,7 +90,7 @@ // error message errorMessageLabel = new Label(composite, SWT.NONE); - errorMessageLabel.setText(XMLUIMessages.error_message_goes_here); //$NON-NLS-1$ + errorMessageLabel.setText(XMLUIMessages.error_message_goes_here); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; errorMessageLabel.setLayoutData(gd); @@ -110,7 +110,7 @@ protected String getModelValue(String string) { String result = null; - if (string != null && string.trim().length() > 0) { + if ((string != null) && (string.trim().length() > 0)) { result = string; } return result; @@ -123,14 +123,15 @@ protected void updateErrorMessage() { String errorMessage = null; String name = elementNameField.getText(); - // String name = elementNameField.getText().trim(); + // String name = elementNameField.getText().trim(); if (name.length() > 0) { // TODO use checkName from model level - //errorMessage = ValidateHelper.checkXMLName(name); + // errorMessage = ValidateHelper.checkXMLName(name); if (!NameValidator.isValid(name)) { errorMessage = XMLUIMessages._UI_INVALID_NAME; } - } else { + } + else { errorMessage = ""; //$NON-NLS-1$ } @@ -138,6 +139,3 @@ okButton.setEnabled(errorMessage == null); } } - - -
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditEntityHelper.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditEntityHelper.java index 4fbec45..3d4bb7c 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditEntityHelper.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditEntityHelper.java
@@ -31,14 +31,14 @@ String[] extensions = {"dtd", "txt"}; //$NON-NLS-1$ //$NON-NLS-2$ SelectXMLCatalogIdDialog dialog = new SelectXMLCatalogIdDialog(parentShell, extensions); dialog.create(); - dialog.getShell().setText(XMLUIMessages._UI_LABEL_SELECT_XML_CATALOG_ENTRY); //$NON-NLS-1$ + dialog.getShell().setText(XMLUIMessages._UI_LABEL_SELECT_XML_CATALOG_ENTRY); dialog.setBlockOnOpen(true); dialog.open(); if (dialog.getReturnCode() == Window.OK) { String id = dialog.getId(); if (id != null) { publicIdField.setText(id); - if (systemIdField != null && dialog.getSystemId() != null) { + if ((systemIdField != null) && (dialog.getSystemId() != null)) { systemIdField.setText(dialog.getSystemId()); } } @@ -49,7 +49,7 @@ String[] extensions = {"dtd"}; //$NON-NLS-1$ SelectFileOrXMLCatalogIdDialog dialog = new SelectFileOrXMLCatalogIdDialog(parentShell, extensions, ICatalogEntry.ENTRY_TYPE_SYSTEM); dialog.create(); - dialog.getShell().setText(XMLUIMessages._UI_LABEL_SPECIFY_SYSTEM_ID); //$NON-NLS-1$ + dialog.getShell().setText(XMLUIMessages._UI_LABEL_SPECIFY_SYSTEM_ID); dialog.setBlockOnOpen(true); dialog.open(); if (dialog.getReturnCode() == Window.OK) { @@ -57,11 +57,13 @@ IFile file = dialog.getFile(); if (id != null) { systemIdField.setText(id); - } else if (file != null) { + } + else if (file != null) { String uri = null; if (resourceLocation != null) { uri = URIHelper.getRelativeURI(file.getLocation(), resourceLocation); - } else { + } + else { uri = file.getLocation().toOSString(); } systemIdField.setText(uri);
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditNamespaceInfoDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditNamespaceInfoDialog.java index b6f16c5..f1c65b8 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditNamespaceInfoDialog.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditNamespaceInfoDialog.java
@@ -96,7 +96,7 @@ protected Control createDialogArea(Composite parent) { Composite dialogsubArea = (Composite) super.createDialogArea(parent); - PlatformUI.getWorkbench().getHelpSystem().setHelp(dialogsubArea, XMLCommonUIContextIds.XCUI_NAMESPACE_DIALOG); + PlatformUI.getWorkbench().getHelpSystem().setHelp(dialogsubArea, XMLCommonUIContextIds.XCUI_NAMESPACE_DIALOG); Composite composite = new Composite(dialogsubArea, SWT.NONE); GridLayout layout = new GridLayout(); @@ -118,7 +118,7 @@ // row 1 // Label uriLabel = new Label(composite, SWT.NONE); - uriLabel.setText(XMLUIMessages._UI_LABEL_NAMESPACE_NAME_COLON); //$NON-NLS-1$ + uriLabel.setText(XMLUIMessages._UI_LABEL_NAMESPACE_NAME_COLON); uriField = new Text(composite, SWT.SINGLE | SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); @@ -129,13 +129,13 @@ uriField.setEnabled(fInfo.getProperty("uri-readOnly") == null); //$NON-NLS-1$ // never read - Label placeHolder1 = new Label(composite, SWT.NONE); - placeHolder1.setText(""); //$NON-NLS-1$ + Label placeHolder1 = new Label(composite, SWT.NONE); + placeHolder1.setText(""); //$NON-NLS-1$ // row 2 // Label prefixLabel = new Label(composite, SWT.NONE); - prefixLabel.setText(XMLUIMessages._UI_LABEL_PREFIX_COLON); //$NON-NLS-1$ + prefixLabel.setText(XMLUIMessages._UI_LABEL_PREFIX_COLON); prefixField = new Text(composite, SWT.SINGLE | SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); @@ -146,13 +146,13 @@ prefixField.setEnabled(fInfo.getProperty("prefix-readOnly") == null); //$NON-NLS-1$ // never read - Label placeHolder2 = new Label(composite, SWT.NONE); - placeHolder2.setText(""); //$NON-NLS-1$ + Label placeHolder2 = new Label(composite, SWT.NONE); + placeHolder2.setText(""); //$NON-NLS-1$ // row 3 // Label locationHintLabel = new Label(composite, SWT.NONE); - locationHintLabel.setText(XMLUIMessages._UI_LABEL_LOCATION_HINT_COLON); //$NON-NLS-1$ + locationHintLabel.setText(XMLUIMessages._UI_LABEL_LOCATION_HINT_COLON); locationHintField = new Text(composite, SWT.SINGLE | SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); @@ -169,13 +169,13 @@ }; browseButton = new Button(composite, SWT.NONE); - browseButton.setText(XMLUIMessages._UI_LABEL_BROWSE); //$NON-NLS-1$ + browseButton.setText(XMLUIMessages._UI_LABEL_BROWSE); browseButton.addSelectionListener(selectionListener); browseButton.setEnabled(locationHintField.getEnabled()); // error message errorMessageLabel = new Label(dialogsubArea, SWT.NONE); - errorMessageLabel.setText(XMLUIMessages.error_message_goes_here); //$NON-NLS-1$ + errorMessageLabel.setText(XMLUIMessages.error_message_goes_here); errorMessageLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Color color = new Color(errorMessageLabel.getDisplay(), 200, 0, 0); errorMessageLabel.setForeground(color); @@ -191,7 +191,7 @@ String[] extensions = {".xsd"}; //$NON-NLS-1$ SelectFileOrXMLCatalogIdDialog dialog = new SelectFileOrXMLCatalogIdDialog(getShell(), extensions); dialog.create(); - dialog.getShell().setText(XMLUIMessages._UI_LABEL_SELECT_FILE); //$NON-NLS-1$ + dialog.getShell().setText(XMLUIMessages._UI_LABEL_SELECT_FILE); dialog.setBlockOnOpen(true); dialog.open(); @@ -221,10 +221,10 @@ CMDocument document = ContentModelManager.getInstance().createCMDocument(grammarURI, "xsd"); //$NON-NLS-1$ List namespaceInfoList = (List) document.getProperty("http://org.eclipse.wst/cm/properties/namespaceInfo"); //$NON-NLS-1$ NamespaceInfo info = (NamespaceInfo) namespaceInfoList.get(0); - if (uriField.getText().trim().length() == 0 && info.uri != null) { + if ((uriField.getText().trim().length() == 0) && (info.uri != null)) { uriField.setText(info.uri); } - if (prefixField.getText().trim().length() == 0 && info.prefix != null) { + if ((prefixField.getText().trim().length() == 0) && (info.prefix != null)) { prefixField.setText(info.prefix); } } @@ -240,10 +240,12 @@ protected void updateOKButtonState() { if (okButton != null) { - if (uriField.getText().trim().length() == 0 && prefixField.getText().trim().length() == 0 && locationHintField.getText().trim().length() == 0) + if ((uriField.getText().trim().length() == 0) && (prefixField.getText().trim().length() == 0) && (locationHintField.getText().trim().length() == 0)) { okButton.setEnabled(false); - else + } + else { okButton.setEnabled(errorMessage == null); + } } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditProcessingInstructionDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditProcessingInstructionDialog.java index 4b3fe66..5009e45 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditProcessingInstructionDialog.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditProcessingInstructionDialog.java
@@ -49,7 +49,7 @@ data = getModelValue(dataField.getText()); super.buttonPressed(buttonId); } - + protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); @@ -71,14 +71,14 @@ gd.widthHint = 250; Label targetLabel = new Label(composite, SWT.NONE); - targetLabel.setText(XMLUIMessages._UI_LABEL_TARGET_COLON); //$NON-NLS-1$ + targetLabel.setText(XMLUIMessages._UI_LABEL_TARGET_COLON); targetField = new Text(composite, SWT.SINGLE | SWT.BORDER); targetField.setLayoutData(gd); targetField.setText(getDisplayValue(target)); Label dataLabel = new Label(composite, SWT.NONE); - dataLabel.setText(XMLUIMessages._UI_LABEL_DATA_COLON); //$NON-NLS-1$ + dataLabel.setText(XMLUIMessages._UI_LABEL_DATA_COLON); dataField = new Text(composite, SWT.SINGLE | SWT.BORDER); dataField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -89,7 +89,7 @@ protected Label createMessageArea(Composite composite) { Label label = new Label(composite, SWT.NONE); - //label.setText(message); + // label.setText(message); return label; } @@ -103,7 +103,7 @@ protected String getModelValue(String string) { String result = null; - if (string != null && string.trim().length() > 0) { + if ((string != null) && (string.trim().length() > 0)) { result = string; } return result; @@ -114,6 +114,3 @@ return target; } } - - -
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditSchemaInfoDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditSchemaInfoDialog.java index 01aefdc..9ffb226 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditSchemaInfoDialog.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditSchemaInfoDialog.java
@@ -47,8 +47,8 @@ protected Control createDialogArea(Composite parent) { Composite dialogArea = (Composite) super.createDialogArea(parent); PlatformUI.getWorkbench().getHelpSystem().setHelp(dialogArea, XMLCommonUIContextIds.XCUI_SCHEMA_INFO_DIALOG); - - CommonEditNamespacesDialog editNamespacesControl = new CommonEditNamespacesDialog(dialogArea, resourceLocation, XMLUIMessages._UI_NAMESPACE_DECLARATIONS, false, true); //$NON-NLS-1$ + + CommonEditNamespacesDialog editNamespacesControl = new CommonEditNamespacesDialog(dialogArea, resourceLocation, XMLUIMessages._UI_NAMESPACE_DECLARATIONS, false, true); editNamespacesControl.setNamespaceInfoList(namespaceInfoList); editNamespacesControl.updateErrorMessage(namespaceInfoList);
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoErrorHelper.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoErrorHelper.java index ae360c3..f00ee2e 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoErrorHelper.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoErrorHelper.java
@@ -40,13 +40,15 @@ String urikey = nsInfo.uri != null ? nsInfo.uri : ""; //$NON-NLS-1$ NamespaceInfo nsInfo2 = null; if ((nsInfo2 = (NamespaceInfo) uriTable.get(urikey)) != null) { - if (nsInfo.uri != null && nsInfo.uri.equals(nsInfo2.uri)) { - result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITH_NAME + "'" + nsInfo.uri + "'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } else { - result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_NAME; //$NON-NLS-1$ + if ((nsInfo.uri != null) && nsInfo.uri.equals(nsInfo2.uri)) { + result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITH_NAME + "'" + nsInfo.uri + "'"; //$NON-NLS-1$ //$NON-NLS-2$ + } + else { + result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_NAME; } break; - } else { + } + else { uriTable.put(urikey, nsInfo); } @@ -54,30 +56,33 @@ String key = nsInfo.prefix != null ? nsInfo.prefix : ""; //$NON-NLS-1$ if (prefixTable.get(key) != null) { if (nsInfo.prefix != null) { - result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITH_PREFIX + "'" + nsInfo.prefix + "'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - break; - } else { - result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_PREFIX; //$NON-NLS-1$ + result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITH_PREFIX + "'" + nsInfo.prefix + "'"; //$NON-NLS-1$ //$NON-NLS-2$ break; } - } else { + else { + result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_PREFIX; + break; + } + } + else { prefixTable.put(key, nsInfo); } - if (nsInfo.locationHint != null && idResolver != null) { + if ((nsInfo.locationHint != null) && (idResolver != null)) { String grammarURI = idResolver.resolve(null, nsInfo.locationHint, nsInfo.locationHint); if (!URIHelper.isReadableURI(grammarURI, false)) { - result = XMLUIMessages._UI_WARNING_SCHEMA_CAN_NOT_BE_LOCATED + " '" + nsInfo.locationHint + "'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + result = XMLUIMessages._UI_WARNING_SCHEMA_CAN_NOT_BE_LOCATED + " '" + nsInfo.locationHint + "'"; //$NON-NLS-1$ //$NON-NLS-2$ break; } } - if (idResolver != null && nsInfo.locationHint == null && !nsInfo.uri.equals(DOMNamespaceInfoManager.XSI_URI)) { - result = XMLUIMessages._UI_WARNING_LOCATION_HINT_NOT_SPECIFIED + " '" + nsInfo.uri + "'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + if ((idResolver != null) && (nsInfo.locationHint == null) && !nsInfo.uri.equals(DOMNamespaceInfoManager.XSI_URI)) { + result = XMLUIMessages._UI_WARNING_LOCATION_HINT_NOT_SPECIFIED + " '" + nsInfo.uri + "'"; //$NON-NLS-1$ //$NON-NLS-2$ break; } - } else { + } + else { if (nsInfo.prefix != null) { - result = XMLUIMessages._UI_WARNING_NAMESPACE_NAME_NOT_SPECIFIED + " '" + nsInfo.prefix + "'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + result = XMLUIMessages._UI_WARNING_NAMESPACE_NAME_NOT_SPECIFIED + " '" + nsInfo.prefix + "'"; //$NON-NLS-1$ //$NON-NLS-2$ break; } } @@ -87,8 +92,8 @@ for (Iterator iterator = namespaceInfoList.iterator(); iterator.hasNext();) { NamespaceInfo nsInfo = (NamespaceInfo) iterator.next(); nsInfo.normalize(); - if (nsInfo.uri != null && nsInfo.isPrefixRequired && nsInfo.prefix == null) { - result = XMLUIMessages._UI_WARNING_PREFIX_NOT_SPECIFIED + " '" + nsInfo.uri + "'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + if ((nsInfo.uri != null) && nsInfo.isPrefixRequired && (nsInfo.prefix == null)) { + result = XMLUIMessages._UI_WARNING_PREFIX_NOT_SPECIFIED + " '" + nsInfo.uri + "'"; //$NON-NLS-1$ //$NON-NLS-2$ break; } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoTable.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoTable.java index e2830e5..a005c94 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoTable.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoTable.java
@@ -90,11 +90,11 @@ if (result.equals("")) { //$NON-NLS-1$ switch (column) { case 0 : { - result = XMLUIMessages._UI_NO_NAMESPACE_NAME; //$NON-NLS-1$ + result = XMLUIMessages._UI_NO_NAMESPACE_NAME; break; } case 1 : { - result = XMLUIMessages._UI_NO_PREFIX; //$NON-NLS-1$ + result = XMLUIMessages._UI_NO_PREFIX; break; } } @@ -102,15 +102,17 @@ return result; } - String getDefaultPrefix() { + String getDefaultPrefix() { String defaultPrefix = "p"; //$NON-NLS-1$ - if (namespaceInfoList == null) + if (namespaceInfoList == null) { return defaultPrefix; + } Vector v = new Vector(); for (int i = 0; i < namespaceInfoList.size(); i++) { NamespaceInfo nsinfo = (NamespaceInfo) namespaceInfoList.get(i); - if (nsinfo.prefix != null) + if (nsinfo.prefix != null) { v.addElement(nsinfo.prefix); + } } if (v.contains(defaultPrefix)) { String s = defaultPrefix; @@ -118,8 +120,10 @@ s = defaultPrefix + Integer.toString(j); } return s; - } else + } + else { return defaultPrefix; + } } public Object[] getElements(Object inputElement) { @@ -145,9 +149,9 @@ } } - protected static final String LOCATION_HINT = XMLUIMessages._UI_LABEL_LOCATION_HINT; //$NON-NLS-1$ - protected static final String NAMESPACE_URI = XMLUIMessages._UI_LABEL_NAMESPACE_NAME; //$NON-NLS-1$ - protected static final String PREFIX = XMLUIMessages._UI_LABEL_PREFIX; //$NON-NLS-1$ + protected static final String LOCATION_HINT = XMLUIMessages._UI_LABEL_LOCATION_HINT; + protected static final String NAMESPACE_URI = XMLUIMessages._UI_LABEL_NAMESPACE_NAME; + protected static final String PREFIX = XMLUIMessages._UI_LABEL_PREFIX; protected Button deleteButton; protected boolean dummyRowsRemoved = false; protected Button editButton; @@ -176,7 +180,7 @@ setLayout(createGridLayout()); setLayoutData(new GridData(GridData.FILL_BOTH)); Group namespaceInfoGroup = new Group(this, SWT.NONE); - namespaceInfoGroup.setText(XMLUIMessages._UI_LABEL_XML_SCHEMA_INFORMATION); //$NON-NLS-1$ + namespaceInfoGroup.setText(XMLUIMessages._UI_LABEL_XML_SCHEMA_INFORMATION); namespaceInfoGroup.setLayout(new GridLayout()); GridData gd = new GridData(GridData.FILL_BOTH); if (widthHint != -1) { @@ -186,7 +190,7 @@ gd.heightHint = heightHint; } namespaceInfoGroup.setLayoutData(gd); - //WorkbenchHelp.setHelp(namespaceInfoGroup, new + // WorkbenchHelp.setHelp(namespaceInfoGroup, new // ControlContextComputer(namespaceInfoGroup, // XMLBuilderContextIds.XMLC_NAMESPACE_GROUP)); String[] titleArray = {NAMESPACE_URI, PREFIX, LOCATION_HINT}; @@ -249,9 +253,11 @@ public void widgetSelected(SelectionEvent e) { if (e.widget == newButton) { performNew(); - } else if (e.widget == editButton) { + } + else if (e.widget == editButton) { performEdit(); - } else if (e.widget == deleteButton) { + } + else if (e.widget == deleteButton) { performDelete(); } } @@ -266,19 +272,19 @@ // add the New button // newButton = new Button(buttonComposite, SWT.NONE); - newButton.setText(XMLUIMessages._UI_BUTTON_NEW); //$NON-NLS-1$ + newButton.setText(XMLUIMessages._UI_BUTTON_NEW); newButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); newButton.addSelectionListener(selectionListener); // add the Edit button // editButton = new Button(buttonComposite, SWT.NONE); - editButton.setText(XMLUIMessages._UI_BUTTON_EDIT); //$NON-NLS-1$ + editButton.setText(XMLUIMessages._UI_BUTTON_EDIT); editButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); editButton.addSelectionListener(selectionListener); // add the Delete button // deleteButton = new Button(buttonComposite, SWT.NONE); - deleteButton.setText(XMLUIMessages._UI_BUTTON_DELETE); //$NON-NLS-1$ + deleteButton.setText(XMLUIMessages._UI_BUTTON_DELETE); deleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); deleteButton.addSelectionListener(selectionListener); } @@ -295,7 +301,7 @@ } protected NamespaceInfo getTargetNamespaceInfo() { - return (namespaceInfoList != null && namespaceInfoList.size() > 0) ? (NamespaceInfo) namespaceInfoList.get(0) : null; + return ((namespaceInfoList != null) && (namespaceInfoList.size() > 0)) ? (NamespaceInfo) namespaceInfoList.get(0) : null; } protected EditNamespaceInfoDialog invokeDialog(String title, NamespaceInfo info) { @@ -334,14 +340,14 @@ 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); //$NON-NLS-1$ + invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, (NamespaceInfo) selectedObject); performDelayedUpdate(); } } public void performNew() { NamespaceInfo info = new NamespaceInfo(); - EditNamespaceInfoDialog dialog = invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, info); //$NON-NLS-1$ + EditNamespaceInfoDialog dialog = invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, info); if (dialog.getReturnCode() == Window.OK) { namespaceInfoList.add(info); performDelayedUpdate(); @@ -370,11 +376,11 @@ Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null; NamespaceInfo info = (NamespaceInfo) selectedObject; editButton.setEnabled(info != null); - deleteButton.setEnabled(info != null && info.getProperty("unremovable") == null); //$NON-NLS-1$ + deleteButton.setEnabled((info != null) && (info.getProperty("unremovable") == null)); //$NON-NLS-1$ } public void updateHelper(List namespaceInfoList) { - if (visibleRows != -1 && !dummyRowsRemoved) { + if ((visibleRows != -1) && !dummyRowsRemoved) { dummyRowsRemoved = true; tableViewer.getTable().removeAll(); } @@ -384,7 +390,8 @@ if (namespaceInfoList.size() > 0) { tableViewer.setSelection(new StructuredSelection(namespaceInfoList.get(0))); } - } else { + } + else { tableViewer.setSelection(selection); } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdDialog.java index edfc968..aafef8c 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdDialog.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdDialog.java
@@ -82,6 +82,6 @@ } protected void updateButtonState() { - okButton.setEnabled(panel.getFile() != null || panel.getXMLCatalogId() != null); + okButton.setEnabled((panel.getFile() != null) || (panel.getXMLCatalogId() != null)); } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdPanel.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdPanel.java index a9cdeba..2987b04 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdPanel.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdPanel.java
@@ -46,8 +46,8 @@ public MySelectSingleFileView(Composite parent) { super(null, true); - //String[] ext = {".dtd"}; - //addFilterExtensions(ext); + // String[] ext = {".dtd"}; + // addFilterExtensions(ext); control = createControl(parent); control.setLayoutData(new GridData(GridData.FILL_BOTH)); MySelectSingleFileView.this.setListener(this); @@ -85,13 +85,13 @@ radioButton = new Button[2]; radioButton[0] = new Button(this, SWT.RADIO); - radioButton[0].setText(XMLUIMessages._UI_RADIO_BUTTON_SELECT_FROM_WORKSPACE); //$NON-NLS-1$ + radioButton[0].setText(XMLUIMessages._UI_RADIO_BUTTON_SELECT_FROM_WORKSPACE); radioButton[0].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); radioButton[0].setSelection(true); radioButton[0].addSelectionListener(this); radioButton[1] = new Button(this, SWT.RADIO); - radioButton[1].setText(XMLUIMessages._UI_RADIO_BUTTON_SELECT_FROM_CATALOG); //$NON-NLS-1$ + radioButton[1].setText(XMLUIMessages._UI_RADIO_BUTTON_SELECT_FROM_CATALOG); radioButton[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); radioButton[1].addSelectionListener(this); @@ -107,9 +107,9 @@ updateCompletionStateChange(); } }); - Dialog.applyDialogFont(parent); + Dialog.applyDialogFont(parent); pageBook.showPage(selectSingleFileView.getControl()); - + } public IFile getFile() { @@ -175,7 +175,8 @@ public void widgetSelected(SelectionEvent e) { if (e.widget == radioButton[0]) { pageBook.showPage(selectSingleFileView.getControl()); - } else { + } + else { pageBook.showPage(selectXMLCatalogIdPanel); } updateCompletionStateChange();
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdDialog.java index 9bea443..b45756a 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdDialog.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdDialog.java
@@ -33,7 +33,6 @@ - public class SelectXMLCatalogIdDialog extends Dialog { protected String[] extensions; protected Button okButton; @@ -64,7 +63,7 @@ protected String computeDefaultSystemId(ICatalogEntry mappingInfo) { String result = mappingInfo.getAttributeValue(ICatalogEntry.ATTR_WEB_URL); - if (result == null && mappingInfo.getURI() != null) { + if ((result == null) && (mappingInfo.getURI() != null)) { int index = mappingInfo.getURI().lastIndexOf("/"); //$NON-NLS-1$ String lastSegment = index != -1 ? mappingInfo.getURI().substring(index + 1) : mappingInfo.getURI(); result = lastSegment;
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdPanel.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdPanel.java index 80ed9bd..36171dd 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdPanel.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdPanel.java
@@ -49,7 +49,7 @@ this.setLayoutData(gd); Label label = new Label(this, SWT.NONE); - label.setText(XMLUIMessages._UI_LABEL_XML_CATALOG_COLON); //$NON-NLS-1$ + label.setText(XMLUIMessages._UI_LABEL_XML_CATALOG_COLON); tableViewer = createTableViewer(this); tableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); @@ -58,17 +58,18 @@ protected XMLCatalogTableViewer createTableViewer(Composite parent) { String headings[] = new String[2]; - headings[0] = XMLUIMessages._UI_LABEL_KEY; //$NON-NLS-1$ - headings[1] = XMLUIMessages._UI_LABEL_URI; //$NON-NLS-1$ + headings[0] = XMLUIMessages._UI_LABEL_KEY; + headings[1] = XMLUIMessages._UI_LABEL_URI; XMLCatalogTableViewer theTableViewer = new XMLCatalogTableViewer(parent, headings) { protected void addXMLCatalogEntries(List list, ICatalogEntry[] entries) { - for (int i=0; i < entries.length; i++) { + for (int i = 0; i < entries.length; i++) { ICatalogEntry entry = entries[i]; if (catalogEntryType == 0) { list.add(entry); - } else if (catalogEntryType == entry.getEntryType()) { + } + else if (catalogEntryType == entry.getEntryType()) { list.add(entry); } } @@ -77,7 +78,7 @@ public Collection getXMLCatalogEntries() { List result = null; - if (fXmlCatalog == null || doTableSizeHack) { + if ((fXmlCatalog == null) || doTableSizeHack) { // this lets us create a table with an initial height of // 10 rows // otherwise we get stuck with 0 row heigh table... that's @@ -87,30 +88,26 @@ for (int i = 0; i < 6; i++) { result.add(""); //$NON-NLS-1$ } - } else { + } + else { result = new Vector(); - INextCatalog[] nextCatalogs = fXmlCatalog.getNextCatalogs(); - for (int i = 0; i < nextCatalogs.length; i++) - { - INextCatalog catalog = nextCatalogs[i]; - ICatalog referencedCatalog = catalog.getReferencedCatalog(); - if (referencedCatalog != null) - { - if (XMLCorePlugin.SYSTEM_CATALOG_ID - .equals(referencedCatalog.getId())) - { - ICatalog systemCatalog = referencedCatalog; - addXMLCatalogEntries(result, systemCatalog.getCatalogEntries()); - - } else if (XMLCorePlugin.USER_CATALOG_ID - .equals(referencedCatalog.getId())) - { - ICatalog userCatalog = referencedCatalog; - addXMLCatalogEntries(result, userCatalog.getCatalogEntries()); - - } - } - } + INextCatalog[] nextCatalogs = fXmlCatalog.getNextCatalogs(); + for (int i = 0; i < nextCatalogs.length; i++) { + INextCatalog catalog = nextCatalogs[i]; + ICatalog referencedCatalog = catalog.getReferencedCatalog(); + if (referencedCatalog != null) { + if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) { + ICatalog systemCatalog = referencedCatalog; + addXMLCatalogEntries(result, systemCatalog.getCatalogEntries()); + + } + else if (XMLCorePlugin.USER_CATALOG_ID.equals(referencedCatalog.getId())) { + ICatalog userCatalog = referencedCatalog; + addXMLCatalogEntries(result, userCatalog.getCatalogEntries()); + + } + } + } } return result; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogTableViewer.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogTableViewer.java index c80e455..2733ba3 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogTableViewer.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogTableViewer.java
@@ -53,7 +53,7 @@ Comparator comparator = new Comparator() { public int compare(Object o1, Object o2) { int result = 0; - if (o1 instanceof ICatalogEntry && o2 instanceof ICatalogEntry) { + if ((o1 instanceof ICatalogEntry) && (o2 instanceof ICatalogEntry)) { ICatalogEntry mappingInfo1 = (ICatalogEntry) o1; ICatalogEntry mappingInfo2 = (ICatalogEntry) o2; result = Collator.getInstance().compare(mappingInfo1.getKey(), mappingInfo2.getKey()); @@ -84,18 +84,21 @@ String uri = catalogEntry.getURI(); if (uri.endsWith("dtd")) { //$NON-NLS-1$ base = dtdFileImage; - } else if (uri.endsWith("xsd")) { //$NON-NLS-1$ + } + else if (uri.endsWith("xsd")) { //$NON-NLS-1$ base = xsdFileImage; - } else { + } + else { base = unknownFileImage; } if (base != null) { if (URIHelper.isReadableURI(uri, false)) { result = base; - } else { - //TODO... SSE port - result = base;//imageFactory.createCompositeImage(base, + } + else { + // TODO... SSE port + result = base;// imageFactory.createCompositeImage(base, // errorImage, // ImageFactory.BOTTOM_LEFT); } @@ -151,7 +154,7 @@ protected static Image unknownFileImage = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TXTEXT); protected static Image xsdFileImage = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_XSDFILE); - //protected ImageFactory imageFactory = new ImageFactory(); + // protected ImageFactory imageFactory = new ImageFactory(); public XMLCatalogTableViewer(Composite parent, String[] columnProperties) { super(parent, SWT.FULL_SELECTION);
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java index e24391f..a1bcfca 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java
@@ -33,7 +33,7 @@ public class DragNodeCommand extends DefaultDragAndDropCommand { private List fSelections; private TreeViewer fTreeViewer; - + public DragNodeCommand(Object target, float location, int operations, int operation, Collection sources, TreeViewer treeViewer) { super(target, location, operations, operation, sources); fTreeViewer = treeViewer; @@ -46,13 +46,14 @@ String undoDesc = new String(); if (getOperation() == DND.DROP_MOVE) { undoDesc = XMLUIMessages.DragNodeCommand_0; - } else if (getOperation() == DND.DROP_COPY) { + } + else if (getOperation() == DND.DROP_COPY) { undoDesc = XMLUIMessages.DragNodeCommand_1; } - + structuredModel.beginRecording(this, undoDesc); if (batchUpdate) { - // structuredModel.aboutToChangeModel(); + // structuredModel.aboutToChangeModel(); } } } @@ -66,18 +67,18 @@ if (source.getNodeType() == Node.ATTRIBUTE_NODE) { Attr sourceAttribute = (Attr) source; Element sourceAttributeOwnerElement = sourceAttribute.getOwnerElement(); - if (parentNode.getNodeType() == Node.ELEMENT_NODE && sourceAttributeOwnerElement != parentNode) { + if ((parentNode.getNodeType() == Node.ELEMENT_NODE) && (sourceAttributeOwnerElement != parentNode)) { result = true; if (!testOnly) { try { - if(getOperation() == DND.DROP_MOVE) { + if (getOperation() == DND.DROP_MOVE) { Element targetElement = (Element) parentNode; sourceAttributeOwnerElement.removeAttributeNode(sourceAttribute); targetElement.getAttributes().setNamedItem(sourceAttribute); fSelections.add(sourceAttribute); } else if (getOperation() == DND.DROP_COPY) { - Attr cloneAttribute = (Attr) sourceAttribute.cloneNode(false); + Attr cloneAttribute = (Attr) sourceAttribute.cloneNode(false); Element targetElement = (Element) parentNode; targetElement.getAttributes().setNamedItem(cloneAttribute); fSelections.add(cloneAttribute); @@ -89,19 +90,20 @@ } } else { - if ((parentNode.getNodeType() == Node.ELEMENT_NODE || parentNode.getNodeType() == Node.DOCUMENT_NODE) && - !(refChild instanceof Attr)) { + if (((parentNode.getNodeType() == Node.ELEMENT_NODE) || (parentNode.getNodeType() == Node.DOCUMENT_NODE)) && !(refChild instanceof Attr)) { result = true; if (!testOnly) { if (isAncestor(source, parentNode)) { - //System.out.println("can not perform this drag drop operation.... todo... pop up dialog"); + // System.out.println("can not perform this drag drop + // operation.... todo... pop up dialog"); } else { - // defect 221055 this test is required or else the node will + // defect 221055 this test is required or else the + // node will // be removed from the tree and the insert will fail if (source != refChild) { - if(getOperation() == DND.DROP_MOVE) { + if (getOperation() == DND.DROP_MOVE) { source.getParentNode().removeChild(source); parentNode.insertBefore(source, refChild); fSelections.add(source); @@ -118,20 +120,20 @@ } return result; } - + private void endModelChange(Node node, boolean batchUpdate) { IStructuredModel structuredModel = getStructuredModel(node); if (structuredModel != null) { structuredModel.endRecording(this); if (batchUpdate) { - // structuredModel.changedModel(); + // structuredModel.changedModel(); } } } public void execute() { executeHelper(false); - + // Make our selection if the treeViewer != null if (fTreeViewer != null) { StructuredSelection structuredSelection = new StructuredSelection(fSelections); @@ -158,9 +160,10 @@ for (Iterator i = sourcesList.iterator(); i.hasNext();) { Object source = i.next(); if (source instanceof Node) { - if (!(refChild == null && targetNode instanceof Attr)) { + if (!((refChild == null) && (targetNode instanceof Attr))) { result = doModify((Node) source, parentNode, refChild, testOnly); - } else { + } + else { result = false; } if (!result) { @@ -171,7 +174,8 @@ if (!testOnly) { endModelChange(targetNode, performBatchUpdate); } - } else { + } + else { result = false; } return result; @@ -182,7 +186,8 @@ int result = DND.FEEDBACK_SELECT; if (location > 0.75) { result = DND.FEEDBACK_INSERT_AFTER; - } else if (location < 0.25) { + } + else if (location < 0.25) { result = DND.FEEDBACK_INSERT_BEFORE; } return result; @@ -194,7 +199,8 @@ int feedback = getFeedback(); if (feedback == DND.FEEDBACK_SELECT) { result = node; - } else { + } + else { result = getParentOrOwner(node); } return result; @@ -213,13 +219,14 @@ if (feedback == DND.FEEDBACK_INSERT_BEFORE) { result = node; - } else if (feedback == DND.FEEDBACK_INSERT_AFTER) { + } + else if (feedback == DND.FEEDBACK_INSERT_AFTER) { result = node.getNextSibling(); } return result; } - private IStructuredModel getStructuredModel (Node node) { + private IStructuredModel getStructuredModel(Node node) { IStructuredModel result = null; if (node instanceof IDOMNode) { result = ((IDOMNode) node).getModel();
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/XMLDragAndDropManager.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/XMLDragAndDropManager.java index aca6ee6..fa32745 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/XMLDragAndDropManager.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/XMLDragAndDropManager.java
@@ -28,7 +28,7 @@ public class XMLDragAndDropManager implements DragAndDropManager { private TreeViewer fViewer; - + public static void addDragAndDropSupport(TreeViewer viewer) { int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers = new Transfer[]{ObjectTransfer.getInstance()}; @@ -39,7 +39,7 @@ public XMLDragAndDropManager() { super(); } - + public XMLDragAndDropManager(TreeViewer viewer) { fViewer = viewer; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/doubleclick/XMLDoubleClickStrategy.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/doubleclick/XMLDoubleClickStrategy.java index 24f7560..1e18345 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/doubleclick/XMLDoubleClickStrategy.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/doubleclick/XMLDoubleClickStrategy.java
@@ -45,32 +45,39 @@ if (fStructuredModel != null) { int caretPosition = textViewer.getSelectedRange().x; - if (caretPosition < 0) + if (caretPosition < 0) { return; + } fNode = (Node) fStructuredModel.getIndexedRegion(caretPosition); - if (fNode == null) + if (fNode == null) { return; + } updateDoubleClickCount(caretPosition); updateStructuredDocumentRegion(); updateTextRegion(); - if (fNode.getNodeType() == Node.TEXT_NODE) + if (fNode.getNodeType() == Node.TEXT_NODE) { processTextDoubleClicked(); - else + } + else { processElementDoubleClicked(); + } } - } finally { - if (fStructuredModel != null) + } + finally { + if (fStructuredModel != null) { fStructuredModel.releaseFromRead(); + } } } } protected Point getWord(String string, int cursor) { - if (string == null) + if (string == null) { return null; + } int wordStart = 0; int wordEnd = string.length(); @@ -80,24 +87,30 @@ wordStart = Math.max(wordStart, temp); temp = string.lastIndexOf(DOUBLE_QUOTE, cursor - 1); wordStart = Math.max(wordStart, temp); - if (wordStart == -1) + if (wordStart == -1) { wordStart = cursor; - else + } + else { wordStart++; + } wordEnd = string.indexOf(SPACE, cursor); - if (wordEnd == -1) + if (wordEnd == -1) { wordEnd = string.length(); + } temp = string.indexOf(SINGLE_QUOTE, cursor); - if (temp == -1) + if (temp == -1) { temp = string.length(); + } wordEnd = Math.min(wordEnd, temp); temp = string.indexOf(DOUBLE_QUOTE, cursor); - if (temp == -1) + if (temp == -1) { temp = string.length(); + } wordEnd = Math.min(wordEnd, temp); - if (wordEnd == string.length()) + if (wordEnd == string.length()) { wordEnd = cursor; + } if ((wordStart == wordEnd) && !isQuoted(string)) { wordStart = 0; @@ -108,8 +121,9 @@ } protected boolean isQuoted(String string) { - if ((string == null) || (string.length() < 2)) + if ((string == null) || (string.length() < 2)) { return false; + } int lastIndex = string.length() - 1; char firstChar = string.charAt(0); @@ -138,7 +152,8 @@ nextRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(nextRegionOffset); if ((nextRegion != null) && (nextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) { fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), nextRegion.getTextEnd() - fTextRegion.getStart()); - } else { + } + else { // attribute has no value fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength()); fDoubleClickCount = 0; @@ -154,23 +169,31 @@ if (word.x == word.y) { // no word found; select whole region fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), regionText.length()); fDoubleClickCount++; - } else + } + else { fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion) + word.x, word.y - word.x); - } else if (fDoubleClickCount == 2) { + } + } + else if (fDoubleClickCount == 2) { if (isQuoted(regionText)) { // ==> // Point word = getWord(regionText, fCaretPosition - // fStructuredDocumentRegion.getStartOffset(fTextRegion)); fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), regionText.length()); - } else + } + else { processElementAttrValueDoubleClicked2Times(); - } else if (fDoubleClickCount == 3) { - if (isQuoted(regionText)) + } + } + else if (fDoubleClickCount == 3) { + if (isQuoted(regionText)) { processElementAttrValueDoubleClicked2Times(); + } else { fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength()); fDoubleClickCount = 0; } - } else { // fDoubleClickCount == 4 + } + else { // fDoubleClickCount == 4 fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength()); fDoubleClickCount = 0; } @@ -190,22 +213,26 @@ } protected void processElementDoubleClicked() { - if (fTextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) + if (fTextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { processElementAttrValueDoubleClicked(); // special handling for - // XML_TAG_ATTRIBUTE_VALUE + } else { if (fDoubleClickCount == 1) { fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart() + fTextRegion.getStart(), fTextRegion.getTextLength()); - } else if (fDoubleClickCount == 2) { - if (fTextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) + } + else if (fDoubleClickCount == 2) { + if (fTextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) { processElementAttrNameDoubleClicked2Times(); - else if (fTextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) + } + else if (fTextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) { processElementAttrEqualsDoubleClicked2Times(); + } else { fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength()); fDoubleClickCount = 0; } - } else { // fDoubleClickCount == 3 + } + else { // fDoubleClickCount == 3 fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength()); fDoubleClickCount = 0; } @@ -217,26 +244,34 @@ super.doubleClicked(fStructuredTextViewer); Point selectedRange = fStructuredTextViewer.getSelectedRange(); - if ((selectedRange.x == fStructuredDocumentRegion.getStartOffset(fTextRegion)) && (selectedRange.y == fTextRegion.getTextLength())) + if ((selectedRange.x == fStructuredDocumentRegion.getStartOffset(fTextRegion)) && (selectedRange.y == fTextRegion.getTextLength())) { // only one word in region, skip one level of double click // selection fDoubleClickCount++; - } else if (fDoubleClickCount == 2) { + } + } + else if (fDoubleClickCount == 2) { if (fTextRegion.getType() == DOMRegionContext.UNDEFINED) { fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength()); fDoubleClickCount = 0; - } else { - if (isQuoted(fStructuredDocumentRegion.getFullText(fTextRegion))) - fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion) + 1, fTextRegion.getTextLength() - 2); - else - fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), fTextRegion.getTextLength()); } - } else { - if ((fDoubleClickCount == 3) && isQuoted(fStructuredDocumentRegion.getFullText(fTextRegion))) - fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), fTextRegion.getTextLength()); else { - if ((fDoubleClickCount == 3) && isQuoted(fStructuredDocumentRegionText)) + if (isQuoted(fStructuredDocumentRegion.getFullText(fTextRegion))) { + fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion) + 1, fTextRegion.getTextLength() - 2); + } + else { + fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), fTextRegion.getTextLength()); + } + } + } + else { + if ((fDoubleClickCount == 3) && isQuoted(fStructuredDocumentRegion.getFullText(fTextRegion))) { + fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), fTextRegion.getTextLength()); + } + else { + if ((fDoubleClickCount == 3) && isQuoted(fStructuredDocumentRegionText)) { fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart() + 1, fStructuredDocumentRegion.getLength() - 2); + } else { fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength()); fDoubleClickCount = 0; @@ -251,11 +286,14 @@ protected void updateDoubleClickCount(int caretPosition) { if (fCaretPosition == caretPosition) { - if (fStructuredDocumentRegion != null) + if (fStructuredDocumentRegion != null) { fDoubleClickCount++; - else + } + else { fDoubleClickCount = 1; - } else { + } + } + else { fCaretPosition = caretPosition; fDoubleClickCount = 1; } @@ -263,10 +301,12 @@ protected void updateStructuredDocumentRegion() { fStructuredDocumentRegion = fStructuredModel.getStructuredDocument().getRegionAtCharacterOffset(fCaretPosition); - if (fStructuredDocumentRegion != null) + if (fStructuredDocumentRegion != null) { fStructuredDocumentRegionText = fStructuredDocumentRegion.getText(); - else + } + else { fStructuredDocumentRegionText = ""; //$NON-NLS-1$ + } } protected void updateTextRegion() { @@ -279,7 +319,9 @@ if (fTextRegion == null) { fTextRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(fCaretPosition - 1); } - } else + } + else { fTextRegion = null; + } } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/CMImageUtil.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/CMImageUtil.java index e106190..7311b66 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/CMImageUtil.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/CMImageUtil.java
@@ -51,8 +51,9 @@ } public static Image getImage(CMNode cmnode) { - if (cmnode == null) + if (cmnode == null) { return null; + } Image image = null; ImageDescriptor descriptor = getImageDescriptor(cmnode); if (descriptor != null) { @@ -62,14 +63,14 @@ } public static ImageDescriptor getImageDescriptor(CMNode cmnode) { - if (cmnode == null) + if (cmnode == null) { return null; + } // cache CM-specified images with the XML UI plugin String imageURLString = (String) cmnode.getProperty("small-icon"); //$NON-NLS-1$ ImageDescriptor descriptor = null; - if (imageURLString != null && imageURLString.length() > 0) { - descriptor = XMLUIPlugin.getInstance().getImageRegistry() - .getDescriptor(imageURLString); + if ((imageURLString != null) && (imageURLString.length() > 0)) { + descriptor = XMLUIPlugin.getInstance().getImageRegistry().getDescriptor(imageURLString); if (descriptor == null) { try { URL imageURL = new URL(imageURLString); @@ -77,11 +78,12 @@ connection.setUseCaches(false); ImageData data = new ImageData(connection.getInputStream()); descriptor = ImageDescriptor.createFromImageData(data); - XMLUIPlugin.getInstance().getImageRegistry().put( - imageURLString, descriptor); - } catch (MalformedURLException e) { + XMLUIPlugin.getInstance().getImageRegistry().put(imageURLString, descriptor); + } + catch (MalformedURLException e) { descriptor = null; - } catch (IOException e) { + } + catch (IOException e) { descriptor = null; } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImageHelper.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImageHelper.java index 32338df..8610595 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImageHelper.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImageHelper.java
@@ -39,12 +39,13 @@ * @return Returns a XMLEditorPluginImageHelper */ public synchronized static XMLEditorPluginImageHelper getInstance() { - if (instance == null) + if (instance == null) { instance = new XMLEditorPluginImageHelper(); + } return instance; } - // save a descriptor for each image + // save a descriptor for each image private HashMap fImageDescRegistry = null; private final String PLUGINID = XMLUIPlugin.ID; @@ -63,8 +64,9 @@ image = desc.createImage(); // dont add the missing image descriptor image to the image // registry - if (!desc.equals(ImageDescriptor.getMissingImageDescriptor())) + if (!desc.equals(ImageDescriptor.getMissingImageDescriptor())) { getImageRegistry().put(resource, image); + } } return image; } @@ -83,7 +85,8 @@ ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(PLUGINID, imageFilePath); if (imageDescriptor != null) { getImageDescriptorRegistry().put(imageFilePath, imageDescriptor); - } else { + } + else { imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); } @@ -125,9 +128,10 @@ ImageDescriptor imageDescriptor = null; Object o = getImageDescriptorRegistry().get(resource); if (o == null) { - //create a descriptor + // create a descriptor imageDescriptor = createImageDescriptor(resource); - } else { + } + else { imageDescriptor = (ImageDescriptor) o; } return imageDescriptor; @@ -139,8 +143,9 @@ * @return HashMap - image descriptor registry for this plugin */ private HashMap getImageDescriptorRegistry() { - if (fImageDescRegistry == null) + if (fImageDescRegistry == null) { fImageDescRegistry = new HashMap(); + } return fImageDescRegistry; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImages.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImages.java index f25a458..f6b54ba 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImages.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImages.java
@@ -41,9 +41,9 @@ public static final String IMG_OBJ_LOCAL_VARIABLE = "icons/full/obj16/localvariable_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJ_NOTATION = "icons/full/obj16/notation.gif"; //$NON-NLS-1$ public static final String IMG_OBJ_PROCESSINGINSTRUCTION = "icons/full/obj16/proinst_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG_GENERIC = "icons/full/obj16/tag-generic.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG_GENERIC_DEEMPHASIZED = "icons/full/obj16/tag-generic-deemphasized.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG_GENERIC_EMPHASIZED = "icons/full/obj16/tag-generic-emphasized.gif"; //$NON-NLS-1$ + public static final String IMG_OBJ_TAG_GENERIC = "icons/full/obj16/tag-generic.gif"; //$NON-NLS-1$ + public static final String IMG_OBJ_TAG_GENERIC_DEEMPHASIZED = "icons/full/obj16/tag-generic-deemphasized.gif"; //$NON-NLS-1$ + public static final String IMG_OBJ_TAG_GENERIC_EMPHASIZED = "icons/full/obj16/tag-generic-emphasized.gif"; //$NON-NLS-1$ public static final String IMG_OBJ_TAG_MACRO = "icons/full/obj16/tag-macro.gif"; //$NON-NLS-1$ public static final String IMG_OBJ_TXTEXT = "icons/full/obj16/text.gif"; //$NON-NLS-1$ public static final String IMG_OBJ_WARNING_OBJ = "icons/full/obj16/warning_obj.gif"; //$NON-NLS-1$ @@ -52,6 +52,6 @@ public static final String IMG_OVR_ERROR = "icons/full/ovr16/error_ovr.gif"; //$NON-NLS-1$ public static final String IMG_OVR_STALE_ERROR = "icons/full/ovr16/stale_error_ovr.gif"; //$NON-NLS-1$ public static final String IMG_OVR_WARN = "icons/full/ovr16/warn_ovr.gif"; //$NON-NLS-1$ - - public static final String IMG_WIZBAN_GENERATEXML = "icons/full/wizban/generatexml_wiz.png"; //$NON-NLS-1$ + + public static final String IMG_WIZBAN_GENERATEXML = "icons/full/wizban/generatexml_wiz.png"; //$NON-NLS-1$ }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileEditorInput.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileEditorInput.java index 18e86fb..38cf5e3 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileEditorInput.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileEditorInput.java
@@ -21,7 +21,7 @@ // org.eclipse.wst.xml.ui.internal.hyperlink // org.eclipse.wst.html.ui.internal.hyperlink // org.eclipse.jst.jsp.ui.internal.hyperlink - + /** * The workbench adapter which simply provides the label. */ @@ -103,10 +103,12 @@ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ public Object getAdapter(Class adapter) { - if (ILocationProvider.class.equals(adapter)) + if (ILocationProvider.class.equals(adapter)) { return this; - if (IWorkbenchAdapter.class.equals(adapter)) + } + if (IWorkbenchAdapter.class.equals(adapter)) { return fWorkbenchAdapter; + } return Platform.getAdapterManager().getAdapter(this, adapter); } @@ -120,31 +122,32 @@ } return null; } - - /* - * @see org.eclipse.ui.IPathEditorInput#getPath() - * @since 3.1 - */ - public IPath getPath() { - return Path.fromOSString(fFile.getAbsolutePath()); - } + + /* + * @see org.eclipse.ui.IPathEditorInput#getPath() + * @since 3.1 + */ + public IPath getPath() { + return Path.fromOSString(fFile.getAbsolutePath()); + } /* * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object o) { - if (o == this) + if (o == this) { return true; + } if (o instanceof ExternalFileEditorInput) { ExternalFileEditorInput input = (ExternalFileEditorInput) o; return fFile.equals(input.fFile); } - - if (o instanceof IPathEditorInput) { - IPathEditorInput input= (IPathEditorInput)o; - return getPath().equals(input.getPath()); - } + + if (o instanceof IPathEditorInput) { + IPathEditorInput input = (IPathEditorInput) o; + return getPath().equals(input.getPath()); + } return false; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileHyperlink.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileHyperlink.java index f96a072..fb900ee 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileHyperlink.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileHyperlink.java
@@ -20,7 +20,7 @@ // org.eclipse.wst.xml.ui.internal.hyperlink // org.eclipse.wst.html.ui.internal.hyperlink // org.eclipse.jst.jsp.ui.internal.hyperlink - + private IRegion fHyperlinkRegion; private File fHyperlinkFile; @@ -28,7 +28,7 @@ fHyperlinkFile = file; fHyperlinkRegion = region; } - + public IRegion getHyperlinkRegion() { return fHyperlinkRegion; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/WorkspaceFileHyperlink.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/WorkspaceFileHyperlink.java index 23fe9cb..2dde689 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/WorkspaceFileHyperlink.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/WorkspaceFileHyperlink.java
@@ -61,12 +61,12 @@ } public void open() { - if (fFile != null && fFile.exists()) { + if ((fFile != null) && fFile.exists()) { try { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IEditorPart editor = IDE.openEditor(page, fFile, true); // highlight range in editor if possible - if (fHighlightRange != null && editor instanceof ITextEditor) { + if ((fHighlightRange != null) && (editor instanceof ITextEditor)) { ((ITextEditor) editor).setHighlightRange(fHighlightRange.getOffset(), fHighlightRange.getLength(), true); } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java index de5c4b3..98b620b 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java
@@ -93,7 +93,7 @@ // for now, only capable of creating 1 hyperlink List hyperlinks = new ArrayList(0); - if (region != null && textViewer != null) { + if ((region != null) && (textViewer != null)) { IDocument document = textViewer.getDocument(); Node currentNode = getCurrentNode(document, region.getOffset()); if (currentNode != null) { @@ -110,9 +110,10 @@ // resolve attribute value uriString = getURIString(currentAttr, document); // verify validity of uri string - if (uriString == null || !isValidURI(uriString)) + if ((uriString == null) || !isValidURI(uriString)) { // reset current attribute currentAttr = null; + } } if (currentAttr == null) { // try to find a linkable attribute within element @@ -124,7 +125,7 @@ currentNode = currentAttr; } // try to create hyperlink from information gathered - if (uriString != null && currentNode != null && isValidURI(uriString)) { + if ((uriString != null) && (currentNode != null) && isValidURI(uriString)) { IRegion hyperlinkRegion = getHyperlinkRegion(currentNode); IHyperlink hyperlink = createHyperlink(uriString, hyperlinkRegion, document, currentNode); if (hyperlink != null) { @@ -133,8 +134,9 @@ } } } - if (hyperlinks.size() == 0) + if (hyperlinks.size() == 0) { return null; + } return (IHyperlink[]) hyperlinks.toArray(new IHyperlink[0]); } @@ -154,10 +156,12 @@ baseLoc = location.toString(); } else { - if (location.segmentCount() > 1) + if (location.segmentCount() > 1) { baseLoc = ResourcesPlugin.getWorkspace().getRoot().getFile(location).getLocation().toString(); - else + } + else { baseLoc = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(location).toString(); + } } } } @@ -223,15 +227,17 @@ IStructuredModel sModel = null; try { sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document); - if(sModel != null) { + if (sModel != null) { inode = sModel.getIndexedRegion(offset); - if (inode == null) + if (inode == null) { inode = sModel.getIndexedRegion(offset - 1); + } } } finally { - if (sModel != null) + if (sModel != null) { sModel.releaseFromRead(); + } } if (inode instanceof Node) { @@ -253,9 +259,11 @@ if (fileString != null) { IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(fileString)); - for (int i = 0; i < files.length && file == null; i++) - if (files[i].exists()) + for (int i = 0; (i < files.length) && (file == null); i++) { + if (files[i].exists()) { file = files[i]; + } + } } return file; @@ -355,8 +363,9 @@ String publicId = st.hasMoreTokens() ? st.nextToken() : null; String systemId = st.hasMoreTokens() ? st.nextToken() : null; // found location hint - if (namespaceURI.equalsIgnoreCase(publicId)) + if (namespaceURI.equalsIgnoreCase(publicId)) { return systemId; + } } } return null; @@ -388,9 +397,9 @@ String attrName = attrNode.getName(); String attrValue = attrNode.getValue(); attrValue = StringUtils.strip(attrValue); - if (attrValue != null && attrValue.length() > 0) { + if ((attrValue != null) && (attrValue.length() > 0)) { baseLoc = getBaseLocation(document); - + // handle schemaLocation attribute String prefix = DOMNamespaceHelper.getPrefix(attrName); String unprefixedName = DOMNamespaceHelper.getUnprefixedName(attrName); @@ -429,8 +438,9 @@ boolean isHttp = false; if (uriString != null) { String tempString = uriString.toLowerCase(); - if (tempString.startsWith(HTTP_PROTOCOL)) + if (tempString.startsWith(HTTP_PROTOCOL)) { isHttp = true; + } } return isHttp; } @@ -452,12 +462,14 @@ String prefix = DOMNamespaceHelper.getPrefix(attrName); String unprefixedName = DOMNamespaceHelper.getUnprefixedName(attrName); // determine if attribute is namespace declaration - if ((XMLNS.equals(prefix)) || (XMLNS.equals(unprefixedName))) + if ((XMLNS.equals(prefix)) || (XMLNS.equals(unprefixedName))) { return true; + } // determine if attribute contains schema location - if ((XSI_NAMESPACE_URI.equals(DOMNamespaceHelper.getNamespaceURI(attr))) && ((SCHEMA_LOCATION.equals(unprefixedName)) || (NO_NAMESPACE_SCHEMA_LOCATION.equals(unprefixedName)))) + if ((XSI_NAMESPACE_URI.equals(DOMNamespaceHelper.getNamespaceURI(attr))) && ((SCHEMA_LOCATION.equals(unprefixedName)) || (NO_NAMESPACE_SCHEMA_LOCATION.equals(unprefixedName)))) { return true; + } // determine if attribute value is of type URI if (cmElement != null) { @@ -478,12 +490,14 @@ private boolean isValidURI(String uriString) { boolean isValid = false; - if (isHttp(uriString)) + if (isHttp(uriString)) { isValid = true; + } else { File file = getFileFromUriString(uriString); - if (file != null) + if (file != null) { isValid = file.isFile(); + } } return isValid; } @@ -498,8 +512,9 @@ */ private String resolveURI(String baseLocation, String publicId, String systemId) { // dont resolve if there's nothing to resolve - if ((baseLocation == null) && (publicId == null) && (systemId == null)) + if ((baseLocation == null) && (publicId == null) && (systemId == null)) { return null; + } return URIResolverPlugin.createResolver().resolve(baseLocation, publicId, systemId); } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesControl.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesControl.java index e45bc98..357ef53 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesControl.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesControl.java
@@ -44,15 +44,15 @@ Text prefixField; Text uriField; - //protected NamespaceInfo info; + // protected NamespaceInfo info; public EditNamespaceControl(Composite parent) { - super(parent, SWT.NONE); //BORDER); + super(parent, SWT.NONE); // BORDER); setLayout(new GridLayout()); setLayoutData(new GridData(GridData.FILL_BOTH)); Label label = new Label(this, SWT.NONE); - label.setText(XMLUIMessages._UI_ENTER_REQ_PREFIX_AND_NAMESPACE); //$NON-NLS-1$ + label.setText(XMLUIMessages._UI_ENTER_REQ_PREFIX_AND_NAMESPACE); Composite composite = new Composite(this, SWT.NONE); GridLayout layout = new GridLayout(); @@ -68,39 +68,39 @@ // row 1 // Label prefixLabel = new Label(composite, SWT.NONE); - prefixLabel.setText(XMLUIMessages._UI_LABEL_PREFIX_COLON); //$NON-NLS-1$ + prefixLabel.setText(XMLUIMessages._UI_LABEL_PREFIX_COLON); prefixField = new Text(composite, SWT.SINGLE | SWT.BORDER); prefixField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - //prefixField.setText(getDisplayValue(info.prefix)); - //prefixField.addModifyListener(modifyListener); - //prefixField.setEnabled(info.getProperty("prefix-readOnly") == + // prefixField.setText(getDisplayValue(info.prefix)); + // prefixField.addModifyListener(modifyListener); + // prefixField.setEnabled(info.getProperty("prefix-readOnly") == // null); new Label(composite, SWT.NONE); // row 2 // Label uriLabel = new Label(composite, SWT.NONE); - uriLabel.setText(XMLUIMessages._UI_LABEL_NAMESPACE_NAME_COLON); //$NON-NLS-1$ + uriLabel.setText(XMLUIMessages._UI_LABEL_NAMESPACE_NAME_COLON); uriField = new Text(composite, SWT.SINGLE | SWT.BORDER); uriField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - //uriField.setText(getDisplayValue(info.uri)); - //uriField.addModifyListener(modifyListener); - //uriField.setEnabled(info.getProperty("uri-readOnly") == null); + // uriField.setText(getDisplayValue(info.uri)); + // uriField.addModifyListener(modifyListener); + // uriField.setEnabled(info.getProperty("uri-readOnly") == null); new Label(composite, SWT.NONE); // row 3 // Label locationHintLabel = new Label(composite, SWT.NONE); - locationHintLabel.setText(XMLUIMessages._UI_LABEL_LOCATION_HINT_COLON); //$NON-NLS-1$ + locationHintLabel.setText(XMLUIMessages._UI_LABEL_LOCATION_HINT_COLON); locationHintField = new Text(composite, SWT.SINGLE | SWT.BORDER); locationHintField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - //locationHintField.setText(getDisplayValue(info.locationHint)); - //locationHintField.addModifyListener(modifyListener); - //locationHintField.setEnabled(info.getProperty("locationHint-readOnly") + // locationHintField.setText(getDisplayValue(info.locationHint)); + // locationHintField.addModifyListener(modifyListener); + // locationHintField.setEnabled(info.getProperty("locationHint-readOnly") // == null); SelectionListener selectionListener = new SelectionAdapter() { @@ -110,7 +110,7 @@ }; browseButton = new Button(composite, SWT.NONE); - browseButton.setText(XMLUIMessages._UI_LABEL_BROWSE); //$NON-NLS-1$ + browseButton.setText(XMLUIMessages._UI_LABEL_BROWSE); browseButton.addSelectionListener(selectionListener); browseButton.setEnabled(locationHintField.getEnabled()); } @@ -119,49 +119,52 @@ String[] extensions = {".xsd"}; //$NON-NLS-1$ SelectFileOrXMLCatalogIdDialog dialog = new SelectFileOrXMLCatalogIdDialog(getShell(), extensions); dialog.create(); - dialog.getShell().setText(XMLUIMessages._UI_LABEL_SELECT_FILE); //$NON-NLS-1$ + dialog.getShell().setText(XMLUIMessages._UI_LABEL_SELECT_FILE); dialog.setBlockOnOpen(true); dialog.open(); if (dialog.getReturnCode() == Window.OK) { - //String grammarURI = null; + // String grammarURI = null; IFile file = dialog.getFile(); String id = dialog.getId(); if (file != null) { String uri = null; if (resourceLocation != null) { uri = URIHelper.getRelativeURI(file.getLocation(), resourceLocation); - //grammarURI = file.getLocation().toOSString(); - } else { + // grammarURI = file.getLocation().toOSString(); + } + else { uri = file.getLocation().toOSString(); - //grammarURI = uri; + // grammarURI = uri; } locationHintField.setText(uri); - } else if (id != null) { + } + else if (id != null) { locationHintField.setText(id); - //URIResolver resolver = - URIResolverPlugin.createResolver(); - //grammarURI = resolver.resolve(null, id, id); + // URIResolver resolver = + URIResolverPlugin.createResolver(); + // grammarURI = resolver.resolve(null, id, id); } try { - //TODO CMDocument document = + // TODO CMDocument document = // CMDocumentBuilderRegistry.getInstance().buildCMDocument(grammarURI); - // List namespaceInfoList = + // List namespaceInfoList = // (List)document.getProperty("http://org.eclipse.wst/cm/properties/namespaceInfo"); - // NamespaceInfo info = + // NamespaceInfo info = // (NamespaceInfo)namespaceInfoList.get(0); - // if (uriField.getText().trim().length() == 0 && info.uri + // if (uriField.getText().trim().length() == 0 && info.uri // != null) - // { - // uriField.setText(info.uri); - // } - // if (prefixField.getText().trim().length() == 0 && + // { + // uriField.setText(info.uri); + // } + // if (prefixField.getText().trim().length() == 0 && // info.prefix != null) - // { - // prefixField.setText(info.prefix); - // } - } catch (Exception e) { + // { + // prefixField.setText(info.prefix); + // } + } + catch (Exception e) { } } } @@ -196,27 +199,27 @@ setLayout(new GridLayout()); radio1 = new Button(this, SWT.RADIO); - radio1.setText(XMLUIMessages._UI_SELECT_REGISTERED_NAMESPACES); //$NON-NLS-1$ + radio1.setText(XMLUIMessages._UI_SELECT_REGISTERED_NAMESPACES); radio1.addSelectionListener(this); radio2 = new Button(this, SWT.RADIO); - radio2.setText(XMLUIMessages._UI_SPECIFY_NEW_NAMESPACE); //$NON-NLS-1$ + radio2.setText(XMLUIMessages._UI_SPECIFY_NEW_NAMESPACE); radio2.addSelectionListener(this); Label separator = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - //Group namespaceInfoGroup = new Group(this, SWT.NONE); - //namespaceInfoGroup.setText("Namespace Declarations"); + // Group namespaceInfoGroup = new Group(this, SWT.NONE); + // namespaceInfoGroup.setText("Namespace Declarations"); // //XMLCommonUIPlugin.getInstance().getString("_UI_LABEL_XML_SCHEMA_INFORMATION")); - //namespaceInfoGroup.setLayout(new GridLayout(2, false)); - //namespaceInfoGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); + // namespaceInfoGroup.setLayout(new GridLayout(2, false)); + // namespaceInfoGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); pageBook = new PageBook(this, SWT.NONE); pageBook.setLayoutData(new GridData(GridData.FILL_BOTH)); tableSection = new Composite(pageBook, SWT.NONE); tableSection.setLayout(new GridLayout()); Label label = new Label(tableSection, SWT.NONE); - label.setText(XMLUIMessages._UI_SELECT_NAMESPACE_TO_ADD); //$NON-NLS-1$ + label.setText(XMLUIMessages._UI_SELECT_NAMESPACE_TO_ADD); tableViewer = new CommonNamespaceInfoTable(tableSection, SWT.CHECK, 6); editNamespaceControl = new EditNamespaceControl(pageBook); @@ -237,7 +240,8 @@ list.add(item.getData()); } } - } else { + } + else { NamespaceInfo info = new NamespaceInfo(); info.prefix = editNamespaceControl.prefixField.getText(); info.uri = editNamespaceControl.uriField.getText(); @@ -258,7 +262,8 @@ public void widgetSelected(SelectionEvent e) { if (e.widget == radio1) { pageBook.showPage(tableSection); - } else if (e.widget == radio2) { + } + else if (e.widget == radio2) { pageBook.showPage(editNamespaceControl); } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesDialog.java index b084aea..d3fa611 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesDialog.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesDialog.java
@@ -72,9 +72,9 @@ protected void addCatalogMapToList(ICatalog catalog, List list) { ICatalogEntry[] entries = catalog.getCatalogEntries(); - for ( int i = 0; i < entries.length; i++) { + for (int i = 0; i < entries.length; i++) { ICatalogEntry entry = entries[i]; - if (entry.getEntryType() == ICatalogEntry.ENTRY_TYPE_PUBLIC && entry.getURI().endsWith(".xsd")) { //$NON-NLS-1$ + if ((entry.getEntryType() == ICatalogEntry.ENTRY_TYPE_PUBLIC) && entry.getURI().endsWith(".xsd")) { //$NON-NLS-1$ if (!isAlreadyDeclared(entry.getKey())) { NamespaceInfo namespaceInfo = new NamespaceInfo(entry.getKey(), "xx", null); //$NON-NLS-1$ list.add(namespaceInfo); @@ -137,27 +137,22 @@ addBuiltInNamespaces(list); ICatalog defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog(); INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs(); - for (int i = 0; i < nextCatalogs.length; i++) - { - INextCatalog catalog = nextCatalogs[i]; - ICatalog referencedCatalog = catalog.getReferencedCatalog(); - if (referencedCatalog != null) - { - if (XMLCorePlugin.USER_CATALOG_ID - .equals(referencedCatalog.getId())) - { - ICatalog userCatalog = referencedCatalog; - addCatalogMapToList(userCatalog, list); + for (int i = 0; i < nextCatalogs.length; i++) { + INextCatalog catalog = nextCatalogs[i]; + ICatalog referencedCatalog = catalog.getReferencedCatalog(); + if (referencedCatalog != null) { + if (XMLCorePlugin.USER_CATALOG_ID.equals(referencedCatalog.getId())) { + ICatalog userCatalog = referencedCatalog; + addCatalogMapToList(userCatalog, list); - } else if (XMLCorePlugin.SYSTEM_CATALOG_ID - .equals(referencedCatalog.getId())) - { - ICatalog systemCatalog = referencedCatalog; - addCatalogMapToList(systemCatalog, list); - } - } - } - + } + else if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) { + ICatalog systemCatalog = referencedCatalog; + addCatalogMapToList(systemCatalog, list); + } + } + } + computeAddablePrefixes(list, existingNamespaces); addNamespacesControl.setNamespaceInfoList(list); @@ -180,7 +175,7 @@ lastIndex = uri.lastIndexOf('/'); } prefix = uri.substring(lastIndex + 1); - if (prefix.length() > 20 || prefix.indexOf(':') != -1) { + if ((prefix.length() > 20) || (prefix.indexOf(':') != -1)) { prefix = null; } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesDialog.java index dc0d9c3..a2fa0c0 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesDialog.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesDialog.java
@@ -92,7 +92,8 @@ // Create the 'common'/middle Composite if (useGroup) { commonComposite = new Group(parent, SWT.NONE); - } else { + } + else { commonComposite = new Composite(parent, SWT.NONE); } commonComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); @@ -121,9 +122,11 @@ public void widgetSelected(SelectionEvent e) { if (e.widget == newButton) { performNew(); - } else if (e.widget == editButton) { + } + else if (e.widget == editButton) { performEdit(); - } else if (e.widget == deleteButton) { + } + else if (e.widget == deleteButton) { performDelete(); } } @@ -133,46 +136,47 @@ Composite buttonComposite = new Composite(composite, SWT.NONE); buttonComposite.setLayoutData(createHorizontalFill()); GridLayout buttonGridLayout = new GridLayout(); - //buttonGridLayout.numColumns = 3; - //buttonGridLayout.makeColumnsEqualWidth = true; + // buttonGridLayout.numColumns = 3; + // buttonGridLayout.makeColumnsEqualWidth = true; buttonComposite.setLayout(buttonGridLayout); // add the New button // newButton = new Button(buttonComposite, SWT.NONE); - //newButton.setText(" " + + // newButton.setText(" " + // XMLCommonUIPlugin.getInstance().getString("_UI_BUTTON_NEW") + " "); - newButton.setText(" " + XMLUIMessages.CommonEditNamespacesDialog_0 + " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - newButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); //ViewUtility.createHorizontalFill()); + newButton.setText(" " + XMLUIMessages.CommonEditNamespacesDialog_0 + " "); //$NON-NLS-1$ //$NON-NLS-2$ + newButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // ViewUtility.createHorizontalFill()); newButton.addSelectionListener(selectionListener); // add the Edit button // - //gd = new GridData(); - //gd.horizontalAlignment = gd.FILL; - //gd.grabExcessHorizontalSpace = true; + // gd = new GridData(); + // gd.horizontalAlignment = gd.FILL; + // gd.grabExcessHorizontalSpace = true; editButton = new Button(buttonComposite, SWT.NONE); - editButton.setText(XMLUIMessages._UI_BUTTON_EDIT); //$NON-NLS-1$ - editButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); //ViewUtility.createHorizontalFill()); + editButton.setText(XMLUIMessages._UI_BUTTON_EDIT); + editButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // ViewUtility.createHorizontalFill()); editButton.addSelectionListener(selectionListener); // add the Delete button // - //gd = new GridData(); - //gd.horizontalAlignment = gd.FILL; - //gd.grabExcessHorizontalSpace = true; + // gd = new GridData(); + // gd.horizontalAlignment = gd.FILL; + // gd.grabExcessHorizontalSpace = true; deleteButton = new Button(buttonComposite, SWT.NONE); - deleteButton.setText(XMLUIMessages._UI_BUTTON_DELETE); //$NON-NLS-1$ - deleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); //ViewUtility.createHorizontalFill()); + deleteButton.setText(XMLUIMessages._UI_BUTTON_DELETE); + deleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // ViewUtility.createHorizontalFill()); deleteButton.addSelectionListener(selectionListener); } private void createControlArea() { if (useGroup) { ((Group) commonComposite).setText(tableLabel); - } else { + } + else { Label label = new Label(commonComposite, SWT.NONE); label.setText(tableLabel); label.setLayoutData(createGridData(false, 3)); @@ -211,7 +215,7 @@ NamespaceInfo result = null; for (Iterator i = namespaceInfoList.iterator(); i.hasNext();) { NamespaceInfo info = (NamespaceInfo) i.next(); - if (info.uri != null && info.uri.equals(namespace)) { + if ((info.uri != null) && info.uri.equals(namespace)) { result = info; break; } @@ -263,10 +267,10 @@ * tableViewer.refresh(); } }; * Display.getCurrent().asyncExec(delayedUpdate); */ - //if (updateListener != null) - //{ - // updateListener.updateOccured(this, namespaceInfoList); - //} + // if (updateListener != null) + // { + // updateListener.updateOccured(this, namespaceInfoList); + // } } public void performDelete() { @@ -282,7 +286,7 @@ public void performEdit() { Object selection = getSelection(tableViewer.getSelection()); if (selection != null) { - invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, (NamespaceInfo) selection); //$NON-NLS-1$ + invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, (NamespaceInfo) selection); updateErrorMessage(namespaceInfoList); performDelayedUpdate(); } @@ -290,7 +294,7 @@ public void performNew() { Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell(); - CommonAddNamespacesDialog dialog = new CommonAddNamespacesDialog(shell, XMLUIMessages._UI_ADD_NAMESPACE_DECLARATIONS, resourceLocation, namespaceInfoList); //$NON-NLS-1$ + CommonAddNamespacesDialog dialog = new CommonAddNamespacesDialog(shell, XMLUIMessages._UI_ADD_NAMESPACE_DECLARATIONS, resourceLocation, namespaceInfoList); dialog.createAndOpen(); if (dialog.getReturnCode() == Window.OK) { namespaceInfoList.addAll(dialog.getNamespaceInfoList()); @@ -308,7 +312,7 @@ Object selection = getSelection(tableViewer.getSelection()); NamespaceInfo info = (NamespaceInfo) selection; editButton.setEnabled(info != null); - deleteButton.setEnabled(info != null && info.getProperty("unremovable") == null); //$NON-NLS-1$ + deleteButton.setEnabled((info != null) && (info.getProperty("unremovable") == null)); //$NON-NLS-1$ } public void updateErrorMessage(List namespaceInfoList) {
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesTargetFieldDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesTargetFieldDialog.java index fbae406..7f3366a 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesTargetFieldDialog.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesTargetFieldDialog.java
@@ -41,7 +41,7 @@ protected Text targetNamespaceField; public CommonEditNamespacesTargetFieldDialog(Composite parent, IPath resourceLocation1) { - super(parent, resourceLocation1, XMLUIMessages._UI_NAMESPACE_DECLARATIONS); //$NON-NLS-1$ + super(parent, resourceLocation1, XMLUIMessages._UI_NAMESPACE_DECLARATIONS); Composite targetComp = getTopComposite(); targetComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -49,7 +49,7 @@ GridData gd = new GridData(GridData.FILL_BOTH); Label targetNamespaceLabel = new Label(targetComp, SWT.NONE); targetNamespaceLabel.setLayoutData(gd); - targetNamespaceLabel.setText(XMLUIMessages._UI_TARGET_NAMESPACE); //$NON-NLS-1$ + targetNamespaceLabel.setText(XMLUIMessages._UI_TARGET_NAMESPACE); targetNamespaceField = new Text(targetComp, SWT.BORDER); targetNamespaceField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -71,7 +71,7 @@ editTargetNamespace = true; } - invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, nsInfo); //$NON-NLS-1$ + invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, nsInfo); updateErrorMessage(namespaceInfoList); performDelayedUpdate();
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonNamespaceInfoTable.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonNamespaceInfoTable.java index ebb373a..90fd0f1 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonNamespaceInfoTable.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonNamespaceInfoTable.java
@@ -48,11 +48,11 @@ int columnCode = getColumnCode(columnIndex); if (columnCode == COLUMN_LOCATION_HINT) { NamespaceInfo info = (NamespaceInfo) object; - if (info.locationHint == null || info.locationHint.trim().equals("")) { //$NON-NLS-1$ + if ((info.locationHint == null) || info.locationHint.trim().equals("")) { //$NON-NLS-1$ // Comment this out until we solve the alignment/(space // for image being allocated // to prefix column) ...... - // result = + // result = // XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_WARNING_OBJ); } } @@ -74,7 +74,7 @@ break; } case COLUMN_CHECKBOX : { - result = ""; //info.locationHint; //$NON-NLS-1$ + result = ""; // info.locationHint; //$NON-NLS-1$ break; } case COLUMN_LOCATION_HINT : { @@ -86,11 +86,11 @@ if (result.equals("")) { //$NON-NLS-1$ switch (columnCode) { case COLUMN_PREFIX : { - result = XMLUIMessages._UI_NO_PREFIX; //$NON-NLS-1$ + result = XMLUIMessages._UI_NO_PREFIX; break; } case COLUMN_NAMESPACE_URI : { - result = XMLUIMessages._UI_NO_NAMESPACE_NAME; //$NON-NLS-1$ + result = XMLUIMessages._UI_NO_NAMESPACE_NAME; break; } } @@ -116,16 +116,18 @@ if (obj != null) { NamespaceInfo info = (NamespaceInfo) obj; TableColumn col = getTable().getColumn(0); - if (e.x < col.getWidth()) // if the point falls within the + if (e.x < col.getWidth()) // if the point falls within + // the // Select column then perform // check/uncheck { String currentState = (String) info.getProperty("checked"); //$NON-NLS-1$ System.out.println("currentState" + currentState); //$NON-NLS-1$ - if (currentState == null || currentState.equals("false")) //$NON-NLS-1$ + if ((currentState == null) || currentState.equals("false")) //$NON-NLS-1$ { info.setProperty("checked", "true"); //$NON-NLS-1$ //$NON-NLS-2$ - } else { + } + else { info.setProperty("checked", "false"); //$NON-NLS-1$ //$NON-NLS-2$ } refresh(); @@ -141,12 +143,12 @@ protected static final int COLUMN_PREFIX = 3; protected static final String LABEL_CHECKBOX = ""; //$NON-NLS-1$ - protected static final String LABEL_LOCATION_HINT = XMLUIMessages._UI_LABEL_LOCATION_HINT; //$NON-NLS-1$ - protected static final String LABEL_NAMESPACE_URI = XMLUIMessages._UI_LABEL_NAMESPACE_NAME; //$NON-NLS-1$ - protected static final String LABEL_PREFIX = XMLUIMessages._UI_LABEL_PREFIX; //$NON-NLS-1$ + protected static final String LABEL_LOCATION_HINT = XMLUIMessages._UI_LABEL_LOCATION_HINT; + protected static final String LABEL_NAMESPACE_URI = XMLUIMessages._UI_LABEL_NAMESPACE_NAME; + protected static final String LABEL_PREFIX = XMLUIMessages._UI_LABEL_PREFIX; protected List checkedList = new ArrayList(); - //protected List namespaceInfoList = new ArrayList(); + // protected List namespaceInfoList = new ArrayList(); protected int[] columnIndexMap; protected boolean showCheckBoxes = true; private boolean showLocationText = false; @@ -158,9 +160,9 @@ this(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER, visibleRows, false); } - //protected CellEditor getCellEditor(int column) + // protected CellEditor getCellEditor(int column) // { - // return (column == COLUMN_CHECKBOX) ? checkBoxCellEditor : + // return (column == COLUMN_CHECKBOX) ? checkBoxCellEditor : // textCellEditor; // } @@ -197,13 +199,15 @@ if ((columnPropertiesArray[i]).equals(LABEL_LOCATION_HINT)) { if (showLocationText) { column.setText(columnPropertiesArray[i]); - } else { + } + else { // Comment this out until we solve the alignment/(space // for image being allocated // to prefix column) ...... - // column.setImage(XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TXTEXT)); + // column.setImage(XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TXTEXT)); } - } else { + } + else { column.setText(columnPropertiesArray[i]); } column.setAlignment(SWT.LEFT); @@ -212,13 +216,13 @@ table.setLayout(layout); this.visibleRows = visibleRows; - //for (int i = 0; i < visibleRows; i++) + // for (int i = 0; i < visibleRows; i++) // { - // TableItem item = new TableItem(table, SWT.NONE); - // item.setText("#######"); - //} - //checkBoxCellEditor = new NamespaceInfoCheckboxCellEditor(table); - //textCellEditor = new TextCellEditor(table); + // TableItem item = new TableItem(table, SWT.NONE); + // item.setText("#######"); + // } + // checkBoxCellEditor = new NamespaceInfoCheckboxCellEditor(table); + // textCellEditor = new TextCellEditor(table); /* * CellEditor[] cellEditors = new @@ -226,14 +230,14 @@ * columnPropertiesArray.length; i++) { cellEditors[i] = * getCellEditor(i); } setCellEditors(cellEditors); */ - //if (showCheckBoxes) - //{ - // getTable().addMouseListener(new TableItemChecker()); - //} + // if (showCheckBoxes) + // { + // getTable().addMouseListener(new TableItemChecker()); + // } } - //protected CellEditor checkBoxCellEditor; - //protected CellEditor textCellEditor; + // protected CellEditor checkBoxCellEditor; + // protected CellEditor textCellEditor; protected int[] createColumnIndexMap() { int[] result = new int[showCheckBoxes ? 4 : 3]; @@ -283,13 +287,14 @@ // displayed if (showLocationText) { result = 10; - } else { + } + else { result = 20; } break; } case COLUMN_CHECKBOX : { - result = 1; //info.locationHint; + result = 1; // info.locationHint; break; } case COLUMN_LOCATION_HINT : { @@ -297,7 +302,8 @@ // displayed if (showLocationText) { result = 10; - } else { + } + else { result = 2; } break;
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EncodingSettings.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EncodingSettings.java index 54e4f39..7bd9ced 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EncodingSettings.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EncodingSettings.java
@@ -43,14 +43,15 @@ private class ComboListener implements ModifyListener { public void modifyText(ModifyEvent e) { int i = encodingCombo.getSelectionIndex(); - if (i >= 0 && i < ianaVector.size()) + if ((i >= 0) && (i < ianaVector.size())) { ianaText.setText((String) (ianaVector.elementAt(encodingCombo.getSelectionIndex()))); + } } } - private static String ENCODING_LABEL = XMLUIMessages.EncodingSettings_1; //$NON-NLS-1$ + private static String ENCODING_LABEL = XMLUIMessages.EncodingSettings_1; - private static String IANA_LABEL = XMLUIMessages.EncodingSettings_0; //$NON-NLS-1$ + private static String IANA_LABEL = XMLUIMessages.EncodingSettings_0; private ModifyListener comboListener = new ComboListener(); protected Combo encodingCombo; @@ -126,7 +127,7 @@ return; } - if (0 <= index && index < ianaVector.size()) { + if ((0 <= index) && (index < ianaVector.size())) { encodingCombo.add(description, index); ianaVector.add(index, ianaTag); } @@ -187,18 +188,20 @@ if (enc != null) { encodingCombo.add(enc); - } else { + } + else { Logger.log(Logger.WARNING, "CommonCharsetNames.getDisplayString(" + iana + ") returned null"); //$NON-NLS-1$ //$NON-NLS-2$ encodingCombo.add(iana); } ianaVector.add(iana); } - } catch (Exception e) { - //e.printStackTrace(); - //MessageDialog.openError(getShell(), "Resource exception", + } + catch (Exception e) { + // e.printStackTrace(); + // MessageDialog.openError(getShell(), "Resource exception", // "Unable to obtain encoding strings. Check resource file"); - //XMLEncodingPlugin.getPlugin().getMsgLogger().write(e.toString()); - //XMLEncodingPlugin.getPlugin().getMsgLogger().writeCurrentThread(); + // XMLEncodingPlugin.getPlugin().getMsgLogger().write(e.toString()); + // XMLEncodingPlugin.getPlugin().getMsgLogger().writeCurrentThread(); Logger.log(Logger.ERROR, "Exception", e); //$NON-NLS-1$ } } @@ -299,7 +302,7 @@ * @param index */ public void removeEntry(int index) { - if (0 <= index && index < ianaVector.size()) { + if ((0 <= index) && (index < ianaVector.size())) { encodingCombo.remove(index); ianaVector.remove(index); }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/WorkbenchDefaultEncodingSettings.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/WorkbenchDefaultEncodingSettings.java index 7596b1a..7f47ba9 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/WorkbenchDefaultEncodingSettings.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/WorkbenchDefaultEncodingSettings.java
@@ -65,7 +65,7 @@ defaultEncodingComposite.setLayoutData(data); fUseDefaultButton = new Button(defaultEncodingComposite, SWT.CHECK); - fUseDefaultButton.setText(XMLUIMessages.WorkbenchDefaultEncodingSettings_0); //$NON-NLS-1$ + fUseDefaultButton.setText(XMLUIMessages.WorkbenchDefaultEncodingSettings_0); fUseDefaultButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { @@ -91,8 +91,9 @@ * @return a <code>String</code> value */ public String getIANATag() { - if (!isDefault()) + if (!isDefault()) { return fEncodingSettings.getIANATag(); + } return WORKBENCH_DEFAULT; } @@ -106,7 +107,8 @@ String workbenchValue = getWorkbenchEncoding(); workbenchValue = CommonCharsetNames.getIanaPreferredCharsetName(workbenchValue); fEncodingSettings.setIANATag(workbenchValue); - } else if (fNonDefaultIANA != null) { + } + else if (fNonDefaultIANA != null) { fEncodingSettings.setIANATag(fNonDefaultIANA); } getEncodingCombo().setEnabled(!fUseDefaultButton.getSelection()); @@ -124,14 +126,16 @@ * */ public void setIANATag(String ianaTag) { - if (ianaTag == null || ianaTag.equals(WORKBENCH_DEFAULT)) { + if ((ianaTag == null) || ianaTag.equals(WORKBENCH_DEFAULT)) { fUseDefaultButton.setSelection(true); handleUseDefaultButtonSelected(); - } else { + } + else { fUseDefaultButton.setSelection(false); handleUseDefaultButtonSelected(); - if (!isDefault()) + if (!isDefault()) { fEncodingSettings.setIANATag(ianaTag); + } } } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLColorPage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLColorPage.java index 99d9353..15d9ea1 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLColorPage.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLColorPage.java
@@ -70,7 +70,23 @@ } public String getSampleText() { - return XMLUIMessages.Sample_XML_doc; //$NON-NLS-1$ = "<?xml version=\"1.0\"?>\n<?customProcessingInstruction\n\tXML processor specific\n\tcontent ?>\n<!DOCTYPE colors\n\tPUBLIC \"//IBM/XML/COLORS/\" \"colors.dtd\">\n<colors>\n\t<!-- begin color definitions -->\n\t<color name=\"plaintext\" foreground=\"#000000\"\n\t\tbackground=\"#D4D0C8\"/>\n\t<color name=\"bold\" foreground=\"#000000\"\n\t\tbackground=\"#B3ACA0\">\n\t<![CDATA[<123456789>]]>\n\tNormal text content.\n\t<color name=\"inverse\" foreground=\"#F0F0F0\"\n\t\tbackground=\"#D4D0C8\"/>\n\n</colors>\n"; + return XMLUIMessages.Sample_XML_doc; // = "<?xml + // version=\"1.0\"?>\n<?customProcessingInstruction\n\tXML + // processor + // specific\n\tcontent + // ?>\n<!DOCTYPE + // colors\n\tPUBLIC + // \"//IBM/XML/COLORS/\" + // \"colors.dtd\">\n<colors>\n\t<!-- + // begin color definitions + // -->\n\t<color + // name=\"plaintext\" + // foreground=\"#000000\"\n\t\tbackground=\"#D4D0C8\"/>\n\t<color + // name=\"bold\" + // foreground=\"#000000\"\n\t\tbackground=\"#B3ACA0\">\n\t<![CDATA[<123456789>]]>\n\tNormal + // text content.\n\t<color + // name=\"inverse\" + // foreground=\"#F0F0F0\"\n\t\tbackground=\"#D4D0C8\"/>\n\n</colors>\n"; } protected void initCommonContextStyleMap(Dictionary contextStyleMap) { @@ -98,22 +114,37 @@ protected void initCommonDescriptions(Dictionary descriptions) { // create descriptions for hilighting types - descriptions.put(IStyleConstantsXML.COMMENT_BORDER, XMLUIMessages.Comment_Delimiters_UI_); //$NON-NLS-1$ = "Comment Delimiters" - descriptions.put(IStyleConstantsXML.COMMENT_TEXT, XMLUIMessages.Comment_Content_UI_); //$NON-NLS-1$ = "Comment Content" - descriptions.put(IStyleConstantsXML.TAG_BORDER, XMLUIMessages.Tag_Delimiters_UI_); //$NON-NLS-1$ = "Tag Delimiters" - descriptions.put(IStyleConstantsXML.TAG_NAME, XMLUIMessages.Tag_Names_UI_); //$NON-NLS-1$ = "Tag Names" - descriptions.put(IStyleConstantsXML.TAG_ATTRIBUTE_NAME, XMLUIMessages.Attribute_Names_UI_); //$NON-NLS-1$ = "Attribute Names" - descriptions.put(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE, XMLUIMessages.Attribute_Values_UI_); //$NON-NLS-1$ = "Attribute Values" - descriptions.put(IStyleConstantsXML.DECL_BORDER, XMLUIMessages.Declaration_Delimiters_UI_); //$NON-NLS-1$ = "Declaration Delimiters" - descriptions.put(IStyleConstantsXML.XML_CONTENT, XMLUIMessages.Content_UI_); //$NON-NLS-1$ = "Content" + descriptions.put(IStyleConstantsXML.COMMENT_BORDER, XMLUIMessages.Comment_Delimiters_UI_); // = + // "Comment + // Delimiters" + descriptions.put(IStyleConstantsXML.COMMENT_TEXT, XMLUIMessages.Comment_Content_UI_); // = + // "Comment + // Content" + descriptions.put(IStyleConstantsXML.TAG_BORDER, XMLUIMessages.Tag_Delimiters_UI_); // = + // "Tag + // Delimiters" + descriptions.put(IStyleConstantsXML.TAG_NAME, XMLUIMessages.Tag_Names_UI_); // = + // "Tag + // Names" + descriptions.put(IStyleConstantsXML.TAG_ATTRIBUTE_NAME, XMLUIMessages.Attribute_Names_UI_); // = + // "Attribute + // Names" + descriptions.put(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE, XMLUIMessages.Attribute_Values_UI_); // = + // "Attribute + // Values" + descriptions.put(IStyleConstantsXML.DECL_BORDER, XMLUIMessages.Declaration_Delimiters_UI_); // = + // "Declaration + // Delimiters" + descriptions.put(IStyleConstantsXML.XML_CONTENT, XMLUIMessages.Content_UI_); // = + // "Content" } protected void initCommonStyleList(ArrayList list) { - //list.add(IStyleConstantsXML.CDATA_BORDER); - //list.add(IStyleConstantsXML.CDATA_TEXT); - //list.add(IStyleConstantsXML.PI_BORDER); - //list.add(IStyleConstantsXML.PI_CONTENT); + // list.add(IStyleConstantsXML.CDATA_BORDER); + // list.add(IStyleConstantsXML.CDATA_TEXT); + // list.add(IStyleConstantsXML.PI_BORDER); + // list.add(IStyleConstantsXML.PI_CONTENT); list.add(IStyleConstantsXML.TAG_BORDER); list.add(IStyleConstantsXML.TAG_NAME); @@ -143,10 +174,20 @@ initCommonDescriptions(descriptions); initDocTypeDescriptions(descriptions); - descriptions.put(IStyleConstantsXML.CDATA_BORDER, XMLUIMessages.CDATA_Delimiters_UI_); //$NON-NLS-1$ = "CDATA Delimiters" - descriptions.put(IStyleConstantsXML.CDATA_TEXT, XMLUIMessages.CDATA_Content_UI_); //$NON-NLS-1$ = "CDATA Content" - descriptions.put(IStyleConstantsXML.PI_BORDER, XMLUIMessages.Processing_Instruction_Del_UI_); //$NON-NLS-1$ = "Processing Instruction Delimiters" - descriptions.put(IStyleConstantsXML.PI_CONTENT, XMLUIMessages.Processing_Instruction_Con_UI__UI_); //$NON-NLS-1$ = "Processing Instruction Content" + descriptions.put(IStyleConstantsXML.CDATA_BORDER, XMLUIMessages.CDATA_Delimiters_UI_); // = + // "CDATA + // Delimiters" + descriptions.put(IStyleConstantsXML.CDATA_TEXT, XMLUIMessages.CDATA_Content_UI_); // = + // "CDATA + // Content" + descriptions.put(IStyleConstantsXML.PI_BORDER, XMLUIMessages.Processing_Instruction_Del_UI_); // = + // "Processing + // Instruction + // Delimiters" + descriptions.put(IStyleConstantsXML.PI_CONTENT, XMLUIMessages.Processing_Instruction_Con_UI__UI_); // = + // "Processing + // Instruction + // Content" } protected void initDocTypeContextStyleMap(Dictionary contextStyleMap) { @@ -165,10 +206,21 @@ protected void initDocTypeDescriptions(Dictionary descriptions) { // create descriptions for hilighting types for DOCTYPE related items - descriptions.put(IStyleConstantsXML.DOCTYPE_NAME, XMLUIMessages.DOCTYPE_Name_UI_); //$NON-NLS-1$ = "DOCTYPE Name" - descriptions.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID, XMLUIMessages.DOCTYPE_SYSTEM_PUBLIC_Keyw_UI_); //$NON-NLS-1$ = "DOCTYPE SYSTEM/PUBLIC Keyword" - descriptions.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF, XMLUIMessages.DOCTYPE_Public_Reference_UI_); //$NON-NLS-1$ = "DOCTYPE Public Reference" - descriptions.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF, XMLUIMessages.DOCTYPE_System_Reference_UI_); //$NON-NLS-1$ = "DOCTYPE System Reference" + descriptions.put(IStyleConstantsXML.DOCTYPE_NAME, XMLUIMessages.DOCTYPE_Name_UI_); // = + // "DOCTYPE + // Name" + descriptions.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID, XMLUIMessages.DOCTYPE_SYSTEM_PUBLIC_Keyw_UI_); // = + // "DOCTYPE + // SYSTEM/PUBLIC + // Keyword" + descriptions.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF, XMLUIMessages.DOCTYPE_Public_Reference_UI_); // = + // "DOCTYPE + // Public + // Reference" + descriptions.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF, XMLUIMessages.DOCTYPE_System_Reference_UI_); // = + // "DOCTYPE + // System + // Reference" } protected void initDocTypeStyleList(ArrayList list) { @@ -214,7 +266,10 @@ picker.setDescriptions(descriptions); picker.setStyleList(styleList); } - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.eclipse.wst.sse.ui.preferences.ui.AbstractColorPage#savePreferences() */ protected void savePreferences() {
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java index e571669..bfffcfc 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java
@@ -169,10 +169,12 @@ protected void initializeValuesForCreatingOrSavingGroup() { String endOfLineCode = getModelPreferences().getString(CommonEncodingPreferenceNames.END_OF_LINE_CODE); - if (endOfLineCode.length() > 0) + if (endOfLineCode.length() > 0) { setCurrentEOLCode(endOfLineCode); - else + } + else { setCurrentEOLCode(CommonEncodingPreferenceNames.NO_TRANSLATION); + } } protected void initializeValuesForValidatingGroup() { @@ -205,10 +207,12 @@ protected void performDefaultsForCreatingOrSavingGroup() { String endOfLineCode = getModelPreferences().getDefaultString(CommonEncodingPreferenceNames.END_OF_LINE_CODE); - if (endOfLineCode.length() > 0) + if (endOfLineCode.length() > 0) { setCurrentEOLCode(endOfLineCode); - else + } + else { setCurrentEOLCode(CommonEncodingPreferenceNames.NO_TRANSLATION); + } } protected void performDefaultsForValidatingGroup() {
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java index b611e44..e884dc4 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java
@@ -186,10 +186,12 @@ fAutoPropose.setSelection(getPreferenceStore().getBoolean(XMLUIPreferenceNames.AUTO_PROPOSE)); fAutoProposeText.setText(getPreferenceStore().getString(XMLUIPreferenceNames.AUTO_PROPOSE_CODE)); String suggestionStrategy = getPreferenceStore().getString(XMLUIPreferenceNames.SUGGESTION_STRATEGY); - if (suggestionStrategy.length() > 0) + if (suggestionStrategy.length() > 0) { setCurrentSuggestionStrategy(suggestionStrategy); - else + } + else { setCurrentSuggestionStrategy(XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_LAX); + } } protected void initializeValuesForFormattingGroup() { @@ -230,10 +232,12 @@ fAutoPropose.setSelection(getPreferenceStore().getDefaultBoolean(XMLUIPreferenceNames.AUTO_PROPOSE)); fAutoProposeText.setText(getPreferenceStore().getDefaultString(XMLUIPreferenceNames.AUTO_PROPOSE_CODE)); String suggestionStrategy = getPreferenceStore().getDefaultString(XMLUIPreferenceNames.SUGGESTION_STRATEGY); - if (suggestionStrategy.length() > 0) + if (suggestionStrategy.length() > 0) { setCurrentSuggestionStrategy(suggestionStrategy); - else + } + else { setCurrentSuggestionStrategy(XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_LAX); + } } protected void performDefaultsForFormattingGroup() { @@ -321,8 +325,9 @@ try { widthText = fLineWidthText.getText(); int formattingLineWidth = Integer.parseInt(widthText); - if ((formattingLineWidth < WIDTH_VALIDATION_LOWER_LIMIT) || (formattingLineWidth > WIDTH_VALIDATION_UPPER_LIMIT)) + if ((formattingLineWidth < WIDTH_VALIDATION_LOWER_LIMIT) || (formattingLineWidth > WIDTH_VALIDATION_UPPER_LIMIT)) { throw new NumberFormatException(); + } } catch (NumberFormatException nfexc) { setInvalidInputMessage(widthText); @@ -335,8 +340,9 @@ if (fIndentationSize != null) { try { indentSize = fIndentationSize.getSelection(); - if ((indentSize < MIN_INDENTATION_SIZE) || (indentSize > MAX_INDENTATION_SIZE)) + if ((indentSize < MIN_INDENTATION_SIZE) || (indentSize > MAX_INDENTATION_SIZE)) { throw new NumberFormatException(); + } } catch (NumberFormatException nfexc) { setInvalidInputMessage(Integer.toString(indentSize));
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTemplatePreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTemplatePreferencePage.java index 267fbc3..ebec028 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTemplatePreferencePage.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTemplatePreferencePage.java
@@ -59,6 +59,7 @@ /* * (non-Javadoc) + * * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#createViewer(org.eclipse.swt.widgets.Composite) */ protected SourceViewer createViewer(Composite parent) { @@ -83,6 +84,7 @@ viewer.setDocument(document); return viewer; } + /* * (non-Javadoc) *
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceInitializer.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceInitializer.java index fd41d76..dfb8a71 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceInitializer.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceInitializer.java
@@ -18,18 +18,16 @@ */ public void initializeDefaultPreferences() { IPreferenceStore store = XMLUIPlugin.getDefault().getPreferenceStore(); - + store.setDefault(XMLUIPreferenceNames.AUTO_PROPOSE, true); store.setDefault(XMLUIPreferenceNames.AUTO_PROPOSE_CODE, "<"); //$NON-NLS-1$ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=140946 - store.setDefault(XMLUIPreferenceNames.SUGGESTION_STRATEGY, XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_STRICT); - store.setDefault( - XMLUIPreferenceNames.USE_INFERRED_GRAMMAR, true); + store.setDefault(XMLUIPreferenceNames.SUGGESTION_STRATEGY, XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_STRICT); + store.setDefault(XMLUIPreferenceNames.USE_INFERRED_GRAMMAR, true); // XML Style Preferences String NOBACKGROUNDBOLD = " | null | false"; //$NON-NLS-1$ - String styleValue = ColorHelper.getColorString(127, 0, 127) - + NOBACKGROUNDBOLD; + String styleValue = ColorHelper.getColorString(127, 0, 127) + NOBACKGROUNDBOLD; store.setDefault(IStyleConstantsXML.TAG_ATTRIBUTE_NAME, styleValue); styleValue = ColorHelper.getColorString(42, 0, 255) + NOBACKGROUNDBOLD; @@ -54,16 +52,13 @@ styleValue = ColorHelper.getColorString(0, 0, 128) + NOBACKGROUNDBOLD; store.setDefault(IStyleConstantsXML.DOCTYPE_NAME, styleValue); - store.setDefault(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF, - styleValue); + store.setDefault(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF, styleValue); - styleValue = ColorHelper.getColorString(128, 128, 128) - + NOBACKGROUNDBOLD; + styleValue = ColorHelper.getColorString(128, 128, 128) + NOBACKGROUNDBOLD; store.setDefault(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID, styleValue); styleValue = ColorHelper.getColorString(63, 127, 95) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF, - styleValue); + store.setDefault(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF, styleValue); styleValue = "null" + NOBACKGROUNDBOLD; //$NON-NLS-1$ store.setDefault(IStyleConstantsXML.XML_CONTENT, styleValue); // specified @@ -78,8 +73,7 @@ styleValue = ColorHelper.getColorString(0, 128, 128) + NOBACKGROUNDBOLD; store.setDefault(IStyleConstantsXML.TAG_BORDER, styleValue); - styleValue = ColorHelper.getColorString(63, 127, 127) - + NOBACKGROUNDBOLD; + styleValue = ColorHelper.getColorString(63, 127, 127) + NOBACKGROUNDBOLD; store.setDefault(IStyleConstantsXML.TAG_NAME, styleValue); styleValue = ColorHelper.getColorString(0, 128, 128) + NOBACKGROUNDBOLD;
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceNames.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceNames.java index 0c35532..f5b76fb 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceNames.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceNames.java
@@ -15,9 +15,9 @@ * Preference keys for XML UI */ public class XMLUIPreferenceNames { - - public final static String SUGGESTION_STRATEGY_VALUE_LAX = "Lax"; //$NON-NLS-1$ - public final static String SUGGESTION_STRATEGY_VALUE_STRICT = "Strict"; //$NON-NLS-1$ + + public final static String SUGGESTION_STRATEGY_VALUE_LAX = "Lax"; //$NON-NLS-1$ + public final static String SUGGESTION_STRATEGY_VALUE_STRICT = "Strict"; //$NON-NLS-1$ /** * A named preference that controls if code assist gets auto activated. * <p> @@ -68,20 +68,20 @@ private static String getUseInferredGrammarKey() { return "useInferredGrammar"; //$NON-NLS-1$ } - - /** - * A named preference that holds the characters that auto activate code - * assist. - * <p> - * Value is of type <code>String</code>. All characters that trigger - * auto code assist. - * </p> - */ - public static final String SUGGESTION_STRATEGY = getSuggestionStrategeyKey(); - private static String getSuggestionStrategeyKey() { - return "suggestionStrategy";//$NON-NLS-1$ - } + /** + * A named preference that holds the characters that auto activate code + * assist. + * <p> + * Value is of type <code>String</code>. All characters that trigger + * auto code assist. + * </p> + */ + public static final String SUGGESTION_STRATEGY = getSuggestionStrategeyKey(); + + private static String getSuggestionStrategeyKey() { + return "suggestionStrategy";//$NON-NLS-1$ + } /** * The key to store the last template name used in new DTD file wizard.
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterFactoryXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterFactoryXML.java index 96cba42..0731a3c 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterFactoryXML.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterFactoryXML.java
@@ -37,7 +37,7 @@ ProjectionModelNodeAdapterXML adapter = null; // create adapter for every element tag - if ((isActive()) && (target instanceof Node) && ((Node) target).getNodeType() == Node.ELEMENT_NODE) { + if ((isActive()) && (target instanceof Node) && (((Node) target).getNodeType() == Node.ELEMENT_NODE)) { adapter = new ProjectionModelNodeAdapterXML(this); adapter.updateAdapter((Node) target); } @@ -51,7 +51,7 @@ * @return */ boolean isActive() { - return (fProjectionViewers != null && !fProjectionViewers.isEmpty()); + return ((fProjectionViewers != null) && !fProjectionViewers.isEmpty()); } /**
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterXML.java index 62026bc..318f4b6 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterXML.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterXML.java
@@ -91,8 +91,9 @@ public void markCollapsed() { /* workaround for BUG85874 */ // do not mark collapsed if annotation is not visible - if (fIsVisible) + if (fIsVisible) { super.markCollapsed(); + } } } @@ -112,14 +113,14 @@ */ private Position createProjectionPosition(Node node) { Position pos = null; - if (isNodeProjectable(node) && node instanceof IndexedRegion) { + if (isNodeProjectable(node) && (node instanceof IndexedRegion)) { // IDocument document = // fAdapterFactory.getProjectionViewer().getDocument(); // if (document != null) { IndexedRegion inode = (IndexedRegion) node; int start = inode.getStartOffset(); int end = inode.getEndOffset(); - if (start >= 0 && start < end) { + if ((start >= 0) && (start < end)) { // region-based // extra line when collapsed, but no region increase when add // newline @@ -171,7 +172,7 @@ if ((node != null) && (!fTagAnnotations.isEmpty())) { Iterator it = fTagAnnotations.keySet().iterator(); - while (it.hasNext() && anno == null) { + while (it.hasNext() && (anno == null)) { TagProjectionAnnotation a = (TagProjectionAnnotation) it.next(); Node n = a.getNode(); if (node.equals(n)) { @@ -275,13 +276,14 @@ } // specifically add all annotations to viewer - if (viewer != null && !projectionAnnotations.isEmpty()) { + if ((viewer != null) && !projectionAnnotations.isEmpty()) { fAdapterFactory.queueAnnotationModelChanges(node, null, projectionAnnotations, null, viewer); } // only update when there is something to update - if ((oldList != null && oldList.length > 0) || (!additions.isEmpty()) || (modifyList != null && modifyList.length > 0)) + if (((oldList != null) && (oldList.length > 0)) || (!additions.isEmpty()) || ((modifyList != null) && (modifyList.length > 0))) { fAdapterFactory.queueAnnotationModelChanges(node, oldList, additions, modifyList); + } } // save new list of annotations
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionViewerInformation.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionViewerInformation.java index c20c119..1dccff6 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionViewerInformation.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionViewerInformation.java
@@ -55,9 +55,10 @@ // annotation model will be updated after all documentChanged // listeners have been notified IDocument document = event.getDocument(); - if (document instanceof IDocumentExtension && fInfo.getDocument() == document) { - if (fInfo.hasChangesQueued()) + if ((document instanceof IDocumentExtension) && (fInfo.getDocument() == document)) { + if (fInfo.hasChangesQueued()) { ((IDocumentExtension) document).registerPostNotificationReplace(this, new PostDocumentChangedListener(fInfo)); + } } } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/StructuredTextFoldingProviderXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/StructuredTextFoldingProviderXML.java index 4ac69d0..e985c11 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/StructuredTextFoldingProviderXML.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/StructuredTextFoldingProviderXML.java
@@ -46,7 +46,7 @@ private void addAdapterToNodeAndChildren(Node node, int childLevel) { // stop adding initial adapters MAX_CHILDREN levels deep for // performance sake - if (node instanceof INodeNotifier && childLevel < MAX_CHILDREN) { + if ((node instanceof INodeNotifier) && (childLevel < MAX_CHILDREN)) { INodeNotifier notifier = (INodeNotifier) node; // try and get the adapter for the current node and update the @@ -62,7 +62,7 @@ } int siblingLevel = 0; Node nextChild = node.getFirstChild(); - while (nextChild != null && siblingLevel < MAX_SIBLINGS) { + while ((nextChild != null) && (siblingLevel < MAX_SIBLINGS)) { Node childNode = nextChild; nextChild = childNode.getNextSibling(); @@ -88,7 +88,7 @@ if (startNode instanceof Node) { int siblingLevel = 0; Node nextSibling = (Node) startNode; - while (nextSibling != null && siblingLevel < MAX_SIBLINGS) { + while ((nextSibling != null) && (siblingLevel < MAX_SIBLINGS)) { Node currentNode = nextSibling; nextSibling = currentNode.getNextSibling(); @@ -149,8 +149,9 @@ } } finally { - if (sModel != null) + if (sModel != null) { sModel.releaseFromRead(); + } } } @@ -166,8 +167,9 @@ * is enabled. (otherwise, only install would have been called) */ public void initialize() { - if (!isInstalled()) + if (!isInstalled()) { return; + } // clear out old info projectionDisabled(); @@ -213,8 +215,9 @@ } // clear out all annotations - if (fViewer.getProjectionAnnotationModel() != null) + if (fViewer.getProjectionAnnotationModel() != null) { fViewer.getProjectionAnnotationModel().removeAllAnnotations(); + } removeAllAdapters(); @@ -293,7 +296,7 @@ public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { // if folding is enabled and new document is going to be a totally // different document, disable projection - if (fDocument != null && fDocument != newInput) { + if ((fDocument != null) && (fDocument != newInput)) { // disable projection and disconnect everything projectionDisabled(); fProjectionNeedsToBeEnabled = true; @@ -303,7 +306,7 @@ public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { // if projection was previously enabled before input document changed // and new document is different than old document - if (fProjectionNeedsToBeEnabled && fDocument == null && newInput != null) { + if (fProjectionNeedsToBeEnabled && (fDocument == null) && (newInput != null)) { projectionEnabled(); fProjectionNeedsToBeEnabled = false; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/EnumeratedStringPropertyDescriptor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/EnumeratedStringPropertyDescriptor.java index e302240..b9360f9 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/EnumeratedStringPropertyDescriptor.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/EnumeratedStringPropertyDescriptor.java
@@ -52,15 +52,17 @@ // Check to see if we already have a Cell Editor with a valid Control // under the given parent. // If any of that's not true, create and return a new Cell Editor - if (fEditor == null || fEditor.getControl() == null || fEditor.getControl().isDisposed() || parent != fParent) + if ((fEditor == null) || (fEditor.getControl() == null) || fEditor.getControl().isDisposed() || (parent != fParent)) { fEditor = new StringComboBoxCellEditor(parent, fValues); + } fParent = parent; return fEditor; } public void updateValues(String newValues[]) { - if (Arrays.equals(fValues, newValues)) + if (Arrays.equals(fValues, newValues)) { return; + } fValues = newValues; if (fEditor != null) { fEditor.setItems(newValues);
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/StringComboBoxCellEditor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/StringComboBoxCellEditor.java index 05f4788..f9a0a76 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/StringComboBoxCellEditor.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/StringComboBoxCellEditor.java
@@ -28,7 +28,7 @@ private boolean fSettingValue = false; /** - * + * */ public StringComboBoxCellEditor() { super(); @@ -55,10 +55,12 @@ // otherwise limits to set of valid values Object index = super.doGetValue(); int selection = -1; - if (index instanceof Integer) + if (index instanceof Integer) { selection = ((Integer) index).intValue(); - if (selection >= 0) + } + if (selection >= 0) { return getItems()[selection]; + } else if (getControl() instanceof CCombo) { // retrieve the actual text as the list of valid items doesn't // contain the value @@ -68,22 +70,27 @@ } protected void doSetValue(Object value) { - if (fSettingValue) + if (fSettingValue) { return; + } fSettingValue = true; if (value instanceof Integer) { super.doSetValue(value); - } else { + } + else { String stringValue = value.toString(); int selection = -1; - for (int i = 0; i < getItems().length; i++) - if (getItems()[i].equals(stringValue)) + for (int i = 0; i < getItems().length; i++) { + if (getItems()[i].equals(stringValue)) { selection = i; - if (selection >= 0) + } + } + if (selection >= 0) { super.doSetValue(new Integer(selection)); + } else { super.doSetValue(new Integer(-1)); - if (getControl() instanceof CCombo && !stringValue.equals(((CCombo) getControl()).getText())) { + if ((getControl() instanceof CCombo) && !stringValue.equals(((CCombo) getControl()).getText())) { // update the Text widget ((CCombo) getControl()).setText(stringValue); } @@ -93,7 +100,7 @@ } public void setItems(String[] newItems) { - if (getControl() == null || getControl().isDisposed()) { + if ((getControl() == null) || getControl().isDisposed()) { Logger.log(Logger.ERROR, "Attempted to update item list for disposed cell editor"); //$NON-NLS-1$ return; } @@ -101,10 +108,11 @@ // keep selection if possible Object previousSelectedValue = getValue(); super.setItems(newItems); - if (previousSelectedValue != null && getControl() instanceof CCombo) { + if ((previousSelectedValue != null) && (getControl() instanceof CCombo)) { for (int i = 0; i < newItems.length; i++) { - if (newItems[i].equals(previousSelectedValue)) + if (newItems[i].equals(previousSelectedValue)) { setValue(previousSelectedValue); + } } } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySource.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySource.java index 27f94c0..695854b 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySource.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySource.java
@@ -48,7 +48,7 @@ * properties of DOM nodes. */ public class XMLPropertySource implements IPropertySource, IPropertySourceExtension, IPropertySource2 { - protected final static String CATEGORY_ATTRIBUTES = XMLUIMessages.XMLPropertySourceAdapter_0; //$NON-NLS-1$ + protected final static String CATEGORY_ATTRIBUTES = XMLUIMessages.XMLPropertySourceAdapter_0; private static final boolean fSetExpertFilter = false; @@ -124,7 +124,7 @@ ownerDocument = (Document) node; } } - if(ownerDocument != null) { + if (ownerDocument != null) { adapter = (DocumentTypeAdapter) ((INodeNotifier) ownerDocument).getAdapterFor(DocumentTypeAdapter.class); } @@ -135,14 +135,16 @@ String attributeName = attrDecl.getAttrName(); List values = new ArrayList(1); String impliedValue = helper.getImpliedValue(); - if (impliedValue != null) + if (impliedValue != null) { values.add(impliedValue); - boolean checkIfCurrentValueIsIncluded = (fNode.getAttributes() != null && fNode.getAttributes().getNamedItem(attributeName) != null && fNode.getAttributes().getNamedItem(attributeName).getNodeValue() != null); + } + boolean checkIfCurrentValueIsIncluded = ((fNode.getAttributes() != null) && (fNode.getAttributes().getNamedItem(attributeName) != null) && (fNode.getAttributes().getNamedItem(attributeName).getNodeValue() != null)); if (checkIfCurrentValueIsIncluded) { String currentValue = null; currentValue = fNode.getAttributes().getNamedItem(attributeName).getNodeValue(); - if (!currentValue.equals(impliedValue)) + if (!currentValue.equals(impliedValue)) { values.add(currentValue); + } } String[] validStrings = new String[values.size()]; validStrings = (String[]) values.toArray(validStrings); @@ -153,14 +155,15 @@ String attributeName = attrDecl.getAttrName(); List values = new ArrayList(1); boolean currentValueKnown = false; - boolean checkIfCurrentValueIsKnown = (fNode.getAttributes() != null && fNode.getAttributes().getNamedItem(attributeName) != null && fNode.getAttributes().getNamedItem(attributeName).getNodeValue() != null); + boolean checkIfCurrentValueIsKnown = ((fNode.getAttributes() != null) && (fNode.getAttributes().getNamedItem(attributeName) != null) && (fNode.getAttributes().getNamedItem(attributeName).getNodeValue() != null)); String currentValue = null; - if (checkIfCurrentValueIsKnown) + if (checkIfCurrentValueIsKnown) { currentValue = fNode.getAttributes().getNamedItem(attributeName).getNodeValue(); + } - if (valuesHelper.getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED && valuesHelper.getImpliedValue() != null) { + if ((valuesHelper.getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED) && (valuesHelper.getImpliedValue() != null)) { // FIXED value - currentValueKnown = currentValue != null && valuesHelper.getImpliedValue().equals(currentValue); + currentValueKnown = (currentValue != null) && valuesHelper.getImpliedValue().equals(currentValue); values.add(valuesHelper.getImpliedValue()); } else { @@ -168,7 +171,7 @@ String[] valueStrings = null; // valueStrings = valuesHelper.getEnumeratedValues(); ModelQuery modelQuery = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument()); - if (modelQuery != null && fNode.getNodeType() == Node.ELEMENT_NODE) { + if ((modelQuery != null) && (fNode.getNodeType() == Node.ELEMENT_NODE)) { valueStrings = modelQuery.getPossibleDataTypeValues((Element) fNode, attrDecl); } else { @@ -176,19 +179,22 @@ } if (valueStrings != null) { for (int i = 0; i < valueStrings.length; i++) { - if (checkIfCurrentValueIsKnown && valueStrings[i].equals(currentValue)) + if (checkIfCurrentValueIsKnown && valueStrings[i].equals(currentValue)) { currentValueKnown = true; + } values.add(valueStrings[i]); } } } - if (valuesHelper.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE && valuesHelper.getImpliedValue() != null) { - if (!values.contains(valuesHelper.getImpliedValue())) + if ((valuesHelper.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE) && (valuesHelper.getImpliedValue() != null)) { + if (!values.contains(valuesHelper.getImpliedValue())) { values.add(valuesHelper.getImpliedValue()); + } } - if (checkIfCurrentValueIsKnown && !currentValueKnown && currentValue != null && currentValue.length() > 0) + if (checkIfCurrentValueIsKnown && !currentValueKnown && (currentValue != null) && (currentValue.length() > 0)) { values.add(currentValue); + } String[] validStrings = new String[values.size()]; validStrings = (String[]) values.toArray(validStrings); return validStrings; @@ -204,8 +210,9 @@ TextPropertyDescriptor descriptor = new TextPropertyDescriptor(attributeName, attributeName); descriptor.setCategory(getCategory(null)); descriptor.setDescription(attributeName); - if (hideOnFilter && fSetExpertFilter) + if (hideOnFilter && fSetExpertFilter) { descriptor.setFilterFlags(new String[]{IPropertySheetEntry.FILTER_ID_EXPERT}); + } return descriptor; } @@ -222,8 +229,9 @@ EnumeratedStringPropertyDescriptor descriptor = new EnumeratedStringPropertyDescriptor(attrDecl.getAttrName(), attrDecl.getAttrName(), _getValidStrings(attrDecl, valuesHelper)); descriptor.setCategory(getCategory(attrDecl)); descriptor.setDescription(attrDecl.getAttrName()); - if (attrDecl.getUsage() != CMAttributeDeclaration.REQUIRED && fSetExpertFilter) + if ((attrDecl.getUsage() != CMAttributeDeclaration.REQUIRED) && fSetExpertFilter) { descriptor.setFilterFlags(new String[]{IPropertySheetEntry.FILTER_ID_EXPERT}); + } return descriptor; } @@ -249,10 +257,10 @@ if (attrType != null) { // handle declarations that provide FIXED/ENUMERATED values - if (attrType.getEnumeratedValues() != null && attrType.getEnumeratedValues().length > 0) { + if ((attrType.getEnumeratedValues() != null) && (attrType.getEnumeratedValues().length > 0)) { descriptor = createEnumeratedPropertyDescriptor(attrDecl, attrType); } - else if ((attrDecl.getUsage() == CMAttributeDeclaration.FIXED || attrType.getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED) && attrType.getImpliedValue() != null) { + else if (((attrDecl.getUsage() == CMAttributeDeclaration.FIXED) || (attrType.getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED)) && (attrType.getImpliedValue() != null)) { descriptor = createFixedPropertyDescriptor(attrDecl, attrType); } else { @@ -294,8 +302,9 @@ // CMAttributeDeclaration to derive a descriptor if (attrMap != null) { String attrName = attr.getName(); - if (fCaseSensitive) + if (fCaseSensitive) { attrDecl = (CMAttributeDeclaration) attrMap.getNamedItem(attrName); + } else { attrDecl = null; for (int j = 0; j < attrMap.getLength(); j++) { @@ -310,16 +319,19 @@ // descriptor ID if (attrDecl != null) { descriptor = createPropertyDescriptor(attrDecl); - if (descriptor != null) + if (descriptor != null) { names.add(attrDecl.getNodeName()); + } } else { descriptor = createDefaultPropertyDescriptor(attr.getName()); - if (descriptor != null) + if (descriptor != null) { names.add(attr.getName()); + } } - if (descriptor != null) + if (descriptor != null) { descriptorList.add(descriptor); + } } } @@ -337,8 +349,9 @@ } IPropertyDescriptor[] descriptors = new IPropertyDescriptor[descriptorList.size()]; - for (int i = 0; i < descriptors.length; i++) + for (int i = 0; i < descriptors.length; i++) { descriptors[i] = (IPropertyDescriptor) descriptorList.get(i); + } return descriptors; } @@ -346,8 +359,9 @@ TextPropertyDescriptor descriptor = new TextPropertyDescriptor(attrDecl.getAttrName(), attrDecl.getAttrName()); descriptor.setCategory(getCategory(attrDecl)); descriptor.setDescription(attrDecl.getAttrName()); - if (attrDecl.getUsage() != CMAttributeDeclaration.REQUIRED && fSetExpertFilter) + if ((attrDecl.getUsage() != CMAttributeDeclaration.REQUIRED) && fSetExpertFilter) { descriptor.setFilterFlags(new String[]{IPropertySheetEntry.FILTER_ID_EXPERT}); + } return descriptor; } @@ -356,7 +370,7 @@ if (attrDecl.supports("category")) { //$NON-NLS-1$ return (String) attrDecl.getProperty("category"); //$NON-NLS-1$ } - if (fShouldDeriveCategories && attrDecl.getAttrType() != null && attrDecl.getAttrType().getNodeName() != null && attrDecl.getAttrType().getNodeName().length() > 0) { + if (fShouldDeriveCategories && (attrDecl.getAttrType() != null) && (attrDecl.getAttrType().getNodeName() != null) && (attrDecl.getAttrType().getNodeName().length() > 0)) { return attrDecl.getAttrType().getDataTypeName(); } } @@ -364,8 +378,9 @@ } private CMElementDeclaration getDeclaration() { - if (fNode == null || fNode.getNodeType() != Node.ELEMENT_NODE) + if ((fNode == null) || (fNode.getNodeType() != Node.ELEMENT_NODE)) { return null; + } ModelQuery modelQuery = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument()); if (modelQuery != null) { return modelQuery.getCMElementDeclaration((Element) fNode); @@ -393,7 +408,7 @@ * @return all valid descriptors. */ public final IPropertyDescriptor[] getPropertyDescriptors() { - if (fDescriptors == null || fDescriptors.length == 0) { + if ((fDescriptors == null) || (fDescriptors.length == 0)) { fDescriptors = createPropertyDescriptors(); } else { @@ -413,30 +428,36 @@ if (attrMap != null) { Node attribute = attrMap.getNamedItem(name); if (attribute != null) { - if (attribute instanceof IDOMNode) + if (attribute instanceof IDOMNode) { returnedValue = ((IDOMNode) attribute).getValueSource(); - else + } + else { returnedValue = attribute.getNodeValue(); + } } } - if (returnedValue == null) + if (returnedValue == null) { returnedValue = ""; //$NON-NLS-1$ + } return returnedValue; } private String[] getValidValues(CMAttributeDeclaration attrDecl) { - if (attrDecl == null) + if (attrDecl == null) { return new String[0]; + } String[] validValues = null; CMDataType attrType = attrDecl.getAttrType(); if (attrType != null) { validValues = _getValidStrings(attrDecl, attrType); - if (fSortEnumeratedValues) + if (fSortEnumeratedValues) { Arrays.sort(validValues); + } } - if (validValues == null) + if (validValues == null) { validValues = new String[0]; + } return validValues; } @@ -459,7 +480,7 @@ if (attrDecl != null) { if (attrDecl.getAttrType() != null) { CMDataType helper = attrDecl.getAttrType(); - if (helper.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE && helper.getImpliedValue() != null) { + if ((helper.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE) && (helper.getImpliedValue() != null)) { resettable = true; } } @@ -479,8 +500,9 @@ String property = propertyObject.toString(); NamedNodeMap attrMap = fNode.getAttributes(); - if (attrMap != null) + if (attrMap != null) { return attrMap.getNamedItem(property) != null; + } return false; } @@ -526,11 +548,12 @@ if (attrDecl != null) { if (attrDecl.getAttrType() != null) { CMDataType helper = attrDecl.getAttrType(); - if (helper.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE && helper.getImpliedValue() != null) + if ((helper.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE) && (helper.getImpliedValue() != null)) { defValue = helper.getImpliedValue(); + } } } - if (defValue != null && defValue.length() > 0) { + if ((defValue != null) && (defValue.length() > 0)) { ((Attr) attrMap.getNamedItem(property)).setValue(defValue); } else { @@ -551,13 +574,15 @@ // refresh // on the PropertySheet page and the setInput again asks the editor to // close; besides, why apply the same value twice? - if (!fValuesBeingSet.isEmpty() && fValuesBeingSet.peek() == nameObject) + if (!fValuesBeingSet.isEmpty() && (fValuesBeingSet.peek() == nameObject)) { return; + } fValuesBeingSet.push(nameObject); String name = nameObject.toString(); String valueString = null; - if (value != null) + if (value != null) { valueString = value.toString(); + } NamedNodeMap attrMap = fNode.getAttributes(); try { if (attrMap != null) { @@ -568,21 +593,25 @@ // triggers a viewer update, forcing the // active cell editor to save its value and causing the // loop to continue - if (attr.getValue() == null || !attr.getValue().equals(valueString)) { - if (attr instanceof IDOMNode) + if ((attr.getValue() == null) || !attr.getValue().equals(valueString)) { + if (attr instanceof IDOMNode) { ((IDOMNode) attr).setValueSource(valueString); - else + } + else { attr.setValue(valueString); + } } } else { // NEW(?) value if (value != null) { // never create an empty attribute Attr newAttr = fNode.getOwnerDocument().createAttribute(name); - if (newAttr instanceof IDOMNode) + if (newAttr instanceof IDOMNode) { ((IDOMNode) newAttr).setValueSource(valueString); - else + } + else { newAttr.setValue(valueString); + } attrMap.setNamedItem(newAttr); } } @@ -595,16 +624,18 @@ } catch (DOMException e) { Display d = getDisplay(); - if (d != null) + if (d != null) { d.beep(); + } } fValuesBeingSet.pop(); } protected void updatePropertyDescriptors() { - if (fDescriptors == null || fDescriptors.length == 0) + if ((fDescriptors == null) || (fDescriptors.length == 0)) { // Nothing to update return; + } // List of all names encountered in the tag and defined by the element List declaredNames = new ArrayList(); @@ -641,7 +672,7 @@ ((EnumeratedStringPropertyDescriptor) fDescriptors[j]).updateValues(validValues); } // Replace with better descriptor - else if (validValues != null && validValues.length > 0) { + else if ((validValues != null) && (validValues.length > 0)) { fDescriptors[j] = createPropertyDescriptor(attrDecl); } } @@ -692,8 +723,9 @@ } else { boolean exists = false; - for (int j = 0; j < descriptorNames.size(); j++) + for (int j = 0; j < descriptorNames.size(); j++) { exists = (descriptorNames.get(j).toString().equalsIgnoreCase(attrName)) || exists; + } if (!exists) { descriptorNames.add(attrName); IPropertyDescriptor descriptor = createPropertyDescriptor(attrDecl); @@ -719,8 +751,9 @@ } else { boolean exists = false; - for (int j = 0; j < descriptorNames.size(); j++) + for (int j = 0; j < descriptorNames.size(); j++) { exists = (descriptorNames.get(j).toString().equalsIgnoreCase(attrName)) || exists; + } if (!exists) { descriptorNames.add(attrName); descriptors.add(createDefaultPropertyDescriptor(attrName)); @@ -731,8 +764,9 @@ // Update fDescriptors IPropertyDescriptor[] newDescriptors = new IPropertyDescriptor[descriptors.size()]; - for (int i = 0; i < newDescriptors.length; i++) + for (int i = 0; i < newDescriptors.length; i++) { newDescriptors[i] = (IPropertyDescriptor) descriptors.get(i); + } fDescriptors = newDescriptors; } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/XMLSourceEditingTextTools.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/XMLSourceEditingTextTools.java index 099ccc9..3ccd334 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/XMLSourceEditingTextTools.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/XMLSourceEditingTextTools.java
@@ -42,26 +42,30 @@ } public int getEndTagEndOffset() { - if (node.getEndStructuredDocumentRegion() != null) + if (node.getEndStructuredDocumentRegion() != null) { return node.getEndStructuredDocumentRegion().getEndOffset(); + } return -1; } public int getEndTagStartOffset() { - if (node.getEndStructuredDocumentRegion() != null) + if (node.getEndStructuredDocumentRegion() != null) { return node.getEndStructuredDocumentRegion().getStartOffset(); + } return -1; } public int getStartTagEndOffset() { - if (node.getStartStructuredDocumentRegion() != null) + if (node.getStartStructuredDocumentRegion() != null) { return node.getStartStructuredDocumentRegion().getEndOffset(); + } return -1; } public int getStartTagStartOffset() { - if (node.getStartStructuredDocumentRegion() != null) + if (node.getStartStructuredDocumentRegion() != null) { return node.getStartStructuredDocumentRegion().getStartOffset(); + } return -1; } } @@ -70,7 +74,7 @@ public int getCaretOffset() { StructuredTextViewer stv = fTextEditor.getTextViewer(); - if (stv != null && stv.getTextWidget() != null && !stv.getTextWidget().isDisposed()) { + if ((stv != null) && (stv.getTextWidget() != null) && !stv.getTextWidget().isDisposed()) { return stv.widgetOffset2ModelOffset(stv.getTextWidget().getCaretOffset()); } return 0; @@ -109,7 +113,7 @@ public Node getNode(int offset) throws BadLocationException { Node node = null; - if (0 <= offset && offset <= getDocument().getLength()) { + if ((0 <= offset) && (offset <= getDocument().getLength())) { node = (Node) fTextEditor.getModel().getIndexedRegion(offset); } else { @@ -124,8 +128,9 @@ * @see org.eclipse.wst.sse.ui.extensions.SourceEditingTextTools#getNodeLocation(org.w3c.dom.Node) */ public NodeLocation getNodeLocation(Node node) { - if (node.getNodeType() == Node.ELEMENT_NODE && node instanceof IDOMNode) + if ((node.getNodeType() == Node.ELEMENT_NODE) && (node instanceof IDOMNode)) { return new NodeLocationImpl((IDOMNode) node); + } return null; } @@ -145,8 +150,9 @@ // return (vsm != null) ? vsm.getSelectedNodes() : null; // } public int getStartOffset(Node node) { - if (node == null || !(node instanceof IDOMText)) + if ((node == null) || !(node instanceof IDOMText)) { return -1; + } IStructuredDocumentRegion fnode = ((IDOMText) node).getFirstStructuredDocumentRegion(); return fnode.getStartOffset();
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForXML.java index 09b9df1..a7badb2 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForXML.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForXML.java
@@ -30,7 +30,7 @@ import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames; /** - * + * */ public class AdapterFactoryProviderForXML implements AdapterFactoryProvider { @@ -75,7 +75,9 @@ } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryProvider#isFor(org.eclipse.wst.sse.core.internal.ltk.modelhandler.IDocumentTypeHandler) */ public boolean isFor(IDocumentTypeHandler contentTypeDescription) {
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectEnclosingXMLActionDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectEnclosingXMLActionDelegate.java index 4efac6b..bd27261 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectEnclosingXMLActionDelegate.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectEnclosingXMLActionDelegate.java
@@ -25,7 +25,7 @@ protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection) { IndexedRegion indexedRegion = null; - + indexedRegion = getIndexedRegion(document, textSelection.getOffset()); return indexedRegion; @@ -37,16 +37,17 @@ Node cursorNode = (Node) indexedRegion; // use parent node for empty text node - if (cursorNode.getNodeType() == Node.TEXT_NODE && cursorNode.getNodeValue().trim().length() == 0) { + if ((cursorNode.getNodeType() == Node.TEXT_NODE) && (cursorNode.getNodeValue().trim().length() == 0)) { cursorNode = cursorNode.getParentNode(); - if (cursorNode instanceof IndexedRegion) + if (cursorNode instanceof IndexedRegion) { indexedRegion = (IndexedRegion) cursorNode; + } } Region cursorNodeRegion = new Region(indexedRegion.getStartOffset(), indexedRegion.getEndOffset() - indexedRegion.getStartOffset()); - if (cursorNodeRegion.getOffset() >= textSelection.getOffset() && cursorNodeRegion.getOffset() <= textSelection.getOffset() + textSelection.getLength() && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= textSelection.getOffset() && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= textSelection.getOffset() + textSelection.getLength()) { + if ((cursorNodeRegion.getOffset() >= textSelection.getOffset()) && (cursorNodeRegion.getOffset() <= textSelection.getOffset() + textSelection.getLength()) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= textSelection.getOffset()) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= textSelection.getOffset() + textSelection.getLength())) { Node newNode = cursorNode.getParentNode(); if (newNode instanceof IndexedRegion) { @@ -54,8 +55,9 @@ newRegion = new Region(newIndexedRegion.getStartOffset(), newIndexedRegion.getEndOffset() - newIndexedRegion.getStartOffset()); } } - else + else { newRegion = cursorNodeRegion; + } } return newRegion; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectNextXMLActionDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectNextXMLActionDelegate.java index 25b385d..03327bc 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectNextXMLActionDelegate.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectNextXMLActionDelegate.java
@@ -26,8 +26,9 @@ protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection) { int offset = textSelection.getOffset() + textSelection.getLength() - 1; - if (offset < 0) + if (offset < 0) { offset = 0; + } IndexedRegion indexedRegion = null; @@ -42,21 +43,23 @@ Node cursorNode = (Node) indexedRegion; // use parent node for empty text node - if (cursorNode.getNodeType() == Node.TEXT_NODE && cursorNode.getNodeValue().trim().length() == 0) { + if ((cursorNode.getNodeType() == Node.TEXT_NODE) && (cursorNode.getNodeValue().trim().length() == 0)) { cursorNode = cursorNode.getParentNode(); - if (cursorNode instanceof IndexedRegion) + if (cursorNode instanceof IndexedRegion) { indexedRegion = (IndexedRegion) cursorNode; + } } Region cursorNodeRegion = new Region(indexedRegion.getStartOffset(), indexedRegion.getEndOffset() - indexedRegion.getStartOffset()); int currentOffset = textSelection.getOffset(); int currentEndOffset = currentOffset + textSelection.getLength(); - if (cursorNodeRegion.getOffset() >= currentOffset && cursorNodeRegion.getOffset() <= currentEndOffset && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= currentOffset && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= currentEndOffset) { + if ((cursorNodeRegion.getOffset() >= currentOffset) && (cursorNodeRegion.getOffset() <= currentEndOffset) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= currentOffset) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= currentEndOffset)) { newRegion = getNewSelectionRegion2(indexedRegion, textSelection); } - else + else { newRegion = cursorNodeRegion; + } } return newRegion; } @@ -95,8 +98,9 @@ IndexedRegion newIndexedRegion = (IndexedRegion) newNode; newRegion = new Region(textSelection.getOffset(), newIndexedRegion.getEndOffset() - textSelection.getOffset()); - if (newNode.getNodeType() == Node.TEXT_NODE) + if (newNode.getNodeType() == Node.TEXT_NODE) { newRegion = getNewSelectionRegion2(newIndexedRegion, new TextSelection(newRegion.getOffset(), newRegion.getLength())); + } } } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectPreviousXMLActionDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectPreviousXMLActionDelegate.java index 52b2062..f3b7b95 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectPreviousXMLActionDelegate.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectPreviousXMLActionDelegate.java
@@ -38,16 +38,17 @@ Node cursorNode = (Node) indexedRegion; // use parent node for empty text node - if (cursorNode.getNodeType() == Node.TEXT_NODE && cursorNode.getNodeValue().trim().length() == 0) { + if ((cursorNode.getNodeType() == Node.TEXT_NODE) && (cursorNode.getNodeValue().trim().length() == 0)) { cursorNode = cursorNode.getParentNode(); - if (cursorNode instanceof IndexedRegion) + if (cursorNode instanceof IndexedRegion) { indexedRegion = (IndexedRegion) cursorNode; + } } Region cursorNodeRegion = new Region(indexedRegion.getStartOffset(), indexedRegion.getEndOffset() - indexedRegion.getStartOffset()); - if (cursorNodeRegion.getOffset() >= textSelection.getOffset() && cursorNodeRegion.getOffset() <= textSelection.getOffset() + textSelection.getLength() && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= textSelection.getOffset() && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= textSelection.getOffset() + textSelection.getLength()) { + if ((cursorNodeRegion.getOffset() >= textSelection.getOffset()) && (cursorNodeRegion.getOffset() <= textSelection.getOffset() + textSelection.getLength()) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= textSelection.getOffset()) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= textSelection.getOffset() + textSelection.getLength())) { Node newNode = cursorNode.getPreviousSibling(); if (newNode == null) { newNode = cursorNode.getParentNode(); @@ -62,14 +63,16 @@ IndexedRegion newIndexedRegion = (IndexedRegion) newNode; newRegion = new Region(newIndexedRegion.getStartOffset(), textSelection.getOffset() + textSelection.getLength() - newIndexedRegion.getStartOffset()); - if (newNode.getNodeType() == Node.TEXT_NODE) + if (newNode.getNodeType() == Node.TEXT_NODE) { newRegion = getNewSelectionRegion(newIndexedRegion, new TextSelection(newRegion.getOffset(), newRegion.getLength())); + } } } } - else + else { newRegion = cursorNodeRegion; + } } return newRegion; }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/LineStyleProviderForXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/LineStyleProviderForXML.java index a56a635..0e3845c 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/LineStyleProviderForXML.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/LineStyleProviderForXML.java
@@ -38,52 +38,73 @@ String type = region.getType(); if ((type == DOMRegionContext.XML_CONTENT) || (type == DOMRegionContext.XML_DOCTYPE_INTERNAL_SUBSET)) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.XML_CONTENT); - } else if ((type == DOMRegionContext.XML_TAG_OPEN) || (type == DOMRegionContext.XML_END_TAG_OPEN) || (type == DOMRegionContext.XML_TAG_CLOSE) || (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE)) { + } + else if ((type == DOMRegionContext.XML_TAG_OPEN) || (type == DOMRegionContext.XML_END_TAG_OPEN) || (type == DOMRegionContext.XML_TAG_CLOSE) || (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE)) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_BORDER); - } else if ((type == DOMRegionContext.XML_CDATA_OPEN) || (type == DOMRegionContext.XML_CDATA_CLOSE)) { + } + else if ((type == DOMRegionContext.XML_CDATA_OPEN) || (type == DOMRegionContext.XML_CDATA_CLOSE)) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.CDATA_BORDER); - } else if (type == DOMRegionContext.XML_CDATA_TEXT) { + } + else if (type == DOMRegionContext.XML_CDATA_TEXT) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.CDATA_TEXT); - } else if (type == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) { + } + else if (type == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_ATTRIBUTE_NAME); - } else if (type == DOMRegionContext.XML_DOCTYPE_DECLARATION) { + } + else if (type == DOMRegionContext.XML_DOCTYPE_DECLARATION) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_NAME); - } else if (type == DOMRegionContext.XML_TAG_NAME) { + } + else if (type == DOMRegionContext.XML_TAG_NAME) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_NAME); - } else if ((type == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) { + } + else if ((type == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE); - } else if (type == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) { + } + else if (type == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS); - } else if ((type == DOMRegionContext.XML_COMMENT_OPEN) || (type == DOMRegionContext.XML_COMMENT_CLOSE)) { + } + else if ((type == DOMRegionContext.XML_COMMENT_OPEN) || (type == DOMRegionContext.XML_COMMENT_CLOSE)) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.COMMENT_BORDER); - } else if (type == DOMRegionContext.XML_COMMENT_TEXT) { + } + else if (type == DOMRegionContext.XML_COMMENT_TEXT) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.COMMENT_TEXT); - } else if (type == DOMRegionContext.XML_DOCTYPE_NAME) { + } + else if (type == DOMRegionContext.XML_DOCTYPE_NAME) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.DOCTYPE_NAME); - } else if (type == DOMRegionContext.XML_PI_CONTENT) { + } + else if (type == DOMRegionContext.XML_PI_CONTENT) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.PI_CONTENT); - } else if ((type == DOMRegionContext.XML_PI_OPEN) || (type == DOMRegionContext.XML_PI_CLOSE)) { + } + else if ((type == DOMRegionContext.XML_PI_OPEN) || (type == DOMRegionContext.XML_PI_CLOSE)) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.PI_BORDER); - } else if ((type == DOMRegionContext.XML_DECLARATION_OPEN) || (type == DOMRegionContext.XML_DECLARATION_CLOSE)) { + } + else if ((type == DOMRegionContext.XML_DECLARATION_OPEN) || (type == DOMRegionContext.XML_DECLARATION_CLOSE)) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.DECL_BORDER); - } else if (type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSREF) { + } + else if (type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSREF) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF); - } else if (type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBREF) { + } + else if (type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBREF) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF); - } else if (type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBLIC || type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSTEM) { + } + else if ((type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBLIC) || (type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSTEM)) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID); - } else if (type == DOMRegionContext.UNDEFINED) { + } + else if (type == DOMRegionContext.UNDEFINED) { return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.CDATA_TEXT); - } else if (type == DOMRegionContext.WHITE_SPACE) { + } + else if (type == DOMRegionContext.WHITE_SPACE) { // white space is normall not on its own ... but when it is, we'll // treat as content return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.XML_CONTENT); - } else if ((type == DOMRegionContext.XML_CHAR_REFERENCE) || (type == DOMRegionContext.XML_ENTITY_REFERENCE) || (type == DOMRegionContext.XML_PE_REFERENCE)) { + } + else if ((type == DOMRegionContext.XML_CHAR_REFERENCE) || (type == DOMRegionContext.XML_ENTITY_REFERENCE) || (type == DOMRegionContext.XML_PE_REFERENCE)) { // we may want to character and entity references to have it own // color in future, // but for now, we'll make attribute value return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE); - } else { + } + else { // default, return null to signal "not handled" // in which case, other factories should be tried return null; @@ -102,37 +123,53 @@ // check if preference changed is a style preference if (IStyleConstantsXML.TAG_NAME.equals(prefKey)) { styleKey = IStyleConstantsXML.TAG_NAME; - } else if (IStyleConstantsXML.TAG_BORDER.equals(prefKey)) { + } + else if (IStyleConstantsXML.TAG_BORDER.equals(prefKey)) { styleKey = IStyleConstantsXML.TAG_BORDER; - } else if (IStyleConstantsXML.TAG_ATTRIBUTE_NAME.equals(prefKey)) { + } + else if (IStyleConstantsXML.TAG_ATTRIBUTE_NAME.equals(prefKey)) { styleKey = IStyleConstantsXML.TAG_ATTRIBUTE_NAME; - } else if (IStyleConstantsXML.TAG_ATTRIBUTE_VALUE.equals(prefKey)) { + } + else if (IStyleConstantsXML.TAG_ATTRIBUTE_VALUE.equals(prefKey)) { styleKey = IStyleConstantsXML.TAG_ATTRIBUTE_VALUE; - } else if (IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS.equals(prefKey)) { + } + else if (IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS.equals(prefKey)) { styleKey = IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS; - } else if (IStyleConstantsXML.COMMENT_BORDER.equals(prefKey)) { + } + else if (IStyleConstantsXML.COMMENT_BORDER.equals(prefKey)) { styleKey = IStyleConstantsXML.COMMENT_BORDER; - } else if (IStyleConstantsXML.COMMENT_TEXT.equals(prefKey)) { + } + else if (IStyleConstantsXML.COMMENT_TEXT.equals(prefKey)) { styleKey = IStyleConstantsXML.COMMENT_TEXT; - } else if (IStyleConstantsXML.CDATA_BORDER.equals(prefKey)) { + } + else if (IStyleConstantsXML.CDATA_BORDER.equals(prefKey)) { styleKey = IStyleConstantsXML.CDATA_BORDER; - } else if (IStyleConstantsXML.CDATA_TEXT.equals(prefKey)) { + } + else if (IStyleConstantsXML.CDATA_TEXT.equals(prefKey)) { styleKey = IStyleConstantsXML.CDATA_TEXT; - } else if (IStyleConstantsXML.DECL_BORDER.equals(prefKey)) { + } + else if (IStyleConstantsXML.DECL_BORDER.equals(prefKey)) { styleKey = IStyleConstantsXML.DECL_BORDER; - } else if (IStyleConstantsXML.DOCTYPE_EXTERNAL_ID.equals(prefKey)) { + } + else if (IStyleConstantsXML.DOCTYPE_EXTERNAL_ID.equals(prefKey)) { styleKey = IStyleConstantsXML.DOCTYPE_EXTERNAL_ID; - } else if (IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF.equals(prefKey)) { + } + else if (IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF.equals(prefKey)) { styleKey = IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF; - } else if (IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF.equals(prefKey)) { + } + else if (IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF.equals(prefKey)) { styleKey = IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF; - } else if (IStyleConstantsXML.DOCTYPE_NAME.equals(prefKey)) { + } + else if (IStyleConstantsXML.DOCTYPE_NAME.equals(prefKey)) { styleKey = IStyleConstantsXML.DOCTYPE_NAME; - } else if (IStyleConstantsXML.PI_CONTENT.equals(prefKey)) { + } + else if (IStyleConstantsXML.PI_CONTENT.equals(prefKey)) { styleKey = IStyleConstantsXML.PI_CONTENT; - } else if (IStyleConstantsXML.PI_BORDER.equals(prefKey)) { + } + else if (IStyleConstantsXML.PI_BORDER.equals(prefKey)) { styleKey = IStyleConstantsXML.PI_BORDER; - } else if (IStyleConstantsXML.XML_CONTENT.equals(prefKey)) { + } + else if (IStyleConstantsXML.XML_CONTENT.equals(prefKey)) { styleKey = IStyleConstantsXML.XML_CONTENT; } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/MarkupTagInfoProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/MarkupTagInfoProvider.java index 5b553d8..47513ef 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/MarkupTagInfoProvider.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/MarkupTagInfoProvider.java
@@ -39,12 +39,13 @@ /** * Returns basic tag information for display given a CMNode - * + * * @return String */ public String getInfo(CMNode node) { - if (node == null) + if (node == null) { return null; + } StringBuffer sb = new StringBuffer(); // we assume that if there is tagInfo present, only display tagInfo printTagInfo(sb, node); @@ -75,7 +76,7 @@ sb.append(PARAGRAPH_END); } String[] enumeratedValue = dataType.getEnumeratedValues(); - if (enumeratedValue != null && enumeratedValue.length > 0) { + if ((enumeratedValue != null) && (enumeratedValue.length > 0)) { sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Enumerated_Values____5 + SPACE + BOLD_END); sb.append(LIST_BEGIN); for (int i = 0; i < enumeratedValue.length; i++) { @@ -104,7 +105,8 @@ if (dataType != null) { printDataTypeInfo(sb, dataType); } - } else { + } + else { CMDescriptionBuilder builder = new CMDescriptionBuilder(); String description = builder.buildDescription(node); if ((description != null) && (description.length() > 0)) { @@ -112,7 +114,8 @@ sb.append(description + PARAGRAPH_END); } } - } else if (node.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) { + } + else if (node.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) { CMAttributeDeclaration ad = (CMAttributeDeclaration) node; sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Attribute____3 + SPACE + BOLD_END); sb.append(node.getNodeName()); @@ -122,7 +125,8 @@ if (dataType != null) { printDataTypeInfo(sb, dataType); } - } else if (node.getNodeType() == CMNode.DATA_TYPE) { + } + else if (node.getNodeType() == CMNode.DATA_TYPE) { sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Data_Type____4 + SPACE + BOLD_END); sb.append(node.getNodeName()); sb.append(PARAGRAPH_END);
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java index 2825dd9..41c3f64 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java
@@ -16,7 +16,6 @@ import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.ITextHover; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.Region; import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; @@ -67,12 +66,14 @@ String result = null; IndexedRegion treeNode = ContentAssistUtils.getNodeAt(textViewer, documentPosition); - if (treeNode == null) + if (treeNode == null) { return null; + } Node node = (Node) treeNode; - while (node != null && node.getNodeType() == Node.TEXT_NODE && node.getParentNode() != null) + while ((node != null) && (node.getNodeType() == Node.TEXT_NODE) && (node.getParentNode() != null)) { node = node.getParentNode(); + } IDOMNode parentNode = (IDOMNode) node; IStructuredDocumentRegion flatNode = ((IStructuredDocument) textViewer.getDocument()).getRegionAtCharacterOffset(documentPosition); @@ -93,15 +94,19 @@ */ protected String computeRegionHelp(IndexedRegion treeNode, IDOMNode parentNode, IStructuredDocumentRegion flatNode, ITextRegion region) { String result = null; - if (region == null) + if (region == null) { return null; + } String regionType = region.getType(); - if (regionType == DOMRegionContext.XML_TAG_NAME) + if (regionType == DOMRegionContext.XML_TAG_NAME) { result = computeTagNameHelp((IDOMNode) treeNode, parentNode, flatNode, region); - else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) + } + else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) { result = computeTagAttNameHelp((IDOMNode) treeNode, parentNode, flatNode, region); - else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) + } + else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { result = computeTagAttValueHelp((IDOMNode) treeNode, parentNode, flatNode, region); + } return result; } @@ -156,8 +161,9 @@ } addlInfo = getInfoProvider().getInfo(cmnode); - if (addlInfo == null && parentOrOwner != null) + if ((addlInfo == null) && (parentOrOwner != null)) { addlInfo = getInfoProvider().getInfo(parentOrOwner); + } return addlInfo; } @@ -171,13 +177,15 @@ IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion(); ITextRegionList openRegions = open.getRegions(); int i = openRegions.indexOf(region); - if (i < 0) + if (i < 0) { return null; + } ITextRegion nameRegion = null; while (i >= 0) { nameRegion = openRegions.get(i--); - if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) + if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) { break; + } } return nameRegion; } @@ -212,8 +220,9 @@ CMElementDeclaration result = null; if (node.getNodeType() == Node.ELEMENT_NODE) { ModelQuery modelQuery = ModelQueryUtil.getModelQuery(node.getOwnerDocument()); - if (modelQuery != null) + if (modelQuery != null) { result = modelQuery.getCMElementDeclaration((Element) node); + } } return result; } @@ -225,8 +234,9 @@ * org.eclipse.jface.text.IRegion) */ public String getHoverInfo(ITextViewer viewer, IRegion hoverRegion) { - if ((hoverRegion == null) || (viewer == null) || (viewer.getDocument() == null)) + if ((hoverRegion == null) || (viewer == null) || (viewer.getDocument() == null)) { return null; + } String displayText = null; int documentOffset = hoverRegion.getOffset(); @@ -245,11 +255,12 @@ * attribute name, or attribute value and if offset is not over * invalid whitespace. otherwise, returns <code>null</code> * - * @see ITextHover#getHoverRegion(ITextViewer, int) + * @see org.eclipse.jface.text.ITextHover#getHoverRegion(ITextViewer, int) */ public IRegion getHoverRegion(ITextViewer textViewer, int offset) { - if ((textViewer == null) || (textViewer.getDocument() == null)) + if ((textViewer == null) || (textViewer.getDocument() == null)) { return null; + } IStructuredDocumentRegion flatNode = ((IStructuredDocument) textViewer.getDocument()).getRegionAtCharacterOffset(offset); ITextRegion region = null; @@ -287,8 +298,9 @@ * first place if true, use getHoverRegion(ITextViewer, int) */ public IRegion getHoverRegion(ITextViewer textViewer, int offset, boolean enabled) { - if ((!enabled) || (textViewer == null) || (textViewer.getDocument() == null)) + if ((!enabled) || (textViewer == null) || (textViewer.getDocument() == null)) { return null; + } IStructuredDocumentRegion flatNode = ((IStructuredDocument) textViewer.getDocument()).getRegionAtCharacterOffset(offset); ITextRegion region = null;
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/XMLCommonResources.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/XMLCommonResources.java index 83f41f7..8504e81 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/XMLCommonResources.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/XMLCommonResources.java
@@ -32,8 +32,9 @@ protected static XMLCommonResources instance; public synchronized static XMLCommonResources getInstance() { - if (instance == null) + if (instance == null) { instance = new XMLCommonResources(XMLUIPlugin.getDefault()); + } return instance; } @@ -46,15 +47,16 @@ this.editorPlugin = editorPlugin; try { resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.xml.ui.internal.XMLUIPluginResources"); //$NON-NLS-1$ - } catch (MissingResourceException exception) { - //TODO... log an error message - //B2BUtilPlugin.getPlugin().getMsgLogger().write(B2BUtilPlugin.getGUIString("_WARN_PLUGIN_PROPERTIES_MISSING") + } + catch (MissingResourceException exception) { + // TODO... log an error message + // B2BUtilPlugin.getPlugin().getMsgLogger().write(B2BUtilPlugin.getGUIString("_WARN_PLUGIN_PROPERTIES_MISSING") // + descriptor.getLabel()); resourceBundle = null; } } - ImageDescriptor _getImageDescriptor(String iconName) { + ImageDescriptor _getImageDescriptor(String iconName) { return AbstractUIPlugin.imageDescriptorFromPlugin(XMLUIPlugin.ID, iconName); }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidator.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidator.java index b6bd222..d3502ea 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidator.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidator.java
@@ -54,27 +54,30 @@ protected static final String FIRST_NON_WHITESPACE_TEXT = "FIRST_NON_WHITESPACE_TEXT"; //$NON-NLS-1$ protected static final String TEXT_ENTITY_REFERENCE = "TEXT_ENTITY_REFERENCE"; //$NON-NLS-1$ protected static final String VALUE_OF_ATTRIBUTE_WITH_GIVEN_VALUE = "VALUE_OF_ATTRIBUTE_WITH_GIVEN_VALUE"; //$NON-NLS-1$ - - /** - * This constant specifies the attribute name that specifies the side of the 'start tag' - * that the validator has used to report an error. A validator may choose to report a message - * at the left (the start of the start tag)or at the right (the end of the start tag). - * When this attribute is not specified error ERROR_SIDE_LEFT is the default. - */ + + /** + * This constant specifies the attribute name that specifies the side of + * the 'start tag' that the validator has used to report an error. A + * validator may choose to report a message at the left (the start of the + * start tag)or at the right (the end of the start tag). When this + * attribute is not specified error ERROR_SIDE_LEFT is the default. + */ protected static final String ERROR_SIDE = "ERROR_SIDE"; //$NON-NLS-1$ - - /** - * When the ERROR_SIDE attribute specifies the ERROR_SIDE_LEFT value it is assumed - * that the message specifies a location to the left of the start tag - */ + + /** + * When the ERROR_SIDE attribute specifies the ERROR_SIDE_LEFT value it is + * assumed that the message specifies a location to the left of the start + * tag + */ protected static final String ERROR_SIDE_LEFT = "ERROR_SIDE_LEFT"; //$NON-NLS-1$ - - /** - * When the ERROR_SIDE attribute specifies the ERROR_SIDE_RIGHT value it is assumed - * that the message specifies a location to the right of the start tag - */ + + /** + * When the ERROR_SIDE attribute specifies the ERROR_SIDE_RIGHT value it + * is assumed that the message specifies a location to the right of the + * start tag + */ protected static final String ERROR_SIDE_RIGHT = "ERROR_SIDE_RIGHT"; //$NON-NLS-1$ - + protected static final String COLUMN_NUMBER_ATTRIBUTE = "columnNumber"; //$NON-NLS-1$ protected static final String SQUIGGLE_SELECTION_STRATEGY_ATTRIBUTE = "squiggleSelectionStrategy"; //$NON-NLS-1$ protected static final String SQUIGGLE_NAME_OR_VALUE_ATTRIBUTE = "squiggleNameOrValue"; //$NON-NLS-1$ @@ -116,8 +119,9 @@ } public String[] getURIs() { - if (file != null) + if (file != null) { return new String[]{file.getFullPath().toString()}; + } return new String[0]; } @@ -196,7 +200,8 @@ byte[] byteArray; try { byteArray = xmlModel.getStructuredDocument().get().getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { + } + catch (UnsupportedEncodingException e) { // Not likely to happen byteArray = xmlModel.getStructuredDocument().get().getBytes(); } @@ -223,8 +228,9 @@ finally { - if (xmlModel != null) + if (xmlModel != null) { xmlModel.releaseFromRead(); + } } } } @@ -302,17 +308,19 @@ return model instanceof IDOMModel ? (IDOMModel) model : null; } - /** - * @deprecated use computeStartEndLocation(int startOffset, String errorMessage, String selectionStrategy, boolean leftError, String nameOrValue, IDOMDocument document) { - * - */ - protected int[] computeStartEndLocation(int startOffset, String errorMessage, String selectionStrategy, String nameOrValue, IDOMDocument document) - { - return computeStartAndEndLocation(startOffset, selectionStrategy, ERROR_SIDE_RIGHT, nameOrValue, document); - } - + /** + * @deprecated use computeStartEndLocation(int startOffset, String + * errorMessage, String selectionStrategy, boolean leftError, + * String nameOrValue, IDOMDocument document) { + * + */ + protected int[] computeStartEndLocation(int startOffset, String errorMessage, String selectionStrategy, String nameOrValue, IDOMDocument document) { + return computeStartAndEndLocation(startOffset, selectionStrategy, ERROR_SIDE_RIGHT, nameOrValue, document); + } + /** * Calculates the "better" offsets. + * * @param startOffset - * the offset given by Xerces * @param errorMessage - @@ -327,11 +335,10 @@ /* * The way the offsets is calculated is: - find the indexed region * (element) closest to the given offset - if we are between two elements, - * choosing left or right element will depend on parameter 'errorSide' - * - based on the selectionStrategy choose the underlining strategy - * (eg START_TAG means underline the start tag of that element) - * - use information from nameOrValue and the DOM to - * get better offsets + * choosing left or right element will depend on parameter 'errorSide' - + * based on the selectionStrategy choose the underlining strategy (eg + * START_TAG means underline the start tag of that element) - use + * information from nameOrValue and the DOM to get better offsets * */ protected int[] computeStartAndEndLocation(int startOffset, String selectionStrategy, String errorSide, String nameOrValue, IDOMDocument document) { @@ -342,15 +349,18 @@ IndexedRegion prevRegion = document.getModel().getIndexedRegion(startOffset - 1); if (prevRegion != region) { - // if between two regions we use the 'errorSide' to understand which - // element is applicable. if we know the error has been reported to the - // right of the tag, then we can assume we need to step back to the previous - // region to land at the 'correct location. Otherwise assume we're - // exactly where we need to be. - if (ERROR_SIDE_LEFT.equals(errorSide)) - { - region = prevRegion; - } + // if between two regions we use the 'errorSide' to understand + // which + // element is applicable. if we know the error has been + // reported to the + // right of the tag, then we can assume we need to step back + // to the previous + // region to land at the 'correct location. Otherwise assume + // we're + // exactly where we need to be. + if (ERROR_SIDE_LEFT.equals(errorSide)) { + region = prevRegion; + } } // initialize start and end positions to be the start positions @@ -408,7 +418,7 @@ if (attributes != null) { IDOMNode first = (IDOMNode) attributes.item(0); IDOMNode last = (IDOMNode) attributes.item(attributes.getLength() - 1); - if (first != null && last != null) { + if ((first != null) && (last != null)) { startEndPositions[0] = first.getStartOffset(); startEndPositions[1] = last.getEndOffset(); } @@ -425,7 +435,7 @@ char curChar = value.charAt(index); // here we are finding start offset by skipping over // whitespace: - while (curChar == '\n' || curChar == '\t' || curChar == '\r' || curChar == ' ') { + while ((curChar == '\n') || (curChar == '\t') || (curChar == '\r') || (curChar == ' ')) { curChar = value.charAt(index); index++; } @@ -456,8 +466,11 @@ for (int i = 0; i < nodes.getLength(); i++) { Node currentNode = nodes.item(i); if (currentNode.getNodeType() == Node.TEXT_NODE) { - // TODO (Trung) I don't think we should call getNodeValue(), trim(), length() repeatedly. - // This is inefficient, to improve use local variables to store values. + // TODO (Trung) I don't think we should call + // getNodeValue(), trim(), length() + // repeatedly. + // This is inefficient, to improve use local + // variables to store values. IDOMText textNode = (IDOMText) currentNode; if (textNode.getNodeValue().trim().length() > 0) { String value = textNode.getNodeValue(); @@ -466,7 +479,7 @@ char curChar = value.charAt(index); // here we are finding start offset by // skipping over whitespace: - while (curChar == '\n' || curChar == '\t' || curChar == '\r' || curChar == ' ') { + while ((curChar == '\n') || (curChar == '\t') || (curChar == '\r') || (curChar == ' ')) { curChar = value.charAt(index); index++; } @@ -513,14 +526,17 @@ } else if (VALUE_OF_ATTRIBUTE_WITH_GIVEN_VALUE.equals(selectionStrategy)) { // TODO (Trung) do we really need this strategy ? - // If we know the name of the name of the attribute, we can retrieve its value. - // Hence, we can incoperate this strategy with ATTRIBUTE_VALUE ? + // If we know the name of the name of the attribute, we + // can retrieve its value. + // Hence, we can incoperate this strategy with + // ATTRIBUTE_VALUE ? if (node.getNodeType() == Node.ELEMENT_NODE) { // here we will search through all attributes for the // one with the // with the value we want: // TODO (Trung) I see a potential problem here. - // What happens when there is another attribute having the same value + // What happens when there is another attribute having + // the same value // with this attribute's buggy value ? // Need to solve when time permits. NamedNodeMap attributes = node.getAttributes(); @@ -556,11 +572,11 @@ protected boolean isDelegateValidatorEnabled(IFile file) { return true; } - - protected String getErrorSide(IMessage message) - { - // note that if the ERROR_SIDE is unspecified we return the default value ERROR_SIDE_LEFT - Object value = message.getAttribute(ERROR_SIDE); - return ERROR_SIDE_RIGHT.equals(value) ? ERROR_SIDE_RIGHT : ERROR_SIDE_LEFT; - } + + protected String getErrorSide(IMessage message) { + // note that if the ERROR_SIDE is unspecified we return the default + // value ERROR_SIDE_LEFT + Object value = message.getAttribute(ERROR_SIDE); + return ERROR_SIDE_RIGHT.equals(value) ? ERROR_SIDE_RIGHT : ERROR_SIDE_LEFT; + } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidatorForXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidatorForXML.java index cde9107..bfd57c7 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidatorForXML.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidatorForXML.java
@@ -49,10 +49,12 @@ try { ProjectConfiguration configuration = ConfigurationManager.getManager().getProjectConfiguration(file.getProject()); ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(VALIDATOR_CLASS); - if (configuration.isBuildEnabled(vmd) || configuration.isManualEnabled(vmd)) + if (configuration.isBuildEnabled(vmd) || configuration.isManualEnabled(vmd)) { enabled = true; - else + } + else { enabled = false; + } } catch (InvocationTargetException e) { Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/MarkupValidator.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/MarkupValidator.java index cdb7e62..560c985 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/MarkupValidator.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/MarkupValidator.java
@@ -42,8 +42,8 @@ import org.w3c.dom.Node; /** - * Basic XML syntax checking step. - * Only used as ISourceValidator at the momment + * Basic XML syntax checking step. Only used as ISourceValidator at the + * momment * * @author pavery */ @@ -62,35 +62,38 @@ private IDocument fDocument; - private void addAttributeError(String messageText, String attributeValueText, int start, int length, int problemId, IStructuredDocumentRegion sdRegion, IReporter reporter) { - - if (sdRegion.isDeleted()) - return; - - int lineNo = getLineNumber(start); - LocalizedMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText); - message.setOffset(start); - message.setLength(length); - message.setLineNo(lineNo); - - AnnotationInfo info = new AnnotationInfo(message, problemId, attributeValueText); - ((IncrementalReporter)reporter).addAnnotationInfo(this, info); + private void addAttributeError(String messageText, String attributeValueText, int start, int length, int problemId, IStructuredDocumentRegion sdRegion, IReporter reporter) { + + if (sdRegion.isDeleted()) { + return; + } + + int lineNo = getLineNumber(start); + LocalizedMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText); + message.setOffset(start); + message.setLength(length); + message.setLineNo(lineNo); + + AnnotationInfo info = new AnnotationInfo(message, problemId, attributeValueText); + ((IncrementalReporter) reporter).addAnnotationInfo(this, info); } private void checkAttributesInEndTag(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) { - - if(structuredDocumentRegion.isDeleted()) - return; - + + if (structuredDocumentRegion.isDeleted()) { + return; + } + ITextRegionList textRegions = structuredDocumentRegion.getRegions(); int errorCount = 0; int start = structuredDocumentRegion.getEndOffset(); int end = structuredDocumentRegion.getEndOffset(); - for (int i = 0; i < textRegions.size() && errorCount < AbstractStructuredTextReconcilingStrategy.ELEMENT_ERROR_LIMIT && !structuredDocumentRegion.isDeleted(); i++) { + for (int i = 0; (i < textRegions.size()) && (errorCount < AbstractStructuredTextReconcilingStrategy.ELEMENT_ERROR_LIMIT) && !structuredDocumentRegion.isDeleted(); i++) { ITextRegion textRegion = textRegions.get(i); - if (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME || textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS || textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { - if (start > structuredDocumentRegion.getStartOffset(textRegion)) + if ((textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) || (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) { + if (start > structuredDocumentRegion.getStartOffset(textRegion)) { start = structuredDocumentRegion.getStartOffset(textRegion); + } end = structuredDocumentRegion.getEndOffset(textRegion); errorCount++; } @@ -103,25 +106,27 @@ message.setOffset(start); message.setLength(end - start); message.setLineNo(getLineNumber(start)); - + AnnotationInfo info = new AnnotationInfo(message, ProblemIDsXML.AttrsInEndTag, null); - ((IncrementalReporter)reporter).addAnnotationInfo(this, info); + ((IncrementalReporter) reporter).addAnnotationInfo(this, info); } } private void checkClosingBracket(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) { - - if(structuredDocumentRegion.isDeleted()) - return; - + + if (structuredDocumentRegion.isDeleted()) { + return; + } + ITextRegionList regions = structuredDocumentRegion.getRegions(); ITextRegion r = null; boolean closed = false; - for (int i = 0; i < regions.size() && !structuredDocumentRegion.isDeleted(); i++) { + for (int i = 0; (i < regions.size()) && !structuredDocumentRegion.isDeleted(); i++) { r = regions.get(i); - if (r.getType() == DOMRegionContext.XML_TAG_CLOSE || r.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) + if ((r.getType() == DOMRegionContext.XML_TAG_CLOSE) || (r.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE)) { closed = true; + } } if (!closed) { @@ -130,39 +135,40 @@ int start = structuredDocumentRegion.getStartOffset(); int length = structuredDocumentRegion.getText().trim().length(); int lineNo = getLineNumber(start); - + LocalizedMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText); message.setOffset(start); message.setLength(length); message.setLineNo(lineNo); - + AnnotationInfo info = new AnnotationInfo(message, ProblemIDsXML.MissingClosingBracket, null); - ((IncrementalReporter)reporter).addAnnotationInfo(this, info); + ((IncrementalReporter) reporter).addAnnotationInfo(this, info); } } private void checkEmptyTag(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) { - - if(structuredDocumentRegion.isDeleted()) - return; - + + if (structuredDocumentRegion.isDeleted()) { + return; + } + // navigate to name ITextRegionList regions = structuredDocumentRegion.getRegions(); if (regions.size() == 2) { // missing name region - if (regions.get(0).getType() == DOMRegionContext.XML_TAG_OPEN && regions.get(1).getType() == DOMRegionContext.XML_TAG_CLOSE) { + if ((regions.get(0).getType() == DOMRegionContext.XML_TAG_OPEN) && (regions.get(1).getType() == DOMRegionContext.XML_TAG_CLOSE)) { String messageText = XMLUIMessages.ReconcileStepForMarkup_3; int start = structuredDocumentRegion.getStartOffset(); int length = structuredDocumentRegion.getLength(); int lineNo = getLineNumber(start); - + LocalizedMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText); message.setOffset(start); message.setLength(length); message.setLineNo(lineNo); - + AnnotationInfo info = new AnnotationInfo(message, ProblemIDsXML.EmptyTag, null); - ((IncrementalReporter)reporter).addAnnotationInfo(this, info); + ((IncrementalReporter) reporter).addAnnotationInfo(this, info); } } } @@ -179,53 +185,55 @@ } private void checkForAttributeValue(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) { - - if(structuredDocumentRegion.isDeleted()) - return; - + + if (structuredDocumentRegion.isDeleted()) { + return; + } + // check for attributes without a value // track the attribute/equals/value sequence using a state of 0, 1 ,2 // representing the name, =, and value, respectively int attrState = 0; ITextRegionList textRegions = structuredDocumentRegion.getRegions(); - // ReconcileAnnotationKey key = createKey(structuredDocumentRegion, getScope()); - + // ReconcileAnnotationKey key = createKey(structuredDocumentRegion, + // getScope()); + int errorCount = 0; - for (int i = 0; i < textRegions.size() && errorCount < AbstractStructuredTextReconcilingStrategy.ELEMENT_ERROR_LIMIT; i++) { + for (int i = 0; (i < textRegions.size()) && (errorCount < AbstractStructuredTextReconcilingStrategy.ELEMENT_ERROR_LIMIT); i++) { ITextRegion textRegion = textRegions.get(i); - if (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME || isTagCloseTextRegion(textRegion)) { + if ((textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || isTagCloseTextRegion(textRegion)) { // dangling name and '=' - if (attrState == 2 && i >= 2) { + if ((attrState == 2) && (i >= 2)) { // create annotation ITextRegion nameRegion = textRegions.get(i - 2); Object[] args = {structuredDocumentRegion.getText(nameRegion)}; String messageText = NLS.bind(XMLUIMessages.Attribute__is_missing_a_value, args); - + int start = structuredDocumentRegion.getStartOffset(nameRegion); int end = structuredDocumentRegion.getEndOffset(); int lineNo = getLineNumber(start); int textLength = structuredDocumentRegion.getText(nameRegion).trim().length(); - + LocalizedMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText); message.setOffset(start); message.setLength(textLength); message.setLineNo(lineNo); - + // quick fix info ITextRegion equalsRegion = textRegions.get(i - 2 + 1); int insertOffset = structuredDocumentRegion.getTextEndOffset(equalsRegion) - end; Object[] additionalFixInfo = {structuredDocumentRegion.getText(nameRegion), new Integer(insertOffset)}; - + AnnotationInfo info = new AnnotationInfo(message, ProblemIDsXML.MissingAttrValue, additionalFixInfo); - - ((IncrementalReporter)reporter).addAnnotationInfo(this, info); - + + ((IncrementalReporter) reporter).addAnnotationInfo(this, info); + // annotation.setAdditionalFixInfo(additionalFixInfo); - //results.add(annotation); + // results.add(annotation); errorCount++; } // name but no '=' (XML only) - else if (attrState == 1 && i >= 1) { + else if ((attrState == 1) && (i >= 1)) { // create annotation ITextRegion previousRegion = textRegions.get(i - 1); Object[] args = {structuredDocumentRegion.getText(previousRegion)}; @@ -233,22 +241,24 @@ int start = structuredDocumentRegion.getStartOffset(previousRegion); int textLength = structuredDocumentRegion.getText(previousRegion).trim().length(); int lineNo = getLineNumber(start); - + LocalizedMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText); message.setOffset(start); message.setLength(textLength); message.setLineNo(lineNo); - + AnnotationInfo info = new AnnotationInfo(message, ProblemIDsXML.NoAttrValue, structuredDocumentRegion.getText(previousRegion)); - - ((IncrementalReporter)reporter).addAnnotationInfo(this, info); - + + ((IncrementalReporter) reporter).addAnnotationInfo(this, info); + errorCount++; } attrState = 1; - } else if (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) { + } + else if (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) { attrState = 2; - } else if (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { + } + else if (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { attrState = 0; } } @@ -256,44 +266,46 @@ } private void checkForSpaceBeforeName(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) { - - if(structuredDocumentRegion.isDeleted()) - return; - + + if (structuredDocumentRegion.isDeleted()) { + return; + } + String sdRegionText = structuredDocumentRegion.getFullText(); if (sdRegionText.startsWith(" ")) { //$NON-NLS-1$ IStructuredDocumentRegion prev = structuredDocumentRegion.getPrevious(); if (prev != null) { // this is possibly the case of "< tag" - if (prev.getRegions().size() == 1 && isStartTag(prev)) { + if ((prev.getRegions().size() == 1) && isStartTag(prev)) { // add the error for preceding space in tag name String messageText = XMLUIMessages.ReconcileStepForMarkup_2; int start = structuredDocumentRegion.getStartOffset(); // find length of whitespace int length = sdRegionText.trim().equals("") ? sdRegionText.length() : sdRegionText.indexOf(sdRegionText.trim()); //$NON-NLS-1$ - + LocalizedMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText); message.setOffset(start); message.setLength(length); message.setLineNo(getLineNumber(start)); - + AnnotationInfo info = new AnnotationInfo(message, ProblemIDsXML.SpacesBeforeTagName, null); - ((IncrementalReporter)reporter).addAnnotationInfo(this, info); + ((IncrementalReporter) reporter).addAnnotationInfo(this, info); } } } } private void checkNoNamespaceInPI(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) { - - if(structuredDocumentRegion.isDeleted()) - return; - + + if (structuredDocumentRegion.isDeleted()) { + return; + } + // navigate to name ITextRegionList regions = structuredDocumentRegion.getRegions(); ITextRegion r = null; int errorCount = 0; - for (int i = 0; i < regions.size() && errorCount < AbstractStructuredTextReconcilingStrategy.ELEMENT_ERROR_LIMIT && !structuredDocumentRegion.isDeleted(); i++) { + for (int i = 0; (i < regions.size()) && (errorCount < AbstractStructuredTextReconcilingStrategy.ELEMENT_ERROR_LIMIT) && !structuredDocumentRegion.isDeleted(); i++) { r = regions.get(i); if (r.getType() == DOMRegionContext.XML_TAG_NAME) { String piText = structuredDocumentRegion.getText(r); @@ -302,14 +314,14 @@ String messageText = XMLUIMessages.ReconcileStepForMarkup_4; int start = structuredDocumentRegion.getStartOffset(r) + index; int length = piText.trim().length() - index; - + LocalizedMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText); message.setOffset(start); message.setLength(length); message.setLineNo(getLineNumber(start)); - + AnnotationInfo info = new AnnotationInfo(message, ProblemIDsXML.NamespaceInPI, null); - ((IncrementalReporter)reporter).addAnnotationInfo(this, info); + ((IncrementalReporter) reporter).addAnnotationInfo(this, info); errorCount++; } @@ -322,10 +334,11 @@ ITextRegion r = null; String attrValueText = ""; //$NON-NLS-1$ int errorCount = 0; - for (int i = 0; i < regions.size() && errorCount < AbstractStructuredTextReconcilingStrategy.ELEMENT_ERROR_LIMIT; i++) { + for (int i = 0; (i < regions.size()) && (errorCount < AbstractStructuredTextReconcilingStrategy.ELEMENT_ERROR_LIMIT); i++) { r = regions.get(i); - if (r.getType() != DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) + if (r.getType() != DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { continue; + } attrValueText = structuredDocumentRegion.getText(r); // attribute value includes quotes in the string @@ -340,10 +353,12 @@ int size = st.countTokens(); // get the pieces of the attribute value String one = "", two = ""; //$NON-NLS-1$ //$NON-NLS-2$ - if (size > 0) + if (size > 0) { one = st.nextToken(); - if (size > 1) + } + if (size > 1) { two = st.nextToken(); + } if (size > 2) { // should be handled by parsing... // as in we can't have an attribute value like: <element @@ -359,14 +374,16 @@ String message = XMLUIMessages.ReconcileStepForMarkup_0; addAttributeError(message, attrValueText, structuredDocumentRegion.getStartOffset(r), attrValueText.trim().length(), ProblemIDsXML.Unclassified, structuredDocumentRegion, reporter); errorCount++; - } else { + } + else { // missing both String message = XMLUIMessages.ReconcileStepForMarkup_1; addAttributeError(message, attrValueText, structuredDocumentRegion.getStartOffset(r), attrValueText.trim().length(), ProblemIDsXML.AttrValueNotQuoted, structuredDocumentRegion, reporter); errorCount++; } - } else if (size == 2) { - if (one.equals(SQUOTE) && !two.equals(SQUOTE) || one.equals(DQUOTE) && !two.equals(DQUOTE)) { + } + else if (size == 2) { + if ((one.equals(SQUOTE) && !two.equals(SQUOTE)) || (one.equals(DQUOTE) && !two.equals(DQUOTE))) { // missing closing quote String message = XMLUIMessages.ReconcileStepForMarkup_0; addAttributeError(message, attrValueText, structuredDocumentRegion.getStartOffset(r), attrValueText.trim().length(), ProblemIDsXML.Unclassified, structuredDocumentRegion, reporter); @@ -378,16 +395,18 @@ } private void checkStartEndTagPairs(IStructuredDocumentRegion sdRegion, IReporter reporter) { - - if(sdRegion.isDeleted()) - return; - + + if (sdRegion.isDeleted()) { + return; + } + // check start/end tag pairs IDOMNode xmlNode = getXMLNode(sdRegion); - - if(xmlNode == null) - return; - + + if (xmlNode == null) { + return; + } + boolean selfClosed = false; String tagName = null; int length = 0; @@ -395,50 +414,52 @@ if (xmlNode.isContainer()) { IStructuredDocumentRegion endRegion = xmlNode.getEndStructuredDocumentRegion(); if (endRegion == null) { - IStructuredDocumentRegion startRegion = xmlNode.getStartStructuredDocumentRegion(); - if(!startRegion.isDeleted()) { - // analyze the tag (check self closing) - ITextRegionList regions = startRegion.getRegions(); - ITextRegion r = null; - for (int i = 0; i < regions.size(); i++) { - r = regions.get(i); - if (r.getType() == DOMRegionContext.XML_TAG_OPEN || r.getType() == DOMRegionContext.XML_TAG_CLOSE) { - length++; - } else if (r.getType() == DOMRegionContext.XML_TAG_NAME) { - tagName = sdRegion.getText(r); - length += tagName.length(); - } else if (r.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) { - selfClosed = true; - } - } - - if (!selfClosed && tagName != null) { - Object[] args = {tagName}; - String messageText = NLS.bind(XMLUIMessages.Missing_end_tag_, args); - - int start = sdRegion.getStart(); - int lineNumber = getLineNumber(start); - - //SEVERITY_STRUCTURE == IMessage.HIGH_SEVERITY - IMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText); - message.setOffset(start); - message.setLength(length); - message.setLineNo(lineNumber); - - if(reporter instanceof IncrementalReporter) { - - Object[] additionalFixInfo = getStartEndFixInfo(xmlNode, tagName, r); - - AnnotationInfo info = new AnnotationInfo(message, ProblemIDsXML.MissingEndTag, additionalFixInfo); - //annotation.setAdditionalFixInfo(additionalFixInfo); - ((IncrementalReporter)reporter).addAnnotationInfo(this, info); - } - else { - reporter.addMessage(this, message); - } - } - } - } + IStructuredDocumentRegion startRegion = xmlNode.getStartStructuredDocumentRegion(); + if (!startRegion.isDeleted()) { + // analyze the tag (check self closing) + ITextRegionList regions = startRegion.getRegions(); + ITextRegion r = null; + for (int i = 0; i < regions.size(); i++) { + r = regions.get(i); + if ((r.getType() == DOMRegionContext.XML_TAG_OPEN) || (r.getType() == DOMRegionContext.XML_TAG_CLOSE)) { + length++; + } + else if (r.getType() == DOMRegionContext.XML_TAG_NAME) { + tagName = sdRegion.getText(r); + length += tagName.length(); + } + else if (r.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) { + selfClosed = true; + } + } + + if (!selfClosed && (tagName != null)) { + Object[] args = {tagName}; + String messageText = NLS.bind(XMLUIMessages.Missing_end_tag_, args); + + int start = sdRegion.getStart(); + int lineNumber = getLineNumber(start); + + // SEVERITY_STRUCTURE == IMessage.HIGH_SEVERITY + IMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText); + message.setOffset(start); + message.setLength(length); + message.setLineNo(lineNumber); + + if (reporter instanceof IncrementalReporter) { + + Object[] additionalFixInfo = getStartEndFixInfo(xmlNode, tagName, r); + + AnnotationInfo info = new AnnotationInfo(message, ProblemIDsXML.MissingEndTag, additionalFixInfo); + // annotation.setAdditionalFixInfo(additionalFixInfo); + ((IncrementalReporter) reporter).addAnnotationInfo(this, info); + } + else { + reporter.addMessage(this, message); + } + } + } + } } } @@ -447,12 +468,12 @@ // quick fix info String tagClose = "/>"; //$NON-NLS-1$ int tagCloseOffset = xmlNode.getFirstStructuredDocumentRegion().getEndOffset(); - if (r != null && r.getType() == DOMRegionContext.XML_TAG_CLOSE) { + if ((r != null) && (r.getType() == DOMRegionContext.XML_TAG_CLOSE)) { tagClose = "/"; //$NON-NLS-1$ tagCloseOffset--; } IDOMNode firstChild = (IDOMNode) xmlNode.getFirstChild(); - while (firstChild != null && firstChild.getNodeType() == Node.TEXT_NODE) { + while ((firstChild != null) && (firstChild.getNodeType() == Node.TEXT_NODE)) { firstChild = (IDOMNode) firstChild.getNextSibling(); } int endOffset = xmlNode.getEndOffset(); @@ -464,31 +485,35 @@ } private void checkStartingSpaceForPI(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) { - - if(structuredDocumentRegion.isDeleted()) - return; - + + if (structuredDocumentRegion.isDeleted()) { + return; + } + IStructuredDocumentRegion prev = structuredDocumentRegion.getPrevious(); - if (prev != null && !prev.isDeleted()) { + if ((prev != null) && !prev.isDeleted()) { String prevText = prev.getFullText(); - if (prev.getType() == DOMRegionContext.XML_CONTENT && prevText.endsWith(" ")) { //$NON-NLS-1$ + if ((prev.getType() == DOMRegionContext.XML_CONTENT) && prevText.endsWith(" ")) { //$NON-NLS-1$ String messageText = XMLUIMessages.ReconcileStepForMarkup_5; int start = prev.getStartOffset(); int length = prev.getLength(); - + LocalizedMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText); message.setOffset(start); message.setLength(length); message.setLineNo(getLineNumber(start)); - + AnnotationInfo info = new AnnotationInfo(message, ProblemIDsXML.SpacesBeforePI, null); - ((IncrementalReporter)reporter).addAnnotationInfo(this, info); - -// Position p = new Position(start, length); -// -// ReconcileAnnotationKey key = createKey(structuredDocumentRegion, getScope()); -// TemporaryAnnotation annotation = new TemporaryAnnotation(p, SEVERITY_SYNTAX_ERROR, message, key, ProblemIDsXML.SpacesBeforePI); -// results.add(annotation); + ((IncrementalReporter) reporter).addAnnotationInfo(this, info); + + // Position p = new Position(start, length); + // + // ReconcileAnnotationKey key = + // createKey(structuredDocumentRegion, getScope()); + // TemporaryAnnotation annotation = new TemporaryAnnotation(p, + // SEVERITY_SYNTAX_ERROR, message, key, + // ProblemIDsXML.SpacesBeforePI); + // results.add(annotation); } } } @@ -498,10 +523,11 @@ } private IDOMNode getXMLNode(IStructuredDocumentRegion sdRegion) { - - if(sdRegion == null) - return null; - + + if (sdRegion == null) { + return null; + } + IStructuredModel xModel = null; IDOMNode xmlNode = null; // get/release models should always be in a try/finally block @@ -511,7 +537,8 @@ if (xModel != null) { xmlNode = (IDOMNode) xModel.getIndexedRegion(sdRegion.getStart()); } - } finally { + } + finally { if (xModel != null) { xModel.releaseFromRead(); } @@ -526,8 +553,9 @@ * @param structuredDocumentRegion */ private boolean isEndTag(IStructuredDocumentRegion structuredDocumentRegion) { - if (structuredDocumentRegion == null || structuredDocumentRegion.isDeleted()) + if ((structuredDocumentRegion == null) || structuredDocumentRegion.isDeleted()) { return false; + } return structuredDocumentRegion.getFirstRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN; } @@ -539,8 +567,9 @@ * */ private boolean isPI(IStructuredDocumentRegion structuredDocumentRegion) { - if (structuredDocumentRegion == null || structuredDocumentRegion.isDeleted()) - return false; + if ((structuredDocumentRegion == null) || structuredDocumentRegion.isDeleted()) { + return false; + } return structuredDocumentRegion.getFirstRegion().getType() == DOMRegionContext.XML_PI_OPEN; } @@ -552,8 +581,9 @@ * */ private boolean isStartTag(IStructuredDocumentRegion structuredDocumentRegion) { - if (structuredDocumentRegion == null || structuredDocumentRegion.isDeleted()) + if ((structuredDocumentRegion == null) || structuredDocumentRegion.isDeleted()) { return false; + } return structuredDocumentRegion.getFirstRegion().getType() == DOMRegionContext.XML_TAG_OPEN; } @@ -561,7 +591,7 @@ // sequencing, we need to know what's // an appropriate close. private boolean isTagCloseTextRegion(ITextRegion textRegion) { - return textRegion.getType() == DOMRegionContext.XML_TAG_CLOSE || textRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE; + return (textRegion.getType() == DOMRegionContext.XML_TAG_CLOSE) || (textRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE); } /** @@ -571,18 +601,20 @@ * */ private boolean isXMLContent(IStructuredDocumentRegion structuredDocumentRegion) { - if(structuredDocumentRegion == null || structuredDocumentRegion.isDeleted()) - return false; + if ((structuredDocumentRegion == null) || structuredDocumentRegion.isDeleted()) { + return false; + } return structuredDocumentRegion.getFirstRegion().getType() == DOMRegionContext.XML_CONTENT; } - private void setDocument(IDocument doc){ + private void setDocument(IDocument doc) { fDocument = doc; } + private IDocument getDocument() { return fDocument; } - + public void connect(IDocument document) { setDocument(document); } @@ -592,58 +624,65 @@ } public void validate(IRegion dirtyRegion, IValidationContext helper, IReporter reporter) { - if(getDocument() == null) + if (getDocument() == null) { return; - if(!(reporter instanceof IncrementalReporter)) + } + if (!(reporter instanceof IncrementalReporter)) { return; - if(!(getDocument() instanceof IStructuredDocument)) + } + if (!(getDocument() instanceof IStructuredDocument)) { return; + } // remove old messages reporter.removeAllMessages(this); - - IStructuredDocumentRegion[] regions = ((IStructuredDocument)fDocument).getStructuredDocumentRegions(dirtyRegion.getOffset(), dirtyRegion.getLength()); + + IStructuredDocumentRegion[] regions = ((IStructuredDocument) fDocument).getStructuredDocumentRegions(dirtyRegion.getOffset(), dirtyRegion.getLength()); for (int i = 0; i < regions.length; i++) { validate(regions[i], reporter); } } - + public void validate(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) { - if (structuredDocumentRegion == null) + if (structuredDocumentRegion == null) { return; - + } + if (isStartTag(structuredDocumentRegion)) { // check for attributes without a value checkForAttributeValue(structuredDocumentRegion, reporter); // check if started tag is ended - checkStartEndTagPairs(structuredDocumentRegion, reporter); + checkStartEndTagPairs(structuredDocumentRegion, reporter); // check empty tag <> checkEmptyTag(structuredDocumentRegion, reporter); // check that each attribute has quotes checkQuotesForAttributeValues(structuredDocumentRegion, reporter); // check that the closing '>' is there checkClosingBracket(structuredDocumentRegion, reporter); - } else if (isEndTag(structuredDocumentRegion)) { + } + else if (isEndTag(structuredDocumentRegion)) { checkAttributesInEndTag(structuredDocumentRegion, reporter); // check that the closing '>' is there checkClosingBracket(structuredDocumentRegion, reporter); - } else if (isPI(structuredDocumentRegion)) { + } + else if (isPI(structuredDocumentRegion)) { // check validity of processing instruction checkStartingSpaceForPI(structuredDocumentRegion, reporter); checkNoNamespaceInPI(structuredDocumentRegion, reporter); - } else if (isXMLContent(structuredDocumentRegion)) { + } + else if (isXMLContent(structuredDocumentRegion)) { checkForSpaceBeforeName(structuredDocumentRegion, reporter); } } public void cleanup(IReporter reporter) { // TODO Auto-generated method stub - + } public void validate(IValidationContext helper, IReporter reporter) throws ValidationException { // TODO Auto-generated method stub - + } }
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java index 6c37951..0378e8a 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java
@@ -105,7 +105,7 @@ StringBuffer text = new StringBuffer(super.getText(o)); if (o instanceof Node) { Node node = (Node) o; - if (node.getNodeType() == Node.ELEMENT_NODE && fShowAttributes) { + if ((node.getNodeType() == Node.ELEMENT_NODE) && fShowAttributes) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88444 if (node.hasAttributes()) { Element element = (Element) node; @@ -127,7 +127,7 @@ // ID if (elementDecl != null) { int i = 0; - while (i < attributes.getLength() && idTypedAttribute == null) { + while ((i < attributes.getLength()) && (idTypedAttribute == null)) { Node attr = attributes.item(i); String attrName = attr.getNodeName(); CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) elementDecl.getAttributes().getNamedItem(attrName); @@ -135,7 +135,7 @@ if ((attrDecl.getAttrType() != null) && (CMDataType.ID.equals(attrDecl.getAttrType().getDataTypeName()))) { idTypedAttribute = attr; } - else if (attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED && requiredAttribute == null) { + else if ((attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) && (requiredAttribute == null)) { // as a backup, keep tabs on // any required // attributes @@ -173,10 +173,10 @@ // display the attribute and value (without quotes) String attributeName = shownAttribute.getNodeName(); - if (attributeName != null && attributeName.length() > 0) { + if ((attributeName != null) && (attributeName.length() > 0)) { text.append(" " + attributeName); //$NON-NLS-1$ String attributeValue = shownAttribute.getNodeValue(); - if (attributeValue != null && attributeValue.length() > 0) { + if ((attributeValue != null) && (attributeValue.length() > 0)) { text.append("=" + StringUtils.strip(attributeValue)); //$NON-NLS-1$ } } @@ -316,11 +316,12 @@ Node node = (Node) object; // replace attribute node in selection with its parent - if (node.getNodeType() == Node.ATTRIBUTE_NODE) + if (node.getNodeType() == Node.ATTRIBUTE_NODE) { node = ((Attr) node).getOwnerElement(); - // replace TextNode in selection with its parent - else if (node.getNodeType() == Node.TEXT_NODE) + } + else if (node.getNodeType() == Node.TEXT_NODE) { node = node.getParentNode(); + } return node; } return object;
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/properties/XMLPropertySheetConfiguration.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/properties/XMLPropertySheetConfiguration.java index b578055..f033278 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/properties/XMLPropertySheetConfiguration.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/properties/XMLPropertySheetConfiguration.java
@@ -57,7 +57,7 @@ } public void cacheUpdated(CMDocumentCache cache, final String uri, int oldStatus, int newStatus, CMDocument cmDocument) { - if (newStatus == CMDocumentCache.STATUS_LOADED || newStatus == CMDocumentCache.STATUS_ERROR) { + if ((newStatus == CMDocumentCache.STATUS_LOADED) || (newStatus == CMDocumentCache.STATUS_ERROR)) { refreshPages(); } } @@ -97,7 +97,7 @@ for (int i = 0; i < pages.length; i++) { PropertySheetPage page = (PropertySheetPage) pages[i]; - if (page.getControl() != null && !page.getControl().isDisposed()) { + if ((page.getControl() != null) && !page.getControl().isDisposed()) { page.refresh(); } } @@ -123,7 +123,7 @@ private INodeNotifier fSource = null; public IPropertySource getPropertySource(Object object) { - if (fSource != null && object.equals(fSource)) { + if ((fSource != null) && object.equals(fSource)) { return fPropertySource; } @@ -191,7 +191,7 @@ selectedObjects[i] = ownerElement; } // replace Text Node with its parent - else if ((node.getNodeType() == Node.TEXT_NODE || (node.getNodeType() == Node.CDATA_SECTION_NODE)) && parentNode != null) { + else if (((node.getNodeType() == Node.TEXT_NODE) || (node.getNodeType() == Node.CDATA_SECTION_NODE)) && (parentNode != null)) { selectedObjects[i] = parentNode; } }