-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uncaught Exception related to CompoundTableSaver #19
Comments
Dear Zhengwei,
to be honest, I don't know what the problem is. One would need to debug it stepwise.
However, I would suggest not to use DataWarrior internal classes and methods at all, if you can avoid that.
These methods are not guaranteed to stay, they may change names or parameter lists with any small DataWarrior update.
What should stay are the interfaces defined in the plugin API. You should be able to achieve the same thing using that API. If functionality is not available, e.g. to save the front window into a file, you can in most cases run a macro through the PluginHelper class to achieve things. For instance saving the front window can be done with a macro that contains just one task defined as:
<macro name="Test">
<task name="saveFileAs">
fileName=/home/thomas/test.dwar
</task>
</macro>
Just create a String containing the macro and pass it to the PluginHelper.runMacro(String macro) method...
Would that be a solution for you?
Creating a macro definition as above is easy: In the DataWarrior Macro menu choose 'Start Recording...'. Do interactively whatever you want in the macro, choose 'Stop Recording' and 'Copy Macro', which copies the entire macro definition code into the clipboard.
Best wishes,
Thomas
…________________________________
Von: zpeng2003bht ***@***.***>
Gesendet: Dienstag, 19. September 2023 20:07
An: thsa/datawarrior ***@***.***>
Cc: Subscribed ***@***.***>
Betreff: [thsa/datawarrior] uncaught Exception related to CompoundTableSaver (Issue #19)
Dear Thomas:
I am using the following function "writeTable" in our "PLPConnectorTask.java" plugin code, leveraging the DW's "CompoundTableSaver" class, to export the molecules inside the active DW DEFrame into a SDF file:
private void writeTable(String fileName) {
SwingUtilities.invokeLater(() -> {
try {
DEFrame currentDEFrame = sDataExplorer.getActiveFrame();
DECompoundTableModel currentTableModel = currentDEFrame.getTableModel();
JTable currentTable = currentDEFrame.getMainFrame().getMainPane().getTable();
CompoundTableSaver dataSaver = new CompoundTableSaver(currentDEFrame, currentTableModel, currentTable);
dataSaver.saveSDFile(new File(fileName), FileHelper.cFileTypeSDV2, 0, 2, 1, null);
// assuming the 0st column contains the idcode encoded structure
// assuming the 1st column contain the 2D coordinate
// assuming the 2st column is the idColumn column
// coordsColumn if -1, then 2D-coords are generated on the fly
} catch (Exception e) {
e.printStackTrace();
}
});
}
It works well when I test the plugin inside a Java IDE (Eclipse) along with DW source code and its dependencies.
However when we packaged this "PLPConnectorTask.java" plugin as a JAR and placed it within the "plugin" folder of the standalone DataWarrior, this function call leads to the following error message seen in the dialog:
[DW_UncaughtExceptio]<https://user-images.githubusercontent.com/94724774/269048469-3019ce6b-7c0c-47e9-8ee4-31b0143aed96.gif>
Since the error message displayed in the dialog is too short, and I could not reproduce this error inside the Eclipse IDE to see the full stack trace of this exception, I wonder if you could provide some tips and suggestions.
best,
Zhengwei
—
Reply to this email directly, view it on GitHub<#19>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACNFEBUY4EITUPJX7NRVPIDX3HNOBANCNFSM6AAAAAA46WLXJ4>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
________________________________
The information of this email and in any file transmitted with it is strictly confidential and may be legally privileged. It is intended solely for the addressee. If you are not the intended recipient, any copying, distribution or any other use of this email is prohibited and may be unlawful. In such case, you should please notify the sender immediately and destroy this email. The content of this email is not legally binding unless confirmed by letter. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of the sender's company.
|
Dear Mr.Thomas, I have developed a plugin in Java which operates flawlessly when run from the IDE. I've managed to successfully compile, run, and package the project along with all external libraries in Maven. The expected behavior is to place the resultant jar into the software's plugin folder, and it should function as intended. Indeed, it does work as expected, apart from one critical issue: any operation involving write functionality fails, triggering an error, and it throws different exceptions for different write action. include my “log in” page where it does not really call any method from DataWarrior or its external library. The peculiar aspect is that the exact same code operates without a hitch when executed from the IDE, but exhibits this problem once packed into a jar. I've attempted to resolve this issue through two different coding approaches, both of which work perfectly in the IDE, but fail when executed from the jar. Steps already taken to troubleshoot include:Granted full access permissions to the relevant folder, DataWarrior, and I/O directory. The output folder seems to be accessed without any problems, but attempts to access the input folder (e.g., adding a column to the current table) fail consistently. Thank you, |
HI Mr.Thomas, |
I have check file permissions:
Console: "----------------------------------Can write: true---------------------------------- but package jar wouldn't be able to write. The error message I am getting is: I have checked source code of IPluginHelper, it is clear that there is indeed a runMacro method defined in the interface: void runMacro(String var1); |
Dear Thomas: Shawn and I have created the following plugin called "SaveSDFPluginTask" which works nicely within the IDE but leads to the same "uncaught Exception" when it is deployed into the "plugin" folder of a standalone DW. We hope that you can use this "SaveSDFPluginTask" code to
Your help is the only path forward for us to deploy our "PLPConnectorTask" plugin to our internal DW users. Many thanks again. Best, /* The purpose of this class is to demonstrate the "Uncaught Exception:" we have obtained when deploying the
import org.openmolecules.datawarrior.plugin.IPluginHelper; import javax.swing.*; public class SaveSDFPluginTask implements IPluginTask {
// static final String localInputFolder = "C:/Users/zpeng/DW_PLP_Temp_Folder/Input/";
} |
Dear Thomas:
I am using the following function "writeTable" in our "PLPConnectorTask.java" plugin code, leveraging the DW's "CompoundTableSaver" class, to export the molecules inside the active DW DEFrame into a SDF file:
It works well when I test the plugin inside a Java IDE (Eclipse) along with DW source code and its dependencies.
However when we packaged this "PLPConnectorTask.java" plugin as a JAR and placed it within the "plugin" folder of the standalone DataWarrior, this function call leads to the following error message seen in the dialog:
Since the error message displayed in the dialog is too short, and I could not reproduce this error inside the Eclipse IDE to see the full stack trace of this exception, I wonder if you could provide some tips and suggestions.
best,
Zhengwei
The text was updated successfully, but these errors were encountered: