Board index » jbuilder » DOES ANYBODY KNOW

DOES ANYBODY KNOW


2003-10-24 06:03:11 AM
jbuilder6
does anybody know how to do this ?
 
 

Re:DOES ANYBODY KNOW

package test;
import java.io.*;
import com.borland.jbuilder.node.*;
import com.borland.primetime.*;
import com.borland.primetime.ide.*;
import com.borland.primetime.node.*;
import com.borland.primetime.util.*;
import com.borland.primetime.vfs.*;
public class Spy
extends BrowserAdapter implements BufferListener {
private Url url;
public Spy() {}
public static void initOpenTool(byte major, byte minor) {
if (major == PrimeTime.CURRENT_MAJOR_VERSION) {
Browser.addStaticBrowserListener(new Spy());
}
}
public void browserViewerActivated(
Browser browser, Node node, NodeViewer viewer) {
if (url != null) {
Buffer buffer = VFS.findBuffer(url);
if (buffer != null) {
buffer.removeBufferListener(this);
}
url = null;
}
if (node instanceof JavaFileNode) {
url = ((JavaFileNode)node).getUrl();
try {
VFS.getBuffer(url).addBufferListener(this);
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
public void browserViewerDeactivating(
Browser browser, Node node, NodeViewer viewer) throws VetoException
{
if (url != null) {
Buffer buffer = VFS.findBuffer(url);
if (buffer != null) {
buffer.removeBufferListener(this);
}
url = null;
}
}
public void bufferChanged(Buffer buffer, BufferUpdater updater) {}
public void bufferLoaded(Buffer buffer) {}
public void bufferStateChanged(Buffer buffer, int oldState, int
newState) {}
public void bufferSaving(Buffer buffer) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
baos.write("MY TEST\n".getBytes());
baos.write(buffer.getContent());
buffer.setContent(baos.toByteArray());
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
"Petar" < XXXX@XXXXX.COM >wrote in message
Quote
does anybody know how to do this ?


 

Re:DOES ANYBODY KNOW

Woow !
This is great. Thanks a lot !
Petar
"Bill Joy" < XXXX@XXXXX.COM >wrote in message
Quote
package test;

import java.io.*;
import com.borland.jbuilder.node.*;
import com.borland.primetime.*;
import com.borland.primetime.ide.*;
import com.borland.primetime.node.*;
import com.borland.primetime.util.*;
import com.borland.primetime.vfs.*;


public class Spy
extends BrowserAdapter implements BufferListener {
private Url url;

public Spy() {}

public static void initOpenTool(byte major, byte minor) {
if (major == PrimeTime.CURRENT_MAJOR_VERSION) {
Browser.addStaticBrowserListener(new Spy());
}
}

public void browserViewerActivated(
Browser browser, Node node, NodeViewer viewer) {

if (url != null) {
Buffer buffer = VFS.findBuffer(url);
if (buffer != null) {
buffer.removeBufferListener(this);
}
url = null;
}
if (node instanceof JavaFileNode) {
url = ((JavaFileNode)node).getUrl();
try {
VFS.getBuffer(url).addBufferListener(this);
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}

public void browserViewerDeactivating(
Browser browser, Node node, NodeViewer viewer) throws VetoException
{

if (url != null) {
Buffer buffer = VFS.findBuffer(url);
if (buffer != null) {
buffer.removeBufferListener(this);
}
url = null;
}
}

public void bufferChanged(Buffer buffer, BufferUpdater updater) {}
public void bufferLoaded(Buffer buffer) {}
public void bufferStateChanged(Buffer buffer, int oldState, int
newState) {}

public void bufferSaving(Buffer buffer) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
baos.write("MY TEST\n".getBytes());
baos.write(buffer.getContent());
buffer.setContent(baos.toByteArray());
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}


"Petar" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...
>does anybody know how to do this ?
>
>


 

{smallsort}

Re:DOES ANYBODY KNOW

Can you please tell me when the case noted by
!!>happens. url is always set to null when browser
deactivates. Therefore in activated url is null.
Or I am missing something.
Can you recomend me some tutorial, book, site
with examples. I find it hard learning only from
the samples directory.
Thanks one more time.
Petar
Quote
public void browserViewerActivated(
Browser browser, Node node, NodeViewer viewer) {

if (url != null) {
!!>Buffer buffer = VFS.findBuffer(url); // WHEN ?
if (buffer != null) {
buffer.removeBufferListener(this);
}
url = null;
}
if (node instanceof JavaFileNode) {
url = ((JavaFileNode)node).getUrl();
try {
VFS.getBuffer(url).addBufferListener(this);
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}

 

Re:DOES ANYBODY KNOW

Given the way this demo works, VFS.findBuffer() should probably never
return null. It should always find the Buffer loaded by the viewer of
the previously active Node.
Browser will deactivate the viewer for the active Node when closing
causing the demo to clear the Url reference.
Note that it would be more realistic to be a BufferListener for all
open files. The demo will only modify the source of a modified file
which is currently active during the save.
"Petar" < XXXX@XXXXX.COM >wrote in message
Quote
Can you please tell me when the case noted by
!!>happens. url is always set to null when browser
deactivates. Therefore in activated url is null.

Or I am missing something.

Can you recomend me some tutorial, book, site
with examples. I find it hard learning only from
the samples directory.

Thanks one more time.
Petar