-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show recently used "File > New" wizards #1922
Open
lathapatil
wants to merge
1
commit into
eclipse-platform:master
Choose a base branch
from
lathapatil:Enhancements/1530_Recent_File_New_Submenus
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
67 changes: 67 additions & 0 deletions
67
...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,67 @@ | ||
/******************************************************************************* | ||
* 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. | ||
*/ | ||
public class RecentNewWizardSelection { | ||
private Set<String> menuIds = 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) { | ||
menuIds.add(shortcut); | ||
if (menuIds.size() > MAX_MENU_SIZE) { | ||
Iterator<String> iterator = menuIds.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> getMenuIds() { | ||
return Collections.unmodifiableSet(menuIds); | ||
} | ||
|
||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you intended to have 5 recent items: currently only four are kept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please share the scenario you tested .
It do not add the shortcuts if it is already present as part of fixed shortcuts (highlighted in the plugin perspective image) of current perspective . The last used shortcuts change if you switch the perspective .
Java perspective
When I switch to plugin perspective ..