| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| */ |
| package org.eclipse.osbp.vaaclipse.addons.softwarefactory.welcome; |
| |
| import javax.inject.Inject; |
| |
| import org.eclipse.e4.core.contexts.IEclipseContext; |
| import org.eclipse.e4.ui.model.application.MApplication; |
| import org.eclipse.osbp.preferences.ProductConfiguration; |
| |
| import com.vaadin.event.LayoutEvents.LayoutClickEvent; |
| import com.vaadin.event.LayoutEvents.LayoutClickListener; |
| import com.vaadin.shared.MouseEventDetails.MouseButton; |
| import com.vaadin.shared.ui.label.ContentMode; |
| import com.vaadin.ui.AbstractComponent; |
| import com.vaadin.ui.Label; |
| import com.vaadin.ui.RichTextArea; |
| import com.vaadin.ui.VerticalLayout; |
| |
| public class WelcomeView implements LayoutClickListener { |
| |
| /** |
| * |
| */ |
| private static final long serialVersionUID = 1L; |
| private int clickHit = 0; |
| private boolean editMode = false; |
| private AbstractComponent label = null; |
| private VerticalLayout parent; |
| |
| @Inject |
| public WelcomeView(VerticalLayout parent, IEclipseContext context, MApplication app) { |
| this.parent = parent; |
| parent.addStyleName("os-welcome"); |
| parent.addLayoutClickListener(this); |
| renderView(parent); |
| } |
| |
| private void renderView(VerticalLayout parent) { |
| if (label != null) { |
| parent.removeComponent(label); |
| } |
| if (editMode) { |
| label = new RichTextArea(); |
| } else { |
| label = new Label("", ContentMode.HTML); |
| } |
| label.setSizeFull(); |
| parent.addComponent(label); |
| parent.setMargin(true); |
| if (editMode) { |
| ((RichTextArea) label).setValue(ProductConfiguration.getWelcomeScreen()); |
| } else { |
| ((Label) label).setValue(ProductConfiguration.getWelcomeScreen()); |
| } |
| } |
| |
| @Override |
| public void layoutClick(LayoutClickEvent event) { |
| if (1 < event.getRelativeX() && event.getRelativeX() < 50 && 1 < event.getRelativeY() |
| && event.getRelativeY() < 50 && event.getButton() == MouseButton.RIGHT && event.isAltKey() |
| && event.isCtrlKey()) { |
| clickHit++; |
| } |
| if (clickHit >= 5) { |
| clickHit = 0; |
| if (editMode) { |
| ProductConfiguration.setWelcomeScreen(((RichTextArea) label).getValue()); |
| } |
| editMode ^= true; |
| renderView(parent); |
| } |
| } |
| } |