Override eclipse Plugin in Project explorer - java

In my project the user sees the red cross icon on the file containing an error and the folders above. When the (modelling nature of the sirius) plugin is added to the project the red cross dissapears on the file (not on the folders).
How can i keep the error icon on the file?
I can get information about the content extension which probably causes the problem
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); ProjectExplorer expl = (ProjectExplorer) page.findView(IPageLayout.ID_PROJECT_EXPLORER);
INavigatorContentService content = expl.getNavigatorContentService();
INavigatorContentExtension siriusext = content.getContentExtensionById("org.eclipse.sirius.ui.resource.content.session");
siriusext.getDescriptor().getAppearsBeforeId();
The problem is probably the sirius INavigatorContentService because it is set to appear before id "org.eclipse.jdt.java.ui.javaContent"
(siriusext.getDescriptor().getAppearsBeforeId())
How can i (have the modelling nature and) keep the error icon on the file?
Any help is appreciated!

I answered your question on the Sirius forum [1].
The problem seems to come from the getImage() implementation in the label provider used by the INavigatorExtension provided by Sirius.
A workaround could be to try to provide your own navigator content with an Override element targeting the Sirius Content Management (org.eclipse.sirius.ui.resource.content.session) as suppressed extension and provide your own label provider (which could extend the Sirius one and specifically handle the file case in getImage, but you might loose the M decorator on files handled by Sirius).
Could you open a bugzilla [2] to track the issue ? Then the team will have the possibility to analyze the issue and try to find a proper solution.
Regards,
Maxime
[1] https://www.eclipse.org/forums/index.php?t=msg&th=877968&goto=1498330&#msg_1498330
[2] https://bugs.eclipse.org/bugs/enter_bug.cgi?product=sirius

Related

How to add Cards to microsoft teams bot using Bot Framework SDK for Java?

I'm using the Java botbuilder to build a microsoft teams bot. I want to add Cards to my bot (e.g. to embed links, quick replies, and images).
In the above link it says: suggested actions are not supported in Microsoft Teams: if you want buttons to appear on a Teams bot message, use a card.
However, I can find no documentation on how to add a 'card' to the Activity schema.
I tried:
1. Using suggested actions
I tried adding my List<CardAction> to the SuggestedActions
field in Activity but they were not rendered by microsoft teams
(as expected, the documentation says this is not supported).
2. Using Attachments
I suspect it could be done using attachments, but can only find
documentation for the C#/JS versions (e.g.
https://learn.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-send-rich-cards?view=azure-bot-service-3.0).
So I want to know how to add 'a card' to Activity schema so it can be rendered by my bot.
The BotFramework Java SDK is still in preview, so there isn't a lot of documentation I can point you towards. However, here is an example of adding a HeroCard to a reply.
Activity reply = new Activity()
.withType(ActivityTypes.MESSAGE)
.withRecipient(activity.from())
.withFrom(activity.recipient())
.withAttachments(Arrays.asList(
new Attachment()
.withContentType("application/vnd.microsoft.card.hero")
.withContent(new HeroCard()
.withTitle("Hero Card")
.withSubtitle("BotFramework")
.withButtons(Arrays.asList(new CardAction()
.withValue("https://learn.microsoft.com/en-us/azure/bot-service/")
.withTitle("Get started")
.withType(ActionTypes.OPEN_URL)
))
.withImages(Collections.singletonList(new CardImage()
.withUrl("https://sec.ch9.ms/ch9/7ff5/e07cfef0-aa3b-40bb-9baa-7c9ef8ff7ff5/buildreactionbotframework_960.jpg"))))
));
You can also take a look at the SDK Attachment Tests for more examples.
Hope this helps!

How to remove unwanted menu contributions in eclipse rcp application?

