Skip to content

Commit

Permalink
Fixes #210 and #209. Also placed some printlns for a while for easing…
Browse files Browse the repository at this point in the history
… reporting if the fix is not complete.
  • Loading branch information
laurentpetit committed Feb 17, 2011
1 parent 9b5e730 commit 5bf1b21
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
1 change: 1 addition & 0 deletions ccw.core/META-INF/MANIFEST.MF
Expand Up @@ -48,3 +48,4 @@ Export-Package: ccw,
ccw.utils.editors.antlrbased,
ccw.wizards
Bundle-ActivationPolicy: lazy

51 changes: 32 additions & 19 deletions ccw.core/src/ccw/CCWPlugin.java
Expand Up @@ -77,7 +77,8 @@ public static Color getSystemColor(int swtKey) {
* dispose the color themselves)
*/
public static Color getCCWColor(int index) {
return CCWPlugin.getDefault().allColors[index];
CCWPlugin defaultPlugin = getDefault();
return defaultPlugin.getAllColors()[index];
}

/** The shared instance */
Expand All @@ -88,13 +89,23 @@ public static Color getCCWColor(int index) {
// clear as mud to me at the moment
public Color[] allColors;

/**
* Must be called from the UI thread
*/
public Color[] getAllColors() {
if (allColors == null) {
initializeParenRainbowColors();
}
return allColors;
}

private ColorRegistry colorRegistry;

private FontRegistry fontRegistry;

private ServerSocket ackREPLServer;

private synchronized void startREPLServer() throws CoreException {
public synchronized void startREPLServer() throws CoreException {
if (ackREPLServer == null) {
try {
ackREPLServer = (ServerSocket)((List)Var.find(Symbol.intern("clojure.tools.nrepl/start-server")).invoke()).get(0);
Expand All @@ -114,27 +125,27 @@ public int getREPLServerPort() throws CoreException {
}

public CCWPlugin() {
System.out.println("CCWPlugin instanciated");
}

public void start(BundleContext context) throws Exception {
System.out.println("CCWPlugin start() starts");
super.start(context);

plugin = this;
startClojureCode(context);
startREPLServer();
initializeParenRainbowColors();
System.out.println("CCWPlugin start() ends");
}

private synchronized void createColorRegistry() {
if (colorRegistry == null) {
DisplayUtil.syncExec(new Runnable() {
public void run() {
colorRegistry = new ColorRegistry(getWorkbench().getDisplay());
colorRegistry.put("ccw.repl.expressionBackground", new RGB(0xf0, 0xf0, 0xf0));
}});
colorRegistry = new ColorRegistry(getWorkbench().getDisplay());
colorRegistry.put("ccw.repl.expressionBackground", new RGB(0xf0, 0xf0, 0xf0));
}
}

/**
* Must be called from the UI thread only
*/
public ColorRegistry getColorRegistry() {
if (colorRegistry == null) {
createColorRegistry();
Expand Down Expand Up @@ -221,15 +232,17 @@ private void stopREPLServer() {
}
}

private void initializeParenRainbowColors() {
allColors = new Color[] {
new Color(Display.getDefault(), 0x00, 0xCC, 0x00),
new Color(Display.getDefault(), 0x00, 0x88, 0xAA),
new Color(Display.getDefault(), 0x66, 0x00, 0xAA),
new Color(Display.getDefault(), 0x00, 0x77, 0x00),
new Color(Display.getDefault(), 0x77, 0xEE, 0x00),
new Color(Display.getDefault(), 0xFF, 0x88, 0x00)
};
private synchronized void initializeParenRainbowColors() {
if (allColors == null) {
allColors = new Color[] {
new Color(Display.getDefault(), 0x00, 0xCC, 0x00),
new Color(Display.getDefault(), 0x00, 0x88, 0xAA),
new Color(Display.getDefault(), 0x66, 0x00, 0xAA),
new Color(Display.getDefault(), 0x00, 0x77, 0x00),
new Color(Display.getDefault(), 0x77, 0xEE, 0x00),
new Color(Display.getDefault(), 0xFF, 0x88, 0x00)
};
}
}

private void disposeParenRainbowColors() {
Expand Down

0 comments on commit 5bf1b21

Please sign in to comment.