-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show recently used File > New wizards
Changes requested in the PR #1837 are addressed here
- Loading branch information
1 parent
136058f
commit 295f697
Showing
7 changed files
with
159 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...pse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/RecentNewWizardSelection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 ETAS GmbH and others, all rights reserved. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ETAS GmbH - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.ui.internal.dialogs; | ||
|
||
import java.util.Collections; | ||
import java.util.Iterator; | ||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* A <code>RecentNewWizardSelection</code> is used to manage the five most | ||
* recent new wizards used or created from the "Other" shortcut, which is part | ||
* of the menu manager with New Wizard actions. The recently used new wizards | ||
* will appear before the "Other" shortcut. | ||
* | ||
* @since 3.5 | ||
*/ | ||
public class RecentNewWizardSelection { | ||
private Set<String> selectedFromOther = new LinkedHashSet<>(); | ||
private static RecentNewWizardSelection instance; | ||
private static final int MAX_MENU_SIZE = 5; | ||
|
||
public static RecentNewWizardSelection getInstance() { | ||
synchronized (RecentNewWizardSelection.class) { | ||
if (instance == null) { | ||
instance = new RecentNewWizardSelection(); | ||
} | ||
return instance; | ||
} | ||
} | ||
|
||
/** | ||
* Adds the new wizard menu shortcut ID to the set and removes the oldest one if | ||
* the number of recently used new wizard menu shortcuts exceeds MAX_MENU_SIZE. | ||
* | ||
* @param shortcut the new wizard menu shortcut ID | ||
*/ | ||
public void addItem(String shortcut) { | ||
selectedFromOther.add(shortcut); | ||
if (selectedFromOther.size() > MAX_MENU_SIZE) { | ||
Iterator<String> iterator = selectedFromOther.iterator(); | ||
iterator.next(); | ||
iterator.remove(); | ||
} | ||
} | ||
|
||
/** | ||
* Returns the set of recently used new wizard menu shortcut IDs. | ||
* | ||
* @return the set of recently used new wizard menu shortcut IDs | ||
*/ | ||
|
||
public Set<String> getSelectedFromOther() { | ||
return Collections.unmodifiableSet(selectedFromOther); | ||
} | ||
|
||
} |