Skip to content

Commit

Permalink
mra/MRAChartPanel: Give some feedback to the user that chart is reloa…
Browse files Browse the repository at this point in the history
…ding.
  • Loading branch information
paulosousadias committed Nov 14, 2024
1 parent 6f2fd2b commit 46355dd
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions src/java/pt/lsts/neptus/mra/MRAChartPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.XYSeriesCollection;

import pt.lsts.neptus.gui.InfiniteProgressPanel;
import pt.lsts.neptus.gui.SelectAllFocusListener;
import pt.lsts.neptus.i18n.I18n;
import pt.lsts.neptus.mra.importers.IMraLogGroup;
Expand All @@ -97,6 +98,9 @@ public class MRAChartPanel extends JPanel implements ChartMouseListener {
private IMraLogGroup source;
private JTextField timeStepField;
private JButton selectEntities;
private JButton redraw;

private InfiniteProgressPanel busyPanel;

private JLabel lblX = new JLabel();
private JLabel lblY = new JLabel();
Expand Down Expand Up @@ -157,7 +161,11 @@ public void actionPerformed(ActionEvent e) {
}

if (chart.supportsVariableTimeSteps()) {
JButton redraw = new JButton(I18n.text("Redraw"));
busyPanel = InfiniteProgressPanel.createInfinitePanelBeans(I18n.text(""), 25);
controlPanel.add(busyPanel, "split");
busyPanel.setVisible(false);

redraw = new JButton(I18n.text("Redraw"));
timeStepField = new JTextField("" + timestep, 4);
if (MRATimeSeriesPlot.class.isAssignableFrom(chart.getClass())) {
selectEntities = new JButton(I18n.text("Series..."));
Expand Down Expand Up @@ -194,10 +202,10 @@ protected Void doInBackground() throws Exception {

@Override
protected void done() {
redraw.setEnabled(true);
blockButtonsUI(false);
}
};
redraw.setEnabled(false);
blockButtonsUI(true);
worker.execute();
}
timeStepField.setText(timestep + "");
Expand Down Expand Up @@ -317,11 +325,30 @@ protected Void doInBackground() throws Exception {

@Override
protected void done() {
blockButtonsUI(false);
}
};
blockButtonsUI(true);
worker.execute();
}

private void blockButtonsUI(boolean block) {
setBusy(block);
if (timeStepField != null)
timeStepField.setEnabled(!block);
if (selectEntities != null)
selectEntities.setEnabled(!block);
if (redraw != null)
redraw.setEnabled(!block);
}

private void setBusy(boolean busy) {
if (busyPanel != null) {
busyPanel.setVisible(busy);
busyPanel.setBusy(busy);
}
}

public void regeneratePanel() {
if (cpanel != null)
remove(cpanel);
Expand Down

0 comments on commit 46355dd

Please sign in to comment.