/*
* 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
*/
/*
*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Install and Modify Printer implementation
*/
/*
* Window for Edit -> Install Printer
*/
int action;
// where to place initial focus
boolean usePPD;
boolean useLocalhost;
boolean failed = false;
boolean cacheerr = false;
boolean ppdincacheerr = false;
switch (action) {
helpTag = "InstallLocalPPD";
} else {
helpTag = "InstallLocal";
}
break;
case Constants.ADDNETWORK:
helpTag = "InstallNetworkPPD";
} else
helpTag = "InstallNetwork";
break;
case Constants.MODIFYATTACHED:
failed = false;
try {
} catch (pmNeedPPDCacheException e) {
cacheerr = true;
} catch (pmCacheMissingPPDException e) {
ppdincacheerr = true;
} catch (Exception e) {
failed = true;
}
if (cacheerr) {
pmMessageDialog m = new pmMessageDialog(
"Cannot.modify.this.queue;ppdcache.file.missing."));
m.setVisible(true);
throw new pmGuiException("No ppdcache file");
}
if (ppdincacheerr) {
pmMessageDialog m = new pmMessageDialog(
"Cannot.modify.this.queue;PPD.file.not.in.ppdcache."));
m.setVisible(true);
throw new pmGuiException("PPD file not in ppdcache");
}
if (failed) {
// error popup?
// throw something?
}
dumpLogs("ModifyAttached()");
helpTag = "ModifyPPD";
else
helpTag = "Modify";
// helpTag = "ModifyAttached";
break;
case Constants.MODIFYNETWORK:
failed = false;
try {
} catch (Exception e) {
failed = true;
}
if (failed) {
// error popup?
// throw new pmGuiException();
}
dumpLogs("ModifyNetwork()");
helpTag = "ModifyPPD";
else
helpTag = "Modify";
// helpTag = "ModifyNetwork";
break;
case Constants.MODIFYREMOTE:
failed = false;
try {
} catch (Exception e) {
failed = true;
}
if (failed) {
// error popup?
// throw something?
}
helpTag = "ModifyPPD";
else
helpTag = "Modify";
// helpTag = "ModifyRemote";
break;
}
// ensure that pmButton hashtable gets cleaned up
frame.setClearButtonsOnClose(true);
setLayout(new BorderLayout());
// Build the Screen
northPanel();
centerPanel();
}
southPanel();
// default button is always OK, for now...
// frame.getRootPane().setDefaultButton (okButton);
// okButton.setAsDefaultButton ();
// handle Esc as cancel
this.registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}},
} else {
}
public void focusGained(FocusEvent e) {
}
public void focusLost(FocusEvent e) {
}
});
}
int numColumns;
public accessListModel() {
numColumns = getColumnCount();
}
}
}
}
return false;
else
}
}
public void removeListEntries() {
}
public int getRowCount() {
}
public int getSize() {
}
public int getColumnCount() {
return 1;
}
}
}
}
}
}
return access;
}
}
}
public void centerPanel() {
accessModel = new accessListModel();
GridBagConstraints c = new GridBagConstraints();
public void valueChanged(ListSelectionEvent e) {
(ListSelectionModel)e.getSource();
}
});
// Create the label
c.gridx = 0;
c.gridy = 0;
labelConstraints(c);
// Create User Access List
} else {
}
c.gridwidth = 2;
c.gridx = 1;
// Create Textfield
c.gridx = 1;
c.gridy = 1;
c.ipadx = 15;
c.gridx = 1;
c.gridy = 2;
adButtons(c);
c.gridwidth = 1;
c.gridx = 2;
}
public void northPanel() {
GridBagConstraints c = new GridBagConstraints();
// Define the constraints and create the labels
labelConstraints(c);
c.gridx = 0;
c.gridy = 0;
printernameLabel(north, c);
c.gridy++;
servernameLabel(north, c);
c.gridy++;
descriptionLabel(north, c);
c.gridy++;
// Add printers, modify local
printerportLabel(north, c);
c.gridy++;
}
printermakeLabel(north, c);
c.gridy++;
printermodelsLabel(north, c);
c.gridy++;
ppdcontentsLabel(north, c);
} else {
printertypeLabel(north, c);
c.gridy++;
filecontentsLabel(north, c);
}
}
printermakeLabel(north, c);
c.gridy++;
printermodelsLabel(north, c);
c.gridy++;
ppdcontentsLabel(north, c);
} else {
printertypeLabel(north, c);
c.gridy++;
filecontentsLabel(north, c);
}
}
c.gridy++;
faultnotLabel(north, c);
c.gridy++;
destinationLabel(north, c);
c.gridy++;
protocolLabel(north, c);
c.gridy++;
}
optionsLabel(north, c);
c.gridy++;
bannerLabel(north, c);
} else {
optionLabel(north, c);
}
// Define the constraints and create the fields
// Add printers
c.gridx = 1;
c.gridy = 0;
// Printer Name and Server Name
c.gridy++;
labelConstraints(c);
try {
} catch (Exception e) {
"CLNT:pmInstPr:getLocalHostName exception " + e);
}
c.gridy++;
} else {
labelConstraints(c);
c.gridy++;
labelConstraints(c);
c.gridy++;
}
// Description
descriptionField(north, c);
}
c.gridy++;
printerportField(north, c);
c.gridy++;
labelConstraints(c);
c.gridy++;
}
printermakeField(north, c);
c.gridy++;
printermodelsField(north, c);
c.gridy++;
ppdcontentsField(north, c);
} else {
printertypeField(north, c);
c.gridy++;
filecontentsField(north, c);
}
}
printermakeField(north, c);
c.gridy++;
printermodelsField(north, c);
c.gridy++;
ppdcontentsField(north, c);
setMake();
setModel();
setPPD();
} else {
// display with printer type and file contents
printertypeField(north, c);
c.gridy++;
filecontentsField(north, c);
setType();
}
}
c.gridy++;
faultnotField(north, c);
setFault();
}
c.gridy++;
destinationField(north, c);
c.gridy++;
protocolField(north, c);
c.gridy++;
}
optionsFields(north, c);
if (workingPrinter.getIsDefaultPrinter()) {
}
setBanner();
}
} else {
defaultoptionField(north, c);
if (workingPrinter.getIsDefaultPrinter()) {
}
}
}
public void setNetworkInfo() {
if (p != null) {
if (p.equals("bsd"))
else if (p.equals("tcp"))
else if (p.equals("uri"))
}
}
public void setMake() {
}
}
public void setModel() {
}
public void setPPD() {
}
public void setFault() {
else {
}
}
public void setBanner() {
}
public void setType() {
// lpadmin can combine things like: simple,any ...
} else {
}
"PostScript"));
"PostScript"));
"Both.PostScript.and.ASCII"));
"Both.PostScript.and.ASCII"));
} else if (filecontents.equals(
"text/plain,application/postscript")) {
"Both.PostScript.and.ASCII"));
} else {
"CLNT:pmInstPr:setType()unknown file contents type");
}
}
}
public void setPrinterType() {
int x = 0;
"CLNT:pmInstPrsetPrinterType(): printer type is " + type);
return;
} else {
"CLNT:pmInstPr:setPrinterType(): user defined type " +
type);
}
}
if (pmMisc.isppdCachefile()) {
getMake();
}
}
}
}
}
// Printer Name is a required field.
throw new pmIncompleteFormException(
}
throw new pmIncompleteFormException(
}
try {
if ((useLocalhost))
server = "localhost";
else
} catch (Exception e) {
"CLNT:pmInstPr:getLocalHostName exception " + e);
}
"CLNT:pmInstPr:getPrinterServer(): printer is: " + printer);
"CLNT:pmInstPr:getPrinterServer(): server is: " + server);
}
throw new pmIncompleteFormException
"Printer.Port.Selection.required"));
}
}
throw new pmIncompleteFormException
"Printer.Make.Selection.required"));
}
}
throw new pmIncompleteFormException(
}
throw new pmIncompleteFormException(
}
"CLNT:pmInstPr:getNetworkInfo(): destination is: " +
"CLNT:pmInstPr:getNetworkInfo(): protocol is: " + protocol);
}
public void getDescription() {
"CLNT:pmInstPr:getDescription():description: " + "<" +
description + ">");
description = null;
}
public void getUserAccess() {
} else {
}
}
if (t != null) {
if (t.equals("PostScript"))
else if (t.equals("HP Printer"))
else if (t.equals("Reverse PostScript"))
else if (t.equals("Epson 2500"))
else if (t.equals("IBM ProPrinter"))
else if (t.equals("Qume Sprint 5"))
else if (t.equals("Daisy"))
else if (t.equals("Diablo"))
else if (t.equals("Datagraphix"))
else if (t.equals("DEC LA100"))
else if (t.equals("DEC LN03"))
else if (t.equals("Dec Writer"))
else if (t.equals("Texas Instruments 800"))
else {
"CLNT:pmIns:gui2lptype: printer type unknown: " + t);
}
} else {
}
return lp;
}
if (f != null) {
"Both.PostScript.and.ASCII"))) {
}
} else {
"CLNT:pmInstPr:gui2lpfcontents(): input string null");
}
return lp;
}
if (n != null) {
} else {
"CLNT:pmInstPr:gui2lpfaultn():input faultnotify null");
}
return lp;
}
if (p.equals("TCP"))
else if (p.equals("BSD"))
else if (p.equals("URI"))
else {
"CLNT:pmInstPr:gui2lpprotocol: protocol is empty");
}
return lp;
}
else {
"CLNT:pmInstPr:gui2lpbanner(): banner is empty");
}
"CLNT:pmInstPr:gui2lpbanner(): banner is " + lp);
return lp;
}
public void updatePrinter() {
if (workingPrinter != null) {
}
if (description != null)
}
}
}
if (destination != null)
if (useraccesslist != null)
else {
}
} else {
"CLNT:pmInstPr:updatePrinter(): workingPrinter null");
}
}
errorLog = p.getErrorLog();
warnLog = p.getWarnLog();
}
}
try {
getPort();
} else {
}
getFault();
getBanner();
} catch (pmIncompleteFormException ie) {
}
boolean exist;
boolean failed = false;
// exists could throw an exception from the underyling cmds...
try {
} catch (Exception e) {
throw new pmGuiException();
}
if (exist) {
throw new pmPrinterExistsException();
}
try {
} catch (Exception e) {
failed = true;
} finally {
dumpLogs("doAddLocal()");
if (failed)
throw new pmAddPrinterFailedException(errorLog);
}
}
try {
} else {
}
getFault();
getBanner();
} catch (pmIncompleteFormException ie) {
}
boolean exist = false;
try {
} catch (Exception e) {
"CLNT:pmInstPr:doAddNetwork:printer exists " + e);
throw new pmGuiException();
}
if (exist) {
"CLNT:pmInstPr:Trying to add existing printer: " + printer);
throw new pmPrinterExistsException();
}
boolean failed = false;
try {
} catch (Exception e) {
failed = true;
} finally {
dumpLogs("doAddNetwork()");
if (failed)
throw new pmAddPrinterFailedException(errorLog);
}
}
getFault();
getBanner();
} else {
}
boolean failed = false;
try {
} catch (Exception e) {
failed = true;
} finally {
dumpLogs("doModifyLocalAttached()");
if (failed)
throw new pmModifyPrinterFailedException(errorLog);
}
}
getFault();
getBanner();
} else {
}
boolean failed = false;
try {
} catch (Exception e) {
failed = true;
} finally {
dumpLogs("doModifyLocalNetwork()");
if (failed)
throw new pmModifyPrinterFailedException(errorLog);
}
}
boolean failed = false;
try {
} catch (Exception e) {
failed = true;
} finally {
dumpLogs("doModifyRemote()");
if (failed)
throw new pmModifyPrinterFailedException(errorLog);
}
}
public void doClearFields() {
if (modelCombo != null)
if (faultCombo != null)
if (protocolCombo != null)
if (defaultp.isSelected())
if (bannerCombo != null)
}
public void doResetFields() {
if (workingPrinter != null) {
try {
else
} catch (Exception e) {
"CLNT:pmInstallPr:doResetFields(): getComment() " +
"Exception: " + e);
}
try {
} catch (Exception e) {
"CLNT:pmInsPr:doResetFields(): getDevice() " +
"Exception: " + e);
}
}
setMake();
setModel();
setPPD();
} else {
setType();
}
setFault();
try {
} catch (Exception e) {
"CLNT:InstPr:doResetFields(): addaccessList() " +
"Exception: " + e);
} finally {
}
// selected and banner object out of sync
setBanner();
}
// selected and printer object out of sync
if ((defaultp.isSelected() &&
(!defaultp.isSelected() &&
}
}
public boolean isactionModify() {
return true;
else
return false;
}
public void doReset() {
} else {
}
// as a side effect, the OK button will regain default status
if (defaultComponent != null)
}
// if nameservice, check for login
try {
}
} catch (pmUserCancelledException e) {
throw new pmLoginFailedException(
} catch (pmGuiException ge) {
pmMessageDialog m = new pmMessageDialog(
"LoginFailed");
m.setVisible(true);
throw new pmLoginFailedException(
} catch (Exception e) {
pmMessageDialog m = new pmMessageDialog(
"LoginFailed");
m.setVisible(true);
throw new pmLoginFailedException(
}
}
// Check for confirmation option
|| (myTop.getConfirmOption() == false)) {
try {
switch (action) {
doAddLocal();
break;
case Constants.ADDNETWORK:
doAddNetwork();
break;
case Constants.MODIFYATTACHED:
"CLNT:pmInstPr:Printer Details: server is " +
break;
case Constants.MODIFYNETWORK:
// add dest and protocol
break;
case Constants.MODIFYREMOTE:
break;
}
} catch (pmIncompleteFormException fe) {
pmMessageDialog m = new pmMessageDialog(
m.setVisible(true);
throw new pmIncompleteFormException();
} catch (pmPrinterExistsException ee) {
pmMessageDialog m = new pmMessageDialog(
"The.specified.printer.already.exists."));
m.setVisible(true);
} catch (pmNullSelectedPrinterException ne) {
pmMessageDialog m = new pmMessageDialog(
"The.selected.printer.does.not.exist."));
m.setVisible(true);
cleanup();
// frame.dispose();
} catch (pmAddPrinterFailedException ae) {
pmMessageDialog m = new pmMessageDialog(
ae.getMessage(),
"AddPrinterFailed");
m.setVisible(true);
} catch (pmModifyPrinterFailedException me) {
pmMessageDialog m = new pmMessageDialog(
me.getMessage(),
"ModifyFailed");
m.setVisible(true);
} catch (pmGuiException ge) {
pmMessageDialog m = new pmMessageDialog(
m.setVisible(true);
} catch (pmCmdFailedException cfe) {
"error.message.command-failed");
pmMessageDialog m = new pmMessageDialog(
msg);
m.setVisible(true);
} catch (Exception e) {
pmMessageDialog m = new pmMessageDialog(
e.toString());
m.setVisible(true);
} finally {
}
// Update the list of printers
}
}
public boolean confirmAction() {
if (myTop.getConfirmOption() == true) {
"Continue.action.for.this.printer?"));
d.setVisible(true);
pmMessageDialog m =
new pmMessageDialog(
m.setVisible(true);
return false;
}
}
return true;
}
public void actionportCombo() {
"PrinterPort");
o.setVisible(true);
try {
pmMessageDialog m = new pmMessageDialog(
"Device.missing.or.not.writeable."),
"PrinterPort"); // "InvalidDevice"
m.setVisible(true);
else
} else {
else
}
"CLNT:pmInstPr:error validating device" + de);
}
} else { // Cancelled out of Other window
else
}
}
int idx;
int i;
if (idx != -1)
else
// Some Manufacturers have multiple names
// Collapse them
try {
} catch (Exception e) {
"CLNT:pmInstPr:getModelsList: exception" + e);
}
boolean havemodel = false;
boolean addmake = false;
"CLNT:pmInstPr:Probe:no models for "
+ tmake);
} else {
if (models[i].equalsIgnoreCase(
havemodel = true;
}
}
// Some Printers do not preceed the model
// name with the Make. If fail, try adding
// Make to front of model
if (!havemodel) {
if (models[i].equalsIgnoreCase(
havemodel = true;
addmake = true;
}
}
}
if (havemodel) {
if (!addmake) {
makemodel[1]);
} else {
}
}
}
}
}
}
}
}
}
public void actiontypeCombo() {
"PrinterType");
o.setVisible(true);
try {
pmMessageDialog m = new pmMessageDialog(
"Invalid.printer.type."),
"PrinterType");
m.setVisible(true);
else
} else {
else
}
"CLNT:pmInstPr:error validating printertype"
+ pte);
}
} else { // Cancelled out of Other window
else
}
}
}
// Printer make has been selected
public void actionmakeCombo() {
int i;
}
// Get Model
public void actionmodelCombo() {
int i;
try {
} catch (Exception e) {
"CLNT:pmInstPr:actionmodelCombo: exception" + e);
}
"CLNT:pmInstPr:actionmodelCombo:no models for "
+ make);
"No.Models.Found"));
} else {
}
}
}
public void actionppdCombo() {
int i;
int rec = -1;
int idx = -1;
try {
} catch (Exception e) {
"CLNT:pmInstPr:actionmodelCombo: exception" +e);
}
// Get the ppd files list
// If a recommended ppd is in the list, display it first
"CLNT:pmInstPr:actionmodelCombo: no ppds for " +
} else {
if (rec != -1)
idx = i;
}
if (idx != -1)
}
}
}
public void actionaddButton() {
try {
} catch (Exception e) {
"CLNT:pmInstPr:actionaddButton:UserAccessList empty");
}
} else {
pmMessageDialog m = new pmMessageDialog(
// "FormError"
m.setVisible(true);
} else {
}
}
}
}
public void actiondeleteButton() {
int row;
int rcount;
int idx;
if (rcount != 0) {
}
}
}
public void cleanup() {
}
}
}
public void pmScreendispose() {
}
public void actionokButton() {
boolean incomplete = false;
try {
doAction();
} catch (pmLoginFailedException le) {
// User already notified
} catch (pmIncompleteFormException fe) {
// User already notified
incomplete = true;
} catch (pmGuiException ge) {
}
if (!incomplete) {
cleanup();
frame.setVisible(false);
// frame.dispose();
}
}
public void actionapplyButton() {
try {
doAction();
} catch (pmLoginFailedException le) {
// User already notified
} catch (pmGuiException ge) {
}
}
public void actionresetButton() {
doReset();
}
public void actioncancelButton() {
cleanup();
frame.setVisible(false);
// frame.dispose();
}
public void actionhelpButton() {
}
public void Show() {
frame.setVisible(true);
// set focus to initial field, depending on which action is tbd
// this seems to work best after pack()
// default button is always OK, for now...
// frame.getRootPane().setDefaultButton (okButton);
if (defaultComponent != null) {
}
}
}