[nobug] Modernize code in a few places
Change-Id: I5eb183e2af3ca74d4fa57582ac92b5a2c3ef42fb
diff --git a/features/org.eclipse.wst.common_sdk.feature/feature.xml b/features/org.eclipse.wst.common_sdk.feature/feature.xml
index ddcf6f9..bae6072 100644
--- a/features/org.eclipse.wst.common_sdk.feature/feature.xml
+++ b/features/org.eclipse.wst.common_sdk.feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.wst.common_sdk.feature"
label="%featureName"
- version="3.23.0.qualifier"
+ version="3.28.0.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
diff --git a/features/org.eclipse.wst.common_sdk.feature/pom.xml b/features/org.eclipse.wst.common_sdk.feature/pom.xml
index 97b99af..f6a49d9 100644
--- a/features/org.eclipse.wst.common_sdk.feature/pom.xml
+++ b/features/org.eclipse.wst.common_sdk.feature/pom.xml
@@ -21,6 +21,6 @@
<groupId>org.eclipse.webtools.common</groupId>
<artifactId>org.eclipse.wst.common_sdk.feature</artifactId>
- <version>3.23.0-SNAPSHOT</version>
+ <version>3.28.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
</project>
diff --git a/features/org.eclipse.wst.common_ui.feature/feature.xml b/features/org.eclipse.wst.common_ui.feature/feature.xml
index 1c5066e..3b9244c 100644
--- a/features/org.eclipse.wst.common_ui.feature/feature.xml
+++ b/features/org.eclipse.wst.common_ui.feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.wst.common_ui.feature"
label="%featureName"
- version="3.23.0.qualifier"
+ version="3.28.0.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
diff --git a/features/org.eclipse.wst.common_ui.feature/pom.xml b/features/org.eclipse.wst.common_ui.feature/pom.xml
index 6534531..72ac5d0 100644
--- a/features/org.eclipse.wst.common_ui.feature/pom.xml
+++ b/features/org.eclipse.wst.common_ui.feature/pom.xml
@@ -21,7 +21,7 @@
<groupId>org.eclipse.webtools.common</groupId>
<artifactId>org.eclipse.wst.common_ui.feature</artifactId>
- <version>3.23.0-SNAPSHOT</version>
+ <version>3.28.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
<build>
diff --git a/plugins/org.eclipse.wst.common.snippets/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.common.snippets/META-INF/MANIFEST.MF
index 2fef667..4d940d9 100644
--- a/plugins/org.eclipse.wst.common.snippets/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.wst.common.snippets/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %Snippets_View.name
Bundle-SymbolicName: org.eclipse.wst.common.snippets; singleton:=true
-Bundle-Version: 1.2.600.qualifier
+Bundle-Version: 1.2.700.qualifier
Bundle-Activator: org.eclipse.wst.common.snippets.internal.SnippetsPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -17,8 +17,6 @@
org.eclipse.wst.common.snippets.internal.ui;x-internal:=true,
org.eclipse.wst.common.snippets.internal.util;x-internal:=true,
org.eclipse.wst.common.snippets.ui
-Import-Package: com.ibm.icu.util,
- com.ibm.icu.text
Require-Bundle: org.eclipse.gef;bundle-version="[3.10.0,6.0.0)",
org.eclipse.ui.ide;bundle-version="[3.12.0,4.0.0)",
org.eclipse.ui.workbench.texteditor;bundle-version="[3.10.0,4.0.0)",
@@ -26,6 +24,7 @@
org.eclipse.jface.text;bundle-version="[3.11.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.11.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)",
- org.eclipse.core.expressions;bundle-version="[3.5.0,4.0.0)"
+ org.eclipse.core.expressions;bundle-version="[3.5.0,4.0.0)",
+ com.ibm.icu;bundle-version="71.1.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/plugins/org.eclipse.wst.common.snippets/pom.xml b/plugins/org.eclipse.wst.common.snippets/pom.xml
index 7d3dedc..514b2c7 100644
--- a/plugins/org.eclipse.wst.common.snippets/pom.xml
+++ b/plugins/org.eclipse.wst.common.snippets/pom.xml
@@ -21,7 +21,7 @@
<groupId>org.eclipse.webtools.common</groupId>
<artifactId>org.eclipse.wst.common.snippets</artifactId>
- <version>1.2.600-SNAPSHOT</version>
+ <version>1.2.700-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<build>
diff --git a/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/SnippetDefinitions.java b/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/SnippetDefinitions.java
index bfc76a7..e70fada 100644
--- a/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/SnippetDefinitions.java
+++ b/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/SnippetDefinitions.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -30,20 +30,20 @@
/**
* The full list of category model objects
*/
- protected List fCategories = null;
+ protected List<ISnippetCategory> fCategories = null;
/**
* The full list of item model objects
*/
- protected List fItems = null;
+ protected List<ISnippetItem> fItems = null;
/**
* Gets the categories.
*
* @return Returns a List
*/
- public List getCategories() {
+ public List<ISnippetCategory> getCategories() {
if (fCategories == null)
- fCategories = new ArrayList();
+ fCategories = new ArrayList<>();
return fCategories;
}
@@ -55,7 +55,7 @@
* @return the ISnippetCategory if found, null if not
*/
public ISnippetCategory getCategory(String id) {
- Iterator iterator = getCategories().iterator();
+ Iterator<ISnippetCategory> iterator = getCategories().iterator();
while (iterator.hasNext()) {
SnippetPaletteDrawer category = (SnippetPaletteDrawer) iterator.next();
if (category.getId().equals(id))
@@ -71,14 +71,14 @@
* @return the ISnippetItem if found, null if not
*/
public ISnippetItem getItem(String id) {
- Iterator iterator = getItems().iterator();
+ Iterator<ISnippetItem> iterator = getItems().iterator();
while (iterator.hasNext()) {
SnippetPaletteItem item = (SnippetPaletteItem) iterator.next();
if (item.getId().equals(id))
return item;
}
for (int i = 0; i < fCategories.size(); i++) {
- ISnippetItem[] items = ((ISnippetCategory) fCategories.get(i)).getItems();
+ ISnippetItem[] items = fCategories.get(i).getItems();
for (int j = 0; j < items.length; j++) {
SnippetPaletteItem item = (SnippetPaletteItem) items[j];
if (item.getId().equals(id)) {
@@ -95,9 +95,9 @@
*
* @return a List of all the ISnippetItems loaded
*/
- public List getItems() {
+ public List<ISnippetItem> getItems() {
if (fItems == null)
- fItems = new ArrayList();
+ fItems = new ArrayList<>();
return fItems;
}
@@ -107,7 +107,7 @@
* @param categories -
* the categories to set
*/
- public void setCategories(List categories) {
+ public void setCategories(List<ISnippetCategory> categories) {
fCategories = categories;
}
@@ -117,7 +117,7 @@
* @param items
* The items to set
*/
- public void setItems(List items) {
+ public void setItems(List<ISnippetItem> items) {
fItems = items;
}
}
diff --git a/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/model/SnippetManager.java b/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/model/SnippetManager.java
index fd44da2..30acf78 100644
--- a/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/model/SnippetManager.java
+++ b/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/model/SnippetManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * Copyright (c) 2004, 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -123,7 +123,7 @@
}
protected ISnippetsEntry findEntry(SnippetDefinitions defs, String id) {
- List categories = defs.getCategories();
+ List<ISnippetCategory> categories = defs.getCategories();
ISnippetsEntry match = null;
for (int i = 0; match == null && i < categories.size(); i++) {
SnippetPaletteDrawer category = (SnippetPaletteDrawer) categories.get(i);
diff --git a/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/AbstractModelFactory.java b/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/AbstractModelFactory.java
index 51cddd6..e6d69c5 100644
--- a/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/AbstractModelFactory.java
+++ b/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/AbstractModelFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -17,6 +17,8 @@
import java.util.List;
import org.eclipse.gef.palette.PaletteDrawer;
+import org.eclipse.wst.common.snippets.core.ISnippetCategory;
+import org.eclipse.wst.common.snippets.core.ISnippetItem;
import org.eclipse.wst.common.snippets.core.ISnippetVariable;
import org.eclipse.wst.common.snippets.core.ISnippetsEntry;
import org.eclipse.wst.common.snippets.internal.Logger;
@@ -31,22 +33,22 @@
}
protected void connectItemsAndCategories(SnippetDefinitions definitions) {
- Iterator iterator = definitions.getCategories().iterator();
- while (iterator.hasNext()) {
- SnippetPaletteDrawer category = (SnippetPaletteDrawer) iterator.next();
+ Iterator<ISnippetCategory> categories = definitions.getCategories().iterator();
+ while (categories.hasNext()) {
+ SnippetPaletteDrawer category = (SnippetPaletteDrawer) categories.next();
category.getChildren().clear();
}
- iterator = definitions.getItems().iterator();
- while (iterator.hasNext()) {
- SnippetPaletteItem item = (SnippetPaletteItem) iterator.next();
+ Iterator<ISnippetItem> items = definitions.getItems().iterator();
+ while (items.hasNext()) {
+ SnippetPaletteItem item = (SnippetPaletteItem) items.next();
SnippetPaletteDrawer parentCategory = (SnippetPaletteDrawer) definitions.getCategory(item.getCategoryName());
if (parentCategory != null) {
parentCategory.add(item);
}
else {
Logger.log(Logger.WARNING, "Rejecting item " + item.getId() + " in missing category " + item.getCategoryName()); //$NON-NLS-1$ //$NON-NLS-2$
- iterator.remove();
+ items.remove();
}
}
@@ -88,10 +90,10 @@
return var;
}
- protected List createVariables(Object[] sources) {
+ protected List<ISnippetVariable> createVariables(Object[] sources) {
if (sources == null || sources.length < 1)
return null;
- List variables = new ArrayList(sources.length);
+ List<ISnippetVariable> variables = new ArrayList<>(sources.length);
for (int i = 0; i < sources.length; i++) {
ISnippetVariable variable = createVariable(sources[i]);
if (variable != null)
diff --git a/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/ModelFactoryForPlugins.java b/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/ModelFactoryForPlugins.java
index e1c202a..39d00fc 100644
--- a/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/ModelFactoryForPlugins.java
+++ b/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/ModelFactoryForPlugins.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2018 IBM Corporation and others.
+ * Copyright (c) 2004, 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -174,18 +174,22 @@
IConfigurationElement[] children = element.getChildren();
for (int i = 0; i < children.length; i++) {
- if (children[i].getName().equals(SnippetsPlugin.NAMES.CONTENT))
- setProperty(item, SnippetsPlugin.NAMES.CONTENT, children[i].getValue());
- else if (children[i].getName().equals(SnippetsPlugin.NAMES.VARIABLES)) {
- Iterator iterator = createVariables(children[i].getChildren()).iterator();
- while (iterator.hasNext()) {
- item.addVariable((ISnippetVariable) iterator.next());
- }
- }
- else if (children[i].getName().equals(SnippetsPlugin.NAMES.VARIABLE)) {
- ISnippetVariable var = createVariable(children[i]);
- if (var != null)
- item.addVariable(var);
+ switch (children[i].getName()) {
+ case SnippetsPlugin.NAMES.CONTENT :
+ setProperty(item, SnippetsPlugin.NAMES.CONTENT, children[i].getValue());
+ break;
+ case SnippetsPlugin.NAMES.VARIABLES :
+ Iterator iterator = createVariables(children[i].getChildren()).iterator();
+ while (iterator.hasNext()) {
+ item.addVariable((ISnippetVariable) iterator.next());
+ }
+ break;
+ case SnippetsPlugin.NAMES.VARIABLE :
+ ISnippetVariable var = createVariable(children[i]);
+ if (var != null)
+ item.addVariable(var);
+ break;
+ default:
}
}
}
diff --git a/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/SnippetCustomizerDialog.java b/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/SnippetCustomizerDialog.java
index 52eff5e..50a1569 100644
--- a/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/SnippetCustomizerDialog.java
+++ b/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/SnippetCustomizerDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2012 IBM Corporation and others.
+ * Copyright (c) 2004, 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -83,7 +83,7 @@
}
protected void handleExport() {
- PaletteDrawer exportCategory = (PaletteDrawer) getSelectedPaletteEntry();
+ SnippetPaletteDrawer exportCategory = (SnippetPaletteDrawer) getSelectedPaletteEntry();
EXPORT_IMPORT_STRATEGY strategy = exportStrategy(exportCategory);
if (EXPORT_IMPORT_STRATEGY.ARCHIVE == strategy) {
@@ -107,7 +107,7 @@
return EXPORT_IMPORT_STRATEGY.XML;
}
- private void exportArchive(PaletteDrawer exportCategory) {
+ private void exportArchive(SnippetPaletteDrawer exportCategory) {
String filename = openFileDialog("*.zip");//$NON-NLS-1$
if (filename != null) {
ZipOutputStream outputStream = null;
@@ -167,7 +167,7 @@
}
}
- private void exportXML(PaletteDrawer exportCategory) {
+ private void exportXML(SnippetPaletteDrawer exportCategory) {
String filename = openFileDialog("*.xml");//$NON-NLS-1$
OutputStream outputStream = null;
@@ -198,7 +198,7 @@
}
- private SnippetDefinitions getCategory(PaletteDrawer exportCategory, String fileName) {
+ private SnippetDefinitions getCategory(SnippetPaletteDrawer exportCategory, String fileName) {
SnippetDefinitions definitions = ModelFactoryForUser.getInstance().load(fileName);
ISnippetCategory existingCategory = definitions.getCategory(exportCategory.getId());
diff --git a/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/UserModelDumper.java b/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/UserModelDumper.java
index f4f4f6d..da29dfc 100644
--- a/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/UserModelDumper.java
+++ b/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/UserModelDumper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -161,7 +161,7 @@
Document document = CommonXML.getDocumentBuilder().getDOMImplementation().createDocument(null, SnippetsPlugin.NAMES.SNIPPETS, null);
Element root = document.getDocumentElement();
for (int i = 0; i < defs.getCategories().size(); i++) {
- ISnippetCategory category = (ISnippetCategory) defs.getCategories().get(i);
+ ISnippetCategory category = defs.getCategories().get(i);
Element categoryElement = createCategory(document, category);
root.appendChild(categoryElement);
}
diff --git a/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/team/SnippetDefinitionResourceChangeListener.java b/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/team/SnippetDefinitionResourceChangeListener.java
index 82de035..abbe4c5 100644
--- a/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/team/SnippetDefinitionResourceChangeListener.java
+++ b/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/team/SnippetDefinitionResourceChangeListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -186,7 +186,7 @@
SnippetDefinitions defs = ModelFactoryForWorkspace.getWorkspaceInstance().loadFrom(file);
ISnippetCategory category = null;
if (defs.getCategories().size() > 0) {
- category = (ISnippetCategory) defs.getCategories().get(0);
+ category = defs.getCategories().get(0);
}
CategoryFileInfo result = new CategoryFileInfo(this, file, category);
if (category != null)