I have made a eclipse RCP application, everything is working fine but i recently noticed the Refractor option in menu. I would like to get rid of it. I have the following in ActionBarAdvisor.java:
#Override
protected void fillMenuBar(IMenuManager menu) {
menu.add(createFile());
menu.add(createEdit());
menu.add(createNavigate());
menu.add(createProject());
menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(createWindow());
menu.add(createHelp());
}
The above functions add actions to menu as:
edit.add(undoAct);
and also undoAct is defined as:
private IWorkbenchAction undoAction
makeActions function has contents as:
#Override
protected void makeActions(IWorkbenchWindow window) {
undoAction = ActionFactory.UNDO.create(window);
undoAction.setText("Undo Menu");
register(undoAction);
}
I found a suggestion which said to use hideActionSets to hide the menu. But I could not hide the entire menu but just its actions!
Remove "File, edit,...etc" menus from Eclipse RCP application
How to remove Refractor option now?
Thank you.
You can use activities, as described here.
First, you will need to find the ID of the menu:
Use the Plug-In Spy
The first way is to use the Plug-In Spy. Press alt-shift-F2 and click on a
menu item or toolbar button that you want to be hidden. If there is an ID
string under the heading "active action definition identifier" then you are
in luck. This item has been added using the Command Extension and you can
use this ID as the pattern argument for the Activities Extension. But not
all items that have been added using the Command Extension present their ID
string to the plug-in spy.
As a side note, the ID strings are period separated. For instance the ID for
a button might be "org.eclipse.ui.navigate.backwardHistory". Regular
expressions use the period to stand for any character. Luckily the period
used as a wild card matches with actual period characters so you don't need
to escape them if you don't want to. I find it makes it a bit easier to read
if they are not escaped and it is highly unlikely it will cause any
ambiguous matches.
Use the Plug-In Registry and plugin.xml files
The second way is to use the Plug-In Registry. You can open this view by
going to:
Window/Show View.../Other/Plug-in Development/Plug-In Registry
What you would like to do is to try to get a couple pieces of information:
a) the plugin that is contributing the UI element
b) information about what kind of extension the plugin is using to create
the UI element
If there is a very unique word associated with the UI element or its tool
tip then you can use this in the Plug-In Registry's filter field to try to
nail down which plug-in is contributing the UI element. The filter field is
not a very powerful tool so it can be a bit frustrating to use. It does not
allow wildcards and does not match space characters.
When you track down which plug-in is contributing the UI element then you
open the the plug-in in question from the Plug-Ins view which is found
grouped with the Package Explorer in the Plug-in Development perspective.
Then go to the Extensions tab and search for the ID string which can usually
be found in either a usage of the Command or ActionSet extension. If the UI
element is added using an ActionSet then you prefix the plug-in ID to UI ID
in the pattern argument given to the Activities Extension. For example
org.eclipse.ui.actionsets.foo becomes the pattern
org.eclipse.ui/org.eclipse.ui.actionsets.foo.
Then create a new Activity which will never be activated and a corresponding activityPatternBinding with the id you found in the last step. It will look like this in your plugin.xml:
<extension point="org.eclipse.ui.activities">
<activity id="myActivity" name="MenuHidingActivity">
<enabledWhen>
<with variable="activePartId">
<equals value="nonExistentPartId"></equals>
</with>
</enabledWhen>
</activity>
<activityPatternBinding activityId="myActivity" pattern="menuItemID">
</activityPatternBinding>
</extension>

How to use GWTQuery-UI

I am trying to unserstand how GWTQuery works, for that I am trying out a simple demo with the slider. As per the documentation at Google (the slider tab is on the bottom left), and using the class AbstractSliderDemo from here, which in turn, is implementing the Demo interface defined here, my onModuleLoad simply contains:
Label e = $("#slider").widget();
Query q = new Query();
q.setupDemoElement(e.getElement());
However on page-load, it is throwing a NullPointer exception. Can anybody guide me how to use it. Probably I am missing something here. (I have added both GWTQuery and GWTQuery-UI jar files to the build path, as well as including <inherits name='gwtquery.plugins.Ui' /> in the XML file).
And here is the directory structure of my project:
GwtQuery-Ui is just a wrapper on jquery-ui. That means that you need to inject the jquery and jquery-ui javascript file. Check the getting started guide og GwtQuery-ui

