KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > keys > KeyAssistDialog


1 /*******************************************************************************
2  * Copyright (c) 2004, 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.ui.internal.keys;
13
14 import java.util.ArrayList JavaDoc;
15 import java.util.Collection JavaDoc;
16 import java.util.Comparator JavaDoc;
17 import java.util.Iterator JavaDoc;
18 import java.util.List JavaDoc;
19 import java.util.Map JavaDoc;
20 import java.util.ResourceBundle JavaDoc;
21 import java.util.SortedMap JavaDoc;
22 import java.util.TreeMap JavaDoc;
23
24 import org.eclipse.core.commands.Command;
25 import org.eclipse.core.commands.ParameterizedCommand;
26 import org.eclipse.core.commands.common.CommandException;
27 import org.eclipse.core.commands.common.NotDefinedException;
28 import org.eclipse.jface.bindings.Binding;
29 import org.eclipse.jface.bindings.TriggerSequence;
30 import org.eclipse.jface.bindings.keys.KeySequence;
31 import org.eclipse.jface.bindings.keys.KeyStroke;
32 import org.eclipse.jface.dialogs.Dialog;
33 import org.eclipse.jface.dialogs.PopupDialog;
34 import org.eclipse.jface.preference.PreferenceDialog;
35 import org.eclipse.jface.window.Window;
36 import org.eclipse.swt.SWT;
37 import org.eclipse.swt.graphics.Point;
38 import org.eclipse.swt.graphics.Rectangle;
39 import org.eclipse.swt.layout.GridData;
40 import org.eclipse.swt.layout.GridLayout;
41 import org.eclipse.swt.widgets.Composite;
42 import org.eclipse.swt.widgets.Control;
43 import org.eclipse.swt.widgets.Event;
44 import org.eclipse.swt.widgets.Label;
45 import org.eclipse.swt.widgets.Listener;
46 import org.eclipse.swt.widgets.Shell;
47 import org.eclipse.swt.widgets.Table;
48 import org.eclipse.swt.widgets.TableColumn;
49 import org.eclipse.swt.widgets.TableItem;
50 import org.eclipse.ui.IWorkbench;
51 import org.eclipse.ui.activities.IActivityManager;
52 import org.eclipse.ui.commands.ICommandService;
53 import org.eclipse.ui.contexts.IContextService;
54 import org.eclipse.ui.dialogs.PreferencesUtil;
55 import org.eclipse.ui.internal.util.Util;
56 import org.eclipse.ui.keys.IBindingService;
57
58 import com.ibm.icu.text.MessageFormat;
59
60 /**
61  * <p>
62  * A dialog displaying a list of key bindings. The dialog will execute a command
63  * if it is selected.
64  * </p>
65  * <p>
66  * The methods on this class are not thread-safe and must be run from the UI
67  * thread.
68  * </p>
69  *
70  * @since 3.1
71  */

