Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 150632 Details for
Bug 293447
[Commands] Parameter as a part of command's name in the Quick Access
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed implementation
parameter-in-command-name.patch (text/plain), 3.03 KB, created by
Mykola Nikishov
on 2009-10-27 10:42:01 EDT
(
hide
)
Description:
Proposed implementation
Filename:
MIME Type:
Creator:
Mykola Nikishov
Created:
2009-10-27 10:42:01 EDT
Size:
3.03 KB
patch
obsolete
>diff --git a/src/org/eclipse/core/commands/ParameterizedCommand.java b/src/org/eclipse/core/commands/ParameterizedCommand.java >index fdcc471..4502e40 100644 >--- a/src/org/eclipse/core/commands/ParameterizedCommand.java >+++ b/src/org/eclipse/core/commands/ParameterizedCommand.java >@@ -8,6 +8,7 @@ > * Contributors: > * IBM Corporation - initial API and implementation > * Benjamin Muskalla - bug 222861 [Commands] ParameterizedCommand#equals broken >+ * Mykola Nikishov <mn@mn.com.ua> - bug 293447 Parameter as a part of command's name in the Quick Access > *******************************************************************************/ > > package org.eclipse.core.commands; >@@ -17,8 +18,12 @@ import java.util.Collection; > import java.util.Collections; > import java.util.HashMap; > import java.util.Iterator; >+import java.util.LinkedHashSet; > import java.util.List; > import java.util.Map; >+import java.util.Set; >+import java.util.regex.Matcher; >+import java.util.regex.Pattern; > > import org.eclipse.core.commands.common.NotDefinedException; > import org.eclipse.core.internal.commands.util.Util; >@@ -529,6 +534,8 @@ public final class ParameterizedCommand implements Comparable { > return command.getId(); > } > >+ private static final String PARAM_REGEX = "\\{(\\d+)\\}"; >+ > /** > * Returns a human-readable representation of this command with all of its > * parameterizations. >@@ -540,12 +547,40 @@ public final class ParameterizedCommand implements Comparable { > */ > public final String getName() throws NotDefinedException { > if (name == null) { >- final StringBuffer nameBuffer = new StringBuffer(); >+ StringBuffer nameBuffer = new StringBuffer(); > nameBuffer.append(command.getName()); > if (parameterizations != null) { >+ Set paramsToSkip = new LinkedHashSet(); >+ Pattern pattern = Pattern.compile(PARAM_REGEX); >+ String commandName = command.getName(); >+ Matcher matcher = pattern.matcher(commandName); >+ while (matcher.find()) { >+ matcher.group(); >+ final String paramNumber = commandName.substring(matcher >+ .start() + 1, matcher.end() - 1); >+ final int paramIndex = Integer.parseInt(paramNumber); >+ paramsToSkip.add(new Integer(paramIndex)); >+ String valueInArray; >+ try { >+ valueInArray = parameterizations[paramIndex] >+ .getValueName(); >+ commandName = matcher.replaceFirst(valueInArray); >+ } catch (ParameterValuesException e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ matcher = pattern.matcher(commandName); >+ } >+ nameBuffer = new StringBuffer(); >+ nameBuffer.append(commandName); >+ > nameBuffer.append(" ("); //$NON-NLS-1$ > final int parameterizationCount = parameterizations.length; > for (int i = 0; i < parameterizationCount; i++) { >+ if (paramsToSkip.contains(new Integer(i))) { >+ // this parameter was added to command's name already, skip it >+ continue; >+ } > final Parameterization parameterization = parameterizations[i]; > nameBuffer > .append(parameterization.getParameter().getName());
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 293447
:
150632
|
152320
|
155065