Skip to content

Commit

Permalink
Make UI thread not blocked on node problems and improve node problem …
Browse files Browse the repository at this point in the history
…error reporting.

fixes #1
  • Loading branch information
fireduck64 committed Nov 7, 2019
1 parent b32be39 commit fe9ca8c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/ChannelGlobals.java
Expand Up @@ -2,7 +2,7 @@

public class ChannelGlobals
{
public static final String VERSION = "dev.10.25.0";
public static final String VERSION = "dev.11.07.0";

public static final String NODE_ADDRESS_STRING="node";
public static final String CHANNEL_ADDRESS_STRING="chan";
Expand Down
9 changes: 6 additions & 3 deletions src/iceleaf/ChannelComboBox.java
Expand Up @@ -11,12 +11,12 @@
public class ChannelComboBox extends JComboBox<String>
{

private ChannelNode node;
private ChannelNodePanel node_panel;
protected TreeSet<String> current_select_box_items=new TreeSet<>();

public ChannelComboBox(ChannelNode node)
public ChannelComboBox(ChannelNodePanel node_panel)
{
this.node = node;
this.node_panel = node_panel;

UpdateThread ut = new UpdateThread();
ut.start();
Expand All @@ -34,6 +34,9 @@ public void runPass() throws Exception
try
{
TreeSet<String> names = new TreeSet<>();
ChannelNode node = node_panel.getNode();
if (node == null) return;

for(ChannelID cid : node.getChannelSubscriber().getChannelSet())
{
names.add(cid.toString());
Expand Down
23 changes: 10 additions & 13 deletions src/iceleaf/ChannelNodePanel.java
Expand Up @@ -85,25 +85,20 @@ public void setupPanel()

c.gridwidth = 1;
panel.add(new JLabel("Import files to channel: "), c);
while(node == null)
{
try
{
Thread.sleep(10); // evil person, sleeping in ui thread
}
catch(Throwable t){}
}
channel_import_box = new ChannelComboBox(node);
channel_import_box = new ChannelComboBox(this);
panel.add(channel_import_box, c);

c.gridwidth = GridBagConstraints.REMAINDER;
import_button = new JButton("Import");
import_button.addActionListener( new ImportAction());
panel.add(import_button, c);

}



// May very well be null on startup
public ChannelNode getNode()
{
return node;
}

public class NodeUpdateThread extends PeriodicThread
Expand All @@ -129,6 +124,8 @@ public void runPass() throws Exception
startNode();
}

if (node == null) return;

StringBuilder sb=new StringBuilder();

sb.append("Local node ID: " + AddressUtil.getAddressString( ChannelGlobals.NODE_ADDRESS_STRING, node.getNodeID()));
Expand Down Expand Up @@ -164,7 +161,7 @@ public void runPass() throws Exception
}
catch(Exception e)
{
String text = e.toString();
String text = MiscUtils.printStackTrace(e);
setMessageBox(text);
e.printStackTrace();

Expand Down Expand Up @@ -192,6 +189,7 @@ public void run()
private void startNode()
throws Exception
{
//There are too many side effects to try this more than once
start_attempt=true;
TreeMap<String, String> config_map = new TreeMap();

Expand All @@ -212,7 +210,6 @@ private void startNode()
setStatusBox("Node started");
setMessageBox("");


}

public class CreateAction implements ActionListener
Expand Down

0 comments on commit fe9ca8c

Please sign in to comment.