1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-11 11:05:24 +02:00

[fix] API inconsitency in ISystemPromptDialog

This commit is contained in:
Uwe Stieber 2007-02-13 09:52:50 +00:00
parent 6b04348c73
commit 3ecdb0a3a5
3 changed files with 151 additions and 154 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************** /********************************************************************************
* Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms * This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
@ -11,7 +11,7 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* {Name} (company) - description of contribution. * {Uwe Stieber} (Wind River) - API consistency.
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.ui.dialogs; package org.eclipse.rse.ui.dialogs;
@ -20,8 +20,7 @@ package org.eclipse.rse.ui.dialogs;
/** /**
* Suggested interface for dialogs used in actions in remote system framework. * Suggested interface for dialogs used in actions in remote system framework.
*/ */
public interface ISystemPromptDialog public interface ISystemPromptDialog {
{
/** /**
* For explicitly setting input object * For explicitly setting input object
*/ */
@ -38,6 +37,12 @@ public interface ISystemPromptDialog
*/ */
public Object getOutputObject(); public Object getOutputObject();
/**
* For explicitly setting output object after wizard is dismissed. Called in the
* wizard's processFinish method, typically.
*/
public void setOutputObject(Object outputObject);
/** /**
* Allow caller to determine if window was cancelled or not. * Allow caller to determine if window was cancelled or not.
*/ */
@ -48,10 +53,10 @@ public interface ISystemPromptDialog
* excessible method * excessible method
*/ */
public int publicConvertWidthInCharsToPixels(int chars); public int publicConvertWidthInCharsToPixels(int chars);
/** /**
* Expose inherited protected method convertHeightInCharsToPixels as a publicly * Expose inherited protected method convertHeightInCharsToPixels as a publicly
* excessible method * excessible method
*/ */
public int publicConvertHeightInCharsToPixels(int chars); public int publicConvertHeightInCharsToPixels(int chars);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************** /********************************************************************************
* Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. * Copyright (c) 2002, 2007 IBM Corporation and others.. All rights reserved.
* This program and the accompanying materials are made available under the terms * This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
@ -11,7 +11,7 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* {Name} (company) - description of contribution. * {Uwe Stieber} (Wind River) - API consistency.
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.ui.dialogs; package org.eclipse.rse.ui.dialogs;
@ -354,33 +354,32 @@ public abstract class SystemPromptDialog
//helpIdPerControl.put(c, helpId); //helpIdPerControl.put(c, helpId);
} }
/** /* (non-Javadoc)
* For explicitly setting input object. Called by SystemDialogAction * @see org.eclipse.rse.ui.dialogs.ISystemPromptDialog#setInputObject(java.lang.Object)
*/ */
public void setInputObject(Object inputObject) public void setInputObject(Object inputObject)
{ {
this.inputObject = inputObject; this.inputObject = inputObject;
} }
/**
* For explicitly getting input object /* (non-Javadoc)
* @see org.eclipse.rse.ui.dialogs.ISystemPromptDialog#getInputObject()
*/ */
public Object getInputObject() public Object getInputObject()
{ {
return inputObject; return inputObject;
} }
/** /* (non-Javadoc)
* For explicitly getting output object after dialog is dismissed. Set by the * @see org.eclipse.rse.ui.dialogs.ISystemPromptDialog#getOutputObject()
* dialog's processOK method.
*/ */
public Object getOutputObject() public Object getOutputObject()
{ {
return outputObject; return outputObject;
} }
/** /* (non-Javadoc)
* Allow caller to determine if window was cancelled or not. * @see org.eclipse.rse.ui.dialogs.ISystemPromptDialog#wasCancelled()
* Will return <code>false</code> if Cancel All was pressed.
*/ */
public boolean wasCancelled() public boolean wasCancelled()
{ {
@ -416,20 +415,27 @@ public abstract class SystemPromptDialog
return fMessageLine; return fMessageLine;
} }
/** /* (non-Javadoc)
* For explicitly setting output object. Call this in your processOK method. * @see org.eclipse.rse.ui.dialogs.ISystemPromptDialog#setOutputObject(java.lang.Object)
* If an output object validator has been set via setOutputObjectValidator, then * <p>
* this will call its isValid method on the outputObject and will return the error * Note: Signature has changed to ensure overall API consistency!!! If used with return
* message if any that it issues. A return of null always means no errors and * value in specific product code (open source code does not reference this method!),
* hence it is ok to dismiss the dialog. * replace the old code:<pre>
*
* String xyz = "output object";
* SystemMessage message = systemPromptDialog.setOutputObject(xyz);
*
* </pre>with the new code:<pre>
*
* String xyz = "output object";
* systemPromptDialog.setOutputObject(xyz);
* if (systemPromptDialog.getOutputObjectValidator() != null)
* SystemMessage message = systemPromptDialog.getOutputObjectValidator().validate((String)systemPromptDialog.getOutputObject());
* </pre>
*
*/ */
protected SystemMessage setOutputObject(Object outputObject) public void setOutputObject(Object outputObject) {
{
this.outputObject = outputObject; this.outputObject = outputObject;
if ((outputObjectValidator != null) && (outputObject instanceof String))
return outputObjectValidator.validate((String)outputObject);
else
return null;
} }
/** /**

View file

@ -1,5 +1,5 @@
/******************************************************************************** /********************************************************************************
* Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. * Copyright (c) 2002, 2007 IBM Corporation. All rights reserved.
* This program and the accompanying materials are made available under the terms * This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
@ -11,11 +11,12 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* {Name} (company) - description of contribution. * {Uwe Stieber} (Wind River) - API consistency.
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.ui.dialogs; package org.eclipse.rse.ui.dialogs;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.ProgressMonitorPart; import org.eclipse.jface.wizard.ProgressMonitorPart;
import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.jface.wizard.WizardDialog;
@ -57,83 +58,75 @@ import org.eclipse.swt.widgets.Shell;
* @see org.eclipse.rse.ui.wizards.AbstractSystemWizard * @see org.eclipse.rse.ui.wizards.AbstractSystemWizard
* @see org.eclipse.rse.ui.actions.SystemBaseWizardAction * @see org.eclipse.rse.ui.actions.SystemBaseWizardAction
*/ */
public class SystemWizardDialog public class SystemWizardDialog extends WizardDialog implements ISystemPromptDialog {
extends WizardDialog
implements ISystemPromptDialog
{
protected ISystemWizard wizard;
protected String helpId; protected String helpId;
/** /**
* Constructor * Constructor
*/ */
public SystemWizardDialog(Shell shell, ISystemWizard wizard) public SystemWizardDialog(Shell shell, IWizard wizard) {
{ this(shell, wizard, null);
super(shell, wizard);
this.wizard = wizard;
wizard.setSystemWizardDialog(this);
} }
/** /**
* Constructor two. Use when you have an input object at instantiation time. * Constructor two. Use when you have an input object at instantiation time.
*/ */
public SystemWizardDialog(Shell shell, ISystemWizard wizard, Object inputObject) public SystemWizardDialog(Shell shell, IWizard wizard, Object inputObject) {
{ super(shell, wizard);
super(shell,wizard); if (wizard instanceof ISystemWizard) {
this.wizard = wizard; ((ISystemWizard)wizard).setSystemWizardDialog(this);
setInputObject(inputObject); setInputObject(inputObject);
wizard.setSystemWizardDialog(this); }
} }
/** /* (non-Javadoc)
* For explicitly setting input object. Called by SystemDialogAction * @see org.eclipse.rse.ui.dialogs.ISystemPromptDialog#setInputObject(java.lang.Object)
*/ */
public void setInputObject(Object inputObject) public void setInputObject(Object inputObject) {
{ if (getWizard() instanceof ISystemWizard) ((ISystemWizard)getWizard()).setInputObject(inputObject);
wizard.setInputObject(inputObject);
}
/**
* For explicitly getting input object.
*/
public Object getInputObject()
{
return wizard.getInputObject();
} }
/** /* (non-Javadoc)
* For explicitly getting output object after wizard is dismissed. Set by the * @see org.eclipse.rse.ui.dialogs.ISystemPromptDialog#getInputObject()
* dialog's processOK method.
*/ */
public Object getOutputObject() public Object getInputObject() {
{ return getWizard() instanceof ISystemWizard ? ((ISystemWizard)getWizard()).getInputObject() : null;
return wizard.getOutputObject();
} }
/** /* (non-Javadoc)
* Allow caller to determine if wizard was cancelled or not. * @see org.eclipse.rse.ui.dialogs.ISystemPromptDialog#getOutputObject()
*/ */
public boolean wasCancelled() public Object getOutputObject() {
{ return getWizard() instanceof ISystemWizard ? ((ISystemWizard)getWizard()).getOutputObject() : null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.dialogs.ISystemPromptDialog#setOutputObject(java.lang.Object)
*/
public void setOutputObject(Object outputObject) {
if (getWizard() instanceof ISystemWizard) ((ISystemWizard)getWizard()).setOutputObject(outputObject);
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.dialogs.ISystemPromptDialog#wasCancelled()
*/
public boolean wasCancelled() {
//System.out.println("Inside wasCancelled of SystemWizardDialog: " + wizard.wasCancelled()); //System.out.println("Inside wasCancelled of SystemWizardDialog: " + wizard.wasCancelled());
return wizard.wasCancelled(); return getWizard() instanceof ISystemWizard ? ((ISystemWizard)getWizard()).wasCancelled() : false;
} }
/** /**
* Set the help context id for this wizard dialog * Set the help context id for this wizard dialog
*/ */
public void setHelp(String id) public void setHelp(String id) {
{
helpId = id; helpId = id;
if (wizard != null) { if (getWizard() instanceof ISystemWizard) ((ISystemWizard)getWizard()).setHelp(id);
wizard.setHelp(id);
}
} }
/** /**
* Get the help context id for this wizard dialog, as set in setHelp * Get the help context id for this wizard dialog, as set in setHelp
*/ */
public String getHelpContextId() public String getHelpContextId() {
{
return helpId; return helpId;
} }
@ -142,23 +135,18 @@ public class SystemWizardDialog
* with the SystemRegistry for all framework progress monitor requests, if user has specified * with the SystemRegistry for all framework progress monitor requests, if user has specified
* they need a progress monitor for this wizard. * they need a progress monitor for this wizard.
*/ */
protected Control createDialogArea(Composite parent) protected Control createDialogArea(Composite parent) {
{ boolean needsMonitor = getWizard().needsProgressMonitor();
boolean needsMonitor = wizard.needsProgressMonitor();
Control ctrl = super.createDialogArea(parent); Control ctrl = super.createDialogArea(parent);
if (!needsMonitor) if (!needsMonitor) {
{
IProgressMonitor pm = getProgressMonitor(); IProgressMonitor pm = getProgressMonitor();
((ProgressMonitorPart)pm).dispose(); ((ProgressMonitorPart)pm).dispose();
} }
if (needsMonitor && RSEUIPlugin.isTheSystemRegistryActive()) if (needsMonitor && RSEUIPlugin.isTheSystemRegistryActive()) {
{
RSEUIPlugin.getTheSystemRegistry().setRunnableContext(getShell(), this); RSEUIPlugin.getTheSystemRegistry().setRunnableContext(getShell(), this);
// add a dispose listener // add a dispose listener
getShell().addDisposeListener(new DisposeListener() getShell().addDisposeListener(new DisposeListener() {
{ public void widgetDisposed(DisposeEvent e) {
public void widgetDisposed(DisposeEvent e)
{
RSEUIPlugin.getTheSystemRegistry().clearRunnableContext(); RSEUIPlugin.getTheSystemRegistry().clearRunnableContext();
} }
}); });
@ -169,8 +157,7 @@ public class SystemWizardDialog
/** /**
* Exposes this nice new 2.0 capability to the public. * Exposes this nice new 2.0 capability to the public.
*/ */
public void updateSize(IWizardPage page) public void updateSize(IWizardPage page) {
{
super.updateSize(page); super.updateSize(page);
} }
@ -178,16 +165,15 @@ public class SystemWizardDialog
* Expose inherited protected method convertWidthInCharsToPixels as a publicly * Expose inherited protected method convertWidthInCharsToPixels as a publicly
* excessible method * excessible method
*/ */
public int publicConvertWidthInCharsToPixels(int chars) public int publicConvertWidthInCharsToPixels(int chars) {
{
return convertWidthInCharsToPixels(chars); return convertWidthInCharsToPixels(chars);
} }
/** /**
* Expose inherited protected method convertHeightInCharsToPixels as a publicly * Expose inherited protected method convertHeightInCharsToPixels as a publicly
* excessible method * excessible method
*/ */
public int publicConvertHeightInCharsToPixels(int chars) public int publicConvertHeightInCharsToPixels(int chars) {
{
return convertHeightInCharsToPixels(chars); return convertHeightInCharsToPixels(chars);
} }
} }