Combo box issue in Linux KDE environment - linux

I have a RCP application which works well in Linux GNOME environment.But when I tried the Application with Linux KDE environment
I am facing some issues with the combo box.
1.Combo box is not disposing properly.
Also when I tried to debug with eclipse,The entire UI goes to freeze state and I forced to restart my machine.
Is there any library need to be replaced while using Linux KDE environment?.Also combo box is not behaving as expected using the same code.
Please help me to resolve the issues.

I ran into the same issue on Ubuntu. I'm using IBM's Nebula implementation of a TableCombo with slight modifications. If you too, then the following code might help you:
getShell().addShellListener(new ShellAdapter() {
#Override
public void shellDeactivated(ShellEvent e) {
Display.getCurrent().asyncExec(new Runnable() {
#Override
public void run() {
if (Display.getCurrent().getFocusControl() == null) {
dropDown(false);
}
}
});
}
});
Insert this at the end of the createPopup() method.

Related

Getting Change Event to Fire in SyncFusion's SFAutoComplete Control

I am trying to use the SFAutoComplete control from SyncFusion in a Xamarin iPad app. (only iPad).
I am not able to get any sort of change event to fire.
What I've tried:
If you download SyncFusion and install it, it comes with a "SampleBrowser" app that has samples for all the controls in the suite.
If you open that SampleBrowser in visual studio and open the AutoComplete_Tablet.cs file after line 97, I've added this code:
countryAutoComplete.ValueChanged += (sender, args) =>
{
suggestionModeLabel.Text = "IT WORKED!";
};
But it never fires.
I've tried to use several different events from the list of events this control has (partial list from screenshot):
None of them seem to fire (I haven't tried ALL of them).
What do I need to do to get one of these events to fire? What am I missing?
Thanks for using Syncfusion Controls.
Delegate property can be used to hook the SFAutoComplete's events as per in the following code example,
Declaration code for Delegate property
SFAutoComplete autocomplete = new SFAutoComplete();
autocomplete.Delegate = new SFAutoCompleteDelegate();
The way to hook the events in SFAutoComplete
public class SFAutoCompleteDelegate : AutoCompleteDelegate
{
public override void DidTextChange(SFAutoComplete SFAutoComplete, string value)
{
//It fired while changing the text in AutoComplete
}
public override void DidSelectionChange(SFAutoComplete SFAutoComplete, string value)
{
//It fired while changing the suggestion from suggestion box.
}
}
We have created a sample for achieving your requirement. Please download the same from the following link
Link:http://www.syncfusion.com/downloads/support/forum/125261/ze/testingAutoComplete_21799375630
Thanks & Regards,
Hemalatha M.R

Leap Motion Controller.RemoveListener() called in Dispose() hangs

I've started developing a Leap Motion app and this is driving me nuts. Whenever I exit the application, the code responsible for cleaning up the Leap Motion controller hangs on me.
public void CleanUp()
{
_lmController.RemoveListener(_lmListener);
_lmController.Dispose();
}
I create both the controller and the listener in my Main Thread in a presenter class:
public MainViewPresenter(IMainView view, IApplicationController applicationController)
{
_view = view;
_applicationController = applicationController;
_view.Presenter = this;
_lmListener.Frame += _lmListener_Frame;
_lmController.AddListener(_lmListener);
}
The Cleanup() method is also a presenter method called on the view's FormClosing event. The weird thing is that it works perfectly fine when I call it from _listener_Frame(), which runs on a separate, Leap Motion-created no-name thread!
_lmListener_Frame() itself resides in the presenter. It just gets data from _lmController, creates a view model and sends it to the view, which in turn uses Invoke to update the display data.
I've tried calling the CleanUp stuff in Dispose() (both the view and the presenter (not redundant of course)) and that also doesn't work.
I admit that I'm not an expert in threading, but I can't see how there's any conflict going on here, and why RemoveListener works from controller thread, but not from the Main Thread, where the listener was actually added. Any help is appreciated!
SOLUTION
Completely by chance, I've found the solution today! It turns out that the "Invoke" call was the culprit, and it should've been BeginInvoke all this time, although this isn't mentioned anywhere in the WinForms setup guide. I'm guessing it was causing a deadlock with the controller thread and after the first GUI update it was bound to crash.
In a Windows forms Application, the following worked for me:
protected override void Dispose(bool disposing)
{
try
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
this.controller.RemoveListener(this.listener);
this.controller.Dispose();
}
}
finally
{
base.Dispose(disposing);
}
}
}
I wrote it awhile ago, though, and don't remember why it needed to be more complicated than what you tried. (Full example here: https://developer.leapmotion.com/documentation/csharp/devguide/Project_Setup_WinForms.html)

