diff --git a/src/ChannelGlobals.java b/src/ChannelGlobals.java index cd8600c..d0d0412 100644 --- a/src/ChannelGlobals.java +++ b/src/ChannelGlobals.java @@ -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"; diff --git a/src/iceleaf/ChannelComboBox.java b/src/iceleaf/ChannelComboBox.java index c99c618..2db480d 100644 --- a/src/iceleaf/ChannelComboBox.java +++ b/src/iceleaf/ChannelComboBox.java @@ -11,12 +11,12 @@ public class ChannelComboBox extends JComboBox { - private ChannelNode node; + private ChannelNodePanel node_panel; protected TreeSet 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(); @@ -34,6 +34,9 @@ public void runPass() throws Exception try { TreeSet names = new TreeSet<>(); + ChannelNode node = node_panel.getNode(); + if (node == null) return; + for(ChannelID cid : node.getChannelSubscriber().getChannelSet()) { names.add(cid.toString()); diff --git a/src/iceleaf/ChannelNodePanel.java b/src/iceleaf/ChannelNodePanel.java index 9b2604c..7512e43 100644 --- a/src/iceleaf/ChannelNodePanel.java +++ b/src/iceleaf/ChannelNodePanel.java @@ -85,15 +85,7 @@ 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; @@ -101,9 +93,12 @@ public void setupPanel() 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 @@ -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())); @@ -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(); @@ -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 config_map = new TreeMap(); @@ -212,7 +210,6 @@ private void startNode() setStatusBox("Node started"); setMessageBox(""); - } public class CreateAction implements ActionListener