Open existing view in the same dataTree
/*
* Open existing view in the same dataTree based on its name
*
* @author David Pech <[email protected]>
*/
import
com.im.df.api.dml.*
import
com.im.df.api.dll.*
import
com.im.df.api.support.SelectionDescription
import
com.im.ijc.core.api.util.IJCCoreUtils
import
com.im.ijc.core.api.views.AbstractViewTopComponent
// this is a skeleton of a button script
// init is called when the button is initialized
//
// widget is IJCWidget instance
init = { widget ->
}
// destroy is called when the button is disposed to do clean-up if necessary
//
// widget is IJCWidget instance
destroy = { widget ->
}
// evaluate is called when the button is clicked to perform action
//
// widget is IJCWidget instance
evaluate = { widget ->
def rs = widget.form.resultSet
def dataTree = rs.dataTree
def views = dataTree.getViews().getItems()
// define the view name you want to open
def viewToOpen =
"yourViewName"
for
(view in views) {
// if a view of a given name is found
if
(view.getName().toLowerCase().contains(viewToOpen.toLowerCase())) {
// open the view
AbstractViewTopComponent.getViewRegistry().open(view);
break
;
}
}
}
// on_change is called when some vertex state is changed to make it possible to update button state
//
// widget is IJCWidget instance
// button JButton object used in browse mode
on_change = { widget, button ->
}