Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2016-10-04 15:05:54 +0000
committerGerrit Code Review @ Eclipse.org2016-11-09 08:21:00 +0000
commit22d6cd8dcddee32ab067c07b742fadccd0847f41 (patch)
tree131fde39c2b31392f8da2e90a4e7ec1a6e8cda59 /plugins/infra/properties
parent567776b61bd3f399951d7ad182389e0ca9ecc487 (diff)
downloadorg.eclipse.papyrus-22d6cd8dcddee32ab067c07b742fadccd0847f41.tar.gz
org.eclipse.papyrus-22d6cd8dcddee32ab067c07b742fadccd0847f41.tar.xz
org.eclipse.papyrus-22d6cd8dcddee32ab067c07b742fadccd0847f41.zip
Bug 501511 - [Documentation] A new documentation View for UML Element
shall be available. https://bugs.eclipse.org/bugs/show_bug.cgi?id=501511 - Add new Documentation View. Change-Id: Iac879a5eb1e188dd59cd9bcd38d90bf0e756b83f Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
Diffstat (limited to 'plugins/infra/properties')
-rw-r--r--plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/widgets/TabbedPropertyTitle.java163
1 files changed, 163 insertions, 0 deletions
diff --git a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/widgets/TabbedPropertyTitle.java b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/widgets/TabbedPropertyTitle.java
new file mode 100644
index 00000000000..2dc6888d377
--- /dev/null
+++ b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/widgets/TabbedPropertyTitle.java
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2015 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - copy it in Papyrus from org.eclipse.ui because is not API.
+ *******************************************************************************/
+package org.eclipse.papyrus.infra.properties.ui.widgets;
+
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.IFormColors;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+
+/**
+ * The title in the tabbed property sheet page.
+ *
+ * @author Anthony Hunter
+ */
+public class TabbedPropertyTitle
+ extends Composite {
+
+ private CLabel label;
+
+ private Image image = null;
+
+ private String text = null;
+
+ private static final String BLANK = ""; //$NON-NLS-1$
+
+ private static final String TITLE_FONT = "org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyTitle"; //$NON-NLS-1$
+
+ private TabbedPropertySheetWidgetFactory factory;
+
+ /**
+ * Constructor for TabbedPropertyTitle.
+ *
+ * @param parent
+ * the parent composite.
+ * @param factory
+ * the widget factory for the tabbed property sheet
+ */
+ public TabbedPropertyTitle(Composite parent,
+ TabbedPropertySheetWidgetFactory factory) {
+ super(parent, SWT.NO_FOCUS);
+ this.factory = factory;
+
+ this.addPaintListener(new PaintListener() {
+
+ public void paintControl(PaintEvent e) {
+ if (image == null && (text == null || text.equals(BLANK))) {
+ label.setVisible(false);
+ } else {
+ label.setVisible(true);
+ drawTitleBackground(e);
+ }
+ }
+ });
+
+ factory.getColors().initializeSectionToolBarColors();
+ setBackground(factory.getColors().getBackground());
+ setForeground(factory.getColors().getForeground());
+
+ FormLayout layout = new FormLayout();
+ layout.marginWidth = 1;
+ layout.marginHeight = 2;
+ setLayout(layout);
+
+ Font font;
+ if (!JFaceResources.getFontRegistry().hasValueFor(TITLE_FONT)) {
+ FontData[] fontData = JFaceResources.getFontRegistry().getBold(
+ JFaceResources.DEFAULT_FONT).getFontData();
+ /* title font is 2pt larger than that used in the tabs. */
+ fontData[0].setHeight(fontData[0].getHeight() + 2);
+ JFaceResources.getFontRegistry().put(TITLE_FONT, fontData);
+ }
+ font = JFaceResources.getFont(TITLE_FONT);
+
+ label = factory.createCLabel(this, BLANK);
+ label.setBackground(new Color[] {
+ factory.getColors().getColor(IFormColors.H_GRADIENT_END),
+ factory.getColors().getColor(IFormColors.H_GRADIENT_START) },
+ new int[] { 100 }, true);
+ label.setFont(font);
+ label.setForeground(factory.getColors().getColor(IFormColors.TITLE));
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.bottom = new FormAttachment(100, 0);
+ label.setLayoutData(data);
+
+ /*
+ * setImage(PlatformUI.getWorkbench().getSharedImages().getImage(
+ * ISharedImages.IMG_OBJ_ELEMENT));
+ */
+ }
+
+ /**
+ * @param e
+ */
+ protected void drawTitleBackground(PaintEvent e) {
+ Rectangle bounds = getClientArea();
+ label.setBackground(new Color[] {
+ factory.getColors().getColor(IFormColors.H_GRADIENT_END),
+ factory.getColors().getColor(IFormColors.H_GRADIENT_START) },
+ new int[] { 100 }, true);
+ Color bg = factory.getColors().getColor(IFormColors.H_GRADIENT_END);
+ Color gbg = factory.getColors().getColor(IFormColors.H_GRADIENT_START);
+ GC gc = e.gc;
+ gc.setForeground(bg);
+ gc.setBackground(gbg);
+ gc.fillGradientRectangle(bounds.x, bounds.y, bounds.width,
+ bounds.height, true);
+ // background bottom separator
+ gc.setForeground(factory.getColors().getColor(
+ IFormColors.H_BOTTOM_KEYLINE1));
+ gc.drawLine(bounds.x, bounds.height - 2, bounds.x + bounds.width - 1,
+ bounds.height - 2);
+ gc.setForeground(factory.getColors().getColor(
+ IFormColors.H_BOTTOM_KEYLINE2));
+ gc.drawLine(bounds.x, bounds.height - 1, bounds.x + bounds.width - 1,
+ bounds.height - 1);
+ }
+
+ /**
+ * Set the text label.
+ *
+ * @param text
+ * the text label.
+ * @param image
+ * the image for the label.
+ */
+ public void setTitle(String text, Image image) {
+ this.text = text;
+ this.image = image;
+ if (text != null) {
+ label.setText(text);
+ } else {
+ label.setText(BLANK);
+ }
+ label.setImage(image);
+ redraw();
+ }
+}

Back to the top