blob: 663462753e5261488bb630558e4a01b038893507 [file] [log] [blame]
/*******************************************************************************
* 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.character;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.skills.model.IUser;
import org.eclipse.skills.service.ISkillService;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.wb.swt.SWTResourceManager;
public class CharacterView extends ViewPart {
public static IUser getUser() {
final ISkillService skillService = PlatformUI.getWorkbench().getService(ISkillService.class);
if (skillService != null)
return skillService.getUser();
return null;
}
private StatsComposite fStatsComposite;
private LocalResourceManager fResourceManager;
public CharacterView() {
}
@Override
public void createPartControl(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
fResourceManager = new LocalResourceManager(JFaceResources.getResources(), composite);
final Label lblTitle = addTitle(composite);
final CharacterComposite characterComposite = new CharacterComposite(composite, SWT.NONE, fResourceManager);
characterComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create());
fStatsComposite = new StatsComposite(composite, SWT.NONE, fResourceManager);
fStatsComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
}
private Label addTitle(final Composite parent) {
// FIXME use default font for headers
final Label lblTitle = new Label(parent, SWT.NONE);
lblTitle.setFont(SWTResourceManager.getFont("Cantarell", 24, SWT.BOLD));
lblTitle.setForeground(SWTResourceManager.getColor(SWT.COLOR_TITLE_BACKGROUND));
lblTitle.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).indent(20, 0).create());
lblTitle.setText(getUser().getName() + ", an expert (TODO)");
return lblTitle;
}
@Override
public void setFocus() {
}
}