Search in sources :

Example 6 with ITextPosition

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;
}
Also used : ITextPosition(com.archimatetool.model.ITextPosition) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 7 with ITextPosition

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);
}
Also used : ITextPosition(com.archimatetool.model.ITextPosition) Composite(org.eclipse.swt.widgets.Composite) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) TextPositionCommand(com.archimatetool.editor.diagram.commands.TextPositionCommand) Command(org.eclipse.gef.commands.Command) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) EObject(org.eclipse.emf.ecore.EObject) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TextPositionCommand(com.archimatetool.editor.diagram.commands.TextPositionCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 8 with ITextPosition

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;
}
Also used : ITextPosition(com.archimatetool.model.ITextPosition)

Aggregations

ITextPosition (com.archimatetool.model.ITextPosition)8 Rectangle (org.eclipse.draw2d.geometry.Rectangle)4 TextPositionCommand (com.archimatetool.editor.diagram.commands.TextPositionCommand)2 Command (org.eclipse.gef.commands.Command)2 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)2 BorderColorCommand (com.archimatetool.editor.diagram.commands.BorderColorCommand)1 ConnectionTextPositionCommand (com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand)1 DiagramModelObjectAlphaCommand (com.archimatetool.editor.diagram.commands.DiagramModelObjectAlphaCommand)1 FillColorCommand (com.archimatetool.editor.diagram.commands.FillColorCommand)1 FontColorCommand (com.archimatetool.editor.diagram.commands.FontColorCommand)1 FontStyleCommand (com.archimatetool.editor.diagram.commands.FontStyleCommand)1 LineColorCommand (com.archimatetool.editor.diagram.commands.LineColorCommand)1 LineWidthCommand (com.archimatetool.editor.diagram.commands.LineWidthCommand)1 TextAlignmentCommand (com.archimatetool.editor.diagram.commands.TextAlignmentCommand)1 IBorderObject (com.archimatetool.model.IBorderObject)1 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)1 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)1 IFontAttribute (com.archimatetool.model.IFontAttribute)1 ILineObject (com.archimatetool.model.ILineObject)1 ITextAlignment (com.archimatetool.model.ITextAlignment)1