Setting a navigation rules in a returnListener from a Dialog doesn't work in ADF 10g (JSF faces 1.1)

I've a confirmation dialog created using the dialog framework. The dialog is opened by a command link and the value selected in tg is returned to a return listener. This is my command link.
<af:commandLink id="btnSalva" shortDesc="Salva"
binding="#{segnaPrzzDep.btnSalva}"
partialSubmit="true" immediate="true"
windowHeight="250"
windowWidth="350"
useWindow="true"
action="#{segnaPrzzDep.aclSalvaSegnaPrezzoDep}"
returnListener="#{segnaPrzzDep.rtlSalvaSegnaPrezzoDep}"
styleClass="btnSalva"/>
In the return listener i try to set a navigation rule, but nothing happens. I do it like this (the return handler does only this):
FacesContext fc = FacesContext.getCurrentInstance();
NavigationHandler nh = fc.getApplication().getNavigationHandler();
nh.handleNavigation(fc, "", "archivio");
The starnge thing is that if i use the dialog framework but withouth opening the window everything is ok. I f i set-up the command link like this:
<af:commandLink id="btnSalva" shortDesc="Salva"
binding="#{segnaPrzzDep.btnSalva}"
partialSubmit="true" immediate="true"
action="#{segnaPrzzDep.aclSalvaSegnaPrezzoDep}"
returnListener="#{segnaPrzzDep.rtlSalvaSegnaPrezzoDep}"
styleClass="btnSalva"/>
Everything works correctly. I'm using jDev 10.3.1.4 and the same version of ADF.
I have been just writing a very similar question, then i noticed that you have already post it.
I guess that the root cause will be the same in both our cases even that I am using the trinidad lib not ADF. The trinidad lib was actually a fork from ADF so they share quite a lot of code.
In my case, we have migrated from trinidad 1.0.7 to trinidad 1.0.10 (due to this problem).
Because of this upgrade the "commandButton" tag in our jsp files defined as
<tr:commandButton ... returnListener="bean.listenerMethod" ... useWindow="true" />
stops calling the bean.listenerMethod when the dialog where this button is present is closed.
Setting useWindow="false" causes the bean.listenerMethod to be called again.
Before the upgrade, the mentioned commandButton worked well in both cases (useWindow="true"/"false").
So as you can see the symptoms are very similar.
Now for the findings that i have made when analysing this issue.
By checking the logs I observed that the LifeCycleImpl class did not invoke all of the phases when returning back to the main page (after closing the dialog).
So 1) the post on the dialog was processed, which means all phases were processed and 2) the main page was called afterwards, but this time the very first phase "restore view" was just processed and then jumped directly to "render response" phase calling the main page without invoking the bean.listenerMethod.
When checking the same logs on trinidad 1.0.7 all of the phases where called also in step 2).
I have debugged the sources of trinindad 1.0.10 and tracked this difference to be caused by this "bug".
The problem here is that the UIViewRoot is being removed from session. When then calling close on the dialog, the "restore view" phase during (described above) step 2) can not find the UIVIewRoot of the main page.
When this happen, LifeCycleImpl decides to skipp directly to the "render phase" since it is probably expecting that due to missing UIViewRoot in the session this is the first call to the page (view) and so it just reloads the main page.
I am quite new to JSF but to me this looks like a bug.
In my case there is quite a high pressure on me to fix this problem somehow, so lets see what i will be able to do with this.
I have posted a new bug to https://issues.apache.org/jira/browse/TRINIDAD-2171.
I have find a workaround for this problem. In my project I created a class and a package
as org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java.
To this class i have copied everything from corresponding class in trinidad lib. Then i
have commented out changes done due to fix in https://issues.apache.org/jira/browse/TRINIDAD-1193.
Finally I make sure that my class gets loaded first before the one from trinidad lib (in tomcat this was done by coping the class to WEB_INF\classes dir, since this dir is called as first one when loading classes, i.e. before loading WEB-INF\libs where trinidad lib are placed).

How to deal with file uploading in test automation using selenium or webdriver

