Example #1
0
/*-------------------------------------------------------------------------*/
void qmonMatrixSelect(Widget w, XtPointer cld, XtPointer cad)
{
   XbaeMatrixSelectCellCallbackStruct *cbs = 
               (XbaeMatrixSelectCellCallbackStruct*) cad;
   int select_begin=0;
   int i;
   Widget* matrices = (Widget*) cld;

   DENTER(GUI_LAYER, "qmonMatrixSelect");

   if (cbs->params && !strcmp(cbs->params[0], "begin")) {
      XbaeMatrixDeselectAll(w);
      while (matrices && *matrices) {
         XbaeMatrixDeselectAll(*matrices);
         matrices++;
      }
      XbaeMatrixSelectRow(w, cbs->row);
   }

   if (cbs->params && !strcmp(cbs->params[0], "end")) {
      while (matrices && *matrices) {
         XbaeMatrixDeselectAll(*matrices);
         matrices++;
      }
      select_begin = XbaeMatrixFirstSelectedRow(w);
      if (select_begin == -1) {
         XbaeMatrixSelectRow(w, cbs->row);
         DEXIT;
         return;
      }
      if (cbs->row < select_begin) {
         for (i=cbs->row; i<select_begin; i++)
            XbaeMatrixSelectRow(w, i);
      }
      else {
         for (i=select_begin; i<=cbs->row; i++)
            XbaeMatrixSelectRow(w, i);
      }
   }
   if (cbs->params && !strcmp(cbs->params[0], "toggle")) {
      if (XbaeMatrixIsRowSelected(w, cbs->row)) {
         DPRINTF(("XbaeMatrixDeselectRow\n"));
         XbaeMatrixDeselectRow(w, cbs->row);
      }
      else {
         XbaeMatrixSelectRow(w, cbs->row);
         DPRINTF(("XbaeMatrixSelectRow\n"));
      }
   }

   if (cbs->params && !strcmp(cbs->params[0], "editall")) {
      XbaeMatrixEditCell(w, cbs->row, cbs->column);
   }

   if (cbs->params && !strcmp(cbs->params[0], "edit") && cbs->column != 0) {
      XbaeMatrixEditCell(w, cbs->row, cbs->column);
   }

   DEXIT;
}
Example #2
0
/***********************************************************************
 *                                                                     *
 *   When selecting a cell highlight the complete row.                 *
 *                                                                     *
 ***********************************************************************/
