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

Merge Branch Freeze into Develop #970

Merged
merged 4 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
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 @@ -19,6 +19,7 @@
import org.eclipse.fordiac.ide.model.libraryElement.CFBInstance;
import org.eclipse.fordiac.ide.model.libraryElement.IInterfaceElement;
import org.eclipse.fordiac.ide.model.libraryElement.SubApp;
import org.eclipse.fordiac.ide.model.ui.actions.OpenListener;
import org.eclipse.fordiac.ide.model.ui.editors.AbstractBreadCrumbEditor;
import org.eclipse.fordiac.ide.model.ui.widgets.GoIntoSubappSelectionEvent;
import org.eclipse.gef.EditPart;
Expand All @@ -41,9 +42,11 @@ public Object execute(final ExecutionEvent event) throws ExecutionException {
if (editPart != null) {
if (editPart.getModel() instanceof final SubApp subapp && subapp.isUnfolded()) {
// with go to child we now want to open the subapp
if (HandlerUtil.getActiveEditor(event) instanceof final AbstractBreadCrumbEditor breadcrumbEditor) {
breadcrumbEditor.getBreadcrumb().setInput(editPart.getModel(),
new GoIntoSubappSelectionEvent(breadcrumbEditor.getBreadcrumb(), subapp));
final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
final AbstractBreadCrumbEditor breadCrumbEditor = OpenListener.getBreadCrumbEditor(activeEditor);
if (breadCrumbEditor != null) {
breadCrumbEditor.getBreadcrumb().setInput(editPart.getModel(),
new GoIntoSubappSelectionEvent(breadCrumbEditor.getBreadcrumb(), subapp));
}
} else {
editPart.performRequest(new Request(RequestConstants.REQ_OPEN));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.part.MultiPageEditorSite;

/**
* Helper class for reducing the effort to implement open listeners
Expand Down Expand Up @@ -90,23 +91,15 @@ protected void openInFBTypeEditor(final FBType root, final EObject element) {
}

public static AbstractBreadCrumbEditor getBreadCrumbEditor(final IEditorPart openedEditor) {
AbstractBreadCrumbEditor breadCrumbEditor = openedEditor.getAdapter(AbstractBreadCrumbEditor.class);
if ((breadCrumbEditor == null) && (openedEditor instanceof final FormEditor formEditor)) {
breadCrumbEditor = getBreadCrumbFromMultiPageEditor(formEditor);
}
return breadCrumbEditor;
}

private static AbstractBreadCrumbEditor getBreadCrumbFromMultiPageEditor(final FormEditor openedEditor) {
final IEditorInput input = openedEditor.getActiveEditor().getEditorInput();

for (final IEditorPart subEditor : openedEditor.findEditors(input)) {
if (subEditor instanceof final AbstractBreadCrumbEditor bcEditor) {
openedEditor.setActiveEditor(subEditor);
return bcEditor;
final AbstractBreadCrumbEditor breadCrumbEditor = openedEditor.getAdapter(AbstractBreadCrumbEditor.class);
if ((breadCrumbEditor != null)
&& (breadCrumbEditor.getEditorSite() instanceof final MultiPageEditorSite multiPageEditorSite)) {
final MultiPageEditorPart multiPageEditor = multiPageEditorSite.getMultiPageEditor();
if (multiPageEditor.getSelectedPage() != breadCrumbEditor) {
multiPageEditor.setActiveEditor(breadCrumbEditor);
}
}
return null;
return breadCrumbEditor;
}

private static boolean sameLevelAsParent(final Object element) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,10 @@
class="org.eclipse.fordiac.ide.structuredtextcore.ui.DTPExecutableExtensionFactory:org.eclipse.xtext.ui.resource.generic.EmfResourceUIServiceProvider"
uriExtension="dtp">
</resourceServiceProvider>
<resourceServiceProvider
class="org.eclipse.fordiac.ide.structuredtextcore.ui.DTPExecutableExtensionFactory:org.eclipse.xtext.ui.resource.generic.EmfResourceUIServiceProvider"
uriExtension="DTP">
</resourceServiceProvider>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
package org.eclipse.fordiac.ide.structuredtextcore.ui.refactoring;

import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.fordiac.ide.model.libraryElement.LibraryElement;
import org.eclipse.fordiac.ide.model.resource.FordiacTypeResource;
import org.eclipse.fordiac.ide.structuredtextcore.resource.LibraryElementXtextResource;
import org.eclipse.xtext.ide.serializer.IEmfResourceChange;
import org.eclipse.xtext.ide.serializer.impl.EObjectDescriptionDeltaProvider.Deltas;
Expand All @@ -35,6 +37,9 @@ public void applyChange(final Deltas deltas, final IAcceptor<IEmfResourceChange>
if (resource instanceof final LibraryElementXtextResource libResource) {
importUpdater.updateImports(deltas, libResource.getInternalLibraryElement(),
(imp, value) -> changeAcceptor.accept(new ImportedNamespaceChange(imp, value)));
} else if (resource instanceof final FordiacTypeResource typeResource) {
importUpdater.updateImports(deltas, (LibraryElement) typeResource.getContents().getFirst(),
(imp, value) -> changeAcceptor.accept(new ImportedNamespaceChange(imp, value)));
}
if (resource instanceof final XtextResource xtextResource && hasContents(xtextResource)) {
super.applyChange(deltas, changeAcceptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public abstract class AbstractTypeEditor extends AbstractCloseAbleFormEditor imp

@Override
protected void addPages() {
final TypeEditorInput ei = getTypeEditorInput();
editorPages = typeEditorPageFactory.getEditors(getType());
final TypeEditorInput ei = getEditorInput();
for (final ITypeEditorPage typeEditorPage : editorPages) {
try {
// set command stack has to be done before the page is added
Expand All @@ -121,10 +121,10 @@ private TypeEditorInput checkEditorInput(final IEditorInput editorInput) {
}

if (editorInput instanceof final IFileEditorInput fileEI) {
if (getEditorInput() != null) {
if (getTypeEditorInput() != null) {
// when we already had an input it means the file for our type has changed,
// provide a new TypeEditorInput with the new file
return new TypeEditorInput(getEditorInput().getContent(), getEditorInput().getTypeEntry(),
return new TypeEditorInput(getTypeEditorInput().getContent(), getTypeEditorInput().getTypeEntry(),
fileEI.getFile());
}

Expand Down Expand Up @@ -286,9 +286,8 @@ public <T> T getAdapter(final Class<T> adapter) {
return null;
}

@Override
public TypeEditorInput getEditorInput() {
return (TypeEditorInput) super.getEditorInput();
private TypeEditorInput getTypeEditorInput() {
return (super.getEditorInput() instanceof final TypeEditorInput typeEI) ? typeEI : null;
}

protected Collection<ITypeEditorPage> getEditorPages() {
Expand All @@ -302,12 +301,12 @@ public String getTitleToolTip() {
}

protected LibraryElement getType() {
final TypeEditorInput ei = getEditorInput();
final TypeEditorInput ei = getTypeEditorInput();
return (ei != null) ? ei.getContent() : null;
}

protected TypeEntry getTypeEntry() {
final TypeEditorInput ei = getEditorInput();
final TypeEditorInput ei = getTypeEditorInput();
return (ei != null) ? ei.getTypeEntry() : null;
}

Expand Down Expand Up @@ -387,7 +386,10 @@ public void reloadType() {
if ((curType != null) && getTypeEntry().eAdapters().contains(adapter)) {
getTypeEntry().eAdapters().remove(adapter);
}
getEditorInput().setType(newFBType);
final TypeEditorInput typeEI = getTypeEditorInput();
if (typeEI != null) {
typeEI.setType(newFBType);
}
getEditorPages().stream().forEach(ITypeEditorPage::reloadType);
final IEditorPart activeEditor = getActiveEditor();
if (activeEditor instanceof final ITypeEditorPage editorPage) {
Expand Down
Loading