use of com.archimatetool.editor.model.commands.EObjectFeatureCommand in project archi by archimatetool.
the class TextContentSection method createControls.
@Override
protected void createControls(Composite parent) {
createLabel(parent, Messages.TextContentSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.NONE);
StyledTextControl styledTextControl = createStyledTextControl(parent, SWT.NONE);
styledTextControl.setMessage(Messages.TextContentSection_2);
fTextContentControl = new PropertySectionTextControl(styledTextControl.getControl(), IArchimatePackage.Literals.TEXT_CONTENT__CONTENT) {
@Override
protected void textChanged(String oldText, String newText) {
CompoundCommand result = new CompoundCommand();
for (EObject textContent : getEObjects()) {
if (isAlive(textContent)) {
Command cmd = new EObjectFeatureCommand(Messages.TextContentSection_1, textContent, IArchimatePackage.Literals.TEXT_CONTENT__CONTENT, newText);
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
};
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(fTextContentControl.getTextControl(), 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);
fCanvas = new Canvas(parent, SWT.BORDER);
getWidgetFactory().adapt(fCanvas);
GridData gd = new GridData(SWT.NONE, SWT.NONE, false, false);
gd.widthHint = IMAGE_SIZE;
gd.heightHint = IMAGE_SIZE;
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 (fImageButton.isEnabled()) {
chooseImage();
}
}
});
fCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
if (fImage != null) {
e.gc.setAntialias(SWT.ON);
e.gc.setInterpolation(SWT.HIGH);
Rectangle imageBounds = fImage.getBounds();
Rectangle newSize = ImageFactory.getScaledImageSize(fImage, IMAGE_SIZE);
// Centre the image
int x = (IMAGE_SIZE - newSize.width) / 2;
int y = (IMAGE_SIZE - newSize.height) / 2;
e.gc.drawImage(fImage, 0, 0, imageBounds.width, imageBounds.height, x, y, newSize.width, newSize.height);
}
}
});
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[] && fImageButton.isEnabled()) {
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);
getWidgetFactory().adapt(fComboPosition, true, true);
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, IArchimatePackage.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 AbstractImporter method importImageBytes.
/**
* Import the image bytes from the imported model's IDiagramModelImageProvider to the target model's IDiagramModelImageProvider
*/
protected void importImageBytes(IDiagramModelImageProvider importedObject, IDiagramModelImageProvider targetObject) throws IOException {
String importedImagePath = importedObject.getImagePath();
if (importedImagePath != null) {
IArchiveManager importedArchiveManager = (IArchiveManager) getImportedModel().getAdapter(IArchiveManager.class);
IArchiveManager targetArchiveManager = (IArchiveManager) getTargetModel().getAdapter(IArchiveManager.class);
importedImagePath = targetArchiveManager.copyImageBytes(importedArchiveManager, importedImagePath);
addCommand(new EObjectFeatureCommand(null, targetObject, IArchimatePackage.Literals.DIAGRAM_MODEL_IMAGE_PROVIDER__IMAGE_PATH, importedImagePath));
}
}
use of com.archimatetool.editor.model.commands.EObjectFeatureCommand in project archi by archimatetool.
the class HintContentSection method createControls.
@Override
protected void createControls(Composite parent) {
createLabel(parent, Messages.HintContentSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
Text text = createSingleTextControl(parent, SWT.NONE);
text.setMessage(Messages.HintContentSection_2);
fTextTitleControl = new PropertySectionTextControl(text, ICanvasPackage.Literals.HINT_PROVIDER__HINT_TITLE) {
@Override
protected void textChanged(String oldText, String newText) {
CompoundCommand result = new CompoundCommand();
for (EObject provider : getEObjects()) {
if (isAlive(provider)) {
Command cmd = new EObjectFeatureCommand(Messages.HintContentSection_1, provider, ICanvasPackage.Literals.HINT_PROVIDER__HINT_TITLE, newText);
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
};
createLabel(parent, Messages.HintContentSection_3, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.NONE);
StyledTextControl styledTextControl = createStyledTextControl(parent, SWT.NONE);
styledTextControl.setMessage(Messages.HintContentSection_5);
fTextContentControl = new PropertySectionTextControl(styledTextControl.getControl(), ICanvasPackage.Literals.HINT_PROVIDER__HINT_CONTENT) {
@Override
protected void textChanged(String oldText, String newText) {
CompoundCommand result = new CompoundCommand();
for (EObject provider : getEObjects()) {
if (isAlive(provider)) {
Command cmd = new EObjectFeatureCommand(Messages.HintContentSection_4, provider, ICanvasPackage.Literals.HINT_PROVIDER__HINT_CONTENT, newText);
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
};
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(fTextContentControl.getTextControl(), HELP_ID);
}
use of com.archimatetool.editor.model.commands.EObjectFeatureCommand in project archi by archimatetool.
the class NotesSection method createControls.
@Override
protected void createControls(Composite parent) {
createLabel(parent, Messages.NotesSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.NONE);
StyledTextControl styledTextControl = createStyledTextControl(parent, SWT.NONE);
styledTextControl.setMessage(Messages.NotesSection_2);
fTextNotesControl = new PropertySectionTextControl(styledTextControl.getControl(), ICanvasPackage.Literals.NOTES_CONTENT__NOTES) {
@Override
protected void textChanged(String oldText, String newText) {
CompoundCommand result = new CompoundCommand();
for (EObject notesContent : getEObjects()) {
if (isAlive(notesContent)) {
Command cmd = new EObjectFeatureCommand(Messages.NotesSection_1, notesContent, ICanvasPackage.Literals.NOTES_CONTENT__NOTES, newText);
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
};
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(fTextNotesControl.getTextControl(), HELP_ID);
}
Aggregations