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

Draft: Refactoring improvement and EMFComprare previews for renamings #131

Draft
wants to merge 15 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* Contributors:
* Alois Zoitl, Filip Andren
* - initial API and implementation and/or initial documentation
* Martin Schwarz
* - Build fixes
*******************************************************************************/
package org.eclipse.fordiac.ide.application.actions;

Expand All @@ -22,6 +24,7 @@
import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
import org.eclipse.gef.ui.actions.SelectAllAction;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IWorkbenchPart;
Expand All @@ -48,7 +51,7 @@ private static List<EditPart> getSelectableEditParts(final GraphicalViewer viewe

for (final Object child : children) {
if ((child instanceof AbstractFBNElementEditPart) || (child instanceof GroupEditPart)) {
final GraphicalEditPart childPart = (GraphicalEditPart) child;
final EditPart childPart = (EditPart) child;
if (childPart.isSelectable()) {
selectableChildren.add(childPart);
addConnectionsTo(selectableChildren, childPart);
Expand All @@ -58,14 +61,19 @@ private static List<EditPart> getSelectableEditParts(final GraphicalViewer viewe
return Collections.unmodifiableList(selectableChildren);
}

private static void addConnectionsTo(final List<EditPart> selectableChildren, final GraphicalEditPart child) {
private static void addConnectionsTo(final List<EditPart> selectableChildren, final EditPart child) {
// the editparts are in charge of managing the connections if we take all source
// connections
// from one edit part we should get all connections in the end.

for (final GraphicalEditPart elementChild : child.getChildren()) {
elementChild.getSourceConnections().stream().filter(EditPart::isSelectable)
.forEach(selectableChildren::add);
final List<?> elementChildren = child.getChildren();
for (final Object elementChild : elementChildren) {
if (elementChild instanceof AbstractGraphicalEditPart) {
final List<? extends GraphicalEditPart> connections = ((AbstractGraphicalEditPart) elementChild)
.getSourceConnections();
connections.stream().filter(EditPart::isSelectable).forEach(selectableChildren::add);
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* Fabio Gandolfi - initial implementation and/or documentation
* Martin Schwarz - Build fixes
*******************************************************************************/
package org.eclipse.fordiac.ide.application.commands;

Expand All @@ -30,6 +31,7 @@
import org.eclipse.fordiac.ide.model.ConnectionLayoutTagger;
import org.eclipse.fordiac.ide.model.commands.change.AbstractChangeContainerBoundsCommand;
import org.eclipse.fordiac.ide.model.libraryElement.FBNetworkElement;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.commands.Command;
Expand Down Expand Up @@ -222,7 +224,7 @@ private EditPartViewer getViewer() {
}

private Rectangle getFBBounds(final List<FBNetworkElement> children) {
final Map<Object, Object> editPartRegistry = getViewer().getEditPartRegistry();
final Map<Object, EditPart> editPartRegistry = getViewer().getEditPartRegistry();
Rectangle fbBounds = null;

for (final FBNetworkElement fbe : children) {
Expand All @@ -243,7 +245,7 @@ private Rectangle getFBBounds(final List<FBNetworkElement> children) {
}

private static void addValueBounds(final Rectangle fbBounds, final FBNetworkElement fbe,
final Map<Object, Object> editPartRegistry) {
final Map<Object, EditPart> editPartRegistry) {
fbe.getInterface().getInputVars().stream().filter(Objects::nonNull)
.map(ie -> editPartRegistry.get(ie.getValue())).filter(GraphicalEditPart.class::isInstance)
.forEach(ep -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Alois Zoitl - extracted most code into common base class for group
* infrastructure
* - extracted this policy from the AbstractContainerContentEditPart
* Martin Schwarz - Build fixes
*******************************************************************************/
package org.eclipse.fordiac.ide.application.policies;

Expand Down Expand Up @@ -94,7 +95,7 @@ protected Rectangle getNewContentBounds(final List<EditPart> editParts) {
}

private void addValueBounds(final FBNetworkElement model, final Rectangle selectionExtend) {
final Map<Object, Object> editPartRegistry = getHost().getViewer().getEditPartRegistry();
final Map<Object, EditPart> editPartRegistry = getHost().getViewer().getEditPartRegistry();
model.getInterface().getInputVars().stream().filter(Objects::nonNull)
.map(ie -> editPartRegistry.get(ie.getValue())).filter(GraphicalEditPart.class::isInstance)
.forEach(ep -> selectionExtend.union(((GraphicalEditPart) ep).getFigure().getBounds()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Contributors:
* Alois Zoitl - initial API and implementation and/or initial documentation
* Martin Jobst - refactor evaluator API
* Martin Schwarz - Build fixes
*******************************************************************************/
package org.eclipse.fordiac.ide.debug.ui.view.editparts;

Expand Down Expand Up @@ -190,7 +191,7 @@ public void terminated(final EvaluatorThreadPoolExecutor executor) {
}

private void updateValues(final Collection<? extends Variable<?>> variables) {
final Map<Object, Object> editPartRegistry = getViewer().getEditPartRegistry();
final Map<Object, EditPart> editPartRegistry = getViewer().getEditPartRegistry();
if (shouldUpdate()) {
Display.getDefault().asyncExec(() -> {
variables
Expand All @@ -210,7 +211,7 @@ private boolean shouldUpdate() {
return false;
}

private void updateVariable(final Map<Object, Object> editPartRegistry, final String variableName,
private void updateVariable(final Map<Object, EditPart> editPartRegistry, final String variableName,
final Value value) {
final InterfaceValueEntity interfaceValueEntity = interfaceValues.get(variableName);
if (interfaceValueEntity != null) {
Expand All @@ -233,7 +234,7 @@ public void handleDebugEvents(final DebugEvent[] events) {
break;
case DebugEvent.CHANGE:
if (ev.getSource() instanceof EvaluatorDebugVariable) {
final Map<Object, Object> editPartRegistry = getViewer().getEditPartRegistry();
final Map<Object, EditPart> editPartRegistry = getViewer().getEditPartRegistry();
Display.getDefault().asyncExec(() -> {
final EvaluatorDebugVariable evaluatorDebugVariable = (EvaluatorDebugVariable) ev.getSource();
updateVariable(editPartRegistry, evaluatorDebugVariable.getName(),
Expand All @@ -248,15 +249,15 @@ public void handleDebugEvents(final DebugEvent[] events) {
}

private void updateAllValues() {
final Map<Object, Object> editPartRegistry = getViewer().getEditPartRegistry();
final Map<Object, EditPart> editPartRegistry = getViewer().getEditPartRegistry();
Display.getDefault().asyncExec(() -> {
interfaceValues.entrySet().forEach(entry -> updateVariable(editPartRegistry, entry.getKey(),
entry.getValue().getVariable().getValue()));
updateAllEvents(editPartRegistry);
});
}

private void updateAllEvents(final Map<Object, Object> editPartRegistry) {
private void updateAllEvents(final Map<Object, EditPart> editPartRegistry) {
eventValues.entrySet().forEach(entry -> {
final Object ep = editPartRegistry.get(entry.getValue());
if (ep instanceof EventValueEditPart) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Filip Adren, Alois Zoitl
* - initial API and implementation and/or initial documentation
* Fabio Gandolfi - added doubleclickevent for pin jumps
* Martin Schwarz - Build fixes
*******************************************************************************/
package org.eclipse.fordiac.ide.gef.utilities;

Expand Down Expand Up @@ -41,7 +42,8 @@ public final class ElementSelector {
* @param viewObjects list with objects to select
*/
public static void selectViewObjects(final Collection<? extends Object> viewObjects) {
final IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
final IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.getActivePart();
final GraphicalViewer viewer = part.getAdapter(GraphicalViewer.class);
if (viewer != null) {
viewer.flush();
Expand All @@ -58,9 +60,10 @@ public static void selectViewObjects(final Collection<? extends Object> viewObje

}

private static List<EditPart> getSelectableEditParts(final GraphicalViewer viewer, final Collection<?> viewObjects) {
private static List<EditPart> getSelectableEditParts(final GraphicalViewer viewer,
final Collection<?> viewObjects) {
final List<EditPart> selectableChildren = new ArrayList<>();
final Map<Object, Object> editPartRegistry = viewer.getEditPartRegistry();
final Map<Object, EditPart> editPartRegistry = viewer.getEditPartRegistry();
for (final Object view : viewObjects) {
final Object child = editPartRegistry.get(view);
if ((child instanceof EditPart) && ((EditPart) child).getModel().equals(view)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Require-Bundle: org.eclipse.fordiac.ide.model,
org.eclipse.fordiac.ide.globalconstantseditor.model,
org.eclipse.fordiac.ide.typemanagement
Import-Package: org.apache.log4j,
org.eclipse.fordiac.ide.typemanagement.refactoring,
org.eclipse.xtext.ui.codemining;resolution:=optional
Bundle-RequiredExecutionEnvironment: JavaSE-21
Export-Package: org.eclipse.fordiac.ide.structuredtextcore.ui,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ltk.ui.refactoring,
org.eclipse.fordiac.ide.model.search,
org.eclipse.fordiac.ide.model.commands,
org.eclipse.fordiac.ide.model.ui
org.eclipse.compare,
org.eclipse.emf.compare,
org.eclipse.emf.compare.edit,
org.eclipse.emf.compare.ide.ui
Bundle-Vendor: Eclipse 4diac
Bundle-ActivationPolicy: lazy
Bundle-Version: 3.0.0.qualifier
Expand All @@ -36,4 +39,6 @@ Export-Package: org.eclipse.fordiac.ide.typemanagement,
org.eclipse.fordiac.ide.typemanagement.util,
org.eclipse.fordiac.ide.typemanagement.wizards
Automatic-Module-Name: org.eclipse.fordiac.ide.typemanagement
Import-Package: org.eclipse.fordiac.ide.model.ui.editors
Import-Package: org.eclipse.emf.compare,
org.eclipse.fordiac.ide.model.ui.editors,
org.eclipse.fordiac.ide.model.ui.widgets
32 changes: 31 additions & 1 deletion plugins/org.eclipse.fordiac.ide.typemanagement/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@
<extension
point="org.eclipse.ltk.ui.refactoring.changePreviewViewers">
<changePreviewViewer
class="org.eclipse.fordiac.ide.typemanagement.wizards.ChangeConfigurationViewer"
class="org.eclipse.fordiac.ide.typemanagement.previews.ChangeConfigurationViewer"
id="org.eclipse.fordiac.ide.typemanagement.wizards.DeleteStructChangeViewer">
<enablement>
<or>
Expand All @@ -678,6 +678,36 @@
</or>
</enablement>
</changePreviewViewer>
<changePreviewViewer
class="org.eclipse.fordiac.ide.typemanagement.previews.StructChangePreviewViewer"
id="org.eclipse.fordiac.ide.typemanagement.changePreviewViewer2">
<enablement>
<or>
<instanceof
value="org.eclipse.fordiac.ide.typemanagement.refactoring.rename.StructuredTypeMemberChange">
</instanceof>
</or></enablement>
</changePreviewViewer>
<changePreviewViewer
class="org.eclipse.fordiac.ide.typemanagement.previews.InterfaceDataTypeChangePreviewViewer"
id="org.eclipse.fordiac.ide.typemanagement.previews.InterfaceDataTypeChangePreviewViewer">
<enablement>
<or>
<instanceof
value="org.eclipse.fordiac.ide.typemanagement.refactoring.InterfaceDataTypeChange">
</instanceof>
</or></enablement>
</changePreviewViewer>
<changePreviewViewer
class="org.eclipse.fordiac.ide.typemanagement.previews.UpdateInstancesChangePreviewViewer"
id="org.eclipse.fordiac.ide.typemanagement.previews.UpdateInstancesChangePreviewViewer">
<enablement>
<or>
<instanceof
value="org.eclipse.fordiac.ide.typemanagement.refactoring.UpdateInstancesChange">
</instanceof>
</or></enablement>
</changePreviewViewer>
</extension>
<extension
point="org.eclipse.ui.menus">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* - Externalized all translatable strings
* Martin Jobst
* - add strings for Build Path property page
* Martin Schwarz
* - add/modify strings for rename refactoring
*******************************************************************************/

package org.eclipse.fordiac.ide.typemanagement;
Expand Down Expand Up @@ -124,7 +126,9 @@ public final class Messages extends NLS {
public static String typeManagementPreferencePageDescription;

public static String Refactoring_RenameFromTo;
public static String Refactoring_AffectedFuctionBlock;
public static String Refactoring_AffectedStruct;
public static String Refactoring_AffectedFbInstances;
public static String Refactoring_AffectedInstancesOfFB;
public static String Refactoring_UpdateTypeEntryChange;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# Jose Cabral - Add preferences for information about new types
# Andrea Zoitl - Externalized all translatable strings
# Martin Jobst - add strings for Build Path property page
# Martin Schwarz - add/modify strings for rename refactoring
###############################################################################

AbstractCommandChange_CannotExecuteCommand=Cannot execute command
Expand Down Expand Up @@ -72,7 +73,8 @@ RenameElementRefactoringProcessor_Name=Rename element to {0}
RenameElementRefactoringProcessor_RenamePinInType=Rename Pin in type: {0}
RenameElementRefactoringWizardPage_Name=Name
RenameType_Name=Rename IEC 61499 Type
RenameType_TypeExists=The type {0} is already included in the library
RenameType_TypeExists=The type ''{0}'' is already included in the library
OldTypeLibVersionCouldNotBeDeleted= There was a problem while importing the new Type Library version, old one could not be deleted!
OpenTypeHandler_EDITOR_OPEN_ERROR_MESSAGE=Could not open according editor
OpenTypeHandler_NO_FILES_IN_WORKSPACE=There are no files in your workspace
OpenTypeHandler_NO_FILES_SELECTED=No file selected
Expand All @@ -84,9 +86,13 @@ typeManagementPreferencePageIdentificationTitle=Identification information
typeManagementPreferencePageVersionTitle=Version information
typeManagementPreferencePageDescription=Default values for created Function Blocks
Warning=Warning
Refactoring_RenameFromTo=Rename Type from ''{0}'' to ''{1}''
Refactoring_AffectedFuctionBlock=Update affected Function Blocks
Refactoring_AffectedFbInstances=Update affected Function Block instances
Refactoring_RenameFromTo=Rename Type from {0} to : {1}
Refactoring_AffectedStruct=Affected Struct {0} that contain struct {1} as member
Refactoring_AffectedStruct=Update affected Structs
Refactoring_AffectedInstancesOfFB=Affected Instances of this FB Type
UpdatedInstances=Instances which have been updated with the new type library version
Refactoring_UpdateTypeEntryChange=Update type entry and editors
PreviewChange_DeleteChoice=Delete
PreviewChange_ChangeToAnyStruct=Change to ANY_STRUCT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
* - initial API and implementation and/or initial documentation
* Dario Romano
* - add correct preservation of selection and ui initialization from change state
* Martin Schwarz
* - moved file
*******************************************************************************/
package org.eclipse.fordiac.ide.typemanagement.wizards;
package org.eclipse.fordiac.ide.typemanagement.previews;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -66,7 +68,6 @@ public void widgetSelected(final SelectionEvent e) {
}
}
});

}

@Override
Expand Down
Loading