use of java.util.LinkedHashSet in project webmagic by code4craft.
the class ClassUtils method getFieldsIncludeSuperClass.
public static Set<Field> getFieldsIncludeSuperClass(Class clazz) {
Set<Field> fields = new LinkedHashSet<Field>();
Class current = clazz;
while (current != null) {
Field[] currentFields = current.getDeclaredFields();
for (Field currentField : currentFields) {
fields.add(currentField);
}
current = current.getSuperclass();
}
return fields;
}
use of java.util.LinkedHashSet in project cogtool by cogtool.
the class FramePropertiesPane method update.
public void update(Frame frame) {
Object pathObj = frame.getAttribute(WidgetAttributes.IMAGE_PATH_ATTR);
if (NullSafe.equals(WidgetAttributes.NO_IMAGE, pathObj)) {
imagePath.setVisible(false);
imagePathText.setVisible(false);
} else {
String imgPath = (String) pathObj;
imagePath.setVisible(true);
imagePathText.setVisible(true);
imagePathText.setText(imgPath);
imagePathText.setSelection(imgPath.length());
}
Set<TransitionSource> children = new LinkedHashSet<TransitionSource>();
children.addAll(frame.getWidgets());
children.addAll(frame.getInputDevices());
widgetUpdater.updateTree(children.iterator());
if (eltGroupTreeLabel != null) {
Set<FrameElementGroup> grps = frame.getEltGroups();
if (!CogToolPref.NESTED_GROUPS_SHOWN_AT_TOP_LEVEL.getBoolean()) {
grps = filterNestedGroups(grps);
}
eltGroupUpdater.updateTree(grps.iterator());
Set<SimpleWidgetGroup> implicitGroups = new HashSet<SimpleWidgetGroup>();
for (IWidget w : frame.getWidgets()) {
SimpleWidgetGroup g = w.getParentGroup();
if (g != null) {
implicitGroups.add(g);
}
}
implicitGroupUpdater.updateTree(implicitGroups.iterator());
}
setFrameName(frame);
}
use of java.util.LinkedHashSet in project jetty.project by eclipse.
the class OSGiWebInfConfiguration method configure.
/* ------------------------------------------------------------ */
/**
* Allow fragments to supply some resources that are added to the baseResource of the webapp.
*
* The resources can be either prepended or appended to the baseResource.
*
* @see org.eclipse.jetty.webapp.WebInfConfiguration#configure(org.eclipse.jetty.webapp.WebAppContext)
*/
@Override
public void configure(WebAppContext context) throws Exception {
TreeMap<String, Resource> prependedResourcesPath = new TreeMap<String, Resource>();
TreeMap<String, Resource> appendedResourcesPath = new TreeMap<String, Resource>();
Bundle bundle = (Bundle) context.getAttribute(OSGiWebappConstants.JETTY_OSGI_BUNDLE);
if (bundle != null) {
Set<Bundle> fragments = (Set<Bundle>) context.getAttribute(FRAGMENT_AND_REQUIRED_BUNDLES);
if (fragments != null && !fragments.isEmpty()) {
// looked up.
for (Bundle frag : fragments) {
String path = Util.getManifestHeaderValue(OSGiWebappConstants.JETTY_WAR_FRAGMENT_FOLDER_PATH, OSGiWebappConstants.JETTY_WAR_FRAGMENT_RESOURCE_PATH, frag.getHeaders());
convertFragmentPathToResource(path, frag, appendedResourcesPath);
path = Util.getManifestHeaderValue(OSGiWebappConstants.JETTY_WAR_PATCH_FRAGMENT_FOLDER_PATH, OSGiWebappConstants.JETTY_WAR_PREPEND_FRAGMENT_RESOURCE_PATH, frag.getHeaders());
convertFragmentPathToResource(path, frag, prependedResourcesPath);
}
if (!appendedResourcesPath.isEmpty()) {
LinkedHashSet<Resource> resources = new LinkedHashSet<Resource>();
//Add in any existing setting of extra resource dirs
Set<Resource> resourceDirs = (Set<Resource>) context.getAttribute(WebInfConfiguration.RESOURCE_DIRS);
if (resourceDirs != null && !resourceDirs.isEmpty())
resources.addAll(resourceDirs);
//Then append the values from JETTY_WAR_FRAGMENT_FOLDER_PATH
resources.addAll(appendedResourcesPath.values());
context.setAttribute(WebInfConfiguration.RESOURCE_DIRS, resources);
}
}
}
super.configure(context);
// place the prepended resources at the beginning of the contexts's resource base
if (!prependedResourcesPath.isEmpty()) {
Resource[] resources = new Resource[1 + prependedResourcesPath.size()];
System.arraycopy(prependedResourcesPath.values().toArray(new Resource[prependedResourcesPath.size()]), 0, resources, 0, prependedResourcesPath.size());
resources[resources.length - 1] = context.getBaseResource();
context.setBaseResource(new ResourceCollection(resources));
}
}
use of java.util.LinkedHashSet in project che by eclipse.
the class CheArtifactResolver method resolve.
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
public ArtifactResolutionResult resolve(ArtifactResolutionRequest request) {
Artifact rootArtifact = request.getArtifact();
Set<Artifact> artifacts = request.getArtifactDependencies();
Map<String, Artifact> managedVersions = request.getManagedVersionMap();
List<ResolutionListener> listeners = request.getListeners();
ArtifactFilter collectionFilter = request.getCollectionFilter();
ArtifactFilter resolutionFilter = request.getResolutionFilter();
RepositorySystemSession session = getSession(request.getLocalRepository());
//TODO: hack because metadata isn't generated in m2e correctly and i want to run the maven i have in the workspace
if (source == null) {
try {
source = container.lookup(ArtifactMetadataSource.class);
} catch (ComponentLookupException e) {
// won't happen
}
}
if (listeners == null) {
listeners = new ArrayList<ResolutionListener>();
if (logger.isDebugEnabled()) {
listeners.add(new DebugResolutionListener(logger));
}
listeners.add(new WarningResolutionListener(logger));
}
ArtifactResolutionResult result = new ArtifactResolutionResult();
if (request.isResolveRoot()) /* && rootArtifact.getFile() == null */
{
try {
resolve(rootArtifact, request.getRemoteRepositories(), session);
} catch (ArtifactResolutionException e) {
result.addErrorArtifactException(e);
return result;
} catch (ArtifactNotFoundException e) {
result.addMissingArtifact(request.getArtifact());
return result;
}
}
ArtifactResolutionRequest collectionRequest = request;
if (request.isResolveTransitively()) {
MetadataResolutionRequest metadataRequest = new DefaultMetadataResolutionRequest(request);
metadataRequest.setArtifact(rootArtifact);
metadataRequest.setResolveManagedVersions(managedVersions == null);
try {
ResolutionGroup resolutionGroup = source.retrieve(metadataRequest);
if (managedVersions == null) {
managedVersions = resolutionGroup.getManagedVersions();
}
Set<Artifact> directArtifacts = resolutionGroup.getArtifacts();
if (artifacts == null || artifacts.isEmpty()) {
artifacts = directArtifacts;
} else {
List<Artifact> allArtifacts = new ArrayList<Artifact>();
allArtifacts.addAll(artifacts);
allArtifacts.addAll(directArtifacts);
Map<String, Artifact> mergedArtifacts = new LinkedHashMap<String, Artifact>();
for (Artifact artifact : allArtifacts) {
String conflictId = artifact.getDependencyConflictId();
if (!mergedArtifacts.containsKey(conflictId)) {
mergedArtifacts.put(conflictId, artifact);
}
}
artifacts = new LinkedHashSet<Artifact>(mergedArtifacts.values());
}
collectionRequest = new ArtifactResolutionRequest(request);
collectionRequest.setServers(request.getServers());
collectionRequest.setMirrors(request.getMirrors());
collectionRequest.setProxies(request.getProxies());
collectionRequest.setRemoteRepositories(resolutionGroup.getResolutionRepositories());
} catch (ArtifactMetadataRetrievalException e) {
ArtifactResolutionException are = new ArtifactResolutionException("Unable to get dependency information for " + rootArtifact.getId() + ": " + e.getMessage(), rootArtifact, metadataRequest.getRemoteRepositories(), e);
result.addMetadataResolutionException(are);
return result;
}
}
if (artifacts == null || artifacts.isEmpty()) {
if (request.isResolveRoot()) {
result.addArtifact(rootArtifact);
}
return result;
}
// After the collection we will have the artifact object in the result but they will not be resolved yet.
result = artifactCollector.collect(artifacts, rootArtifact, managedVersions, collectionRequest, source, collectionFilter, listeners, null);
if (result.hasMetadataResolutionExceptions() || result.hasVersionRangeViolations() || result.hasCircularDependencyExceptions()) {
return result;
}
if (result.getArtifactResolutionNodes() != null) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
CountDownLatch latch = new CountDownLatch(result.getArtifactResolutionNodes().size());
for (ResolutionNode node : result.getArtifactResolutionNodes()) {
Artifact artifact = node.getArtifact();
if (resolutionFilter == null || resolutionFilter.include(artifact)) {
executor.execute(new ResolveTask(classLoader, latch, artifact, session, node.getRemoteRepositories(), result));
} else {
latch.countDown();
}
}
try {
latch.await();
} catch (InterruptedException e) {
result.addErrorArtifactException(new ArtifactResolutionException("Resolution interrupted", rootArtifact, e));
}
}
// have been resolved.
if (request.isResolveRoot()) {
// Add the root artifact (as the first artifact to retain logical order of class path!)
Set<Artifact> allArtifacts = new LinkedHashSet<Artifact>();
allArtifacts.add(rootArtifact);
allArtifacts.addAll(result.getArtifacts());
result.setArtifacts(allArtifacts);
}
return result;
}
use of java.util.LinkedHashSet in project che by eclipse.
the class UnusedCodeFix method createCleanUp.
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, IProblemLocation[] problems, boolean removeUnusedPrivateMethods, boolean removeUnusedPrivateConstructors, boolean removeUnusedPrivateFields, boolean removeUnusedPrivateTypes, boolean removeUnusedLocalVariables, boolean removeUnusedImports, boolean removeUnusedCast) {
List<CompilationUnitRewriteOperation> result = new ArrayList<CompilationUnitRewriteOperation>();
Hashtable<ASTNode, List<SimpleName>> variableDeclarations = new Hashtable<ASTNode, List<SimpleName>>();
LinkedHashSet<CastExpression> unnecessaryCasts = new LinkedHashSet<CastExpression>();
for (int i = 0; i < problems.length; i++) {
IProblemLocation problem = problems[i];
int id = problem.getProblemId();
if (removeUnusedImports && (id == IProblem.UnusedImport || id == IProblem.DuplicateImport || id == IProblem.ConflictingImport || id == IProblem.CannotImportPackage || id == IProblem.ImportNotFound)) {
ImportDeclaration node = UnusedCodeFix.getImportDeclaration(problem, compilationUnit);
if (node != null) {
result.add(new RemoveImportOperation(node));
}
}
if ((removeUnusedPrivateMethods && id == IProblem.UnusedPrivateMethod) || (removeUnusedPrivateConstructors && id == IProblem.UnusedPrivateConstructor) || (removeUnusedPrivateTypes && id == IProblem.UnusedPrivateType)) {
SimpleName name = getUnusedName(compilationUnit, problem);
if (name != null) {
IBinding binding = name.resolveBinding();
if (binding != null) {
result.add(new RemoveUnusedMemberOperation(new SimpleName[] { name }, false));
}
}
}
if ((removeUnusedLocalVariables && id == IProblem.LocalVariableIsNeverUsed) || (removeUnusedPrivateFields && id == IProblem.UnusedPrivateField)) {
SimpleName name = getUnusedName(compilationUnit, problem);
if (name != null) {
IBinding binding = name.resolveBinding();
if (binding instanceof IVariableBinding && !isFormalParameterInEnhancedForStatement(name) && (!((IVariableBinding) binding).isField() || isSideEffectFree(name, compilationUnit))) {
VariableDeclarationFragment parent = (VariableDeclarationFragment) ASTNodes.getParent(name, VariableDeclarationFragment.class);
if (parent != null) {
ASTNode varDecl = parent.getParent();
if (!variableDeclarations.containsKey(varDecl)) {
variableDeclarations.put(varDecl, new ArrayList<SimpleName>());
}
variableDeclarations.get(varDecl).add(name);
} else {
result.add(new RemoveUnusedMemberOperation(new SimpleName[] { name }, false));
}
}
}
}
if (removeUnusedCast && id == IProblem.UnnecessaryCast) {
ASTNode selectedNode = problem.getCoveringNode(compilationUnit);
ASTNode curr = selectedNode;
while (curr instanceof ParenthesizedExpression) {
curr = ((ParenthesizedExpression) curr).getExpression();
}
if (curr instanceof CastExpression) {
unnecessaryCasts.add((CastExpression) curr);
}
}
}
for (Iterator<ASTNode> iter = variableDeclarations.keySet().iterator(); iter.hasNext(); ) {
ASTNode node = iter.next();
List<SimpleName> names = variableDeclarations.get(node);
result.add(new RemoveUnusedMemberOperation(names.toArray(new SimpleName[names.size()]), false));
}
if (unnecessaryCasts.size() > 0)
result.add(new RemoveAllCastOperation(unnecessaryCasts));
if (result.size() == 0)
return null;
return new UnusedCodeFix(FixMessages.UnusedCodeFix_change_name, compilationUnit, result.toArray(new CompilationUnitRewriteOperation[result.size()]));
}
Aggregations