Skip to content

Commit

Permalink
[2141] Double click on an element shall not expand and open properties
Browse files Browse the repository at this point in the history
at the same time

Bug: 2141
Change-Id: Ic4f58b2136016caf05093ff634dc75ef95a53fb8
Signed-off-by: Philippe DUL <philippe.dul@thalesgroup.com>
  • Loading branch information
pdulth committed Aug 8, 2018
1 parent 1579c2c commit 749ee6f
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 15 deletions.
@@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2018 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Thales - initial API and implementation
*******************************************************************************/
package org.polarsys.capella.core.platform.sirius.ui.navigator.actions;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
import org.polarsys.capella.core.model.handler.command.CapellaResourceHelper;
import org.polarsys.capella.core.ui.properties.CapellaUIPropertiesPlugin;

public class OpenPropertiesAction extends BaseSelectionListenerAction {

public OpenPropertiesAction() {
super("Open properties");
}

@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) getStructuredSelection();
Object element = selection.getFirstElement();

if (CapellaResourceHelper.isSemanticElement(element)) {
CapellaUIPropertiesPlugin.getDefault().openWizard((EObject) element);
}
}

@Override
protected boolean updateSelection(IStructuredSelection selection) {
boolean result = false;

if (!selection.isEmpty()) {
result = (CapellaResourceHelper.isSemanticElements(selection.toList())) ? true : false;
}

return result;
}
}
Expand Up @@ -10,30 +10,56 @@
*******************************************************************************/
package org.polarsys.capella.core.platform.sirius.ui.navigator.actions.providers;

import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.navigator.CommonActionProvider;
import org.eclipse.ui.navigator.ICommonActionConstants;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
import org.eclipse.ui.navigator.ICommonViewerSite;
import org.polarsys.capella.common.data.modellingcore.ModelElement;
import org.polarsys.capella.core.platform.sirius.ui.navigator.actions.OpenPropertiesAction;
import org.polarsys.capella.core.platform.sirius.ui.navigator.actions.SelectionHelper;

/**
* Action Provider for {@link ModelElement}.
*/
public class ModelElementActionProvider extends CommonActionProvider {


private OpenPropertiesAction _openPropertiesAction;


/**
* @see org.eclipse.ui.actions.ActionGroup#dispose()
*/
@Override
public void dispose() {
super.dispose();

if (null != _openPropertiesAction) {
ISelectionProvider selectionProvider = getActionSite().getViewSite().getSelectionProvider();
selectionProvider.removeSelectionChangedListener(_openPropertiesAction);
_openPropertiesAction = null;
}
}

@Override
public void fillActionBars(IActionBars actionBars) {
super.fillActionBars(actionBars);
actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, _openPropertiesAction);
actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), _openPropertiesAction);
}
/**
* @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
*/
@Override
public void init(ICommonActionExtensionSite site_p) {
super.init(site_p);

ICommonViewerSite commonViewSite = site_p.getViewSite();
_openPropertiesAction = new OpenPropertiesAction();
SelectionHelper.registerToSelectionChanges(_openPropertiesAction, commonViewSite.getSelectionProvider());

}
}
Expand Up @@ -903,21 +903,6 @@ public void init(IPageSite pageSite) {
return propertySheetPage;
}

/**
* @see org.eclipse.ui.navigator.CommonNavigator#handleDoubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
*/
@Override
protected void handleDoubleClick(DoubleClickEvent event) {
super.handleDoubleClick(event);
// Add an additional behavior for ModelElement selection.
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
Object element = selection.getFirstElement();

if (CapellaResourceHelper.isSemanticElement(element)) {
CapellaUIPropertiesPlugin.getDefault().openWizard(event, (EObject) element);
}
}

/**
* @see org.eclipse.ui.navigator.CommonNavigator#init(org.eclipse.ui.IViewSite, org.eclipse.ui.IMemento)
*/
Expand Down

0 comments on commit 749ee6f

Please sign in to comment.