use of com.archimatetool.model.IFontAttribute in project archi by archimatetool.
the class FontColorSection method update.
@Override
protected void update() {
String colorValue = ((IFontAttribute) getFirstSelectedObject()).getFontColor();
RGB rgb = ColorFactory.convertStringToRGB(colorValue);
if (rgb != null) {
fColorChooser.setColorValue(rgb);
} else {
// Null is the default system color
fColorChooser.setColorValue(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND).getRGB());
}
fColorChooser.setEnabled(!isLocked(getFirstSelectedObject()));
fColorChooser.setIsDefaultColor(colorValue == null);
}
use of com.archimatetool.model.IFontAttribute in project archi by archimatetool.
the class FontSection method update.
@Override
protected void update() {
IFontAttribute lastSelected = (IFontAttribute) getFirstSelectedObject();
fFontChooser.setFontObject(lastSelected);
fFontChooser.setEnabled(!isLocked(lastSelected));
fFontChooser.setIsDefaultFont(lastSelected.getFont() == null);
}
use of com.archimatetool.model.IFontAttribute in project archi by archimatetool.
the class FormatPainterTool method createCommand.
protected CompoundCommand createCommand(PaintFormat pf, IDiagramModelComponent targetComponent) {
CompoundCommand result = new CompoundCommand(Messages.FormatPainterTool_0);
// IFontAttribute
if (pf.getSourceComponent() instanceof IFontAttribute && targetComponent instanceof IFontAttribute) {
IFontAttribute source = (IFontAttribute) pf.getSourceComponent();
IFontAttribute target = (IFontAttribute) targetComponent;
Command cmd = new FontStyleCommand(target, source.getFont());
if (cmd.canExecute()) {
result.add(cmd);
}
cmd = new FontColorCommand(target, source.getFontColor());
if (cmd.canExecute()) {
result.add(cmd);
}
}
// ILineObject
if (pf.getSourceComponent() instanceof ILineObject && targetComponent instanceof ILineObject) {
ILineObject source = (ILineObject) pf.getSourceComponent();
ILineObject target = (ILineObject) targetComponent;
Command cmd = new LineColorCommand(target, source.getLineColor());
if (cmd.canExecute()) {
result.add(cmd);
}
cmd = new LineWidthCommand(target, source.getLineWidth());
if (cmd.canExecute()) {
result.add(cmd);
}
}
// IBorderObject
if (pf.getSourceComponent() instanceof IBorderObject && targetComponent instanceof IBorderObject) {
IBorderObject source = (IBorderObject) pf.getSourceComponent();
IBorderObject target = (IBorderObject) targetComponent;
Command cmd = new BorderColorCommand(target, source.getBorderColor());
if (cmd.canExecute()) {
result.add(cmd);
}
}
// ITextPosition
if (pf.getSourceComponent() instanceof ITextPosition && targetComponent instanceof ITextPosition) {
ITextPosition source = (ITextPosition) pf.getSourceComponent();
ITextPosition target = (ITextPosition) targetComponent;
Command cmd = new TextPositionCommand(target, source.getTextPosition());
if (cmd.canExecute()) {
result.add(cmd);
}
}
// ITextAlignment
if (pf.getSourceComponent() instanceof ITextAlignment && targetComponent instanceof ITextAlignment) {
ITextAlignment source = (ITextAlignment) pf.getSourceComponent();
ITextAlignment target = (ITextAlignment) targetComponent;
Command cmd = new TextAlignmentCommand(target, source.getTextAlignment());
if (cmd.canExecute()) {
result.add(cmd);
}
}
// IDiagramModelObject
if (pf.getSourceComponent() instanceof IDiagramModelObject && targetComponent instanceof IDiagramModelObject) {
IDiagramModelObject source = (IDiagramModelObject) pf.getSourceComponent();
IDiagramModelObject target = (IDiagramModelObject) targetComponent;
// Source fill colour is null which is "default"
String fillColorString = source.getFillColor();
if (fillColorString == null) {
fillColorString = ColorFactory.convertColorToString(ColorFactory.getDefaultFillColor(source));
}
Command cmd = new FillColorCommand(target, fillColorString);
if (cmd.canExecute()) {
result.add(cmd);
}
// Alpha opacity
cmd = new DiagramModelObjectAlphaCommand(target, source.getAlpha());
if (cmd.canExecute()) {
result.add(cmd);
}
}
// IDiagramModelConnection
if (pf.getSourceComponent() instanceof IDiagramModelConnection && targetComponent instanceof IDiagramModelConnection) {
IDiagramModelConnection source = (IDiagramModelConnection) pf.getSourceComponent();
IDiagramModelConnection target = (IDiagramModelConnection) targetComponent;
// Connection text position
Command cmd = new ConnectionTextPositionCommand(target, source.getTextPosition());
if (cmd.canExecute()) {
result.add(cmd);
}
}
return result;
}
use of com.archimatetool.model.IFontAttribute in project archi by archimatetool.
the class FontAction method run.
@Override
public void run() {
List<?> selection = getSelectedObjects();
IFontAttribute model = (IFontAttribute) getFirstValidSelectedModelObject(selection);
if (model == null) {
return;
}
// Set default font on first selected object
FontData fontData = FontFactory.getDefaultUserViewFontData();
String rgbValue = null;
rgbValue = model.getFontColor();
String fontValue = model.getFont();
if (fontValue != null) {
try {
fontData = new FontData(fontValue);
} catch (Exception ex) {
// ex.printStackTrace();
}
}
FontDialog dialog = new FontDialog(getWorkbenchPart().getSite().getShell());
dialog.setText(Messages.FontAction_1);
dialog.setFontList(new FontData[] { fontData });
dialog.setRGB(ColorFactory.convertStringToRGB(rgbValue));
FontData selectedFontData = dialog.open();
if (selectedFontData != null) {
execute(createCommand(selection, selectedFontData, dialog.getRGB()));
}
}
use of com.archimatetool.model.IFontAttribute in project archi by archimatetool.
the class FontColorAction method run.
@Override
public void run() {
List<?> selection = getSelectedObjects();
IFontAttribute model = (IFontAttribute) getFirstValidSelectedModelObject(selection);
if (model == null) {
return;
}
ColorDialog colorDialog = new ColorDialog(getWorkbenchPart().getSite().getShell());
// Set default RGB on first selected object
RGB defaultRGB = null;
String s = model.getFontColor();
if (s != null) {
defaultRGB = ColorFactory.convertStringToRGB(s);
}
if (defaultRGB != null) {
colorDialog.setRGB(defaultRGB);
} else {
colorDialog.setRGB(new RGB(0, 0, 0));
}
RGB newColor = colorDialog.open();
if (newColor != null) {
execute(createCommand(selection, newColor));
}
}
Aggregations