How do I keep the browser open after a coded ui test finishes?

I'm using Visual Studio 2012 Coded UI tests for a web application. I have a test for logging into the app which starts the browser, locates the login dialogue, enters credentials, and then clicks ok. I have an assertion which checks for the correct url after the login. This test appears to function correctly. My problem is that it closes the browser after the test runs. I need to keep the browser open, so I can run the next test in my sequence. How do I do this?
At the moment, I don't have anything in my [TestCleanup()] section. I'm assuming that what I'm looking for goes here, but so far I haven't had a lot of luck figuring out what that is supposed to be.
I don't have the original source where I found this solution :(
You can have a method like the one showed below. This method needs to be called in TestSetup. Also declare a class level variable _browserWindow of the tyep BrowserWindow
private void SetBrowser()
{
if(_browserWindow == null)
{
BrowserWindow.CurrentBrowser = "ie";
_browserWindow = BrowserWindow.Launch("http://www.google.com");
_browserWindow.CloseOnPlaybackCleanup = false;
_browserWindow.Maximized = !_browserWindow.Maximized;
}
else
{
BrowserWindow.CurrentBrowser = "ie";
_browserWindow = BrowserWindow.Locate("Google");
_browserWindow.Maximized = !_browserWindow.Maximized;
}
}
Ok, so what I needed to have happen was the launch and login before each test. I thought what I wanted was to run the browser and login test first, and then each additional test. After reading more, I've decided what I actually wanted was to run this logic as initialization code for each test. I've done that by adding this code to the default [TestInitialize()] generated when I started the coded ui project in Visual Studio 2012.
I have found the following method to work for my data driven coded UI test in Visual Studio 2015.
You will want to use [ClassInitialize] and get your browser open and direct it according to where your [TestMethod] begins.
Use [ClassCleanup] to release the resources after all the methods in the test class have been executed.
You can redirect test methods different after the class has been initialized by using the [TestInitialize] and clean-up test using the [TestCleanup]. Be careful with those though because they will occur for each test method and if it closes your browser instance your following test will fail.
private static BrowserWindow browserWindow = null;
[ClassInitialize]
public static void ClassInitialize(TestContext context)
{
Playback.Initialize();
browserWindow = BrowserWindow.Launch(new Uri("http://198.238.204.79/"));
}
[ClassCleanup]
public static void TestCleanup()
{
browserWindow.Close();
Playback.Cleanup();
}

Java Thread Safety v Displaying a Dialog from separate Thread

