~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/clients/qmon/qmon_browser.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*___INFO__MARK_BEGIN__*/
 
2
/*************************************************************************
 
3
 * 
 
4
 *  The Contents of this file are made available subject to the terms of
 
5
 *  the Sun Industry Standards Source License Version 1.2
 
6
 * 
 
7
 *  Sun Microsystems Inc., March, 2001
 
8
 * 
 
9
 * 
 
10
 *  Sun Industry Standards Source License Version 1.2
 
11
 *  =================================================
 
12
 *  The contents of this file are subject to the Sun Industry Standards
 
13
 *  Source License Version 1.2 (the "License"); You may not use this file
 
14
 *  except in compliance with the License. You may obtain a copy of the
 
15
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
16
 * 
 
17
 *  Software provided under this License is provided on an "AS IS" basis,
 
18
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
19
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
20
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
21
 *  See the License for the specific provisions governing your rights and
 
22
 *  obligations concerning the Software.
 
23
 * 
 
24
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
25
 * 
 
26
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
27
 * 
 
28
 *   All Rights Reserved.
 
29
 * 
 
30
 ************************************************************************/
 
31
/*___INFO__MARK_END__*/
 
32
#include <X11/Xos.h>
 
33
 
 
34
#include <Xm/Xm.h>
 
35
#if XmVersion <= 1001
 
36
#include <Xm/MwmUtil.h>
 
37
#endif
 
38
 
 
39
#include <Xmt/Xmt.h>
 
40
#include <Xmt/Cli.h>
 
41
#include <Xmt/Icon.h>
 
42
#include <Xmt/Create.h>
 
43
#include <Xmt/Chooser.h>
 
44
#include <Xmt/Dialogs.h>
 
45
 
 
46
#include "qmon_proto.h"
 
47
#include "qmon_rmon.h"
 
48
 
 
49
#include "sge.h"
 
50
#include "basis_types.h"
 
51
#include "sge_prog.h"
 
52
#include "qmon_util.h"
 
53
#include "qmon_browser.h"
 
54
#include "qmon_globals.h"
 
55
#include "qmon_init.h"
 
56
#include "qmon_file.h"
 
57
#include "qmon_message.h"
 
58
 
 
59
#include "gdi/sge_gdi.h"
 
60
#include "gdi/sge_gdi_ctx.h"
 
61
 
 
62
extern sge_gdi_ctx_class_t *ctx;
 
63
 
 
64
static int BrowserState = 0;
 
65
static Widget BrowserShell = 0;
 
66
static Widget browser_object = 0;
 
67
 
 
68
/*-------------------------------------------------------------------------*/
 
69
static Widget qmonBrowserCreateDialog(Widget parent, char *title);
 
70
static void qmonBrowserClose(Widget w, XtPointer cld, XtPointer cad);
 
71
static void qmonBrowserClear(Widget w, XtPointer cld, XtPointer cad);
 
72
static void qmonBrowserSetState(Widget w, XtPointer cld, XtPointer cad);
 
73
/*-------------------------------------------------------------------------*/
 
74
 
 
75
/*-------------------------------------------------------------------------*/
 
76
/* PUBLIC FUNCTIONS                                                       */
 
77
/*-------------------------------------------------------------------------*/
 
78
   
 
79
/*-------------------------------------------------------------------------*/
 
80
void qmonBrowserOpen(Widget w, XtPointer cld, XtPointer cad)
 
81
{
 
82
   
 
83
   DENTER(TOP_LAYER, "qmonBrowserOpen");
 
84
 
 
85
   /* set busy cursor */
 
86
   XmtDisplayBusyCursor(w);
 
87
 
 
88
   if (!BrowserShell) {
 
89
      BrowserShell = qmonBrowserCreateDialog(AppShell, "Qmon Object Browser");
 
90
      /* 
 
91
      ** set the close button callback 
 
92
      ** set the icon and iconName
 
93
      */
 
94
      XmtCreatePixmapIcon(BrowserShell, qmonGetIcon("toolbar_browser"), None);
 
95
      XtVaSetValues(BrowserShell, XtNiconName, "qmon:Browser", NULL);
 
96
      XmtAddDeleteCallback(BrowserShell, XmDO_NOTHING, qmonBrowserClose,  NULL);
 
97
 
 
98
   } 
 
99
 
 
100
   xmui_manage(BrowserShell);
 
101
 
 
102
   /* set default cursor */
 
103
   XmtDisplayDefaultCursor(w);
 
104
 
 
105
   DEXIT;
 
106
 
 
107
}
 
108
 
 
109
 
 
110
 
 
111
/*-------------------------------------------------------------------------*/
 
112
void qmonBrowserShow(
 
113
StringConst s 
 
114
) {
 
115
   Widget browser;
 
116
   
 
117
   DENTER(GUI_LAYER, "qmonBrowserShow");
 
118
 
 
119
   if (!BrowserShell) {
 
120
      DEXIT;
 
121
      return;
 
122
   }
 
123
      
 
124
   browser = XmtNameToWidget(BrowserShell, "*browser");   
 
125
   if (s) {
 
126
      XmtCliPuts(s, browser);
 
127
      XmtCliFlush(browser);
 
128
   }   
 
129
 
 
130
   /*    XBell(XtDisplay(browser), 0); */
 
131
 
 
132
   DEXIT;
 
133
}
 
