Skip to content

Commit

Permalink
[Clean-up] Fixed several warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
azoitl authored and oberlehner committed Dec 30, 2024
1 parent b48a13e commit 8ca8d16
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2022 fortiss GmbH, Primetals Technologies GmbH
* Copyright (c) 2012, 2024 fortiss GmbH, Primetals Technologies Austria GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -39,13 +39,10 @@ public DeleteFBNetworkAction(final IWorkbenchPart part) {
}

@Override
public Command createDeleteCommand(final List selObjects) {
public Command createDeleteCommand(final List<EditPart> selObjects) {
if (selObjects.isEmpty()) {
return null;
}
if (!(selObjects.get(0) instanceof EditPart)) {
return null;
}

final HashSet<Group> groups = ((List<?>) selObjects).stream().filter(EditPart.class::isInstance)
.map(EditPart.class::cast).map(EditPart::getModel).filter(Group.class::isInstance)
Expand All @@ -54,15 +51,15 @@ public Command createDeleteCommand(final List selObjects) {
final List<EditPart> list = new ArrayList<>();

// Resort list such that the connects are before any other edit parts
for (final Object object : selObjects) {
if (object instanceof ConnectionEditPart) {
list.add((EditPart) object);
for (final EditPart ep : selObjects) {
if (ep instanceof ConnectionEditPart) {
list.add(ep);
}
}

for (final Object object : selObjects) {
if (!(object instanceof ConnectionEditPart) && !isInGroupToBeDeleted(object, groups)) {
list.add((EditPart) object);
for (final EditPart ep : selObjects) {
if (!(ep instanceof ConnectionEditPart) && !isInGroupToBeDeleted(ep, groups)) {
list.add(ep);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.eclipse.fordiac.ide.model.libraryElement.FBNetwork;
import org.eclipse.fordiac.ide.model.libraryElement.IInterfaceElement;
import org.eclipse.fordiac.ide.ui.editors.EditorUtils;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.commands.Command;
Expand Down Expand Up @@ -72,9 +71,9 @@ public Object execute(final ExecutionEvent event) throws ExecutionException {
return Status.CANCEL_STATUS;
}

private static boolean checkVisibilityOfSelection(final List<? extends EditPart> selection) {
private static boolean checkVisibilityOfSelection(final List<?> selection) {
final Set<Boolean> visibility = new HashSet<>();
for (final EditPart obj : selection) {
for (final Object obj : selection) {
if (obj instanceof final ConnectionEditPart conep) {
visibility.add(Boolean.valueOf(!conep.getFigure().isHidden()));
} else if (obj instanceof final AbstractFBNElementEditPart fbEP) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public class FBInterfaceElementIsFreeAndPartOfSubapp extends PropertyTester {

@Override
public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
return receiver instanceof final List receiverList && checkList(receiverList)
return receiver instanceof final List<?> receiverList && checkList(receiverList)
&& receiverList.get(0) instanceof final InterfaceEditPartForFBNetwork ieEditPart
&& ieEditPart.getModel() instanceof final IInterfaceElement ie && isFromFBOrCFB(ie)
&& hasNoConnections(ie) && isNestedInSubApp(ie);
}

private static boolean checkList(final List reciverList) {
private static boolean checkList(final List<?> reciverList) {
return reciverList.size() == 1;
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/org.eclipse.fordiac.ide.elk/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<extension point="org.eclipse.ui.handlers">
<handler class="org.eclipse.fordiac.ide.elk.handlers.LayoutHandler" commandId="org.eclipse.fordiac.ide.elk.layout"/>
<handler class="org.eclipse.fordiac.ide.elk.handlers.ConnectionLayoutHandler" commandId="org.eclipse.fordiac.ide.elk.connectionLayout"/>
<handler class="org.eclipse.fordiac.ide.elk.handlers.ConnectionLayoutMuleHandler" commandId="org.eclipse.fordiac.ide.elk.connectionLayoutMule"/>
<handler class="org.eclipse.fordiac.ide.elk.handlers.ConnectionLayoutHandlerMule" commandId="org.eclipse.fordiac.ide.elk.connectionLayoutMule"/>
<handler class="org.eclipse.fordiac.ide.elk.handlers.SystemLayoutHandler" commandId="org.eclipse.fordiac.ide.elk.systemExplorerLayout"/>
</extension>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected static void showExceptionErrorDialog(final Exception e) {
}

private final List<IFile> collectExportees() {
final List<Object> resources = page.getSelectedResources();
final List<?> resources = page.getSelectedResources();
return resources.parallelStream().filter(IFile.class::isInstance).map(IFile.class::cast).toList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected boolean validateSourceGroup() {
}

@Override
public List getSelectedResources() {
public List<?> getSelectedResources() {
return super.getSelectedResources();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/*******************************************************************************
* Copyright (c) 2013 fortiss GmbH
*
* Copyright (c) 2013, 2024 fortiss GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Alois Zoitl
* - initial API and implementation and/or initial documentation
* Alois Zoitl - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.eclipse.fordiac.ide.fbtypeeditor.ecc.actions;

Expand All @@ -32,7 +31,7 @@ public DeleteECCAction(final IWorkbenchPart part) {
}

@Override
public Command createDeleteCommand(final List objects) {
public Command createDeleteCommand(final List<EditPart> objects) {
if (objects.isEmpty()) {
return null;
}
Expand All @@ -42,34 +41,30 @@ public Command createDeleteCommand(final List objects) {
return super.createDeleteCommand(getDeleteList(objects));
}

@SuppressWarnings("rawtypes")
private static List<EditPart> getDeleteList(final List objects) {
private static List<EditPart> getDeleteList(final List<EditPart> objects) {
final List<EditPart> list = new ArrayList<>();

for (final Object object : objects) {
if (object instanceof ECTransitionEditPart) {
list.add(0, (EditPart) object); // add the transitions before anything else
} else if (object instanceof ECActionAlgorithmEditPart) {
if (!stateContainedInDeleteList(objects,
((ECActionAlgorithmEditPart) object).getCastedModel().getAction().getECState())) {
list.add((EditPart) object);
for (final EditPart ep : objects) {
if (ep instanceof ECTransitionEditPart) {
list.add(0, ep); // add the transitions before anything else
} else if (ep instanceof final ECActionAlgorithmEditPart ecActionAlgEP) {
if (!stateContainedInDeleteList(objects, ecActionAlgEP.getCastedModel().getAction().getECState())) {
list.add(ecActionAlgEP);
}
} else if (object instanceof ECActionOutputEventEditPart) {
if (!stateContainedInDeleteList(objects,
((ECActionOutputEventEditPart) object).getCastedModel().getAction().getECState())) {
list.add((EditPart) object);
} else if (ep instanceof final ECActionOutputEventEditPart ecActionEventEP) {
if (!stateContainedInDeleteList(objects, ecActionEventEP.getCastedModel().getAction().getECState())) {
list.add(ecActionEventEP);
}
} else if (object instanceof EditPart) {
list.add((EditPart) object);
} else {
list.add(ep);
}
}
return list;
}

@SuppressWarnings("rawtypes")
private static boolean stateContainedInDeleteList(final List objects, final ECState eState) {
for (final Object object : objects) {
if (object instanceof EditPart && ((EditPart) object).getModel().equals(eState)) {
private static boolean stateContainedInDeleteList(final List<EditPart> objects, final ECState eState) {
for (final EditPart ep : objects) {
if (ep.getModel().equals(eState)) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any?endof=org.eclipse.gef.group.copy">
<command
categoryId="org.eclipse.fordiacpopup:org.eclipse.ui.popup.any"
commandId="org.eclipse.fordiac.ide.fbtypeeditor.servicesequence.expandSequence"
label="Expand/Collapse"
style="push">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,7 @@ public void selectionChanged(final IWorkbenchPart part, final ISelection selecti
*
* @return the sel actions
*/
@SuppressWarnings("rawtypes")
public List getSelActions() {
public List<String> getSelActions() {
return getSelectionActions();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public abstract class AbstractCombinedCellEditor<T> extends TextCellEditor {
private T element;

protected AbstractCombinedCellEditor(final T element) {
super();
this.element = element;
}

Expand All @@ -58,6 +57,7 @@ protected AbstractCombinedCellEditor(final T element, final Composite parent, fi
protected CCombo getCombobox() {
return comboBox;
}

@Override
protected Control createControl(final Composite parent) {
container = createContainer(parent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected PolylineConnection getConnectionFigure() {
}

@Override
protected List createSelectionHandles() {
protected List<? extends ConnectionEndpointHandle> createSelectionHandles() {
final List<ConnectionEndpointHandle> list = new ArrayList<>();
list.add(createConnectionEndPointHandle((ConnectionEditPart) getHost(), ConnectionLocator.SOURCE));
list.add(createConnectionEndPointHandle((ConnectionEditPart) getHost(), ConnectionLocator.TARGET));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.fordiac.ide.gef.editparts.AbstractConnectableEditPart;
import org.eclipse.fordiac.ide.gef.preferences.DiagramPreferences;
import org.eclipse.gef.Handle;
import org.eclipse.gef.Request;
import org.eclipse.gef.editpolicies.ResizableEditPolicy;

Expand All @@ -35,7 +36,7 @@ public void deactivate() {
}

@Override
protected void createMoveHandle(final List handles) {
protected void createMoveHandle(final List<Handle> handles) {
handles.add(new ModifiedMoveHandle(getHost(), insets, DiagramPreferences.CORNER_DIM));
removeSelectionFeedbackFigure();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- @generated communication -->
<package
uri="http://Communication/1.0"
class="org.eclipse.fordiac.ide.systemconfiguration.segment.communication.impl.CommunicationPackage"
class="org.eclipse.fordiac.ide.systemconfiguration.segment.communication.CommunicationPackage"
genModel="model/communication.genmodel"/>
</extension>
<extension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.eclipse.fordiac.ide.model.libraryElement.INamedElement;
import org.eclipse.fordiac.ide.model.libraryElement.LibraryElement;
import org.eclipse.fordiac.ide.model.libraryElement.LibraryElementPackage;
import org.eclipse.fordiac.ide.model.libraryElement.Link;
import org.eclipse.fordiac.ide.model.libraryElement.PositionableElement;
import org.eclipse.fordiac.ide.systemconfiguration.policies.DeleteDeviceEditPolicy;
import org.eclipse.fordiac.ide.systemconfiguration.policies.DeviceViewLayoutEditPolicy;
Expand Down Expand Up @@ -377,10 +378,7 @@ public ConnectionAnchor getTargetConnectionAnchor(final Request request) {
}

@Override
protected List<?> getModelTargetConnections() {
final List<Object> connections = new ArrayList<>();
connections.addAll(getModel().getInConnections());
connections.addAll(super.getModelTargetConnections());
return connections;
protected List<Link> getModelTargetConnections() {
return getModel().getInConnections();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static Listener getReverseSelectionListener(final TableViewer viewer, fin
final CommandProvider commandProvider) {
return ev -> {
if (!viewer.getStructuredSelection().isEmpty()) {
final List<Object> bottomup = viewer.getStructuredSelection().toList();
final List<?> bottomup = viewer.getStructuredSelection().toList();
Collections.reverse(bottomup);
executeCompoundCommandForList(viewer, bottomup, executor, commandProvider);
viewer.getTable().forceFocus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public static Listener getSelectionListener(final NatTable table, final CommandE
};
}

protected static void executeCompoundCommandForList(final TableViewer viewer, final List<Object> selection,
protected static void executeCompoundCommandForList(final TableViewer viewer, final List<?> selection,
final CommandExecutor executor, final CommandProvider commandProvider) {
final CompoundCommand cmd = new CompoundCommand();
selection.stream().forEach(elem -> cmd.add(commandProvider.getCommand(elem)));
Expand Down

0 comments on commit 8ca8d16

Please sign in to comment.