use of org.eclipse.swt.graphics.Font in project cubrid-manager by CUBRID.
the class QueryExecuter method makeResult.
/**
* Make query editor result panel,including table panel and sql text and
* message text
*
* @param resultTbl the Table.
* @param sqlText the Text.
* @param messageText the StyledText.
*/
public void makeResult(final TableSelectSupport tableSelectSupport, StyledText messageText, boolean multiQueryResult) {
this.selectableSupport = tableSelectSupport;
this.tblResult = tableSelectSupport.getTable();
logMessageText = messageText;
int[] queryInfoRange = new int[2];
int[] queryRange = new int[2];
StringBuilder resultMessage = new StringBuilder();
resultMessage.append(getQueryMsg() == null ? "" : getQueryMsg().trim());
queryInfoRange[0] = 0;
queryInfoRange[1] = resultMessage.length();
resultMessage.append(StringUtil.NEWLINE).append(QueryUtil.SPLIT_LINE_FOR_QUERY_RESULT).append(StringUtil.NEWLINE);
queryRange[0] = resultMessage.length();
resultMessage.append(query);
queryRange[1] = query.length();
ServerInfo serverInfo = database.getServer() == null ? null : database.getServer().getServerInfo();
String fontString = QueryOptions.getFontString(serverInfo);
Font tmpFont = ResourceManager.getFont(fontString);
if (tmpFont == null) {
String[] fontData = QueryOptions.getDefaultFont();
tmpFont = ResourceManager.getFont(fontData[0], Integer.valueOf(fontData[1]), Integer.valueOf(fontData[2]));
}
font = tmpFont;
tblResult.setFont(font);
int[] fontColor = QueryOptions.getFontColor(serverInfo);
color = ResourceManager.getColor(fontColor[0], fontColor[1], fontColor[2]);
tblResult.setForeground(color);
// Set font and foreground
selectableSupport.getTableCursor().setFont(font);
selectableSupport.getTableCursor().setForeground(color);
selectableSupport.setShowDetailOperator(this);
tblResult.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
selectableSupport.redrawMoreButton();
}
});
if (queryEditor != null) {
if (!multiQueryResult) {
createContextMenuItems();
}
editor = new ControlEditor(selectableSupport.getTableCursor());
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.grabVertical = true;
bindEvents();
addTableItemToolTips();
}
makeColumn();
makeItem();
if (!StringUtil.isEmpty(queryPlanLog)) {
resultMessage.append(StringUtil.NEWLINE).append(QueryUtil.SPLIT_LINE_FOR_QUERY_RESULT);
resultMessage.append(StringUtil.NEWLINE).append(queryPlanLog);
}
if (!StringUtil.isEmpty(statsLog)) {
resultMessage.append(StringUtil.NEWLINE).append(Messages.queryStat).append(":");
resultMessage.append(StringUtil.NEWLINE).append(QueryUtil.SPLIT_LINE_FOR_QUERY_RESULT);
resultMessage.append(StringUtil.NEWLINE).append(statsLog);
}
messageText.setText(resultMessage.toString());
// Styled Query info
StyleRange queryInfoStyle = new StyleRange();
queryInfoStyle.start = queryInfoRange[0];
queryInfoStyle.length = queryInfoRange[1];
queryInfoStyle.fontStyle = SWT.NORMAL;
queryInfoStyle.foreground = ResourceManager.getColor(SWT.COLOR_BLUE);
messageText.setStyleRange(queryInfoStyle);
StyleRange queryStyle = new StyleRange();
queryStyle.start = queryRange[0];
queryStyle.length = queryRange[1];
queryStyle.fontStyle = SWT.BOLD;
messageText.setStyleRange(queryStyle);
// styled log text
updateStyledLogTextForStatistics(messageText);
updateStyledLogTextForPlan(messageText);
updateStyledLogTextForTrace(messageText);
}
use of org.eclipse.swt.graphics.Font in project cubrid-manager by CUBRID.
the class QueryResultComposite method displayDataCompareLabel.
/**
* Display Data Compare Label
*/
public void displayDataCompareLabel(final Composite composite, final Table resultTable) {
Color redColor = ResourceManager.getColor(255, 0, 0);
Color greenColor = ResourceManager.getColor(0, 154, 33);
Color blueColor = ResourceManager.getColor(0, 0, 255);
Composite labelComposite = new Composite(composite, SWT.NONE);
labelComposite.setLayout(new GridLayout(6, false));
if (this.baseQueryExecuter != null) {
Label labelRedIconMsg = new Label(labelComposite, SWT.NONE);
labelRedIconMsg.setText(Messages.diffData);
labelRedIconMsg.setForeground(redColor);
Label sepWithResult = new Label(labelComposite, SWT.SEPARATOR | SWT.VERTICAL | SWT.SHADOW_OUT);
sepWithResult.setLayoutData(new GridData(GridData.FILL_VERTICAL));
Label labelGreenIconMsg = new Label(labelComposite, SWT.NONE);
labelGreenIconMsg.setText(Messages.extraColumns);
labelGreenIconMsg.setForeground(greenColor);
Label sepWithResult2 = new Label(labelComposite, SWT.SEPARATOR | SWT.VERTICAL | SWT.SHADOW_OUT);
sepWithResult2.setLayoutData(new GridData(GridData.FILL_VERTICAL));
Label labelBlueIconMsg = new Label(labelComposite, SWT.NONE);
labelBlueIconMsg.setText(Messages.extraRows);
labelBlueIconMsg.setForeground(blueColor);
final Button viewComparisonBtn = new Button(labelComposite, SWT.NONE);
viewComparisonBtn.setText(Messages.hideHighlight);
viewComparisonBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, true, 1, 2));
viewComparisonBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
if (showHighlight == true) {
hideCompareHighlight(resultTable);
viewComparisonBtn.setText(Messages.showHighlight);
showHighlight = false;
} else {
showCompareHighlight(resultTable);
viewComparisonBtn.setText(Messages.hideHighlight);
showHighlight = true;
}
}
});
} else {
Label baseLabel = new Label(labelComposite, SWT.NONE);
baseLabel.setText(Messages.baseTableMsg);
baseLabel.setFont(new Font(Display.getCurrent(), "Arial", 8, SWT.BOLD));
}
}
use of org.eclipse.swt.graphics.Font in project dbeaver by serge-rider.
the class EmptyPresentation method createPresentation.
@Override
public void createPresentation(@NotNull final IResultSetController controller, @NotNull Composite parent) {
super.createPresentation(controller, parent);
UIUtils.createHorizontalLine(parent);
placeholder = new Canvas(parent, SWT.NONE);
placeholder.setLayoutData(new GridData(GridData.FILL_BOTH));
placeholder.setBackground(controller.getDefaultBackground());
final Font normalFont = parent.getFont();
FontData[] fontData = normalFont.getFontData();
fontData[0].setStyle(fontData[0].getStyle() | SWT.BOLD);
fontData[0].setHeight(18);
final Font largeFont = new Font(normalFont.getDevice(), fontData[0]);
placeholder.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
UIUtils.dispose(largeFont);
}
});
placeholder.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
if (controller.isRefreshInProgress()) {
return;
}
e.gc.setFont(largeFont);
UIUtils.drawMessageOverControl(placeholder, e, "No Data", -10);
e.gc.setFont(normalFont);
if (controller.getDataContainer() instanceof SQLEditor.QueryResultsContainer) {
String execQuery = ActionUtils.findCommandDescription(CoreCommands.CMD_EXECUTE_STATEMENT, controller.getSite(), true);
String execScript = ActionUtils.findCommandDescription(CoreCommands.CMD_EXECUTE_SCRIPT, controller.getSite(), true);
UIUtils.drawMessageOverControl(placeholder, e, "Execute query (" + execQuery + ") or script (" + execScript + ") to see results", 20);
}
}
});
trackPresentationControl();
}
use of org.eclipse.swt.graphics.Font in project dbeaver by serge-rider.
the class AttributePart method createFigure.
/**
* @return the ColumnLabel representing the Column
*/
@Override
protected AttributeItemFigure createFigure() {
ERDEntityAttribute column = (ERDEntityAttribute) getModel();
AttributeItemFigure attributeFigure = new AttributeItemFigure(column);
DiagramPart diagramPart = (DiagramPart) getParent().getParent();
boolean showNullability = diagramPart.getDiagram().hasAttributeStyle(ERDAttributeStyle.NULLABILITY);
Font columnFont = diagramPart.getNormalFont();
Color columnColor = diagramPart.getContentPane().getForegroundColor();
if (column.isInPrimaryKey()) {
columnFont = diagramPart.getBoldFont();
if (showNullability && !column.getObject().isRequired()) {
columnFont = diagramPart.getBoldItalicFont();
}
/*
if (!column.isInForeignKey()) {
columnFont = diagramPart.getBoldFont();
} else {
columnFont = diagramPart.getBoldItalicFont();
}
*/
} else {
if (showNullability && !column.getObject().isRequired()) {
columnFont = diagramPart.getItalicFont();
}
}
if (column.isInForeignKey()) {
//columnColor = Display.getDefault().getSystemColor(SWT.COLOR_DARK_BLUE);
}
attributeFigure.setFont(columnFont);
attributeFigure.setForegroundColor(columnColor);
return attributeFigure;
}
use of org.eclipse.swt.graphics.Font in project sling by apache.
the class JcrPropertiesView method createPartControl.
/**
* This is a callback that will allow us
* to create the viewer and initialize it.
*/
public void createPartControl(Composite parent) {
SyncDirManager.registerUpdateListener(new UpdateHandler() {
@Override
public void syncDirUpdated(SyncDir syncDir) {
refreshContent();
}
});
mainControl = new Composite(parent, SWT.NONE);
final GridLayout gridLayout = new GridLayout(1, true);
mainControl.setLayout(gridLayout);
if (getViewSite() != null) {
titleLabel = new Label(mainControl, SWT.WRAP);
titleLabel.setText("");
GridData data = new GridData(GridData.FILL_HORIZONTAL);
titleLabel.setLayoutData(data);
Label horizontalLine = new Label(mainControl, SWT.SEPARATOR | SWT.HORIZONTAL);
data = new GridData(GridData.FILL_HORIZONTAL);
horizontalLine.setLayoutData(data);
}
Font font;
if (!JFaceResources.getFontRegistry().hasValueFor(TITLE_FONT)) {
FontData[] fontData = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT).getFontData();
/* title font is 2pt larger than that used in the tabs. */
fontData[0].setHeight(fontData[0].getHeight() + 2);
JFaceResources.getFontRegistry().put(TITLE_FONT, fontData);
}
font = JFaceResources.getFont(TITLE_FONT);
if (titleLabel != null) {
titleLabel.setFont(font);
}
Composite tableParent = new Composite(mainControl, SWT.NONE);
// tableParent.setBackground(new Color(Display.getDefault(), 100,20,180));
GridData tableLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
// shrink to min - table settings will resize to correct ratios
tableLayoutData.widthHint = 1;
tableLayoutData.heightHint = SWT.DEFAULT;
tableParent.setLayoutData(tableLayoutData);
TableColumnLayout tableLayout = new TableColumnLayout() {
@Override
protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
Point p = super.computeSize(composite, wHint, hHint, flushCache);
return new Point(p.x, p.y);
}
};
tableParent.setLayout(tableLayout);
viewer = new TableViewer(tableParent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.HIDE_SELECTION | SWT.FULL_SELECTION);
TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewer, new FocusCellOwnerDrawHighlighter(viewer), new CellNavigationStrategy());
ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(viewer) {
@Override
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
resetLastValueEdited();
return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR) || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
};
int features = ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION | ColumnViewerEditor.KEEP_EDITOR_ON_DOUBLE_CLICK;
TableViewerEditor.create(viewer, focusCellManager, actSupport, features);
viewer.getTable().setLinesVisible(true);
viewer.getTable().setHeaderVisible(true);
viewer.setContentProvider(new ViewContentProvider());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
final ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection iss = (IStructuredSelection) selection;
if (iss.isEmpty()) {
deleteAction.setEnabled(false);
} else {
deleteAction.setEnabled(true);
}
} else {
deleteAction.setEnabled(false);
}
}
});
CellLabelProvider clp = new JcrCellLabelProvider(viewer);
TableViewerColumn column0 = new TableViewerColumn(viewer, SWT.NONE);
column0.getColumn().setText("Name");
column0.getColumn().setResizable(true);
column0.getColumn().setWidth(200);
tableLayout.setColumnData(column0.getColumn(), new ColumnWeightData(30, 140));
final TableViewerColumn column1 = new TableViewerColumn(viewer, SWT.NONE);
column1.getColumn().setText("Type");
column1.getColumn().setResizable(true);
column1.getColumn().setWidth(300);
column1.setLabelProvider(clp);
tableLayout.setColumnData(column1.getColumn(), new ColumnWeightData(10, 80));
final TableViewerColumn column2 = new TableViewerColumn(viewer, SWT.NONE);
column2.getColumn().setText("Value");
column2.getColumn().setResizable(true);
column2.getColumn().setWidth(300);
tableLayout.setColumnData(column2.getColumn(), new ColumnWeightData(70, 220));
final TableViewerColumn column3 = new TableViewerColumn(viewer, SWT.NONE);
column3.getColumn().setText("Protected");
column3.getColumn().setResizable(true);
column3.getColumn().setWidth(300);
column3.setLabelProvider(clp);
tableLayout.setColumnData(column3.getColumn(), new ColumnWeightData(5, 57));
final TableViewerColumn column4 = new TableViewerColumn(viewer, SWT.NONE);
column4.getColumn().setText("Mandatory");
column4.getColumn().setResizable(true);
column4.getColumn().setWidth(300);
column4.setLabelProvider(clp);
tableLayout.setColumnData(column4.getColumn(), new ColumnWeightData(5, 62));
final TableViewerColumn column5 = new TableViewerColumn(viewer, SWT.NONE);
column5.getColumn().setText("Multiple");
column5.getColumn().setResizable(true);
column5.getColumn().setWidth(300);
column5.setLabelProvider(clp);
tableLayout.setColumnData(column5.getColumn(), new ColumnWeightData(5, 82));
final TableViewerColumn column6 = new TableViewerColumn(viewer, SWT.NONE);
column6.getColumn().setText("Auto Created");
column6.getColumn().setResizable(true);
column6.getColumn().setWidth(300);
column6.setLabelProvider(clp);
tableLayout.setColumnData(column6.getColumn(), new ColumnWeightData(5, 77));
column0.setLabelProvider(clp);
column0.setEditingSupport(new JcrEditingSupport(this, viewer, ColumnId.NAME));
column1.setLabelProvider(clp);
column1.setEditingSupport(new JcrEditingSupport(this, viewer, ColumnId.TYPE));
column2.setLabelProvider(clp);
column2.setEditingSupport(new JcrEditingSupport(this, viewer, ColumnId.VALUE));
column5.setEditingSupport(new JcrEditingSupport(this, viewer, ColumnId.MULTIPLE));
// Create the help context id for the viewer's control
PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "org.apache.sling.ide.eclipse-ui.viewer");
makeActions();
hookContextMenu();
hookDoubleClickAction();
contributeToActionBars();
listener = new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (selection instanceof IStructuredSelection) {
IStructuredSelection iss = (IStructuredSelection) selection;
Object firstElem = iss.getFirstElement();
if (firstElem instanceof JcrNode) {
JcrNode jcrNode = (JcrNode) firstElem;
setInput(jcrNode);
return;
}
}
}
};
if (getViewSite() != null) {
getViewSite().getPage().addSelectionListener(listener);
final ISelection selection = getViewSite().getPage().getSelection();
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
listener.selectionChanged(null, selection);
}
});
}
}
Aggregations