Skip to content
Snippets Groups Projects
Commit 2606444d authored by Simon Barner's avatar Simon Barner
Browse files

Add "Select All" action (CTRL+A) for diagram model editors.

refs 3084
parent f461b1e4
No related branches found
No related tags found
No related merge requests found
Showing
with 121 additions and 14 deletions
org.fortiss.tooling.kernel.ui/trunk/icons/select_all.png

241 B

......@@ -26,7 +26,7 @@ import org.eclipse.jface.action.IContributionItem;
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: EF068A38A42C0E4AB6E94AA3D99A4FFE
* @ConQAT.Rating YELLOW Hash: CB12A92EE54964BB92F8DB7E446808BC
*/
public interface ITutorialUIWhitelistProvider {
/** Returns whether the given element should be displayed in the navigator tree. */
......@@ -44,6 +44,9 @@ public interface ITutorialUIWhitelistProvider {
/** Returns whether the global rename action is visible in the context menu. */
boolean globalRenameActionVisible();
/** Returns whether the global "select all" action is visible in the context menu. */
boolean globalSelectAllActionVisible();
/** Returns whether the given context menu contribution is visible. */
boolean contextMenuContributionVisible(EObject element, IContributionItem contribution);
}
......@@ -29,7 +29,7 @@ import org.fortiss.tooling.kernel.ui.extension.ITutorialUIWhitelistProvider;
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: E42D05ED143FC1B3FA87BD1828F67537
* @ConQAT.Rating YELLOW Hash: 91424573B85CF01E1577D55B445C7710
*/
public abstract class TutorialStepUIAtomicWithWhitelistBase extends TutorialStepUIAtomicBase
implements ITutorialUIWhitelistProvider {
......@@ -73,6 +73,12 @@ public abstract class TutorialStepUIAtomicWithWhitelistBase extends TutorialStep
return true;
}
/** {@inheritDoc} */
@Override
public boolean globalSelectAllActionVisible() {
return true;
}
/** {@inheritDoc} */
@Override
public boolean contextMenuContributionVisible(EObject element, IContributionItem contribution) {
......
......@@ -30,7 +30,7 @@ import org.fortiss.tooling.kernel.ui.extension.ITutorialUIWhitelistProvider;
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: 69DF31BEA71E0C448A989D1332F27206
* @ConQAT.Rating YELLOW Hash: 8945A5050A267FF6017A75199FD94F05
*/
public abstract class TutorialStepUICompositeWithWhitelistBase extends TutorialStepUICompositeBase
implements ITutorialUIWhitelistProvider {
......@@ -76,6 +76,12 @@ public abstract class TutorialStepUICompositeWithWhitelistBase extends TutorialS
return true;
}
/** {@inheritDoc} */
@Override
public boolean globalSelectAllActionVisible() {
return true;
}
/** {@inheritDoc} */
@Override
public boolean contextMenuContributionVisible(EObject element, IContributionItem contribution) {
......
......@@ -44,6 +44,7 @@ import org.fortiss.tooling.kernel.ui.internal.actions.DeleteAction;
import org.fortiss.tooling.kernel.ui.internal.actions.PasteAction;
import org.fortiss.tooling.kernel.ui.internal.actions.RedoAction;
import org.fortiss.tooling.kernel.ui.internal.actions.RenameAction;
import org.fortiss.tooling.kernel.ui.internal.actions.SelectAllAction;
import org.fortiss.tooling.kernel.ui.internal.actions.UndoAction;
import org.fortiss.tooling.kernel.ui.internal.views.NavigatorNewMenu;
import org.fortiss.tooling.kernel.ui.service.IActionService;
......@@ -55,7 +56,7 @@ import org.fortiss.tooling.kernel.ui.util.EObjectSelectionUtils;
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 2EB398C7C37EB120360B479B0A3EF898
* @ConQAT.Rating YELLOW Hash: 30F05BE76B211235B375C2DF267C4635
*/
public class ActionService implements IActionService, IPersistencyServiceListener,
CommandStackListener, IIntrospectiveKernelService {
......@@ -91,6 +92,9 @@ public class ActionService implements IActionService, IPersistencyServiceListene
/** The global rename action. */
public RenameAction globalRenameAction;
/** The global "select all" action. */
public SelectAllAction globalSelectAllAction;
/** Initializes the service. */
public void initializeService() {
globalDeleteAction = new DeleteAction();
......@@ -100,6 +104,7 @@ public class ActionService implements IActionService, IPersistencyServiceListene
globalCutAction = new CutAction();
globalPasteAction = new PasteAction();
globalRenameAction = new RenameAction();
globalSelectAllAction = new SelectAllAction();
}
/** Starts the service. */
......@@ -114,13 +119,13 @@ public class ActionService implements IActionService, IPersistencyServiceListene
/** {@inheritDoc} */
@Override
public void addGlobalDefaultActionSectionToMenu(IMenuManager menuManager) {
addGlobalEditingActionsToMenu(menuManager, true, true, true);
addGlobalEditingActionsToMenu(menuManager, true, true, true, true);
}
/** {@inheritDoc} */
@Override
public void addGlobalEditingActionsToMenu(IMenuManager menuManager, boolean copyPaste,
boolean delete, boolean rename) {
boolean delete, boolean rename, boolean selectAll) {
if(copyPaste) {
menuManager.appendToGroup(GLOBAL_DEFAULT_MENU_SECTION_ID, globalCopyAction);
menuManager.appendToGroup(GLOBAL_DEFAULT_MENU_SECTION_ID, globalCutAction);
......@@ -132,6 +137,10 @@ public class ActionService implements IActionService, IPersistencyServiceListene
if(rename) {
menuManager.appendToGroup(GLOBAL_DEFAULT_MENU_SECTION_ID, globalRenameAction);
}
if(selectAll) {
menuManager.appendToGroup(GLOBAL_DEFAULT_MENU_SECTION_ID, globalSelectAllAction);
}
}
/** {@inheritDoc} */
......@@ -171,6 +180,8 @@ public class ActionService implements IActionService, IPersistencyServiceListene
ActionFactory.DELETE.getCommandId(), actionBars);
registerGlobalAction(globalRenameAction, ActionFactory.RENAME.getId(),
ActionFactory.RENAME.getCommandId(), actionBars);
registerGlobalAction(globalSelectAllAction, ActionFactory.SELECT_ALL.getId(),
ActionFactory.SELECT_ALL.getCommandId(), actionBars);
}
/** Registers the given action globally. */
......@@ -189,6 +200,7 @@ public class ActionService implements IActionService, IPersistencyServiceListene
globalPasteAction.refresh(targets);
globalDeleteAction.refresh(targets);
globalRenameAction.refresh(targets);
globalSelectAllAction.refresh(targets);
globalUndoAction.refresh(targets);
globalRedoAction.refresh(targets);
}
......@@ -259,6 +271,12 @@ public class ActionService implements IActionService, IPersistencyServiceListene
globalRenameAction.run();
}
/** {@inheritDoc} */
@Override
public void runGlobalSelectAllAction() {
globalSelectAllAction.run();
}
/** {@inheritDoc} */
@Override
public Prototype getNewMenuContributionPrototype(IContributionItem contributionItem) {
......
......@@ -55,7 +55,7 @@ import org.osgi.framework.Bundle;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 3448206DA62CB18B6BC802486F94D387
* @ConQAT.Rating YELLOW Hash: C750C764FE6FEC1CC10F7709200A2BC9
*/
public class ContextMenuService implements IContextMenuService, IIntrospectiveKernelService {
/** The singleton service instance. */
......@@ -173,7 +173,8 @@ public class ContextMenuService implements IContextMenuService, IIntrospectiveKe
IActionService.getInstance().addGlobalEditingActionsToMenu(menu,
ITutorialUIService.getInstance().globalCopyPasteActionsVisible(),
ITutorialUIService.getInstance().globalDeleteActionVisible(),
ITutorialUIService.getInstance().globalRenameActionVisible());
ITutorialUIService.getInstance().globalRenameActionVisible(),
ITutorialUIService.getInstance().globalSelectAllActionVisible());
}
}
}
......
......@@ -59,7 +59,7 @@ import org.osgi.framework.BundleException;
* @author hoelzl
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash: 86CD841209EB95BE385D3201B5137A06
* @ConQAT.Rating YELLOW Hash: B64FCE1222C16D24B0D64C9641915E8D
*/
public final class TutorialUIService implements ITutorialUIService, ITutorialUIWhitelistProvider,
IIntrospectiveKernelService {
......@@ -307,6 +307,22 @@ public final class TutorialUIService implements ITutorialUIService, ITutorialUIW
return false;
}
/** {@inheritDoc} */
@Override
public boolean globalSelectAllActionVisible() {
TutorialStepBase step = ITutorialService.getInstance().getActiveTutorialStep();
while(step != null) {
if(step instanceof ITutorialUIWhitelistProvider) {
ITutorialUIWhitelistProvider p = (ITutorialUIWhitelistProvider)step;
if(p.globalSelectAllActionVisible()) {
return true;
}
}
step = step.getParent();
}
return false;
}
/** {@inheritDoc} */
@Override
public boolean contextMenuContributionVisible(EObject element, IContributionItem contribution) {
......
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal.actions;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.actions.ActionFactory;
import org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator;
import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
import org.fortiss.tooling.kernel.ui.util.SelectionUtils;
/**
* Action for selecting all elements in the currently active editor. the currently selected model
* element.
*
* @author barner
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 703812CFF16B4B0ACFEC857D9B17CA6D
*/
public class SelectAllAction extends EObjectActionBase<EObject> {
/** Constructor. */
public SelectAllAction() {
super("Select all", ToolingKernelUIActivator.getImageDescriptor("icons/select_all.png"));
setId(ActionFactory.SELECT_ALL.getId());
}
/** {@inheritDoc} */
@Override
public void run() {
EObject target = getTarget();
if(target != null) {
SelectionUtils.setSelection(target.eContents());
}
}
}
......@@ -30,7 +30,7 @@ import org.fortiss.tooling.kernel.ui.internal.ActionService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 6296378743496C14102753053F08D77F
* @ConQAT.Rating YELLOW Hash: 1BDD6C00C8379F1C4661C01E865184F0
*/
public interface IActionService {
/** Returns the service instance. */
......@@ -59,6 +59,9 @@ public interface IActionService {
/** Runs the global rename action. */
public void runGlobalRenameAction();
/** Runs the global "select all" action. */
public void runGlobalSelectAllAction();
/** Registers all global actions with the given {@link IActionBars}. */
void registerGlobalActions(IActionBars actionBars);
......@@ -73,13 +76,14 @@ public interface IActionService {
/**
* Adds the global default actions to the given context menu. Currently the
* default are the editing actions as provided by #
* {@link IActionService#addGlobalEditingActionsToMenu(IMenuManager,boolean,boolean,boolean)}.
* {@link IActionService#addGlobalEditingActionsToMenu(IMenuManager,boolean,boolean,boolean,boolean)}
* .
*/
void addGlobalDefaultActionSectionToMenu(IMenuManager menuManager);
/** Adds the global editing actions to the menu (Copy, Cut, Paste, Delete, Rename). */
/** Adds the global editing actions to the menu (Copy, Cut, Paste, Delete, Rename, Select All). */
void addGlobalEditingActionsToMenu(IMenuManager menuManager, boolean copyPaste, boolean delete,
boolean rename);
boolean rename, boolean selectAll);
/** Adds the global undo/redo actions to the menu. */
void addGlobalUndoRedoActionsToMenu(IMenuManager menuManager);
......
......@@ -28,7 +28,7 @@ import org.fortiss.tooling.kernel.ui.service.IActionService;
* @author aravantinos
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 45636C73464A38AAF743A8E9C5E13CC6
* @ConQAT.Rating YELLOW Hash: C77D5F99A252385BAED91752692B71CE
*/
public class ActionUtils {
......@@ -55,6 +55,8 @@ public class ActionUtils {
IActionService.getInstance().runGlobalRedoAction();
} else if(e.keyCode == SWT.F2) {
IActionService.getInstance().runGlobalRenameAction();
} else if((e.stateMask & SWT.CTRL) != 0 && e.keyCode == 0x61) {
IActionService.getInstance().runGlobalSelectAllAction();
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment