29 |
import org.jsampler.SamplerChannelModel; |
import org.jsampler.SamplerChannelModel; |
30 |
import org.jsampler.SamplerModel; |
import org.jsampler.SamplerModel; |
31 |
|
|
32 |
|
import net.sf.juife.Task; |
33 |
|
|
34 |
import static org.jsampler.JSI18n.i18n; |
import static org.jsampler.JSI18n.i18n; |
35 |
|
|
36 |
|
|
54 |
Integer[] chnIDs = CC.getClient().getSamplerChannelIDs(); |
Integer[] chnIDs = CC.getClient().getSamplerChannelIDs(); |
55 |
|
|
56 |
boolean found = false; |
boolean found = false; |
57 |
|
|
58 |
|
javax.swing.SwingUtilities.invokeAndWait(new Runnable() { |
59 |
|
public void |
60 |
|
run() { CC.getMainFrame().setAutoUpdateChannelListUI(false); } |
61 |
|
}); |
62 |
|
|
63 |
for(SamplerChannelModel m : sm.getChannels()) { |
for(SamplerChannelModel m : sm.getChannels()) { |
64 |
for(int i = 0; i < chnIDs.length; i++) { |
for(int i = 0; i < chnIDs.length; i++) { |
65 |
if(m.getChannelId() == chnIDs[i]) { |
if(m.getChannelId() == chnIDs[i]) { |
75 |
for(int id : chnIDs) { |
for(int id : chnIDs) { |
76 |
if(id >= 0) sm.addChannel(CC.getClient().getSamplerChannelInfo(id)); |
if(id >= 0) sm.addChannel(CC.getClient().getSamplerChannelInfo(id)); |
77 |
} |
} |
78 |
|
|
79 |
|
manageAutoUpdate(false); |
80 |
} catch(Exception x) { |
} catch(Exception x) { |
81 |
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
82 |
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
83 |
|
manageAutoUpdate(true); |
84 |
} |
} |
85 |
} |
} |
86 |
|
|
87 |
|
private void |
88 |
|
manageAutoUpdate(boolean force) { |
89 |
|
if(!force) { |
90 |
|
Task[] tasks = CC.getTaskQueue().getPendingTasks(); |
91 |
|
for(Task t : tasks) if(t.equals(this)) return; |
92 |
|
} |
93 |
|
|
94 |
|
javax.swing.SwingUtilities.invokeLater(new Runnable() { |
95 |
|
public void |
96 |
|
run() { |
97 |
|
CC.getMainFrame().setAutoUpdateChannelListUI(true); |
98 |
|
CC.getMainFrame().updateChannelListUI(); |
99 |
|
} |
100 |
|
}); |
101 |
|
} |
102 |
|
|
103 |
|
/** |
104 |
|
* Used to decrease the traffic. All task in the queue |
105 |
|
* equal to this are removed if added using {@link org.jsampler.CC#scheduleTask}. |
106 |
|
* @see org.jsampler.CC#addTask |
107 |
|
*/ |
108 |
|
public boolean |
109 |
|
equals(Object obj) { |
110 |
|
if(obj == null) return false; |
111 |
|
if(!(obj instanceof UpdateChannels)) return false; |
112 |
|
|
113 |
|
return true; |
114 |
|
} |
115 |
} |
} |