use of org.csstudio.opibuilder.util.MacrosInput in project yamcs-studio by yamcs.
the class OPIRuntimeDelegate method addRunnerInputMacros.
private void addRunnerInputMacros(final IEditorInput input) {
MacrosInput macrosInput = ((IRunnerInput) input).getMacrosInput();
if (macrosInput != null) {
macrosInput = macrosInput.getCopy();
macrosInput.getMacrosMap().putAll(displayModel.getMacrosInput().getMacrosMap());
displayModel.setPropertyValue(AbstractContainerModel.PROP_MACROS, macrosInput);
}
}
use of org.csstudio.opibuilder.util.MacrosInput in project yamcs-studio by yamcs.
the class OPIShell method openOPIShell.
/**
***********************************************************
* Static helper methods to manage open shells.
************************************************************
*/
/**
* This is the only way to create an OPIShell. Logs an error and cleans up if path is null.
*/
public static void openOPIShell(IPath path, MacrosInput macrosInput) {
if (macrosInput == null) {
macrosInput = new MacrosInput(new LinkedHashMap<String, String>(), true);
}
boolean alreadyOpen = false;
for (OPIShell opiShell : openShells) {
if (opiShell.getPath().equals(path) && opiShell.getMacrosInput().equals(macrosInput)) {
opiShell.raiseToTop();
alreadyOpen = true;
}
}
if (!alreadyOpen) {
OPIShell os = null;
try {
os = new OPIShell(Display.getCurrent(), path, macrosInput);
openShells.add(os);
sendUpdateCommand();
} catch (Exception e) {
if (os != null) {
os.dispose();
}
log.log(Level.WARNING, "Failed to create new OPIShell.", e);
}
}
}
use of org.csstudio.opibuilder.util.MacrosInput in project yamcs-studio by yamcs.
the class RunnerInputFactory method saveState.
/**
* Saves the state of the given RunnerInput into the given memento.
*
* @param memento
* the storage area for element state
* @param input
* the opi runner input
*/
public static void saveState(IMemento memento, IRunnerInput input) {
IPath path = ((IRunnerInput) input).getPath();
memento.putString(TAG_PATH, path.toString());
MacrosInput macros = ((IRunnerInput) input).getMacrosInput();
if (macros != null)
memento.putString(TAG_MACRO, macros.toPersistenceString());
}
use of org.csstudio.opibuilder.util.MacrosInput in project yamcs-studio by yamcs.
the class RunnerInputFactory method createInput.
public static IAdaptable createInput(IMemento memento) {
// Get the file name.
String pathString = memento.getString(TAG_PATH);
if (pathString == null) {
return null;
}
// Get a handle to the IFile...which can be a handle
// to a resource that does not exist in workspace
IPath path;
if (ResourceUtil.isURL(pathString))
path = new URLPath(pathString);
else
path = new Path(pathString);
MacrosInput macrosInput = null;
String macroString = memento.getString(TAG_MACRO);
if (macroString != null)
try {
macrosInput = MacrosInput.recoverFromString(macroString);
} catch (Exception e) {
OPIBuilderPlugin.getLogger().log(Level.WARNING, "Failed to recover macro", // $NON-NLS-1$
e);
}
return new RunnerInput(path, null, macrosInput);
}
Aggregations