Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial commit of a bubbles ui

  • Loading branch information...
commit c10cf08348f6d596d9b000d15fcaf67f95f5b12d 1 parent 469aee9
@JPMoresmau authored
View
7 net.sf.eclipsefp.haskell.visual/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
View
28 net.sf.eclipsefp.haskell.visual/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>net.sf.eclipsefp.haskell.visual</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
12 net.sf.eclipsefp.haskell.visual/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %bundleName
+Bundle-SymbolicName: net.sf.eclipsefp.haskell.visual
+Bundle-Version: 2.4.2
+Bundle-Activator: net.sf.eclipsefp.haskell.visual.Activator
+Bundle-Vendor: %bundleVendor
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
View
4 net.sf.eclipsefp.haskell.visual/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
View
3  net.sf.eclipsefp.haskell.visual/plugin.properties
@@ -0,0 +1,3 @@
+# bundle manifest
+bundleVendor = The EclipseFP Project
+bundleName = Haskell Visual Environment
View
50 net.sf.eclipsefp.haskell.visual/src/net/sf/eclipsefp/haskell/visual/Activator.java
@@ -0,0 +1,50 @@
+package net.sf.eclipsefp.haskell.visual;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "net.sf.eclipsefp.haskell.visual"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
View
140 net.sf.eclipsefp.haskell.visual/src/net/sf/eclipsefp/haskell/visual/ui/Bubble.java
@@ -0,0 +1,140 @@
+/**
+ * Copyright (c) 2012 by JP Moresmau
+ * This code is made available under the terms of the Eclipse Public License,
+ * version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
+ */
+package net.sf.eclipsefp.haskell.visual.ui;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.graphics.Resource;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author JP Moresmau
+ *
+ */
+public class Bubble extends Composite {
+ private static final int SIZE_PIXELS=15;
+ private static final int MIN_WIDTH=30;
+ private static final int MIN_HEIGHT=30;
+
+ private StyledText st;
+
+ private List<Resource> resources=new ArrayList<Resource>();
+
+ private boolean isSizing=false;
+ private boolean isMoving=false;
+ private int diffMoveX=0;
+ private int diffMoveY=0;
+
+ /**
+ * @param parent
+ * @param style
+ */
+ public Bubble(final Desktop parent, int style) {
+ super(parent, style);
+
+ this.setLayout(new GridLayout(1, false));
+ st=new StyledText(this, SWT.NONE);
+ st.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
+ st.setText("first line\n\tsecond line\n\tthird line\n\nfourth line\n");
+
+ final Cursor moveCursor=new Cursor(getDisplay(), SWT.CURSOR_SIZEALL);
+ resources.add(moveCursor);
+ final Cursor sizeCursor=new Cursor(getDisplay(), SWT.CURSOR_SIZESE);
+ resources.add(sizeCursor);
+
+
+ this.addMouseMoveListener(new MouseMoveListener() {
+
+ @Override
+ public void mouseMove(MouseEvent paramMouseEvent) {
+ Rectangle r=getBounds();
+ int x=paramMouseEvent.x;
+ int y=paramMouseEvent.y;
+ System.out.println(r.x+"->"+x);
+ System.out.println(r.y+"->"+y);
+ if (isSizing){
+ if (x>MIN_WIDTH && y>MIN_HEIGHT){
+ setSize(x, y);
+ }
+ } else if (isMoving){
+ int newx=x-diffMoveX;
+ int newy=y-diffMoveY;
+ parent.setBounds(r.x+newx, r.y+newy, Bubble.this);
+ } else {
+ //if (getBounds().contains(x, y)){
+ if (x>(r.width)-SIZE_PIXELS && y>(+r.height)-SIZE_PIXELS){
+ setCursor(sizeCursor);
+ } else {
+ setCursor(moveCursor);
+ }
+ /*} else {
+ setCursor(null);
+ }*/
+ }
+ }
+ });
+ this.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseUp(MouseEvent paramMouseEvent) {
+ isSizing=false;
+ isMoving=false;
+ }
+
+ @Override
+ public void mouseDown(MouseEvent paramMouseEvent) {
+ Rectangle r=getBounds();
+ int x=paramMouseEvent.x;
+ int y=paramMouseEvent.y;
+ //if (getBounds().contains(x, y)){
+ if (x>(r.width)-SIZE_PIXELS && y>(r.height)-SIZE_PIXELS){
+ isSizing=true;
+ isMoving=false;
+ return;
+ } else {
+ isSizing=false;
+ isMoving=true;
+ diffMoveX=x;
+ diffMoveY=y;
+ return;
+ }
+ //}
+ //isSizing=false;
+ //isMoving=false;
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent paramMouseEvent) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Widget#dispose()
+ */
+ @Override
+ public void dispose() {
+ for (Resource r:resources){
+ r.dispose();
+ }
+ super.dispose();
+ }
+
+
+}
View
61 net.sf.eclipsefp.haskell.visual/src/net/sf/eclipsefp/haskell/visual/ui/Desktop.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2012 by JP Moresmau
+ * This code is made available under the terms of the Eclipse Public License,
+ * version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
+ */
+package net.sf.eclipsefp.haskell.visual.ui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @author JP Moresmau
+ *
+ */
+public class Desktop extends Composite {
+
+ /**
+ * @param parent
+ * @param style
+ */
+ public Desktop(Composite parent, int style) {
+ super(parent, style);
+ setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ setLayout(null);
+ Bubble b=new Bubble(this,SWT.NONE);
+
+ setBounds(0, 0, b);
+ }
+
+ public void setBounds(int x,int y,Control c){
+ Point p=c.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ c.setBounds(x, y, p.x, p.y);
+ }
+
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setText ("Shell");
+ shell.setSize (200, 200);
+ shell.setLayout(new GridLayout(1,false));
+
+ Desktop d=new Desktop(shell,SWT.NONE);
+ d.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
+
+ shell.open ();
+
+
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.