134
 
 
135
/*-------------------------------------------------------------------------*/
 
136
Boolean qmonBrowserObjectEnabled(
 
137
int obj_id 
 
138
) {
 
139
   return ((BrowserState & obj_id) == obj_id);    
 
140
}
 
141
 
 
142
/*-------------------------------------------------------------------------*/
 
143
void qmonBrowserMessages(Widget w, XtPointer cld, XtPointer cad)
 
144
{
 
145
   char *host = (char*)cld;
 
146
   char filename[SGE_PATH_MAX];
 
147
   lList *alp = NULL;
 
148
   const char *default_cell = ctx->get_default_cell(ctx);
 
149
 
 
150
   DENTER(GUI_LAYER, "qmonBrowserMessages");
 
151
 
 
152
   /*
 
153
   ** get the path to the messages file
 
154
   */
 
155
   sprintf(filename, "%s/%s/spool/", SGE_ROOT, default_cell);
 
156
 
 
157
   if (!host || !strcmp(host , "global"))
 
158
      strcat(filename, "qmaster");
 
159
   else
 
160
      strcat(filename, host);
 
161
   strcat(filename, "/");
 
162
   strcat(filename, ERR_FILE);
 
163
 
 
164
   alp = qmonReadFile(filename);
 
165
   qmonMessageBox(w, alp, 0);
 
166
   lFreeList(&alp);
 
167
   
 
168
   DEXIT;
 
169
}
 
170
 
 
171
/*-------------------------------------------------------------------------*/
 
172
/* PRIVATE FUNCTIONS                                                       */
 
173
/*-------------------------------------------------------------------------*/
 
174
 
 
175
 
 
176
/*-------------------------------------------------------------------------*/
 
177
static Widget qmonBrowserCreateDialog(
 
178
Widget parent,
 
179
char *title 
 
180
) {
 
181
   
 
182
   Widget browser_shell, browser, browser_close, browser_clear,
 
183
          browser_main_link;
 
184
   
 
185
   DENTER(TOP_LAYER, "qmonBrowserCreateDialog");
 
186
 
 
187
   browser_shell = XmtBuildQueryToplevel(parent, "browser_shell",
 
188
                            "browser_object", &browser_object,
 
189
                            "browser", &browser,
 
190
                            "browser_close", &browser_close,
 
191
                            "browser_clear", &browser_clear,
 
192
                            "browser_main_link", &browser_main_link,
 
193
                            NULL);
 
194
 
 
195
   /* set iconName */
 
196
   XtVaSetValues( browser_shell, 
 
197
/*                   XmNtitle, title, */
 
198
                  XmNallowShellResize, True,
 
199
                  NULL);
 
200
   
 
201
   /* attach callbacks */
 
202
   XtAddCallback(browser_main_link, XmNactivateCallback, 
 
203
                        qmonMainControlRaise, NULL); 
 
204
   XtAddCallback(browser_object, XmtNvalueChangedCallback, 
 
205
                        qmonBrowserSetState, (XtPointer) browser); 
 
206
   XtAddCallback(browser_close, XmNactivateCallback, 
 
207
                        qmonBrowserClose, NULL); 
 
208
   XtAddCallback(browser_clear, XmNactivateCallback, 
 
209
                        qmonBrowserClear, (XtPointer) browser);
 
210
   
 
211
   DEXIT;
 
212
   return browser_shell;
 
213
}
 
214
 
 
215
/*-------------------------------------------------------------------------*/
 
216
static void qmonBrowserClose(Widget w, XtPointer cld, XtPointer cad)
 
217
{
 
218
   
 
219
   DENTER(TOP_LAYER, "qmonBrowserClose");
 
220
 
 
221
   /* disable browsing */
 
222
   XmtChooserSetState(browser_object, 0, True);
 
223
 
 
224
   xmui_unmanage(BrowserShell);
 
225
 
 
226
   DEXIT;
 
227
}
 
228
 
 
229
/*-------------------------------------------------------------------------*/
 
230
static void qmonBrowserClear(Widget w, XtPointer cld, XtPointer cad)
 
231
{
 
232
   Widget browser = (Widget) cld;
 
233
 
 
234
   DENTER(GUI_LAYER, "qmonBrowserClear");
 
235
 
 
236
   XmtCliClear(browser);
 
237
 
 
238
   DEXIT;
 
239
}
 
240
 
 
241
/*-------------------------------------------------------------------------*/
 
242
static void qmonBrowserSetState(Widget w, XtPointer cld, XtPointer cad)
 
243
{
 
244
   XmtChooserCallbackStruct *cbs = (XmtChooserCallbackStruct*) cad;
 
245
   Widget browser = (Widget) cld;
 
246
   Boolean out, err;
 
247
   
 
248
   DENTER(GUI_LAYER, "qmonBrowserSetState");
 
249
   
 
250
   BrowserState = cbs->state;
 
251
   
 
252
   if (BrowserState & BROWSE_STDOUT)
 
253
      out = True;
 
254
   else
 
255
      out = False;
 
256
      
 
257
   if (BrowserState & BROWSE_STDERR)
 
258
      err = True;
 
259
   else
 
260
      err = False;
 
261
      
 
262
   XtVaSetValues( browser, 
 
263
                  XmtNdisplayStdout, out,
 
264
                  XmtNdisplayStderr, err,
 
265
                  NULL);
 
266
   DEXIT;
 
267
}