72 final class KeyAssistDialog extends PopupDialog {
73
74     /**
75      * The data key for the binding stored on an SWT widget. The key is a
76      * fully-qualified name, but in reverse order. This is so that the equals
77      * method will detect misses faster.
78      */

79     private static final String JavaDoc BINDING_KEY = "Binding.bindings.jface.eclipse.org"; //$NON-NLS-1$
80

81     /**
82      * The value of <code>previousWidth</code> to set if there is no
83      * remembered width.
84      */

85     private static final int NO_REMEMBERED_WIDTH = -1;
86
87     /**
88      * The translation bundle in which to look up internationalized text.
89      */

90     private static final ResourceBundle JavaDoc RESOURCE_BUNDLE = ResourceBundle
91             .getBundle(KeyAssistDialog.class.getName());
92
93     /**
94      * The activity manager for the associated workbench.
95      */

96     private final IActivityManager activityManager;
97
98     /**
99      * The binding service for the associated workbench.
100      */

101     private final IBindingService bindingService;
102
103     /**
104      * The binding that was selected when the key assist dialog last closed.
105      * This is only remembered until <code>clearRememberedState()</code> is
106      * called.
107      */

108     private Binding binding = null;
109
110     /**
111      * The ordered list of command identifiers corresponding to the table.
112      */

113     private final List JavaDoc bindings = new ArrayList JavaDoc();
114
115     /**
116      * The command service for the associated workbench.
117      */

118     private final ICommandService commandService;
119
120     /**
121      * The table containing of the possible completions. This value is
122      * <code>null</code> until the dialog is created.
123      */

124     private Table completionsTable = null;
125
126     /**
127      * Whether this dialog is currently holding some remembered state.
128      */

129     private boolean hasRememberedState = false;
130
131     /**
132      * The key binding state for the associated workbench.
133      */

134     private final KeyBindingState keyBindingState;
135
136     /**
137      * The width of the shell when it was previously open. This is only
138      * remembered until <code>clearRememberedState()</code> is called.
139      */

140     private int previousWidth = NO_REMEMBERED_WIDTH;
141
142     /**
143      * The key binding listener for the associated workbench.
144      */

145     private final WorkbenchKeyboard workbenchKeyboard;
146
147     /**
148      * A sorted map of conflicts to be used when the dialog pops up.
149      *
150      * @since 3.3
151      */

152     private SortedMap JavaDoc conflictMatches;
153
154     /**
155      * Constructs a new instance of <code>KeyAssistDialog</code>. When the
156      * dialog is first constructed, it contains no widgets. The dialog is first
157      * created with no parent. If a parent is required, call
158      * <code>setParentShell()</code>. Also, between uses, it might be
159      * necessary to call <code>setParentShell()</code> as well.
160      *
161      * @param workbench
162      * The workbench in which this dialog is created; must not be
163      * <code>null</code>.
164      * @param associatedKeyboard
165      * The key binding listener for the workbench; must not be
166      * <code>null</code>.
167      * @param associatedState
168      * The key binding state associated with the workbench; must not
169      * be <code>null</code>.
170      */

171     KeyAssistDialog(final IWorkbench workbench,
172             final WorkbenchKeyboard associatedKeyboard,
173             final KeyBindingState associatedState) {
174         super((Shell) null, PopupDialog.INFOPOPUP_SHELLSTYLE, true, false,
175                 false, false, null, null);
176
177         this.activityManager = workbench.getActivitySupport()
178                 .getActivityManager();
179         this.bindingService = (IBindingService) workbench
180                 .getService(IBindingService.class);
181         this.commandService = (ICommandService) workbench
182                 .getService(ICommandService.class);
183         this.keyBindingState = associatedState;
184         this.workbenchKeyboard = associatedKeyboard;
185
186         this.setInfoText(getKeySequenceString());
187     }
188
189     /**
190      * Clears out the remembered state of the key assist dialog. This includes
191      * its width, as well as the selected binding.
192      */

193     final void clearRememberedState() {
194         previousWidth = NO_REMEMBERED_WIDTH;
195         binding = null;
196         hasRememberedState = false;
197     }
198
199     /**
200      * Closes this shell, but first remembers some state of the dialog. This way
201      * it will have a response if asked to open the dialog again or if asked to
202      * open the keys preference page. This does not remember the internal state.
203      *
204      * @return Whether the shell was already closed.
205      */

206     public final boolean close() {
207         return close(false);
208     }
209
210     /**
211      * Closes this shell, but first remembers some state of the dialog. This way
212      * it will have a response if asked to open the dialog again or if asked to
213      * open the keys preference page.
214      *
215      * @param rememberState
216      * Whether the internal state should be remembered.
217      * @return Whether the shell was already closed.
218      */

219     public final boolean close(final boolean rememberState) {
220         return close(rememberState, true);
221     }
222
223     /**
224      * Closes this shell, but first remembers some state of the dialog. This way
225      * it will have a response if asked to open the dialog again or if asked to
226      * open the keys preference page.
227      *
228      * @param rememberState
229      * Whether the internal state should be remembered.
230      * @param resetState
231      * Whether the state should be reset.
232      * @return Whether the shell was already closed.
233      */

234     private final boolean close(final boolean rememberState,
235             final boolean resetState) {
236         final Shell shell = getShell();
237         if (rememberState) {
238             // Remember the previous width.
239
final int widthToRemember;
240             if ((shell != null) && (!shell.isDisposed())) {
241                 widthToRemember = getShell().getSize().x;
242             } else {
243                 widthToRemember = NO_REMEMBERED_WIDTH;
244             }
245
246             // Remember the selected command name and key sequence.
247
final Binding bindingToRemember;
248             if ((completionsTable != null) && (!completionsTable.isDisposed())) {
249                 final int selectedIndex = completionsTable.getSelectionIndex();
250                 if (selectedIndex != -1) {
251                     final TableItem selectedItem = completionsTable
252                             .getItem(selectedIndex);
253                     bindingToRemember = (Binding) selectedItem
254                             .getData(BINDING_KEY);
255                 } else {
256                     bindingToRemember = null;
257                 }
258             } else {
259                 bindingToRemember = null;
260             }
261
262             rememberState(widthToRemember, bindingToRemember);
263             completionsTable = null;
264         }
265
266         if (resetState) {
267             keyBindingState.reset();
268         }
269         return super.close();
270     }
271
272     /**
273      * Sets the position for the dialog based on the position of the workbench
274      * window. The dialog is flush with the bottom right corner of the workbench
275      * window. However, the dialog will not appear outside of the display's
276      * client area.
277      *
278      * @param size
279      * The final size of the dialog; must not be <code>null</code>.
280      */

281     private final void configureLocation(final Point size) {
282         final Shell shell = getShell();
283
284         final Shell workbenchWindowShell = keyBindingState
285                 .getAssociatedWindow().getShell();
286         final int xCoord;
287         final int yCoord;
288         if (workbenchWindowShell != null) {
289             /*
290              * Position the shell at the bottom right corner of the workbench
291              * window
292              */

293             final Rectangle workbenchWindowBounds = workbenchWindowShell
294                     .getBounds();
295             xCoord = workbenchWindowBounds.x + workbenchWindowBounds.width
296                     - size.x - 10;
297             yCoord = workbenchWindowBounds.y + workbenchWindowBounds.height
298                     - size.y - 10;
299
300         } else {
301             xCoord = 0;
302             yCoord = 0;
303
304         }
305         final Rectangle bounds = new Rectangle(xCoord, yCoord, size.x, size.y);
306         shell.setBounds(getConstrainedShellBounds(bounds));
307     }
308
309     /**
310      * Sets the size for the dialog based on its previous size. The width of the
311      * dialog is its previous width, if it exists. Otherwise, it is simply the
312      * packed width of the dialog. The maximum width is 40% of the workbench
313      * window's width. The dialog's height is the packed height of the dialog to
314      * a maximum of half the height of the workbench window.
315      *
316      * @return The size of the dialog
317      */

318     private final Point configureSize() {
319         final Shell shell = getShell();
320
321         // Get the packed size of the shell.
322
shell.pack();
323         final Point size = shell.getSize();
324
325         // Use the previous width if appropriate.
326
if ((previousWidth != NO_REMEMBERED_WIDTH) && (previousWidth > size.x)) {
327             size.x = previousWidth;
328         }
329
330         // Enforce maximum sizing.
331
final Shell workbenchWindowShell = keyBindingState
332                 .getAssociatedWindow().getShell();
333         if (workbenchWindowShell != null) {
334             final Point workbenchWindowSize = workbenchWindowShell.getSize();
335             final int maxWidth = workbenchWindowSize.x * 2 / 5;
336             final int maxHeight = workbenchWindowSize.y / 2;
337             if (size.x > maxWidth) {
338                 size.x = maxWidth;
339             }
340             if (size.y > maxHeight) {
341                 size.y = maxHeight;
342             }
343         }
344
345         // Set the size for the shell.
346
shell.setSize(size);
347         return size;
348     }
349
350     /**
351      * Returns a string representing the key sequence used to open this dialog.
352      *
353      * @return the string describing the key sequence, or <code>null</code> if
354      * it cannot be determined.
355      */

356     private String JavaDoc getKeySequenceString() {
357         final Command command = commandService
358                 .getCommand("org.eclipse.ui.window.showKeyAssist"); //$NON-NLS-1$
359
final TriggerSequence[] keyBindings = bindingService
360                 .getActiveBindingsFor(new ParameterizedCommand(command, null));
361         final int keyBindingsCount = keyBindings.length;
362         final KeySequence currentState = keyBindingState.getCurrentSequence();
363         final int prefixSize = currentState.getKeyStrokes().length;
364
365         // Try to find the first possible matching key binding.
366
KeySequence keySequence = null;
367         for (int i = 0; i < keyBindingsCount; i++) {
368             keySequence = (KeySequence) keyBindings[i];
369
370             // Now just double-check to make sure the key is still possible.
371
if (prefixSize > 0) {
372                 if (keySequence.startsWith(currentState, false)) {
373                     /*
374                      * Okay, so we have a partial match. Replace the key binding
375                      * with the required suffix completion.
376                      */

377                     final KeyStroke[] oldKeyStrokes = keySequence
378                             .getKeyStrokes();
379                     final int newSize = oldKeyStrokes.length - prefixSize;
380                     final KeyStroke[] newKeyStrokes = new KeyStroke[newSize];
381                     System.arraycopy(oldKeyStrokes, prefixSize, newKeyStrokes,
382                             0, newSize);
383                     keySequence = KeySequence.getInstance(newKeyStrokes);
384                     break;
385                 }
386
387                 /*
388                  * The prefix doesn't match, so null out the key binding and try
389                  * again.
390                  */

391                 keySequence = null;
392                 continue;
393
394             }
395
396             // There is no prefix, so just grab the first.
397
break;
398         }
399         if (keySequence == null) {
400             return null; // couldn't find a suitable key binding
401
}
402
403         return MessageFormat.format(Util.translateString(RESOURCE_BUNDLE,
404                 "openPreferencePage"), //$NON-NLS-1$
405
new Object JavaDoc[] { keySequence.format() });
406     }
407
408     /**
409      * Creates the content area for the key assistant. This creates a table and
410      * places it inside the composite. The composite will contain a list of all
411      * the key bindings.
412      *
413      * @param parent
414      * The parent composite to contain the dialog area; must not be
415      * <code>null</code>.
416      */

417     protected final Control createDialogArea(final Composite parent) {
418         // First, register the shell type with the context support
419
registerShellType();
420
421         // Create a composite for the dialog area.
422
final Composite composite = new Composite(parent, SWT.NONE);
423         final GridLayout compositeLayout = new GridLayout();
424         compositeLayout.marginHeight = 0;
425         compositeLayout.marginWidth = 0;
426         composite.setLayout(compositeLayout);
427         composite.setLayoutData(new GridData(GridData.FILL_BOTH));
428         composite.setBackground(parent.getBackground());
429
430         // Layout the partial matches.
431
final SortedMap JavaDoc partialMatches;
432         if (conflictMatches != null) {
433             partialMatches = conflictMatches;
434             conflictMatches = null;
435         } else {
436             partialMatches = getPartialMatches();
437         }
438
439         if (partialMatches.isEmpty()) {
440             createEmptyDialogArea(composite);
441         } else {
442             createTableDialogArea(composite, partialMatches);
443         }
444         return composite;
445     }
446
447     /**
448      * Creates an empty dialog area with a simple message saying there were no
449      * matches. This is used if no partial matches could be found. This should
450      * not really ever happen, but might be possible if the commands are
451      * changing while waiting for this dialog to open.
452      *
453      * @param parent
454      * The parent composite for the dialog area; must not be
455      * <code>null</code>.
456      */

457     private final void createEmptyDialogArea(final Composite parent) {
458         final Label noMatchesLabel = new Label(parent, SWT.NULL);
459         noMatchesLabel.setText(Util.translateString(RESOURCE_BUNDLE,
460                 "NoMatches.Message")); //$NON-NLS-1$
461
noMatchesLabel.setLayoutData(new GridData(GridData.FILL_BOTH));
462         noMatchesLabel.setBackground(parent.getBackground());
463     }
464
465     /**
466      * Creates a dialog area with a table of the partial matches for the current
467      * key binding state. The table will be either the minimum width, or
468      * <code>previousWidth</code> if it is not
469      * <code>NO_REMEMBERED_WIDTH</code>.
470      *
471      * @param parent
472      * The parent composite for the dialog area; must not be
473      * <code>null</code>.
474      * @param partialMatches
475      * The lexicographically sorted map of partial matches for the
476      * current state; must not be <code>null</code> or empty.
477      */

478     private final void createTableDialogArea(final Composite parent,
479             final SortedMap JavaDoc partialMatches) {
480         // Layout the table.
481
completionsTable = new Table(parent, SWT.FULL_SELECTION | SWT.SINGLE);
482         final GridData gridData = new GridData(GridData.FILL_BOTH);
483         completionsTable.setLayoutData(gridData);
484         completionsTable.setBackground(parent.getBackground());
485         completionsTable.setLinesVisible(true);
486
487         // Initialize the columns and rows.
488
bindings.clear();
489         final TableColumn columnCommandName = new TableColumn(completionsTable,
490                 SWT.LEFT, 0);
491         final TableColumn columnKeySequence = new TableColumn(completionsTable,
492                 SWT.LEFT, 1);
493         final Iterator JavaDoc itemsItr = partialMatches.entrySet().iterator();
494         while (itemsItr.hasNext()) {
495             final Map.Entry JavaDoc entry = (Map.Entry JavaDoc) itemsItr.next();
496             final TriggerSequence sequence = (TriggerSequence) entry.getValue();
497             final Binding binding = (Binding) entry.getKey();
498             final ParameterizedCommand command = binding
499                     .getParameterizedCommand();
500             try {
501                 final String JavaDoc[] text = { command.getName(), sequence.format() };
502                 final TableItem item = new TableItem(completionsTable, SWT.NULL);
503                 item.setText(text);
504                 item.setData(BINDING_KEY, binding);
505                 bindings.add(binding);
506             } catch (NotDefinedException e) {
507                 // Not much to do, but this shouldn't really happen.
508
}
509         }
510
511         Dialog.applyDialogFont(parent);
512         columnKeySequence.pack();
513         if (previousWidth != NO_REMEMBERED_WIDTH) {
514             columnKeySequence.setWidth(previousWidth);
515         }
516         columnCommandName.pack();
517
518         /*
519          * If you double-click on the table, it should execute the selected
520          * command.
521          */

522         completionsTable.addListener(SWT.DefaultSelection, new Listener() {
523             public final void handleEvent(final Event event) {
524                 executeKeyBinding(event);
525             }
526         });
527     }
528
529     /**
530      * Edits the remembered selection in the preference dialog.
531      */

532     private final void editKeyBinding() {
533         // Create a preference dialog on the keys preference page.
534
final String JavaDoc keysPageId = "org.eclipse.ui.preferencePages.Keys"; //$NON-NLS-1$
535
final PreferenceDialog dialog = PreferencesUtil
536                 .createPreferenceDialogOn(getShell(), keysPageId, null, binding);
537
538         /*
539          * Forget the remembered state (so we don't get stuck editing
540          * preferences).
541          */

542         clearRememberedState();
543
544         // Open the dialog (blocking).
545
dialog.open();
546     }
547
548     /**
549      * Handles the default selection event on the table of possible completions.
550      * This attempts to execute the given command.
551      */

552     private final void executeKeyBinding(final Event trigger) {
553         // Try to execute the corresponding command.
554
final int selectionIndex = completionsTable.getSelectionIndex();
555         if (selectionIndex >= 0) {
556             final Binding binding = (Binding) bindings.get(selectionIndex);
557             try {
558                 workbenchKeyboard.executeCommand(binding, trigger);
559             } catch (final CommandException e) {
560                 workbenchKeyboard.logException(e, binding
561                         .getParameterizedCommand());
562             }
563         }
564     }
565
566     /**
567      * Gets the list of key bindings that are partial matches to the current key
568      * binding state.
569      *
570      * @return A sorted map of key sequences (KeySequence) to command identifier
571      * (String) representing the list of enabled commands that could
572      * possibly complete the current key sequence.
573      */

574     private final SortedMap JavaDoc getPartialMatches() {
575         // Put all partial matches into the matches into the map.
576
final Map JavaDoc partialMatches = bindingService
577                 .getPartialMatches(keyBindingState.getCurrentSequence());
578
579         // Create a sorted map that sorts based on lexicographical order.
580
final SortedMap JavaDoc sortedMatches = new TreeMap JavaDoc(new Comparator JavaDoc() {
581             public final int compare(final Object JavaDoc a, final Object JavaDoc b) {
582                 final Binding bindingA = (Binding) a;
583                 final Binding bindingB = (Binding) b;
584                 final ParameterizedCommand commandA = bindingA
585                         .getParameterizedCommand();
586                 final ParameterizedCommand commandB = bindingB
587                         .getParameterizedCommand();
588                 try {
589                     return commandA.getName().compareTo(commandB.getName());
590                 } catch (final NotDefinedException e) {
591                     // should not happen
592
return 0;
593                 }
594             }
595         });
596
597         /*
598          * Remove those partial matches for which either the command is not
599          * identified or the activity manager believes the command is not
600          * enabled.
601          */

602         final Iterator JavaDoc partialMatchItr = partialMatches.entrySet().iterator();
603         while (partialMatchItr.hasNext()) {
604             final Map.Entry JavaDoc entry = (Map.Entry JavaDoc) partialMatchItr.next();
605             final Binding binding = (Binding) entry.getValue();
606             final Command command = binding.getParameterizedCommand()
607                     .getCommand();
608             if (command.isDefined()
609                     && activityManager.getIdentifier(command.getId())
610                             .isEnabled()) {
611                 sortedMatches.put(binding, entry.getKey());
612             }
613         }
614
615         return sortedMatches;
616
617     }
618
619     /**
620      * Returns whether the dialog is currently holding some remembered state.
621      *
622      * @return <code>true</code> if the dialog has remembered state;
623      * <code>false</code> otherwise.
624      */

625     private final boolean hasRememberedState() {
626         return hasRememberedState;
627     }
628
629     /**
630      * Opens this dialog. This method can be called multiple times on the same
631      * dialog. This only opens the dialog if there is no remembered state; if
632      * there is remembered state, then it tries to open the preference page
633      * instead.
634      *
635      * @return The return code from this dialog.
636      */

637     public final int open() {
638         // If there is remember state, open the preference page.
639
if (hasRememberedState()) {
640             editKeyBinding();
641             clearRememberedState();
642             return Window.OK;
643         }
644
645         // If the dialog is already open, dispose the shell and recreate it.
646
final Shell shell = getShell();
647         if (shell != null) {
648             close(false, false);
649         }
650         create();
651
652         // Configure the size and location.
653
final Point size = configureSize();
654         configureLocation(size);
655
656         // Call the super method.
657
return super.open();
658     }
659
660     /**
661      * Opens this dialog with the list of bindings for the user to select from.
662      *
663      * @return The return code from this dialog.
664      * @since 3.3
665      */

666     public final int open(Collection JavaDoc bindings) {
667         conflictMatches = new TreeMap JavaDoc(new Comparator JavaDoc() {
668             public final int compare(final Object JavaDoc a, final Object JavaDoc b) {
669                 final Binding bindingA = (Binding) a;
670                 final Binding bindingB = (Binding) b;
671                 final ParameterizedCommand commandA = bindingA
672                         .getParameterizedCommand();
673                 final ParameterizedCommand commandB = bindingB
674                         .getParameterizedCommand();
675                 try {
676                     return commandA.getName().compareTo(commandB.getName());
677                 } catch (final NotDefinedException e) {
678                     // should not happen
679
return 0;
680                 }
681             }
682         });
683         Iterator JavaDoc i = bindings.iterator();
684         while (i.hasNext()) {
685             Binding b = (Binding) i.next();
686             conflictMatches.put(b, b.getTriggerSequence());
687         }
688
689         // If the dialog is already open, dispose the shell and recreate it.
690
final Shell shell = getShell();
691         if (shell != null) {
692             close(false, false);
693         }
694         create();
695
696         // Configure the size and location.
697
final Point size = configureSize();
698         configureLocation(size);
699
700         // Call the super method.
701
return super.open();
702     }
703
704     /**
705      * Registers the shell as the same type as its parent with the context
706      * support. This ensures that it does not modify the current state of the
707      * application.
708      */

709     private final void registerShellType() {
710         final Shell shell = getShell();
711         final IContextService contextService = (IContextService) keyBindingState
712                 .getAssociatedWindow().getWorkbench().getService(
713                         IContextService.class);
714         contextService.registerShell(shell, contextService
715                 .getShellType((Shell) shell.getParent()));
716     }
717
718     /**
719      * Remembers the current state of this dialog.
720      *
721      * @param previousWidth
722      * The previous width of the dialog.
723      * @param binding
724      * The binding to remember, may be <code>null</code> if none.
725      */

726     private final void rememberState(final int previousWidth,
727             final Binding binding) {
728         this.previousWidth = previousWidth;
729         this.binding = binding;
730         hasRememberedState = true;
731     }
732
733     /**
734      * Exposing this within the keys package.
735      *
736      * @param newParentShell
737      * The new parent shell; this value may be <code>null</code> if
738      * there is to be no parent.
739      */

740     protected final void setParentShell(final Shell newParentShell) {
741         super.setParentShell(newParentShell);
742     }
743 }
744
Popular Tags