1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
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
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.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
36
#include <Xm/MwmUtil.h>
42
#include <Xmt/Create.h>
43
#include <Xmt/Chooser.h>
44
#include <Xmt/Dialogs.h>
46
#include "qmon_proto.h"
47
#include "qmon_rmon.h"
50
#include "basis_types.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"
59
#include "gdi/sge_gdi.h"
60
#include "gdi/sge_gdi_ctx.h"
62
extern sge_gdi_ctx_class_t *ctx;
64
static int BrowserState = 0;
65
static Widget BrowserShell = 0;
66
static Widget browser_object = 0;
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
/*-------------------------------------------------------------------------*/
75
/*-------------------------------------------------------------------------*/
76
/* PUBLIC FUNCTIONS */
77
/*-------------------------------------------------------------------------*/
79
/*-------------------------------------------------------------------------*/
80
void qmonBrowserOpen(Widget w, XtPointer cld, XtPointer cad)
83
DENTER(TOP_LAYER, "qmonBrowserOpen");
86
XmtDisplayBusyCursor(w);
89
BrowserShell = qmonBrowserCreateDialog(AppShell, "Qmon Object Browser");
91
** set the close button callback
92
** set the icon and iconName
94
XmtCreatePixmapIcon(BrowserShell, qmonGetIcon("toolbar_browser"), None);
95
XtVaSetValues(BrowserShell, XtNiconName, "qmon:Browser", NULL);
96
XmtAddDeleteCallback(BrowserShell, XmDO_NOTHING, qmonBrowserClose, NULL);
100
xmui_manage(BrowserShell);
102
/* set default cursor */
103
XmtDisplayDefaultCursor(w);
111
/*-------------------------------------------------------------------------*/
112
void qmonBrowserShow(
117
DENTER(GUI_LAYER, "qmonBrowserShow");
124
browser = XmtNameToWidget(BrowserShell, "*browser");
126
XmtCliPuts(s, browser);
127
XmtCliFlush(browser);
130
/* XBell(XtDisplay(browser), 0); */
135
/*-------------------------------------------------------------------------*/
136
Boolean qmonBrowserObjectEnabled(
139
return ((BrowserState & obj_id) == obj_id);
142
/*-------------------------------------------------------------------------*/
143
void qmonBrowserMessages(Widget w, XtPointer cld, XtPointer cad)
145
char *host = (char*)cld;
146
char filename[SGE_PATH_MAX];
148
const char *default_cell = ctx->get_default_cell(ctx);
150
DENTER(GUI_LAYER, "qmonBrowserMessages");
153
** get the path to the messages file
155
sprintf(filename, "%s/%s/spool/", SGE_ROOT, default_cell);
157
if (!host || !strcmp(host , "global"))
158
strcat(filename, "qmaster");
160
strcat(filename, host);
161
strcat(filename, "/");
162
strcat(filename, ERR_FILE);
164
alp = qmonReadFile(filename);
165
qmonMessageBox(w, alp, 0);
171
/*-------------------------------------------------------------------------*/
172
/* PRIVATE FUNCTIONS */
173
/*-------------------------------------------------------------------------*/
176
/*-------------------------------------------------------------------------*/
177
static Widget qmonBrowserCreateDialog(
182
Widget browser_shell, browser, browser_close, browser_clear,
185
DENTER(TOP_LAYER, "qmonBrowserCreateDialog");
187
browser_shell = XmtBuildQueryToplevel(parent, "browser_shell",
188
"browser_object", &browser_object,
190
"browser_close", &browser_close,
191
"browser_clear", &browser_clear,
192
"browser_main_link", &browser_main_link,
196
XtVaSetValues( browser_shell,
197
/* XmNtitle, title, */
198
XmNallowShellResize, True,
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);
212
return browser_shell;
215
/*-------------------------------------------------------------------------*/
216
static void qmonBrowserClose(Widget w, XtPointer cld, XtPointer cad)
219
DENTER(TOP_LAYER, "qmonBrowserClose");
221
/* disable browsing */
222
XmtChooserSetState(browser_object, 0, True);
224
xmui_unmanage(BrowserShell);
229
/*-------------------------------------------------------------------------*/
230
static void qmonBrowserClear(Widget w, XtPointer cld, XtPointer cad)
232
Widget browser = (Widget) cld;
234
DENTER(GUI_LAYER, "qmonBrowserClear");
236
XmtCliClear(browser);
241
/*-------------------------------------------------------------------------*/
242
static void qmonBrowserSetState(Widget w, XtPointer cld, XtPointer cad)
244
XmtChooserCallbackStruct *cbs = (XmtChooserCallbackStruct*) cad;
245
Widget browser = (Widget) cld;
248
DENTER(GUI_LAYER, "qmonBrowserSetState");
250
BrowserState = cbs->state;
252
if (BrowserState & BROWSE_STDOUT)
257
if (BrowserState & BROWSE_STDERR)
262
XtVaSetValues( browser,
263
XmtNdisplayStdout, out,
264
XmtNdisplayStderr, err,