/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*
*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Top level
*/
/*
* Top window for printer manager
*/
boolean runningAuth = false;
boolean isRoot = false;
setLayout(new BorderLayout());
pmTopInit();
}
public void pmTopInit() {
try {
} catch (Exception e) {
}
try {
} catch (Exception e) {
}
try {
} catch (Exception e) {
}
newNS = "files";
// determine root privileges
try {
}
runningAuth = true;
isRoot = true;
} else
northPanel();
centerPanel();
southPanel();
}
// Set values so that printer selection null
public void clearSelected() {
selectedRow = -1;
enableEditMenuItems(false);
}
// Create north panel with GridBagLayout
public void northPanel() {
}
int numColumns;
};
// Initialize for JTable calls from SWING classes
public listTableModel() {
numColumns = getColumnCount();
}
int j = 0;
return;
}
for (j = 0; j < 3; j++) {
rowDataList[i + j]);
}
}
}
}
public int getRowCount() {
}
public int getColumnCount() {
return columnNames.length;
}
return columnNames[col];
}
}
}
}
return i;
}
return -1;
}
};
// called on enter or double-click
void modifySelectedPrinter() {
if (m.isSelectionEmpty()) {
return;
}
int selectedRow = m.getMinSelectionIndex();
doModify();
}
// Create printer list in center panel
public void centerPanel() {
listModel = new listTableModel();
listTable.setColumnSelectionAllowed(false);
listTable.setRowSelectionAllowed(true);
listTable.setShowGrid(false);
public void actionPerformed(ActionEvent e) {
if (runningAuth)
else
}},
public void mouseClicked(MouseEvent e) {
int clickCount = e.getClickCount();
if (clickCount == 2) {
if (rowIndex == -1) {
} else {
if (runningAuth)
else
}
}
}
});
// Add selection listener
public void valueChanged(ListSelectionEvent e) {
if (listSM.isSelectionEmpty()) {
enableEditMenuItems(false);
} else {
"CLNT: list element selected" + selectedRow);
"CLNT: selectedPrinter is " + selectedPrinter);
enableEditMenuItems(true);
}
}
});
GridBagConstraints c = new GridBagConstraints();
try {
} catch (Exception e) {
pmMessageDialog m = new pmMessageDialog(
"Cannot.get.list.of.printers.Exiting."),
"getPrinterListFailed");
m.setVisible(true);
}
scrollPane = new JScrollPane();
}
// Create south panel with grid layout
public void southPanel() {
GridBagConstraints c = new GridBagConstraints();
// Constraints applied across all entries
c.gridheight = 1;
c.gridwidth = 1;
c.gridy = 1;
// Create the labels
c.gridx = 0;
try {
} catch (Exception e) {
defaultpLabel = new JLabel(
}
try {
} catch (Exception e) {
}
} else {
try {
domainhostLabel = new JLabel(
host.getDomainName());
} catch (Exception e) {
}
}
c.gridx = 2;
c.gridx = 3;
}
// name service
// ---
// cmd line console
// confirm all actions
// use ppd file
// ---
// exit
public void mouseClicked(MouseEvent e) {
};
});
new ActionListener() {
public void actionPerformed(ActionEvent e) {
loadView.setVisible(true);
else
};
});
load.setEnabled(true);
logCheck = new JCheckBoxMenuItem(
public void actionPerformed(ActionEvent e) {
if (c.isSelected() == true) {
commandLog.setVisible(true);
} else {
commandLog.setVisible(false);
}
}
});
if (!runningAuth)
logCheck.setEnabled(false);
confirmCheck = new JCheckBoxMenuItem(
if (!runningAuth)
confirmCheck.setEnabled(false);
usePPD = new JCheckBoxMenuItem(
useLocalhost = new JCheckBoxMenuItem(
if (!runningAuth) {
usePPD.setEnabled(false);
useLocalhost.setEnabled(false);
}
new ActionListener() {
public void actionPerformed(ActionEvent e) {
};
});
exit.setEnabled(true);
return appMenu;
}
// disable everything is not running as root
// add access to printer...
// ---
// new local printer...
// new network printer...
// ---
// delete printer
// modify properties...
new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (accessView != null)
accessView.setVisible(true);
else
accessView.Show();
};
});
if (!runningAuth)
access.setEnabled(false);
new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (localinstallView != null)
localinstallView.setVisible(true);
else {
try {
localinstallView = new pmInstallPrinter(
}
}
};
});
if (!runningAuth)
local.setEnabled(false);
new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (networkinstallView != null)
networkinstallView.setVisible(true);
else {
try {
networkinstallView = new
}
}
};
});
if (!runningAuth)
network.setEnabled(false);
modifyMenuItem = new JMenuItem(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
doModify();
};
});
modifyMenuItem.setEnabled(false);
deleteMenuItem = new JMenuItem(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (selectedPrinter == null) {
// show error window
} else {
}
};
});
deleteMenuItem.setEnabled(false);
return objectMenu;
}
// returns true iff name was found in the printer list
int row = -1;
try {
}
if (row != -1) {
selectedRow = row;
}
return row != -1;
}
// find printer...
new ActionListener() {
public void actionPerformed(ActionEvent e) {
findFrame.setVisible(true);
}
});
return toolsMenu;
}
// Create help Menu
public void actionPerformed(ActionEvent e) {
};
});
public void actionPerformed(ActionEvent e) {
};
});
public void actionPerformed(ActionEvent e) {
aboutBox.setVisible(true);
};
});
public void actionPerformed(ActionEvent e) {
};
});
return helpMenu;
}
}
public void doModify() {
if (modifyView != null)
try {
} else {
if (isNetwork()) {
modifyView = new
} else {
modifyView = new
}
modifyView.Show();
} else {
try {
modifyView = new pmInstallPrinter(
} catch (Exception e) {
"CLNT:pmTop:caught exception" + e);
}
modifyView.Show();
}
}
} catch (Exception e) {
}
} // doModify()
public boolean isNetwork() {
try {
} catch (Exception e) {
}
newpr.getDestination());
return true;
} else {
return false;
}
}
// Set the new namespace
public void pmsetNS() {
// translate from gui to server
useLocalhost.setState(true);
useLocalhost.setState(false);
useLocalhost.setState(false);
} else {
useLocalhost.setState(true);
}
"\n serverNS: " + serverNS +
useLocalhost.setState(true);
useLocalhost.setState(false);
useLocalhost.setState(false);
} else {
useLocalhost.setState(true);
}
}
// This tool is read-only unless the user is root on the
// print server. Thus, don't check for namespace authorization
// if user is not root.
if (isRoot) {
// Check if user is authorized with this nameservice
runningAuth = true;
} else {
try {
runningAuth = true;
}
} catch (pmUserCancelledException e) {
"CLNT:pmTop:user cancelled login");
runningAuth = false;
} catch (pmGuiException e) {
runningAuth = false;
pmMessageDialog m = new pmMessageDialog(
"Required.login.failed."),
"LoginFailed");
m.setVisible(true);
} catch (Exception e) {
runningAuth = false;
pmMessageDialog m = new pmMessageDialog(
"Required.login.failed."),
"LoginFailed");
m.setVisible(true);
}
} else {
try {
runningAuth = true;
runningAuth = false;
pmMessageDialog m = new pmMessageDialog(
"User.not.authorized.to.modify.this.namespace."),
"AuthorizationFailed");
m.setVisible(true);
}
}
}
}
// Change front panel as unauthorized to modify
if (!runningAuth) {
logCheck.setEnabled(false);
confirmCheck.setEnabled(false);
usePPD.setEnabled(false);
useLocalhost.setEnabled(false);
access.setEnabled(false);
local.setEnabled(false);
network.setEnabled(false);
modifyMenuItem.setEnabled(false);
deleteMenuItem.setEnabled(false);
} else {
logCheck.setEnabled(true);
confirmCheck.setEnabled(true);
access.setEnabled(true);
local.setEnabled(true);
network.setEnabled(true);
if (pmMisc.isppdCachefile())
usePPD.setEnabled(true);
else
usePPD.setEnabled(false);
useLocalhost.setEnabled(true);
useLocalhost.setVisible(true);
} else {
useLocalhost.setVisible(false);
}
}
} else {
runningAuth = false;
}
ns.getNameService());
}
public topnsListener() {}
}
}
}
public void pmsetdefaultpLabel() {
try {
"CLNT: pmTop:pmsetdefaultpLabel(): default printer: " +
} catch (Exception e) {
}
}
public boolean getLogOption() {
}
}
public boolean getConfirmOption() {
return confirmCheck.getState();
}
public boolean getUsePPD() {
}
public boolean getUseLocalhost() {
return useLocalhost.getState();
}
}
public void deleteAllScreens() {
if (accessView != null)
accessView = null;
if (localinstallView != null)
if (networkinstallView != null)
if (modifyView != null)
modifyView = null;
}
/*
* this must be called when:
* . an existing printer is selected
* . the selection is disabled
*/
if (!runningAuth)
return;
}
/*
*/
warningLog = warn;
}
/*
* display current log state for the specified action
* if the cmdLog is empty nothing at all will be displayed!
*/
// Debug.info("CLNT: showLogData():actionName: " + actionName);
// Debug.info("CLNT: showLogData():cmdLog: " + cmdLog);
return;
// iterate over multiline cmds
cmdLog, "\n\r", false);
while (st.hasMoreTokens()) {
addToCommandLog("\n");
}
while (st.hasMoreTokens()) {
addToCommandLog("\n");
}
}
if (warningLog != null) {
while (st.hasMoreTokens()) {
addToCommandLog("\n");
}
}
addToCommandLog("***\n");
}
commandLog.addText(s);
}
else
}
public void pmsetNSLabel() {
try {
host.getLocalHostName());
} catch (Exception e) {
"CLNT: pmTop:getLocalHostName caught " + e);
}
} else {
"CLNT: pmsetNSLabel:nameserviceLabel is : " +
try {
host.getDomainName());
} catch (Exception e) {
"CLNT: pmTop:getDomainName caught " + e);
}
}
}
// Update the list of printers
// Printer list will change if nameservice changes and when user
public void pmsetPrinterList() {
ns.getNameService());
try {
} catch (Exception e) {
}
}
// returns -1 if error, 0 otherwise
int rv = 0;
}
return rv;
}
// use pmFrame to get app icon
public void windowClosing(WindowEvent e) {
}
});
frame.setVisible(true);
aboutBox = new pmAboutBox();
/*
* Make sure to open the help frame after the about box,
* command log, and find frame windows have been opened.
* Otherwise it might cause null pointer exceptions as it
* takes a long time for the help frame to load.
*/
helpFrame = new pmHelpFrame();
}
// disable Enter action **for all JTextFields**
static {
JTextField f = new JTextField();
}
}