Page 1 of 1

Get Current File Path When Choosing Different Doc

Posted: Sat Oct 29, 2016 4:35 am
by mcc
Hi,

I know there's a way to get path using

Code: Select all

authorAccess.getEditorAccess().getEditorLocation().getPath();
However, seems the authorAccess can be only passed when open a dialog, so it will keep the same even though I choose another file. That means once new a dialog, the filepath would remain the same unless close the dialog. If I click on other file while that dialog is open, I cannot get new authorAccess. (we want to prevent user from doing sth on different files)

How to new another authorAccess ? Or is there another way to get file path ?

Thanks a lot!

Re: Get Current File Path When Choosing Different Doc

Posted: Mon Oct 31, 2016 10:39 am
by Radu
Hi,

I'm sorry but I do not understand. So you show a custom swing JDialog implementation? Is the dialog modal or modeless?
You can use our static API access to add a listener and when a new editor tab is selected, you can have access to its Author Access implementation:

Code: Select all

    PluginWorkspaceProvider.getPluginWorkspace().addEditorChangeListener(new WSEditorChangeListener(){
@Override
public void editorSelected(URL editorLocation) {
@SuppressWarnings("unused")
WSEditor editor = PluginWorkspaceProvider.getPluginWorkspace().getCurrentEditorAccess(PluginWorkspace.MAIN_EDITING_AREA);
if(editor.getCurrentPage() instanceof WSAuthorEditorPage){
AuthorAccess authorAccess = ((WSAuthorEditorPage)editor.getCurrentPage()).getAuthorAccess();
...
}
}
}, PluginWorkspace.MAIN_EDITING_AREA);

Regards,
Radu

Re: Get Current File Path When Choosing Different Doc

Posted: Tue Nov 01, 2016 3:15 am
by mcc
Great, that works. Thanks a lot Radu!