Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public class CSSSWTColorHelper {

/*--------------- SWT Color Helper -----------------*/

public static Color getSWTColor(RGBColor rgbColor, Display display) {
public static Color getSWTColor(RGBColor rgbColor) {
RGBA rgb = getRGBA(rgbColor);
return new Color(display, rgb);
return new Color(rgb);
Comment thread
akurtakov marked this conversation as resolved.
}

public static Color getSWTColor(CSSValue value, Display display) {
Expand All @@ -64,7 +64,7 @@ public static Color getSWTColor(CSSValue value, Display display) {
Color color = display.getSystemColor(SWT.COLOR_BLACK);
RGBA rgba = getRGBA((CSSPrimitiveValue) value, display);
if (rgba != null) {
color = new Color(display, rgba.rgb.red, rgba.rgb.green, rgba.rgb.blue, rgba.alpha);
color = new Color(rgba.rgb.red, rgba.rgb.green, rgba.rgb.blue, rgba.alpha);
}
return color;
Comment thread
akurtakov marked this conversation as resolved.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ public void handleEvent(Event event) {
List<Color> colors = new ArrayList<>();
for (Object rgbObj : grad.getRGBs()) {
if (rgbObj instanceof RGBA rgba) {
Color color = new Color(control.getDisplay(), rgba);
Color color = new Color(rgba);
colors.add(color);
} else if (rgbObj instanceof RGB rgb) {
Color color = new Color(control.getDisplay(), rgb);
Color color = new Color(rgb);
colors.add(color);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void drawSelectedTab(int itemIndex, GC gc, Rectangle bounds) {
if (!active && !onBottom) {
RGB blendColor = gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW).getRGB();
RGB topGradient = blend(blendColor, tabOutlineColor.getRGB(), 40);
gradientLineTop = new Color(gc.getDevice(), topGradient);
gradientLineTop = new Color(topGradient);
foregroundPattern = new Pattern(gc.getDevice(), 0, 0, 0, bounds.height + 1, gradientLineTop,
gc.getDevice().getSystemColor(SWT.COLOR_WHITE));
gc.setForegroundPattern(foregroundPattern);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private Image rotateImage(Display display, Image image, Integer[] frameInts) {
Image rotatedImage = new Image(display, imageData);
GC gc = new GC(rotatedImage);
RGB rgb = new RGB(0x7d, 0, 0);
Color offRed = new Color(display, rgb);
Color offRed = new Color(rgb);
gc.setBackground(offRed);
gc.fillRectangle(0, 0, bounds.height, bounds.width);
Transform t = new Transform(display);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void keyReleased(KeyEvent e) {}
GridData gd2= new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
fStatusField.setLayoutData(gd2);

Color statusTextForegroundColor= new Color(fStatusField.getDisplay(),
Color statusTextForegroundColor= new Color(
blend(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(), display.getSystemColor(SWT.COLOR_INFO_FOREGROUND).getRGB(), 0.56f));
fStatusField.setForeground(statusTextForegroundColor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ private void setStatusLabelColors(Color foreground, Color background) {
if (foreground == null || background == null) {
return;
}
Color statusLabelForeground= new Color(fStatusLabel.getDisplay(), Colors.blend(background.getRGB(), foreground.getRGB(), 0.56f));
Color statusLabelForeground= new Color(Colors.blend(background.getRGB(), foreground.getRGB(), 0.56f));
fStatusLabel.setForeground(statusLabelForeground);
fStatusLabel.setBackground(background);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void install(ITextViewer textViewer) {
} else if (fRGB != null) {
StyledText text= fTextViewer.getTextWidget();
if (text != null && !text.isDisposed()) {
fColor= new Color(text.getDisplay(), fRGB);
fColor= new Color(fRGB);
}
}
}
Expand Down Expand Up @@ -349,7 +349,7 @@ private Color createColorFromPreferenceStore() {
}

if (rgb != null) {
return new Color(textWidget.getDisplay(), rgb);
return new Color(rgb);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
Expand Down Expand Up @@ -876,7 +875,6 @@ protected Control createInfoTextArea(Composite parent) {

GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL,
SWT.BEGINNING).applyTo(infoLabel);
Display display = parent.getDisplay();

Color backgroundColor = getBackground();
if (backgroundColor == null) {
Expand All @@ -886,7 +884,7 @@ protected Control createInfoTextArea(Composite parent) {
if (foregroundColor == null) {
foregroundColor = getDefaultForeground();
}
Color infoColor = new Color(display, blend(
Color infoColor = new Color(blend(
backgroundColor.getRGB(), foregroundColor.getRGB(),
0.56f));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private Control createTitleArea(Composite parent) {
Color background;
Color foreground;
if (titleAreaRGB != null) {
titleAreaColor = new Color(display, titleAreaRGB);
titleAreaColor = new Color(titleAreaRGB);
background = titleAreaColor;
foreground = null;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public static Color getRequiredFieldBackgroundColor(Control control) {
destBlue += (src.getBlue() - destBlue) * alpha / 0xFF;

// create the color
Color color = new Color(display, destRed, destGreen, destBlue);
Color color = new Color(destRed, destGreen, destBlue);
// record the color in a map using the original color as the key
requiredFieldColorMap.put(dest, color);
// If we have never created a color on this display before, install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private ImageData getImageData(int zoom) {
RGB color = getColorValue();
gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_BORDER));
if (color != null) {
gc.setBackground(new Color(display, color));
gc.setBackground(new Color(color));
gc.fillRectangle(image.getBounds());
}
gc.setLineWidth(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public ColorRegistry(Display display, boolean cleanOnDisplayDisposal) {
}

/**
* Create a new <code>Color</code> on the receivers <code>Display</code>.
* Create a new <code>Color</code> for the given RGB value.
*
* @param rgb the <code>RGB</code> data for the color.
* @return the new <code>Color</code> object.
Expand All @@ -142,7 +142,7 @@ private Color createColor(RGB rgb) {
hookDisplayDispose();
}
}
return new Color(display, rgb);
return new Color(rgb);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,10 @@ public int hashCode() {

@Override
public Color createColor(Device device) {
// If this descriptor is wrapping an existing color, then we can return the original color
// if this is the same device.
if (originalColor != null && originalColor.getDevice() == device) {
// If we're allocating on the same device as the original color, return the original.
// If this descriptor is wrapping an existing color, return the original.
if (originalColor != null) {
return originalColor;
}
return new Color(device, color);
return new Color(color);
Comment thread
akurtakov marked this conversation as resolved.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Color getColor(RGB rgb) {

Color color= colorTable.get(rgb);
if (color == null) {
color= new Color(display, rgb);
color= new Color(rgb);
colorTable.put(rgb, color);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1147,14 +1147,14 @@ public Image getImage(Object element) {
return null;
}
RGB rgb= colorEntry.isSystemDefault() ? colorEntry.systemColorRGB : colorEntry.getRGB();
Color color= new Color(tableComposite.getParent().getDisplay(), rgb.red, rgb.green, rgb.blue);
Color color= new Color(rgb.red, rgb.green, rgb.blue);
int dimensions= 10;
final ImageGcDrawer imageGcDrawer = (gc, width, height) -> {
// Draw color preview
gc.setBackground(color);
gc.fillRectangle(0, 0, width, height);
// Draw outline around color preview
gc.setBackground(new Color(tableComposite.getParent().getDisplay(), 0, 0, 0));
gc.setBackground(new Color(0, 0, 0));
gc.setLineWidth(2);
gc.drawRectangle(0, 0, width, height);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void keyReleased(KeyEvent e) {}
GridData gd2= new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
fStatusField.setLayoutData(gd2);

Color statusTextForegroundColor= new Color(fStatusField.getDisplay(),
Color statusTextForegroundColor= new Color(
blend(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(), display.getSystemColor(SWT.COLOR_INFO_FOREGROUND).getRGB(), 0.56f));
fStatusField.setForeground(statusTextForegroundColor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ protected void paintHyperlink(GC gc) {
*/
protected void paintText(GC gc, Rectangle bounds) {
gc.setFont(getFont());
Color fg = isEnabled() ? getForeground() : new Color(gc.getDevice(),FormColors.blend(getBackground().getRGB(), getForeground().getRGB(), 70));
Color fg = isEnabled() ? getForeground() : new Color(FormColors.blend(getBackground().getRGB(), getForeground().getRGB(), 70));
gc.setForeground(fg);
if ((getStyle() & SWT.WRAP) != 0) {
FormUtil.paintWrapText(gc, text, bounds, underlined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ public ImageData getImageData(int zoom) {
@Override
public Image createImage(boolean returnMissingImageOnError, Device device) {
final ImageGcDrawer imageGcDrawer = (gc, width, height) -> {
Color color1 = new Color(device, fRGBs[0]);
Color color2 = new Color(device, fRGBs[1]);
Color color1 = new Color(fRGBs[0]);
Color color2 = new Color(fRGBs[1]);
try {
gc.setBackground(color1);
gc.fillRectangle(0, 0, width, height);
Expand All @@ -131,7 +131,7 @@ public Image createImage(boolean returnMissingImageOnError, Device device) {
color2.dispose();
}
};
Color background = new Color(device, fRGBs[0]);
Color background = new Color(fRGBs[0]);
Image image = new Image(device, imageGcDrawer, 1, fLength);
image.setBackground(background);
background.dispose();
Expand Down Expand Up @@ -196,9 +196,9 @@ public Image createImage(boolean returnMissingImageOnError, Device device) {
final ImageGcDrawer imageGcDrawer = (gc, iWidth, iHeight) -> {
Color[] colors = new Color[fRGBs.length];
for (int i = 0; i < colors.length; i++) {
colors[i] = fRGBs[i] == null ? null : new Color(device, fRGBs[i]);
colors[i] = fRGBs[i] == null ? null : new Color(fRGBs[i]);
}
Color bg = fBgRGB == null ? null : new Color(device, fBgRGB);
Color bg = fBgRGB == null ? null : new Color(fBgRGB);
try {
drawTextGradient(gc, iWidth, iHeight, colors, fPercents, fVertical, bg);
} finally {
Expand All @@ -212,7 +212,7 @@ public Image createImage(boolean returnMissingImageOnError, Device device) {
}
}
};
Color background = fRGBs[0] == null ? null : new Color(device, fRGBs[0]);
Color background = fRGBs[0] == null ? null : new Color(fRGBs[0]);
Image gradient = new Image(device, imageGcDrawer, Math.max(width, 1), Math
.max(height, 1));
if (background != null) {
Expand Down Expand Up @@ -312,8 +312,8 @@ public ImageData getImageData(int zoom) {

@Override
public Image createImage(boolean returnMissingImageOnError, Device device) {
Color originalBgColor = new Color(device, fRGBs[0]);
Color color1 = new Color(device, fRGBs[1]);
Color originalBgColor = new Color(fRGBs[0]);
Color color1 = new Color(fRGBs[1]);
final ImageGcDrawer imageGcDrawer = (gc, width, height) -> {
gc.setBackground(color1);
gc.fillRectangle(0, fMarginHeight + 2, width, fTheight - fMarginHeight - 3);
Expand All @@ -337,8 +337,8 @@ private class SimpleSectionGradientImageDescriptor extends SimpleSectionImageDes
@Override
public Image createImage(boolean returnMissingImageOnError, Device device) {
final ImageGcDrawer imageGcDrawer = (gc, width, height) -> {
Color color1 = new Color(device, fRGBs[0]);
Color color2 = new Color(device, fRGBs[1]);
Color color1 = new Color(fRGBs[0]);
Color color2 = new Color(fRGBs[1]);
try {
gc.setBackground(color1);
gc.fillRectangle(0, 0, width, height);
Expand All @@ -352,7 +352,7 @@ public Image createImage(boolean returnMissingImageOnError, Device device) {
color2.dispose();
}
};
Color background = new Color(device, fRGBs[0]);
Color background = new Color(fRGBs[0]);
Image image = new Image(device, imageGcDrawer, 1, fLength);
image.setBackground(background);
background.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4147,14 +4147,13 @@ public void gesture(GestureEvent e) {
* Creates a color from the information stored in the given preference store.
* Returns <code>null</code> if there is no such information available.
*
* @param store the store to read from
* @param key the key used for the lookup in the preference store
* @param display the display used create the color
* @param store the store to read from
* @param key the key used for the lookup in the preference store
* @return the created color according to the specification in the preference
* store
* @since 2.0
*/
private Color createColor(IPreferenceStore store, String key, Display display) {
private Color createColor(IPreferenceStore store, String key) {

RGB rgb = null;

Expand All @@ -4167,7 +4166,7 @@ private Color createColor(IPreferenceStore store, String key, Display display) {
}

if (rgb != null) {
return new Color(display, rgb);
return new Color(rgb);
}
}

Expand All @@ -4190,22 +4189,22 @@ protected void initializeViewerColors(ISourceViewer viewer) {

// ----------- foreground color --------------------
Color color = store.getBoolean(PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT) ? null
: createColor(store, PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
: createColor(store, PREFERENCE_COLOR_FOREGROUND);
styledText.setForeground(color);

// ---------- background color ----------------------
color = store.getBoolean(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) ? null
: createColor(store, PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
: createColor(store, PREFERENCE_COLOR_BACKGROUND);
styledText.setBackground(color);

// ----------- selection foreground color --------------------
color = store.getBoolean(PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT) ? null
: createColor(store, PREFERENCE_COLOR_SELECTION_FOREGROUND, styledText.getDisplay());
: createColor(store, PREFERENCE_COLOR_SELECTION_FOREGROUND);
styledText.setSelectionForeground(color);

// ---------- selection background color ----------------------
color = store.getBoolean(PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT) ? null
: createColor(store, PREFERENCE_COLOR_SELECTION_BACKGROUND, styledText.getDisplay());
: createColor(store, PREFERENCE_COLOR_SELECTION_BACKGROUND);
styledText.setSelectionBackground(color);

}
Expand All @@ -4223,9 +4222,7 @@ private void initializeFindScopeColor(ISourceViewer viewer) {
IPreferenceStore store = getPreferenceStore();
if (store != null) {

StyledText styledText = viewer.getTextWidget();

Color color = createColor(store, PREFERENCE_COLOR_FIND_SCOPE, styledText.getDisplay());
Color color = createColor(store, PREFERENCE_COLOR_FIND_SCOPE);

IFindReplaceTarget target = viewer.getFindReplaceTarget();
if (target instanceof IFindReplaceTargetExtension) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public InfoForm(Composite parent) {
Display display= parent.getDisplay();
fBackgroundColor= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
fForegroundColor= display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
fSeparatorColor= new Color(display, 152, 170, 203);
fSeparatorColor= new Color(152, 170, 203);

fPropertyChangeListener = this::handlePropertyChange;
JFaceResources.getFontRegistry().addListener(fPropertyChangeListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ protected void keepOpen(Display display, Shell dialog) {
*/
private Image createSeparatorBgImage() {
final ImageGcDrawer imageGcDrawer = (gc, width, height) -> {
gc.setBackground(new Color(dialog.getDisplay(), 127, 127, 127));
gc.setBackground(new Color(127, 127, 127));
gc.fillRectangle(0, 0, width, height);
};
return new Image(Display.getDefault(), imageGcDrawer, 1, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ public HeapStatus(Composite parent, IPreferenceStore prefStore) {
disabledGcImage = new Image(display, gcImage, SWT.IMAGE_DISABLE);
}

usedMemCol = new Color(display, 160, 160, 160); // gray
lowMemCol = new Color(display, 255, 70, 70); // medium red
freeMemCol = new Color(display, 255, 190, 125); // light orange
usedMemCol = new Color(160, 160, 160); // gray
lowMemCol = new Color(255, 70, 70); // medium red
freeMemCol = new Color(255, 190, 125); // light orange
sepCol = topLeftCol = armCol = usedMemCol;
bgCol = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
bottomRightCol = display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private void createFilteredTreeViewer(Composite parent) {
TreeViewer treeViewer = filteredTree.getViewer();
Control treeControl = treeViewer.getControl();
RGB dimmedRGB = blend(treeControl.getForeground().getRGB(), treeControl.getBackground().getRGB(), 60);
dimmedForeground = new Color(treeControl.getDisplay(), dimmedRGB);
dimmedForeground = new Color(dimmedRGB);

treeViewer
.setLabelProvider(new ViewLabelProvider(context, modelService, partService, window, dimmedForeground));
Expand Down
Loading
Loading