Skip to content

Commit

Permalink
[#1370] Operator fails on startup
Browse files Browse the repository at this point in the history
Rework LicensingColorRegistry
  • Loading branch information
ruspl-afed committed May 23, 2024
1 parent e7a6347 commit 411aa81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" name="org.eclipse.passage.lic.internal.inspector.ui.LicensingColorRegistry">
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.passage.lic.internal.inspector.ui.LicensingColorRegistry">
<service>
<provide interface="org.eclipse.passage.lic.jface.resource.LicensingColorResolver"/>
</service>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2020 ArSysOp
* Copyright (c) 2018, 2024 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -16,38 +16,25 @@
import org.eclipse.passage.lic.jface.resource.LicensingColorResolver;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;

@Component
public class LicensingColorRegistry implements LicensingColorResolver {
public final class LicensingColorRegistry implements LicensingColorResolver {

private ColorRegistry colorRegistry;
private final ColorRegistry colors = new ColorRegistry();

@Activate
public void activate() {
colorRegistry = new ColorRegistry();
addValidationColors();
}

protected void addValidationColors() {
public LicensingColorRegistry() {
register(COLOR_VALIDATION_OK, new RGB(250, 250, 250));
register(COLOR_VALIDATION_ERROR, new RGB(250, 194, 180));
}

protected void register(String identifier, RGB rgb) {
colorRegistry.put(identifier, rgb);
}

@Deactivate
public void deactivate() {
colorRegistry = null;
private void register(String identifier, RGB rgb) {
colors.put(identifier, rgb);
}

@Override
public Color getColor(String identifier) {
return colorRegistry.get(identifier);
return colors.get(identifier);
}

}

0 comments on commit 411aa81

Please sign in to comment.