Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[contribs] Better UI for SEI results.
Signed-off-by: Stéphane Galland <galland@arakhne.org>
- Loading branch information
Showing
8 changed files
with
193 additions
and
17 deletions.
There are no files selected for viewing
Binary file modified
BIN
+215 Bytes
(130%)
contribs/io.sarl.experienceindex/io.sarl.experienceindex.plugin/icons/sei.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.7 KB
...io.sarl.experienceindex/io.sarl.experienceindex.plugin/icons/sei_background.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
145 changes: 145 additions & 0 deletions
145
...enceindex.plugin/src/io/sarl/experienceindex/eclipse/SarlExperienceIndexResultDialog.sarl
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,145 @@ | ||
/* | ||
* $Id$ | ||
* | ||
* SARL is an general-purpose agent programming language. | ||
* More details on http://www.sarl.io | ||
* | ||
* Copyright (C) 2014-2017 the original authors or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sarl.experienceindex.eclipse | ||
|
||
import java.lang.ref.SoftReference | ||
import java.text.MessageFormat | ||
|
||
import org.eclipse.jface.dialogs.Dialog | ||
import org.eclipse.jface.dialogs.IDialogConstants | ||
import org.eclipse.jface.dialogs.IconAndMessageDialog | ||
import org.eclipse.swt.SWT | ||
import org.eclipse.swt.graphics.Color | ||
import org.eclipse.swt.graphics.Font | ||
import org.eclipse.swt.graphics.GC | ||
import org.eclipse.swt.graphics.Image | ||
import org.eclipse.swt.widgets.Composite | ||
import org.eclipse.swt.widgets.Control | ||
import org.eclipse.swt.widgets.Shell | ||
|
||
import io.sarl.experienceindex.SarlExperienceIndex.SEI | ||
|
||
/** | ||
* Dialog that shows the results for the SARL experience index. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
* @since 0.6 | ||
*/ | ||
class SarlExperienceIndexResultDialog extends IconAndMessageDialog { | ||
|
||
static val GLOBAL_ICON_SIZE = 256 | ||
|
||
static val BACKGROUND_IMAGE = "icons/sei_background.png" | ||
|
||
static val ICON = "icons/sei.png" | ||
|
||
static val SEI_FONT = "arial" | ||
|
||
static val SEI_FONT_SIZE = 110 | ||
|
||
static val SEI_FONT_STYLE = SWT::BOLD | ||
|
||
static val SEI_FONT_COLOR_RED = 94 | ||
static val SEI_FONT_COLOR_GREEN = 105 | ||
static val SEI_FONT_COLOR_BLUE = 114 | ||
|
||
val sei : SEI | ||
|
||
var globalImage : SoftReference<Image> | ||
|
||
/** Construct the dialog. | ||
* | ||
* @param parentShell the parent shell. | ||
* @param sei the Sarl experience index. | ||
*/ | ||
new (parentShell : Shell, sei : SEI) { | ||
super(parentShell) | ||
this.sei = sei | ||
this.message = MessageFormat::format( | ||
Messages::SarlExperienceIndexResultDialog_0, | ||
sei.baseScore, | ||
sei.cpuScore, | ||
sei.memoryScore, | ||
sei.diskScore) | ||
} | ||
|
||
/** | ||
* Opens a SEI dialog to display the results of the SEI computation. | ||
* | ||
* @param parent the parent shell of the dialog, or {@code null} if none. | ||
* @param sei the Sarl experience index. | ||
* @return the code of the button that was pressed that resulted in this | ||
* dialog closing. This will be {@link Dialog#OK} if the OK | ||
* button was pressed, or {@link Dialog#CANCEL} if this | ||
* dialog's close window decoration or the ESC key was used. | ||
*/ | ||
static def open(parent : Shell, sei : SEI) : int { | ||
val dialog = new SarlExperienceIndexResultDialog(parent, sei) | ||
dialog.open | ||
} | ||
|
||
protected override createDialogArea(parent : Composite) : Control { | ||
var composite = super.createDialogArea(parent) as Composite | ||
composite.createMessageArea | ||
return composite | ||
} | ||
|
||
protected override getImage : Image { | ||
var img = this.globalImage?.get | ||
if (img === null) { | ||
var display = this.shell.display | ||
img = new Image(display, GLOBAL_ICON_SIZE, GLOBAL_ICON_SIZE) | ||
var gc = new GC(img) | ||
var backimg = SarlExperienceIndexPlugin::^default.getImage(BACKGROUND_IMAGE) | ||
gc.antialias = SWT::ON | ||
gc.drawImage(backimg, 0, 0) | ||
backimg.dispose | ||
gc.foreground = new Color(display, SEI_FONT_COLOR_RED, SEI_FONT_COLOR_GREEN, SEI_FONT_COLOR_BLUE) | ||
var newFont = new Font(display, SEI_FONT, SEI_FONT_SIZE, SEI_FONT_STYLE) | ||
gc.font = newFont | ||
var text = MessageFormat::format(Messages::SarlExperienceIndexResultDialog_1, this.sei.baseScore) | ||
var size = gc.textExtent(text) | ||
gc.drawText(text, | ||
(GLOBAL_ICON_SIZE - size.x) / 2, | ||
(GLOBAL_ICON_SIZE - size.y) / 2, | ||
SWT::DRAW_TRANSPARENT) | ||
newFont.dispose | ||
gc.dispose | ||
this.globalImage = new SoftReference(img) | ||
} | ||
return img | ||
} | ||
|
||
protected override configureShell(shell : Shell) { | ||
super.configureShell(shell) | ||
shell.text = Messages::SarlExperienceIndexResultDialog_2 | ||
shell.setImage(SarlExperienceIndexPlugin.getDefault().getImage(ICON)); | ||
} | ||
|
||
protected override createButtonsForButtonBar(parent : Composite) { | ||
createButton(parent, IDialogConstants::OK_ID, IDialogConstants::OK_LABEL, true) | ||
} | ||
|
||
} |
5 changes: 3 additions & 2 deletions
5
...ex/io.sarl.experienceindex.plugin/src/io/sarl/experienceindex/eclipse/messages.properties
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
SarlExperienceIndexEvaluatorHandler_0 = Computing the SARL experience index... | ||
SarlExperienceIndexEvaluatorHandler_1 = SARL Experience Index | ||
SarlExperienceIndexEvaluatorHandler_2 = The SARL experience index was computed. Results are:\n- Base Score: {0}\n- CPU Score: {1}\n- Memory Score: {2}\n- Disk Score: {3} | ||
SarlExperienceIndexResultDialog_0 = The SARL Experience index for your system is described below.\n- Global Score: {0,number,#0.0}\n- Processor Score: {1,number,#0.0}\n- Memory Score: {2,number,#0.0}\n- Hard-disk Score: {3,number,#0.0} | ||
SarlExperienceIndexResultDialog_1 = {0,number,#0.0} | ||
SarlExperienceIndexResultDialog_2 = SARL Experience Index (SEI) |
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