PROBLEM with Selfmade Manager
Moderator: admin
PROBLEM with Selfmade Manager
I have Written a Manager to read Files with the formate of GZIP, by changing the String readLine() I am able to open the my files from the File Menu in LOGMX, but I am not able to Use Drag and Drop functionality. With Drag and Drop I get the error Formate not Handled. Can you help me out with it?
Re: PROBLEM with Selfmade Manager
Hello,
Does your Manager extend the class "LogFileManager" or "LocalFileManager"? Since LogMX v3.0.2, you can now extend the default LocalFileManager, and completely replace this LogMX default local file manager with your own manager (go to Tools > Options > Managers).
If your Manager doesn't extend "LocalFileManager" (which is not recommended in your case), what does your "getProtocolName()" return? If you don't extend "LocalFileManager", i'm afraid using drap'n'drop will not work, since LogMX chooses the Manager to use according to the URL specified by Windows for this drag'n'drop (here "file" by default).
Feel free to post your Manager code here or by Private Message if you still have troubles.
Xavier
Does your Manager extend the class "LogFileManager" or "LocalFileManager"? Since LogMX v3.0.2, you can now extend the default LocalFileManager, and completely replace this LogMX default local file manager with your own manager (go to Tools > Options > Managers).
If your Manager doesn't extend "LocalFileManager" (which is not recommended in your case), what does your "getProtocolName()" return? If you don't extend "LocalFileManager", i'm afraid using drap'n'drop will not work, since LogMX chooses the Manager to use according to the URL specified by Windows for this drag'n'drop (here "file" by default).
Feel free to post your Manager code here or by Private Message if you still have troubles.
Xavier
Re: PROBLEM with Selfmade Manager
Hello Xavier. Niti and me finally got the custom manager running.
As Niti told in her post, we first faced some problems deriving from LogFileManager. Especially using drag&drop. We tried with Protocol "file" and also with custom Protocol name like "gzfile".
We then tried to derive from LocalFileManager.
We didn't find the official description how to derive from LocalFileManager but the source of your LocalFileManager which you sent me couple of months ago helped out to understand what we should do.
Actually we found that some needed stuff was declared private in LocalFileManager.
Perhaps you should consider to declare some private members of LocalFileManager as protected since it would make deriving and reusing even more simple.
Finally we got our LocalFileManagerGzip working and here is the code we want to contribute to LogMx community. In contrast to original LocalFileManager it doesn't support "encoding detection" and "auto refresh".
If you don't need them you can use it as replacement for original LogFileManager. You will be able to open or drag&drop compressed (zip,gzip) and also uncompressed files.
As Niti told in her post, we first faced some problems deriving from LogFileManager. Especially using drag&drop. We tried with Protocol "file" and also with custom Protocol name like "gzfile".
We then tried to derive from LocalFileManager.
We didn't find the official description how to derive from LocalFileManager but the source of your LocalFileManager which you sent me couple of months ago helped out to understand what we should do.
Actually we found that some needed stuff was declared private in LocalFileManager.
Perhaps you should consider to declare some private members of LocalFileManager as protected since it would make deriving and reusing even more simple.
Finally we got our LocalFileManagerGzip working and here is the code we want to contribute to LogMx community. In contrast to original LocalFileManager it doesn't support "encoding detection" and "auto refresh".
If you don't need them you can use it as replacement for original LogFileManager. You will be able to open or drag&drop compressed (zip,gzip) and also uncompressed files.
Code: Select all
/**
* LocalFileManagerGzip: Extension of LocalFileManager for Zip and Gz formats.
* Random Access and Automatic Encoding detection are not supported.
*
*
*/
package sample.manager;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.zip.GZIPInputStream;
//import java.util.zip.ZipException;
import com.lightysoft.logmx.mgr.managers.LocalFileManager;
public class LocalFileManagerGzip extends LocalFileManager
{
protected BufferedReader bufReader = null; // As the bufReader and file are private in Local File Manager
protected File gzfile = null;
protected static final String NAME= "LocalFileManager Gzip v1";
public String getName() {
return NAME;
}
public String readLine() throws Exception { // The subclass for reading ZIP file
if (bufReader == null)
{
gzfile = new File(getCurrentURL());
try {
GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(gzfile));
bufReader = new BufferedReader(new InputStreamReader(gzipInputStream,
getEncoding()));
}
// backward compatible IOException, newer versions throw ZipException
// catch (ZipException NotinGZIPFormate)
catch (IOException NotinGZIPFormate)
{
try {
bufReader = new BufferedReader(new InputStreamReader(new FileInputStream(gzfile),
getEncoding()));
}
catch (FileNotFoundException lFileNotFoundException)
{
throw new IOException("Unable to open file \"" + getCurrentURL()
+ "\" in read-only mode.");
}
}
}
return bufReader.readLine();
}
public void releaseResources(boolean pSoftRelease)
{
super.releaseResources(pSoftRelease);
try {
if (bufReader != null)
{
bufReader.close();
}
} catch (IOException lException)
{
// any way
}
bufReader = null;
}
public boolean supportRandomAccess() {
return false;
}
public boolean supportHeaderReading() {
return false;
}
}
Re: PROBLEM with Selfmade Manager
Hello,
Thank you for your feedback.
To answer to your question, the 'bufReader' attribute was indeed declared 'private' to improve our Local Manager integrity. It shouldn't be an issue since the only two methods that use it (readLine() and releaseResources()) are declared "public" so that you can re-define your own Manager behavior regarding this buffer reader (as you perfectly did
).
Thank you for your contribution. This Manager will be included in the "Parsers & Managers Repository" that will come soon.
Xavier.
Thank you for your feedback.
To answer to your question, the 'bufReader' attribute was indeed declared 'private' to improve our Local Manager integrity. It shouldn't be an issue since the only two methods that use it (readLine() and releaseResources()) are declared "public" so that you can re-define your own Manager behavior regarding this buffer reader (as you perfectly did
![Smile :)](./images/smilies/icon_e_smile.gif)
Thank you for your contribution. This Manager will be included in the "Parsers & Managers Repository" that will come soon.
Xavier.