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