-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[565568] [Filtering]Performing a derivation having as target a folder in
the source project causes an infinite loop Bug 565568 Change-Id: I3127556c19503e22b4610dc19419d9afc4792df5 Signed-off-by: Ali AKAR <[email protected]>
- Loading branch information
1 parent
db5fba1
commit 8b7fbbf
Showing
2 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
...rc/org/polarsys/capella/filtering/tools/actions/FilteringProjectContentsLocationArea.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,63 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 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.filtering.tools.actions; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.resources.IResource; | ||
import org.eclipse.core.runtime.IAdaptable; | ||
import org.eclipse.emf.ecore.EObject; | ||
import org.eclipse.jface.viewers.ISelection; | ||
import org.eclipse.jface.viewers.IStructuredSelection; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.ui.ISelectionService; | ||
import org.eclipse.ui.PlatformUI; | ||
import org.polarsys.capella.common.helpers.EcoreUtil2; | ||
import org.polarsys.capella.core.platform.sirius.ui.project.internal.CapellaProjectContentsLocationArea; | ||
|
||
public class FilteringProjectContentsLocationArea extends CapellaProjectContentsLocationArea { | ||
|
||
public FilteringProjectContentsLocationArea(IErrorMessageReporter reporter, Composite composite) { | ||
super(reporter, composite); | ||
} | ||
|
||
@Override | ||
public String checkValidLocation() { | ||
String isValid = super.checkValidLocation(); | ||
if(isValid == null) { | ||
IProject project = getSelectedProject(); | ||
if(project != null) { | ||
String selectedPrjloc = project.getLocation().toOSString(); | ||
String trgtPrjLoc = getProjectLocation(); | ||
if(trgtPrjLoc.startsWith(selectedPrjloc)) { | ||
return "Generation is not allowed inside the source project"; | ||
} | ||
} | ||
} | ||
return isValid; | ||
} | ||
|
||
private IProject getSelectedProject() { | ||
ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService(); | ||
ISelection sel = selectionService.getSelection("capella.project.explorer"); | ||
Object selectedObject = sel; | ||
if (sel instanceof IStructuredSelection) { | ||
selectedObject = ((IStructuredSelection) sel).getFirstElement(); | ||
if(selectedObject instanceof EObject) { | ||
return EcoreUtil2.getProject((EObject)selectedObject); | ||
} | ||
else if (selectedObject instanceof IAdaptable) { | ||
IResource res = (IResource) ((IAdaptable) selectedObject).getAdapter(IResource.class); | ||
return res.getProject(); | ||
} | ||
} | ||
return null; | ||
} | ||
} |
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