Skip to content
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

Fixed detaching of SubApp from Type with no open editor #324

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.gef.commands.CommandStack;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISources;
import org.eclipse.ui.PlatformUI;
Expand Down Expand Up @@ -55,22 +56,25 @@ public void setEnabled(final Object evaluationContext) {
}

private static SubApp getSelectedSubApp(final Object selection) {
if (selection instanceof final IStructuredSelection structSel) {
if (!structSel.isEmpty() && (structSel.size() == 1)) {
return getSubApp(structSel.getFirstElement());
}
if (selection instanceof TreeSelection) {
return null;
}
if ((selection instanceof final IStructuredSelection structSel)
&& (!structSel.isEmpty() && (structSel.size() == 1))) {
return getSubApp(structSel.getFirstElement());
}
return null;
}

private static SubApp getSubApp(final Object currentElement) {
if (currentElement instanceof SubApp) {
return (SubApp) currentElement;
if (currentElement instanceof final SubApp subApp) {
return subApp;
}
if (currentElement instanceof final SubAppForFBNetworkEditPart subAppForFBNetworkEditPart) {
return subAppForFBNetworkEditPart.getModel();
}
if (currentElement instanceof SubAppForFBNetworkEditPart) {
return ((SubAppForFBNetworkEditPart) currentElement).getModel();
} else if (currentElement instanceof UISubAppNetworkEditPart) {
return (SubApp) ((UISubAppNetworkEditPart) currentElement).getModel().eContainer();
if (currentElement instanceof final UISubAppNetworkEditPart uiSubAppNetworkEditPart) {
return (SubApp) uiSubAppNetworkEditPart.getModel().eContainer();
}
return null;
}
Expand Down
Loading