I am showing and hiding Eclipse view with code below. It works perfectly with Eclipse 3.3, but with Eclipse Juno (version 4.3) it's not showing the first time but showing when I fire the event for the second time.
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage();
page.showView(UserView.ID);
page.hideView(page.findView(UserView.ID));
Is somebody come across with this situation before?
I am not sure why you are not getting it the first time. Check to see if you dont have null pointer errors when you fire it the first time.
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
can return a null if the workbench is not yet loaded.
I faced the same issue with the minimized state, so I tried chaging the view's state forcing it to appear after page.showView(UserView.ID);
this piece of code got my viewPart to show :
page.showView(UserView.ID);
IWorkbenchPartReference ref = page.getReference(searchResultUI);
page.setPartState(ref,IWorkbenchPage.STATE_RESTORED); //or STATE_MAXIMIZED
Related
In my eclipse plugin I need to get the selection in the package explorer.
I found out that this works like this:
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
ISelectionService service = window.getSelectionService();
IStructuredSelection structured = (IStructuredSelection) service.getSelection("org.eclipse.jdt.ui.PackageExplorer");
Object selection = structured.getFirstElement();
This works fine in 99% of all cases but I recently ran into a case where the getSelection("org.eclipse.jdt.ui.PackageExplorer"); returns null although I can clearly see that I have something selected in the package explorer...
How can that be?
Check that the view is not the Project Explorer rather than Package Explorer. They can look very similar and both default to appearing in the same place.
I'm making tetris in Android via eclipse (I use an emulator of eclipse). The program worked untill I added a bunch of stuff (maybe wasn't so smart, but nothing visual was changed so) I didn't run the progam in a while. Now I can go to my first activity, but as soon as I click the button to go to my next one, the program stops working :(
Here is my code:
MainActivity.java http://pastebin.com/P9AAJ90n (button towards Tetris.java)
Tetris.java http://pastebin.com/WEsXshPh (probably contains error)
TetrisView.java http://pastebin.com/ejUJjLMk
I think that's the code the problem is located in, but do ask for more if required...
(I think the problem is located in the onCreate() method of Tetris.java
Now the LogCat Debug text:
http://pastebin.com/MSCxHdsr
Thanks in advance
PS: If I remove the whole onCreate() of Tetris.java except the first 2 lines, I can run the program.
-----------------------------------------------EDIT-----------------------------------------------
I removed one of the setContentView(), still stops working. Also looked into DroppedTiles, thought I fixed it but didn't :(
Logcat: http://pastebin.com/JHu7n1uA
DroppedTiles: http://pastebin.com/tyKLuxVd
Block: http://pastebin.com/zmPa7cv7
I commented the DroppedTiles in Tetris.java...
Tried reading the debug log but most of it I do not understand sadly
you're setting content view twice
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tetris);
// Intent intent = getIntent();
// Add mTetrisView to this
mTetrisView = new TetrisView(this, null);
setContentView(mTetrisView);
mTetrisView.init();
figure out which is the correct one (probably the first) and remove the other.
I'm new to robotium and i'm trying to write a quick and dirty script to run through all screens in an app.
The problem i have mainly with the 'home button' in the app. I've tried lots of options but i cant seem to get it to click there except with index, which is not what i want.
When i check out the button with the hierarchyviewer it looks like this:
Link
However when i try for example:
assertTrue(
"Wait for text (id: myapp.R.id.home) failed.",
solo.waitForImageById("myapp.R.id.home", 20000));
solo.clickOnImage((ImageView) solo.findViewById("myapp.R.id.home"));
solo.waitForActivity("MenuActivity");
It fails at the waitForImageByID line. Ive tried multiple options like waitForImageButton etc, but i just cant seem to get it clicked. What am i missing here?
junit.framework.AssertionFailedError: View with id: '0' is not found!
at com.jayway.android.robotium.solo.Solo.getView(Solo.java:1990)
at com.jayway.android.robotium.solo.Solo.getView(Solo.java:1970)
at com.bitbar.recorder.extensions.OtherUtils.a(OtherUtils.java:246)
at com.bitbar.recorder.extensions.OtherUtils.b(OtherUtils.java:241)
at com.bitbar.recorder.extensions.v.a(Waiter.java:71)
at com.bitbar.recorder.extensions.ExtSolo.waitForImageButtonById(ExtSolo.java:4176)
at com.example.android.apis.test.Test.testRecorded(Test.java:137)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1740)
Use the following line to press the home button in the action bar
solo.clickOnActionBarHomeButton();
The issue is that the id that it is referring is not in your application, it is in androids default R file, try android.R.id.home and it should work fine. It is worth noting though that if your application uses action bar sherlock to support the action bar pre 4.0 that this will have a different ID there and you will have to handle this in your test.
You can see this for yourself looking at: http://developer.android.com/reference/android/R.id.html
When you are using ActionBarSherlock there are two different Ids you have to check, android.R.id.home for API-Level>11 and abs__home for lower levels (provided by ActionBarSherlock):
View homeButton = activity.findViewById(android.R.id.home);
if (homeButton == null) {
homeButton = activity.findViewById(R.id.abs__home);
}
What about this code:
ArrayList<LinearLayout> ll = solo.getCurrentViews(LinearLayout.class);
//You can change 1 with the ordinal number of LinearLayout you want to click.
solo.clickOnView(ll.get(1));
or also
ArrayList<ImageView> iv = solo.getCurrentViews(ImageView.class);
//You can change 0 with the ordinal number of Image you want to click.
solo.clickOnView(iv.get(0));
I think if you identify the correct id for view or linear layout or image view it should work.
Dave C's answer was working only partially for me. The button was clicked but before the preceding screen was loaded assertions had started and thus were always false. The solution is to run "home click" on the main thread (Robotium 5.2.1):
getInstrumentation().runOnMainSync(new Runnable() {
#Override
public void run() {
solo.clickOnActionBarHomeButton();
}
});
From your question I can see that it is an image view. You can click on any view using the following piece of code.
View view = solo.getView("View_name_from_hierachy_viewer");
solo.clickOnView(view);
View_name_from_hierachy_viewer in your case will be "home".
Let me know if this does not work.
In a RCP application, I change the locale by programatically setting it in the .ini file and restarting the application.
The problem is that view titles, which are defined in OSGI-INF/l10n files referred from the plugin.xml file, aren't updated until I focus them.
For example after having switched from EN to FR, I have this :
It's only after I click on the second tab that I get this :
I can't reset the perspectives as they may have been changed by the user (view resized, removed or added). I've set configurer.setSaveAndRestore(true); in my WorkbenchAdvisor.initialize method to ensure the views layout is restored at launch.
Is there a way to programatically force an update of the views titles without losing the perspective configuration ?
I precise that I can't use the new Eclipse 4 (Juno) API.
As you are restoring perspective from previous session, it might be remembering part titles.
By default ViewPart doesnt do anything in saveMemento() method.
Override below methods are to debug the issue
public void init(IViewSite site, IMemento memento) throws PartInitException
String getPartName()
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).