Giter VIP home page Giter VIP logo

greip's Introduction

Greip - Additional SWT Widgets

Main repository for the Greip Project. The goal of this project is to propose new widgets for the SWT API. Currently Greip contains a small set of powerful widgets.

Calculator

A simple calculator, displayed as a whole widget or inside a tool window. (read more...)

ColorButton

The ColorButton widget allow the user to select a color. (read more...)

FontButton

The FontButton widget allow the user to select a font from all available fonts in the system. (read more...)

Picture

This widget simply shows a Picture. Supported picture formats: PNG, BMP, JPEG, GIF (including animated GIFs), ICO and TIFF. (read more...)

Separator

The Separator widget represents a separator line with text and image. (read more...)

StyledLabel

The StyledLabel widget represents a label with text formatting. (read more...)

Tile

The Tile widget represents a graphical element (e.g. picture, chart etc.) represented by a decorator and many formatted text sections. (read more...)

Localization

All widgets are fully localized in a separate fragment. You can add more localizations by creating your own localization fragment.

Available translations:

  • English
  • German
  • French
  • Spain
  • Portuguese
  • Italian
  • Arabic

Eclipse update site

To install Greip use this update site: https://github.com/greipadmin/greip/raw/master/updatesite or drag the install button into your running Eclipse workspace.

Drag to your running Eclipse workspace to install More Clipboard

Release notes

  • Stable releases
    • 1.1.0 [12-03-2019]
      • finalize all APIs
      • color and font selection redesigned
      • new color chooser named ColorCircleChooser
      • calculator now supports parenthesis
  • Beta releases
    • 1.0.3 [25-01-2019]
      • finalize API for Tile widget
      • add some features to Tile widget
    • 1.0.2 [05-01-2019] first release available on Eclipse marketplace
      • finalize API's for Calculator, Separator, ColorButton, FontButton, Picture an Styled Label
      • preview Tile widget
  • Alpha releases
    • 1.0.1 [07-02-2017] first release on GitHub
    • 1.0.0 [07-02-2017] first internal release

Origin of the name

Greip is a natural satellite of Saturn. Its discovery was announced on 26 June 2006. Greip is about 6 kilometres in diameter, and orbits Saturn at an average distance of 18,066 Mm in 906.556 days. Read more on Wikipedia...

License

Eclipse Public License, Version 1.0 (EPL-1.0). See https://www.eclipse.org/legal/epl-v10.html.

greip's People

Contributors

greipadmin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

greip's Issues

StyledText: IllegalArgumentException: Index out of bounds

I am trying to use StyledText in my Eclipse e4 RCP application.

Problem: No text is displayed and when I move the mouse over the field, I get an IllegalArgumentException (see strack trace below).

I am essentially replacing Label with StyledLabel trying to print the following text:

20 <style fg="#008000">↑19</style> <style fg="#800000">↓1</style>

I also tried the text from the sample but I also get a rendering issue. As you can see on the screenshot, the second line is not printed correctly. If I remove the line break, nothing is displayed and I get the exception as above.

Bildschirmfoto 2019-05-05 um 20 46 50

I am developing against the 2018-09 Eclipse repository (I am hesitant to update to a later version because Eclipse is remove support for 32bit versions).

Any idea what I am doing wrong?

The stack trace:

java.lang.IllegalArgumentException: Index out of bounds
	at org.eclipse.swt.SWT.error(SWT.java:4576)
	at org.eclipse.swt.SWT.error(SWT.java:4510)
	at org.eclipse.swt.SWT.error(SWT.java:4481)
	at org.eclipse.swt.graphics.TextLayout.getStyle(TextLayout.java:1476)
	at org.greip.markup.MarkupText.getLinkAtLocation(MarkupText.java:169)
	at org.greip.label.StyledLabel.lambda$2(StyledLabel.java:126)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4292)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1512)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1535)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1520)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1324)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4116)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3733)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1173)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1062)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:165)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:199)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:391)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:246)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:595)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1501)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1474)

My changes - see the replacement of Label by StyledText.

diff --git a/name.abuchen.portfolio.ui/META-INF/MANIFEST.MF b/name.abuchen.portfolio.ui/META-INF/MANIFEST.MF
index ad042fbb..56d86ee1 100644
--- a/name.abuchen.portfolio.ui/META-INF/MANIFEST.MF
+++ b/name.abuchen.portfolio.ui/META-INF/MANIFEST.MF
@@ -88,6 +88,7 @@ Import-Package: com.google.common.collect;version="23.5.0",
  org.eclipse.swt.layout,
  org.eclipse.swt.program,
  org.eclipse.swt.widgets,
+ org.greip.label,
  org.json.simple;version="1.1.1",
  org.json.simple.parser;version="1.1.1",
  org.osgi.framework;version="1.7.0",
diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/dashboard/TradesWidget.java b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/dashboard/TradesWidget.java
index 67f63cda..3406e55d 100644
--- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/dashboard/TradesWidget.java
+++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/dashboard/TradesWidget.java
@@ -17,6 +17,7 @@ import org.eclipse.swt.widgets.Label;
 import org.eclipse.ui.forms.events.HyperlinkAdapter;
 import org.eclipse.ui.forms.events.HyperlinkEvent;
 import org.eclipse.ui.forms.widgets.ImageHyperlink;
+import org.greip.label.StyledLabel;
 
 import com.ibm.icu.text.MessageFormat;
 
@@ -25,6 +26,7 @@ import name.abuchen.portfolio.snapshot.trades.Trade;
 import name.abuchen.portfolio.snapshot.trades.TradeCollector;
 import name.abuchen.portfolio.ui.Images;
 import name.abuchen.portfolio.ui.editor.PortfolioPart;
+import name.abuchen.portfolio.ui.util.Colors;
 import name.abuchen.portfolio.ui.views.trades.TradeDetailsView;
 import name.abuchen.portfolio.util.Interval;
 
@@ -34,7 +36,7 @@ public class TradesWidget extends WidgetDelegate<TradeDetailsView.Input>
     private PortfolioPart part;
 
     protected Label title;
-    protected Label indicator;
+    protected StyledLabel indicator;
 
     public TradesWidget(Widget widget, DashboardData dashboardData)
     {
@@ -55,7 +57,7 @@ public class TradesWidget extends WidgetDelegate<TradeDetailsView.Input>
         title.setBackground(container.getBackground());
         GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(title);
 
-        indicator = new Label(container, SWT.NONE);
+        indicator = new StyledLabel(container, SWT.NONE);
         indicator.setFont(resources.getKpiFont());
         indicator.setBackground(container.getBackground());
         indicator.setText(""); //$NON-NLS-1$
@@ -88,8 +90,15 @@ public class TradesWidget extends WidgetDelegate<TradeDetailsView.Input>
 
         List<Trade> trades = input.getTrades();
         long positive = trades.stream().filter(t -> t.getIRR() > 0).count();
-        this.indicator.setText(
-                        MessageFormat.format("{0}   ↑{1} ↓{2}", trades.size(), positive, trades.size() - positive)); //$NON-NLS-1$
+        String text = MessageFormat.format(
+                        "{0} <style fg=\"" + Colors.toHex(Colors.DARK_GREEN) + "\">↑{1}</style> <style fg=\""
+                                        + Colors.toHex(Colors.DARK_RED) + "\">↓{2}</style>\n", //$NON-NLS-1$
+                        trades.size(), positive, 
+                        trades.size() - positive);
+        
+        System.out.println(text);
+        
+        this.indicator.setText(text);
     }
 
     @Override

BTW, great widgets - Calculator and ColorChooser is also something that I could use. 😄 👍

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.