Comments (5)
from datawarrior.
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.
Relocated the software from Program Files (x86) to Program Files.
Moved the I/O folder to multiple different locations in an attempt to resolve the pathing issue.
Observations:
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.
I am seeking guidance or suggestions that might help in resolving this write operation issue in the packaged jar environment. Any assistance would be greatly appreciated.
Thank you,
Shawn Cui
from datawarrior.
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. Relocated the software from Program Files (x86) to Program Files. Moved the I/O folder to multiple different locations in an attempt to resolve the pathing issue. Observations:
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. I am seeking guidance or suggestions that might help in resolving this write operation issue in the packaged jar environment. Any assistance would be greatly appreciated.
Thank you, Shawn Cui
HI Mr.Thomas,
I have specified the issue in a more detailed note,
it is live on:
https://blush-cabin-70a.notion.site/DW-Write-into-Folder-issue-de6d895db01c4634b0f29ef83cc359f0?pvs=4
from datawarrior.
I have check file permissions:
for:
@OverRide public void run(Properties configuration, IPluginHelper dwInterface) {
// Correct the path for localInputFolder
final String localInputFolder = "C:\\Users\\shawn.cui\\DATA_IO\\Input\\";
// Check if the directory is writable
File directory = new File(localInputFolder);
System.out.println("----------------------------------Can write: " + directory.canWrite() + "----------------------------------");
// Print the absolute path to ensure it's being resolved correctly
System.out.println("Absolute path: " + directory.getAbsolutePath());
// Export the current set of molecule inside DW into a SDF file
String pValue = localInputFolder.concat("input.sdf");
System.out.println("----------------------------------Full path to output file: " + pValue + "----------------------------------"); // Print the full path of the file you are attempting to write to
writeTableViaMacro(dwInterface, pValue); // use macro instead of DW internal per Thomas. 09/22/2023
}
Console:
"----------------------------------Can write: true----------------------------------
Absolute path: C:\Users\shawn.cui\DATA_IO\Input
----------------------------------Full path to output file: C:\Users\shawn.cui\DATA_IO\Input\input.sdf----------------------------------
but package jar wouldn't be able to write.
The error message I am getting is:
org.openmolecules.datawarrior.plugin.IPluginHelper.runMacro(Ljava/lang/String;)V
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);
from datawarrior.
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
- reproduce the same "uncaught Exception" issue on your machine;
- identify and fix this issue in DW;
- release a new version of DW with the issue already fixed for download (say, from https://openmolecules.org/datawarrior/download.html).
Your help is the only path forward for us to deploy our "PLPConnectorTask" plugin to our internal DW users. Many thanks again.
Best,
Zhengwei
/* The purpose of this class is to demonstrate the "Uncaught Exception:" we have obtained when deploying the
- PLPConnectorTask Plugin inside the "plugin" folder of a stand-alone DataWarrior installed on a
- Windows machine.
- This class will be shared with Thomas for possible in-depth debugging.
*/
import org.openmolecules.datawarrior.plugin.IPluginHelper;
import org.openmolecules.datawarrior.plugin.IPluginTask;
import org.openmolecules.datawarrior.plugin.IUserInterfaceHelper;
import javax.swing.*;
import java.util.Properties;
public class SaveSDFPluginTask implements IPluginTask {
private final String CONFIGURATION_SELECTED = "selected";
private final String[] OPTIONS = { "viaMacro" };
public JComboBox<String> mComboBox;
static final String localInputFolder = "C:/Users/" + System.getProperty("user.name") + "/DW_PLP_Temp_Folder/Input/";
// static final String localInputFolder = "C:/Users/zpeng/DW_PLP_Temp_Folder/Input/";
public SaveSDFPluginTask() {
System.out.println("localInputFolder: " + localInputFolder);
//localInputFolder: C:/Users/shawn.cui/DW_PLP_Temp_Folder/Input/
}
@Override public String getTaskCode() {
return "SaveSDFbugreport";
}
@Override public String getTaskName() {
return "SaveSDFbugreport";
}
/**
* This method expects a JPanel with all UI-elements for defining a database query.
* These may include elements to define a structure search and/or alphanumerical
* search criteria. 'Cancel' and 'OK' buttons are provided outside of this panel.
* @param dialogHelper gives access to a chemistry panel to let the user draw a chemical (sub-)structure
* @return
*/
@Override public JComponent createDialogContent(IUserInterfaceHelper dialogHelper) {
mComboBox = new JComboBox<String>(OPTIONS);
mComboBox.setSelectedIndex(0);
JPanel panel = new JPanel();
panel.add(new JLabel("Select one:"));
panel.add(mComboBox);
return panel;
}
/**
* This method is called after the users presses the dialog's 'OK' button.
* At this time the dialog is still shown. This method expects a Properties
* object containing all UI-elements' states converted into key-value pairs
* describing the user defined database query. This query configuration is
* used later for two purposes:<br>
* - to run the query independent from the actual dialog<br>
* - to populate a dialog with a query that has been performed earlier<br>
* @return query configuration
*/
@Override public Properties getDialogConfiguration() {
Properties configuration = new Properties();
configuration.setProperty(CONFIGURATION_SELECTED, (String)mComboBox.getSelectedItem());
return configuration;
}
/**
* This method populates an empty database query dialog with a previously configured database query.
* @param configuration
*/
@Override public void setDialogConfiguration(Properties configuration) {
String selected = configuration.getProperty(CONFIGURATION_SELECTED, OPTIONS[0]);
mComboBox.setSelectedItem(selected);
}
/**
* Checks, whether the given database query configuration is a valid one.
* If not, the this method should return a short and clear error message
* intended for the user in order to correct the dialog setting.
* @param configuration
* @return user-interpretable error message or null, if query configuration is valid
*/
@Override public String checkConfiguration(Properties configuration) {
return null; // no need to check, any configuration will be acceptable
}
@Override public void run(Properties configuration, IPluginHelper dwInterface) {
// Export the current set of molecule inside DW into a SDF file
String pValue = localInputFolder.concat("input.sdf");
writeTableViaMacro(dwInterface, pValue); // use macro instead of DW internal per Thomas. 09/22/2023
}
private void writeTableViaMacro(IPluginHelper dwInterface, String fileName) {
String macroString = "<macro name=\"zpSaveSDF\">\r\n"
+ "<task name=\"saveSDFile\">\r\n"
+ "version=v3\r\n"
+ "idColumn=Structure No\r\n"
+ "structureColumn=Structure\r\n"
+ "coordinates=2D\r\n";
macroString = macroString.concat("fileName=");
macroString = macroString.concat(fileName);
macroString = macroString.concat("\r\n</task>\r\n"
+ "</macro>");
System.out.println(macroString);
dwInterface.runMacro(macroString);
}
}
from datawarrior.
Related Issues (20)
- Copy-paste for structures throwing error in the master branch HOT 1
- Need some help to build Data Warrior and the plug-in examples on a Windows laptop. HOT 2
- It would be nice to have a stable version of codes for download HOT 2
- A Pipeline Pilot connector as a Data Warrior plugin HOT 8
- How to load a SDF file into a new and independent instance of DW from an existing instance of DW? HOT 2
- Adjusting UI Minimum Size for Plugin HOT 1
- Plugin Not Found HOT 1
- How to convert a Reaction / Trasformation column into Smile/Smart HOT 2
- mmtf.jar missing in classpath under Windows HOT 1
- Trouble installing v 6.01 HOT 7
- DataWarrior v06.00.00 does not support csv files HOT 9
- Datawarrior fails to start on Windows if not installed in C:\Program Files\DataWarrior HOT 1
- Feature request
- Type conversion HOT 4
- Crash when copy pasting this smiles
- could there any script to run sar or R-Group decompostion automatically? HOT 3
- Trojan horse? HOT 2
- feature suggestion: asset page about releases and cumulative updates
- style suggest: version labels consistently available as git tags
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datawarrior.