On Eclipse Luna, I need to programmatically build java projects and then retrieve the Problems View's records. I use the following code
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IResource resource = workspace.getRoot();
IMarker[] markers = resource.findMarkers(IMarker.MARKER, true, IResource.DEPTH_INFINITE);
for (IMarker m : markers) {
System.out.println("Id: " + m.getId());
System.out.println("Message: " + m.getAttribute(IMarker.MESSAGE));
System.out.println("Source ID: " + m.getAttribute(IMarker.SOURCE_ID));
System.out.println("Location: " + m.getAttribute(IMarker.LOCATION));
System.out.println("Line Number: " + m.getAttribute(IMarker.LINE_NUMBER));
System.out.println("Marker: " + m.getAttribute(IMarker.MARKER));
}
The message and line number are printed correctly. But IMarker.SOURCE_ID returns "JDT" and IMarker.LOCATION is always null.
Anybody knows how can I get the data shown as "Resource" and "Path" on the Problems View? I cannot create any custom Marker view using MarkerSupportView. I need to access the existing Problems View in a programmatic way. Thank you for any suggestion.
Got it. Use getResource() instead of getAttribute().
The markers API is pretty flexible, you should read the documentation.
Long story short, there will be other attributes that you're not looking at. Try calling getAttributes and dumping them out.
Related
So I'm having trouble formulating the correct syntax for selecting this element from a webpage. Here is what the path looks like on the Inspect Element Interface on Firefox
And here's what my current code looks like:
Element prices = doc.select("body[class =en page-type-search page-type-group-shelf og ress] " +
"div#wrap " +
"div#main-wrap " +
"div#jalapeno-template " +
"div[class=zone zone3 wgrid-10of12 wgrid-6of8 wgrid-4of4] " +
"section#shelf-page " +
"div#shelf-thumbs " +
"div.shelf-thumbs " +
"div.price-current " +
"span.product-price-analytics").first();
String priceOne = prices.attr("data-analytics-value");
And just to be incredibly clear, the attribute that I'm wanting is the 'data-analytics-value' because it gives an exact price.
I think that I have all the correct syntax so what am I doing wrong? When I run the program it gives me a nullPointerException. Any help is appreciated!
[Update] I changed princeOne to doc.toString() and its saying the the web browser is not running javascript and that JavaScript is required to view the walmart website, any work arounds?
After trying with no luck using Android's WebView, I accidentally found a solution in setting my userAgent, all I did was change the
Jsoup.connect(url).get();
line to
Jsoup.connect(url).userAgent("YOUR_USER_AGENT_HERE").get();
and it worked like a charm. Thanks for the reply anyway Fred!
I am trying to write an application from extracting entities from a text and want to use GATE jar files. For which I have installed the GATE tool and have imported jar files, but it is giving errors. I can't understand from where to download more jar files and how to run the first simple program with this.
Please make sure that you added gate.jar from YOUR_GATE_HOME/bin folder.
From your screenshot I can assume that you used an example provided by GitHub. This example looks good, except one part (from my point of view of course). I would suggest to replace output piece with the next more readable code:
String text = "Steve works for Apple Inc in California.";
Document gateDocument = Factory.newDocument(text);
corpus.add(gateDocument);
// tell the ANNIE application about the corpus and run it
annie.setCorpus(corpus);
annie.execute();
List<Annotation> personAnnotations = gateDocument.getAnnotations().get(ANNIEConstants.PERSON_ANNOTATION_TYPE).inDocumentOrder();
for (Annotation personAnnotation : personAnnotations) {
System.out.println("Entity Text: " + gate.Utils.stringFor(gateDocument, personAnnotation) + " Features: " + personAnnotation.getFeatures());
}
Similar things could be done for Location, Organisation and other Entity types defined in GATE. Also do not forget to release resources with Factory.deleteResource().
I need to create deployment with role that contains Chef extension via Java Azure SDK. I have next code for setting extension parameters, but it doesn't work.
As an example I use next material in Python http://blogs.msdn.com/b/shwetasblogs/archive/2015/02/19/creating-deployment-amp-customizing-linux-vms-with-python-amp-chef-part-2.aspx
private void withExtension(Role role) {
ArrayList<ResourceExtensionReference> references = new ArrayList<ResourceExtensionReference>();
ResourceExtensionReference reference = new ResourceExtensionReference();
reference.setReferenceName("LinuxChefClient");
reference.setVersion("11.*");
reference.setPublisher("Chef.Bootstrap.WindowsAzure");
reference.setName("LinuxChefClient");
ResourceExtensionParameterValue publicConfig = new ResourceExtensionParameterValue();
publicConfig.setType("Public");
publicConfig.setKey("PublicParams");
String value = "{\n" +
" \"client_rb\": \"chef_server_url \\\"https://<chefServerUri>\\\"\\nnode_name \\\"<vmName>\\\"\\nvalidation_key \\\"/etc/chef/validation.pem\\\"\\nlog_location \\\"/etc/chef/client.log\\\"\\nlog_level :info\\njson_attribs \\\"/etc/chef/role.json\\\"\",\n" +
" \"run_list\": [\"role[base]\"]\n" +
"}";
publicConfig.setValue(value);
ResourceExtensionParameterValue privateConfig = new ResourceExtensionParameterValue();
privateConfig.setType("Private");
privateConfig.setKey("PrivateParams");
privateConfig.setValue("{ \"validation_key\": \"" + VALIDATION_PEM + "\" }");
ArrayList<ResourceExtensionParameterValue> parameterValues = new ArrayList<ResourceExtensionParameterValue>();
parameterValues.add(publicConfig);
parameterValues.add(privateConfig);
reference.setResourceExtensionParameterValues(parameterValues);
references.add(reference);
role.setResourceExtensionReferences(references);
}
It seems that you do not encrypt the value of privateConfig and publicConfig. As this official document description(Request body part), before setting value, we need encrypt those values:
<PublicConfiguration>
base-64-encoded-xsd-for-extension-public-configuration
</PublicConfiguration>
<PrivateConfiguration>
base-64-encoded-xsd-for-extension-private-configuration
</PrivateConfiguration>
Please try to add this code into your project:
value=Base64.encode(value.getBytes(Charset.forName("UTF-8")));
By the way, please share more error information if the above code don't work.
I am not able to add the comment, so asking my questions in Reply -
What is the error that you see?
Is your VM getting created successfully?
George, please answer these questions so that I can help you better. By the way, you can check the blog - http://blogs.msdn.com/b/azureossds/archive/2015/09/08/accessing-vm-extensions-like-chef-using-azure-sdk-for-java-programmatically.aspx
for using Azure sdk for Java to access the extensions. You will have to modify the code to set the extension reference in order to create a new one.
Hope this helps !!
I've just moved one of my Android projects over to Gradle, and as per recommendations inside the IDE and online I've moved all the configurations (min/max sdk, version name/code etc) into the build.gradle file.
Now a bug has been reported from a customer that where he could usually see the version name and code inside the product there is nothing.
After checking it out I've found out that the usual way of extracting those values has stopped working after I removed the android:versionCode="" and android:versionName="" tags from AndroidManifest.xml. I have verified that it works when these values are there.
Now I've been trying to search for a way of extracting these same values to use in code, but I have not found any reference to this behaviour else where (this not working like this).
The code I used to use to get the values was to simply extract them from the PackageManager as so
try {
PackageInfo pInfo = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0);
return pInfo.versionName + " Build " + pInfo.versionCode;
} catch(PackageManager.NameNotFoundException e){
e.printStackTrace();
}
All hints, tips or solutions appreciated.
Use the BuildConfig class to fetch your version code which are defined in build.gradle file:
Log.e(TAG, BuildConfig.VERSION_NAME + " Build " + BuildConfig.VERSION_CODE);
I want to develop a content assist for my own IDE like the one that Eclipse offers for java.
My problem is:
How to display the information of a completion proposal has an HTML text(javadoc in the case of eclipse)?
I know only how to use a string to show the information of a method in content assist:
new CompletionProposal("catch(a)", index + 1, offset - (index + 1), "catch(a)", img, keyword + " ", null, "Catches an exception a");
Tks for the time, regards Ramos