Skip to content

Commit ed5c94c

Browse files
committed
Use SWT constant and make the code more readable.
1 parent 60ef7e9 commit ed5c94c

File tree

19 files changed

+27
-27
lines changed

19 files changed

+27
-27
lines changed

bundles/org.eclipse.swt.tools.spies/src/org/eclipse/swt/tools/views/SpyView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ String getName(Object object) {
139139
if (object == null) return "null";
140140
String name = object.toString ();
141141
if (fullyQualifiedAction.isChecked()) {
142-
int index = name.indexOf(' ');
142+
int index = name.indexOf(SWT.SPACE);
143143
if (index >= 0 && name.length() >= 1) {
144144
name = object.getClass ().getName () + name.substring(index);
145145
}

bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5295,7 +5295,7 @@ int insertBlockSelectionText(String text, boolean fillWithSpaces) {
52955295
int numSpaces = maxLength - length;
52965296
StringBuilder buffer = new StringBuilder(length + numSpaces);
52975297
buffer.append(line);
5298-
for (int j = 0; j < numSpaces; j++) buffer.append(' ');
5298+
for (int j = 0; j < numSpaces; j++) buffer.append(SWT.SPACE);
52995299
lines[i] = buffer.toString();
53005300
}
53015301
}
@@ -8104,7 +8104,7 @@ int sendTextEvent(int left, int right, int lineIndex, String text, boolean fillW
81048104
int spacesWidth = left - lineWidth + horizontalScrollOffset - leftMargin;
81058105
int spacesCount = spacesWidth / renderer.averageCharWidth;
81068106
for (int i = 0; i < spacesCount; i++) {
8107-
buffer.append(' ');
8107+
buffer.append(SWT.SPACE);
81088108
}
81098109
}
81108110
buffer.append(text);

bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ TextLayout getTextLayout(int lineIndex, int orientation, int width, int lineSpac
12561256
if (style.metrics != null && line.substring(start, endIndex).contains("\t")) {
12571257
line =
12581258
line.substring(0, start) +
1259-
line.substring(start, endIndex).replace('\t', ' ') +
1259+
line.substring(start, endIndex).replace('\t', SWT.SPACE) +
12601260
(end < line.length() ? line.substring(end + 1, line.length()) : "");
12611261
}
12621262
styleEntries.add(new StyleEntry(style, start, end));
@@ -1494,7 +1494,7 @@ void setFont(Font font, int tabs) {
14941494
layout.setFont(regularFont);
14951495
StringBuilder tabBuffer = new StringBuilder(tabs);
14961496
for (int i = 0; i < tabs; i++) {
1497-
tabBuffer.append(' ');
1497+
tabBuffer.append(SWT.SPACE);
14981498
}
14991499
layout.setText(tabBuffer.toString());
15001500
tabWidth = layout.getBounds().width;

bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public String toString() {
139139
sb.append(" dataTypes={ ");
140140
if (dataTypes != null) {
141141
for (TransferData dataType : dataTypes) {
142-
sb.append(dataType.type); sb.append(' ');
142+
sb.append(dataType.type); sb.append(SWT.SPACE);
143143
}
144144
}
145145
sb.append('}');

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2438,7 +2438,7 @@ public void setDefaultTabWidth(int tabLength) {
24382438
String oldString = getText();
24392439
StringBuilder tabBuffer = new StringBuilder(tabLength);
24402440
for (int i = 0; i < tabLength; i++) {
2441-
tabBuffer.append(' ');
2441+
tabBuffer.append(SWT.SPACE);
24422442
}
24432443
setText(tabBuffer.toString());
24442444
ignoreSegments = true;

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ void selectField(FieldPosition fieldPosition) {
13531353
display.syncExec(() -> {
13541354
if (textEntryHandle != 0) {
13551355
String value = getText(getText(), start, end - 1);
1356-
int s = value.lastIndexOf(' ');
1356+
int s = value.lastIndexOf(SWT.SPACE);
13571357
s = (s == -1) ? start : start + s + 1;
13581358
setTextSelection(s, end);
13591359
}

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2890,7 +2890,7 @@ public void setText (String string) {
28902890
int length = string.length ();
28912891
char [] chars = new char [Math.max (6, length) + 1];
28922892
string.getChars (0, length , chars, 0);
2893-
for (int i=length; i<chars.length; i++) chars [i] = ' ';
2893+
for (int i=length; i<chars.length; i++) chars [i] = SWT.SPACE;
28942894
byte [] buffer = Converter.wcsToMbcs (chars, true);
28952895
GTK.gtk_window_set_title (shellHandle, buffer);
28962896
}

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ boolean filters (int eventType) {
12261226
*/
12271227
case '(':
12281228
if (removeAppended && i + 4 == string.length () && text [i + 1] == '&' && text [i + 3] == ')') {
1229-
if (replace) result [j++] = ' ';
1229+
if (replace) result [j++] = SWT.SPACE;
12301230
i += 4;
12311231
break; // break switch case only if we are removing the mnemonic
12321232
}

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,7 +2578,7 @@ void drawTextGDIP(long gdipGraphics, String string, int x, int y, int flags, boo
25782578
buffer = string.toCharArray();
25792579
} else {
25802580
if (draw) return;
2581-
buffer = new char[]{' '};
2581+
buffer = new char[]{SWT.SPACE};
25822582
}
25832583
PointF pt = new PointF();
25842584
long format = Gdip.StringFormat_Clone(Gdip.StringFormat_GenericTypographic());
@@ -4026,7 +4026,7 @@ public boolean isDisposed() {
40264026
float measureSpace(long font, long format) {
40274027
PointF pt = new PointF();
40284028
RectF bounds = new RectF();
4029-
Gdip.Graphics_MeasureString(data.gdipGraphics, new char[]{' '}, 1, font, pt, format, bounds);
4029+
Gdip.Graphics_MeasureString(data.gdipGraphics, new char[]{SWT.SPACE}, 1, font, pt, format, bounds);
40304030
return bounds.Width;
40314031
}
40324032

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2896,7 +2896,7 @@ StyleItem[] itemize () {
28962896
for (int i = 0, latestNeutralIndex = -2, latestUnicodeIndex = -2; i < length; i++) {
28972897
char c = chars[i];
28982898

2899-
if (c >= ' ' && c <= '~' && !Character.isAlphabetic(c)) {
2899+
if (c >= SWT.SPACE && c <= '~' && !Character.isAlphabetic(c)) {
29002900
latestNeutralIndex = i;
29012901
} else if (c > 255) {
29022902
latestUnicodeIndex = i;

0 commit comments

Comments
 (0)