Search in sources :

Example 11 with MacrosInput

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);
    }
}
Also used : MacrosInput(org.csstudio.opibuilder.util.MacrosInput)

Example 12 with 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);
        }
    }
}
Also used : MacrosInput(org.csstudio.opibuilder.util.MacrosInput) NotDefinedException(org.eclipse.core.commands.common.NotDefinedException) PartInitException(org.eclipse.ui.PartInitException) NotEnabledException(org.eclipse.core.commands.NotEnabledException) NotHandledException(org.eclipse.core.commands.NotHandledException) ExecutionException(org.eclipse.core.commands.ExecutionException) NotImplementedException(org.csstudio.opibuilder.datadefinition.NotImplementedException) LinkedHashMap(java.util.LinkedHashMap)

Example 13 with MacrosInput

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());
}
Also used : MacrosInput(org.csstudio.opibuilder.util.MacrosInput) IPath(org.eclipse.core.runtime.IPath)

Example 14 with MacrosInput

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);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) URLPath(org.csstudio.opibuilder.persistence.URLPath) MacrosInput(org.csstudio.opibuilder.util.MacrosInput) IPath(org.eclipse.core.runtime.IPath) URLPath(org.csstudio.opibuilder.persistence.URLPath)

Aggregations

MacrosInput (org.csstudio.opibuilder.util.MacrosInput)14 LinkedHashMap (java.util.LinkedHashMap)4 IPath (org.eclipse.core.runtime.IPath)4 PartInitException (org.eclipse.ui.PartInitException)3 Element (org.jdom.Element)3 InputStream (java.io.InputStream)2 MacrosProperty (org.csstudio.opibuilder.properties.MacrosProperty)2 Path (org.eclipse.core.runtime.Path)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ProcessVariable (org.csstudio.csdata.ProcessVariable)1 PrintDisplayAction (org.csstudio.opibuilder.actions.PrintDisplayAction)1 RefreshOPIAction (org.csstudio.opibuilder.actions.RefreshOPIAction)1 NotImplementedException (org.csstudio.opibuilder.datadefinition.NotImplementedException)1 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)1 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)1 DisplayModel (org.csstudio.opibuilder.model.DisplayModel)1