KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ltk > ui > refactoring > RefactoringWizard


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ltk.ui.refactoring;
13
14 import java.lang.reflect.InvocationTargetException JavaDoc;
15
16 import org.eclipse.core.runtime.Assert;
17 import org.eclipse.core.runtime.CoreException;
18 import org.eclipse.core.runtime.IProgressMonitor;
19
20 import org.eclipse.core.resources.ResourcesPlugin;
21
22 import org.eclipse.swt.widgets.Shell;
23
24 import org.eclipse.jface.operation.IRunnableContext;
25 import org.eclipse.jface.wizard.IWizardContainer;
26 import org.eclipse.jface.wizard.IWizardPage;
27 import org.eclipse.jface.wizard.Wizard;
28
29 import org.eclipse.ui.PlatformUI;
30
31 import org.eclipse.ltk.core.refactoring.Change;
32 import org.eclipse.ltk.core.refactoring.CheckConditionsOperation;
33 import org.eclipse.ltk.core.refactoring.CreateChangeOperation;
34 import org.eclipse.ltk.core.refactoring.PerformChangeOperation;
35 import org.eclipse.ltk.core.refactoring.Refactoring;
36 import org.eclipse.ltk.core.refactoring.RefactoringCore;
37 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
38 import org.eclipse.ltk.internal.ui.refactoring.ChangeExceptionHandler;
39 import org.eclipse.ltk.internal.ui.refactoring.ErrorWizardPage;
40 import org.eclipse.ltk.internal.ui.refactoring.ExceptionHandler;
41 import org.eclipse.ltk.internal.ui.refactoring.FinishResult;
42 import org.eclipse.ltk.internal.ui.refactoring.IErrorWizardPage;
43 import org.eclipse.ltk.internal.ui.refactoring.IPreviewWizardPage;
44 import org.eclipse.ltk.internal.ui.refactoring.InternalAPI;
45 import org.eclipse.ltk.internal.ui.refactoring.Messages;
46 import org.eclipse.ltk.internal.ui.refactoring.PreviewWizardPage;
47 import org.eclipse.ltk.internal.ui.refactoring.RefactoringPluginImages;
48 import org.eclipse.ltk.internal.ui.refactoring.RefactoringUIMessages;
49 import org.eclipse.ltk.internal.ui.refactoring.RefactoringUIPlugin;
50 import org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter;
51
52 /**
53  * An abstract base implementation of a refactoring wizard. A refactoring
54  * wizard differs from a normal wizard in the following characteristics:
55  * <ul>
56  * <li>only pages of type {@link org.eclipse.ltk.ui.refactoring.RefactoringWizardPage
57  * RefactoringWizardPage} can be added to a refactoring wizard. Trying to
58  * add a different kind of page results in an exception.</li>
59  * <li>a refactoring wizard consists of 0 .. n user input pages, one error page
60  * to present the outcome of the refactoring's condition checking and one
61  * preview page to present a preview of the workspace changes.</li>
62  * </ul>
63  * <p>
64  * A refactoring wizard is best opened using the {@link RefactoringWizardOpenOperation}.
65  * </p>
66  * <p>
67  * Clients may extend this class.
68  * </p>
69  *
70  * @see org.eclipse.ltk.core.refactoring.Refactoring
71  *
72  * @since 3.0
73  */

