[TASK] Make it possible to enable/disable window activity.
This commit is contained in:
parent
9e610e7e22
commit
33d513ec03
@ -54,6 +54,7 @@ public class FancyTextObserverWindow extends JFrame implements Observer {
|
||||
private volatile boolean autoScrollToBottom = true;
|
||||
private volatile boolean usePrefixManager = true;
|
||||
private volatile boolean clearInsteadOfEleminatingLines = true;
|
||||
private volatile boolean updateThisWindow = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -90,6 +91,14 @@ public class FancyTextObserverWindow extends JFrame implements Observer {
|
||||
this.usePrefixManager = usePrefixManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether this window is currently being updated with data
|
||||
* @param updateThisWindow
|
||||
*/
|
||||
public void setUpdateThisWindow(boolean updateThisWindow) {
|
||||
this.updateThisWindow = updateThisWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the given text in the window
|
||||
* @param text
|
||||
@ -196,20 +205,19 @@ public class FancyTextObserverWindow extends JFrame implements Observer {
|
||||
// Bottom Panel contains control elements
|
||||
JPanel bottomPanel = new JPanel();
|
||||
|
||||
// Add a checkbox to toggle autoscroll
|
||||
JCheckBox autoscrollCheckbox = new JCheckBox();
|
||||
autoscrollCheckbox.setText("Automatically scroll to bottom");
|
||||
autoscrollCheckbox.setEnabled(true);
|
||||
autoscrollCheckbox.setSelected(true);
|
||||
autoscrollCheckbox.addActionListener(new ActionListener() {
|
||||
// Add a checkbox to toggle updating this window
|
||||
JCheckBox updateWindowCheckbox = new JCheckBox();
|
||||
updateWindowCheckbox.setText("Update this window");
|
||||
updateWindowCheckbox.setEnabled(true);
|
||||
updateWindowCheckbox.setSelected(true);
|
||||
updateWindowCheckbox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JCheckBox checkBox = (JCheckBox) e.getSource();
|
||||
textObserverWindow.setAutoScrollToBottom(checkBox.isSelected());
|
||||
textObserverWindow.setUpdateThisWindow(checkBox.isSelected());
|
||||
}
|
||||
});
|
||||
// TODO: Fix the feature first!
|
||||
//bottomPanel.add(autoscrollCheckbox);
|
||||
bottomPanel.add(updateWindowCheckbox);
|
||||
|
||||
// Add a checkbox to toggle uri shortening using PrefixManager
|
||||
JCheckBox usePrefixManagerCheckbox = new JCheckBox();
|
||||
@ -265,6 +273,10 @@ public class FancyTextObserverWindow extends JFrame implements Observer {
|
||||
* @param color to display the text in
|
||||
*/
|
||||
private void appendToTextPane(String text, boolean addLinebreak, Color color) {
|
||||
if(this.updateThisWindow == false) {
|
||||
// Don't update then window
|
||||
return;
|
||||
}
|
||||
final FancyTextObserverWindow me = this;
|
||||
EventQueue.invokeLater(() -> {
|
||||
me.actuallyAppendTextToTextPane(text, addLinebreak, color);
|
||||
@ -349,6 +361,10 @@ public class FancyTextObserverWindow extends JFrame implements Observer {
|
||||
*/
|
||||
@Override
|
||||
public void update(Observable observable, Object argument) {
|
||||
if(this.updateThisWindow == false) {
|
||||
// Don't update the window
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if(observable instanceof CsparqlQueryResultProxy) {
|
||||
CsparqlQueryResultProxy result = (CsparqlQueryResultProxy) observable;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package lu.jpt.csparqlproject.util;
|
||||
|
||||
import eu.larkc.csparql.cep.api.RdfQuadruple;
|
||||
import lu.jpt.csparqlproject.gui.FancyTextObserverWindow;
|
||||
import lu.jpt.csparqlproject.gui.RawTextObserverWindow;
|
||||
|
||||
/**
|
||||
@ -9,7 +10,8 @@ import lu.jpt.csparqlproject.gui.RawTextObserverWindow;
|
||||
*/
|
||||
public class WindowLoggingRdfStream extends LoggableRdfStream {
|
||||
|
||||
private RawTextObserverWindow observerWindow;
|
||||
//private RawTextObserverWindow observerWindow;
|
||||
private FancyTextObserverWindow observerWindow;
|
||||
|
||||
public WindowLoggingRdfStream(String iri) {
|
||||
super(iri);
|
||||
@ -17,7 +19,8 @@ public class WindowLoggingRdfStream extends LoggableRdfStream {
|
||||
final WindowLoggingRdfStream me = this;
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
me.observerWindow = new RawTextObserverWindow("[RdfStream] "+iri);
|
||||
//me.observerWindow = new RawTextObserverWindow("[RdfStream] "+iri);
|
||||
me.observerWindow = new FancyTextObserverWindow("[RdfStream] "+iri);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user