diff --git a/MAC/Navigator/scripts/libs/nav_fw/nav-config.ctl b/MAC/Navigator/scripts/libs/nav_fw/nav-config.ctl deleted file mode 100644 index 3924a2be079e81c916b8ccdb0de6ce410af9ce59..0000000000000000000000000000000000000000 --- a/MAC/Navigator/scripts/libs/nav_fw/nav-config.ctl +++ /dev/null @@ -1,1186 +0,0 @@ -//# gcfnav-configuration-functions.ctl -//# -//# Copyright (C) 2002-2004 -//# ASTRON (Netherlands Foundation for Research in Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl -//# -//# This program is free software; you can redistribute it and/or modify -//# it under the terms of the GNU General Public License as published by -//# the Free Software Foundation; either version 2 of the License, or -//# (at your option) any later version. -//# -//# This program is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License -//# along with this program; if not, write to the Free Software -//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//# -//# $Id$ - -//# -//# configuration storage functions for the Navigator. -//# - -#uses "nav_fw/gcf-util.ctl" -#uses "nav_fw/nav-view.ctl" - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigGetViewConfig -// -// returns the view config datapoint corresponding to the datapointpath -/////////////////////////////////////////////////////////////////////////// -string navConfigGetViewConfig(string datapointPath) -{ - string datapointType; - string dpViewConfig = ""; - string dpNameTemp = datapointPath; - bool isReference; - - int dotPos = strpos(datapointPath, "."); - if (dotPos >= 0) - { - dpNameTemp = substr(datapointPath, 0, strpos(datapointPath, ".")); - } - datapointType = getPropSetType(dpNameTemp); - if (datapointType != "") - { - // find __nav_<datapointType>_viewconfig datapoint - dpViewConfig = "__nav" + navConfigGetEnvironment("", "") + "_" + datapointType + "_viewconfig"; - } - else - { - // a system root node is selected - // find __nav<environment>_<systemname>_viewconfig datapoint - dpViewConfig = "__nav" + navConfigGetEnvironment("", "") + "_" + datapointPath + "_viewconfig"; - } - if (!dpAccessable(dpViewConfig)) - { - LOG_TRACE("navConfigGetViewConfig", "DP does not exist, using default configuration", dpViewConfig); - dpViewConfig = "__nav_default_viewconfig"; - } - LOG_TRACE(dpViewConfig); - return dpViewConfig; -} - -/////////////////////////////////////////////////////////////////////////// -// Functionname: navConfigGetEnvironment -// Function: -// -// Input: 1. environmentName: "" = current environment, -// !"" = given environment -// 2. userName, in combination with environment Personal: -// "" = current user(name) -// !"" = given user(name) -// returns the view config datapoint corresponding to the datapointpath -/////////////////////////////////////////////////////////////////////////// -string navConfigGetEnvironment(string environmentName, string userName) -{ - string environment; - string environmentOutput; - string environmentType; - string environmentNumber; - dyn_string environmentNames; - dpGet(DPNAME_NAVIGATOR + ELNAME_ENVIRONMENTNAMES, environmentNames); - - if (environmentName == "") // work with the current selected environment - { - string navInstanceEnvironmentName; - dpGet(DPNAME_NAVIGATOR + g_navigatorID + ELNAME_SELECTEDENVIRONMENT, navInstanceEnvironmentName); - environment = navInstanceEnvironmentName; - } - else // work with a given environment - { - environment = environmentName; - } - - if (environment == "Personal") - { - environmentType = "U"; - if (userName != "") // is userName is given, use it. - { - environmentNumber = getUserId(userName); - } - else - { - environmentNumber = getUserId(); - } - } - else - { - environmentType = "E" ; - environmentNumber = dynContains(environmentNames, environment); - } - environmentOutput = environmentType + strexpand("\\fill{0}", 4 - strlen(environmentNumber)) + environmentNumber; - - return environmentOutput; -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigSetSelectedElement -// -// write the selected element in the configuration -/////////////////////////////////////////////////////////////////////////// -void navConfigSetSelectedElement(string datapointPath) -{ - string dpSelectedElementContainer = DPNAME_NAVIGATOR + g_navigatorID + ELNAME_SELECTEDELEMENT; - string dpSelectedElement = datapointPath; - if (dpAccessable(dpSelectedElementContainer)) - { - dpSet(dpSelectedElementContainer, dpSelectedElement); - } -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigGetSelectedView() -// -// returns the caption of the currently selected view -/////////////////////////////////////////////////////////////////////////// -string navConfigGetSelectedView() -{ - string selectedViewCaption = "List"; - if (dpExists(DPNAME_NAVIGATOR + g_navigatorID)) - { - dpGet(DPNAME_NAVIGATOR + g_navigatorID + ELNAME_SELECTEDVIEWCAPTION, selectedViewCaption); - } - return selectedViewCaption; -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigGetViews() -// -// returns the views for the specified resource type -/////////////////////////////////////////////////////////////////////////// -dyn_string navConfigGetViews(string dpViewConfig) -{ - dyn_string views; - // get the views references for this resource type - dpGet(dpViewConfig + ELNAME_VIEWS, views); - return views; -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigGetViewCaption -// -// returns the caption of the specified view -/////////////////////////////////////////////////////////////////////////// -string navConfigGetViewCaption(string dpView) -{ - string caption; - dpGet(dpView + ELNAME_CAPTION, caption); - return caption; -} - - - - - -/////////////////////////////////////////////////////////////////////////// -// Function: navConfigInitPathNames -// Initiliases the global pathNames, according top the operating -// system; -// -// Input: 1. operating system -// -// Output: 1. g_path_temp is set -// 1. g_path_gnuplot is set -/////////////////////////////////////////////////////////////////////////// -void navConfigInitPathNames() -{ - dyn_string pathNames; - if (_WIN32) - { - dpGet("__navigator.pathNamesWindows", pathNames); - if ("" != pathNames[g_path_temp_index]) - g_path_temp = pathNames[g_path_temp_index]; - else - g_path_temp = "c:/temp"; - - g_path_gnuplot = pathNames[g_path_gnuplot_index]; - g_path_pictureconverter = pathNames[g_path_pictureconverter_index]; - } - else - { - dpGet("__navigator.pathNamesLinux", pathNames); - if ("" != pathNames[g_path_temp_index]) - g_path_temp = pathNames[g_path_temp_index]; - else - g_path_temp = "/tmp"; - - g_path_gnuplot = pathNames[g_path_gnuplot_index]; - g_path_pictureconverter = pathNames[g_path_pictureconverter_index]; - } -} - -/////////////////////////////////////////////////////////////////////////// -// Function: navConfigGetPathName -// converts a given pathName, according to the operating system, -// so it be used by a PVSS system command. -// -// Input: 1. user configured pathName -// -// Output: 1. pathName with replaced slashes and backslashes -/////////////////////////////////////////////////////////////////////////// -string navConfigGetPathName(string pathName) -{ - string output; - if (_WIN32) //windows - { - strreplace(pathName, "/", "\\"); - output = pathName; - } - else //It must be Linux - { - strreplace(pathName, "/", "//"); - } - return output; -} - -string navConfigGetSlashes() -{ - string output; - if (_WIN32) //windows - { - output = "\\"; - } - else - { - output = "//"; - } - return output; -} - - - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigGetNavigatorID -// -// returns the navigator ID -// -/////////////////////////////////////////////////////////////////////////// -int navConfigGetNavigatorID() -{ - return g_navigatorID; -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigSetNavigatorID -// -// sets the navigator ID -// -/////////////////////////////////////////////////////////////////////////// -void navConfigSetNavigatorID(int newID) -{ - bool createConfiguration = false; - if (newID > 256) - { - g_navigatorID = newID; - if (!dpAccessable(DPNAME_NAVIGATOR + g_navigatorID)) - { - createConfiguration = true; - } - } - else - { - g_navigatorID = myManNum(); - if (!dpAccessable(DPNAME_NAVIGATOR + g_navigatorID)) - { - createConfiguration = true; - } - } - if (createConfiguration) - { - dpCreate(DPNAME_NAVIGATOR + g_navigatorID, DPTYPENAME_NAVIGATOR_INSTANCE); - } - dpSet(DPNAME_NAVIGATOR + g_navigatorID + ELNAME_USECOUNT, 0); - LOG_DEBUG("Using Navigator ID:", g_navigatorID); -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigIncreaseUseCount -// -// increases the usecount of the navigator -// -/////////////////////////////////////////////////////////////////////////// -void navConfigIncreaseUseCount() -{ - // increase usecount - int usecount = 0; - dpGet(DPNAME_NAVIGATOR + g_navigatorID + ELNAME_USECOUNT, usecount); - usecount++; - dpSet(DPNAME_NAVIGATOR + g_navigatorID + ELNAME_USECOUNT, usecount); -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigDecreaseUseCount -// -// decreases the usecount of the navigator -// -/////////////////////////////////////////////////////////////////////////// -void navConfigDecreaseUseCount() -{ - // lower usecount of this navigator - int usecount = 0; - dpGet(DPNAME_NAVIGATOR + g_navigatorID + ELNAME_USECOUNT, usecount); - usecount--; - if (usecount > 0) - { - dpSet(DPNAME_NAVIGATOR + g_navigatorID + ELNAME_USECOUNT, usecount); - } - else - { - // if usecount == 0, remove datapoint - dpDelete(DPNAME_NAVIGATOR + g_navigatorID); - } -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigCheckEnabled -// -// returns the true if the datapoint is enabled or in the ignore list -// returns false otherwise -// -/////////////////////////////////////////////////////////////////////////// -bool navConfigCheckEnabled(string datapointName) -{ - bool enabled = false; - if (dpAccessable(datapointName + "__enabled")) - { - enabled = true; - LOG_TRACE("dpName__enabled Exists", datapointName, enabled); - } - else - { - LOG_TRACE("dpName__enabled NOT Exists", datapointName, enabled); - // check the ignoreEnabledRoots field - dyn_string ignoreEnabledDPs; - dyn_errClass err; - dpGet(DPNAME_NAVIGATOR + ELNAME_IGNOREENABLEDROOTS, ignoreEnabledDPs); - // If the datapointName is a reference, use the refernce to check for enabled - err = getLastError(); - if (dynlen(err) == 0) - { - for (int i = 1; i <= dynlen(ignoreEnabledDPs) && !enabled; i++) - { - int pos = strpos(datapointName, ignoreEnabledDPs[i]); - LOG_TRACE("checkEnabled", pos, datapointName, ignoreEnabledDPs[i]); - if (pos >= 0) - { - enabled = true; - } - } - } - - } - return enabled; -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigSetSelectedView() -// -// sets the caption of the currently selected view -/////////////////////////////////////////////////////////////////////////// -void navConfigSetSelectedView(string datapoint, int viewid) -{ - string dpViewConfig = navConfigGetViewConfig(datapoint); - dyn_string views = navConfigGetViews(dpViewConfig); - if (viewid <= dynlen(views)) - { - string caption = navConfigGetViewCaption(views[viewid]); - dpSet(DPNAME_NAVIGATOR + g_navigatorID + ELNAME_SELECTEDVIEWCAPTION, caption); - } - dpSet(dpViewConfig + ELNAME_SELECTEDVIEW, viewid); -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigGetViewConfigPanel -// -// returns the config panel of the specified view -/////////////////////////////////////////////////////////////////////////// -string navConfigGetViewConfigPanel(string dpView) -{ - string configPanel; - dpGet(dpView + ELNAME_CONFIGPANEL, configPanel); - return configPanel; -} - - -/////////////////////////////////////////////////////////////////////////// -//Function checkForReference -// -// parameters: parentDatapoint - get the children of this datapoint -// depth - how many levels of children to get -// -// returns - original parentDatapoint if it is a reference -// - bool if it is a reference -// - dyn_string reference with ref information -/////////////////////////////////////////////////////////////////////////// -bool checkForReference(string &parentDatapoint, dyn_string &reference, bool &parentDatapointIsReference) -{ - dyn_string refOut; - for (int i = 1; i <= dynlen(g_referenceList); i++) - { - refOut = strsplit(g_referenceList[i], "="); - if (dynlen(refOut) == 2) - { - if (strpos(parentDatapoint, refOut[1]) == 0) - { - parentDatapointIsReference = TRUE; - strreplace(parentDatapoint, refOut[1], refOut[2]); - reference = refOut; - break; - } - } - } - return parentDatapointIsReference; -} - -/////////////////////////////////////////////////////////////////////////// -//Function checkForReferenceReplaceOriginal -// -// parameters: resources -// reference -// -// returns - reference resources in stead of original resources -/////////////////////////////////////////////////////////////////////////// -void checkForReferenceReplaceOriginal(dyn_string &resources, dyn_string reference) -{ - for (int i = 1; i <= dynlen(resources); i++) - { - strreplace(resources[i], reference[2], reference[1]); - } -} - - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigGetResources -// -// parameters: parentDatapoint - get the children of this datapoint -// depth - how many levels of children to get -// -// returns the names of the resources that are added to the tree -/////////////////////////////////////////////////////////////////////////// -dyn_string navConfigGetResources(string parentDatapoint, int depth) -{ - dyn_string resources; - dyn_string allResources; - dyn_string resourceRoots; - dyn_string reference; - dyn_errClass err; - int maxDepth; - bool parentDatapointIsReference; - checkForReference(parentDatapoint, reference, parentDatapointIsReference); - if (parentDatapoint == "") - { - maxDepth = depth; - // read the roots from the configuration - dpGet(DPNAME_NAVIGATOR + ELNAME_RESOURCEROOTS, resourceRoots); - err = getLastError(); - if (dynlen(err) > 0) - { - // if nothing specified, take the local PIC and PAC trees - resourceRoots = makeDynString("PIC", "PAC"); - } - } - else - { - dyn_string dpPathElements = strsplit(parentDatapoint, "_"); - maxDepth = depth + dynlen(dpPathElements); - resourceRoots = makeDynString(parentDatapoint); - } - for (int i = 1; i <= dynlen(resourceRoots); i++) - { - // query the database for all resources under the given root - dynAppend(allResources, dpNames(resourceRoots[i] + "*")); - } - - ///////////////////////////////////////////////////////////// - LOG_DEBUG("All resources: ", dynlen(allResources)); - dyn_string newCollection; - dyn_string checkCollection = allResources; // collection with DP's, which have no "__enabled" equivalent - dyn_string enabledCollection = dynPatternMatch("*__enabled", allResources); - int enabledCollectionLength = dynlen(enabledCollection); - int position; - for (int j = 1; j<= enabledCollectionLength; j++) - { - string enabledCollectionItem = enabledCollection[j]; - strreplace(enabledCollectionItem, "__enabled", ""); - position = dynContains(checkCollection, enabledCollectionItem); - if (position > 0) - { - LOG_DEBUG("Adding: ", enabledCollectionItem); - dynAppend(newCollection, enabledCollectionItem); - dynRemove(checkCollection, position); - dynRemove(checkCollection, dynContains(checkCollection, enabledCollectionItem + "__enabled")); - } - else if (0 == position) - { - if (navPMLisTemporary(enabledCollectionItem)) - { - LOG_DEBUG("Adding temp: ", enabledCollectionItem); - dynAppend(newCollection, enabledCollectionItem); - } - } - } - /////////////////////////////////////////////////////////////// - - if (dynlen(checkCollection) > 0) - { - dyn_string ignoreEnabledDPs; - dyn_errClass err; - dpGet(DPNAME_NAVIGATOR + ELNAME_IGNOREENABLEDROOTS, ignoreEnabledDPs); - // check the ignoreEnabledRoots field - err = getLastError(); - if (dynlen(err) == 0) - { - dyn_string foundIgnoreItems; - for (int n = 1; n <= dynlen(ignoreEnabledDPs); n++) - { - foundIgnoreItems = dynPatternMatch(ignoreEnabledDPs[n] + "*", checkCollection); - dynAppend(newCollection, foundIgnoreItems); - } - } - } - //////////////////////////////////////////////////////////////// - allResources = newCollection; - ///////////////////////////////////////////////////////////// - // strip everything below the requested level - // remove duplicates - int i = 1; - - while (i <= dynlen(allResources)) - { - dyn_string dpPathElements = strsplit(allResources[i], "_"); - string addResource; - int d = 1; - while (d <= maxDepth && d <= dynlen(dpPathElements)) - { - if (d > 1) - addResource += "_"; - addResource += dpPathElements[d]; - d++; - } - if (!dynContains(resources, addResource)) - { - LOG_DEBUG("Adding: ", addResource); - dynAppend(resources, addResource); - } - i++; - } - if (parentDatapointIsReference) - { - checkForReferenceReplaceOriginal(resources, reference); - } - return resources; -} - - - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigfillEnvironmentList -// -// fills a comb -/////////////////////////////////////////////////////////////////////////// -void navConfigfillEnvironmentList(string dp1, dyn_string environmentNames) -{ - setValue("", "deleteAllItems"); - string selectedEnvironment; - int itemCount = 0; - dpGet(DPNAME_NAVIGATOR + g_navigatorID + ELNAME_SELECTEDENVIRONMENT, selectedEnvironment); - - - for (int i = 1; i<= dynlen(environmentNames); i++) - { - if (environmentNames[i] != "") - setValue("", "appendItem", environmentNames[i]); - if (environmentNames[i] == selectedEnvironment) - { - getValue("", "itemCount", itemCount); - setValue("", "selectedPos", itemCount); - } - - } - if (itemCount == 0) - { - setValue("", "selectedPos", 1); - dpSet(DPNAME_NAVIGATOR + g_navigatorID + ELNAME_SELECTEDENVIRONMENT, "Personal"); - } -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigGetViewConfig -// -// returns the view config datapoint corresponding to the datapointpath -/////////////////////////////////////////////////////////////////////////// -string navConfigGetViewConfig(string datapointPath) -{ - string datapointType; - string dpViewConfig = ""; - string dpNameTemp = datapointPath; - bool isReference; - dyn_string reference; - - checkForReference(dpNameTemp, reference, isReference); - if (dpAccessable(dpNameTemp + "__enabled")) - { - datapointType = getPropSetType(dpNameTemp); - // find __nav_<datapointType>_viewconfig datapoint - dpViewConfig = "__nav" + navConfigGetEnvironment("", "") + "_" + datapointType + "_viewconfig"; - } - else if (dpExists(dpNameTemp)) // Explicit use op dpExist!!! - { - datapointType = dpTypeName(datapointPath); - dpViewConfig = "__nav" + navConfigGetEnvironment("", "") + "_" + datapointType + "_viewconfig"; - } - else - { - // a system root node is selected - // find __nav<environment>_<systemname>_viewconfig datapoint - dpViewConfig = "__nav" + navConfigGetEnvironment("", "") + "_" + datapointPath + "_viewconfig"; - } - if (!dpAccessable(dpViewConfig)) - { - LOG_TRACE("navConfigGetViewConfig", "DP does not exist, using default configuration", dpViewConfig); - dpViewConfig = "__nav_default_viewconfig"; - } - LOG_TRACE(dpViewConfig); - return dpViewConfig; -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigGetViewConfigElements -// -// returns the view config elements corresponding to the viewconfig -/////////////////////////////////////////////////////////////////////////// -bool navConfigGetViewConfigElements( - string dpViewConfig, - int &selectedView, - int &selectedSubView, - dyn_string &views, - dyn_int &nrOfSubViews, - dyn_string &subViews, - dyn_string &configs) -{ - bool success = true; - dyn_errClass err; - - dpGet(dpViewConfig + ELNAME_SELECTEDVIEW, selectedView, - dpViewConfig + ELNAME_SELECTEDSUBVIEW, selectedSubView, - dpViewConfig + ELNAME_VIEWS, views, - dpViewConfig + ELNAME_NROFSUBVIEWS, nrOfSubViews, - dpViewConfig + ELNAME_SUBVIEWS, subViews, - dpViewConfig + ELNAME_CONFIGS, configs); - - err = getLastError(); //test whether no errors - if (dynlen(err) > 0) - { - throwError(err); // write errors to stderr - success = false; - } - return success; -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigSetSelectedSubView -// -// writes the selected subview into the configuration database -/////////////////////////////////////////////////////////////////////////// -void navConfigSetSelectedSubView( - string datapoint, - int selectedSubView) -{ - string dpViewConfig = navConfigGetViewConfig(datapoint); - dpSet(dpViewConfig + ELNAME_SELECTEDSUBVIEW, selectedSubView); -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigGetSubViewConfigElements -// -// returns the subview config elements corresponding to the viewconfig -/////////////////////////////////////////////////////////////////////////// -bool navConfigGetSubViewConfigElements( - string dpSubViewConfig, - string &subViewCaption, - string &subViewFileName) -{ - bool success = true; - dyn_errClass err; - - dpGet(dpSubViewConfig + ELNAME_CAPTION, subViewCaption, - dpSubViewConfig + ELNAME_FILENAME, subViewFileName); - - err = getLastError(); //test whether no errors - if (dynlen(err) > 0) - { - throwError(err); // write errors to stderr - success = false; - } - return success; -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigSanityCheck -// -// returns true if the View configuration items are correct -// returns false and a message otherwise -/////////////////////////////////////////////////////////////////////////// -bool navConfigSanityCheck(string &message) -{ - bool sane = true; - dyn_dyn_anytype tab; - int i; - dpQuery("SELECT '_original.._value' FROM '__nav_*' WHERE _DPT=\"GCFNavViewConfiguration\" ", tab); - - int viewsIndex = 4; - - while(viewsIndex <= dynlen(tab) && sane) - { - int subViewsIndex = viewsIndex + 1; - int configsIndex = viewsIndex + 2; - int nrOfSubviewsIndex = viewsIndex + 3; - - // check number of items in subviews, configs and nrOfSubViews - int nrOfViews = dynlen(tab[viewsIndex][2]); - sane = (nrOfViews == dynlen(tab[nrOfSubviewsIndex][2])); - //DebugTN("check nrOfViews:", sane, nrOfViews, dynlen(tab[nrOfSubviewsIndex][2])); - if (!sane) - { - message = "Invalid view configuration\n#views and nrOfSubViews do not correspond\n(" + tab[viewsIndex][1] + ")"; - DebugTN(message); - } - - if (sane) - { - int nrOfSubViews = 0; - for (i = 1; i <= dynlen(tab[nrOfSubviewsIndex][2]); i++) - nrOfSubViews += tab[nrOfSubviewsIndex][2][i]; - sane = (nrOfSubViews == dynlen(tab[subViewsIndex][2]) && nrOfSubViews == dynlen(tab[configsIndex][2])); - //DebugTN("check nrOfSubViews:", sane, nrOfSubViews, dynlen(tab[subViewsIndex][2]), dynlen(tab[configsIndex][2])); - if (!sane) - { - message = "Invalid view configuration\n#subviews, #configs and total nrOfSubViews do not correspond\n(" + tab[viewsIndex][1] + ")"; - DebugTN(message); - } - } - - if (sane) - { - for (i = 1; i <= dynlen(tab[viewsIndex][2]) && sane; i++) - { - sane = dpAccessable(tab[viewsIndex][2][i]); - LOG_TRACE("check view existance:", sane, tab[viewsIndex][2][i]); - } - if (!sane) - { - message = "Invalid view configuration\nview item (" + (i-1) + ") does not exist\n(" + tab[viewsIndex][1] + ")"; - DebugTN(message); - } - } - - if (sane) - { - for (i = 1; i <= dynlen(tab[subViewsIndex][2]) && sane; i++) - { - sane = dpAccessable(tab[subViewsIndex][2][i]); - DebugTN("check subview existance:", sane, tab[subViewsIndex][2][i]); - } - if (!sane) - { - message = "Invalid view configuration\nsubview item (" + (i-1) + ") does not exist\n(" + tab[viewsIndex][1] + ")"; - DebugTN(message); - } - } - - if (sane) - { - for (i = 1; i <= dynlen(tab[configsIndex][2]) && sane; i++) - { - sane = dpAccessable(tab[configsIndex][2][i]); - DebugTN("check configs existance:", sane, tab[configsIndex][2][i]); - } - if (!sane) - { - message = "Invalid view configuration\nconfig item (" + (i-1) + ") does not exist\n(" + tab[viewsIndex][1] + ")"; - DebugTN(message); - } - } - - viewsIndex += 6; - } - - return sane; -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigSubscribeUpdateTrigger -// -// subscribes to the update trigger datapointelement of the current naviagtor instance -/////////////////////////////////////////////////////////////////////////// -void navConfigSubscribeUpdateTrigger(string callback) -{ - dpConnect(callback, false, DPNAME_NAVIGATOR + g_navigatorID + ELNAME_TRIGGERUPDATE); -} - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigTriggerNavigatorRefresh -// -// writes a dummy value to the navigator configuration -// the navigator will refresh its views. This function is used -// to trigger a refresh of the entire navigator from a subview. -/////////////////////////////////////////////////////////////////////////// -void navConfigTriggerNavigatorRefresh() -{ - dpSet(DPNAME_NAVIGATOR + g_navigatorID + ELNAME_TRIGGERUPDATE, 0); -} - - -/////////////////////////////////////////////////////////////////////////// -//Function navConfigTriggerNavigatorRefreshWithDP -// -// 1. writes a new datapoint name to the navigator configuration with must be -// new displayed dp in the tree view. -// 2.writes a dummy value to the navigator configuration -// the navigator will refresh its views, for the new selected datapoint -// This function is used to trigger a refresh of the entire navigator from -// a subview. -/////////////////////////////////////////////////////////////////////////// -void navConfigTriggerNavigatorRefreshWithDP(string newDatapoint) -{ - dpSet(DPNAME_NAVIGATOR + g_navigatorID + ELNAME_NEWDATAPOINT, newDatapoint); - dpSet(DPNAME_NAVIGATOR + g_navigatorID + ELNAME_TRIGGERUPDATE, 0); -} - - -/////////////////////////////////////////////////////////////////////////// -//Function environmentsAvailableToUser -// -// returns the environments Available To the current User -/////////////////////////////////////////////////////////////////////////// -dyn_string environmentsAvailableToUser() -{ - dyn_string environmentGroups, environmentNames, currentUserGroupNames; - dyn_string Users_UserName, Users_GroupIds, Groups_UserName, Groups_UserId; - dyn_string environmentListAvailableToUser; - string currentGroupIds, currentUser = getUserName(); - environmentListAvailableToUser[1] = "Personal"; - dpGet("_Users.UserName", Users_UserName); - dpGet("_Users.GroupIds", Users_GroupIds); - dpGet("_Groups.UserName", Groups_UserName); - dpGet("_Groups.UserId", Groups_UserId); - - currentGroupIds = Users_GroupIds[dynContains(Users_UserName, currentUser)]; - dyn_string GroupIdsSplit= strsplit(currentGroupIds, ";"); - for (int i = 1; i <= dynlen(GroupIdsSplit); i++) - { - currentUserGroupNames[i] = Groups_UserName[dynContains(Groups_UserId, GroupIdsSplit[i])]; - } - - dpGet(DPNAME_NAVIGATOR + ".environmentGroups", environmentGroups); - dpGet(DPNAME_NAVIGATOR + ".environmentNames", environmentNames); - - for (int i = 1; i <= dynlen(environmentGroups); i++) //UG assignment to Environment - { - dyn_string environmentGroupSplit= strsplit(environmentGroups[i], "|"); //which UG do we have - for (int j = 1; j <= dynlen(environmentGroupSplit); j++) // UG group root,para,quest for env. X - { - for (int k = 1; k <= dynlen(currentUserGroupNames); k++) //user membership in UG guest etc. - { - dyn_string currentUserGroupNamesSplit= strsplit(currentUserGroupNames[k], "|"); - for (int m = 1; m <= dynlen(currentUserGroupNamesSplit); m++) - { - if (currentUserGroupNamesSplit[m] == environmentGroupSplit[j]) - { - environmentListAvailableToUser[dynlen(environmentListAvailableToUser) + 1] = environmentNames[i]; - } - } - } - } - } - return environmentListAvailableToUser; -} - -/////////////////////////////////////////////////////////////////////////// -// Function navConfigConfigSubviewPermitted -// -// if $configDatapoint exits, and not a DPE is selected in the tree, and a -// personal environment can always be configured, but a system environment -// only when you have the user-right. -// -// returns or the configuration of a subview is permitted, nrof Colums, titel etc. -/////////////////////////////////////////////////////////////////////////// -bool navConfigConfigSubviewPermitted() -{ - string selectedEnvironment; - dpGet(DPNAME_NAVIGATOR + g_navigatorID + ELNAME_SELECTEDENVIRONMENT, selectedEnvironment); - - if (dpAccessable($configDatapoint) && - dpGetElementName($datapoint) == "" && - ((selectedEnvironment == "Personal") || (selectedEnvironment != "Personal" && getUserPermission(UR_CONFIGSYSTEMSUBVIEW)))) - { - return TRUE; - } - else - { - return FALSE; - } -} - -////////////////////////////////////////////////////////////////////////////////// -// FunctionName: navConfigGetElementsFromDp -// -// Fills the dpe selectionlist for a datapoint selection -/////////////////////////////////////////////////////////////////////////////////// -dyn_string navConfigGetElementsFromDp(string datapoint) -{ - dyn_string output; - int elementIndex; - - dyn_string elements = getDpTypeStructure(datapoint); - for (elementIndex = 2; elementIndex <= dynlen(elements); elementIndex++) - { - dynAppend(output, substr(elements[elementIndex], 1)); // cut first dot - } - - dynSortAsc(output); - return output; -} - - - -/////////////////////////////////////////////////////////////////////////// -//Function arrangeUserGroupMembership -// -// fills the selectionboxes: member of and not member of -/////////////////////////////////////////////////////////////////////////// -void arrangeUserGroupMembership() -{ - UG_selected.deleteAllItems; - UG_available.deleteAllItems; - dyn_string environmentGroups, environmentNames, UserGroups; - dpGet("_Groups.UserName", UserGroups); - dpGet(DPNAME_NAVIGATOR + ".environmentGroups", environmentGroups); - dpGet(DPNAME_NAVIGATOR + ".environmentNames", environmentNames); - string GroupsForEnvironment = environmentGroups[dynContains(environmentNames, ComboBox_environmentMembership.selectedText)]; - dyn_string GroupsForEnvironmentsplit = strsplit(GroupsForEnvironment, "|"); - - for (int i = 1; i <= dynlen(GroupsForEnvironmentsplit); i++) - { - int position = dynContains(UserGroups, GroupsForEnvironmentsplit[i]); - if (position>0) - { - UG_selected.appendItem = GroupsForEnvironmentsplit[i]; - dynRemove(UserGroups, position); - } - } - UG_available.items = UserGroups; -} - -navConfigAddRemoveSubView() -{ - dyn_errClass err; - dyn_float dfReturn; // return fields: [1] = success/failure, [2] = new nr of subviews - dyn_string dsReturn; // not used - dfReturn[1] = 0; // 0 = failure, 1 = success - dfReturn[2] = 0; // new nr of subviews - string viewsPath = navConfigGetViewsPath(); - string subViewName; - if (comboCaption.visible == true) // adding existing subview - subViewName = comboCaption.selectedText; - else - subViewName = textFieldCaption.text; - - string cleanedText; - for (int i = 0; i<strlen(subViewName); i++) - { - if (! ( (subViewName[i] >= 'a' && subViewName[i] <= 'z') || - (subViewName[i] >= 'A' && subViewName[i] <= 'Z') || - (subViewName[i] >= '0' && subViewName[i] <= '9') ) ) - { - cleanedText += "-"; - } - else - { - cleanedText += subViewName[i]; - } - } - subViewName = $viewName + "_" + cleanedText; - - string subViewDpName = "__nav" + navConfigGetEnvironment("", "") + "_subview_" + subViewName; - string configDpTypeName = "GCFNavSubViewConfig" + $viewName; - string configDpName = "__nav" + navConfigGetEnvironment("", "") + "_" + $selectedElementDpType + "_config_" + subViewName; - string viewConfigDpName = "__nav" + navConfigGetEnvironment("", "") + "_" + $selectedElementDpType + "_viewconfig"; - if ($addView) - { - //######################################################## - if (!dpAccessable(subViewDpName)&& !dpAccessable(configDpName)) - { - if (comboCaption.visible == false) // adding new subview - { - // create new GCFNavSubView instance - dpCreate(subViewDpName, "GCFNavSubView"); //__nav_subview_Alert_Red-Alert-125 - err = getLastError(); - if (dynlen(err) > 0) - { - errorDialog(err); - // open dialog box with errors - throwError(err); // write errors to stderr - } - else - { - dpSet(subViewDpName + ".caption", textFieldCaption.text, - subViewDpName + ".filename", viewsPath + textFieldFileName.text); - } - } - err = getLastError(); - if (dynlen(err) > 0) - { - errorDialog(err); - // open dialog box with errors - throwError(err); // write errors to stderr - } - else - { - // create new config datapoint - LOG_DEBUG("creating DP:", configDpName, configDpTypeName); - dpCreate(configDpName, configDpTypeName); //__nav_TLcuPic_config_Alert_Red-Alert-125 - err = getLastError(); - if (dynlen(err) > 0) - { - errorDialog(err); - // open dialog box with errors - throwError(err); // write errors to stderr - } - else - { - dyn_int nrOfSubViews; - dyn_string subViews, configs; - if (!dpAccessable(viewConfigDpName)) - { - // create a new datapoint, based on the default config - int err; - dpCopy("__nav_default_viewconfig", viewConfigDpName, err); - - // copy the contents of the default config - int i; - dyn_string allC; - dyn_anytype para; - allC = dpNames("__nav_default_viewconfig" + ".**:_original.._value", "GCFNavViewConfiguration"); - dpGet(allC, para); - for (i = 1; i <= dynlen(allC); i++) - { - strreplace(allC[i], "__nav_default_viewconfig", viewConfigDpName); - } - dpSet(allC, para); - } - dpGet(viewConfigDpName + ".nrOfSubViews", nrOfSubViews, - viewConfigDpName + ".subViews", subViews, - viewConfigDpName + ".configs", configs); - - err = getLastError(); - if (dynlen(err) > 0) - { - errorDialog(err); - // open dialog box with errors - throwError(err); // write errors to stderr - } - else - { - int insertIndex = 1; - for (int i = 1; i <= $selectedView; i++) - insertIndex += nrOfSubViews[i]; - dfReturn[2] = nrOfSubViews[$selectedView]; - nrOfSubViews[$selectedView] = nrOfSubViews[$selectedView] + 1; - dynInsertAt(subViews, subViewDpName, insertIndex); - dynInsertAt(configs, configDpName, insertIndex); - dpSet(viewConfigDpName + ".nrOfSubViews", nrOfSubViews, - viewConfigDpName + ".subViews", subViews, - viewConfigDpName + ".configs", configs); - - err = getLastError(); - if (dynlen(err) > 0) - { - errorDialog(err); - // open dialog box with errors - throwError(err); // write errors to stderr - } - else - { - dfReturn[1] = 1; // 0 = failure, 1 = success - dfReturn[2] = nrOfSubViews[$selectedView]; - } - } - } - } - } - else - { - //If the current subview name already exists, show message on screen - string message = "Entered caption already exists. \nPlease enter a new one."; - ChildPanelOnCentralModal(viewsPath + "MessageWarning.pnl", "Warning", makeDynString("$1:" + message)); - return; - } - //######################################################## - } - else - { - // remove subview config for the selected datapoint type and the subview datapoint - - int selectedSubView; - dyn_int nrOfSubViews; - dyn_string subViews, configs; - if (dpAccessable(viewConfigDpName)) - { - dpGet(viewConfigDpName + ".selectedSubView", selectedSubView, - viewConfigDpName + ".nrOfSubViews", nrOfSubViews, - viewConfigDpName + ".subViews", subViews, - viewConfigDpName + ".configs", configs); - err = getLastError(); - if (dynlen(err) > 0) - { - errorDialog(err); - // open dialog box with errors - throwError(err); // write errors to stderr - } - else - { - int removeIndex = 0; - for (int i = 1; i<$selectedView; i++) - removeIndex += nrOfSubViews[i]; - removeIndex += selectedSubView; - - dfReturn[2] = nrOfSubViews[$selectedView]; - nrOfSubViews[$selectedView] = nrOfSubViews[$selectedView]-1; - dynRemove(subViews, removeIndex); - dynRemove(configs, removeIndex); - - dpSet(viewConfigDpName + ".nrOfSubViews", nrOfSubViews, - viewConfigDpName + ".subViews", subViews, - viewConfigDpName + ".configs", configs); - - err = getLastError(); - if (dynlen(err) > 0) - { - errorDialog(err); - // open dialog box with errors - throwError(err); // write errors to stderr - } - else - { - dfReturn[1] = 1; // 0 = failure, 1 = success - dfReturn[2] = nrOfSubViews[$selectedView]; - } - } - } - - dpDelete(subViewDpName); - dpDelete(configDpName); - } - - // write return parameters to the database - dpSet("_Ui_" + myManNum() + ".ReturnValue.Float:_original.._value", dfReturn); - dpSet("_Ui_" + myManNum() + ".ReturnValue.Text:_original.._value", dsReturn); - - PanelOff(); -} diff --git a/MAC/Navigator/scripts/libs/nav_fw/nav-main.ctl b/MAC/Navigator/scripts/libs/nav_fw/nav-main.ctl deleted file mode 100644 index aa8141370bc37db5c15f8b726ad44b0ec73258b4..0000000000000000000000000000000000000000 --- a/MAC/Navigator/scripts/libs/nav_fw/nav-main.ctl +++ /dev/null @@ -1,1458 +0,0 @@ -//# nav-main.ctl -//# -//# Copyright (C) 2002-2004 -//# ASTRON (Netherlands Foundation for Research in Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl -//# -//# This program is free software; you can redistribute it and/or modify -//# it under the terms of the GNU General Public License as published by -//# the Free Software Foundation; either version 2 of the License, or -//# (at your option) any later version. -//# -//# This program is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License -//# along with this program; if not, write to the Free Software -//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//# -//# $Id$ - -//# -//# global functions for the Navigator. All event handlers are implemented here -//# - -#uses "nav_fw/gcfnav-pmlinterface.ctl" -#uses "nav_fw/gcf-util.ctl" -#uses "nav_fw/gcf-common.ctl" -#uses "nav_fw/gcfnav-configuration-functions.ctl" - -global dyn_string g_itemID2datapoint; -global mapping g_datapoint2itemID; -global bool g_initializing = true; -global int STARTUP_DELAY = 1; -global int id; //needed for changing the selection in the tree (panel navigation, ER 218) -global int treeAddCount = 0; //test teller for performance issue -global unsigned g_nodeID = 0; -global unsigned g_parentIndex = 0; -global dyn_string g_referenceList = ""; -//Enumaration for the use of userrights. -global int UR_TREEACCESS1 = 6; -global int UR_TREEACCESS2 = 7; -global int UR_TREEACCESS3 = 8; -global int UR_TREEACCESS4 = 9; -global int UR_TREEACCESS5 = 10; -global int UR_TREEACCESS6 = 11; -global int UR_TREEACCESS7 = 12; -global int UR_TREEACCESS8 = 13; -global int UR_TREEACCESS9 = 14; -global int UR_TREEACCESS10 = 15; -global int UR_CONFIGSYSTEMSUBVIEW = 19; -global int UR_ADDREMOVESYSTEMSUBVIEW = 20; -global int UR_COMMANDSOPERATOR = 21; -global int UR_COMMANDSMAINTENANCE = 22; -global int UR_COMMANDSASTRONOMY = 23; -global int UR_SYSTEMMANAGEMENT = 24; -///////////////////////////////////////////// -//globals voor pathNames -global string g_path_temp = ""; -global string g_path_gnuplot = ""; -global string g_path_pictureconverter = ""; -global int g_path_temp_index = 1; -global int g_path_gnuplot_index = 2; -global int g_path_pictureconverter_index = 3; - -// Includes -#uses "nav_fw/treeView.ctl" -#used "nav_fw/nav-tabview.ctl" -#used "nav_fw/nav-config.ctl" - -// Constants -global string DPNAME_NAVIGATOR = "__navigator"; -global string ELNAME_PROPSETFILTERS = ".resourceRoots"; -global string ELNAME_IGNOREENABLEDROOTS = ".ignoreEnabledRoots"; -global string ELNAME_ENVIRONMENTNAMES = ".environmentNames"; -global string ELNAME_ENVIRONMENTGROUPS = ".environmentGroups"; -global string ELNAME_SELECTEDELEMENT = ".selectedElement"; -global string ELNAME_SELECTEDVIEWCAPTION = ".selectedViewCaption"; -global string ELNAME_USECOUNT = ".useCount"; -global string ELNAME_VIEWSPATH = ".viewsPath"; -global string ELNAME_VIEWS = ".views"; -global string ELNAME_CAPTION = ".caption"; -global string ELNAME_FILENAME = ".filename"; -global string ELNAME_CONFIGPANEL = ".configPanel"; -global string ELNAME_SELECTEDVIEW = ".selectedView"; -global string ELNAME_SELECTEDSUBVIEW = ".selectedSubView"; -global string ELNAME_SELECTEDENVIRONMENT = ".selectedEnvironment"; -global string ELNAME_NROFSUBVIEWS = ".nrOfSubViews"; -global string ELNAME_SUBVIEWS = ".subViews"; -global string ELNAME_CONFIGS = ".configs"; -global string ELNAME_TRIGGERUPDATE = ".triggerUpdate"; -global string ELNAME_NEWDATAPOINT = ".newDatapoint"; -const string ELNAME_TREEACCESS = ".treeAccess"; -global string ELNAME_MESSAGE = ".message"; -global string DPTYPENAME_NAVIGATOR_INSTANCE = "GCFNavigatorInstance"; - -global string MESSAGE_DPACCESS = "Node is not accessable."; -global string MESSAGE_ACCESSDENIED = "ACCESS DENIED\n\nYou have no rights to access this node."; - -global string ACTIVEX_TREE_CTRL_NAME = "FlyTreeXCtrl1"; -global string LIST_TREE_CTRL_NAME = "list"; -global string TAB_VIEWS_CTRL_NAME = "TabViews"; -global int NR_OF_VIEWS = 10; - -// Globals -global int gNavigatorID = 0; -global bool gShowProperties = false; //Show datapoint elements in the tree. If yes=> do! -global bool gActiveXSupported = false; -global string gNavigatorTabFile = "navigator_tab.pnl"; -global int gCurSelTreeViewIdx = 1; - - -////////////////////////////////////////////////////////////////////////////////// -// FunctionName: -// -// Params: -// Returns: -////////////////////////////////////////////////////////////////////////////////// - -// -------------------------- HANDLERS ------------------------------------------- - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: TreeView_OnInit -// -// called when the list is initialized -/////////////////////////////////////////////////////////////////////////// -TreeView_OnInit() -{ - LOG_DEBUG("TreeView_OnInit"); - - TreeCtrl_HandleEventInitialize(); - - // the last line of code of each treeView event handler MUST be the following: - id = -1; -} - -////////////////////////////////////////////////////////////////////////////////// -// FunctionName: TreeCtrl_HandleEventInitialize() -// -// initializes the Resources treeview -////////////////////////////////////////////////////////////////////////////////// -void TreeCtrl_HandleEventInitialize() -{ - initTree(); -} - -/////////////////////////////////////////////////////////////////////////// -// TreeView_OnExpand -// -// called when an item is expanded -/////////////////////////////////////////////////////////////////////////// -TreeView_OnExpand(unsigned treeViewIdx) -{ - LOG_DEBUG("TreeView_OnExpand", selNodeIdx); - - TreeCtrl_HandleEventOnExpand(selNodeIdx) - // the last line of code of each treeView event handler MUST be the following: - id = -1; -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: TreeCtrl_EventOnExpand(long Node) -// -// expands a node in the Resources treeview -/////////////////////////////////////////////////////////////////////////// -void TreeCtrl_HandleEventOnExpand(long treeViewIdx) -{ - dyn_anytype node = navConvTreeIdx2Node(treeViewIdx); - - if (dynlen(node) != treeView_INFO) - { - return; - } - if (checkDpPermit(node[treeView_INFO]) || node[treeView_PARENTID] == 0) - { - dyn_string propSets = getPropertySets(node[treeView_INFO], 2); - LOG_DEBUG("adding property sets: ", LOG_DYN(propSets)); - addPropSetsToTree(node[treeView_PATH], propSets); - // also call the default OnExpand implementation to expand the node - treeView_defaultOnExpandNode(treeViewIdx); - } - else - { - navMessageWarning(MESSAGE_ACCESSDENIED); //access to resource denied - } -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: TreeView_OnSelect -// -// called when an item is selected -/////////////////////////////////////////////////////////////////////////// -TreeView_OnSelect(unsigned pos) -{ - LOG_DEBUG("TreeView_OnSelect", pos); - TreeCtrl_HandleEventOnSelChange(pos); - - // the last line of code of each treeView event handler MUST be the following: - id = -1; -} -/////////////////////////////////////////////////////////////////////////// -// FunctionName: TreeCtrl_EventOnSelChange(long Node) -// -// initializes the Resources treeview -// TODO: optimize for selection change to the same resource type. Then don't reconfigure the tabs -/////////////////////////////////////////////////////////////////////////// -void TreeCtrl_HandleEventOnSelChange(long treeViewIdx) -{ - dyn_anytype node = navConvTreeIdx2Node(treeViewIdx); - - if (dynlen(node) != treeView_INFO) - { - return; - } - if (checkDpPermit(node[treeView_INFO]) || node[treeView_PARENTID] == 0) - { - string dpViewConfig = navConfigGetViewConfig(node[treeView_INFO]); - showView(dpViewConfig, datapointPath); - } - else - { - navMessageWarning(MESSAGE_ACCESSDENIED); //access to resource denied - } -} - - -/////////////////////////////////////////////////////////////////////////// -// TreeView_OnCollapse -// -// called when an item is expanded -/////////////////////////////////////////////////////////////////////////// -TreeView_OnCollapse(unsigned pos) -{ - LOG_DEBUG("TreeView_OnCollapse", pos); - TreeCtrl_HandleEventOnCollapse(pos); - - // the last line of code of each treeView event handler MUST be the following: - id = -1; -} - - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: TreeCtrl_HandleEventOnCollapse(long Node) -// -// expands a node in the Resources treeview -/////////////////////////////////////////////////////////////////////////// -void TreeCtrl_HandleEventOnCollapse(unsigned Node) -{ - treeView_deleteChildren(Node); - // TODO delete only childrens of childrens - treeView_defaultOnCollapseNode(Node); -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: Navigator_HandleUpdateTrigger() -// -// refreshes the navigator -/////////////////////////////////////////////////////////////////////////// -void Navigator_HandleUpdateTrigger(string dpe, int trigger) -{ - string newDatapoint; - dpGet(DPNAME_NAVIGATOR + gNavigatorID + ELNAME_NEWDATAPOINT, newDatapoint); - if (newDatapoint != "") - { - changeSelectedPosition(newDatapoint); - dpSet(DPNAME_NAVIGATOR + gNavigatorID + ELNAME_NEWDATAPOINT, ""); - refreshNavigator(); - } - else - { - refreshNavigator(); - } - -} -// -------------------------- PUBLIC METHODS ------------------------------------- - -////////////////////////////////////////////////////////////////////////////////// -// FunctionName: navConvTreeIdx2Node -// -// Params: treeViewIdx - index of an item of the treeView -// Returns: node object, empty array if treeViewIdx not valid, otherwise it contains 'treeView_INFO' items -/////////////////////////////////////////////////////////////////////////////////// -dyn_anytype navConvTreeIdx2Node(unsigned treeViewIdx) -{ - unsigned nodeId = treeView_convTreeIdx2NodeId(treeViewIdx); - return treeView_getNode(nodeId); -} - -////////////////////////////////////////////////////////////////////////////////// -// FunctionName: navConvTreeIdx2NodePath -// -// Params: treeViewIdx - index of an item of the treeView -// Returns: the complete node path including the node name on the index, "" if treeViewIdx not valid -////////////////////////////////////////////////////////////////////////////////// -string navConvTreeIdx2NodePath(unsigned treeViewIdx) -{ - string nodePath = ""; - dyn_anytype node = navConvTreeIdx2Node(treeViewIdx); - if (dynlen(node) == treeView_INFO) - { - nodePath = node[treeView_PATH]; - } - return nodePath; -} - -////////////////////////////////////////////////////////////////////////////////// -// FunctionName: navConvTreeIdx2DP -// -// Params: treeViewIdx - index of an item of the treeView -// Returns: the node info field of the node on the index, "" if treeViewIdx not valid -////////////////////////////////////////////////////////////////////////////////// -string navConvTreeIdx2DP(unsigned treeViewIdx) -{ - string dp = ""; - dyn_anytype node = navConvTreeIdx2Node(treeViewIdx); - if (dynlen(node) == treeView_INFO) - { - dp = node[treeView_INFO]; - } - return dp; -} - -////////////////////////////////////////////////////////////////////////////////// -// FunctionName: navMessageWarning -// -// used to display a message to the end-user -// -/////////////////////////////////////////////////////////////////////////////////// -void navMessageWarning(string message) -{ - ChildPanelOnCentralModal(navGetViewsPath() + "MessageWarning.pnl", "Warning", makeDynString("$1:" + message)); -} - -/////////////////////////////////////////////////////////////////////////// -//Function navGetViewsPath() -// -// returns the relative path where the navigator views are stored -/////////////////////////////////////////////////////////////////////////// -string navGetViewsPath() -{ - dpGet(DPNAME_NAVIGATOR + ELNAME_VIEWSPATH, viewsPath); - if (viewsPath == "") viewsPath = "nav_fw/"; - return viewsPath; -} - -////////////////////////////////////////////////////////////////////////////////// -// FunctionName: navCorrectResourceRoots, used to check the current systemname -// and fill GCFNavigator resourceroots with the present Systemname -// -/////////////////////////////////////////////////////////////////////////////////// - -void navCorrectResourceRoots() -{ - dyn_string roots; - dpGet(DPNAME_NAVIGATOR + "." + ELNAME_PROPSETFILTERS, roots); - string aSystemName = getSystemName(); - strreplace(aSystemName, ':', ""); - bool replaced = false; - - for (int i = 1; i <= dynlen(roots); i++) - { - dyn_string aS = strsplit(roots[i], ':'); - if (aS[1] != aSystemName) - { - strreplace(roots[i], aS[1], aSystemName); - replaced = true; - } - } - - if (replaced) - { - dpSet(DPNAME_NAVIGATOR + ELNAME_PROPSETFILTERS, roots); - } -} - -// -------------------------- PRIVATE METHODS ------------------------------------ - -////////////////////////////////////////////////////////////////////////////////// -// FunctionName: initTree() -// -// initializes the treeview with propertysets -////////////////////////////////////////////////////////////////////////////////// -void initTree() -{ - LOG_DEBUG("initTree()"); - - shape treeCtrl = getTreeCtrl(); - idispatch items; - if (ActiveXSupported()) - { - items = treeCtrl.Items; - items.BeginUpdate(); - items.Clear(); - treeCtrl.SortType = 0; - } - - // get top level property sets. "" means root, 2 means: 2 level depth - dyn_string propSets = getPropertySets("", 2); - LOG_DEBUG("adding property sets: ", LOG_DYN(propSets)); - addPropSetsToTree("", propSets); - treeView_defaultOnExpandNode(0); // shows the root nodes - if (ActiveXSupported()) - { - items.EndUpdate(); - } - LOG_DEBUG("~initTree()"); - delay(2, 0); - shape treeList = getShape(LIST_TREE_CTRL_NAME); - gCurSelTreeViewIdx = 1; - LOG_TRACE("Init, set selected node[1]", gCurSelTreeViewIdx); - treeList.selectedPos = 1; -} - -////////////////////////////////////////////////////////////////////////////////// -// FunctionName: getPropertySets -// -// Params: parentDatapoint - get the children of this datapoint -// depth - how many levels of children to get -// -// Returns: the names of the property sets, which have to be added to the tree -////////////////////////////////////////////////////////////////////////////////// -dyn_string getPropertySets(string parent, int depth) -{ - dyn_string foundPropSets; - dyn_string allFoundDPs; - dyn_string propSetFilters; - dyn_errClass err; - int maxDepth; - - ///////////////////////////////////////////////////////////// - // 1) Determine whether the parent is the root or not - // and determine a list of property set filters - if (parent == "") - { - // parent is root - maxDepth = depth; - // read the filters from the navigator configuration - dpGet(DPNAME_NAVIGATOR + ELNAME_PROPSETFILTERS, propSetFilters); - err = getLastError(); - if (dynlen(err) > 0 || dynlen(propSetFilters) == 0) - { - // if nothing specified, take the local PIC, PAC, VIC or GSO trees - propSetFilters = makeDynString("PIC", "PAC", "VIC", "GSO"); - } - } - else - { - dyn_string dpPathElements = strsplit(parent, ":_"); - maxDepth = depth + dynlen(dpPathElements); - // if the parent does not contain a system name than the maxDepth must be increased with 1 - // because the dpNames method always returns the systemname in the DP name - // and the system name is always a separate level too - if (strpos(parent, ":") < 0) maxDepth++; - propSetFilters = makeDynString(parent); - } - - ///////////////////////////////////////////////////////////// - // 2) Get all property sets (DP's), which matches with the filter - for (int i = 1; i <= dynlen(propSetFilters); i++) - { - // query the database for all propSets under the given root (filter) - // NOTE: This query also includes the "__enabled" DP's - dynAppend(allFoundDPs, dpNames(propSetFilters[i] + "*")); - } - - ///////////////////////////////////////////////////////////// - // 3) Make a list of enabled property sets (enabledPropSets) - // and a list of existing property sets, which are not enabled (checkPropSets) - // These property sets (checkPropSets) maybe will never be enabled (for instance SNMP related stuff). - // They are marked by the ignoredEnabledRoots list in the navigator configuration and - // have therefor to be checked against this configuration (see step 4). - LOG_DEBUG("All found DP's: ", dynlen(allFoundDPs)); - dyn_string allFoundPropSets; - dyn_string checkPropSets = allFoundDPs; // collection with DP's, which have no "__enabled" equivalent - dyn_string enabledPropSets = dynPatternMatch("*__enabled", allFoundDPs); - int propSetIdx, enablePropSetIdx; - for (int j = 1; j <= dynlen(enabledPropSets); j++) - { - string enabledPropSetsItem = enabledPropSets[j]; - strreplace(enabledPropSetsItem, "__enabled", ""); - propSetIdx = dynContains(checkPropSets, enabledPropSetsItem); - if (propSetIdx > 0) - { - LOG_DEBUG("Adding: ", enabledPropSetsItem); - dynAppend(allFoundPropSets, enabledPropSetsItem); - dynRemove(checkPropSets, propSetIdx); - enablePropSetIdx = dynContains(checkPropSets, enabledPropSetsItem + "__enabled"); - if (enablePropSetIdx > 0) - { - dynRemove(checkPropSets, enablePropSetIdx)); - } - } - else if (0 == propSetIdx) - { - // normally the property set should always be of category "temporary" in this case - if (navPMLisTemporary(enabledPropSetsItem)) - { - LOG_DEBUG("Adding temp: ", enabledPropSetsItem); - dynAppend(allFoundPropSets, enabledPropSetsItem); - } - } - } - - /////////////////////////////////////////////////////////////// - // 4) If there are property sets (DP's), which are not enabled, they have to be checked against the - // ignoreEnableRoots list. - if (dynlen(checkPropSets) > 0) - { - dyn_string ignoreEnabledFilters; - dpGet(DPNAME_NAVIGATOR + ELNAME_IGNOREENABLEDROOTS, ignoreEnabledFilters); - // check the ignoreEnabledFilters field - err = getLastError(); - if (dynlen(err) == 0) - { - dyn_string foundIgnoreItems; - for (int n = 1; n <= dynlen(ignoreEnabledFilters); n++) - { - foundIgnoreItems = dynPatternMatch(ignoreEnabledFilters[n] + "*", checkPropSets); - dynAppend(allFoundPropSets, foundIgnoreItems); - } - } - } - - /////////////////////////////////////////////////////////////// - // 5) strip everything below the requested level - // remove duplicates - int d; - dyn_string psPathElements; - string selectedPropSet; - for (int i = 1; i <= dynlen(allFoundPropSets); i++) - { - psPathElements = strsplit(allFoundPropSets[i], "_"); - // the first element always contains the system name and is also a separate level - // this level therefore can be default skipped - for (d = 2; d <= maxDepth && d <= dynlen(psPathElements); d++) - { - if (d > 2) - selectedPropSet += "_"; - selectedPropSet += psPathElements[d - 1]; - } - if (!dynContains(foundPropSets, selectedPropSet)) - { - LOG_DEBUG("Adding: ", selectedPropSet); - dynAppend(foundPropSets, selectedPropSet); - } - } - dynSortAsc(foundPropSets); - return foundPropSets; -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: addPropSetsToTree() -// -// Adds names of property sets and their elements to the treeview -// -// Params: parent - -// names - names of the property sets to add -// -/////////////////////////////////////////////////////////////////////////// -void addPropSetsToTree(string parent, dyn_string names) -{ - if (dynlen(names) > 0) - { - string systemName; - - ///////////////////////////////////////////////////////////////////// - // 1) Determine parentId and add systemname as root node if necessary - unsigned parentId = 0; - systemName = strrtrim(dpSubStr(names[1], DPSUB_SYS), ":"); - if (getSystemName() == (systemName + ":") && parent == "") - { - treeView_addNode(systemName, parentId, getSystemName()); - } - else - { - dyn_unsigned nodeIds = treeView_findNodes(parent); - if (dynlen(nodeIds) == 1) - { - parentId = nodeIds[1]; - } - else - { - LOG_FATAL("parent '" + parent + "' was not known in the treeView!!! No items added!!!"); - return; - } - } - dyn_anytype parentNode = treeView_getNode(parentId); - string parentDp = ""; - if (dynlen(parentNode) == treeView_INFO) - { - parentDp = parentNode[treeView_INFO]; - } - string curName; - string splittedName; - int j, k, l, m; - unsigned curNewParentId, curNewPropParentId; - dyn_string propertyStructure; - string curPropPath, fullPropPath; - string splittedProp; - string elementName; - dyn_string references, referenceSplit, refPropSets; - for (int i = 1; i <= dynlen(names); i++) - { - curName = names[i]; - // cut the parentDp part from the current dp name to get only the (right) part - // to be added to the tree - strreplace(curName, parentDp, ""); - splittedName = strsplit(curName, "_"); - curNewParentId = parentId; - for (j = 1; j <= dynlen(splittedName); j++) - { - curNewParentId = treeView_addNode(splittedName[j], curNewParentId, names[i]); - if (curNewParentId < 1) break; - } - curNewPropParentId = curNewParentId; - if (j > dynlen(splittedName)) - { - propertyStructure = getPSTypeStructure(names[i]); - for (k = 1; k <= dynlen(propertyStructure); k++) - { - curNewParentId = curNewPropParentId; - curPropPath = propertyStructure[k]; - splittedProp = strsplit(curPropPath, "."); - fullPropPath = names[i]; - for (l = 1; l <= dynlen(splittedProp); l++) - { - fullPropPath += "." + splittedProp[l]; - if ("__" == substr(splittedProp[l], 0, 2)) - { - if (dpAccessable(fullPropPath)) - { - dpGet(fullPropPath, references); - for (m = 1; m <= dynlen(references); m++) - { - referenceSplit = strsplit(references[m], "="); - string referenceViewText = referenceSplit[1] + referenceSign(referenceSplit[2]); - curNewParentId = treeView_addNode(referenceViewText, curNewParentId, referenceSplit[2]); - if (curNewParentId < 1) break; - refNode = treeView_getNode(curNewParentId); - // Because this is a reference, the PS's of the branch must be retrieved and - // added to the tree. - if (dynlen(refNode) > 0) - { - refNodePath = refNodePath[treeView_PATH]; - LOG_TRACE("Add reference: ", referenceViewText); - dyn_string refPropSets = getPropertySets(referenceSplit[2], 1); - addPropSetsToTree(refNodePath, refPropSets); - } - // else -> refnode was not added succesfully - } // end m loop - } - // it is sure that this property can no has childs - break; - } - else if (gShowProperties) - { - curNewParentId = treeView_addNode(splittedProp[l], curNewParentId, fullPropPath); - } // fi "__" - } // end l loop - } // end k loop - } // fi j > dynlen(..) - } // end i loop - } // fi dynlen(names) -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: getPSTypeStructure() -// -// Gets the type structure of a property set (PS) located on a local system or remote system -// even if PS does not exists as DP, if not exists than the __enabled DP will be used -// if DPtype in the __enabled DP has no DP instance than a dummy DP will be created -// -// Params: ps - property set from which the typestructure is requested -// NOTE: The ps param may not contains element, config or attribute tags -// Returns: a list with the type structure including the root element of the PS -/////////////////////////////////////////////////////////////////////////// -dyn_string getPSTypeStructure(string ps) -{ - dyn_string propertyStructure = makeDynString(); - if (dpAccessable(ps)) - { - propertyStructure = dpNames(ps + ".**"); - } - else - { - string systemName; - string psType = getPropSetType(ps); - if (psType != "") - { - systemName = dpSubStr(ps + "__enabled.", DPSUB_SYS); - dyn_string dps = dpNames(systemName + "*", psType); - if (dynlen(dps) == 0) - { - ps = "__dummy_" + psType; // system name may not be included in name of the DP to be created - dpCreate(ps, psType, getSystenId(systemName)); - ps = systemName + ps; - } - else - { - ps = dps[1]; - } - propertyStructure = dpNames(ps + ".**"); - } - } - for (int i = 1; i <= dynlen(propertyStructure); i++) - { - propertyStructure[i] = substr(propertyStructure[i], strlen(ps)); - } - return propertyStructure; -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: getPropSetType() -// -// retrieves the Type information from DP == property set, otherwise from <DP>__enabled -// -// Params: psName - property set name, including systemName -// -// Returns: Property set type -// -/////////////////////////////////////////////////////////////////////////// -string getPropSetType(string psName) -{ - string propSetType = dpTypeName(psName); - if (strlen(propSetType) == 0) - { - if (dpAccessable(psName + "__enabled.")) - { - string enabledValue; - dyn_string enabledValueSplit; - dpGet(psName + "__enabled.", enabledValue); - enabledValueSplit = strsplit(enabledValue, "|"); - if (dynlen(enabledValueSplit) == 2) - { - propSetType = enabledValueSplit[2]; - } - else - { - LOG_WARN("Erronous '" + psName + "__enabled' value: " + enabledValueSplit); - } - } - } - return propSetType; -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: referenceSign() -// -// Params: reference - reference property set -// Returns: " ->>" if reference is distributed -// " ->" if reference is NOT distributed -/////////////////////////////////////////////////////////////////////////// -string referenceSign(string reference) -{ - string refSign; - if (dpIsDistributed(reference)) - { - refSign = " ->>"; - } - else - { - refSign = " ->"; - } - - return refSign; -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: dpIsDistributed() -// -// Checks whether the given dpName is on another system or not -// -// Params: dpName - Datapoint name, including systemName -// -// Returns: TRUE, given dpName is on another system -// FALSE, given dpName is the same system -/////////////////////////////////////////////////////////////////////////// -bool dpIsDistributed(string dpName) -{ - string dpSystemName = strrtrim(dpSubStr(dpName, DPSUB_SYS), ":"); - return (getSystemName() != (dpSystemName + ":")); -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: ActiveXSupported -// -// Returns: true if the panel contains the ActiveX tree control -/////////////////////////////////////////////////////////////////////////// -bool ActiveXSupported() -{ - return gActiveXSupported; -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: setActiveXSupported -// -// sets the global variable that indicates if activeX is supported -// -/////////////////////////////////////////////////////////////////////////// -void setActiveXSupported() -{ - idispatch activeXctrl = 0; - if (activeXctrl == 0) - { - LOG_TRACE("I cannot create a COM object!? What the ....?? You must be running Linux or something.", ""); - gActiveXSupported = false; - } - else - { - LOG_TRACE("I can create a COM object! ", activeXctrl); - releaseComObject(activeXctrl); - gActiveXSupported = true; - } -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: getTreeCtrlName -// -// returns the name of the ActiveX tree control if activeX is supported, -// returns the name of the emulated tree control otherwise -/////////////////////////////////////////////////////////////////////////// -string getTreeCtrlName() -{ - if (ActiveXSupported()) - { - return ACTIVEX_TREE_CTRL_NAME; - } - else - { - return LIST_TREE_CTRL_NAME; - } -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: getTreeCtrl -// -// returns the ActiveX tree control shape if activeX is supported, -// returns the emulated tree control shape otherwise -/////////////////////////////////////////////////////////////////////////// -shape getTreeCtrl() -{ - return getShape(getTreeCtrlName()); -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: getTabCtrlName -// -// returns the name of the tab control that contains the views -/////////////////////////////////////////////////////////////////////////// -string getTabCtrlName() -{ - return TAB_VIEWS_CTRL_NAME; -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: getTabCtrl -// -// returns the tab control shape -/////////////////////////////////////////////////////////////////////////// -shape getTabCtrl() -{ - return getShape(getTabCtrlName()); -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: checkDpPermit -// -// Checks or the current user has permission to access the current datapoint -// -// Params: datapointPath -// Returns: TRUE, permitted to access given dpName -// FALSE, denied to given dpName -/////////////////////////////////////////////////////////////////////////// -bool checkDpPermit(string datapointPath) -{ - dyn_string treeAccess; - bool permit = FALSE; - int permitLength = 0; - dpGet(DPNAME_NAVIGATOR + ELNAME_TREEACCESS, treeAccess); - - for (int i = 6; i <= 15; i++) - { - if (treeAccess[i] != "") - { - if (patternMatch(treeAccess[i] + "*", datapointPath)) - { - if (getUserPermission(i)) - { - if (permitLength <= strlen(treeAccess[i])) - { - permit = TRUE; - permitLength = strlen(treeAccess[i]); - } - } - else - { - if (strlen(datapointPath) >= strlen(treeAccess[i])) - { - permit = FALSE; - break; - } - } - } - } - } - return permit; -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: changeSelectedPostion -// -// Params: newDatapoint - -/////////////////////////////////////////////////////////////////////////// -void changeSelectedPosition(string newDatapoint) -{ - int i; - long nodeID; - dyn_string datapointPath = splitDatapointPath(newDatapoint); - string systemName = substr(getSystemName(getSystemId()), 0, (strlen(getSystemName(getSystemId())) - 1)); - if (g_datapoint == systemName) - { - TreeView_OnExpand(1); - } - string temp = ""; - string temp_dpe = ""; - - dyn_string dcurrent = splitDatapointPath(g_datapoint); - dyn_string dnew = splitDatapointPath(newDatapoint); - int Index; - for (i = 1; i <= dynlen(datapointPath); i++) - { - if (i == 1) - { - temp = datapointPath[i]; - } - else - { - if (i == dynlen(datapointPath)) //last element in datapointPath could be an datapoint element - { - temp_dpe = temp + "." + datapointPath[i]; - } - temp = temp + "_" + datapointPath[i]; //build datapoint - } - - nodeID = getNodeFromDatapoint(temp); - if (nodeID == 0) //temp not found - { - nodeID = getNodeFromDatapoint(temp + " ->"); //maybe a local reference - if (nodeID != 0) - { - temp = temp + " ->"; - } - else - { - nodeID = getNodeFromDatapoint(temp + " ->>"); //temp maybe a remote reference - if (nodeID != 0) - { - temp = temp + " ->>"; - } - } - } - if (i != dynlen(datapointPath)) // do not expand last node, costs to much time/performance!!!! - { - if (nodeID != 0) - { - TreeView_OnExpand((nodeID)); - } - else - { - nodeID = getNodeFromDatapoint(temp_dpe); //nodeID not found, try the datapoint element - if (nodeID != 0) - { - TreeView_OnExpand(nodeID); - - } - } - } - } - - treeView_draw(); - gCurSelTreeViewIdx = nodeID; //update global info - treeView_setSelectedPosition(treeView_Tree2ViewIndex(nodeID)); -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: getSelectedNode -// -// returns the selected node in either the activex tree control or the -// emulated tree control -// 0 = nothing selected. First element in the tree is node nr. 1 -/////////////////////////////////////////////////////////////////////////// -long getSelectedNode() -{ - long selectedNode = 0; - shape treeCtrl = getTreeCtrl(); - if (ActiveXSupported()) - { - selectedNode = treeCtrl.Selected; - } - else - { - int selectedPos; - treeView_getSelectedPosition(selectedPos); - LOG_TRACE("selected pos:", selectedPos); - if (selectedPos >= 1) - { - selectedNode = treeView_view2TreeIndex(selectedPos); - } - else - { - selectedNode = selectedPos; - } - } - LOG_TRACE("selected node:", selectedNode); - return selectedNode; -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: refreshNavigator() -// -// refreshes the views of the navigator -/////////////////////////////////////////////////////////////////////////// -void refreshNavigator() -{ - if (!g_initializing) - { - LOG_TRACE("refreshNavigator ", gCurSelTreeViewIdx); - if (gCurSelTreeViewIdx != 0) - { - string datapointPath = buildPathFromNode(gCurSelTreeViewIdx); - - // if the datapointPath is a reference, it will be translated to the - // the original datapointPath. - dyn_string reference; - bool dpIsReference; - checkForReference(datapointPath, reference, dpIsReference); - string dpViewConfig = navConfigGetViewConfig(datapointPath); - - showView(dpViewConfig, datapointPath); - } - } - else - { - LOG_DEBUG("refreshNavigator suppressed while initializing "); - } -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: showActiveView(string datapointPath) -// -// shows the active tab identified by the datapoint -/////////////////////////////////////////////////////////////////////////// -void showActiveView(string dpViewConfig, string datapointPath) -{ - LOG_DEBUG("showActiveView", dpViewConfig, datapointPath); - shape tabCtrl = getTabCtrl(); - string viewsPath = navGetViewsPath(); - int selectedViewTabId = tabCtrl.activeRegister + 1; - LOG_DEBUG("showActiveView, active view = ", selectedViewTabId); - - navConfigSetSelectedElement(datapointPath); - dyn_string panelParameters = makeDynString("$datapoint:" + datapointPath); - - // get tab properties - dyn_string views = navConfigGetViews(dpViewConfig); - - for (int tabId = 1; tabId <= dynlen(views); tabId++) - { - if (tabId != selectedViewTabId) - { - // load empty panel in non-visible tabs to enhance performance - tabCtrl.registerPanel(tabId - 1, viewsPath + "nopanel.pnl", makeDynString("")); - } - else - { - if (dpAccessable(views[selectedViewTabId])) - { - tabCtrl.registerPanel(selectedViewTabId - 1, gNavigatorTabFile, panelParameters); - } - else - { - LOG_TRACE("showActiveView", "tab reference not found; making tab invisible: ", selectedViewTabId); - tabCtrl.registerVisible(selectedViewTabId - 1) = FALSE; - } - } - } -} - - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: getNodeFromDatapoint -// -// returns the nodeid in the treeview of the corresponding datapoint -/////////////////////////////////////////////////////////////////////////// -long getNodeFromDatapoint(string dpe) -{ - long nodeId = 0; - - //string datapointName = dpSubStr(dpe, DPSUB_SYS_DP_EL); Origiganel - string datapointName = getSystemName(getSystemId()) + dpe; //New AdB 18-3-2005 - LOG_TRACE("getNodeFromDatapoint: searching for: ", dpe, datapointName); - if (mappingHasKey(g_datapoint2itemID, datapointName)) - { - nodeId = g_datapoint2itemID[datapointName]; - } - LOG_TRACE("found??? nodeId= ", nodeId); - return nodeId; -} - -/////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////// -// -// Action handlers -// -/////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: Navigator_HandleEventInitialize() -// -// initializes the navigator -/////////////////////////////////////////////////////////////////////////// -void Navigator_HandleEventInitialize() -{ - LOG_TRACE("Navigator_HandleEventInitialize()", ""); - - // before the first thing, we check the sanity of the configuration - string sanityMessage; - - // Set the global variable: gNavigatorTabFile - gNavigatorTabFile = navGetViewsPath() + "navigator_tab.pnl"; - - if (!navConfigSanityCheck(sanityMessage)) - { - gcfUtilMessageWarning("Sanity check failed", sanityMessage); - } - - // first thing to do: get a new navigator ID - // check the commandline parameter: - int navID = 0; - if (isDollarDefined("$ID")) - navID = $ID; - navConfigSetNavigatorID(navID); - navConfigIncreaseUseCount(); - navConfigSubscribeUpdateTrigger("Navigator_HandleUpdateTrigger"); - - navPMLinitialize(); - - g_initializing = true; - - setActiveXSupported(); - LOG_TRACE("ActiveXSupported global variable set to ", ActiveXSupported()); - - // show the ActiveX tree control if it can be created - shape treeActiveX = getShape(ACTIVEX_TREE_CTRL_NAME); - shape treeList = getShape(LIST_TREE_CTRL_NAME); - if (ActiveXSupported()) - { - treeActiveX.visible = TRUE; - treeList.visible = FALSE; - } - else - { - treeActiveX.visible = FALSE; - treeList.visible = TRUE; - } - - // manually control the initialization of the tree and tabviews - InitializeTabViews(); - //initTree(); //cannot do it here because tree will not be visible initially, only after double click. Strange but true - - delay(STARTUP_DELAY); // wait for the tree control to complete initialization - g_initializing = false; - - - // configure the tabs - long selectedNode = getSelectedNode(); - if (selectedNode != 0) - { - string datapointPath = buildPathFromNode(selectedNode); - string dpViewConfig = navConfigGetViewConfig(datapointPath); - if (selectedNode != 0 && dpAccessable(dpViewConfig)) - { - showView(dpViewConfig, datapointPath); - } - } - - LOG_DEBUG("~Navigator_HandleEventInitialize()"); -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: Navigator_HandleEventTerminate() -// -// NOTE: it is NOT possible to call dpGet in the terminate handler! -/////////////////////////////////////////////////////////////////////////// -void Navigator_HandleEventTerminate() -{ - LOG_DEBUG("Navigator_HandleEventTerminate()"); -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: Navigator_HandleEventClose() -// -// de-initializes the navigator -// NOTE: it is NOT possible to call dpGet in the terminate handler! -/////////////////////////////////////////////////////////////////////////// -void Navigator_HandleEventClose() -{ - LOG_DEBUG("Navigator_HandleEventClose()"); - - navPMLterminate(); - - navConfigDecreaseUseCount(); - - PanelOff(); -} - - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: TabViews_HandleEventInitialize() -// -// initializes the tabview -/////////////////////////////////////////////////////////////////////////// -void TabViews_HandleEventInitialize() -{ - // the initialization of the main panel initializes the tabviews - // nothing should be done here -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: InitializeTabViews() -// -// initializes the tabview -/////////////////////////////////////////////////////////////////////////// -void InitializeTabViews() -{ - LOG_DEBUG("InitializeTabViews()"); - shape tabCtrl = getTabCtrl(); - // hide all tabs - int i = 0; - dyn_errClass err; - int setValueResult; - do - { - setValueResult = setValue(getTabCtrlName(), "registerVisible", i, FALSE); - err = getLastError(); - LOG_TRACE("registerVisible", i, setValueResult, err); - i++; - } while(dynlen(err) == 0 && i < NR_OF_VIEWS && setValueResult == 0); - LOG_DEBUG("~InitializeTabViews()"); -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: TabViews_HandleEventSelectionChanged -// -// stores the selected tab number in the database -/////////////////////////////////////////////////////////////////////////// -void TabViews_HandleEventSelectionChanged() -{ - if (!g_initializing) - { - LOG_DEBUG("TabViews_HandleEventSelectionChanged"); - - shape tabCtrl = getTabCtrl(); - long selectedNode = getSelectedNode(); - if (selectedNode != 0) - { - string datapointPath = buildPathFromNode(selectedNode); - dyn_string reference; - bool dpIsReference; - checkForReference(datapointPath, reference, dpIsReference); - navConfigSetSelectedView(datapointPath, tabCtrl.activeRegister + 1); - - string dpViewConfig = navConfigGetViewConfig(datapointPath); - if (selectedNode != 0 && dpAccessable(dpViewConfig)) - { - showActiveView(dpViewConfig, datapointPath); - } - } - } - else - { - LOG_DEBUG("TabViews_HandleEventSelectionChanged suppressed while initializing"); - } -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: checkForReferenceRemoveFromList -// -// Params: datapointPath - deletes al related references form the -// g_referenceList -// -// returns - none -/////////////////////////////////////////////////////////////////////////// -void checkForReferenceRemoveFromList(string datapointPath) -{ - dyn_string refOut; - - for (int i = dynlen(g_referenceList); i >= 1; i--) - { - refOut = strsplit(g_referenceList[i], "="); - if (patternMatch(datapointPath + "*", refOut[1]) && !(datapointPath == refOut[1])) - { - dynRemove(g_referenceList, i); - } - } -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: TreeCtrl_HandleEventOnDrawCell -// -// draws icons in columns if needed -/////////////////////////////////////////////////////////////////////////// -void TreeCtrl_HandleEventOnDrawCell(long Col, long Row, float Left, float Top, float Right, float Bottom) -{ - if (!g_initializing) - { - if (ActiveXSupported()) - { - shape treeCtrl = getTreeCtrl(); - if (Row >= treeCtrl.FixedRows) - { - if (Col == 0) - { - idispatch aNode; - aNode = treeCtrl.GetNodeAt(Left, Top); - if (aNode != 0) - { - if (aNode.Data != 0) - { - if (aNode.Data == "A" && (treeCtrl.ImagesWidth < (Right - Left))) - { - LOG_TRACE("data is A and image fits", aNode.Data, treeCtrl.ImagesWidth, Right, Left); - int aLeft, aRight; - aLeft = Left + (Right - Left - treeCtrl.ImagesWidth) / 2; - aRight = aLeft + treeCtrl.ImagesWidth; - treeCtrl.DrawImage(1, aLeft, Top, aRight, Bottom); - } - } - } - } - } - } - } -} - -/////////////////////////////////////////////////////////////////////////// -//ButtonMaximize_HandleEventClick() -// -// maximizes the current subview -/////////////////////////////////////////////////////////////////////////// -void ButtonMaximize_HandleEventClick() -{ - LOG_DEBUG("ButtonMaximize_HandleEventClick"); - dyn_errClass err; - shape tabCtrl = getTabCtrl(); - long Node = getSelectedNode(); - if (Node != 0) - { - string datapointPath = buildPathFromNode(Node); - string dpViewConfig = navConfigGetViewConfig(datapointPath); - LOG_TRACE("ButtonMaximize_HandleEventClick", Node, dpViewConfig); - if (Node != 0 && dpAccessable(dpViewConfig)) - { - int selectedView; - int selectedSubView; - dyn_string views; - dyn_int nrOfSubViews; - dyn_string subViews; - dyn_string configs; - - if (navConfigGetViewConfigElements(dpViewConfig, - selectedView, - selectedSubView, - views, - nrOfSubViews, - subViews, - configs)) - { - LOG_TRACE("viewConfig:", selectedView, selectedSubView, views, nrOfSubViews, subViews, configs); - - if (selectedView > 0 && selectedSubView > 0) - { - // create the mapping - int beginSubViews = 1; - for (int i = 1; i < selectedView; i++) - { - beginSubViews += nrOfSubViews[i]; - } - // get subviews config - string subViewCaption; - string subViewFileName; - if (navConfigGetSubViewConfigElements(subViews[beginSubViews + selectedSubView - 1], subViewCaption, subViewFileName)) - { - string viewsPath = navGetViewsPath(); - LOG_DEBUG("subviewcaption, subviewfilename:", subViewCaption, viewsPath + subViewFileName); - - string dpNameTemp = datapointPath; - bool isReference; - dyn_string reference; - string referenceDatapoint = ""; - checkForReference(dpNameTemp, reference, isReference); - - if (isReference) - { - referenceDatapoint = datapointPath; - } - dyn_string panelParameters = makeDynString( - "$datapoint:" + dpNameTemp, - "$configDatapoint:" + configs[beginSubViews + selectedSubView - 1], - "$referenceDatapoint:" + referenceDatapoint); - ModuleOnWithPanel(dpNameTemp, -1, -1, 0, 0, 1, 1, "", viewsPath + subViewFileName, subViewCaption, panelParameters); - } - } - } - } - } -} - - - - - - - - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: SplitDatapointPath -// -// returns the datapointPath in a dyn_string -/////////////////////////////////////////////////////////////////////////// -dyn_string splitDatapointPath(string newDatapoint) -{ - int i; - dyn_string datapointElement; - dyn_string datapointPath= strsplit(newDatapoint, "_"); - string datapointName = datapointPath[1]; - // cut system name myself. Necessary for datapoint parts that are not datapoints themselves - int sepPos = strpos(datapointName, ":"); - if (sepPos >= 0) - { - datapointName = substr(datapointName, sepPos + 1); - } - datapointPath[1] = datapointName; - - // if datapointElement present, split last entry of datapointPath - datapointElement = strsplit(datapointPath[dynlen(datapointPath)], "."); - if (dynlen(datapointElement) > 1) - { - datapointPath[dynlen(datapointPath) ] = datapointElement[1]; - datapointPath[dynlen(datapointPath) + 1] = datapointElement[2]; - } - return datapointPath; -} - - diff --git a/MAC/Navigator/scripts/libs/nav_fw/nav-view.ctl b/MAC/Navigator/scripts/libs/nav_fw/nav-view.ctl deleted file mode 100644 index b81f45ceffd97caa8bad70a51571c98fadd60074..0000000000000000000000000000000000000000 --- a/MAC/Navigator/scripts/libs/nav_fw/nav-view.ctl +++ /dev/null @@ -1,783 +0,0 @@ -//# nav-com.ctl -//# -//# Copyright (C) 2002-2004 -//# ASTRON (Netherlands Foundation for Research in Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl -//# -//# This program is free software; you can redistribute it and/or modify -//# it under the terms of the GNU General Public License as published by -//# the Free Software Foundation; either version 2 of the License, or -//# (at your option) any later version. -//# -//# This program is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License -//# along with this program; if not, write to the Free Software -//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//# -//# $Id$ - -//# -//# global functions for the Navigator. All event handlers are implemented here -//# - -global string TAB_VIEWS_CTRL_NAME = "TabViews"; -global int NR_OF_VIEWS = 10; - -////////////////////////////////////////////////////////////////////////////////// -// FunctionName: -// -// Params: -// Returns: -////////////////////////////////////////////////////////////////////////////////// - -// -------------------------- HANDLERS ------------------------------------------- - -// -------------------------- PUBLIC METHODS ------------------------------------- - - - -// -------------------------- PRIVATE METHODS ------------------------------------ -/////////////////////////////////////////////////////////////////////////// -// FunctionName: showView(string datapointPath) -// -// shows the tab identified by the datapoint -/////////////////////////////////////////////////////////////////////////// -void showView(string dpViewConfig, string datapointPath) -{ - LOG_DEBUG("showView", dpViewConfig, datapointPath); - shape tabCtrl = getTabCtrl(); - string viewsPath = navGetViewsPath(); - int selectedViewTabId = 1; - int tabId; - - navConfigSetSelectedElement(datapointPath); - dyn_string panelParameters = makeDynString("$datapoint:" + datapointPath); - // get the selected tab - string selectedViewCaption = navConfigGetSelectedView(); - LOG_DEBUG("showView", "selected View:", selectedViewCaption); - - // get tab properties - dyn_string views = navConfigGetViews(dpViewConfig); - - // At first find the selected tabview, and replace the current registerPanel - // by an empty panel. So the panel doesn't blink any more. - for (tabId = 1; tabId <= dynlen(views); tabId++) - { - if (dpAccessable(views[tabId])) - { - string caption = navConfigGetViewCaption(views[tabId]); - if (strlen(caption) > 0) - { - if (caption == selectedViewCaption) - { - tabCtrl.registerPanel(tabId - 1, viewsPath + "nopanel.pnl", makeDynString("")); - } - } - } - } - - //Now arrange the other tabs - for (tabId = 1; tabId <= dynlen(views); tabId++) - { - if (dpAccessable(views[tabId])) - { - string caption = navConfigGetViewCaption(views[tabId]); - if (strlen(caption) > 0) - { - LOG_DEBUG("showView", "making tab visible: ", tabId, caption); - tabCtrl.namedColumnHeader("tab" + tabId) = caption; - tabCtrl.registerVisible(tabId - 1) = TRUE; - - // check if this tab is currently selected - if (caption == selectedViewCaption) - { - LOG_DEBUG("showView", "caption=selectedViewCaption"); - - selectedViewTabId = tabId; - //bring this option outside this loop next line is new - //tabCtrl.registerPanel(tabId - 1, gNavigatorTabFile, panelParameters); - } - } - else - { - LOG_TRACE("showView", "empty caption or filename; making tab invisible: ", tabId); - tabCtrl.registerVisible(tabId - 1) = FALSE; - } - } - else - { - LOG_TRACE("showView", "tab reference not found; making tab invisible: ", tabId); - tabCtrl.registerVisible(tabId - 1) = FALSE; - } - //delay(1, 0); - } - - //NOW display the selected tabview, after the tabs are filled and ready - tabCtrl.registerPanel(selectedViewTabId - 1, gNavigatorTabFile, panelParameters); - - // check if this tab is currently selected - if (selectedViewCaption == "") - { - LOG_DEBUG("showView", "selectedViewCaption=\"\""); - selectedViewTabId = 1; - tabCtrl.registerPanel(0, gNavigatorTabFile, panelParameters); - } - tabCtrl.activeRegister = selectedViewTabId - 1; - - // make the rest of the views invisible - int i; - - for (i = tabId; i <= NR_OF_VIEWS; i++) - { - LOG_TRACE("showView", "tab undefined; making tab invisible: ", i); - tabCtrl.registerVisible(i - 1) = FALSE; - } - -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: showActiveView(string datapointPath) -// -// shows the active tab identified by the datapoint -/////////////////////////////////////////////////////////////////////////// -void showActiveView(string dpViewConfig, string datapointPath) -{ - LOG_DEBUG("showActiveView", dpViewConfig, datapointPath); - shape tabCtrl = getTabCtrl(); - string viewsPath = navComGetViewsPath(); - int selectedViewTabId = tabCtrl.activeRegister + 1; - LOG_DEBUG("showActiveView, active view = ", selectedViewTabId); - - navConfigSetSelectedElement(datapointPath); - dyn_string panelParameters = makeDynString("$datapoint:" + datapointPath); - - // get tab properties - dyn_string views = navConfigGetViews(dpViewConfig); - - for (int tabId = 1; tabId <= dynlen(views); tabId++) - { - if (tabId != selectedViewTabId) - { - // load empty panel in non-visible tabs to enhance performance - tabCtrl.registerPanel(tabId - 1, viewsPath + "nopanel.pnl", makeDynString("")); - } - else - { - if (dpAccessable(views[selectedViewTabId])) - { - tabCtrl.registerPanel(selectedViewTabId - 1, gNavigatorTabFile, panelParameters); - } - else - { - LOG_TRACE("showActiveView", "tab reference not found; making tab invisible: ", selectedViewTabId); - tabCtrl.registerVisible(selectedViewTabId - 1) = FALSE; - } - } - } -} - - -/////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////// -// -// Action handlers -// -/////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////// - - - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: TabViews_HandleEventInitialize() -// -// initializes the tabview -/////////////////////////////////////////////////////////////////////////// -void TabViews_HandleEventInitialize() -{ - // the initialization of the main panel initializes the tabviews - // nothing should be done here -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: InitializeTabViews() -// -// initializes the tabview -/////////////////////////////////////////////////////////////////////////// -void InitializeTabViews() -{ - LOG_DEBUG("InitializeTabViews()"); - shape tabCtrl = getTabCtrl(); - // hide all tabs - int i = 0; - dyn_errClass err; - int setValueResult; - do - { - setValueResult = setValue(getTabCtrlName(), "registerVisible", i, FALSE); - err = getLastError(); - LOG_TRACE("registerVisible", i, setValueResult, err); - i++; - } while(dynlen(err) == 0 && i < NR_OF_VIEWS && setValueResult == 0); - LOG_DEBUG("~InitializeTabViews()"); -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: TabViews_HandleEventSelectionChanged -// -// stores the selected tab number in the database -/////////////////////////////////////////////////////////////////////////// -void TabViews_HandleEventSelectionChanged() -{ - if (!g_initializing) - { - LOG_DEBUG("TabViews_HandleEventSelectionChanged"); - - shape tabCtrl = getTabCtrl(); - long selectedNode = getSelectedNode(); - if (selectedNode != 0) - { - string datapointPath = buildPathFromNode(selectedNode); - dyn_string reference; - bool dpIsReference; - checkForReference(datapointPath, reference, dpIsReference); - navConfigSetSelectedView(datapointPath, tabCtrl.activeRegister + 1); - - string dpViewConfig = navConfigGetViewConfig(datapointPath); - if (selectedNode != 0 && dpAccessable(dpViewConfig)) - { - showActiveView(dpViewConfig, datapointPath); - } - } - } - else - { - LOG_DEBUG("TabViews_HandleEventSelectionChanged suppressed while initializing"); - } -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: TreeCtrl_EventOnSelChange(long Node) -// -// initializes the Resources treeview -// TODO: optimize for selection change to the same resource type. Then don't reconfigure the tabs -/////////////////////////////////////////////////////////////////////////// -void TreeCtrl_HandleEventOnSelChange(long Node) -{ - if (gCurSelTreeViewIdx != Node) - { - gCurSelTreeViewIdx = Node; - refreshNavigator(); - } -} - - -/////////////////////////////////////////////////////////////////////////// -// TreeView_OnCollapse -// -// called when an item is expanded -/////////////////////////////////////////////////////////////////////////// -TreeView_OnCollapse(unsigned pos) -{ - LOG_DEBUG("TreeView_OnCollapse", pos); - TreeCtrl_HandleEventOnCollapse(pos); - - // the last line of code of each treeView event handler MUST be the following: - id = -1; -} - - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: TreeCtrl_HandleEventOnCollapse(long Node) -// -// expands a node in the Resources treeview -/////////////////////////////////////////////////////////////////////////// -void TreeCtrl_HandleEventOnCollapse(unsigned Node) -{ - int collapsedNodes = 1; - dyn_string datapoint; - int k = 1; - string temp; - - treeView_pruneChildren(Node, collapsedNodes, ""); //get all nodes which will be collapsed and - //clear these nodes from the tree - //retrieve all dpnames for these nodes - for (int j = Node + 1; j <= (Node + collapsedNodes); j++) - { - datapoint[k]= g_itemID2datapoint[j]; - k++; - } - - //delete the collapse nodes from g_itemID2datapoint and g_datapoint2itemID - for (int i = 1; i <= dynlen(datapoint); i++) - { - long nodeID = getNodeFromDatapoint(datapoint[i]); - dynRemove(g_itemID2datapoint, dynContains(g_itemID2datapoint, datapoint[i])); - mappingRemove(g_datapoint2itemID, datapoint[i]); - } - - //renumber the mapping of the dp's - if (mappinglen(g_datapoint2itemID) > 1) - { - for (int i = 1; i <= mappinglen(g_datapoint2itemID); i++) - { - temp = g_itemID2datapoint[i]; - if (temp != "" && temp != 0) - { - g_datapoint2itemID[temp] = i; - } - } - } - //Delete references in g_referenceList for the related node - string datapointPath = buildPathFromNode(Node); - checkForReferenceRemoveFromList(datapointPath); - - //mark the node as COLLAPSED - dyn_anytype parentNode; - parentNode = treeView_getNode(Node, ""); - parentNode[treeView_STATE] = parentNode[treeView_STATE] & ~treeView_EXPANDED; - treeView_replaceNode(parentNode, Node, ""); - treeView_draw(); -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: checkForReferenceRemoveFromList -// -// Params: datapointPath - deletes al related references form the -// g_referenceList -// -// returns - none -/////////////////////////////////////////////////////////////////////////// -void checkForReferenceRemoveFromList(string datapointPath) -{ - dyn_string refOut; - - for (int i = dynlen(g_referenceList); i >= 1; i--) - { - refOut = strsplit(g_referenceList[i], "="); - if (patternMatch(datapointPath + "*", refOut[1]) && !(datapointPath == refOut[1])) - { - dynRemove(g_referenceList, i); - } - } -} - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: TreeCtrl_HandleEventOnDrawCell -// -// draws icons in columns if needed -/////////////////////////////////////////////////////////////////////////// -void TreeCtrl_HandleEventOnDrawCell(long Col, long Row, float Left, float Top, float Right, float Bottom) -{ - if (!g_initializing) - { - if (ActiveXSupported()) - { - shape treeCtrl = getTreeCtrl(); - if (Row >= treeCtrl.FixedRows) - { - if (Col == 0) - { - idispatch aNode; - aNode = treeCtrl.GetNodeAt(Left, Top); - if (aNode != 0) - { - if (aNode.Data != 0) - { - if (aNode.Data == "A" && (treeCtrl.ImagesWidth < (Right - Left))) - { - LOG_TRACE("data is A and image fits", aNode.Data, treeCtrl.ImagesWidth, Right, Left); - int aLeft, aRight; - aLeft = Left + (Right - Left - treeCtrl.ImagesWidth) / 2; - aRight = aLeft + treeCtrl.ImagesWidth; - treeCtrl.DrawImage(1, aLeft, Top, aRight, Bottom); - } - } - } - } - } - } - } -} - -/////////////////////////////////////////////////////////////////////////// -//ButtonMaximize_HandleEventClick() -// -// maximizes the current subview -/////////////////////////////////////////////////////////////////////////// -void ButtonMaximize_HandleEventClick() -{ - LOG_DEBUG("ButtonMaximize_HandleEventClick"); - dyn_errClass err; - shape tabCtrl = getTabCtrl(); - long Node = getSelectedNode(); - if (Node != 0) - { - string datapointPath = buildPathFromNode(Node); - string dpViewConfig = navConfigGetViewConfig(datapointPath); - LOG_TRACE("ButtonMaximize_HandleEventClick", Node, dpViewConfig); - if (Node != 0 && dpAccessable(dpViewConfig)) - { - int selectedView; - int selectedSubView; - dyn_string views; - dyn_int nrOfSubViews; - dyn_string subViews; - dyn_string configs; - - if (navConfigGetViewConfigElements(dpViewConfig, - selectedView, - selectedSubView, - views, - nrOfSubViews, - subViews, - configs)) - { - LOG_TRACE("viewConfig:", selectedView, selectedSubView, views, nrOfSubViews, subViews, configs); - - if (selectedView > 0 && selectedSubView > 0) - { - // create the mapping - int beginSubViews = 1; - for (int i = 1; i < selectedView; i++) - { - beginSubViews += nrOfSubViews[i]; - } - // get subviews config - string subViewCaption; - string subViewFileName; - if (navConfigGetSubViewConfigElements(subViews[beginSubViews + selectedSubView - 1], subViewCaption, subViewFileName)) - { - string viewsPath = navComGetViewsPath(); - LOG_DEBUG("subviewcaption, subviewfilename:", subViewCaption, viewsPath + subViewFileName); - - string dpNameTemp = datapointPath; - bool isReference; - dyn_string reference; - string referenceDatapoint = ""; - checkForReference(dpNameTemp, reference, isReference); - - if (isReference) - { - referenceDatapoint = datapointPath; - } - dyn_string panelParameters = makeDynString( - "$datapoint:" + dpNameTemp, - "$configDatapoint:" + configs[beginSubViews + selectedSubView - 1], - "$referenceDatapoint:" + referenceDatapoint); - ModuleOnWithPanel(dpNameTemp, -1, -1, 0, 0, 1, 1, "", viewsPath + subViewFileName, subViewCaption, panelParameters); - } - } - } - } - } -} - - -/////////////////////////////////////////////////////////////////////////// -// TreeView_OnSelect -// -// called when an item is selected -/////////////////////////////////////////////////////////////////////////// -TreeView_OnSelect(unsigned pos) -{ - LOG_DEBUG("TreeView_OnSelect", pos); - string datapointPath = buildPathFromNode(pos); - dyn_string reference; - bool parentDatapointIsReference; - checkForReference(datapointPath, reference, parentDatapointIsReference); - - LOG_TRACE("check for expand", parentDatapointIsReference, datapointPath, dpAccessable(datapointPath)); - //Check or the access is permitted to this point in the tree - if (checkDpPermit(datapointPath) || pos == 1) - { - //check or the selected item in the tree is an dpe. If yes, use the dp name to check the existance - if (strpos(datapointPath, ".") > 0) - { - dyn_string datapointPathSplit = strsplit(datapointPath, "."); - datapointPath = datapointPathSplit[1]; - //DebugN("datapointPath after split:" + datapointPath); - } - if (!parentDatapointIsReference || (parentDatapointIsReference && dpAccessable(datapointPath + "__enabled"))) - { - TreeCtrl_HandleEventOnSelChange(pos); - } - else - { - navComMessageWarning(MESSAGE_DPACCESS); //dp not accessable - } - } - else - { - navComMessageWarning(MESSAGE_ACCESSDENIED); //access to resource denied - } - - // the last line of code of each treeView event handler MUST be the following: - id = -1; -} - - - - - - -/////////////////////////////////////////////////////////////////////////// -// FunctionName: SplitDatapointPath -// -// returns the datapointPath in a dyn_string -/////////////////////////////////////////////////////////////////////////// -dyn_string splitDatapointPath(string newDatapoint) -{ - int i; - dyn_string datapointElement; - dyn_string datapointPath= strsplit(newDatapoint, "_"); - string datapointName = datapointPath[1]; - // cut system name myself. Necessary for datapoint parts that are not datapoints themselves - int sepPos = strpos(datapointName, ":"); - if (sepPos >= 0) - { - datapointName = substr(datapointName, sepPos + 1); - } - datapointPath[1] = datapointName; - - // if datapointElement present, split last entry of datapointPath - datapointElement = strsplit(datapointPath[dynlen(datapointPath)], "."); - if (dynlen(datapointElement) > 1) - { - datapointPath[dynlen(datapointPath) ] = datapointElement[1]; - datapointPath[dynlen(datapointPath) + 1] = datapointElement[2]; - } - return datapointPath; -} - - -////////////////////////////////////////////////////////////////////////////////// -// Function: progressBar -// With this function a progress bar can be made. The progress is shown -// horizontal and is going from the left to the right. -// [0 100%] -// -//Input: 1. maximum value (range) == 100% -// 2. current value to show in the progress bar. -/////////////////////////////////////////////////////////////////////////////////// -void progressBar(float Maximum, float value) -{ - float Minimum = 0; - int waarde; - float positie; - if (value > Minimum) - { - setValue("progressBar", "visible", TRUE); - setValue("progressBar_border", "visible", TRUE); - } - - setValue("progressBar", "scale", value/Maximum, 1.0); - - if (Maximum >= value) - { - delay(0, 200); - setValue("progressBar", "visible", FALSE); - setValue("progressBar_border", "visible", FALSE); - } -} - - -dyn_string queryDatabaseForDpElements(string datapointPath) -{ - dyn_string output; - int outputCounter = 1; - dyn_string dpes = dpNames(dpSubStr(datapointPath, DPSUB_SYS_DP) + ".**;"); - int dpesLen = dynlen(dpes); - for (int j = 1; j <= dpesLen; j++) - { - if (dpElementType(dpes[j]) != DPEL_TYPEREF && dpElementType(dpes[j]) != DPEL_STRUCT) - { - output[outputCounter] = dpes[j]; - outputCounter++; - } - } - return output; -} - -/////////////////////////////////////////////////////////////////////////// -// Function queryDatabaseForDP: Query's the (distributed)database according the -// given options -// Input: 1. Datapoint name, including systemName -// 2. Attribute (E.g. "_online.._value") -// 3. Use function progressBar to display a progressBar -// -// Output: dyn_string with the resultsm exlusief the current datapointPath -/////////////////////////////////////////////////////////////////////////// -dyn_string queryDatabaseForDP(string attribute, string datapointPath, bool useProgressBar) -{ - string tempDP; - dyn_string output; - dyn_dyn_anytype tab; - string datapointPathOriginal = datapointPath; - bool dpIsReference = false; - dyn_string reference; - string REMOTESYSTEM = ""; - - checkForReference(datapointPath, reference, dpIsReference); - if (dpIsReference) - { - strreplace(datapointPath, datapointPathOriginal, reference[2]); - if (dpIsDistributed(datapointPath)) - { - REMOTESYSTEM = " REMOTE '" + strrtrim(dpSubStr(reference[2], DPSUB_SYS), ":") + "'"; - } - } - else if (dpIsDistributed(datapointPath)) - { - REMOTESYSTEM = " REMOTE '" + strrtrim(dpSubStr(datapointPath, DPSUB_SYS), ":") + "'"; - } - //DebugN("SELECT '" + attribute + "' FROM '" + datapointPath + "__enabled' " + REMOTESYSTEM); - dpQuery("SELECT '" + attribute + "' FROM '" + datapointPath + "__enabled' " + REMOTESYSTEM, tab); - int maximumCount = dynlen(tab); - for (int i = 2; i <= dynlen(tab); i++) - { - tempDP = tab[i][1]; - if (tempDP != "") - { - strreplace(tempDP, "__enabled.", ""); - if (checkDpPermit(tempDP)) - { - if (tempDP != "") - { - dynAppend(output, tempDP); - } - } - } - if (useProgressBar) - progressBar(maximumCount, i); - } - if (useProgressBar) - progressBar(maximumCount, maximumCount); - dynSortAsc(output); //sort the dyn_string output (alphanumeric) - return output; -} - -/////////////////////////////////////////////////////////////////////////// -// Function queryDatabase: Query's the (distributed)database according the -// given options -// -// Input: 1. Attribute (E.g. "_online.._value") -// 2. Datapoint name, including systemName -// 3. How many first items must be retrieved via the query!!! -// 4. Search depth (relative, from current position) -// 5. Use function progressBar to display a progressBar -// -// Output: dyn_string with the resultsm exlusief the current datapointPath -// -/////////////////////////////////////////////////////////////////////////// -dyn_string queryDatabase(string attribute, string datapointPath, int first, int searchDepth, bool useProgressBar) -{ - dyn_string output; - dyn_dyn_anytype tab; - string fullDpName; - int currentDepth = dynlen(strsplit(datapointPath, "_")); - dyn_dyn_string elementNames; - dyn_dyn_int elementTypes; - string datapointPathOriginal = datapointPath; - int elementIndex; - int outputCounter = 1; - bool dpIsReference = false; - dyn_string reference; - string REMOTESYSTEM = ""; - string firstXResults = ""; - - checkForReference(datapointPath, reference, dpIsReference); - if (dpIsReference) - { - //strreplace(datapointPath, datapointPathOriginal, reference[2]); - if (dpIsDistributed(datapointPath)) - { - REMOTESYSTEM = " REMOTE '" + strrtrim(dpSubStr(reference[2], DPSUB_SYS), ":") + "'"; - } - } - //How many items must be retrieved (this __enabled and this is a DP-Type) - if (first > 0) - { - firstXResults = " FIRST " + first; - } - dpQuery("SELECT '" + attribute + "' FROM '" + datapointPath + "__enabled' " + firstXResults + REMOTESYSTEM, tab); - int maximumCount = dynlen(tab); - int maximumCounter = 0; - int i = 2; - if (dynlen(tab) >= 2) - { - dyn_dyn_string dds; - string fullDpName; - int curDPTElevel = 2; - int elType, elNTypesItemLen; - dyn_string levels; - for (i = 2; i <= dynlen(tab); i++) - { - int functionOk; - fullDpName = tab[i][1]; - strreplace(fullDpName, "__enabled.", ""); - - if ((dynlen(strsplit(fullDpName, "_")) <= (currentDepth + searchDepth)) || (searchDepth == 0)) - { - dyn_string dpes = dpNames(fullDpName + ".**;"); - int dpesLen = dynlen(dpes); - for (int j = 1; j <= dpesLen; j++) - { - if (dpElementType(dpes[j]) != DPEL_TYPEREF && dpElementType(dpes[j]) != DPEL_STRUCT) - { - output[outputCounter] = dpes[j]; - outputCounter++; - } - } - } - maximumCounter++; - //if the progressBar must be used - if (useProgressBar) - { - progressBar(maximumCount, maximumCounter); - } - }//end of for loop - }//end of if - //Hide the progress bar - if (useProgressBar) - { - progressBar(maximumCount, maximumCount); - } - dynSortAsc(output); //sort the dyn_string output (alphanumeric) - return output; -} - - -////////////////////////////////////////////////////////////////////////////////// -// FunctionName: navConfigCheckResourceRoots, used to check the current systemname -// and fill GCFNavigator resourceroots with the present Systemname -// -/////////////////////////////////////////////////////////////////////////////////// - -void navConfigCheckResourceRoots() -{ - dyn_string roots; - dpGet(DPNAME_NAVIGATOR + "." + ELNAME_PROPSETFILTERS, roots); - string aSystemName = getSystemName(); - strreplace(aSystemName, ':', ""); - bool replaced = false; - - for (int i = 1; i <= dynlen(roots); i++) - { - dyn_string aS = strsplit(roots[i], ':'); - if (aS[1] != aSystemName) - { - strreplace(roots[i], aS[1], aSystemName); - replaced = true; - } - } - - if (replaced) - { - dpSet(DPNAME_NAVIGATOR + ELNAME_PROPSETFILTERS, roots); - } -} -