use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.
the class AbstractECorePropertySection method executeCommand.
/**
* Execuate a command on the selected objects' CommandStack
* @param cmd
*/
protected void executeCommand(Command command) {
fIsExecutingCommand = true;
EObject eObject = getFirstSelectedObject();
if (eObject != null && eObject instanceof IAdapter) {
CommandStack commandStack = (CommandStack) ((IAdapter) eObject).getAdapter(CommandStack.class);
if (commandStack != null) {
commandStack.execute(command);
}
}
fIsExecutingCommand = false;
}
use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.
the class DirectEditManager method commit.
/**
* Commits the current value of the cell editor by getting a {@link Command}
* from the source edit part and executing it via the {@link CommandStack}.
* Finally, {@link #bringDown()} is called to perform and necessary cleanup.
*/
protected void commit() {
if (committing)
return;
committing = true;
try {
eraseFeedback();
if (isDirty()) {
CommandStack stack = getEditPart().getViewer().getEditDomain().getCommandStack();
stack.execute(getEditPart().getCommand(getDirectEditRequest()));
}
} finally {
bringDown();
committing = false;
}
}
use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.
the class CSVImporterTests method testDoImport.
@Test
public void testDoImport() throws Exception {
importer.doImport(elements1File);
testDoImportPart1();
// Now undo it
CommandStack stack = (CommandStack) model.getAdapter(CommandStack.class);
stack.undo();
assertEquals("", model.getName());
assertEquals("", model.getPurpose());
assertEquals(0, model.getProperties().size());
assertEquals(0, model.getFolder(FolderType.BUSINESS).getElements().size());
assertEquals(0, model.getFolder(FolderType.RELATIONS).getElements().size());
}
use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.
the class CreateEmptyModelProvider method createEmptyModel.
private IArchimateModel createEmptyModel() {
IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
model.setDefaults();
// Add an Archive Manager
IArchiveManager archiveManager = IArchiveManager.FACTORY.createArchiveManager(model);
model.setAdapter(IArchiveManager.class, archiveManager);
// Add a Command Stack
CommandStack cmdStack = new CommandStack();
model.setAdapter(CommandStack.class, cmdStack);
logMessage(Messages.CreateEmptyModelProvider_7);
return model;
}
use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.
the class ProfilesManagerDialog method okPressed.
/**
* OK was pressed, so see what was added, changed or deleted and execute the Commands
*/
@Override
protected void okPressed() {
super.okPressed();
CompoundCommand compoundCmd = new CompoundCommand(Messages.ProfilesManagerDialog_16);
// Iterate thru our temp list of Profiles
for (IProfile profile : fProfilesTemp.values()) {
// Is this a copy of the original?
if (fProfilesModel.containsKey(profile.getId())) {
IProfile profileOriginal = fProfilesModel.get(profile.getId());
// The Profile has been edited
if (!EcoreUtil.equals(profileOriginal, profile)) {
List<IProfiles> usages = fProfilesUsage.get(profileOriginal.getId());
compoundCmd.add(new ChangeProfileCommand(profileOriginal, profile, usages));
}
} else // A new Profile was added
{
compoundCmd.add(new AddListMemberCommand<IProfile>(fArchimateModel.getProfiles(), profile));
}
}
// Iterate thru model's Profiles and compare with our temp list to see if any Profiles were deleted
for (IProfile profile : fArchimateModel.getProfiles()) {
if (!fProfilesTemp.containsKey(profile.getId())) {
List<IProfiles> usages = fProfilesUsage.get(profile.getId());
compoundCmd.add(new DeleteProfileCommand(profile, usages));
}
}
// Execute the Commands
CommandStack stack = (CommandStack) fArchimateModel.getAdapter(CommandStack.class);
stack.execute(compoundCmd);
}
Aggregations