-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eclipse): add right click menu actions to send message to chat p…
…anel (#3266) * feat(eclipse): update chat panel to compatible with server 0.18.0. * feat(eclipse): add right click menu actions to send message to chat panel. * chore(eclipse): update comments.
- Loading branch information
Showing
20 changed files
with
1,017 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/DebouncedRunnable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.tabbyml.tabby4eclipse; | ||
|
||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.ScheduledExecutorService; | ||
import java.util.concurrent.ScheduledFuture; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class DebouncedRunnable { | ||
private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); | ||
private ScheduledFuture<?> future; | ||
private final long delay; | ||
private final Runnable task; | ||
|
||
public DebouncedRunnable(Runnable task, long delay) { | ||
this.task = task; | ||
this.delay = delay; | ||
} | ||
|
||
public synchronized void call() { | ||
if (future != null && !future.isDone()) { | ||
future.cancel(true); | ||
} | ||
future = scheduler.schedule(task, delay, TimeUnit.MILLISECONDS); | ||
} | ||
|
||
// FIXME: scheduler shutdown not called | ||
public void shutdown() { | ||
scheduler.shutdown(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/StringUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.tabbyml.tabby4eclipse; | ||
|
||
import org.eclipse.swt.graphics.RGB; | ||
|
||
public class StringUtils { | ||
|
||
public static String escapeCharacters(String jsonString) { | ||
return jsonString.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n").replace("\r", "\\r") | ||
.replace("\t", "\\t"); | ||
} | ||
|
||
public static String toHsl(RGB rgb) { | ||
double r = rgb.red / 255.0; | ||
double g = rgb.green / 255.0; | ||
double b = rgb.blue / 255.0; | ||
double max = Math.max(r, Math.max(g, b)); | ||
double min = Math.min(r, Math.min(g, b)); | ||
double l = (max + min) / 2.0; | ||
double h, s; | ||
if (max == min) { | ||
h = 0; | ||
s = 0; | ||
} else { | ||
double delta = max - min; | ||
s = l > 0.5 ? delta / (2.0 - max - min) : delta / (max + min); | ||
if (max == r) { | ||
h = (g - b) / delta + (g < b ? 6 : 0); | ||
} else if (max == g) { | ||
h = (b - r) / delta + 2; | ||
} else { | ||
h = (r - g) / delta + 4; | ||
} | ||
h /= 6; | ||
} | ||
h *= 360; | ||
s *= 100; | ||
l *= 100; | ||
return String.format("%.0f, %.0f%%, %.0f%%", h, s, l); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/Version.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.tabbyml.tabby4eclipse; | ||
|
||
public class Version { | ||
private int major; | ||
private int minor; | ||
private int patch; | ||
|
||
public Version(String versionStr) { | ||
int startIndex = 0; | ||
while (startIndex < versionStr.length() && !Character.isDigit(versionStr.charAt(startIndex))) { | ||
startIndex++; | ||
} | ||
if (startIndex >= versionStr.length()) { | ||
return; | ||
} | ||
int endIndex = versionStr.indexOf("-"); | ||
String numPart = (endIndex != -1) ? versionStr.substring(startIndex, endIndex) | ||
: versionStr.substring(startIndex); | ||
|
||
String[] parts = numPart.split("\\."); | ||
if (parts.length > 0) { | ||
this.major = parseInt(parts[0]); | ||
} | ||
if (parts.length > 1) { | ||
this.minor = parseInt(parts[1]); | ||
} | ||
if (parts.length > 2) { | ||
this.patch = parseInt(parts[2]); | ||
} | ||
} | ||
|
||
public int getMajor() { | ||
return major; | ||
} | ||
|
||
public int getMinor() { | ||
return minor; | ||
} | ||
|
||
public int getPatch() { | ||
return patch; | ||
} | ||
|
||
public boolean isGreaterOrEqualThan(Version other) { | ||
if (this.major > other.major) { | ||
return true; | ||
} else if (this.major < other.major) { | ||
return false; | ||
} else { | ||
if (this.minor > other.minor) { | ||
return true; | ||
} else if (this.minor < other.minor) { | ||
return false; | ||
} else { | ||
return this.patch >= other.patch; | ||
} | ||
} | ||
} | ||
|
||
public boolean isEqual(Version other, boolean ignorePatch) { | ||
if (this.major != other.major || this.minor != other.minor) { | ||
return false; | ||
} | ||
if (ignorePatch) { | ||
return true; | ||
} | ||
return this.patch == other.patch; | ||
} | ||
|
||
private int parseInt(String str) { | ||
try { | ||
return Integer.parseInt(str); | ||
} catch (NumberFormatException e) { | ||
return 0; | ||
} | ||
} | ||
} |
Oops, something went wrong.