use of com.archimatetool.editor.model.commands.EObjectFeatureCommand in project archi by archimatetool.
the class DiagramModelImageSection method clearImage.
protected void clearImage() {
CompoundCommand result = new CompoundCommand();
for (EObject dmo : getEObjects()) {
if (isAlive(dmo)) {
Command cmd = new EObjectFeatureCommand(Messages.DiagramModelImageSection_4, dmo, IArchimatePackage.Literals.DIAGRAM_MODEL_IMAGE_PROVIDER__IMAGE_PATH, null);
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
use of com.archimatetool.editor.model.commands.EObjectFeatureCommand in project archi by archimatetool.
the class DiagramEditorFindReplaceProvider method doRenameCommand.
void doRenameCommand(EditPart editPart, String newName) {
INameable object = (INameable) editPart.getModel();
CommandStack stack = (CommandStack) ((IAdapter) object).getAdapter(CommandStack.class);
if (stack != null) {
stack.execute(new EObjectFeatureCommand(NLS.bind(Messages.DiagramEditorFindReplaceProvider_0, object.getName()), object, IArchimatePackage.Literals.NAMEABLE__NAME, newName));
}
}
use of com.archimatetool.editor.model.commands.EObjectFeatureCommand in project archi by archimatetool.
the class NoteSection method createControls.
@Override
protected void createControls(Composite parent) {
createLabel(parent, Messages.NoteSection_3, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
// Combo
fComboBorderType = new Combo(parent, SWT.READ_ONLY);
fComboBorderType.setItems(comboItems);
fComboBorderType.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
CompoundCommand result = new CompoundCommand();
for (EObject note : getEObjects()) {
if (isAlive(note)) {
Command cmd = new EObjectFeatureCommand(Messages.NoteSection_4, note, IArchimatePackage.Literals.DIAGRAM_MODEL_NOTE__BORDER_TYPE, fComboBorderType.getSelectionIndex());
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
});
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
use of com.archimatetool.editor.model.commands.EObjectFeatureCommand in project archi by archimatetool.
the class IconSection method createControls.
@Override
protected void createControls(Composite parent) {
createLabel(parent, Messages.IconSection_9, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.NONE);
final int canvasSize = IIconic.MAX_IMAGE_SIZE;
fCanvas = new Canvas(parent, SWT.BORDER);
getWidgetFactory().adapt(fCanvas);
GridData gd = new GridData(SWT.NONE, SWT.NONE, false, false);
gd.widthHint = canvasSize;
gd.heightHint = canvasSize;
fCanvas.setLayoutData(gd);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
fCanvas.setLayout(layout);
fCanvas.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
disposeImage();
}
});
fCanvas.addListener(SWT.MouseDoubleClick, new Listener() {
@Override
public void handleEvent(Event event) {
if (!isLocked(getFirstSelectedObject())) {
chooseImage();
}
}
});
fCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
if (fImage != null) {
Rectangle bounds = fImage.getBounds();
int x = (canvasSize - bounds.width) / 2;
int y = (canvasSize - bounds.height) / 2;
e.gc.drawImage(fImage, x, y);
}
}
});
String tooltip = Messages.IconSection_10;
fCanvas.setToolTipText(tooltip);
DropTarget target = new DropTarget(fCanvas, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT);
target.setTransfer(new Transfer[] { FileTransfer.getInstance() });
target.addDropListener(new DropTargetAdapter() {
@Override
public void drop(DropTargetEvent event) {
if (event.data instanceof String[]) {
if (!isLocked(getFirstSelectedObject())) {
File file = new File(((String[]) event.data)[0]);
setImage(file);
}
}
}
});
// Image Button
createImageButton(parent);
// Position
createLabel(parent, Messages.IconSection_11, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
fComboPosition = new Combo(parent, SWT.READ_ONLY);
fComboPosition.setItems(fComboPositionItems);
gd = new GridData(SWT.NONE, SWT.NONE, false, false);
fComboPosition.setLayoutData(gd);
fComboPosition.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
CompoundCommand result = new CompoundCommand();
for (EObject iconic : getEObjects()) {
if (isAlive(iconic)) {
Command cmd = new EObjectFeatureCommand(Messages.IconSection_12, iconic, ICanvasPackage.Literals.ICONIC__IMAGE_POSITION, fComboPosition.getSelectionIndex());
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
});
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
use of com.archimatetool.editor.model.commands.EObjectFeatureCommand in project archi by archimatetool.
the class InfluenceRelationshipSection method createControls.
@Override
protected void createControls(Composite parent) {
createLabel(parent, Messages.InfluenceRelationshipSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
Text text = createSingleTextControl(parent, SWT.NONE);
text.setMessage(Messages.InfluenceRelationshipSection_2);
fTextStrength = new PropertySectionTextControl(text, IArchimatePackage.Literals.INFLUENCE_RELATIONSHIP__STRENGTH) {
@Override
protected void textChanged(String oldText, String newText) {
CompoundCommand result = new CompoundCommand();
for (EObject relationship : getEObjects()) {
if (isAlive(relationship)) {
Command cmd = new EObjectFeatureCommand(Messages.InfluenceRelationshipSection_1, relationship, IArchimatePackage.Literals.INFLUENCE_RELATIONSHIP__STRENGTH, newText);
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
};
// Help ID
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
Aggregations