jEdit Community - Resources for users of the jEdit Text Editor
Interface becomes blank during external processing
Submitted by tj_sony on Thursday, 17 April, 2008 - 10:27
In my below contents, please substitue '[' and ']' with 'open angle bracket' and 'close angle bracket' respectively.

Contents of my jedit_gui.props is as follows
#{{{ process menu
process=aaa \
bbb \
ccc \
ddd \

Contents of my actions.xml is as follows
[ACTION NAME="aaa"]
[CODE]
view.selectProcess("aaa",buffer);
[/CODE]
[/ACTION]

[ACTION NAME="bbb"]
[CODE]
view.selectProcess("bbb",buffer);
[/CODE]
[/ACTION]

[ACTION NAME="ccc"]
[CODE]
view.selectProcess("ccc",buffer);
[/CODE]
[/ACTION]

[ACTION NAME="ddd"]
[CODE]
view.selectProcess("ddd",buffer);
[/CODE]
[/ACTION]

Contents of my View.java is as follows
public void selectProcess(String action,final Buffer buffer) throws IOException
{
...
}

From my customized jedit.jar, when I select anyone of the 4 menubar options (i.e., either aaa, bbb, ccc or ddd), its respective external process happens. But during the happening of the process, the jedit userinterface becomes blank. And till the external process for the respective menubar option is completed I cannot do anyother process on the jedit userinterface.

I think to solve this problem, I need to use Multithreading. Could anyone please tell me where and how do I use Multithreading concept in my above program.
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Use a swing worker: public
by elberry on Thu, 17/04/2008 - 23:57
Use a swing worker:

public void selectProcess(final String action, final Buffer buffer) throws IOException {
   SwingUtilities.invokeLater(new Runnable() {
      public void run() {
         ...
      }
   });
}

This executes your long process in the Swing thread allowing it to repaint.

Learn from the past. Live in the present. Plan for the future.
11101000
 
Interface becomes blank during external processing
by tj_sony on Fri, 18/04/2008 - 07:27
Hi elberry

I did as you had mentioned, that is

public void selectProcess(final String action, final Buffer buffer) throws IOException {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
//I inserted my code here
}
});
}


But still my Interface becomes blank during external processing. Instead of me creating the JMenu in jedit_gui.props, should I create JMenu from View.java and apply the code SwingUtilities.invokeLater(new Runnable(). Please suggest me.
 
Hmm. You might try using the
by elberry on Sun, 20/04/2008 - 22:54
Hmm. You might try using the same technique, but instead of using the SwingUtilities, just spawning your own thread.

Try:
public void selectProcess(final String action, final Buffer buffer) throws IOException {
   new Thread(new Runnable() {
      public void run() {
         //I inserted my code here
      }
   });
}

Another option might be to create your own toolbar. Take a look at the SQL plugin, it adds another toolbar below the jEdit one.

Learn from the past. Live in the present. Plan for the future.
11101000
 
Interface does not become blank, but my code does not execute
by tj_sony on Mon, 21/04/2008 - 12:17
Hi elberry

As mentioned by you, I used the following concept. But now the Interface does not become blank, but my code does not get executed, i.e., code coming within "//I inserted my code here"

public void selectProcess(final String action, final Buffer buffer) throws IOException {
new Thread(new Runnable() {
public void run() {
//I inserted my code here
}
});
}
 
Arg. Sorry, forgot to start t
by elberry on Mon, 21/04/2008 - 20:24
Arg. Sorry, forgot to start the thread.

public void selectProcess(final String action, final Buffer buffer) throws IOException {
   new Thread(new Runnable() {
      public void run() {
         //I inserted my code here
      }
   }).start();
}

If this doesn't work, I'd say your code "inserted my code here" is doing something to block the UI thread. Can you shed a little more light on what you're doing there?

Learn from the past. Live in the present. Plan for the future.
11101000
 
Thanks
by tj_sony on Tue, 22/04/2008 - 10:21
Thanks a lot elberry. You were of great help.
User login
Browse archives
« November 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   101634
Context Free Art (*.cfdg)   0.31   46062
BBEdit scheme   1.0   18601
JBuilder scheme   .001   18502
ColdFusion scheme   1.0   18031
R Edit Mode - extensive version   0.1   17481
Advanced HTML edit mode   1.0   16213
Matlab Edit Mode   1.0   16075
jEdit XP icons   1.0   15236
XP icons for jEdit   1.1   14300