Hi noticed some code in our application when I first started Java programming. I had noticed it created a dialog from a separate thread, but never batted an eye lid as it 'seemed to work'. I then wrapped this method up through my code to display dialogs.
This is as follows:
public class DialogModalVisibleThread
extends Thread {
private JDialog jDialog;
public DialogModalVisibleThread(JDialog dialog, String dialogName) {
this.setName("Set " + dialogName + " Visable");
jDialog = dialog;
}
#Override
public void run() {
jDialog.setVisible(true);
jDialog.requestFocus();
}
}
Usage:
WarnUserDifferenceDialog dialog = new WarnUserDifferenceDialog( _tableDifferenceCache.size() );
DialogModalVisibleThread dmvt = new DialogModalVisibleThread( dialog, "Warn User About Report Diffs");
dmvt.start();
Now, as far as I am now aware, you should never create or modify swing components from a separate thread. All updates must be carried out on the Event Dispatch Thread. Surely this applies to the above code?
EDT on WikiPedia
However, the above code has worked.
But lately, there have been countless repaint issues. For example, click on a JButton which then calls DialogModalVisibleThread to display a dialog. It caused buttons alongside the clicked button not to redraw properly.
The repaint problem is more frequent on my machine and not the other developers machine. The other developer has a laptop with his desktop extended onto a 21" monitor - the monitor being his main display. He is running Windows 7 with Java version 1.6.0_27.
I am running on a laptop with Windows 7 and Java version 1.6.0_24. I have 2 additional monitors with my desktop extended onto both.
In the meantime I am going to upgrade to Java 1.6 update 27.
I wondered if the above code could cause repaint problems or are there any other people out there with related paint issues?
Are there any easy ways to diagnose these problems?
Thanks
So, you're breaking a rule, having problems, and wondering if these problems could be cause by the fact that you broke the rule. The answer is Yes. Respect the rules!
To detect the violations, you might be interested by the following page: http://weblogs.java.net/blog/2006/02/16/debugging-swing-final-summary
The easiest way to check if your problems are being caused by breaking the rules is to fix them (You should fix them anyway :-)
Just use SwingWorker.invokeLater() from the thread you want to update to UI from to easily adhere to Swing's contract. Something like this should do the trick:
#Override
public void run() {
SwingUtilities.invokeLater(new Runnable() {
jDialog.setVisible(true);
jDialog.requestFocus();
}
});
}
EDIT: You should make the 'jDialog' variable final for this to work.

j2me network connection

I have read in many places that network connection in a j2me app should be done in a separate thread. Is this a necessity or a good to have?
I am asking this because I could not find anywhere written that this must be done in a separate thread. Also, when I wrote a simple app to fetch an image over a network and display it on screen (without using a thread) it did not work. When I changed the same to use a separate thread it worked. I am not sure whether it worked just because I changed it to a separate thread, as I had done many other changes to the code also.
Can someone please confirm?
Edit:
If running in a separate thread is not a necessity, can someone please tell me why the below simple piece of code does not work?
It comes to a stage where the emulator asks "Is it ok to connect to net". Irrespective of whether I press an "yes" or a "no" the screen does not change.
public class Moo extends MIDlet {
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
Display display = Display.getDisplay(this);
MyCanvas myCanvas = new MyCanvas();
display.setCurrent(myCanvas);
myCanvas.repaint();
}
class MyCanvas extends Canvas {
protected void paint(Graphics graphics) {
try {
Image bgImage = Image.createImage(getWidth(), getHeight());
HttpConnection httpConnection = (HttpConnection) Connector
.open("https://stackoverflow.com/content/img/so/logo.png");
Image image = Image.createImage(httpConnection
.openInputStream());
bgImage.getGraphics().drawImage(image, 0, 0, 0);
httpConnection.close();
graphics.drawImage(bgImage, 0, 0, 0);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Edit: I got my answer for the code here.
Edit: I spawned off a separate question of this here.
The problem is that you are trying to do work within the thread that is responsible for running the UI. If you do not use a separate thread, then that UI thread is waiting while you do your work and can't process any of your other UI updates! so yes you really should not do any significant work in event handlers since you need to return control quickly there.
I agree with Sean, but it is not required to have your network connection in a separate thread, just best practice. I think that it's probably coincidental that the connection worked properly after moving it to a separate thread. Either way though, if you want to provide any visual feedback to the user while the connection is happening (which you probably do considering the disparity of lag that users can experience on a mobile network), you should have the networked processing in a separate thread.
It is not mandatory that you do network connections in a new thread,however practically you'll find that it almost always a good idea to do so since network activities could block and leave your app in an unresponsive state.
This is an old article but it speaks about some of the issues involved in networking and user experience.

Resources