static void matrix_select_cb(Widget w, XtPointer cd,
                             XbaeMatrixSelectCellCallbackStruct *cbs)
{
   static int prev_row = 0;

   if (cbs->row != prev_row) {
      XbaeMatrixDeselectAll(w);
      XbaeMatrixSelectRow(w, cbs->row);

      prev_row = cbs->row;
   }
}
Example #3
0
/*-------------------------------------------------------------------------*/
static void DeleteLines(Widget w, XtPointer cld, XtPointer cad)
{
   Widget matrix = (Widget) cld;
   int rows;
   int i;
   int rows_to_delete = 0;
   int rows_old;
   int max_rows = 7;
   

   DENTER(GUI_LAYER, "DeleteLines");

   if (!matrix) {
      DEXIT;
      return;
   }

   /* max_rows = XbaeMatrixVisibleRows(matrix); */

   rows = rows_old = XbaeMatrixNumRows(matrix);

   for (i=0; i<rows; i++)
      if (XbaeMatrixIsRowSelected(matrix, i))
         rows_to_delete++;

   i = 0;
   while (i<rows) {
      if (XbaeMatrixIsRowSelected(matrix, i)) {
         XbaeMatrixDeleteRows(matrix, i, 1);
         rows--;
      }
      else
         i++;
   }

   if ((rows_old - rows_to_delete) < max_rows) 
      XbaeMatrixAddRows(matrix, rows, NULL, NULL, NULL, (max_rows - rows));

   /* reset attribute line */
   XbaeMatrixDeselectAll(matrix);

   /* refresh the matrix */
   XbaeMatrixRefresh(matrix);

   
   DEXIT;
}
/*-------------------------------------------------------------------------*/
static void qmonUserAskForProject(Widget w, XtPointer cld, XtPointer cad)
{
   XbaeMatrixLabelActivateCallbackStruct *cbs = 
                            (XbaeMatrixLabelActivateCallbackStruct *) cad;
   Boolean status = False;
   lList *pl = NULL;
   lListElem *cep = NULL;
   int n, i;
   StringConst *strs = NULL;
   static char buf[BUFSIZ];
   lList *lp = NULL;
   lList *alp = NULL;
   lListElem *ep;
   static lEnumeration *what = NULL;
   
   DENTER(GUI_LAYER, "qmonUserAskForProject");

   if (!what) {
      what = lWhat("%T(%I %I)", UU_Type, UU_name, UU_default_project);
   }

   if (cbs->column != 1) {
        DEXIT;
        return;
   }
   
   qmonMirrorMultiAnswer(PROJECT_T, &alp);
   if (alp) {
      qmonMessageBox(w, alp, 0);
      lFreeList(&alp);
      DEXIT;
      return;
   }
   pl = qmonMirrorList(SGE_PR_LIST);
   lPSortList(pl, "%I+", PR_name);
   n = lGetNumberOfElem(pl);
   if (n>0) {
      strs = (StringConst*)XtMalloc(sizeof(String)*(n+1)); 
      strs[0] = "NONE";
      for (cep=lFirst(pl), i=0; i<n; cep=lNext(cep), i++) {
        /*
        ** we get only references don't free, the strings
        */
        strs[i+1] = lGetString(cep, PR_name);
      }
    
      strcpy(buf, "");
      /* FIX_CONST_GUI */
      status = XmtAskForItem(w, NULL, "@{Select a project}",
                        "@{Available projects}", (String*)strs, n+1,
                        False, buf, BUFSIZ, NULL); 
      
      if (status) {
         int rows, i;
         rows = XbaeMatrixNumRows(user_matrix);
         for (i=0; i<rows; i++) {
            String s = XbaeMatrixGetCell(user_matrix, i, 0);
            if (XbaeMatrixIsRowSelected(user_matrix, i) && s &&
                    strcmp(s, "")) {
               ep = lAddElemStr(&lp, UU_name, s, UU_Type); 
               lSetString(ep, UU_default_project, buf);
            }
         } 
         XbaeMatrixDeselectAll(user_matrix);

         /*
         ** send to master as modify request
         */
         for_each (ep, lp) {
            if (ep && lGetString(ep, UU_default_project) && 
                !strcasecmp(lGetString(ep, UU_default_project), "NONE")) 
               lSetString(ep, UU_default_project, NULL);
         }
         if (lp) {
             alp = qmonModList(SGE_UU_LIST, 
                               qmonMirrorListRef(SGE_UU_LIST),
                               UU_name, &lp, NULL, what);
             qmonMessageBox(w, alp, 0);
             updateManopList();

             lFreeList(&alp);
             lFreeList(&lp);
         }
      }
      /*
      ** don't free referenced strings, they are in the pl list
      */
      XtFree((char*)strs);
   }
/*-------------------------------------------------------------------------*/
static void qmonManopDelete(Widget w, XtPointer cld, XtPointer cad)
{
   int type = dialog_mode;
   lList *lp = NULL;
   lList *alp = NULL;
   lEnumeration *what = NULL;
   lDescr *dp;
   int nm;
   int rows, i;
   

   DENTER(GUI_LAYER, "qmonManopDelete");

   switch (type) {
      case SGE_UM_LIST:
         lp = XmStringToCull(manager_list, UM_Type, UM_name, SELECTED_ITEMS);
         dp = UM_Type;
         nm = UM_name;
         break;
      case SGE_UO_LIST:
         lp = XmStringToCull(operator_list, UO_Type, UO_name, SELECTED_ITEMS);
         dp = UO_Type;
         nm = UO_name;
         break;

      case SGE_UU_LIST:
         rows = XbaeMatrixNumRows(user_matrix);
         for (i=0; i<rows; i++) {
            String s = XbaeMatrixGetCell(user_matrix, i, 0);
            if (XbaeMatrixIsRowSelected(user_matrix, i) && s &&
                    strcmp(s, ""))
               lAddElemStr(&lp, UU_name, s, UU_Type); 
         } 
         XbaeMatrixDeselectAll(user_matrix);
         dp = UU_Type;
         nm = UU_name;
         break;

      case SGE_US_LIST:
         qmonUsersetDelete(w, NULL, NULL);
         DEXIT;
         return;
      default:
         DEXIT;
         return;
   }
    
      
   if (lp) {
      what = lWhat("%T(ALL)", dp);
      alp = qmonDelList(type, qmonMirrorListRef(type), nm, &lp, NULL, what);

      qmonMessageBox(w, alp, 0);
   
      updateManopList();

      lFreeList(&alp);
      lFreeList(&lp);
      lFreeWhat(&what);
   } 
   
   DEXIT;
}