mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-11 02:55:23 +02:00
[fix] API inconsitency in ISystemPromptDialog
This commit is contained in:
parent
6b04348c73
commit
3ecdb0a3a5
3 changed files with 151 additions and 154 deletions
|
@ -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,38 +20,43 @@ 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
|
||||||
*/
|
*/
|
||||||
public void setInputObject(Object inputObject);
|
public void setInputObject(Object inputObject);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For explicitly getting input object
|
* For explicitly getting input object
|
||||||
*/
|
*/
|
||||||
public Object getInputObject();
|
public Object getInputObject();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For explicitly getting output object after dialog is dismissed. Set by the
|
* For explicitly getting output object after dialog is dismissed. Set by the
|
||||||
* dialog's processOK method.
|
* dialog's processOK method.
|
||||||
*/
|
*/
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
public boolean wasCancelled();
|
public boolean wasCancelled();
|
||||||
|
|
||||||
/**
|
|
||||||
* Expose inherited protected method convertWidthInCharsToPixels as a publicly
|
|
||||||
* excessible method
|
|
||||||
*/
|
|
||||||
public int publicConvertWidthInCharsToPixels(int chars);
|
|
||||||
/**
|
|
||||||
* Expose inherited protected method convertHeightInCharsToPixels as a publicly
|
|
||||||
* excessible method
|
|
||||||
*/
|
|
||||||
public int publicConvertHeightInCharsToPixels(int chars);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expose inherited protected method convertWidthInCharsToPixels as a publicly
|
||||||
|
* excessible method
|
||||||
|
*/
|
||||||
|
public int publicConvertWidthInCharsToPixels(int chars);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expose inherited protected method convertHeightInCharsToPixels as a publicly
|
||||||
|
* excessible method
|
||||||
|
*/
|
||||||
|
public int publicConvertHeightInCharsToPixels(int chars);
|
||||||
}
|
}
|
|
@ -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()
|
||||||
{
|
{
|
||||||
|
@ -415,21 +414,28 @@ 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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,137 +58,122 @@ 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.
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.ui.dialogs.ISystemPromptDialog#getInputObject()
|
||||||
*/
|
*/
|
||||||
public Object getInputObject()
|
public Object getInputObject() {
|
||||||
{
|
return getWizard() instanceof ISystemWizard ? ((ISystemWizard)getWizard()).getInputObject() : null;
|
||||||
return wizard.getInputObject();
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.ui.dialogs.ISystemPromptDialog#getOutputObject()
|
||||||
|
*/
|
||||||
|
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)
|
||||||
* For explicitly getting output object after wizard is dismissed. Set by the
|
* @see org.eclipse.rse.ui.dialogs.ISystemPromptDialog#wasCancelled()
|
||||||
* dialog's processOK method.
|
|
||||||
*/
|
*/
|
||||||
public Object getOutputObject()
|
public boolean wasCancelled() {
|
||||||
{
|
|
||||||
|
|
||||||
return wizard.getOutputObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow caller to determine if wizard was cancelled or not.
|
|
||||||
*/
|
|
||||||
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 (getWizard() instanceof ISystemWizard) ((ISystemWizard)getWizard()).setHelp(id);
|
||||||
if (wizard != null) {
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Intercept of parent method so we can automatically register the wizard's progress monitor
|
* Intercept of parent method so we can automatically register the wizard's progress monitor
|
||||||
* 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();
|
||||||
{
|
((ProgressMonitorPart)pm).dispose();
|
||||||
IProgressMonitor pm = getProgressMonitor();
|
}
|
||||||
((ProgressMonitorPart)pm).dispose();
|
if (needsMonitor && RSEUIPlugin.isTheSystemRegistryActive()) {
|
||||||
}
|
RSEUIPlugin.getTheSystemRegistry().setRunnableContext(getShell(), this);
|
||||||
if (needsMonitor && RSEUIPlugin.isTheSystemRegistryActive())
|
// add a dispose listener
|
||||||
{
|
getShell().addDisposeListener(new DisposeListener() {
|
||||||
RSEUIPlugin.getTheSystemRegistry().setRunnableContext(getShell(), this);
|
public void widgetDisposed(DisposeEvent e) {
|
||||||
// add a dispose listener
|
RSEUIPlugin.getTheSystemRegistry().clearRunnableContext();
|
||||||
getShell().addDisposeListener(new DisposeListener()
|
}
|
||||||
{
|
});
|
||||||
public void widgetDisposed(DisposeEvent e)
|
}
|
||||||
{
|
return ctrl;
|
||||||
RSEUIPlugin.getTheSystemRegistry().clearRunnableContext();
|
}
|
||||||
}
|
|
||||||
});
|
/**
|
||||||
}
|
* Exposes this nice new 2.0 capability to the public.
|
||||||
return ctrl;
|
*/
|
||||||
}
|
public void updateSize(IWizardPage page) {
|
||||||
|
super.updateSize(page);
|
||||||
/**
|
}
|
||||||
* Exposes this nice new 2.0 capability to the public.
|
|
||||||
*/
|
/**
|
||||||
public void updateSize(IWizardPage page)
|
* Expose inherited protected method convertWidthInCharsToPixels as a publicly
|
||||||
{
|
* excessible method
|
||||||
super.updateSize(page);
|
*/
|
||||||
}
|
public int publicConvertWidthInCharsToPixels(int chars) {
|
||||||
|
return convertWidthInCharsToPixels(chars);
|
||||||
/**
|
}
|
||||||
* Expose inherited protected method convertWidthInCharsToPixels as a publicly
|
|
||||||
* excessible method
|
/**
|
||||||
*/
|
* Expose inherited protected method convertHeightInCharsToPixels as a publicly
|
||||||
public int publicConvertWidthInCharsToPixels(int chars)
|
* excessible method
|
||||||
{
|
*/
|
||||||
return convertWidthInCharsToPixels(chars);
|
public int publicConvertHeightInCharsToPixels(int chars) {
|
||||||
}
|
return convertHeightInCharsToPixels(chars);
|
||||||
/**
|
}
|
||||||
* Expose inherited protected method convertHeightInCharsToPixels as a publicly
|
|
||||||
* excessible method
|
|
||||||
*/
|
|
||||||
public int publicConvertHeightInCharsToPixels(int chars)
|
|
||||||
{
|
|
||||||
return convertHeightInCharsToPixels(chars);
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue