How to catch message about buffer change
Submitted by Wednesday, 7 September, 2011 - 20:38
on
Hi,
I'm trying to develop simple plugin which response to buffer changes. So far I build a JAR file called SimpleLock.jar, containing .props file actions.xml and apropriate java.class files.
My problem is, that after creating and saving some buffer no Dialog appear and no text file is written on C: drive (these are the actions, that should be done after buffer saved).
Here is sample source code:
public class SimpleLockPlugin extends EBPlugin
{
public void handleMessage(EBMessage msg)
{
//I guess some dialog should appear if any message is captured.
JOptionPane.showMessageDialog(null, "Some message.");
//My own class for writing content to file
FileEditor.writeContentToFile("Some message.", "C:\\simpleLock.txt");
if(msg instanceof BufferUpdate)
{
//I guess some dialog should appear if any message related to buffer update is captured.
JOptionPane.showMessageDialog(null, "Some message.");
if( ((BufferUpdate) msg).getWhat().equals(BufferUpdate.SAVED) )
{
String path = ((BufferUpdate) msg).getBuffer().getPath();
//I guess some dialog with path to saved file should appear if any message related to buffer saved is captured.
JOptionPane.showMessageDialog(null, path);
return;
}
}
}
}
I aslo get some errors at jEdit startup, right after opening plugin manager window:
org.xml.sax.SAXParseException: Content is not allowed in prolog.
Every time I open plugin manager wondow two SAXParseException appear.
Is it related to my probem with catching buffer changes?
I'm using jEdit 4.4.1
Any help would be appreciated.
Best regards,
Riven
I'm trying to develop simple plugin which response to buffer changes. So far I build a JAR file called SimpleLock.jar, containing .props file actions.xml and apropriate java.class files.
My problem is, that after creating and saving some buffer no Dialog appear and no text file is written on C: drive (these are the actions, that should be done after buffer saved).
Here is sample source code:
public class SimpleLockPlugin extends EBPlugin
{
public void handleMessage(EBMessage msg)
{
//I guess some dialog should appear if any message is captured.
JOptionPane.showMessageDialog(null, "Some message.");
//My own class for writing content to file
FileEditor.writeContentToFile("Some message.", "C:\\simpleLock.txt");
if(msg instanceof BufferUpdate)
{
//I guess some dialog should appear if any message related to buffer update is captured.
JOptionPane.showMessageDialog(null, "Some message.");
if( ((BufferUpdate) msg).getWhat().equals(BufferUpdate.SAVED) )
{
String path = ((BufferUpdate) msg).getBuffer().getPath();
//I guess some dialog with path to saved file should appear if any message related to buffer saved is captured.
JOptionPane.showMessageDialog(null, path);
return;
}
}
}
}
I aslo get some errors at jEdit startup, right after opening plugin manager window:
org.xml.sax.SAXParseException: Content is not allowed in prolog.
Every time I open plugin manager wondow two SAXParseException appear.
Is it related to my probem with catching buffer changes?
I'm using jEdit 4.4.1
Any help would be appreciated.
Best regards,
Riven