Skip to content
Snippets Groups Projects
Commit cc0d743a authored by Kevin Kassin's avatar Kevin Kassin
Browse files

#Commit 1.8

Warning if there are unsaved changes in another multipage editor now has
a save all option,
attribute and operations text now shrink and expand with when layouting
types
parent cc80c6c6
No related branches found
No related tags found
No related merge requests found
package org.framed.iorm.ui.graphitifeatures;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.ICustomContext;
import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.framed.iorm.ui.literals.IdentifierLiterals;
import org.framed.iorm.ui.multipage.MultipageEditor;
......@@ -74,24 +72,6 @@ public abstract class AbstractStepInFeature extends AbstractCustomFeature {
return false;
}
/**
* manages to close a given multipage editor at the next reasonable opportunity usind the operation
* {@link Display#asyncExec}
* <p>
* It also saves the multipage editor before closing it to clean up the dirty state of the whole workbench.
* @param multipageEditorToClose
*/
public static void closeMultipageEditorWhenPossible(MultipageEditor multipageEditorToClose) {
Display display = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay();
display.asyncExec(new Runnable() {
@Override
public void run() {
multipageEditorToClose.getDiagramEditor().doSave(new NullProgressMonitor());
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(multipageEditorToClose, false);
}
});
}
/**
* to be overriden in subclasses
*/
......
......@@ -62,7 +62,7 @@ public class StepInFeature extends AbstractStepInFeature {
//Step 1
MultipageEditor multipageEditorToClose =
(MultipageEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
closeMultipageEditorWhenPossible(multipageEditorToClose);
GeneralUtil.closeMultipageEditorWhenPossible(multipageEditorToClose);
//Step 2
ContainerShape typeBodyShape = (ContainerShape) context.getPictogramElements()[0];
Type type = null;
......
......@@ -11,6 +11,7 @@ import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.ui.editor.DiagramEditorInput;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorInput;
......@@ -413,8 +414,18 @@ public class MultipageEditor extends FormEditor implements ISelectionListener, I
}
if(unsavedChangesInOtherMultipageEditors) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
MessageDialog.openInformation(shell, MESSAGE_UNSAVED_CHANGES_IN_OTHER_MULTIPAGE_EDITORS_TITLE, MESSAGE_UNSAVED_CHANGES_IN_OTHER_MULTIPAGE_EDITORS_TEXT);
}
MessageDialog dialog = new MessageDialog(shell,
MESSAGE_UNSAVED_CHANGES_IN_OTHER_MULTIPAGE_EDITORS_TITLE, null,
MESSAGE_UNSAVED_CHANGES_IN_OTHER_MULTIPAGE_EDITORS_TEXT, MessageDialog.ERROR,
new String[] {"Save All", "OK"}, 0);
int result = dialog.open();
if(result == 0) {
Display display = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay();
display.asyncExec(new Runnable() {
@Override
public void run() {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().saveAllEditors(false);
} }); } }
activeWorkbenchPart = (MultipageEditor) part;
} } } }
......
......@@ -650,7 +650,9 @@ public class CompartmentTypePattern extends FRaMEDShapePattern implements IPatte
EList<Shape> attributes = attributeContainerShape.getChildren();
//set place of attributes
for(int m = 0; m<attributes.size(); m++) {
attributeContainerShape.getChildren().get(m).getGraphicsAlgorithm().setY(newY+m*HEIGHT_OPERATION_SHAPE);
Text attributeText = (Text) attributeContainerShape.getChildren().get(m).getGraphicsAlgorithm();
attributeText.setY(newY+m*HEIGHT_OPERATION_SHAPE);
attributeText.setWidth(newWidth);
}
//set all attributes visible
indicatorDotsShapeToDelete = null;
......@@ -691,7 +693,9 @@ public class CompartmentTypePattern extends FRaMEDShapePattern implements IPatte
EList<Shape> operations = operationContainerShape.getChildren();
//set place of attributes
for(int m = 0; m<operations.size(); m++) {
operationContainerShape.getChildren().get(m).getGraphicsAlgorithm().setY(newY+m*HEIGHT_OPERATION_SHAPE);
Text operationText = (Text) operationContainerShape.getChildren().get(m).getGraphicsAlgorithm();
operationText.setY(newY+m*HEIGHT_OPERATION_SHAPE);
operationText.setWidth(newWidth);
}
//set all operations visible
indicatorDotsShapeToDelete = null;
......
......@@ -602,7 +602,9 @@ public class DataTypePattern extends FRaMEDShapePattern implements IPattern {
EList<Shape> attributes = attributeContainerShape.getChildren();
//set place of attributes
for(int m = 0; m<attributes.size(); m++) {
attributeContainerShape.getChildren().get(m).getGraphicsAlgorithm().setY(newY+m*HEIGHT_OPERATION_SHAPE);
Text attributeText = (Text) attributeContainerShape.getChildren().get(m).getGraphicsAlgorithm();
attributeText.setY(newY+m*HEIGHT_OPERATION_SHAPE);
attributeText.setWidth(newWidth);
}
//set all attributes visible
indicatorDotsShapeToDelete = null;
......@@ -643,7 +645,9 @@ public class DataTypePattern extends FRaMEDShapePattern implements IPattern {
EList<Shape> operations = operationContainerShape.getChildren();
//set place of operations
for(int m = 0; m<operations.size(); m++) {
operationContainerShape.getChildren().get(m).getGraphicsAlgorithm().setY(newY+m*HEIGHT_OPERATION_SHAPE);
Text operationText = (Text) operationContainerShape.getChildren().get(m).getGraphicsAlgorithm();
operationText.setY(newY+m*HEIGHT_OPERATION_SHAPE);
operationText.setWidth(newWidth);
}
//set all operations visible
indicatorDotsShapeToDelete = null;
......
......@@ -594,7 +594,9 @@ public class NaturalTypePattern extends FRaMEDShapePattern implements IPattern {
EList<Shape> attributes = attributeContainerShape.getChildren();
//set places of attributes
for(int m = 0; m<attributes.size(); m++) {
attributeContainerShape.getChildren().get(m).getGraphicsAlgorithm().setY(newY+m*HEIGHT_OPERATION_SHAPE);
Text attributeText = (Text) attributeContainerShape.getChildren().get(m).getGraphicsAlgorithm();
attributeText.setY(newY+m*HEIGHT_OPERATION_SHAPE);
attributeText.setWidth(newWidth);
}
//set all attributes visible and delete indicator dots
indicatorDotsShapeToDelete = null;
......@@ -635,7 +637,9 @@ public class NaturalTypePattern extends FRaMEDShapePattern implements IPattern {
EList<Shape> operations = operationContainerShape.getChildren();
//set place of operations
for(int m = 0; m<operations.size(); m++) {
operationContainerShape.getChildren().get(m).getGraphicsAlgorithm().setY(newY+m*HEIGHT_OPERATION_SHAPE);
Text operationText = (Text) operationContainerShape.getChildren().get(m).getGraphicsAlgorithm();
operationText.setY(newY+m*HEIGHT_OPERATION_SHAPE);
operationText.setWidth(newWidth);
}
//set all operations visible
indicatorDotsShapeToDelete = null;
......
......@@ -618,7 +618,9 @@ public class RoleTypePattern extends FRaMEDShapePattern implements IPattern {
EList<Shape> attributes = attributeContainerShape.getChildren();
//set places of attributes
for(int m = 0; m<attributes.size(); m++) {
attributeContainerShape.getChildren().get(m).getGraphicsAlgorithm().setY(newY+m*HEIGHT_OPERATION_SHAPE);
Text attributeText = (Text) attributeContainerShape.getChildren().get(m).getGraphicsAlgorithm();
attributeText.setY(newY+m*HEIGHT_OPERATION_SHAPE);
attributeText.setWidth(newWidth);
}
//set all attributes visible and delete indicator dots
indicatorDotsShapeToDelete = null;
......@@ -659,7 +661,9 @@ public class RoleTypePattern extends FRaMEDShapePattern implements IPattern {
EList<Shape> operations = operationContainerShape.getChildren();
//set place of operations
for(int m = 0; m<operations.size(); m++) {
operationContainerShape.getChildren().get(m).getGraphicsAlgorithm().setY(newY+m*HEIGHT_OPERATION_SHAPE);
Text operationText = (Text) operationContainerShape.getChildren().get(m).getGraphicsAlgorithm();
operationText.setY(newY+m*HEIGHT_OPERATION_SHAPE);
operationText.setWidth(newWidth);
}
//set all operations visible
indicatorDotsShapeToDelete = null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment