| /******************************************************************************* |
| * Copyright (c) 2020 Christian Pontesegger and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Christian Pontesegger - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.skills.ui.views; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.skills.model.ISkill; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.layout.GridData; |
| import org.eclipse.swt.layout.GridLayout; |
| import org.eclipse.swt.widgets.Composite; |
| import org.eclipse.swt.widgets.Control; |
| import org.eclipse.swt.widgets.Label; |
| import org.eclipse.swt.widgets.ProgressBar; |
| |
| public class SkillsComposite extends Composite { |
| |
| public SkillsComposite(Composite parent, int style) { |
| super(parent, style); |
| |
| setLayout(new GridLayout(3, false)); |
| } |
| |
| public void setSkills(Collection<ISkill> skills) { |
| // discard old content |
| for (final Control child : getChildren()) |
| child.dispose(); |
| |
| // populate new content |
| for (final ISkill skill : skills) { |
| final Label lblTitle = new Label(this, SWT.NONE); |
| lblTitle.setText(skill.getName()); |
| // FIXME needs better getter for plain text/ abstract |
| lblTitle.setToolTipText(skill.getDescription().toString()); |
| |
| final ProgressBar progressBar = new ProgressBar(this, SWT.NONE); |
| progressBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); |
| progressBar.setMinimum(0); |
| progressBar.setMaximum(100); |
| progressBar.setSelection(skill.getExperience()); |
| |
| final Label lblLevel = new Label(this, SWT.NONE); |
| // FIXME get correct level |
| lblLevel.setText("Lvl 7"); |
| } |
| |
| // trigger fresh layout |
| getParent().layout(); |
| } |
| } |