74 public abstract class RefactoringWizard extends Wizard {
75
76     /**
77      * Flag (value 0) indicating that no special flags are provided.
78      */

79     public static final int NONE= 0;
80     
81     /**
82      * Flag (value 1) indicating that the initial condition checking of the refactoring is done when
83      * the wizard opens. If not specified it is assumed that the initial condition checking
84      * has been done by the client before opening the wizard dialog.
85      */

86     public static final int CHECK_INITIAL_CONDITIONS_ON_OPEN= 1 << 0;
87     
88     /**
89      * Flag (value 2) indicating that a normal wizard based user interface consisting
90      * of a back, next, finish and cancel button should be used to present
91      * this refactoring wizard. This flag can't be specified together with
92      * the flag {@link #DIALOG_BASED_USER_INTERFACE}.
93      */

94     public static final int WIZARD_BASED_USER_INTERFACE= 1 << 1;
95     
96     /**
97      * Flag (value 4) indicating that a lightweight dialog based user interface should
98      * be used to present this refactoring wizard. This user interface consists
99      * of a preview, finish and cancel button and the initial size of dialog
100      * is based on the first user input page. This flag is only valid if only
101      * one user input page is present. Specifying this flag together with more
102      * than one input page will result in an exception when adding the user input
103      * pages. This flag can't be specified together with the flag
104      * {@link #WIZARD_BASED_USER_INTERFACE}.
105      *
106      * @since 3.1
107      */

108     public static final int DIALOG_BASED_USER_INTERFACE= 1 << 2;
109     
110     /**
111      * @deprecated Use {@link #DIALOG_BASED_USER_INTERFACE} instead.
112      */

113     public static final int DIALOG_BASED_UESR_INTERFACE= DIALOG_BASED_USER_INTERFACE;
114     
115     /**
116      * Flag (value 8) indicating that the finish and cancel button should be named
117      * yes and no. The flag is ignored if the flag {@link #WIZARD_BASED_USER_INTERFACE}
118      * is specified.
119      */

120     public static final int YES_NO_BUTTON_STYLE= 1 << 3;
121     
122     /**
123      * Flag (value 16) indicating that the wizard should not show a preview page.
124      * The flag is ignored if the flag {@link #WIZARD_BASED_USER_INTERFACE}
125      * is specified.
126      * */

127     public static final int NO_PREVIEW_PAGE= 1 << 4;
128     
129     /**
130      * Flag (value 32) indicating that the first change node presented in the
131      * preview page should be fully expanded.
132      */

133     public static final int PREVIEW_EXPAND_FIRST_NODE= 1 << 5;
134
135     /**
136      * Flag (value 64) indicating that the dialog representing the refactoring
137      * status to the user will not contain a back button. The flag
138      * is ignored if the flag (@link #WIZARD_BASED_USER_INTERFACE}
139      * is specified.
140      */

141     public static final int NO_BACK_BUTTON_ON_STATUS_DIALOG= 1 << 6;
142     
143     private static final int LAST= 1 << 7;
144     
145     private int fFlags;
146     private Refactoring fRefactoring;
147     private String JavaDoc fDefaultPageTitle;
148     
149     private Change fChange;
150     private RefactoringStatus fInitialConditionCheckingStatus= new RefactoringStatus();
151     private RefactoringStatus fConditionCheckingStatus;
152     
153     private int fUserInputPages;
154     private boolean fInAddPages;
155     
156     private boolean fIsChangeCreationCancelable;
157     private boolean fForcePreviewReview;
158     private boolean fPreviewShown;
159     
160     /**
161      * Creates a new refactoring wizard for the given refactoring.
162      *
163      * @param refactoring the refactoring the wizard is presenting
164      * @param flags flags specifying the behavior of the wizard. If neither
165      * <code>WIZARD_BASED_USER_INTERFACE</code> nor <code>DIALOG_BASED_UESR_INTERFACE</code>
166      * is specified then <code>WIZARD_BASED_USER_INTERFACE</code> will be
167      * taken as a default.
168      */

169     public RefactoringWizard(Refactoring refactoring, int flags) {
170         Assert.isNotNull(refactoring);
171         Assert.isTrue(flags < LAST);
172         if ((flags & DIALOG_BASED_USER_INTERFACE) == 0)
173             flags |= WIZARD_BASED_USER_INTERFACE;
174         Assert.isTrue((flags & DIALOG_BASED_USER_INTERFACE) != 0 || (flags & WIZARD_BASED_USER_INTERFACE) != 0);
175         fRefactoring= refactoring;
176         fFlags= flags;
177         setNeedsProgressMonitor(true);
178         setChangeCreationCancelable(true);
179         setWindowTitle(RefactoringUIMessages.RefactoringWizard_title);
180         setDefaultPageImageDescriptor(RefactoringPluginImages.DESC_WIZBAN_REFACTOR);
181     }
182     
183     //---- Setter and Getters ------------------------------------------------------------
184

185     /**
186      * Returns the refactoring this wizard is associated with.
187      *
188      * @return the wizard's refactoring
189      */

190     public final Refactoring getRefactoring(){
191         return fRefactoring;
192     }
193     
194     /**
195      * Sets the default page title to the given value. This value is used
196      * as a page title for wizard pages which don't provide their own
197      * page title. Setting this value has only an effect as long as the
198      * user interface hasn't been created yet.
199      *
200      * @param defaultPageTitle the default page title.
201      * @see Wizard#setDefaultPageImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)
202      */

203     public final void setDefaultPageTitle(String JavaDoc defaultPageTitle) {
204         Assert.isNotNull(defaultPageTitle);
205         fDefaultPageTitle= defaultPageTitle;
206     }
207     
208     /**
209      * Returns the default page title used for pages that don't provide their
210      * own page title.
211      *
212      * @return the default page title or <code>null</code> if non has been set
213      *
214      * @see #setDefaultPageTitle(String)
215      */

216     public final String JavaDoc getDefaultPageTitle() {
217         return fDefaultPageTitle;
218     }
219     
220     /**
221      * If set to <code>true</code> the Finish or OK button, respectively will
222      * be disabled until the user has visited the preview page. If set to
223      * <code>false</code> the refactoring can be performed before the preview
224      * page has been visited.
225      *
226      * @param forcePreviewReview if <code>true</code> to user must confirm the
227      * preview
228      */

229     public final void setForcePreviewReview(boolean forcePreviewReview) {
230         fForcePreviewReview= forcePreviewReview;
231         IWizardContainer container= getContainer();
232         if (container != null)
233             container.updateButtons();
234     }
235     
236     /**
237      * Returns the width in characters to be used for the message line embedded into
238      * the refactoring wizard dialog.
239      * <p>
240      * Subclasses may override this method and return a different value.
241      * </p>
242      *
243      * @return the message lines width in characters
244      */

245     public int getMessageLineWidthInChars() {
246         return 80;
247     }
248     
249     /**
250      * If set to <code>true</code> the change creation is cancelable by the user.
251      * <p>
252      * By default, change creation is cancelable.
253      * </p>
254      * @param isChangeCreationCancelable determines whether the change creation
255      * is cancelable by the user or not.
256      *
257      * @see Refactoring#createChange(IProgressMonitor)
258      */

259     public final void setChangeCreationCancelable(boolean isChangeCreationCancelable){
260         fIsChangeCreationCancelable= isChangeCreationCancelable;
261     }
262     
263     /**
264      * Sets the initial condition checking status computed by the refactoring.
265      * Clients should uses this method if the initial condition checking
266      * status has been computed outside of this refactoring wizard.
267      *
268      * @param status the initial condition checking status.
269      *
270      * @see Refactoring#checkInitialConditions(IProgressMonitor)
271      * @see #CHECK_INITIAL_CONDITIONS_ON_OPEN
272      */

273     public final void setInitialConditionCheckingStatus(RefactoringStatus status) {
274         Assert.isNotNull(status);
275         fInitialConditionCheckingStatus= status;
276         setConditionCheckingStatus(status);
277     }
278         
279     /**
280      * Returns the refactoring's change object or <code>null</code> if no change
281      * object has been created yet.
282      *
283      * @return the refactoring's change object or <code>null</code>
284      *
285      * @see Refactoring#createChange(IProgressMonitor)
286      */

287     public final Change getChange() {
288         return fChange;
289     }
290     
291     /**
292      * Returns the status of the initial condition checking or <code>null</code>
293      * if the initial condition checking hasn't been performed yet.
294      *
295      * @return the status of the initial condition checking or <code>null</code>
296      *
297      * @see Refactoring#checkInitialConditions(IProgressMonitor)
298      */

299     /* package */ final RefactoringStatus getInitialConditionCheckingStatus() {
300         return fInitialConditionCheckingStatus;
301     }
302     
303     /**
304      * Returns <code>true</code> if the wizard needs a wizard based user interface.
305      * Otherwise <code>false</code> is returned.
306      *
307      * @return whether the wizard needs a wizard based user interface or not
308      */

309     /* package */ boolean needsWizardBasedUserInterface() {
310         return (fFlags & WIZARD_BASED_USER_INTERFACE) != 0;
311     }
312     
313     //---- Page management ------------------------------------------------------------
314

315     /**
316      * {@inheritDoc}
317      *
318      * This method calls the hook method {@link #addUserInputPages()} to allow
319      * subclasses to add specific user input pages.
320      */

321     public final void addPages() {
322         Assert.isNotNull(fRefactoring);
323         try {
324             fInAddPages= true;
325             if (checkActivationOnOpen()) {
326                 internalCheckCondition(CheckConditionsOperation.INITIAL_CONDITONS);
327             }
328             if (fInitialConditionCheckingStatus.hasFatalError()) {
329                 addErrorPage();
330                 // Set the status since we added the error page
331
setConditionCheckingStatus(getConditionCheckingStatus());
332             } else {
333                 Assert.isTrue(getPageCount() == 0);
334                 addUserInputPages();
335                 fUserInputPages= getPageCount();
336                 if (fUserInputPages > 0) {
337                     IWizardPage[] pages= getPages();
338                     ((UserInputWizardPage)pages[fUserInputPages - 1]).markAsLastUserInputPage();
339                 }
340                 addErrorPage();
341                 addPreviewPage();
342             }
343             initializeDefaultPageTitles();
344         } finally {
345             fInAddPages= false;
346         }
347     }
348     
349     /**
350      * {@inheritDoc}
351      *
352      * This method asserts that the pages added to the refactoring wizard
353      * are instances of type {@link RefactoringWizardPage}.
354      */

355     public final void addPage(IWizardPage page) {
356         Assert.isTrue(page instanceof RefactoringWizardPage && fInAddPages);
357         super.addPage(page);
358     }
359     
360     /**
361      * Hook method to add user input pages to this refactoring wizard. Pages
362      * added via this call have to be instances of the type {@link UserInputWizardPage}.
363      * Adding pages of a different kind is not permitted and will result
364      * in unexpected behavior.
365      */

366     protected abstract void addUserInputPages();
367     
368     private void addErrorPage(){
369         addPage(new ErrorWizardPage());
370     }
371     
372     private void addPreviewPage(){
373         addPage(new PreviewWizardPage());
374     }
375     
376     private boolean hasUserInput() {
377         return fUserInputPages > 0;
378     }
379     
380     private void initializeDefaultPageTitles() {
381         if (fDefaultPageTitle == null)
382             return;
383             
384         IWizardPage[] pages= getPages();
385         for (int i= 0; i < pages.length; i++) {
386             IWizardPage page= pages[i];
387             if (page.getTitle() == null)
388                 page.setTitle(fDefaultPageTitle);
389         }
390     }
391     
392     //---- Page computation -----------------------------------------------------------
393

394     /**
395      * {@inheritDoc}
396      */

397     public IWizardPage getStartingPage() {
398         if (hasUserInput())
399             return super.getStartingPage();
400         
401         /*
402          * XXX: Can return null if there's no user input page and change creation has been cancelled.
403          * The only way to avoid this would be setChangeCreationCancelable(true).
404          */

405         return computeUserInputSuccessorPage(null, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
406     }
407     
408     /**
409      * {@inheritDoc}
410      */

411     public IWizardPage getPreviousPage(IWizardPage page) {
412         if (hasUserInput())
413             return super.getPreviousPage(page);
414         if (! page.getName().equals(IErrorWizardPage.PAGE_NAME)){
415             if (fConditionCheckingStatus.isOK())
416                 return null;
417         }
418         return super.getPreviousPage(page);
419     }
420
421     /* package */ IWizardPage computeUserInputSuccessorPage(IWizardPage caller, IRunnableContext context) {
422         Change change= createChange(new CreateChangeOperation(
423             new CheckConditionsOperation(fRefactoring, CheckConditionsOperation.FINAL_CONDITIONS),
424             RefactoringStatus.FATAL), true, context);
425         // Status has been updated since we have passed true
426
RefactoringStatus status= getConditionCheckingStatus();
427         
428         // Creating the change has been canceled
429
if (change == null && status == null) {
430             internalSetChange(InternalAPI.INSTANCE, change);
431             return caller;
432         }
433                 
434         // Set change if we don't have fatal errors.
435
if (!status.hasFatalError())
436             internalSetChange(InternalAPI.INSTANCE, change);
437         
438         if (status.isOK()) {
439             return getPage(IPreviewWizardPage.PAGE_NAME);
440         } else {
441             return getPage(IErrorWizardPage.PAGE_NAME);
442         }
443     }
444     
445     /**
446      * {@inheritDoc}
447      */

448     public boolean canFinish() {
449         if (fForcePreviewReview && !fPreviewShown)
450             return false;
451         return super.canFinish();
452     }
453
454     //---- Condition checking ------------------------------------------------------------
455

456     /* package */ final RefactoringStatus checkFinalConditions() {
457         return internalCheckCondition(CheckConditionsOperation.FINAL_CONDITIONS);
458     }
459     
460     private RefactoringStatus internalCheckCondition(int style) {
461         
462         CheckConditionsOperation op= new CheckConditionsOperation(fRefactoring, style);
463
464         Exception JavaDoc exception= null;
465         try {
466             PlatformUI.getWorkbench().getProgressService().busyCursorWhile(
467                 new WorkbenchRunnableAdapter(op, ResourcesPlugin.getWorkspace().getRoot()));
468         } catch (InterruptedException JavaDoc e) {
469             exception= e;
470         } catch (InvocationTargetException JavaDoc e) {
471             exception= e;
472         }
473         RefactoringStatus status= null;
474         if (exception != null) {
475             RefactoringUIPlugin.log(exception);
476             status= new RefactoringStatus();
477             status.addFatalError(RefactoringUIMessages.RefactoringWizard_internal_error_1);
478         } else {
479             status= op.getStatus();
480         }
481         setConditionCheckingStatus(status, style);
482         return status;
483     }
484     
485     private void setConditionCheckingStatus(RefactoringStatus status, int style) {
486         if ((style & CheckConditionsOperation.ALL_CONDITIONS) == CheckConditionsOperation.ALL_CONDITIONS)
487             setConditionCheckingStatus(status);
488         else if ((style & CheckConditionsOperation.INITIAL_CONDITONS) == CheckConditionsOperation.INITIAL_CONDITONS)
489             setInitialConditionCheckingStatus(status);
490         else if ((style & CheckConditionsOperation.FINAL_CONDITIONS) == CheckConditionsOperation.FINAL_CONDITIONS)
491             setFinalConditionCheckingStatus(status);
492     }
493
494     private RefactoringStatus getConditionCheckingStatus() {
495         return fConditionCheckingStatus;
496     }
497         
498     /**
499      * Sets the refactoring status.
500      *
501      * @param status the refactoring status to set.
502      */

503     /* package */ final void setConditionCheckingStatus(RefactoringStatus status) {
504         ErrorWizardPage page= (ErrorWizardPage)getPage(IErrorWizardPage.PAGE_NAME);
505         if (page != null)
506             page.setStatus(status);
507         fConditionCheckingStatus= status;
508     }
509     
510     /**
511      * Sets the refactoring status returned from final condition checking. Any previously
512      * computed initial status is merged into the given status before it is set to the
513      * error page.
514      *
515      * @param status the final condition checking status to set
516      */

517     private void setFinalConditionCheckingStatus(RefactoringStatus status) {
518         RefactoringStatus newStatus= new RefactoringStatus();
519         if (fInitialConditionCheckingStatus != null)
520             newStatus.merge(fInitialConditionCheckingStatus);
521         newStatus.merge(status);
522         setConditionCheckingStatus(newStatus);
523     }
524     
525     //---- Change management -------------------------------------------------------------
526

527     /**
528      * Note: This method is for internal use only. Clients are not allowed to call this method.
529      *
530      * @param api internal instance to avoid access from external clients
531      * @param operation the create change operation
532      * @param updateStatus flag indicating if status updating is requested
533      *
534      * @return the created change
535      */

536     public final Change internalCreateChange(InternalAPI api, CreateChangeOperation operation, boolean updateStatus) {
537         Assert.isNotNull(api);
538         return createChange(operation, updateStatus, getContainer());
539     }
540
541     /**
542      * Note: This method is for internal use only. Clients are not allowed to call this method.
543      *
544      * @param api internal instance to avoid access from external clients
545      * @param op the perform change operation
546      *
547      * @return whether the finish ended OK or not
548      */

549     public final FinishResult internalPerformFinish(InternalAPI api, PerformChangeOperation op) {
550         op.setUndoManager(RefactoringCore.getUndoManager(), fRefactoring.getName());
551         Shell parent= getContainer().getShell();
552         try{
553             getContainer().run(true, true, new WorkbenchRunnableAdapter(op, ResourcesPlugin.getWorkspace().getRoot()));
554         } catch (InvocationTargetException JavaDoc e) {
555             Throwable JavaDoc inner= e.getTargetException();
556             if (op.changeExecutionFailed()) {
557                 ChangeExceptionHandler handler= new ChangeExceptionHandler(parent, fRefactoring);
558                 if (inner instanceof RuntimeException JavaDoc) {
559                     handler.handle(op.getChange(), (RuntimeException JavaDoc)inner);
560                     return FinishResult.createException();
561                 } else if (inner instanceof CoreException) {
562                     handler.handle(op.getChange(), (CoreException)inner);
563                     return FinishResult.createException();
564                 }
565             }
566             ExceptionHandler.handle(e, parent,
567                 RefactoringUIMessages.RefactoringWizard_refactoring,
568                 RefactoringUIMessages.RefactoringWizard_unexpected_exception_1);
569             return FinishResult.createException();
570         } catch (InterruptedException JavaDoc e) {
571             return FinishResult.createInterrupted();
572         }
573         return FinishResult.createOK();
574     }
575     
576     private Change createChange(CreateChangeOperation operation, boolean updateStatus, IRunnableContext context){
577         InvocationTargetException JavaDoc exception= null;
578         try {
579             context.run(true, fIsChangeCreationCancelable, new WorkbenchRunnableAdapter(
580                 operation, ResourcesPlugin.getWorkspace().getRoot()));
581         } catch (InterruptedException JavaDoc e) {
582             setConditionCheckingStatus(null);
583             return null;
584         } catch (InvocationTargetException JavaDoc e) {
585             exception= e;
586         }
587         
588         if (updateStatus) {
589             RefactoringStatus status= null;
590             if (exception != null) {
591                 status= new RefactoringStatus();
592                 String JavaDoc msg= exception.getMessage();
593                 if (msg != null) {
594                     status.addFatalError(Messages.format(RefactoringUIMessages.RefactoringWizard_see_log, msg));
595                 } else {
596                     status.addFatalError(RefactoringUIMessages.RefactoringWizard_Internal_error);
597                 }
598                 RefactoringUIPlugin.log(exception);
599             } else {
600                 status= operation.getConditionCheckingStatus();
601             }
602             setConditionCheckingStatus(status, operation.getConditionCheckingStyle());
603         } else {
604             if (exception != null)
605                 ExceptionHandler.handle(exception, getContainer().getShell(),
606                     RefactoringUIMessages.RefactoringWizard_refactoring,
607                     RefactoringUIMessages.RefactoringWizard_unexpected_exception);
608         }
609         Change change= operation.getChange();
610         return change;
611     }
612
613     //---- Re-implementation of Wizard methods --------------------------------------------
614

615     public boolean performFinish() {
616         Assert.isNotNull(fRefactoring);
617         
618         RefactoringWizardPage page= (RefactoringWizardPage)getContainer().getCurrentPage();
619         return page.performFinish();
620     }
621     
622     public boolean performCancel() {
623         if (fChange != null)
624             fChange.dispose();
625         return super.performCancel();
626     }
627     
628     //---- Internal API, but public due to Java constraints ------------------------------
629

630     /**
631      * Note: This method is for internal use only. Clients are not allowed to call this method.
632      *
633      * @param api internal instance to avoid access from external clients
634      *
635      * @return whether the wizard has a preview page or not.
636      */

637     public final boolean internalHasPreviewPage(InternalAPI api) {
638         Assert.isNotNull(api);
639         return (fFlags & NO_PREVIEW_PAGE) == 0;
640     }
641     
642     /**
643      * Note: This method is for internal use only. Clients are not allowed to call this method.
644      *
645      * @param api internal instance to avoid access from external clients
646      *
647      * @return whether yes no button style is requested
648      */

649     public final boolean internalIsYesNoStyle(InternalAPI api) {
650         Assert.isNotNull(api);
651         return (fFlags & YES_NO_BUTTON_STYLE) != 0;
652     }
653     
654     /**
655      * Note: This method is for internal use only. Clients are not allowed to call this method.
656      *
657      * @param api internal instance to avoid access from external clients
658      *
659      * @return whether the first node of the preview is supposed to be expanded
660      */

661     public final boolean internalGetExpandFirstNode(InternalAPI api) {
662         Assert.isNotNull(api);
663         return (fFlags & PREVIEW_EXPAND_FIRST_NODE) != 0;
664     }
665     
666     /**
667      * Note: This method is for internal use only. Clients are not allowed to call this method.
668      *
669      * @param api internal instance to avoid access from external clients
670      * @param change the change to set
671      */

672     public final void internalSetChange(InternalAPI api, Change change){
673         Assert.isNotNull(api);
674         IPreviewWizardPage page= (IPreviewWizardPage)getPage(IPreviewWizardPage.PAGE_NAME);
675         if (page != null)
676             page.setChange(change);
677         fChange= change;
678     }
679
680     /**
681      * Note: This method is for internal use only. Clients are not allowed to call this method.
682      *
683      * @param api internal instance to avoid access from external clients
684      * @param shown a boolean indicating if the preview page has been shown or not
685      */

686     public final void internalSetPreviewShown(InternalAPI api, boolean shown) {
687         Assert.isNotNull(api);
688         fPreviewShown= shown;
689         getContainer().updateButtons();
690     }
691     
692     /**
693      * Note: This method is for internal use only. Clients are not allowed to call this method.
694      *
695      * @param api internal instance to avoid access from external clients
696      * @return whether to show a back button or not
697      */

698     public final boolean internalShowBackButtonOnStatusDialog(InternalAPI api) {
699         Assert.isNotNull(api);
700         return (fFlags & NO_BACK_BUTTON_ON_STATUS_DIALOG) == 0;
701     }
702     
703     //---- Helper methods to check style bits --------------------------------------------
704

705     private boolean checkActivationOnOpen() {
706         return (fFlags & CHECK_INITIAL_CONDITIONS_ON_OPEN) != 0;
707     }
708 }
709
Popular Tags