use of com.archimatetool.model.ITextPosition in project archi by archimatetool.
the class RepresentationFigure method calculateTextControlBounds.
@Override
public Rectangle calculateTextControlBounds() {
Rectangle bounds = getBounds().getCopy();
int textPosition = ((ITextPosition) getDiagramModelObject()).getTextPosition();
if (textPosition == ITextPosition.TEXT_POSITION_TOP) {
bounds.y += TOP_MARGIN - 4;
}
return bounds;
}
use of com.archimatetool.model.ITextPosition in project archi by archimatetool.
the class TextPositionSection method createControls.
@Override
protected void createControls(Composite parent) {
SelectionAdapter adapter = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
for (int i = 0; i < fPositionButtons.length; i++) {
// Select/deselects
fPositionButtons[i].setSelection(e.widget == fPositionButtons[i]);
// Commands
if (fPositionButtons[i] == e.widget) {
int position = (Integer) fPositionButtons[i].getData();
CompoundCommand result = new CompoundCommand();
for (EObject textPosition : getEObjects()) {
if (((ITextPosition) textPosition).getTextPosition() != position && isAlive(textPosition)) {
Command cmd = new TextPositionCommand((ITextPosition) textPosition, position);
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
}
}
};
// $NON-NLS-1$
createLabel(parent, Messages.TextPositionSection_3 + ":", ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
Composite client = createComposite(parent, 3);
for (int i = 0; i < fPositionButtons.length; i++) {
fPositionButtons[i] = new Button(client, SWT.TOGGLE | SWT.FLAT);
// Need to do it this way for Mac
getWidgetFactory().adapt(fPositionButtons[i], true, true);
fPositionButtons[i].addSelectionListener(adapter);
}
// Top Button
fPositionButtons[0].setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_ALIGN_TEXT_TOP));
fPositionButtons[0].setData(ITextPosition.TEXT_POSITION_TOP);
// Middle Button
fPositionButtons[1].setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_ALIGN_TEXT_MIDDLE));
fPositionButtons[1].setData(ITextPosition.TEXT_POSITION_CENTRE);
// Bottom Button
fPositionButtons[2].setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_ALIGN_TEXT_BOTTOM));
fPositionButtons[2].setData(ITextPosition.TEXT_POSITION_BOTTOM);
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
use of com.archimatetool.model.ITextPosition in project archi by archimatetool.
the class TextPositionAction method calculateEnabled.
@Override
protected boolean calculateEnabled() {
setChecked(false);
List<?> selected = getSelectedObjects();
ITextPosition model = (ITextPosition) getFirstValidSelectedModelObject(selected);
if (model != null && selected.size() == 1) {
setChecked(model.getTextPosition() == fPosition);
}
return model != null;
}
Aggregations