I think that everybody who uses Webdriver for test automation must be aware of its great advantages for web development.
But there is a huge issue if file uploading is part of your web flow. It stops being test automation. The security restriction of browsers (invoking file selection) practically makes it impossible to automate tests.
Afaik the only option is to have Webdriver click the file upload button, sleep the thread, have developer/tester manually select the file, and then do the rest of the web flow.
How to deal with this, is there a workaround for it? Because it really can't be done like this. It wouldn't make sense.
This is the only case I know of when browser security restrictions do not apply:
<script language=javascript>
function window.onload(){
document.all.attachment.focus();
var WshShell=new ActiveXObject("WScript.Shell")
WshShell.sendKeys("D:\MyFile.doc")
}
</script>
Webdriver can handle this quite easily in IE and Firefox. Its a simple case of finding the element and typing into it.
driver = webdriver.Firefox()
element = driver.find_element_by_id("fileUpload")
element.send_keys("myfile.txt")
The above example is in Python but you get the idea
Using AWT Robots is one option, if you're using Java, which you are. But it's not a good option, it is not very dependable, and not clean at all. Look here
I use HttpClient and run a few tests outside of Selenium. That's more dependable and cleaner.
See the code below. You'll need more exception handling and conditionals to get it to suit your job.
HttpClient c = new HttpClient();
String url = "http://" + cargoHost + ":" + cargoPort + contextPath + "/j_security_check";
PostMethod post = new PostMethod(url);
post.setParameter("j_username", username);
post.setParameter("j_password", password);
c.executeMethod(post);
url = "http://" + cargoHost + ":" + cargoPort + contextPath + "/myurl.html";
MultipartPostMethod mPost = new MultipartPostMethod(url);
String fileNameWithPath = this.getClass().getClassLoader().getResource(filename).getPath();
File f1 = new File(fileNameWithPath);
mPost.addParameter(elementName, f1);
mPost.addParameter("action", "upload");
mPost.addParameter("ajax", "true");
c.executeMethod(mPost);
mPost.getResponseBodyAsString();
The suggestion of typing into the text box works only if the textbox is enabled.
Quite a few applications force you to go through the file system file browser for obvious reasons.
What do you do then?
I don't think the WebDriver mavens thought of just presenting keys into the KeyBoard buffer (this used to be a "no brainer" in earlier automation days)
===
After several days of little sleep, head banging and hair pulling I was able to get some of the Robot-based solution suggested here (and elsewhere).
The problem i encountered was that the dialog text box that was populated with the correct file path and name could not respond to the KeyPress/Release Events of terminating the file name with VK_ENTER as in:
private final static int Enter = KeyEvent.VK_ENTER;
keyboard.keyPress(Enter);
keyboard.keyRelease(Enter);
What happens is that the file path and file name are typed in correctly but the dialog remains opened - against my constant hoping and praying that the key emulation will terminate it and get processed by the app under testing.
Does anyone know how to get this robot to behave a bit better?
Just thought I'd provide an FYI to author's original post of using ActiveX. Another workaround would be to integrate with desktop GUI automation tools to do the job. For example, google "Selenium AutoIt". For a more cross-platform solution, consider tools like Sikuli over AutoIt.
This of course, is not considering WebDriver's support for uploads on IE & Firefox via SendKeys, or considering for other browsers where that method doesn't work.
After banging my head on this problem for far too many hours, I wanted to share with the community that Firefox 7.0.1 seems to have an issue with the FirefoxDriver sendKeys() implementation noted above (at least I couldn't get it to work on my Windows 7 x64 box), I haven't found a workaround, but updating to Firefox 8.0.1 seems to have fixed the problem. For those of you wondering, it's also possible to use Selenium RC to solve this problem (though you need to account for all of your target operating systems and the native key presses required to interact with their file selection dialogs). Hopefully the issues I had to work around save other people some time, in summary:
https://gist.github.com/1511360
If you have your are using a grid, you could make the folder of the testfiles open for sharing.
This way you could select the upload input field and set its value to \\pc-name\myTestFiles
If you're not, you should go with local files on each system.

Categories