Skip to content
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

Hyperlink to Ingestion Data Within Eclipse #86

Open
pauls4GE opened this issue Jul 26, 2023 · 1 comment
Open

Hyperlink to Ingestion Data Within Eclipse #86

pauls4GE opened this issue Jul 26, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request research

Comments

@pauls4GE
Copy link
Contributor

pauls4GE commented Jul 26, 2023

Add hyperlinks to the csv files in the ingestion package, not to the actual source of truth (like the PDFs)

The hyperlinks will take people from the .yaml files to the files that are being referenced in the .yaml file

E.g.:

  • data: package/project_data/data
@saratge
Copy link
Contributor

saratge commented Aug 23, 2023

Few inputs on Console Hyperlinks that can be implemented in RITE

We can print hyperlinks for erroneous YAML/OWL/CSV files while performing Manifest Import. That way, the user can quickly use the hyperlink to explore the eroneous file. Example screenshot:
image
To achieve this, we can either use Eclipse consolePatternMatcherListeners extension point in plugin.xml or programmatically by adding an org.eclipse.ui.console.IPatternMatchListener instance programmatically to the RackConsole object
I have taken the latter approach, and here is an example

 console.addPatternMatchListener(new IPatternMatchListener() {

				@Override
				public void connect(TextConsole console) {
					// TODO Auto-generated method stub
					
				}

				@Override
				public void disconnect() {
					// TODO Auto-generated method stub
					
				}

				@Override
				public void matchFound(PatternMatchEvent event) {
					File file =
			                new File(
			                        "/Users/223057479/ingestion_packages/turnstile-ingestion-package/manifest.yaml");
			        IWorkspace workspace = ResourcesPlugin.getWorkspace();
			        IPath location = Path.fromOSString(file.getAbsolutePath());
			        IFile ifile = workspace.getRoot().getFileForLocation(location);
			        FileLink link = new FileLink(ifile, null, -1, -1, -1);
					try {
						console.addHyperlink(link, event.getOffset(), event.getLength());
					} catch (BadLocationException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}

				@Override
				public String getPattern() {
					// TODO Auto-generated method stub
					return Pattern.compile("(ERROR.*yaml.*)|(ERROR.*csv.*)").pattern();
				}

				@Override
				public int getCompilerFlags() {
					// TODO Auto-generated method stub
					return 0;
				}

				@Override
				public String getLineQualifier() {
					// TODO Auto-generated method stub
					return null;
				}

			            	
            });

In the above code snippet, getPattern() is doing a regex pattern match on lines that start with "ERROR" and subsequently check if any YAML or CSV files are referenced in the message. The IPatternMatchListener registers to the RackConsole using connect() method and actively looks for a line in the console that can pattern match with the regex.

If a regex pattern match succeeds, like the one in the screenshot, the method matchFound(PatternMatchEvent event) is called, where we can add the Hyperlink to the RackConsole. The hyperlink also contains the file path and the editor to launch when the hyperlink is clicked.

Some required imports:

import org.eclipse.debug.ui.console.FileLink;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.ui.console.IPatternMatchListener;
import org.eclipse.ui.console.PatternMatchEvent;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request research
Projects
None yet
Development

No branches or pull requests

4 participants