Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbateman2007-09-25 00:36:06 +0000
committercbateman2007-09-25 00:36:06 +0000
commit080d63f2db4c3b2e919220685daf06255987530e (patch)
treec19f9529355a4b66d6b9271c716ad801c1d5500d
parent0cdc1c6c9a9408259d36f612d2dea59d26594900 (diff)
downloadwebtools.jsf-080d63f2db4c3b2e919220685daf06255987530e.tar.gz
webtools.jsf-080d63f2db4c3b2e919220685daf06255987530e.tar.xz
webtools.jsf-080d63f2db4c3b2e919220685daf06255987530e.zip
- switch to generic containers
- add javadocs - reduce visibility of unnecessarily public things.
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/AbstractLinkCreator.java6
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/CreateLinkWizard.java18
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/ExtensionReader.java21
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/ILinkCreator.java19
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/LinkRequest.java14
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/LinkUtil.java10
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/LinkWizardPage.java35
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/MakeLinkAction.java23
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/MakeLinkCommand.java13
9 files changed, 119 insertions, 40 deletions
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/AbstractLinkCreator.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/AbstractLinkCreator.java
index c2f6e25d7..0e7f3718b 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/AbstractLinkCreator.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/AbstractLinkCreator.java
@@ -23,6 +23,10 @@ import org.eclipse.jst.pagedesigner.viewer.DesignRange;
public abstract class AbstractLinkCreator implements ILinkCreator,
IExecutableExtension {
private String _identifier;
+ /**
+ * the link identifier attribute name
+ */
+ private static final String LINK_IDENTIFIER = "linkIdentifier";
/*
* (non-Javadoc)
@@ -50,6 +54,6 @@ public abstract class AbstractLinkCreator implements ILinkCreator,
*/
public void setInitializationData(IConfigurationElement config,
String propertyName, Object data) throws CoreException {
- this._identifier = config.getAttribute(ILinkCreator.LINK_IDENTIFIER);
+ this._identifier = config.getAttribute(LINK_IDENTIFIER);
}
}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/CreateLinkWizard.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/CreateLinkWizard.java
index e36848abe..b38566368 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/CreateLinkWizard.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/CreateLinkWizard.java
@@ -37,11 +37,16 @@ public class CreateLinkWizard extends Wizard {
private DesignRange _range;
- private Map _linkMap;
+ private Map<String, ILinkCreator> _linkMap;
private String _linkType;
- public CreateLinkWizard(EditPart part, DesignRange range, Map linkMap) {
+ /**
+ * @param part
+ * @param range
+ * @param linkMap
+ */
+ public CreateLinkWizard(EditPart part, DesignRange range, Map<String, ILinkCreator> linkMap) {
this._part = part;
this._range = range;
this._linkMap = linkMap;
@@ -77,11 +82,17 @@ public class CreateLinkWizard extends Wizard {
return true;
}
+ /**
+ * @param pageTitle
+ */
public void setPageTitle(String pageTitle) {
_pageTitle = pageTitle;
initializeDefaultPageImageDescriptor();
}
+ /**
+ *
+ */
protected void initializeDefaultPageImageDescriptor() {
ImageDescriptor desc = PDPlugin.getDefault().getImageDescriptor(
INTIAL_DEFAULT_PAGE_IMAGE);
@@ -89,6 +100,9 @@ public class CreateLinkWizard extends Wizard {
setWindowTitle(WIZARD_TITLE);
}
+ /**
+ * @return the link type
+ */
public String getChosenLinkType() {
return this._linkType;
}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/ExtensionReader.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/ExtensionReader.java
index 5ef0c1de9..6cf3d9f9a 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/ExtensionReader.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/ExtensionReader.java
@@ -12,6 +12,7 @@
package org.eclipse.jst.pagedesigner.actions.link;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
@@ -30,20 +31,24 @@ import org.eclipse.jst.pagedesigner.PDPlugin;
public class ExtensionReader {
private static Logger _log = PDPlugin.getLogger(ExtensionReader.class);
- private static ILinkCreator[] _handlers = null;
+ private static List<ILinkCreator> _handlers = null;
private static final String ATTR_CLASS = "class";
- public static synchronized ILinkCreator[] getAllLinkHandlers() {
+ /**
+ * @return the ext-pts for the link handler
+ * List is not modifiable
+ */
+ public static synchronized List<ILinkCreator> getAllLinkHandlers() {
if (_handlers == null) {
_handlers = readAllLinkHandlers();
}
- return _handlers;
+ return Collections.unmodifiableList(_handlers);
}
- private static ILinkCreator[] readAllLinkHandlers() {
- List result = new ArrayList();
+ private static List<ILinkCreator> readAllLinkHandlers() {
+ List<ILinkCreator> result = new ArrayList<ILinkCreator>();
IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
.getExtensionPoint(PDPlugin.getPluginId(),
IJMTConstants.EXTENSION_POINT_PAGEDESIGNER);
@@ -64,7 +69,7 @@ public class ExtensionReader {
.createExecutableExtension(ATTR_CLASS);
if (obj instanceof ILinkCreator) {
- result.add(obj);
+ result.add((ILinkCreator)obj);
}
} catch (CoreException e) {
_log
@@ -73,8 +78,6 @@ public class ExtensionReader {
}
}
}
- ILinkCreator[] ret = new ILinkCreator[result.size()];
- result.toArray(ret);
- return ret;
+ return result;
}
}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/ILinkCreator.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/ILinkCreator.java
index 83b332b72..0652f37e7 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/ILinkCreator.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/ILinkCreator.java
@@ -20,13 +20,30 @@ import org.w3c.dom.Element;
* @version 1.5
*/
public interface ILinkCreator {
- public static final String LINK_IDENTIFIER = "linkIdentifier";
+ /**
+ * @param part
+ * @param range
+ * @return the link element
+ */
public Element makeLinkElement(EditPart part, DesignRange range);
+ /**
+ * @return link identifier
+ */
public String getLinkIdentifier();
+ /**
+ * @param range
+ * @return true if can call makeLinkElement
+ */
public boolean canExecute(DesignRange range);
+ /**
+ * @param part
+ * @param range
+ * @return a preview string that approximates the result
+ * of makeLinkElement
+ */
public String getSourcePreview(EditPart part, DesignRange range);
}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/LinkRequest.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/LinkRequest.java
index 4f1152e98..1caa1f881 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/LinkRequest.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/LinkRequest.java
@@ -19,19 +19,29 @@ import org.eclipse.jst.pagedesigner.viewer.DesignRange;
* @version 1.5
*/
public class LinkRequest extends Request {
- private String _identifier = "";
+ private final String _identifier;
- private DesignRange _range = null;
+ private final DesignRange _range;
+ /**
+ * @param identifier
+ * @param range
+ */
public LinkRequest(String identifier, DesignRange range) {
this._identifier = identifier;
this._range = range;
}
+ /**
+ * @return the identifier
+ */
public String getIdentifier() {
return this._identifier;
}
+ /**
+ * @return the design range
+ */
public DesignRange getDesignRange() {
return this._range;
}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/LinkUtil.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/LinkUtil.java
index 271b8c108..aeeaf41a4 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/LinkUtil.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/LinkUtil.java
@@ -26,6 +26,11 @@ import org.w3c.dom.Text;
* @version 1.5
*/
public class LinkUtil {
+ /**
+ * @param part
+ * @param range
+ * @return the select text if part is a text node or null.
+ */
public static String getSelectedText(EditPart part, DesignRange range) {
if (part instanceof TextEditPart) {
TextEditPart textPart = (TextEditPart) part;
@@ -38,6 +43,11 @@ public class LinkUtil {
return null;
}
+ /**
+ * @param part
+ * @param range
+ * @return the text from part split if it is a text node or null
+ */
public static Text splitDomText(EditPart part, DesignRange range) {
if (part instanceof TextEditPart) {
Text textNode = (Text) part.getModel();
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/LinkWizardPage.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/LinkWizardPage.java
index f64d5e48f..25e120c12 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/LinkWizardPage.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/LinkWizardPage.java
@@ -35,7 +35,7 @@ import org.eclipse.swt.widgets.Label;
* @author mengbo
* @version 1.5
*/
-public class LinkWizardPage extends WizardPage {
+/*package*/ class LinkWizardPage extends WizardPage {
private static final String GROUP_TITLE = PDPlugin
.getResourceString("LinkWizardPage.GroupTitle");
@@ -44,16 +44,23 @@ public class LinkWizardPage extends WizardPage {
private StyledText _text = null;
- private Map _linkMap = null;
+ private final Map<String, ILinkCreator> _linkMap;
private String _linkType = null;
- private EditPart _part = null;
+ private final EditPart _part;
- private DesignRange _range = null;
+ private final DesignRange _range;
+ /**
+ * @param pageName
+ * @param title
+ * @param editPart
+ * @param range
+ * @param linkMap
+ */
public LinkWizardPage(String pageName, String title, EditPart editPart,
- DesignRange range, Map linkMap) {
+ DesignRange range, Map<String, ILinkCreator> linkMap) {
super(pageName, title, null);
this._part = editPart;
this._range = range;
@@ -83,13 +90,13 @@ public class LinkWizardPage extends WizardPage {
group.setLayoutData(data);
String defaultLink = "";
- Set set = this._linkMap.keySet();
+ Set<String> set = this._linkMap.keySet();
int size = set.size();
String[] keys = new String[size];
- Iterator itr = set.iterator();
+ Iterator<String> itr = set.iterator();
int i = 0;
while (itr.hasNext()) {
- String key = (String) itr.next();
+ String key = itr.next();
keys[i++] = key;
}
Arrays.sort(keys);
@@ -113,7 +120,7 @@ public class LinkWizardPage extends WizardPage {
data.heightHint = 50;
_text.setLayoutData(data);
- ILinkCreator creator = (ILinkCreator) _linkMap.get(defaultLink);
+ ILinkCreator creator = _linkMap.get(defaultLink);
_linkType = creator.getLinkIdentifier();
String previewText = creator.getSourcePreview(_part, _range);
previewText = previewText == null ? "" : previewText;
@@ -132,19 +139,25 @@ public class LinkWizardPage extends WizardPage {
return true;
}
+ /**
+ * @return the link type
+ */
public String getChosenLinkType() {
return this._linkType;
}
- class SelectLinkListener extends SelectionAdapter {
+ class SelectLinkListener extends SelectionAdapter {
private String _key;
+ /**
+ * @param key
+ */
public SelectLinkListener(String key) {
this._key = key;
}
public void widgetSelected(SelectionEvent e) {
- ILinkCreator creator = (ILinkCreator) _linkMap.get(this._key);
+ ILinkCreator creator = _linkMap.get(this._key);
_linkType = creator.getLinkIdentifier();
String previewText = creator.getSourcePreview(_part, _range);
previewText = previewText == null ? "" : previewText;
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/MakeLinkAction.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/MakeLinkAction.java
index ea6c413a5..ee8df1621 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/MakeLinkAction.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/MakeLinkAction.java
@@ -13,6 +13,7 @@ package org.eclipse.jst.pagedesigner.actions.link;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -64,7 +65,7 @@ public class MakeLinkAction extends Action {
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
- Map map = calAvailableLinkCreator();
+ Map<String, ILinkCreator> map = calAvailableLinkCreator();
if (map.size() > 1) {
CreateLinkWizard wizard = new CreateLinkWizard(_editPart, _range,
map);
@@ -78,10 +79,10 @@ public class MakeLinkAction extends Action {
}
// else must be html link
else if (map.size() == 1) {
- Set set = map.entrySet();
- Iterator itr = set.iterator();
+ Set<Map.Entry<String, ILinkCreator>> set = map.entrySet();
+ Iterator<Map.Entry<String,ILinkCreator>> itr = set.iterator();
while (itr.hasNext()) {
- ILinkCreator creator = (ILinkCreator) itr.next();
+ ILinkCreator creator = itr.next().getValue();
_linkType = creator.getLinkIdentifier();
}
}
@@ -199,14 +200,14 @@ public class MakeLinkAction extends Action {
return null;
}
- private Map calAvailableLinkCreator() {
- Map map = new HashMap();
- ILinkCreator[] linkCreators = ExtensionReader.getAllLinkHandlers();
- for (int i = 0, size = linkCreators.length; i < size; i++) {
- String identifier = linkCreators[i].getLinkIdentifier();
- boolean canExecute = linkCreators[i].canExecute(_range);
+ private Map<String, ILinkCreator> calAvailableLinkCreator() {
+ Map<String, ILinkCreator> map = new HashMap<String, ILinkCreator>();
+ List<ILinkCreator> linkCreators = ExtensionReader.getAllLinkHandlers();
+ for (ILinkCreator linkCreator : linkCreators) {
+ String identifier = linkCreator.getLinkIdentifier();
+ boolean canExecute = linkCreator.canExecute(_range);
if (canExecute) {
- map.put(identifier, linkCreators[i]);
+ map.put(identifier, linkCreator);
}
}
return map;
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/MakeLinkCommand.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/MakeLinkCommand.java
index 9ccd1d17b..7c4835f4e 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/MakeLinkCommand.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/actions/link/MakeLinkCommand.java
@@ -11,6 +11,8 @@
*******************************************************************************/
package org.eclipse.jst.pagedesigner.actions.link;
+import java.util.List;
+
import org.eclipse.gef.EditPart;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jst.pagedesigner.PDPlugin;
@@ -35,6 +37,12 @@ public class MakeLinkCommand extends DesignerCommand {
private Element _ele = null;
+ /**
+ * @param identifier
+ * @param viewer
+ * @param part
+ * @param range
+ */
public MakeLinkCommand(String identifier, IHTMLGraphicalViewer viewer,
EditPart part, DesignRange range) {
super(identifier, viewer);
@@ -50,10 +58,9 @@ public class MakeLinkCommand extends DesignerCommand {
* @see org.eclipse.gef.commands.Command#canExecute()
*/
public boolean canExecute() {
- ILinkCreator[] creators = ExtensionReader.getAllLinkHandlers();
+ List<ILinkCreator> creators = ExtensionReader.getAllLinkHandlers();
if (creators != null) {
- for (int i = 0, size = creators.length; i < size; i++) {
- ILinkCreator linkCreator = creators[i];
+ for (ILinkCreator linkCreator : creators) {
String identifier = linkCreator.getLinkIdentifier();
if (this._identifier.equalsIgnoreCase(identifier)) {
this._linkcreator = linkCreator;

Back to the top