items) {
61 | this.items = items;
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/itemSelector/SelectionChangeListener.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.itemSelector;
12 |
13 | import org.eclipse.swt.internal.SWTEventListener;
14 |
15 | /**
16 | * Classes which implement this interface provide methods
17 | * that deal with the events that are generated when selection
18 | * occurs in a control.
19 | *
20 | * After creating an instance of a class that implements
21 | * this interface it can be added to a control using the
22 | * addSelectionChangeListener
method and removed using
23 | * the removeSelectionChangeListener
method. When
24 | * selection occurs in a control the appropriate method
25 | * will be invoked.
26 | *
27 | *
28 | * @see SelectionChangeEvent
29 | */
30 | public interface SelectionChangeListener extends SWTEventListener {
31 |
32 | /**
33 | * Sent when selection occurs in the control.
34 | *
35 | * @param e an event containing information about the selection
36 | */
37 | public void widgetSelected(SelectionChangeEvent e);
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/launcher/LauncherItem.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.launcher;
12 |
13 | /**
14 | * Instances of this class are POJO to store information handled by the Launcher
15 | * widget I could have used a inner class but I prefer this solution :)
16 | */
17 | class LauncherItem {
18 | String title;
19 | String image;
20 | LauncherLabel label;
21 |
22 | /**
23 | * Constructor
24 | *
25 | * @param title text associated to the item
26 | * @param image image associated to the item
27 | */
28 | LauncherItem(final String title, final String image) {
29 | this.title = title;
30 | this.image = image;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/login/LoginDialogVerifier.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.login;
12 |
13 | /**
14 | * This interface describes a verifier for the LoginDialogWidget
15 | */
16 | public interface LoginDialogVerifier {
17 | /**
18 | * Check if the couple login/password is correct
19 | *
20 | * @param login login entered by the user
21 | * @param password password entered by the user
22 | * @throws Exception if the couple login/password is wrong. The description
23 | * of the exception contains the error message that is gonna be
24 | * displayed. For instance, an implementation can throw the
25 | * exception *
26 | * new Exception("Unable to connect to the LDAP Server")
27 | */
28 | void authenticate(String login, String password) throws Exception;
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/multiChoice/MultiChoiceDefaultLabelProvider.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2013 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.multiChoice;
12 |
13 | /**
14 | * Default MultiChoiceLabelProvider that uses the toString() method to determine the content of a given element
15 | */
16 | public class MultiChoiceDefaultLabelProvider implements MultiChoiceLabelProvider {
17 |
18 | /**
19 | * @see org.mihalis.opal.multiChoice.MultiChoiceLabelProvider#getText(java.lang.Object)
20 | */
21 | @Override
22 | public String getText(final Object element) {
23 | return element == null ? "" : element.toString();
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/multiChoice/MultiChoiceLabelProvider.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2013 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.multiChoice;
12 |
13 | /**
14 | * Classes which implement this interface provide methods that determine what to show in a MultiChoice control.
15 | */
16 | public interface MultiChoiceLabelProvider {
17 | /**
18 | * @param element the element for which to provide the label text
19 | * @return the text string used to label the element, or "" if there is no text label for the given object
20 | */
21 | String getText(Object element);
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/multiChoice/MultiChoiceSelectionListener.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 |
12 | package org.mihalis.opal.multiChoice;
13 |
14 | import org.eclipse.swt.events.SelectionEvent;
15 | import org.eclipse.swt.events.SelectionListener;
16 | import org.eclipse.swt.widgets.Button;
17 | import org.eclipse.swt.widgets.Shell;
18 |
19 | /**
20 | * Classes which extend this abstract class provide methods that deal with the
21 | * events that are generated when selection occurs in a MultiChoice control.
22 | */
23 | public abstract class MultiChoiceSelectionListener implements SelectionListener {
24 | private final MultiChoice parent;
25 |
26 | public MultiChoiceSelectionListener(final MultiChoice parent) {
27 | this.parent = parent;
28 | }
29 |
30 | /**
31 | * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
32 | */
33 | @Override
34 | public final void widgetSelected(final SelectionEvent e) {
35 | final Button button = (Button) e.widget;
36 | handle(this.parent, this.parent.getLastModified(), button.getSelection(), this.parent.getPopup());
37 | }
38 |
39 | /**
40 | * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
41 | */
42 | @Override
43 | public final void widgetDefaultSelected(final SelectionEvent inutile) {
44 | }
45 |
46 | /**
47 | * This method contains the code that is called when the selection has
48 | * changed
49 | *
50 | * @param parent MultiChoice responsible of the event
51 | * @param receiver Object modified
52 | * @param selected If true
, the check box has been checked
53 | * @param popup the popup window that contains all checkboxes
54 | */
55 | public abstract void handle(MultiChoice parent, T receiver, boolean selected, Shell popup);
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/notify/NotifierColors.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.notify;
12 |
13 | import org.eclipse.swt.graphics.Color;
14 | import org.mihalis.opal.utils.SWTGraphicUtil;
15 |
16 | /**
17 | * This class is a simple POJO that holds colors used by the Notifier widget
18 | *
19 | */
20 | class NotifierColors {
21 | Color titleColor;
22 | Color textColor;
23 | Color borderColor;
24 | Color leftColor;
25 | Color rightColor;
26 |
27 | void dispose() {
28 | SWTGraphicUtil.safeDispose(this.titleColor);
29 | SWTGraphicUtil.safeDispose(this.borderColor);
30 | SWTGraphicUtil.safeDispose(this.leftColor);
31 | SWTGraphicUtil.safeDispose(this.rightColor);
32 | SWTGraphicUtil.safeDispose(this.textColor);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/notify/NotifierColorsFactory.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON All rights reserved. This program and the
3 | * accompanying materials are made available under the terms of the Eclipse
4 | * Public License v1.0 which accompanies this distribution, and is available at
5 | * http://www.eclipse.org/legal/epl-v10.html
6 | *
7 | * Contributors:
8 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
9 | *******************************************************************************/
10 |
11 | package org.mihalis.opal.notify;
12 |
13 | import org.eclipse.swt.graphics.Color;
14 | import org.eclipse.swt.widgets.Display;
15 |
16 | /**
17 | * This class creates the colors associated to a given theme
18 | *
19 | */
20 | public class NotifierColorsFactory {
21 |
22 | public enum NotifierTheme {
23 | YELLOW_THEME, GRAY_THEME, BLUE_THEME
24 | };
25 |
26 | /**
27 | * Constructor
28 | */
29 | private NotifierColorsFactory() {
30 |
31 | }
32 |
33 | /**
34 | * @param theme a theme for the notifier widget
35 | * @return the color set for the given theme
36 | */
37 | static NotifierColors getColorsForTheme(final NotifierTheme theme) {
38 | final NotifierColors colors = new NotifierColors();
39 | Display display = Display.getDefault();
40 | switch (theme) {
41 | case BLUE_THEME:
42 | colors.textColor = new Color(display, 4, 64, 140);
43 | colors.titleColor = new Color(display, 0, 0, 0);
44 | colors.borderColor = new Color(display, 153, 188, 232);
45 | colors.leftColor = new Color(display, 210, 225, 244);
46 | colors.rightColor = new Color(display, 182, 207, 238);
47 | break;
48 | case GRAY_THEME:
49 | colors.textColor = new Color(display, 0, 0, 0);
50 | colors.titleColor = new Color(display, 255, 20, 20);
51 | colors.borderColor = new Color(display, 208, 208, 208);
52 | colors.leftColor = new Color(display, 255, 255, 255);
53 | colors.rightColor = new Color(display, 208, 208, 208);
54 | break;
55 | default:
56 | colors.textColor = new Color(display, 0, 0, 0);
57 | colors.titleColor = new Color(display, 0, 0, 0);
58 | colors.borderColor = new Color(display, 218, 178, 85);
59 | colors.leftColor = new Color(display, 220, 220, 160);
60 | colors.rightColor = new Color(display, 255, 255, 191);
61 | break;
62 | }
63 | return colors;
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/obutton/ButtonRenderer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.obutton;
12 |
13 | import org.eclipse.swt.graphics.GC;
14 | import org.eclipse.swt.graphics.Point;
15 |
16 | /**
17 | * This interface contains methods used to render a button
18 | */
19 | public interface ButtonRenderer {
20 |
21 | /**
22 | * Dispose the elements when the button is disposed
23 | */
24 | void dispose();
25 |
26 | /**
27 | * Draw the button when the mouse is hover
28 | * @param gc Graphical context
29 | * @param button button displayed
30 | */
31 | void drawButtonWhenMouseHover(GC gc, OButton button);
32 |
33 | /**
34 | * Draw the button when the button is disabled
35 | * @param gc Graphical context
36 | * @param button button displayed
37 | */
38 | void drawButtonWhenDisabled(GC gc, OButton button);
39 |
40 | /**
41 | * Draw the button when the button (toggle button) is selected
42 | * @param gc Graphical context
43 | * @param button button displayed
44 | */
45 | void drawButtonWhenSelected(GC gc, OButton button);
46 |
47 | /**
48 | * @param gc
49 | * @param button
50 | */
51 | void drawButton(GC gc, OButton button);
52 |
53 | /**
54 | * Draw the button when the button is clicked
55 | * @param gc Graphical context
56 | * @param button button displayed
57 | */
58 | void drawButtonWhenClicked(GC gc, OButton parent);
59 |
60 | /**
61 | * Compute the size of the button
62 | * @param button button associated to this renderer
63 | * @param wHint the width hint (can be SWT.DEFAULT
)
64 | * @param hHint the height hint (can be SWT.DEFAULT
)
65 | * @param changed true
if the control's contents have changed, and false
otherwise
66 | * @return the size of the button
67 | */
68 | Point computeSize(OButton button, int wHint, int hHint, boolean changed);
69 |
70 | /**
71 | * Create disabled image
72 | */
73 | void createDisabledImage();
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/obutton/DefaultButtonRenderer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.obutton;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.graphics.Color;
15 | import org.eclipse.swt.widgets.Display;
16 | import org.mihalis.opal.utils.SWTGraphicUtil;
17 |
18 | /**
19 | * This is the default button renderer
20 | */
21 | public class DefaultButtonRenderer extends AbstractButtonRenderer {
22 |
23 | private static DefaultButtonRenderer instance;
24 | private static final Color FIRST_BACKGROUND_COLOR = SWTGraphicUtil.getColorSafely(121, 187, 255);
25 | private static final Color SECOND_BACKGROUND_COLOR = SWTGraphicUtil.getColorSafely(56, 142, 229);
26 |
27 | private DefaultButtonRenderer() {
28 | super();
29 | }
30 |
31 | @Override
32 | protected Color getFontColor() {
33 | return Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
34 | }
35 |
36 | @Override
37 | protected Color getFirstBackgroundColor() {
38 | return FIRST_BACKGROUND_COLOR;
39 | }
40 |
41 | @Override
42 | protected Color getSecondBackgroundColor() {
43 | return SECOND_BACKGROUND_COLOR;
44 | }
45 |
46 | public static DefaultButtonRenderer getInstance() {
47 | if (instance == null) {
48 | instance = new DefaultButtonRenderer();
49 | }
50 | return instance;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/obutton/GreenButtonRenderer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.obutton;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.graphics.Color;
15 | import org.eclipse.swt.widgets.Display;
16 | import org.mihalis.opal.utils.SWTGraphicUtil;
17 |
18 | /**
19 | * This is the green theme button renderer
20 | */
21 | public class GreenButtonRenderer extends AbstractButtonRenderer {
22 |
23 | private static GreenButtonRenderer instance;
24 | private static final Color FIRST_BACKGROUND_COLOR = SWTGraphicUtil.getColorSafely(119, 212, 42);
25 | private static final Color SECOND_BACKGROUND_COLOR = SWTGraphicUtil.getColorSafely(38, 138, 22);
26 |
27 | private GreenButtonRenderer() {
28 | super();
29 | }
30 |
31 | @Override
32 | protected Color getFontColor() {
33 | return Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
34 | }
35 |
36 | @Override
37 | protected Color getFirstBackgroundColor() {
38 | return FIRST_BACKGROUND_COLOR;
39 | }
40 |
41 | @Override
42 | protected Color getSecondBackgroundColor() {
43 | return SECOND_BACKGROUND_COLOR;
44 | }
45 |
46 | public static GreenButtonRenderer getInstance() {
47 | if (instance == null) {
48 | instance = new GreenButtonRenderer();
49 | }
50 | return instance;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/obutton/OrangeButtonRenderer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.obutton;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.graphics.Color;
15 | import org.eclipse.swt.widgets.Display;
16 | import org.mihalis.opal.utils.SWTGraphicUtil;
17 |
18 | /**
19 | * This is the orange theme button renderer
20 | */
21 | public class OrangeButtonRenderer extends AbstractButtonRenderer {
22 |
23 | private static OrangeButtonRenderer instance;
24 | private static final Color FIRST_BACKGROUND_COLOR = SWTGraphicUtil.getColorSafely(255, 195, 117);
25 | private static final Color SECOND_BACKGROUND_COLOR = SWTGraphicUtil.getColorSafely(238, 180, 79);
26 |
27 | private OrangeButtonRenderer() {
28 | super();
29 | }
30 |
31 | @Override
32 | protected Color getFontColor() {
33 | return Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
34 | }
35 |
36 | @Override
37 | protected Color getFirstBackgroundColor() {
38 | return FIRST_BACKGROUND_COLOR;
39 | }
40 |
41 | @Override
42 | protected Color getSecondBackgroundColor() {
43 | return SECOND_BACKGROUND_COLOR;
44 | }
45 |
46 | public static OrangeButtonRenderer getInstance() {
47 | if (instance == null) {
48 | instance = new OrangeButtonRenderer();
49 | }
50 | return instance;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/obutton/PurpleButtonRenderer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.obutton;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.graphics.Color;
15 | import org.eclipse.swt.widgets.Display;
16 | import org.mihalis.opal.utils.SWTGraphicUtil;
17 |
18 | /**
19 | * This is the purple theme button renderer
20 | */
21 | public class PurpleButtonRenderer extends AbstractButtonRenderer {
22 |
23 | private static PurpleButtonRenderer instance;
24 | private static final Color FIRST_BACKGROUND_COLOR = SWTGraphicUtil.getColorSafely(192, 35, 221);
25 | private static final Color SECOND_BACKGROUND_COLOR = SWTGraphicUtil.getColorSafely(165, 17, 192);
26 |
27 | private PurpleButtonRenderer() {
28 | super();
29 | }
30 |
31 | @Override
32 | protected Color getFontColor() {
33 | return Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
34 | }
35 |
36 | @Override
37 | protected Color getFirstBackgroundColor() {
38 | return FIRST_BACKGROUND_COLOR;
39 | }
40 |
41 | @Override
42 | protected Color getSecondBackgroundColor() {
43 | return SECOND_BACKGROUND_COLOR;
44 | }
45 |
46 | public static PurpleButtonRenderer getInstance() {
47 | if (instance == null) {
48 | instance = new PurpleButtonRenderer();
49 | }
50 | return instance;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/obutton/RedButtonRenderer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.obutton;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.graphics.Color;
15 | import org.eclipse.swt.widgets.Display;
16 | import org.mihalis.opal.utils.SWTGraphicUtil;
17 |
18 | /**
19 | * This is the red theme button renderer
20 | */
21 | public class RedButtonRenderer extends AbstractButtonRenderer {
22 |
23 | private static RedButtonRenderer instance;
24 | private static final Color FIRST_BACKGROUND_COLOR = SWTGraphicUtil.getColorSafely(254, 26, 0);
25 | private static final Color SECOND_BACKGROUND_COLOR = SWTGraphicUtil.getColorSafely(208, 2, 0);
26 |
27 | private RedButtonRenderer() {
28 | super();
29 | }
30 |
31 | @Override
32 | protected Color getFontColor() {
33 | return Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
34 | }
35 |
36 | @Override
37 | protected Color getFirstBackgroundColor() {
38 | return FIRST_BACKGROUND_COLOR;
39 | }
40 |
41 | @Override
42 | protected Color getSecondBackgroundColor() {
43 | return SECOND_BACKGROUND_COLOR;
44 | }
45 |
46 | public static RedButtonRenderer getInstance() {
47 | if (instance == null) {
48 | instance = new RedButtonRenderer();
49 | }
50 | return instance;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/opalDialog/ChoiceItem.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.opalDialog;
12 |
13 | /**
14 | * Instances of this class are choice items used by the choice widget
15 | */
16 | public class ChoiceItem {
17 |
18 | private final String instruction;
19 | private final String text;
20 |
21 | /**
22 | * Constructor
23 | *
24 | * @param instruction instruction of the choice
25 | * @param text text displayed under the instruction
26 | */
27 | public ChoiceItem(final String instruction, final String text) {
28 | this.instruction = instruction;
29 | this.text = text;
30 | }
31 |
32 | /**
33 | * Constructor
34 | *
35 | * @param instruction instruction
36 | */
37 | public ChoiceItem(final String instruction) {
38 | this(instruction, null);
39 | }
40 |
41 | /**
42 | * @return the instruction
43 | */
44 | public String getInstruction() {
45 | return this.instruction;
46 | }
47 |
48 | /**
49 | * @return the text
50 | */
51 | public String getText() {
52 | return this.text;
53 | };
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/PWContainer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow;
12 |
13 | import org.eclipse.swt.widgets.Composite;
14 | import org.mihalis.opal.preferenceWindow.widgets.PWWidget;
15 |
16 | /**
17 | * Abstract class for "Containers" (row, group and tab)
18 | *
19 | */
20 | public abstract class PWContainer {
21 |
22 | /**
23 | * Add a container to the current element
24 | *
25 | * @param element element to add
26 | * @return the container
27 | */
28 | public abstract PWContainer add(final PWContainer element);
29 |
30 | /**
31 | * Add a widget to the current element
32 | *
33 | * @param widget widget to add
34 | * @return the container
35 | */
36 | public abstract PWContainer add(final PWWidget widget);
37 |
38 | /**
39 | * Build the content of the container
40 | *
41 | * @param parent parent composite
42 | */
43 | public abstract void build(final Composite parent);
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/PWRowGroup.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow;
12 |
13 | import org.mihalis.opal.preferenceWindow.enabler.Enabler;
14 |
15 | /**
16 | * Abstract class for both row and groups
17 | */
18 | public abstract class PWRowGroup extends PWContainer {
19 |
20 | protected int numberOfColumns;
21 | protected int parentNumberOfColums;
22 | protected PWContainer parent;
23 | protected Enabler enabler;
24 |
25 | /**
26 | * Check if the parent is compatible with the object
27 | *
28 | * @param parent parent to check
29 | * @throws UnsupportedOperationException if the parent is not compatible
30 | * with the object
31 | */
32 | protected abstract void checkParent(PWContainer parent);
33 |
34 | /**
35 | * Enables or disables all elements stored in this group or row
36 | */
37 | public abstract void enableOrDisable();
38 |
39 | /**
40 | * Add a column to the current element
41 | *
42 | * @param number number of column to add
43 | */
44 | public void addColumn(final int number) {
45 | this.numberOfColumns += number;
46 | }
47 |
48 | /**
49 | * @return the number of columns of this group or row
50 | */
51 | public int getNumberOfColums() {
52 | return this.numberOfColumns;
53 | }
54 |
55 | /**
56 | * @param enabler the enabler to set
57 | */
58 | public PWRowGroup setEnabler(final Enabler enabler) {
59 | this.enabler = enabler;
60 | this.enabler.injectRowGroup(this);
61 | return this;
62 | }
63 |
64 | /**
65 | * @param parent the parent to set
66 | */
67 | public void setParent(final PWContainer parent) {
68 | checkParent(parent);
69 | this.parent = parent;
70 | }
71 |
72 | /**
73 | * @param numberOfColumns the number of columns of the parent
74 | */
75 | public void setParentNumberOfColumns(final int numberOfColumns) {
76 | this.parentNumberOfColums = numberOfColumns;
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/ValueAndAssociatedWidgets.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | import org.mihalis.opal.preferenceWindow.widgets.PWWidget;
17 |
18 | /**
19 | * This POJO contains a value a list of widgets that depends on a given property
20 | *
21 | */
22 | class ValueAndAssociatedWidgets {
23 | private Object value;
24 | private final List widgets;
25 | private final List rowGroups;
26 |
27 | /**
28 | * Constructor
29 | *
30 | * @param value associated value
31 | */
32 | ValueAndAssociatedWidgets(final Object value) {
33 | this.value = value;
34 | this.widgets = new ArrayList();
35 | this.rowGroups = new ArrayList();
36 | }
37 |
38 | /**
39 | * @param widget dependant widget
40 | */
41 | void addWidget(final PWWidget widget) {
42 | this.widgets.add(widget);
43 | }
44 |
45 | /**
46 | * @param rowGroup dependant row or group
47 | */
48 | void addRowGroup(final PWRowGroup rowGroup) {
49 | this.rowGroups.add(rowGroup);
50 | }
51 |
52 | /**
53 | * @return the value stored in the instance
54 | */
55 | Object getValue() {
56 | return this.value;
57 | }
58 |
59 | /**
60 | * @param value new value stored in this instance
61 | */
62 | void setValue(final Object value) {
63 | this.value = value;
64 | fireValueChanged();
65 | }
66 |
67 | /**
68 | * Fire events when the value has changed
69 | */
70 | void fireValueChanged() {
71 | for (final PWRowGroup rowGroup : this.rowGroups) {
72 | rowGroup.enableOrDisable();
73 | }
74 |
75 | for (final PWWidget widget : this.widgets) {
76 | widget.enableOrDisable();
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/enabler/EnabledIfEquals.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow.enabler;
12 |
13 | import org.mihalis.opal.preferenceWindow.PreferenceWindow;
14 |
15 | /**
16 | * This enabler is used to enable a widget if a property is equal to a given
17 | * value
18 | */
19 | public class EnabledIfEquals extends Enabler {
20 | private final Object value;
21 |
22 | /**
23 | * Constructor
24 | *
25 | * @param prop property to evaluate
26 | * @param value condition value
27 | */
28 | public EnabledIfEquals(final String prop, final Object value) {
29 | super(prop);
30 | this.value = value;
31 | }
32 |
33 | /**
34 | * @see org.mihalis.opal.preferenceWindow.enabler.Enabler#isEnabled()
35 | */
36 | @Override
37 | public boolean isEnabled() {
38 | final Object propValue = PreferenceWindow.getInstance().getValueFor(this.prop);
39 | if (this.value == null) {
40 | return propValue == null;
41 | }
42 | return this.value.equals(propValue);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/enabler/EnabledIfNotEquals.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow.enabler;
12 |
13 | import org.mihalis.opal.preferenceWindow.PreferenceWindow;
14 |
15 | /**
16 | * This enabler is used to enable a widget if a property is not equal to a given
17 | * value
18 | */
19 | public class EnabledIfNotEquals extends Enabler {
20 | private final Object value;
21 |
22 | /**
23 | * Constructor
24 | *
25 | * @param prop property to evaluate
26 | * @param value condition value
27 | */
28 | public EnabledIfNotEquals(final String prop, final Object value) {
29 | super(prop);
30 | this.value = value;
31 | }
32 |
33 | /**
34 | * @see org.mihalis.opal.preferenceWindow.enabler.Enabler#isEnabled()
35 | */
36 | @Override
37 | public boolean isEnabled() {
38 | final Object propValue = PreferenceWindow.getInstance().getValueFor(this.prop);
39 | if (this.value == null) {
40 | return propValue == null;
41 | }
42 | return !this.value.equals(propValue);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/enabler/EnabledIfTrue.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow.enabler;
12 |
13 | import org.mihalis.opal.preferenceWindow.PreferenceWindow;
14 |
15 | /**
16 | * This enabler is used to enable a widget if a boolean property is true
17 | */
18 | public class EnabledIfTrue extends Enabler {
19 |
20 | /**
21 | * Constructor
22 | *
23 | * @param prop boolean property
24 | */
25 | public EnabledIfTrue(final String prop) {
26 | super(prop);
27 | }
28 |
29 | /**
30 | * @see org.mihalis.opal.preferenceWindow.enabler.Enabler#isEnabled()
31 | */
32 | @Override
33 | public boolean isEnabled() {
34 | final Object value = PreferenceWindow.getInstance().getValueFor(this.prop);
35 |
36 | if (value != null && !(value instanceof Boolean)) {
37 | throw new UnsupportedOperationException("Impossible to evaluate [" + this.prop + "] because it is not a Boolean !");
38 | }
39 |
40 | if (value == null) {
41 | return true;
42 | }
43 |
44 | return ((Boolean) value).booleanValue();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/enabler/Enabler.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow.enabler;
12 |
13 | import org.mihalis.opal.preferenceWindow.PWRowGroup;
14 | import org.mihalis.opal.preferenceWindow.PreferenceWindow;
15 | import org.mihalis.opal.preferenceWindow.widgets.PWWidget;
16 |
17 | /**
18 | * This is the abstract class of all Enablers. An enabler is an object used to
19 | * enable or disable a widget depending on a value of a stored property.
20 | */
21 | public abstract class Enabler {
22 |
23 | protected String prop;
24 |
25 | /**
26 | * Constructor
27 | *
28 | * @param prop property linked to the enabler.
29 | */
30 | public Enabler(final String prop) {
31 | this.prop = prop;
32 | }
33 |
34 | /**
35 | * @return the evaluation condition
36 | */
37 | public abstract boolean isEnabled();
38 |
39 | /**
40 | * Link a widget to the enabler
41 | *
42 | * @param widget widget to link
43 | */
44 | public void injectWidget(final PWWidget widget) {
45 | PreferenceWindow.getInstance().addWidgetLinkedTo(this.prop, widget);
46 | }
47 |
48 | /**
49 | * Link a row or a group to the enabler
50 | *
51 | * @param rowGroup RowGroup to link
52 | */
53 | public void injectRowGroup(final PWRowGroup rowGroup) {
54 | PreferenceWindow.getInstance().addRowGroupLinkedTo(this.prop, rowGroup);
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/widgets/PWButton.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow.widgets;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.events.SelectionListener;
15 | import org.eclipse.swt.widgets.Button;
16 | import org.eclipse.swt.widgets.Composite;
17 | import org.eclipse.swt.widgets.Control;
18 |
19 | /**
20 | * Instances of this class are buttons
21 | *
22 | */
23 | public class PWButton extends PWWidget {
24 | private final SelectionListener listener;
25 |
26 | /**
27 | * Constructor
28 | *
29 | * @param label associated label
30 | * @param listener selection listener
31 | */
32 | public PWButton(final String label, final SelectionListener listener) {
33 | super(label, null, 1, true);
34 | this.listener = listener;
35 | }
36 |
37 | /**
38 | * @see org.mihalis.opal.preferenceWindow.widgets.PWWidget#build(org.eclipse.swt.widgets.Composite)
39 | */
40 | @Override
41 | public Control build(final Composite parent) {
42 | final Button button = new Button(parent, SWT.PUSH);
43 | addControl(button);
44 | if (getLabel() == null) {
45 | throw new UnsupportedOperationException("You need to set a label for a button");
46 | } else {
47 | button.setText(getLabel());
48 | }
49 | if (this.listener != null) {
50 | button.addSelectionListener(this.listener);
51 | }
52 |
53 | return button;
54 |
55 | }
56 |
57 | /**
58 | * @see org.mihalis.opal.preferenceWindow.widgets.PWWidget#check()
59 | */
60 | @Override
61 | public void check() {
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/widgets/PWFileChooser.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow.widgets;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.widgets.Button;
15 | import org.eclipse.swt.widgets.Event;
16 | import org.eclipse.swt.widgets.FileDialog;
17 | import org.eclipse.swt.widgets.Listener;
18 | import org.eclipse.swt.widgets.Text;
19 | import org.mihalis.opal.preferenceWindow.PreferenceWindow;
20 |
21 | /**
22 | * Instances of this class are used to select a file
23 | */
24 | public class PWFileChooser extends PWChooser {
25 |
26 | /**
27 | * Constructor
28 | *
29 | * @param label associated label
30 | * @param propertyKey associated key
31 | */
32 | public PWFileChooser(final String label, final String propertyKey) {
33 | super(label, propertyKey);
34 | }
35 |
36 | /**
37 | * @see org.mihalis.opal.preferenceWindow.widgets.PWChooser#setButtonAction(org.eclipse.swt.widgets.Text,
38 | * org.eclipse.swt.widgets.Button)
39 | */
40 | @Override
41 | protected void setButtonAction(final Text text, final Button button) {
42 | final String originalFile = (String) PreferenceWindow.getInstance().getValueFor(getPropertyKey());
43 | text.setText(originalFile);
44 |
45 | button.addListener(SWT.Selection, new Listener() {
46 | @Override
47 | public void handleEvent(final Event event) {
48 | final FileDialog dialog = new FileDialog(text.getShell(), SWT.OPEN);
49 | final String result = dialog.open();
50 | if (result != null) {
51 | text.setText(result);
52 | PreferenceWindow.getInstance().setValue(getPropertyKey(), result);
53 | }
54 |
55 | }
56 | });
57 |
58 | }
59 |
60 | /**
61 | * @see org.mihalis.opal.preferenceWindow.widgets.PWWidget#check()
62 | */
63 | @Override
64 | public void check() {
65 | final Object value = PreferenceWindow.getInstance().getValueFor(getPropertyKey());
66 | if (value == null) {
67 | PreferenceWindow.getInstance().setValue(getPropertyKey(), "");
68 | } else {
69 | if (!(value instanceof String)) {
70 | throw new UnsupportedOperationException("The property '" + getPropertyKey() + "' has to be a String because it is associated to a file chooser");
71 | }
72 | }
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/widgets/PWIntegerText.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow.widgets;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.widgets.Event;
15 | import org.eclipse.swt.widgets.Listener;
16 | import org.mihalis.opal.preferenceWindow.PreferenceWindow;
17 |
18 | /**
19 | * Instances of this class are text box to type Integers
20 | */
21 | public class PWIntegerText extends PWText {
22 |
23 | /**
24 | * Constructor
25 | *
26 | * @param label associated label
27 | * @param propertyKey associated key
28 | */
29 | public PWIntegerText(final String label, final String propertyKey) {
30 | super(label, propertyKey);
31 | }
32 |
33 | /**
34 | * @see org.mihalis.opal.preferenceWindow.widgets.PWText#addVerifyListeners()
35 | */
36 | @Override
37 | public void addVerifyListeners() {
38 | this.text.addListener(SWT.Verify, new Listener() {
39 | @Override
40 | public void handleEvent(final Event e) {
41 | final String string = e.text;
42 | final char[] chars = new char[string.length()];
43 | string.getChars(0, chars.length, chars, 0);
44 | for (int i = 0; i < chars.length; i++) {
45 | if (!('0' <= chars[i] && chars[i] <= '9') && e.keyCode != SWT.BS && e.keyCode != SWT.DEL) {
46 | e.doit = false;
47 | return;
48 | }
49 | }
50 | }
51 | });
52 | }
53 |
54 | /**
55 | * @see org.mihalis.opal.preferenceWindow.widgets.PWWidget#check()
56 | */
57 | @Override
58 | public void check() {
59 | final Object value = PreferenceWindow.getInstance().getValueFor(getPropertyKey());
60 | if (value == null) {
61 | PreferenceWindow.getInstance().setValue(getPropertyKey(), Integer.valueOf(0));
62 | } else {
63 | if (!(value instanceof Integer)) {
64 | throw new UnsupportedOperationException("The property '" + getPropertyKey() + "' has to be an Integer because it is associated to a integer text widget");
65 | }
66 | }
67 | }
68 |
69 | /**
70 | * @see org.mihalis.opal.preferenceWindow.widgets.PWText#convertValue()
71 | */
72 | @Override
73 | public Object convertValue() {
74 | return Integer.parseInt(this.text.getText());
75 | }
76 |
77 | /**
78 | * @see org.mihalis.opal.preferenceWindow.widgets.PWText#getStyle()
79 | */
80 | @Override
81 | public int getStyle() {
82 | return SWT.NONE;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/widgets/PWLabel.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow.widgets;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.custom.StyledText;
15 | import org.eclipse.swt.layout.GridData;
16 | import org.eclipse.swt.widgets.Composite;
17 | import org.eclipse.swt.widgets.Control;
18 | import org.mihalis.opal.utils.SWTGraphicUtil;
19 |
20 | /**
21 | * Instances of this class are labels, that could contain some HTML tags (B,I,U)
22 | */
23 | public class PWLabel extends PWWidget {
24 |
25 | private StyledText labelWidget;
26 |
27 | /**
28 | * Constructor
29 | *
30 | * @param label associated label
31 | */
32 | public PWLabel(final String label) {
33 | super(label, null, 1, true);
34 | setAlignment(GridData.FILL);
35 | setGrabExcessSpace(true);
36 | }
37 |
38 | /**
39 | * @see org.mihalis.opal.preferenceWindow.widgets.PWWidget#build(org.eclipse.swt.widgets.Composite)
40 | */
41 | @Override
42 | public Control build(final Composite parent) {
43 | if (getLabel() == null) {
44 | throw new UnsupportedOperationException("You need to set a description for a PWLabel object");
45 | }
46 | this.labelWidget = new StyledText(parent, SWT.WRAP | SWT.READ_ONLY);
47 | this.labelWidget.setEnabled(false);
48 | this.labelWidget.setBackground(parent.getBackground());
49 | this.labelWidget.setText(getLabel());
50 | SWTGraphicUtil.applyHTMLFormating(this.labelWidget);
51 | return this.labelWidget;
52 | }
53 |
54 | /**
55 | * @see org.mihalis.opal.preferenceWindow.widgets.PWWidget#check()
56 | */
57 | @Override
58 | public void check() {
59 | }
60 |
61 | /**
62 | * @see org.mihalis.opal.preferenceWindow.widgets.PWWidget#enableOrDisable()
63 | */
64 | @Override
65 | public boolean enableOrDisable() {
66 | if (this.enabler == null) {
67 | return true;
68 | }
69 |
70 | final boolean enabled = this.enabler.isEnabled();
71 | if (!this.labelWidget.isDisposed()) {
72 | if (enabled) {
73 | this.labelWidget.setForeground(this.labelWidget.getDisplay().getSystemColor(SWT.COLOR_BLACK));
74 | } else {
75 | this.labelWidget.setForeground(this.labelWidget.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
76 | }
77 | }
78 | return enabled;
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/widgets/PWPasswordText.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow.widgets;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.mihalis.opal.preferenceWindow.PreferenceWindow;
15 |
16 | /**
17 | * Instances of this class are text box to type password
18 | */
19 | public class PWPasswordText extends PWText {
20 |
21 | /**
22 | * Constructor
23 | *
24 | * @param label associated label
25 | * @param propertyKey associated key
26 | */
27 | public PWPasswordText(final String label, final String propertyKey) {
28 | super(label, propertyKey);
29 | }
30 |
31 | /**
32 | * @see org.mihalis.opal.preferenceWindow.widgets.PWText#addVerifyListeners()
33 | */
34 | @Override
35 | public void addVerifyListeners() {
36 | }
37 |
38 | /**
39 | * @see org.mihalis.opal.preferenceWindow.widgets.PWWidget#check()
40 | */
41 | @Override
42 | public void check() {
43 | final Object value = PreferenceWindow.getInstance().getValueFor(getPropertyKey());
44 | if (value == null) {
45 | PreferenceWindow.getInstance().setValue(getPropertyKey(), "");
46 | } else {
47 | if (!(value instanceof String)) {
48 | throw new UnsupportedOperationException("The property '" + getPropertyKey() + "' has to be a String because it is associated to a password text box");
49 | }
50 | }
51 |
52 | }
53 |
54 | /**
55 | * @see org.mihalis.opal.preferenceWindow.widgets.PWText#convertValue()
56 | */
57 | @Override
58 | public Object convertValue() {
59 | return this.text.getText();
60 | }
61 |
62 | /**
63 | * @see org.mihalis.opal.preferenceWindow.widgets.PWText#getStyle()
64 | */
65 | @Override
66 | public int getStyle() {
67 | return SWT.PASSWORD;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/widgets/PWSeparator.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow.widgets;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.graphics.Image;
15 | import org.eclipse.swt.layout.GridData;
16 | import org.eclipse.swt.widgets.Composite;
17 | import org.eclipse.swt.widgets.Control;
18 | import org.mihalis.opal.titledSeparator.TitledSeparator;
19 |
20 | /**
21 | * Instances of this class are separators
22 | *
23 | */
24 | public class PWSeparator extends PWWidget {
25 |
26 | private final Image image;
27 |
28 | /**
29 | * Constructor
30 | *
31 | */
32 | public PWSeparator() {
33 | this(null, null);
34 | }
35 |
36 | /**
37 | * Constructor
38 | *
39 | * @param label associated label
40 | */
41 | public PWSeparator(final String label) {
42 | this(label, null);
43 | }
44 |
45 | /**
46 | * Constructor
47 | *
48 | * @param label associated label
49 | * @param image associated image
50 | */
51 | public PWSeparator(final String label, final Image image) {
52 | super(label, null, 1, true);
53 | this.image = image;
54 | setAlignment(GridData.FILL);
55 | setGrabExcessSpace(true);
56 | setHeight(20);
57 | }
58 |
59 | /**
60 | * @see org.mihalis.opal.preferenceWindow.widgets.PWWidget#build(org.eclipse.swt.widgets.Composite)
61 | */
62 | @Override
63 | public Control build(final Composite parent) {
64 | final TitledSeparator sep = new TitledSeparator(parent, SWT.NONE);
65 | addControl(sep);
66 | sep.setText(getLabel());
67 | sep.setImage(this.image);
68 | return sep;
69 | }
70 |
71 | /**
72 | * @see org.mihalis.opal.preferenceWindow.widgets.PWWidget#check()
73 | */
74 | @Override
75 | public void check() {
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/widgets/PWStringText.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow.widgets;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.mihalis.opal.preferenceWindow.PreferenceWindow;
15 |
16 | /**
17 | * Instances of this class are text box to type Strings
18 | */
19 | public class PWStringText extends PWText {
20 |
21 | /**
22 | * Constructor
23 | *
24 | * @param label associated label
25 | * @param propertyKey associated key
26 | */
27 | public PWStringText(final String label, final String propertyKey) {
28 | super(label, propertyKey);
29 | }
30 |
31 | /**
32 | * @see org.mihalis.opal.preferenceWindow.widgets.PWText#addVerifyListeners()
33 | */
34 | @Override
35 | public void addVerifyListeners() {
36 | }
37 |
38 | /**
39 | * @see org.mihalis.opal.preferenceWindow.widgets.PWWidget#check()
40 | */
41 | @Override
42 | public void check() {
43 | final Object value = PreferenceWindow.getInstance().getValueFor(getPropertyKey());
44 | if (value == null) {
45 | PreferenceWindow.getInstance().setValue(getPropertyKey(), "");
46 | } else {
47 | if (!(value instanceof String)) {
48 | throw new UnsupportedOperationException("The property '" + getPropertyKey() + "' has to be a String because it is associated to a stringtext");
49 | }
50 | }
51 | }
52 |
53 | /**
54 | * @see org.mihalis.opal.preferenceWindow.widgets.PWText#convertValue()
55 | */
56 | @Override
57 | public Object convertValue() {
58 | return this.text.getText();
59 | }
60 |
61 | /**
62 | * @see org.mihalis.opal.preferenceWindow.widgets.PWText#getStyle()
63 | */
64 | @Override
65 | public int getStyle() {
66 | return SWT.NONE;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/widgets/PWText.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow.widgets;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.layout.GridData;
15 | import org.eclipse.swt.widgets.Composite;
16 | import org.eclipse.swt.widgets.Control;
17 | import org.eclipse.swt.widgets.Event;
18 | import org.eclipse.swt.widgets.Listener;
19 | import org.eclipse.swt.widgets.Text;
20 | import org.mihalis.opal.preferenceWindow.PreferenceWindow;
21 |
22 | /**
23 | * This is the abstract class for all text widgets (except textarea)
24 | */
25 | public abstract class PWText extends PWWidget {
26 |
27 | protected Text text;
28 |
29 | /**
30 | * Constructor
31 | *
32 | * @param label associated label
33 | * @param propertyKey associated property key
34 | */
35 | public PWText(final String label, final String propertyKey) {
36 | super(label, propertyKey, label == null ? 1 : 2, false);
37 | setGrabExcessSpace(true);
38 | }
39 |
40 | /**
41 | * @see org.mihalis.opal.preferenceWindow.widgets.PWWidget#build(org.eclipse.swt.widgets.Composite)
42 | */
43 | @Override
44 | public Control build(final Composite parent) {
45 | buildLabel(parent, GridData.CENTER);
46 | this.text = new Text(parent, SWT.BORDER | getStyle());
47 | addControl(this.text);
48 | addVerifyListeners();
49 | this.text.setText(PreferenceWindow.getInstance().getValueFor(getPropertyKey()).toString());
50 | this.text.addListener(SWT.Modify, new Listener() {
51 | @Override
52 | public void handleEvent(final Event event) {
53 | PreferenceWindow.getInstance().setValue(getPropertyKey(), convertValue());
54 | }
55 | });
56 | return this.text;
57 | }
58 |
59 | /**
60 | * Add the verify listeners
61 | */
62 | public abstract void addVerifyListeners();
63 |
64 | /**
65 | * @return the value of the data typed by the user in the correct format
66 | */
67 | public abstract Object convertValue();
68 |
69 | /**
70 | * @return the style (SWT.NONE or SWT.PASSWORD)
71 | */
72 | public abstract int getStyle();
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/preferenceWindow/widgets/PWTextarea.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.preferenceWindow.widgets;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.layout.GridData;
15 | import org.eclipse.swt.widgets.Composite;
16 | import org.eclipse.swt.widgets.Control;
17 | import org.eclipse.swt.widgets.Event;
18 | import org.eclipse.swt.widgets.Listener;
19 | import org.eclipse.swt.widgets.Text;
20 | import org.mihalis.opal.preferenceWindow.PreferenceWindow;
21 |
22 | /**
23 | * Instances of this class are text areas
24 | *
25 | */
26 | public class PWTextarea extends PWWidget {
27 |
28 | /**
29 | * Constructor
30 | *
31 | * @param label associated label
32 | * @param propertyKey associated key
33 | */
34 | public PWTextarea(final String label, final String propertyKey) {
35 | super(label, propertyKey, label == null ? 1 : 2, false);
36 | setGrabExcessSpace(true);
37 | setHeight(50);
38 | setWidth(350);
39 | }
40 |
41 | /**
42 | * @see org.mihalis.opal.preferenceWindow.widgets.PWWidget#build(org.eclipse.swt.widgets.Composite)
43 | */
44 | @Override
45 | public Control build(final Composite parent) {
46 | buildLabel(parent, GridData.BEGINNING);
47 |
48 | final Text text = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
49 | addControl(text);
50 | text.setText(PreferenceWindow.getInstance().getValueFor(getPropertyKey()).toString());
51 | text.addListener(SWT.FocusOut, new Listener() {
52 |
53 | @Override
54 | public void handleEvent(final Event event) {
55 | PreferenceWindow.getInstance().setValue(getPropertyKey(), text.getText());
56 | }
57 | });
58 |
59 | return text;
60 | }
61 |
62 | /**
63 | * @see org.mihalis.opal.preferenceWindow.widgets.PWWidget#check()
64 | */
65 | @Override
66 | public void check() {
67 | final Object value = PreferenceWindow.getInstance().getValueFor(getPropertyKey());
68 | if (value == null) {
69 | PreferenceWindow.getInstance().setValue(getPropertyKey(), "");
70 | } else {
71 | if (!(value instanceof String)) {
72 | throw new UnsupportedOperationException("The property '" + getPropertyKey() + "' has to be a String because it is associated to a textarea");
73 | }
74 | }
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/promptSupport/CComboFocusControlListener.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.promptSupport;
12 |
13 | import org.eclipse.swt.custom.CCombo;
14 |
15 | /**
16 | * Focus/Control listener for a CCombo widget
17 | */
18 | class CComboFocusControlListener extends BaseFocusControlListener {
19 |
20 | /**
21 | * Constructor
22 | *
23 | * @param control control on which this listener will be attached
24 | */
25 | public CComboFocusControlListener(final CCombo control) {
26 | super(control);
27 | }
28 |
29 | /**
30 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#hidePrompt()
31 | */
32 | @Override
33 | protected void hidePrompt() {
34 | ((CCombo) this.control).setText(EMPTY_STRING);
35 | }
36 |
37 | /**
38 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#highLightPrompt()
39 | */
40 | @Override
41 | protected void highLightPrompt() {
42 | }
43 |
44 | /**
45 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#fillPromptText()
46 | */
47 | @Override
48 | protected void fillPromptText() {
49 | final String promptText = PromptSupport.getPrompt(this.control);
50 | if (promptText != null) {
51 | ((CCombo) this.control).setText(promptText);
52 | }
53 | }
54 |
55 | /**
56 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#isFilled()
57 | */
58 | @Override
59 | protected boolean isFilled() {
60 | final String promptText = PromptSupport.getPrompt(this.control);
61 | if (promptText != null && promptText.equals(((CCombo) this.control).getText().trim())) {
62 | return false;
63 | }
64 | return !EMPTY_STRING.equals(((CCombo) this.control).getText().trim());
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/promptSupport/ComboFocusControlListener.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.promptSupport;
12 |
13 | import org.eclipse.swt.widgets.Combo;
14 |
15 | /**
16 | * Focus/Control listener for a Combo widget
17 | */
18 | class ComboFocusControlListener extends BaseFocusControlListener {
19 |
20 | /**
21 | * Constructor
22 | *
23 | * @param control control on which this listener will be attached
24 | */
25 | public ComboFocusControlListener(final Combo control) {
26 | super(control);
27 | }
28 |
29 | /**
30 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#hidePrompt()
31 | */
32 | @Override
33 | protected void hidePrompt() {
34 | ((Combo) this.control).setText("");
35 | }
36 |
37 | /**
38 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#highLightPrompt()
39 | */
40 | @Override
41 | protected void highLightPrompt() {
42 | }
43 |
44 | /**
45 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#fillPromptText()
46 | */
47 | @Override
48 | protected void fillPromptText() {
49 | final String promptText = PromptSupport.getPrompt(this.control);
50 | if (promptText != null) {
51 | this.control.getDisplay().asyncExec(new Runnable() {
52 |
53 | @Override
54 | public void run() {
55 | ((Combo) ComboFocusControlListener.this.control).setText(promptText);
56 | }
57 | });
58 | }
59 | }
60 |
61 | /**
62 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#isFilled()
63 | */
64 | @Override
65 | protected boolean isFilled() {
66 | final String promptText = PromptSupport.getPrompt(this.control);
67 | if (promptText != null && promptText.equals(((Combo) this.control).getText().trim())) {
68 | return false;
69 | }
70 | return !"".equals(((Combo) this.control).getText().trim());
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/promptSupport/FocusControlListenerFactory.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.promptSupport;
12 |
13 | import org.eclipse.swt.custom.CCombo;
14 | import org.eclipse.swt.custom.StyledText;
15 | import org.eclipse.swt.widgets.Combo;
16 | import org.eclipse.swt.widgets.Control;
17 | import org.eclipse.swt.widgets.Text;
18 |
19 | /**
20 | * This is a factory of focus/control listeners
21 | *
22 | */
23 | class FocusControlListenerFactory {
24 |
25 | /**
26 | * @param control control on which the listener will be added
27 | * @return a BaseControlFocus Listener that can be attached to the events
28 | * focusLost, focusGained and controlResized
29 | */
30 | static BaseFocusControlListener getFocusControlListenerFor(final Control control) {
31 | if (control instanceof Combo) {
32 | return new ComboFocusControlListener((Combo) control);
33 | }
34 | if (control instanceof CCombo) {
35 | return new CComboFocusControlListener((CCombo) control);
36 | }
37 |
38 | if (control instanceof Text) {
39 | return new TextFocusControlListener((Text) control);
40 | }
41 |
42 | if (control instanceof StyledText) {
43 | return new StyledTextFocusControlListener((StyledText) control);
44 | }
45 | throw new IllegalArgumentException("Control should be a Text, a Combo, a CCombo or a StyledText widget");
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/promptSupport/StyledTextFocusControlListener.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 |
9 | * Contributors:
10 | * Laurent CARON (laurent.caron at gmail dot com) - Initial API and implementation
11 | *******************************************************************************/
12 | package org.mihalis.opal.promptSupport;
13 |
14 | import org.eclipse.swt.custom.StyledText;
15 |
16 | /**
17 | * Focus/Control listener for a StyledText widget
18 | */
19 | class StyledTextFocusControlListener extends BaseFocusControlListener {
20 |
21 | /**
22 | * Constructor
23 | *
24 | * @param control control on which this listener will be attached
25 | */
26 | public StyledTextFocusControlListener(final StyledText control) {
27 | super(control);
28 | }
29 |
30 | /**
31 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#hidePrompt()
32 | */
33 | @Override
34 | protected void hidePrompt() {
35 | ((StyledText) this.control).setText(EMPTY_STRING);
36 | }
37 |
38 | /**
39 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#highLightPrompt()
40 | */
41 | @Override
42 | protected void highLightPrompt() {
43 | this.control.getDisplay().asyncExec(new Runnable() {
44 | @Override
45 | public void run() {
46 | ((StyledText) StyledTextFocusControlListener.this.control).selectAll();
47 |
48 | }
49 | });
50 | }
51 |
52 | /**
53 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#fillPromptText()
54 | */
55 | @Override
56 | protected void fillPromptText() {
57 | final String promptText = PromptSupport.getPrompt(this.control);
58 | if (promptText != null) {
59 | ((StyledText) this.control).setText(promptText);
60 | }
61 |
62 | }
63 |
64 | /**
65 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#isFilled()
66 | */
67 | @Override
68 | protected boolean isFilled() {
69 | final String promptText = PromptSupport.getPrompt(this.control);
70 | if (promptText != null && promptText.equals(((StyledText) this.control).getText().trim())) {
71 | return false;
72 | }
73 | return !EMPTY_STRING.equals(((StyledText) this.control).getText().trim());
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/promptSupport/TextFocusControlListener.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.promptSupport;
12 |
13 | import org.eclipse.swt.widgets.Text;
14 |
15 | /**
16 | * Focus/Control listener for a Text widget
17 | */
18 | class TextFocusControlListener extends BaseFocusControlListener {
19 |
20 | /**
21 | * Constructor
22 | *
23 | * @param control control on which this listener will be attached
24 | */
25 | public TextFocusControlListener(final Text control) {
26 | super(control);
27 | }
28 |
29 | /**
30 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#hidePrompt()
31 | */
32 | @Override
33 | protected void hidePrompt() {
34 | ((Text) this.control).setText(EMPTY_STRING);
35 | }
36 |
37 | /**
38 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#highLightPrompt()
39 | */
40 | @Override
41 | protected void highLightPrompt() {
42 | // If we do a select all directly, it's not working !
43 | this.control.getDisplay().asyncExec(new Runnable() {
44 | @Override
45 | public void run() {
46 | ((Text) TextFocusControlListener.this.control).selectAll();
47 | }
48 | });
49 | }
50 |
51 | /**
52 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#fillPromptText()
53 | */
54 | @Override
55 | protected void fillPromptText() {
56 | final String promptText = PromptSupport.getPrompt(this.control);
57 | if (promptText != null) {
58 | ((Text) this.control).setText(promptText);
59 | }
60 | }
61 |
62 | /**
63 | * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#isFilled()
64 | */
65 | @Override
66 | protected boolean isFilled() {
67 | final String promptText = PromptSupport.getPrompt(this.control);
68 | if (promptText != null && promptText.equals(((Text) this.control).getText().trim())) {
69 | return false;
70 | }
71 | return !EMPTY_STRING.equals(((Text) this.control).getText().trim());
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/propertyTable/PTPropertyChangeListener.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.propertyTable;
12 |
13 | /**
14 | * Classes which implement this interface provide methods that deal with the
15 | * events that are generated when value of the property is changed
16 | *
17 | */
18 | public interface PTPropertyChangeListener {
19 | /**
20 | * Sent when value is changed in a property.
21 | *
22 | * @param property property which value has changed
23 | */
24 | void propertyHasChanged(PTProperty property);
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/propertyTable/PTWidget.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.propertyTable;
12 |
13 | import org.eclipse.swt.widgets.Composite;
14 |
15 | /**
16 | * Classes which implement this interface are widgets that may compose a
17 | * PropertyTable (Table for Flat List, TableTree for Category)
18 | *
19 | */
20 | public interface PTWidget {
21 |
22 | /**
23 | * Build the widget (Table or TreeTable)
24 | *
25 | * @return the built widget
26 | */
27 | PTWidget build();
28 |
29 | /**
30 | * Dispose the previous widget and build a new one (when ones switch from
31 | * Category View to Flat List view)
32 | *
33 | * @param table the PropertyTable to dispose
34 | * @return the built widget
35 | */
36 | PTWidget disposeAndBuild(PropertyTable table);
37 |
38 | /**
39 | * Inject the parent property table in the widget
40 | *
41 | * @param table table to inject
42 | */
43 | void setParentPropertyTable(final PropertyTable table);
44 |
45 | /**
46 | * Clear all data and fill the widget
47 | */
48 | void refillData();
49 |
50 | /**
51 | * @return the underlying widget (Table or TableTree)
52 | */
53 | Composite getWidget();
54 |
55 | /**
56 | * Update the description panel (if it exists)
57 | *
58 | * @param selection selected property
59 | */
60 | void updateDescriptionPanel(final Object selection);
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/propertyTable/PTWidgetFactory.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.propertyTable;
12 |
13 | /**
14 | * This class is a factory that builds the widget that is part of a property
15 | * table
16 | */
17 | class PTWidgetFactory {
18 |
19 | /**
20 | * Build the widget displayed in a property table
21 | *
22 | * @param table property table
23 | * @return the widget
24 | */
25 | static PTWidget build(final PropertyTable table) {
26 | PTWidget widget;
27 | if (table.styleOfView == PropertyTable.VIEW_AS_FLAT_LIST) {
28 | widget = new PTWidgetTable();
29 | } else {
30 | widget = new PTWidgetTree();
31 | }
32 | widget.setParentPropertyTable(table);
33 | return widget;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/propertyTable/editor/PTDirectoryEditor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.propertyTable.editor;
12 |
13 | import org.eclipse.swt.graphics.Color;
14 | import org.eclipse.swt.widgets.DirectoryDialog;
15 | import org.eclipse.swt.widgets.Item;
16 | import org.eclipse.swt.widgets.TableItem;
17 | import org.eclipse.swt.widgets.TreeItem;
18 | import org.mihalis.opal.propertyTable.PTProperty;
19 | import org.mihalis.opal.propertyTable.PTWidget;
20 | import org.mihalis.opal.utils.ResourceManager;
21 | import org.mihalis.opal.utils.StringUtil;
22 |
23 | /**
24 | * This editor allows user to select a directory
25 | */
26 | public class PTDirectoryEditor extends PTChooserEditor {
27 |
28 | /**
29 | * @see org.mihalis.opal.propertyTable.editor.PTChooserEditor#openWindow(org.mihalis.opal.propertyTable.PTWidget,
30 | * org.eclipse.swt.widgets.Item,
31 | * org.mihalis.opal.propertyTable.PTProperty)
32 | */
33 | @Override
34 | protected void openWindow(final PTWidget widget, final Item item, final PTProperty property) {
35 | final DirectoryDialog dialog = new DirectoryDialog(widget.getWidget().getShell());
36 | dialog.setMessage(ResourceManager.getLabel(ResourceManager.CHOOSE_DIRECTORY));
37 | final String result = dialog.open();
38 | if (result != null) {
39 | if (item instanceof TableItem) {
40 | ((TableItem) item).setText(1, result);
41 | } else {
42 | ((TreeItem) item).setText(1, result);
43 | }
44 | property.setValue(result);
45 | }
46 |
47 | }
48 |
49 | /**
50 | * @see org.mihalis.opal.propertyTable.editor.PTChooserEditor#getTextFor(org.mihalis.opal.propertyTable.PTProperty)
51 | */
52 | @Override
53 | protected String getTextFor(final PTProperty property) {
54 | return StringUtil.safeToString(property.getValue());
55 | }
56 |
57 | /**
58 | * @see org.mihalis.opal.propertyTable.editor.PTChooserEditor#getBackgroundColor(org.mihalis.opal.propertyTable.PTProperty)
59 | */
60 | @Override
61 | protected Color getBackgroundColor(final PTProperty property) {
62 | return null;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/propertyTable/editor/PTEditor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.propertyTable.editor;
12 |
13 | import org.eclipse.swt.custom.ControlEditor;
14 | import org.eclipse.swt.widgets.Item;
15 | import org.mihalis.opal.propertyTable.PTProperty;
16 | import org.mihalis.opal.propertyTable.PTWidget;
17 |
18 | /**
19 | * This abstract class represents a Property Table Editor. An editor is a widget
20 | * that allows one to modify a property
21 | *
22 | */
23 | public abstract class PTEditor {
24 |
25 | /**
26 | * Renders an editor
27 | *
28 | * @param parent the parent PTWidget (a table or a tree table)
29 | * @param item the item on which the editor is displayed
30 | * @param property the property associated to the editor
31 | * @return a control editor
32 | */
33 | public abstract ControlEditor render(PTWidget parent, Item item, PTProperty property);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/propertyTable/editor/PTFileEditor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.propertyTable.editor;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.graphics.Color;
15 | import org.eclipse.swt.widgets.FileDialog;
16 | import org.eclipse.swt.widgets.Item;
17 | import org.eclipse.swt.widgets.TableItem;
18 | import org.eclipse.swt.widgets.TreeItem;
19 | import org.mihalis.opal.propertyTable.PTProperty;
20 | import org.mihalis.opal.propertyTable.PTWidget;
21 | import org.mihalis.opal.utils.StringUtil;
22 |
23 | /**
24 | * This editor allows user to select a file
25 | */
26 | public class PTFileEditor extends PTChooserEditor {
27 |
28 | /**
29 | * @see org.mihalis.opal.propertyTable.editor.PTChooserEditor#openWindow(org.mihalis.opal.propertyTable.PTWidget,
30 | * org.eclipse.swt.widgets.Item,
31 | * org.mihalis.opal.propertyTable.PTProperty)
32 | */
33 | @Override
34 | protected void openWindow(final PTWidget widget, final Item item, final PTProperty property) {
35 | final FileDialog dialog = new FileDialog(widget.getWidget().getShell(), SWT.OPEN);
36 | final String result = dialog.open();
37 | if (result != null) {
38 | if (item instanceof TableItem) {
39 | ((TableItem) item).setText(1, result);
40 | } else {
41 | ((TreeItem) item).setText(1, result);
42 | }
43 | property.setValue(result);
44 | }
45 |
46 | }
47 |
48 | /**
49 | * @see org.mihalis.opal.propertyTable.editor.PTChooserEditor#getTextFor(org.mihalis.opal.propertyTable.PTProperty)
50 | */
51 | @Override
52 | protected String getTextFor(final PTProperty property) {
53 | return StringUtil.safeToString(property.getValue());
54 | }
55 |
56 | /**
57 | * @see org.mihalis.opal.propertyTable.editor.PTChooserEditor#getBackgroundColor(org.mihalis.opal.propertyTable.PTProperty)
58 | */
59 | @Override
60 | protected Color getBackgroundColor(final PTProperty property) {
61 | return null;
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/propertyTable/editor/PTFloatEditor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.propertyTable.editor;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.events.VerifyEvent;
15 | import org.eclipse.swt.events.VerifyListener;
16 | import org.mihalis.opal.utils.StringUtil;
17 |
18 | /**
19 | * This editor is used to edit float values
20 | */
21 | public class PTFloatEditor extends PTBaseTextEditor {
22 |
23 | /**
24 | * @see org.mihalis.opal.propertyTable.editor.PTBaseTextEditor#addVerifyListeners()
25 | */
26 | @Override
27 | public void addVerifyListeners() {
28 | this.text.addVerifyListener(new VerifyListener() {
29 |
30 | @Override
31 | public void verifyText(final VerifyEvent e) {
32 | if (e.character != 0 && !Character.isDigit(e.character) && e.keyCode != SWT.BS && e.keyCode != SWT.DEL && e.character != '.' && e.character != ',') {
33 | e.doit = false;
34 | return;
35 | }
36 |
37 | e.doit = verifyEntry(e.text, e.keyCode);
38 |
39 | }
40 | });
41 | }
42 |
43 | /**
44 | * Check if an entry is a float
45 | *
46 | * @param entry text typed by the user
47 | * @param keyCode key code
48 | * @return true if the user typed a float value, false otherwise
49 | */
50 | private boolean verifyEntry(final String entry, final int keyCode) {
51 | final String work;
52 | if (keyCode == SWT.DEL) {
53 | work = StringUtil.removeCharAt(this.text.getText(), this.text.getCaretPosition());
54 | } else if (keyCode == SWT.BS && this.text.getCaretPosition() == 0) {
55 | work = StringUtil.removeCharAt(this.text.getText(), this.text.getCaretPosition() - 1);
56 | } else if (keyCode == 0) {
57 | work = entry;
58 | } else {
59 | work = StringUtil.insertString(this.text.getText(), entry, this.text.getCaretPosition());
60 | }
61 |
62 | try {
63 | Double.parseDouble(work.replace(',', '.'));
64 | } catch (final NumberFormatException nfe) {
65 | return false;
66 | }
67 |
68 | return true;
69 | }
70 |
71 | /**
72 | * @see org.mihalis.opal.propertyTable.editor.PTBaseTextEditor#convertValue()
73 | */
74 | @Override
75 | public Object convertValue() {
76 | return Float.parseFloat(this.text.getText());
77 | }
78 |
79 | /**
80 | * @see org.mihalis.opal.propertyTable.editor.PTBaseTextEditor#getStyle()
81 | */
82 | @Override
83 | public int getStyle() {
84 | return SWT.NONE;
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/propertyTable/editor/PTIntegerEditor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.propertyTable.editor;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.widgets.Event;
15 | import org.eclipse.swt.widgets.Listener;
16 |
17 | /**
18 | * This editor is used to edit integer values
19 | */
20 | public class PTIntegerEditor extends PTBaseTextEditor {
21 |
22 | /**
23 | * @see org.mihalis.opal.propertyTable.editor.PTBaseTextEditor#addVerifyListeners()
24 | */
25 | @Override
26 | public void addVerifyListeners() {
27 | this.text.addListener(SWT.Verify, new Listener() {
28 | @Override
29 | public void handleEvent(final Event e) {
30 | final String string = e.text;
31 | final char[] chars = new char[string.length()];
32 | string.getChars(0, chars.length, chars, 0);
33 | for (int i = 0; i < chars.length; i++) {
34 | if (!('0' <= chars[i] && chars[i] <= '9') && e.keyCode != SWT.BS && e.keyCode != SWT.DEL) {
35 | e.doit = false;
36 | return;
37 | }
38 | }
39 | }
40 | });
41 | }
42 |
43 | /**
44 | * @see org.mihalis.opal.propertyTable.editor.PTBaseTextEditor#convertValue()
45 | */
46 | @Override
47 | public Object convertValue() {
48 | int ret = 0;
49 | try {
50 | ret = Integer.parseInt(this.text.getText());
51 | } catch (final NumberFormatException e) {
52 | ret = 0;
53 | this.text.setText("0");
54 | }
55 | return ret;
56 | }
57 |
58 | /**
59 | * @see org.mihalis.opal.propertyTable.editor.PTBaseTextEditor#getStyle()
60 | */
61 | @Override
62 | public int getStyle() {
63 | return SWT.NONE;
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/propertyTable/editor/PTPasswordEditor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.propertyTable.editor;
12 |
13 | import org.eclipse.swt.SWT;
14 |
15 | /**
16 | * This editor is used to edit passwords
17 | */
18 | public class PTPasswordEditor extends PTBaseTextEditor {
19 |
20 | /**
21 | * @see org.mihalis.opal.propertyTable.editor.PTBaseTextEditor#addVerifyListeners()
22 | */
23 | @Override
24 | public void addVerifyListeners() {
25 | }
26 |
27 | /**
28 | * @see org.mihalis.opal.propertyTable.editor.PTBaseTextEditor#convertValue()
29 | */
30 | @Override
31 | public Object convertValue() {
32 | return this.text.getText();
33 | }
34 |
35 | /**
36 | * @see org.mihalis.opal.propertyTable.editor.PTBaseTextEditor#getStyle()
37 | */
38 | @Override
39 | public int getStyle() {
40 | return SWT.PASSWORD;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/propertyTable/editor/PTStringEditor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.propertyTable.editor;
12 |
13 | import org.eclipse.swt.SWT;
14 |
15 | /**
16 | * This editor is used to edit string values
17 | */
18 | public class PTStringEditor extends PTBaseTextEditor {
19 |
20 | @Override
21 | public void addVerifyListeners() {
22 | }
23 |
24 | @Override
25 | public Object convertValue() {
26 | return this.text.getText();
27 | }
28 |
29 | @Override
30 | public int getStyle() {
31 | return SWT.NONE;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/propertyTable/editor/PTURLEditor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.propertyTable.editor;
12 |
13 | import java.net.MalformedURLException;
14 | import java.net.URL;
15 |
16 | import org.eclipse.swt.SWT;
17 | import org.eclipse.swt.widgets.Event;
18 | import org.eclipse.swt.widgets.Listener;
19 | import org.mihalis.opal.opalDialog.Dialog;
20 | import org.mihalis.opal.utils.ResourceManager;
21 |
22 | /**
23 | * This editor is used to edit URL values
24 | */
25 | public class PTURLEditor extends PTBaseTextEditor {
26 |
27 | /**
28 | * @see org.mihalis.opal.propertyTable.editor.PTBaseTextEditor#addVerifyListeners()
29 | */
30 | @Override
31 | public void addVerifyListeners() {
32 | this.text.addListener(SWT.FocusOut, new Listener() {
33 |
34 | @Override
35 | public void handleEvent(final Event event) {
36 | try {
37 | new URL(PTURLEditor.this.text.getText());
38 | } catch (final MalformedURLException e) {
39 | Dialog.error(ResourceManager.getLabel(ResourceManager.APPLICATION_ERROR), ResourceManager.getLabel(ResourceManager.VALID_URL));
40 | event.doit = false;
41 | PTURLEditor.this.text.forceFocus();
42 | }
43 |
44 | }
45 | });
46 |
47 | }
48 |
49 | /**
50 | * @see org.mihalis.opal.propertyTable.editor.PTBaseTextEditor#convertValue()
51 | */
52 | @Override
53 | public Object convertValue() {
54 | return this.text.getText();
55 | }
56 |
57 | /**
58 | * @see org.mihalis.opal.propertyTable.editor.PTBaseTextEditor#getStyle()
59 | */
60 | @Override
61 | public int getStyle() {
62 | return SWT.NONE;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/systemMonitor/CPUUsageSample.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.systemMonitor;
12 |
13 | import java.lang.management.ManagementFactory;
14 |
15 | import javax.management.MBeanServerConnection;
16 | import javax.management.ObjectName;
17 |
18 | /**
19 | * Instances of this class represent a sample that contains the CPU usage
20 | */
21 | public class CPUUsageSample implements Sample {
22 |
23 | private static final String PROCESS_CPU_TIME = "ProcessCpuTime";
24 | private static final String OBJECT_NAME_ATTRIBUTE = "java.lang:type=OperatingSystem";
25 | private final MBeanServerConnection mBeanServerConnection = ManagementFactory.getPlatformMBeanServer();
26 | private ObjectName objectName;
27 | private long time;
28 | private long processTime;
29 |
30 | /**
31 | * Constructor
32 | */
33 | public CPUUsageSample() {
34 | try {
35 | this.objectName = new ObjectName(OBJECT_NAME_ATTRIBUTE);
36 | } catch (final Exception e) {
37 | throw new RuntimeException(e);
38 | }
39 | }
40 |
41 | /**
42 | * @see org.mihalis.opal.systemMonitor.Sample#getValue()
43 | */
44 | @Override
45 | public double getValue() {
46 | try {
47 | float f = ((Long) this.mBeanServerConnection.getAttribute(this.objectName, PROCESS_CPU_TIME)).longValue() - this.processTime;
48 | f /= System.nanoTime() - this.time;
49 | this.time = System.nanoTime();
50 | this.processTime = ((Long) this.mBeanServerConnection.getAttribute(this.objectName, PROCESS_CPU_TIME)).longValue();
51 | return f;
52 | } catch (final Exception localException) {
53 | throw new RuntimeException(localException);
54 | }
55 | }
56 |
57 | /**
58 | * @see org.mihalis.opal.systemMonitor.Sample#getMaxValue()
59 | */
60 | @Override
61 | public double getMaxValue() {
62 | return 1.0d;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/systemMonitor/HeapMemorySample.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.systemMonitor;
12 |
13 | import java.lang.management.ManagementFactory;
14 |
15 | import javax.management.MBeanServerConnection;
16 | import javax.management.ObjectName;
17 | import javax.management.openmbean.CompositeDataSupport;
18 |
19 | /**
20 | * Instances of this class represent a sample that contains the Thread Usage of
21 | * the running application
22 | */
23 | public class HeapMemorySample implements Sample {
24 | private static final String COMMITTED = "committed";
25 | private static final String USED = "used";
26 | private static final String HEAP_MEMORY_USAGE = "HeapMemoryUsage";
27 | private static final String OBJECT_NAME_ATTRIBUTE = "java.lang:type=Memory";
28 | private final MBeanServerConnection mBeanServerConnection = ManagementFactory.getPlatformMBeanServer();
29 | private final ObjectName objectName;
30 |
31 | /**
32 | * Constructor
33 | */
34 | HeapMemorySample() {
35 | try {
36 | this.objectName = new ObjectName(OBJECT_NAME_ATTRIBUTE);
37 | } catch (final Exception e) {
38 | throw new RuntimeException(e);
39 | }
40 | }
41 |
42 | /**
43 | * @see org.mihalis.opal.systemMonitor.Sample#getValue()
44 | */
45 | @Override
46 | public double getValue() {
47 | try {
48 | return ((Long) ((CompositeDataSupport) this.mBeanServerConnection.getAttribute(this.objectName, HEAP_MEMORY_USAGE)).get(USED)).longValue() / 1024.0D / 1024.0D;
49 | } catch (final Exception e) {
50 | throw new RuntimeException(e);
51 | }
52 |
53 | }
54 |
55 | /**
56 | * @see org.mihalis.opal.systemMonitor.Sample#getMaxValue()
57 | */
58 | @Override
59 | public double getMaxValue() {
60 | try {
61 | return ((Long) ((CompositeDataSupport) this.mBeanServerConnection.getAttribute(this.objectName, HEAP_MEMORY_USAGE)).get(COMMITTED)).longValue() / 1024.0D / 1024.0D;
62 | } catch (final Exception e) {
63 | throw new RuntimeException(e);
64 | }
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/systemMonitor/PhysicalMemorySample.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.systemMonitor;
12 |
13 | import java.lang.management.ManagementFactory;
14 |
15 | import javax.management.MBeanServerConnection;
16 | import javax.management.ObjectName;
17 |
18 | /**
19 | * Instances of this class represent a sample that contains the OS memory usage
20 | */
21 | public class PhysicalMemorySample implements Sample {
22 | private static final String TOTAL_PHYSICAL_MEMORY_SIZE = "TotalPhysicalMemorySize";
23 | private static final String FREE_PHYSICAL_MEMORY_SIZE = "FreePhysicalMemorySize";
24 | private static final String OBJECT_NAME_ATTRIBUTE = "java.lang:type=OperatingSystem";
25 | private final MBeanServerConnection mBeanServerConnection = ManagementFactory.getPlatformMBeanServer();
26 | private ObjectName objectName;
27 |
28 | /**
29 | * Constructor
30 | */
31 | PhysicalMemorySample() {
32 | try {
33 | this.objectName = new ObjectName(OBJECT_NAME_ATTRIBUTE);
34 | } catch (final Exception e) {
35 | throw new RuntimeException(e);
36 | }
37 | }
38 |
39 | /**
40 | * @see org.mihalis.opal.systemMonitor.Sample#getValue()
41 | */
42 | @Override
43 | public double getValue() {
44 | try {
45 | final double memSize = ((Long) this.mBeanServerConnection.getAttribute(this.objectName, FREE_PHYSICAL_MEMORY_SIZE)).longValue() / 1024.0d / 1024.0d;
46 | return getMaxValue() - memSize;
47 | } catch (final Exception e) {
48 | throw new RuntimeException(e);
49 | }
50 | }
51 |
52 | /**
53 | * @see org.mihalis.opal.systemMonitor.Sample#getMaxValue()
54 | */
55 | @Override
56 | public double getMaxValue() {
57 | try {
58 | return ((Long) this.mBeanServerConnection.getAttribute(this.objectName, TOTAL_PHYSICAL_MEMORY_SIZE)).longValue() / 1024.0d / 1024.0d;
59 | } catch (final Exception e) {
60 | throw new RuntimeException(e);
61 | }
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/systemMonitor/Sample.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 2Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.systemMonitor;
12 |
13 | /**
14 | * This interface represents a data sample that will be displayed in the
15 | * SystemMonitor widget
16 | */
17 | public interface Sample {
18 | /**
19 | * @return the current value of the sample
20 | */
21 | double getValue();
22 |
23 | /**
24 | * @return the max value of the sample
25 | */
26 | double getMaxValue();
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/systemMonitor/SampleFactory.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.systemMonitor;
12 |
13 | import org.eclipse.swt.graphics.RGB;
14 | import org.mihalis.opal.utils.ResourceManager;
15 |
16 | /**
17 | * This class is a factory that returns the built-o, samples
18 | */
19 | public class SampleFactory {
20 |
21 | /**
22 | * SampleFactory instance
23 | */
24 | private static SampleFactory instance;
25 |
26 | /**
27 | * Constructor
28 | */
29 | private SampleFactory() {
30 | }
31 |
32 | /**
33 | * @return the instance of the factory
34 | */
35 | public static SampleFactory getInstance() {
36 | if (instance == null) {
37 | instance = new SampleFactory();
38 | }
39 | return instance;
40 | }
41 |
42 | /**
43 | * Give a built-in sample
44 | *
45 | * @param identifier Identifier
46 | * @return the sample that corresponds to the identifier
47 | */
48 | public SampleWrapper getSample(final SampleIdentifier identifier) {
49 | switch (identifier) {
50 | case CPU_USAGE: {
51 | final SampleWrapper sr = new SampleWrapper(new CPUUsageSample());
52 | sr.setColor(new RGB(128, 25, 0));
53 | sr.setCaption(ResourceManager.CPU_USAGE + ":");
54 | sr.setFormatPattern("%{percentValue}.0f%%");
55 | return sr;
56 | }
57 | case HEAP_MEMORY: {
58 | final SampleWrapper sr = new SampleWrapper(new HeapMemorySample());
59 | sr.setColor(new RGB(111, 83, 0));
60 | sr.setCaption(ResourceManager.HEAP_MEMORY + ":");
61 | sr.setFormatPattern("%{value},.2fMB / %{maxValue},.2fMB");
62 | return sr;
63 | }
64 | case PHYSICAL_MEMORY: {
65 | final SampleWrapper sr = new SampleWrapper(new PhysicalMemorySample());
66 | sr.setColor(new RGB(15, 75, 0));
67 | sr.setCaption(ResourceManager.PHYSICAL_MEMORY + ":");
68 | sr.setFormatPattern("%{value},.0fMB / %{maxValue},.0fMB");
69 | return sr;
70 | }
71 | default: {
72 | final SampleWrapper sr = new SampleWrapper(new ThreadsUsageSample());
73 | sr.setColor(new RGB(0, 77, 88));
74 | sr.setCaption(ResourceManager.THREADS + ":");
75 | sr.setFormatPattern("%{value},.0f / %{maxValue},.0f (Peak)");
76 | return sr;
77 | }
78 | }
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/systemMonitor/SampleIdentifier.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.systemMonitor;
12 |
13 | /**
14 | * This enumeration lists all built-in samples
15 | */
16 | public enum SampleIdentifier {
17 | PHYSICAL_MEMORY, HEAP_MEMORY, THREADS, CPU_USAGE
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/systemMonitor/ThreadsUsageSample.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.systemMonitor;
12 |
13 | import java.lang.management.ManagementFactory;
14 |
15 | import javax.management.MBeanServerConnection;
16 | import javax.management.ObjectName;
17 |
18 | /**
19 | * Instances of this class represent a sample that contains the Thread Usage of
20 | * the running application
21 | */
22 | public class ThreadsUsageSample implements Sample {
23 | private static final String PEAK_THREAD_COUNT = "PeakThreadCount";
24 | private static final String THREAD_COUNT = "ThreadCount";
25 | private static final String OBJECT_NAME_ATTRIBUTE = "java.lang:type=Threading";
26 | private final MBeanServerConnection mBeanServerConnection = ManagementFactory.getPlatformMBeanServer();
27 | private ObjectName objectName;
28 |
29 | /**
30 | * Constructor
31 | */
32 | ThreadsUsageSample() {
33 | try {
34 | this.objectName = new ObjectName(OBJECT_NAME_ATTRIBUTE);
35 | } catch (final Exception e) {
36 | throw new RuntimeException(e);
37 | }
38 | }
39 |
40 | /**
41 | * @see org.mihalis.opal.systemMonitor.Sample#getValue()
42 | */
43 | @Override
44 | public double getValue() {
45 | try {
46 | return ((Integer) this.mBeanServerConnection.getAttribute(this.objectName, THREAD_COUNT)).intValue();
47 | } catch (final Exception e) {
48 | throw new RuntimeException(e);
49 | }
50 | }
51 |
52 | /**
53 | * @see org.mihalis.opal.systemMonitor.Sample#getMaxValue()
54 | */
55 | @Override
56 | public double getMaxValue() {
57 | try {
58 | return ((Integer) this.mBeanServerConnection.getAttribute(this.objectName, PEAK_THREAD_COUNT)).intValue();
59 | } catch (final Exception e) {
60 | throw new RuntimeException(e);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/textAssist/TextAssistContentProvider.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.textAssist;
12 |
13 | import java.util.List;
14 |
15 | /**
16 | * This class is a content provider for the TextAssist widget. When the user
17 | * types something, an instance returns an arraylist of proposition based on the
18 | * typed text.
19 | */
20 | public abstract class TextAssistContentProvider {
21 | private TextAssist textAssist;
22 |
23 | /**
24 | * Provides the content
25 | *
26 | * @param entry text typed by the user
27 | * @return an array list of String that contains propositions for the entry
28 | * typed by the user
29 | */
30 | public abstract List getContent(final String entry);
31 |
32 | /**
33 | * @param textAssist the textAssist to set
34 | */
35 | protected void setTextAssist(final TextAssist textAssist) {
36 | this.textAssist = textAssist;
37 | }
38 |
39 | /**
40 | * @return the max number of propositions.
41 | */
42 | protected int getMaxNumberOfLines() {
43 | return this.textAssist.getNumberOfLines();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/transitionComposite/DownUpAppearTransition.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.transitionComposite;
12 |
13 | /**
14 | * In this transition, the second control is behind, the first control is
15 | * sliding from down to up
16 | */
17 | public class DownUpAppearTransition extends VerticalTransition {
18 |
19 | /**
20 | * @see org.mihalis.opal.transitionComposite.VerticalTransition#getCoeff()
21 | */
22 | @Override
23 | protected int getCoeff() {
24 | return -1;
25 | }
26 |
27 | /**
28 | * @see org.mihalis.opal.transitionComposite.VerticalTransition#secondIsBehind()
29 | */
30 | @Override
31 | protected boolean secondIsBehind() {
32 | return false;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/transitionComposite/DownUpTransition.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.transitionComposite;
12 |
13 | /**
14 | * In this transition, both control are sliding (vertical movement, down to up)
15 | */
16 | public class DownUpTransition extends VerticalTransition {
17 |
18 | /**
19 | * @see org.mihalis.opal.transitionComposite.VerticalTransition#getCoeff()
20 | */
21 | @Override
22 | protected int getCoeff() {
23 | return -1;
24 | }
25 |
26 | /**
27 | * @see org.mihalis.opal.transitionComposite.VerticalTransition#secondIsBehind()
28 | */
29 | @Override
30 | protected boolean secondIsBehind() {
31 | return true;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/transitionComposite/LeftRightAppearTransition.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.transitionComposite;
12 |
13 | /**
14 | * In this transition, the second control is behind, the first control is
15 | * sliding from left to right
16 | */
17 | public class LeftRightAppearTransition extends HorizontalTransition {
18 |
19 | /**
20 | * @see org.mihalis.opal.transitionComposite.HorizontalTransition#getCoeff()
21 | */
22 | @Override
23 | protected int getCoeff() {
24 | return 1;
25 | }
26 |
27 | /**
28 | * @see org.mihalis.opal.transitionComposite.HorizontalTransition#secondIsBehind()
29 | */
30 | @Override
31 | protected boolean secondIsBehind() {
32 | return false;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/transitionComposite/LeftRightTransition.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.transitionComposite;
12 |
13 | /**
14 | * In this transition, both control are sliding (vertical movement, left to
15 | * right)
16 | */
17 | public class LeftRightTransition extends HorizontalTransition {
18 |
19 | /**
20 | * @see org.mihalis.opal.transitionComposite.HorizontalTransition#getCoeff()
21 | */
22 | @Override
23 | protected int getCoeff() {
24 | return 1;
25 | }
26 |
27 | /**
28 | * @see org.mihalis.opal.transitionComposite.HorizontalTransition#secondIsBehind()
29 | */
30 | @Override
31 | protected boolean secondIsBehind() {
32 | return true;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/transitionComposite/NoTransition.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.transitionComposite;
12 |
13 | import org.eclipse.swt.widgets.Control;
14 |
15 | /**
16 | * This transition is simple, because there is no effect :)
17 | *
18 | */
19 | class NoTransition implements Transition {
20 |
21 | /**
22 | * @see org.mihalis.opal.transitionComposite.Transition#performTransition(org.eclipse.swt.widgets.Control,
23 | * org.eclipse.swt.widgets.Control)
24 | */
25 | @Override
26 | public void performTransition(final Control first, final Control second) {
27 | first.setVisible(false);
28 | second.setVisible(true);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/transitionComposite/RightLeftAppearTransition.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.transitionComposite;
12 |
13 | /**
14 | * In this transition, the second control is behind, the first control is
15 | * sliding from right to left
16 | */
17 | public class RightLeftAppearTransition extends HorizontalTransition {
18 |
19 | /**
20 | * @see org.mihalis.opal.transitionComposite.HorizontalTransition#getCoeff()
21 | */
22 | @Override
23 | protected int getCoeff() {
24 | return -1;
25 | }
26 |
27 | /**
28 | * @see org.mihalis.opal.transitionComposite.HorizontalTransition#secondIsBehind()
29 | */
30 | @Override
31 | protected boolean secondIsBehind() {
32 | return false;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/transitionComposite/RightLeftTransition.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.transitionComposite;
12 |
13 | /**
14 | * In this transition, both control are sliding (vertical movement, right to
15 | * left)
16 | */
17 | public class RightLeftTransition extends HorizontalTransition {
18 |
19 | /**
20 | * @see org.mihalis.opal.transitionComposite.HorizontalTransition#getCoeff()
21 | */
22 | @Override
23 | protected int getCoeff() {
24 | return -1;
25 | }
26 |
27 | /**
28 | * @see org.mihalis.opal.transitionComposite.HorizontalTransition#secondIsBehind()
29 | */
30 | @Override
31 | protected boolean secondIsBehind() {
32 | return true;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/transitionComposite/TRANSITIONS.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.transitionComposite;
12 |
13 | /**
14 | * This enumeration is a list of transitions
15 | */
16 | public enum TRANSITIONS {
17 | LEFT_TO_RIGHT, LEFT_TO_RIGHT_AND_APPEAR, RIGHT_TO_LEFT, RIGHT_TO_LEFT_AND_APPEAR, UP_TO_DOWN, UP_TO_DOWN_AND_APPEAR, DOWN_TO_UP, DOWN_TO_UP_AND_APPEAR, NONE
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/transitionComposite/Transition.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.transitionComposite;
12 |
13 | import org.eclipse.swt.widgets.Control;
14 |
15 | /**
16 | * This interface describes a transition
17 | */
18 | interface Transition {
19 |
20 | /**
21 | * Performs a transition between 2 controls of a TransitionComposite
22 | *
23 | * @param first first control
24 | * @param second second control
25 | */
26 | void performTransition(Control first, Control second);
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/transitionComposite/TransitionFactory.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.transitionComposite;
12 |
13 | /**
14 | * This class is a transition factory
15 | */
16 | public class TransitionFactory {
17 |
18 | /**
19 | * @param transition transition to get
20 | * @return a transition corresponding to the transition
21 | * parameter
22 | */
23 | public static Transition getTransitionFor(final TRANSITIONS transition) {
24 | switch (transition) {
25 | case DOWN_TO_UP:
26 | return new DownUpTransition();
27 | case DOWN_TO_UP_AND_APPEAR:
28 | return new DownUpAppearTransition();
29 | case LEFT_TO_RIGHT:
30 | return new LeftRightTransition();
31 | case LEFT_TO_RIGHT_AND_APPEAR:
32 | return new LeftRightAppearTransition();
33 | case NONE:
34 | return new NoTransition();
35 | case RIGHT_TO_LEFT:
36 | return new RightLeftTransition();
37 | case RIGHT_TO_LEFT_AND_APPEAR:
38 | return new RightLeftAppearTransition();
39 | case UP_TO_DOWN:
40 | return new UpDownTransition();
41 | case UP_TO_DOWN_AND_APPEAR:
42 | return new UpDownAppearTransition();
43 | }
44 | return null;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/transitionComposite/UpDownAppearTransition.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.transitionComposite;
12 |
13 | /**
14 | * In this transition, the second control is behind, the first control is
15 | * sliding from up to down
16 | */
17 | public class UpDownAppearTransition extends VerticalTransition {
18 |
19 | /**
20 | * @see org.mihalis.opal.transitionComposite.VerticalTransition#getCoeff()
21 | */
22 | @Override
23 | protected int getCoeff() {
24 | return 1;
25 | }
26 |
27 | /**
28 | * @see org.mihalis.opal.transitionComposite.VerticalTransition#secondIsBehind()
29 | */
30 | @Override
31 | protected boolean secondIsBehind() {
32 | return false;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/transitionComposite/UpDownTransition.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.transitionComposite;
12 |
13 | /**
14 | * In this transition, both control are sliding (vertical movement, up to down)
15 | */
16 | public class UpDownTransition extends VerticalTransition {
17 |
18 | @Override
19 | protected int getCoeff() {
20 | return 1;
21 | }
22 |
23 | @Override
24 | protected boolean secondIsBehind() {
25 | return true;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/utils/FileToolbox.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.utils;
12 |
13 | import java.io.FileInputStream;
14 | import java.io.FileNotFoundException;
15 | import java.io.IOException;
16 | import java.io.InputStream;
17 | import java.net.MalformedURLException;
18 | import java.net.URL;
19 |
20 | public class FileToolbox {
21 |
22 | /**
23 | * Loads a file into a stream
24 | *
25 | * @param fileName file name
26 | * @return a stream composed of this file
27 | */
28 | public static InputStream getInputStream(final String fileName) {
29 | if (fileName.startsWith("jar:")) {
30 | URL url;
31 | try {
32 | url = new URL(fileName);
33 | return url.openStream();
34 | } catch (final MalformedURLException e) {
35 | throw new RuntimeException(e);
36 | } catch (final IOException e) {
37 | throw new RuntimeException(e);
38 | }
39 | } else {
40 | try {
41 | return new FileInputStream(fileName);
42 | } catch (final FileNotFoundException e) {
43 | throw new RuntimeException(e);
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/mihalis/opal/utils/SimpleSelectionAdapter.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 |
12 | package org.mihalis.opal.utils;
13 |
14 | import org.eclipse.swt.events.SelectionEvent;
15 | import org.eclipse.swt.events.SelectionListener;
16 |
17 | /**
18 | * This class is an adapter for the SelectionListener. Both behaviours (DefaultSelected and Selected) are doing the same thing
19 | */
20 | public abstract class SimpleSelectionAdapter implements SelectionListener {
21 |
22 | /**
23 | * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
24 | */
25 | @Override
26 | public void widgetDefaultSelected(final SelectionEvent e) {
27 | this.handle(e);
28 |
29 | }
30 |
31 | /**
32 | * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
33 | */
34 | @Override
35 | public void widgetSelected(final SelectionEvent e) {
36 | this.handle(e);
37 |
38 | }
39 |
40 | /**
41 | * Sent when selection occurs in the control.
42 | *
43 | * @param e - an event containing information about the selection
44 | */
45 | public abstract void handle(SelectionEvent e);
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/resources/images/angleBackground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/angleBackground.png
--------------------------------------------------------------------------------
/src/main/resources/images/angleButtonFocus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/angleButtonFocus.png
--------------------------------------------------------------------------------
/src/main/resources/images/angleButtonFocusLost.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/angleButtonFocusLost.png
--------------------------------------------------------------------------------
/src/main/resources/images/arrowGreenRight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/arrowGreenRight.png
--------------------------------------------------------------------------------
/src/main/resources/images/arrow_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/arrow_down.png
--------------------------------------------------------------------------------
/src/main/resources/images/arrow_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/arrow_left.png
--------------------------------------------------------------------------------
/src/main/resources/images/arrow_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/arrow_right.png
--------------------------------------------------------------------------------
/src/main/resources/images/arrow_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/arrow_up.png
--------------------------------------------------------------------------------
/src/main/resources/images/category.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/category.png
--------------------------------------------------------------------------------
/src/main/resources/images/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/close.png
--------------------------------------------------------------------------------
/src/main/resources/images/columnArrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/columnArrow.png
--------------------------------------------------------------------------------
/src/main/resources/images/description.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/description.png
--------------------------------------------------------------------------------
/src/main/resources/images/double_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/double_down.png
--------------------------------------------------------------------------------
/src/main/resources/images/double_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/double_left.png
--------------------------------------------------------------------------------
/src/main/resources/images/double_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/double_right.png
--------------------------------------------------------------------------------
/src/main/resources/images/double_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/double_up.png
--------------------------------------------------------------------------------
/src/main/resources/images/fewerDetails.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/fewerDetails.png
--------------------------------------------------------------------------------
/src/main/resources/images/h-slider-drag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/h-slider-drag.png
--------------------------------------------------------------------------------
/src/main/resources/images/h-slider-hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/h-slider-hover.png
--------------------------------------------------------------------------------
/src/main/resources/images/h-slider-normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/h-slider-normal.png
--------------------------------------------------------------------------------
/src/main/resources/images/h-slider-selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/h-slider-selected.png
--------------------------------------------------------------------------------
/src/main/resources/images/information.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/information.png
--------------------------------------------------------------------------------
/src/main/resources/images/light1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/light1.png
--------------------------------------------------------------------------------
/src/main/resources/images/light2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/light2.png
--------------------------------------------------------------------------------
/src/main/resources/images/moreDetails.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/moreDetails.png
--------------------------------------------------------------------------------
/src/main/resources/images/slider-drag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/slider-drag.png
--------------------------------------------------------------------------------
/src/main/resources/images/slider-hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/slider-hover.png
--------------------------------------------------------------------------------
/src/main/resources/images/slider-normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/slider-normal.png
--------------------------------------------------------------------------------
/src/main/resources/images/slider-selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/slider-selected.png
--------------------------------------------------------------------------------
/src/main/resources/images/sort.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/sort.png
--------------------------------------------------------------------------------
/src/main/resources/images/stars/16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/stars/16.png
--------------------------------------------------------------------------------
/src/main/resources/images/stars/32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/stars/32.png
--------------------------------------------------------------------------------
/src/main/resources/images/stars/focus16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/stars/focus16.png
--------------------------------------------------------------------------------
/src/main/resources/images/stars/focus32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/stars/focus32.png
--------------------------------------------------------------------------------
/src/main/resources/images/stars/mark-focus16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/stars/mark-focus16.png
--------------------------------------------------------------------------------
/src/main/resources/images/stars/mark-focus32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/stars/mark-focus32.png
--------------------------------------------------------------------------------
/src/main/resources/images/stars/mark16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/stars/mark16.png
--------------------------------------------------------------------------------
/src/main/resources/images/stars/mark32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/stars/mark32.png
--------------------------------------------------------------------------------
/src/main/resources/images/trash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/images/trash.png
--------------------------------------------------------------------------------
/src/main/resources/resources/opal.properties:
--------------------------------------------------------------------------------
1 | Ok=OK
2 | Cancel=Cancel
3 | Close=Close
4 | Yes=Yes
5 | No=No
6 | MoreDetails=More Details
7 | FewerDetails=Fewer Details
8 | Details=Details
9 | Information=Information
10 | Error=Error
11 | Question=Question
12 | Warning=Warning
13 | Exception=Exception
14 | Choice=Choice
15 | Select=Select
16 | Input=Input
17 | ApplicationError=Application Error
18 | megabytes=Mb
19 | performGC=Perform GC
20 | login=Login
21 | name=Name
22 | password=Password
23 | rememberPassword=Remember password
24 | loginFailed=Login failed
25 | tipOfTheDay=Tip of the day
26 | didYouKnow=Did you know...
27 | showTipAtStartup=Show Tip at startup
28 | previousTip=< Previous Tip
29 | nextTip=Next Tip >
30 | choose=Choose
31 | preferences=Preferences
32 | validURL=Please enter a valid URL
33 | chooseDirectory=Please choose a directory
34 | bold=bold
35 | italic=italic
36 | category.shortDescription = Toggle between Category view and Flat list view
37 | description.shortDescription = Show/Hide the Description pane
38 | sort.shortDescription = Sort Properties and Categories by Name
39 | property=Property
40 | value=Value
41 | editProperty=Edit property
42 | width=Width
43 | height=Height
44 | top=Top
45 | bottom=Bottom
46 | left=Left
47 | right=Right
48 | eraseProperty=Erase the value of the property
49 | physicalMemory=Physical Memory
50 | heapMemory=Heap Memory
51 | threads=Threads
52 | cpuUsage=CPU Usage
53 | peak=Peak
54 | mb=MB
55 | calculator.dividebyzero=Cannot divide by zero !
56 | calculator.invalid=Invalid input for function !
57 | multichoice.message=The entry %s is invalid, please check it!
58 | multichoice.message.plural=The entries %s are invalid, please check it!
--------------------------------------------------------------------------------
/src/main/resources/resources/opal_de_DE.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/resources/opal_de_DE.properties
--------------------------------------------------------------------------------
/src/main/resources/resources/opal_es_ES.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/resources/opal_es_ES.properties
--------------------------------------------------------------------------------
/src/main/resources/resources/opal_fr_FR.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/resources/opal_fr_FR.properties
--------------------------------------------------------------------------------
/src/main/resources/resources/opal_it_IT.properties:
--------------------------------------------------------------------------------
1 | OK=OK
2 | Cancel=Annulla
3 | Close=Chiudi
4 | Yes=Si
5 | No=No
6 | MoreDetails=Pi\u00F9 Dettagli
7 | FewerDetails=Meno Dettagli
8 | Details=Dettagli
9 | Information=Informazione
10 | Error=Errore
11 | Question=Domanda
12 | Warning=Avvertenza
13 | Exception=Eccezione
14 | Choice=Scelta
15 | Select=Seleziona
16 | Input=Input
17 | ApplicationError=Errore di applicazione
18 | megabytes=Mb
19 | performGC=Perform GC
20 | login=Accesso
21 | name=Nome
22 | password=Password
23 | rememberPassword=Remember password
24 | loginFailed=Login failed
25 | tipOfTheDay=Tip of the day
26 | didYouKnow=Did you know...
27 | showTipAtStartup=Show Tip at startup
28 | previousTip=< Previous Tip
29 | nextTip=Next Tip >
30 | choose=Choose
31 | preferences=Preferences
32 | validURL=Please enter a valid URL
33 | chooseDirectory=Please choose a directory
34 | bold=bold
35 | italic=italic
36 | category.shortDescription = Toggle between Category view and Flat list view
37 | description.shortDescription = Show/Hide the Description pane
38 | sort.shortDescription = Sort Properties and Categories by Name
39 | property=Property
40 | value=Value
41 | editProperty=Edit property
42 | width=Width
43 | height=Height
44 | top=Top
45 | bottom=Bottom
46 | left=Left
47 | right=Right
48 | eraseProperty=Erase the value of the property
49 | physicalMemory=Physical Memory
50 | heapMemory=Heap Memory
51 | threads=Threads
52 | cpuUsage=CPU Usage
53 | peak=Peak
54 | mb=MB
55 | calculator.dividebyzero=Cannot divide by zero !
56 | calculator.invalid=Invalid input for function !
57 | multichoice.message=The entry %s is invalid, please check it!
58 | multichoice.message.plural=The entries %s are invalid, please check it!
--------------------------------------------------------------------------------
/src/main/resources/resources/opal_nl_NL.properties:
--------------------------------------------------------------------------------
1 | Ok=OK
2 | Cancel=Annuleren
3 | Close=Sluiten
4 | Yes=Ja
5 | No=Nee
6 | MoreDetails=Meer info
7 | FewerDetails=Minder info
8 | Details=Info
9 | Information=Informatie
10 | Error=Fout
11 | Question=Vraag
12 | Warning=Waarschuwing
13 | Exception=Exception
14 | Choice=Kies
15 | Select=Kies
16 | Input=Invoer
17 | ApplicationError=Fout in toepassing
18 | megabytes=Mb
19 | performGC=Voer GC uit
20 | login=Login
21 | name=Naam
22 | password=Wachtwoord
23 | rememberPassword=Wachtwoord onthouden
24 | loginFailed=Inloggen mislukt
25 | tipOfTheDay=Tip van de dag
26 | didYouKnow=Wisu u dat...
27 | showTipAtStartup=Tips weergeven bij opstarten
28 | previousTip=< Vorige Tip
29 | nextTip=Volgende Tip >
30 | choose=Kies
31 | preferences=Voorkeuren
32 | validURL=Geef een geldige URL op
33 | chooseDirectory=Kies een map
34 | bold=vet
35 | italic=cursief
36 | category.shortDescription = Wissel tussen weergave per category en lijst weergave
37 | description.shortDescription = Toon/Verberg omschrijving
38 | sort.shortDescription = Sorteer eigenschappen en categorie\u00ebn op naam
39 | property=Eigenschap
40 | value=Waarde
41 | editProperty=Bewerk eigenschap
42 | width=Breedte
43 | height=Hoogte
44 | top=Bovenkant
45 | bottom=Onderkant
46 | left=Links
47 | right=Rechts
48 | eraseProperty=Wis de waarde van de eigenschap
49 | physicalMemory=Physical Memory
50 | heapMemory=Heap Memory
51 | threads=Threads
52 | cpuUsage=CPU Usage
53 | peak=Peak
54 | mb=MB
55 | calculator.dividebyzero=Cannot divide by zero !
56 | calculator.invalid=Invalid input for function !
57 | multichoice.message=The entry %s is invalid, please check it!
58 | multichoice.message.plural=The entries %s are invalid, please check it!
--------------------------------------------------------------------------------
/src/main/resources/resources/opal_pl_PL.properties:
--------------------------------------------------------------------------------
1 | Ok=OK
2 | Cancel=Anuluj
3 | Close=Zamknij
4 | Yes=Tak
5 | No=Nie
6 | MoreDetails=Więcej szczegółów
7 | FewerDetails=Mniej szczegółów
8 | Details=Szczegóły
9 | Information=Informacja
10 | Error=Błąd
11 | Question=Pytanie
12 | Warning=Ostrzeżenie
13 | Exception=Wyjątek
14 | Choice=Wybór
15 | Select=Wybór
16 | Input=Wprowadzanie
17 | ApplicationError=Błąd aplikacji
18 | megabytes=Mb
19 | performGC=Wykonaj GC
20 | login=Login
21 | name=Nazwa
22 | password=Hasło
23 | rememberPassword=Zapamiętaj hasło
24 | loginFailed=Logowanie nie powiodło się
25 | tipOfTheDay=Porada dnia
26 | didYouKnow=Czy wiesz, że...
27 | showTipAtStartup=Wyświetl Poradę dnia przy starcie
28 | previousTip=< Poprzednia Porada
29 | nextTip=Następna Porada >
30 | choose=Wybierz
31 | preferences=Preferencje
32 | validURL=Wpisz poprawny adres URL
33 | chooseDirectory=Proszę wybrać katalog
34 | bold=pogrubienie
35 | italic=kursywa
36 | category.shortDescription = Przełącz pomiędzy widokiem kategorii a widokiem płaskiej listy
37 | description.shortDescription = Pokaż/Ukryj panel Opisu
38 | sort.shortDescription = Sortuj Właściwości i Kategorie po Nazwie
39 | property=Właściwość
40 | value=Wartość
41 | editProperty=Edytuj właściwość
42 | width=Szerokość
43 | height=Wysokość
44 | top=Góra
45 | bottom=Dół
46 | left=Lewo
47 | right=Prawo
48 | eraseProperty=Wymaż wartość właściwości
49 | physicalMemory=Pamięć Fizyczna
50 | heapMemory=Sterta Pamięci
51 | threads=Wątki
52 | cpuUsage=Wykorzystanie CPU
53 | peak=Pik
54 | mb=MB
55 | calculator.dividebyzero=Nie można dzielić przez zero !
56 | calculator.invalid=Nieprawidłowe parametry funkcji !
57 | multichoice.message=The entry %s is invalid, please check it!
58 | multichoice.message.plural=The entries %s are invalid, please check it!
--------------------------------------------------------------------------------
/src/main/resources/resources/opal_pt_BR.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/main/resources/resources/opal_pt_BR.properties
--------------------------------------------------------------------------------
/src/main/resources/resources/opal_zh_CN.properties:
--------------------------------------------------------------------------------
1 | Ok=\u786e\u5b9a
2 | Cancel=\u653e\u5f03
3 | Close=\u5173\u95ed
4 | Yes=\u662f
5 | No=\u5426
6 | MoreDetails=\u8be6\u7ec6\u4fe1\u606f
7 | FewerDetails=\u7b80\u660e\u4fe1\u606f
8 | Details=\u4fe1\u606f
9 | Information=\u4fe1\u606f
10 | Error=\u9519\u8bef
11 | Question=\u95ee\u9898
12 | Warning=\u8b66\u544a
13 | Exception=\u5f02\u5e38
14 | Choice=\u9009\u9879
15 | Select=\u9009\u62e9
16 | Input=\u8f93\u5165
17 | ApplicationError=Application Error
18 | megabytes=Mb
19 | performGC=Perform GC
20 | login=Login
21 | name=Name
22 | password=Password
23 | rememberPassword=Remember password
24 | loginFailed=Login failed
25 | tipOfTheDay=Tip of the day
26 | didYouKnow=Did you know...
27 | showTipAtStartup=Show Tip at startup
28 | previousTip=< Previous Tip
29 | nextTip=Next Tip >
30 | choose=Choose
31 | preferences=Preferences
32 | validURL=Please enter a valid URL
33 | chooseDirectory=Please choose a directory
34 | bold=bold
35 | italic=italic
36 | category.shortDescription = Toggle between Category view and Flat list view
37 | description.shortDescription = Show/Hide the Description pane
38 | sort.shortDescription = Sort Properties and Categories by Name
39 | property=Property
40 | value=Value
41 | editProperty=Edit property
42 | width=Width
43 | height=Height
44 | top=Top
45 | bottom=Bottom
46 | left=Left
47 | right=Right
48 | eraseProperty=Erase the value of the property
49 | physicalMemory=Physical Memory
50 | heapMemory=Heap Memory
51 | threads=Threads
52 | cpuUsage=CPU Usage
53 | peak=Peak
54 | mb=MB
55 | calculator.dividebyzero=Cannot divide by zero !
56 | calculator.invalid=Invalid input for function !
57 | multichoice.message=The entry %s is invalid, please check it!
58 | multichoice.message.plural=The entries %s are invalid, please check it!
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/SystemMonitor/RandomSample.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.SystemMonitor;
12 |
13 | import java.util.Random;
14 |
15 | import org.mihalis.opal.systemMonitor.Sample;
16 |
17 | /**
18 | * A random sample
19 | */
20 | public class RandomSample implements Sample {
21 |
22 | @Override
23 | public double getValue() {
24 | return new Random().nextInt(100);
25 | }
26 |
27 | @Override
28 | public double getMaxValue() {
29 | return 99d;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/angles/AngleSliderSnippet.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.angles;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.events.SelectionEvent;
15 | import org.eclipse.swt.layout.GridData;
16 | import org.eclipse.swt.layout.GridLayout;
17 | import org.eclipse.swt.widgets.Button;
18 | import org.eclipse.swt.widgets.Display;
19 | import org.eclipse.swt.widgets.Label;
20 | import org.eclipse.swt.widgets.Shell;
21 | import org.eclipse.swt.widgets.Text;
22 | import org.mihalis.opal.utils.SimpleSelectionAdapter;
23 |
24 | /**
25 | * A simple snipper for the AngleSlider widget
26 | *
27 | */
28 | public class AngleSliderSnippet {
29 |
30 | public static void main(final String[] args) {
31 | final Display display = new Display();
32 | final Shell shell = new Shell(display);
33 | shell.setLayout(new GridLayout(2, false));
34 |
35 | final AngleSlider angleSlider = new AngleSlider(shell, SWT.NONE);
36 | angleSlider.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, false, false, 2, 1));
37 |
38 | final Button button = new Button(shell, SWT.CHECK);
39 | button.setText("Enabled");
40 | button.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));
41 | button.setSelection(true);
42 | button.addSelectionListener(new SimpleSelectionAdapter() {
43 |
44 | @Override
45 | public void handle(final SelectionEvent e) {
46 | angleSlider.setEnabled(button.getSelection());
47 | }
48 | });
49 |
50 | final Label label = new Label(shell, SWT.NONE);
51 | label.setText("Value :");
52 | label.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
53 |
54 | final Text text = new Text(shell, SWT.READ_ONLY | SWT.BORDER);
55 | text.setText("" + angleSlider.getSelection());
56 | text.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
57 | angleSlider.addSelectionListener(new SimpleSelectionAdapter() {
58 |
59 | @Override
60 | public void handle(final SelectionEvent e) {
61 | text.setText("" + angleSlider.getSelection());
62 |
63 | }
64 | });
65 |
66 | shell.pack();
67 | shell.open();
68 |
69 | while (!shell.isDisposed()) {
70 | if (!display.readAndDispatch()) {
71 | display.sleep();
72 | }
73 | }
74 | display.dispose();
75 |
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/breadcrumb/add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/breadcrumb/add.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/breadcrumb/bell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/breadcrumb/bell.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/breadcrumb/feed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/breadcrumb/feed.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/breadcrumb/house.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/breadcrumb/house.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/breadcrumb/script.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/breadcrumb/script.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/brushedMetalComposite/SnippetBrushedMetalComposite.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.brushedMetalComposite;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.layout.FillLayout;
15 | import org.eclipse.swt.layout.RowLayout;
16 | import org.eclipse.swt.widgets.Button;
17 | import org.eclipse.swt.widgets.Display;
18 | import org.eclipse.swt.widgets.Shell;
19 |
20 | /**
21 | * This snippet demonstrates the brushed metal composite
22 | *
23 | */
24 | public class SnippetBrushedMetalComposite {
25 | public static void main(final String[] args) {
26 | final Display display = new Display();
27 | final Shell shell = new Shell(display);
28 | shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
29 | final FillLayout layout1 = new FillLayout(SWT.VERTICAL);
30 | layout1.marginWidth = layout1.marginHeight = 10;
31 | shell.setLayout(layout1);
32 |
33 | // Displays the composite
34 | final BrushedMetalComposite bmc = new BrushedMetalComposite(shell, SWT.NONE);
35 |
36 | // And the content
37 | final RowLayout layout2 = new RowLayout(SWT.VERTICAL);
38 | layout2.marginWidth = layout2.marginHeight = layout2.spacing = 10;
39 | bmc.setLayout(layout2);
40 | for (int i = 0; i < 8; i++) {
41 | final Button button = new Button(bmc, SWT.RADIO);
42 | button.setText("Button " + i);
43 | }
44 |
45 | // Open the shell
46 | shell.setSize(400, 400);
47 | shell.open();
48 | while (!shell.isDisposed()) {
49 | if (!display.readAndDispatch()) {
50 | display.sleep();
51 | }
52 | }
53 | display.dispose();
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/calculator/CalculatorComboSnippet.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.calculator;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.events.ModifyEvent;
15 | import org.eclipse.swt.events.ModifyListener;
16 | import org.eclipse.swt.layout.GridData;
17 | import org.eclipse.swt.layout.GridLayout;
18 | import org.eclipse.swt.widgets.Display;
19 | import org.eclipse.swt.widgets.Label;
20 | import org.eclipse.swt.widgets.Shell;
21 |
22 | /**
23 | * A simple snippet for the CalculatorCombo Widget
24 | */
25 | public class CalculatorComboSnippet {
26 | public static void main(final String[] args) {
27 | final Display display = new Display();
28 | final Shell shell = new Shell(display);
29 | shell.setLayout(new GridLayout(2, false));
30 |
31 | final Label label = new Label(shell, SWT.NONE);
32 | label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
33 | label.setText("Calculator combo:");
34 |
35 | final CalculatorCombo combo = new CalculatorCombo(shell, SWT.NONE);
36 | combo.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false));
37 |
38 | combo.addModifyListener(new ModifyListener() {
39 |
40 | @Override
41 | public void modifyText(final ModifyEvent e) {
42 | System.out.println("New value is " + combo.getValue());
43 |
44 | }
45 | });
46 |
47 | shell.pack();
48 | shell.open();
49 |
50 | while (!shell.isDisposed()) {
51 | if (!display.readAndDispatch()) {
52 | display.sleep();
53 | }
54 | }
55 | display.dispose();
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/calculator/CalculatorSnippet.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2012 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.calculator;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.events.ModifyEvent;
15 | import org.eclipse.swt.events.ModifyListener;
16 | import org.eclipse.swt.layout.FillLayout;
17 | import org.eclipse.swt.widgets.Display;
18 | import org.eclipse.swt.widgets.Shell;
19 |
20 | /**
21 | * A simple snippet for the Calculator Widget
22 | */
23 | public class CalculatorSnippet {
24 | public static void main(final String[] args) {
25 | final Display display = new Display();
26 | final Shell shell = new Shell(display);
27 | shell.setLayout(new FillLayout(SWT.VERTICAL));
28 |
29 | final Calculator calc = new Calculator(shell, SWT.NONE);
30 |
31 | calc.addModifyListener(new ModifyListener() {
32 |
33 | @Override
34 | public void modifyText(final ModifyEvent e) {
35 | System.out.println("New value is " + calc.getValue());
36 |
37 | }
38 | });
39 |
40 | shell.pack();
41 | shell.open();
42 |
43 | while (!shell.isDisposed()) {
44 | if (!display.readAndDispatch()) {
45 | display.sleep();
46 | }
47 | }
48 | display.dispose();
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/gradientComposite/SnippetGradientComposite.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.gradientComposite;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.layout.FillLayout;
15 | import org.eclipse.swt.layout.RowLayout;
16 | import org.eclipse.swt.widgets.Button;
17 | import org.eclipse.swt.widgets.Display;
18 | import org.eclipse.swt.widgets.Shell;
19 |
20 | /**
21 | * This snippet demonstrates the gradient composite
22 | *
23 | */
24 | public class SnippetGradientComposite {
25 | public static void main(final String[] args) {
26 | final Display display = new Display();
27 | final Shell shell = new Shell(display);
28 | shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
29 | final FillLayout layout1 = new FillLayout(SWT.VERTICAL);
30 | layout1.marginWidth = layout1.marginHeight = 10;
31 | shell.setLayout(layout1);
32 |
33 | // Displays the composite
34 | final GradientComposite composite = new GradientComposite(shell, SWT.NONE);
35 | composite.setGradientEnd(display.getSystemColor(SWT.COLOR_WHITE));
36 | composite.setGradientStart(display.getSystemColor(SWT.COLOR_DARK_RED));
37 |
38 | // And the content
39 | final RowLayout layout2 = new RowLayout(SWT.VERTICAL);
40 | layout2.marginWidth = layout2.marginHeight = layout2.spacing = 10;
41 | composite.setLayout(layout2);
42 | for (int i = 0; i < 8; i++) {
43 | final Button button = new Button(composite, SWT.RADIO);
44 | button.setForeground(display.getSystemColor(SWT.COLOR_RED));
45 | button.setText("Button " + i);
46 | }
47 |
48 | // Open the shell
49 | shell.setSize(640, 360);
50 | shell.open();
51 | while (!shell.isDisposed()) {
52 | if (!display.readAndDispatch()) {
53 | display.sleep();
54 | }
55 | }
56 | display.dispose();
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/header/HeaderSnippet.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - initial API and implementation
10 | *******************************************************************************/
11 | package org.mihalis.opal.header;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.graphics.Image;
15 | import org.eclipse.swt.layout.GridData;
16 | import org.eclipse.swt.layout.GridLayout;
17 | import org.eclipse.swt.widgets.Display;
18 | import org.eclipse.swt.widgets.Label;
19 | import org.eclipse.swt.widgets.Shell;
20 | import org.eclipse.swt.widgets.Text;
21 | import org.mihalis.opal.utils.SWTGraphicUtil;
22 |
23 | /**
24 | * This snippet demonstrates the Header widget
25 | *
26 | */
27 | public class HeaderSnippet {
28 |
29 | /**
30 | * @param args
31 | */
32 | public static void main(final String[] args) {
33 | final Display display = new Display();
34 | final Shell shell = new Shell(display);
35 | shell.setLayout(new GridLayout(1, false));
36 |
37 | final Image icon = new Image(display, HeaderSnippet.class.getClassLoader().getResourceAsStream("org/mihalis/opal/header/configure.png"));
38 |
39 | shell.setText("Header Snippet");
40 | shell.setLayout(new GridLayout(2, false));
41 |
42 | final Header header = new Header(shell, SWT.NONE);
43 | header.setTitle("Header title");
44 | header.setImage(icon);
45 | header.setDescription("Description area for the header. You can put all additional, relevant information to the description panel (or jokes, citations, ... what you want !)");
46 | header.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
47 |
48 | createRow(shell, "First Name");
49 | createRow(shell, "Last Name");
50 | createRow(shell, "E-mail");
51 | createRow(shell, "Phone number");
52 |
53 | shell.setSize(640, 350);
54 | SWTGraphicUtil.centerShell(shell);
55 | shell.open();
56 |
57 | while (!shell.isDisposed()) {
58 | if (!display.readAndDispatch()) {
59 | display.sleep();
60 | }
61 | }
62 |
63 | icon.dispose();
64 | display.dispose();
65 | }
66 |
67 | private static void createRow(final Shell shell, final String label) {
68 | final Label lbl = new Label(shell, SWT.NONE);
69 | lbl.setText(label);
70 | lbl.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
71 |
72 | final Text text = new Text(shell, SWT.SINGLE | SWT.BORDER);
73 | text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/header/configure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/header/configure.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/heapManager/HeapManagerSnippet.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com)
10 | *******************************************************************************/
11 | package org.mihalis.opal.heapManager;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.layout.FillLayout;
15 | import org.eclipse.swt.widgets.Display;
16 | import org.eclipse.swt.widgets.Shell;
17 |
18 | /**
19 | * A simple snippet for the TextAssist Widget
20 | */
21 | public class HeapManagerSnippet {
22 | public static void main(final String[] args) {
23 | final Display display = new Display();
24 | final Shell shell = new Shell(display);
25 | shell.setLayout(new FillLayout());
26 |
27 | new HeapManager(shell, SWT.NONE);
28 |
29 | final int[] counter = new int[1];
30 | counter[0] = 1;
31 |
32 | display.timerExec(10, new Runnable() {
33 |
34 | @Override
35 | public void run() {
36 | for (int i = 0; i < 10000; i++) {
37 | @SuppressWarnings("unused")
38 | final String[] temp = new String[1000];
39 | }
40 | counter[0]++;
41 | if (counter[0] < 100) {
42 | display.timerExec(10, this);
43 | }
44 | }
45 | });
46 |
47 | shell.pack();
48 | shell.open();
49 |
50 | while (!shell.isDisposed()) {
51 | if (!display.readAndDispatch()) {
52 | display.sleep();
53 | }
54 | }
55 | display.dispose();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/imageSelector/ImageSelectorSnippet.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.imageSelector;
12 |
13 | import java.util.LinkedList;
14 | import java.util.List;
15 |
16 | import org.eclipse.swt.SWT;
17 | import org.eclipse.swt.layout.FillLayout;
18 | import org.eclipse.swt.widgets.Display;
19 | import org.eclipse.swt.widgets.Shell;
20 |
21 | /**
22 | * A simple snipper for the Image Selector widget
23 | *
24 | */
25 | public class ImageSelectorSnippet {
26 | public static void main(final String[] args) {
27 | final Display display = new Display();
28 | final Shell shell = new Shell(display);
29 | shell.setLayout(new FillLayout());
30 |
31 | // Create the list of images
32 | final List items = new LinkedList();
33 | items.add(new ISItem("Black Eyed Peas", "org/mihalis/opal/imageSelector/images/Black Eyed Peas.jpg"));
34 | items.add(new ISItem("Coldplay", "org/mihalis/opal/imageSelector/images/Coldplay.jpg"));
35 | items.add(new ISItem("Foo Fighters", "org/mihalis/opal/imageSelector/images/Foo Fighters.jpg"));
36 | items.add(new ISItem("Gorillaz", "org/mihalis/opal/imageSelector/images/Gorillaz.jpg"));
37 | items.add(new ISItem("Green Day", "org/mihalis/opal/imageSelector/images/Green Day.jpg"));
38 | items.add(new ISItem("Moby", "org/mihalis/opal/imageSelector/images/Moby.jpg"));
39 | items.add(new ISItem("Norah Jones", "org/mihalis/opal/imageSelector/images/Norah Jones.jpg"));
40 | items.add(new ISItem("Shivaree", "org/mihalis/opal/imageSelector/images/Shivaree.jpg"));
41 | items.add(new ISItem("Sin City", "org/mihalis/opal/imageSelector/images/Sin City.jpg"));
42 |
43 | final ImageSelector imageSelector = new ImageSelector(shell, SWT.NONE);
44 | imageSelector.setItems(items);
45 |
46 | // Open the shell
47 | shell.setSize(640, 360);
48 | shell.open();
49 | while (!shell.isDisposed()) {
50 | if (!display.readAndDispatch()) {
51 | display.sleep();
52 | }
53 | }
54 | display.dispose();
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/imageSelector/images/Black Eyed Peas.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/imageSelector/images/Black Eyed Peas.jpg
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/imageSelector/images/Coldplay.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/imageSelector/images/Coldplay.jpg
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/imageSelector/images/Foo Fighters.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/imageSelector/images/Foo Fighters.jpg
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/imageSelector/images/Gorillaz.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/imageSelector/images/Gorillaz.jpg
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/imageSelector/images/Green Day.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/imageSelector/images/Green Day.jpg
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/imageSelector/images/Moby.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/imageSelector/images/Moby.jpg
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/imageSelector/images/Norah Jones.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/imageSelector/images/Norah Jones.jpg
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/imageSelector/images/Shivaree.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/imageSelector/images/Shivaree.jpg
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/imageSelector/images/Sin City.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/imageSelector/images/Sin City.jpg
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/austria.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/austria.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/belgium.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/belgium.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/bulgaria.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/bulgaria.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/cyprus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/cyprus.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/czech.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/czech.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/denmark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/denmark.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/estonia.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/estonia.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/finland.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/finland.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/france.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/france.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/germany.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/germany.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/greece.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/greece.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/hungary.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/hungary.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/ireland.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/ireland.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/italy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/italy.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/latvia.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/latvia.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/lithuania.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/lithuania.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/luxembourg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/luxembourg.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/malta.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/malta.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/netherlands.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/netherlands.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/poland.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/poland.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/portugal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/portugal.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/romania.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/romania.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/slovakia.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/slovakia.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/slovenia.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/slovenia.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/spain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/spain.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/sweden.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/sweden.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/itemSelector/flags/unitedkingdom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/itemSelector/flags/unitedkingdom.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/launcher/LauncherSnippet.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron at gmail dot com) - Initial implementation and API
10 | *******************************************************************************/
11 | package org.mihalis.opal.launcher;
12 |
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.events.SelectionAdapter;
15 | import org.eclipse.swt.events.SelectionEvent;
16 | import org.eclipse.swt.graphics.Point;
17 | import org.eclipse.swt.layout.GridData;
18 | import org.eclipse.swt.layout.GridLayout;
19 | import org.eclipse.swt.widgets.Display;
20 | import org.eclipse.swt.widgets.Label;
21 | import org.eclipse.swt.widgets.Shell;
22 | import org.mihalis.opal.opalDialog.Dialog;
23 |
24 | /**
25 | * A simple snippet for the Launcher Widget
26 | *
27 | */
28 | public class LauncherSnippet {
29 |
30 | public static void main(final String[] args) {
31 | final Display display = new Display();
32 | final Shell shell = new Shell(display);
33 | shell.setLayout(new GridLayout(1, false));
34 |
35 | final Label title = new Label(shell, SWT.NONE);
36 | title.setText("Launcher");
37 | title.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
38 |
39 | final Launcher l = new Launcher(shell, SWT.NONE);
40 | l.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
41 | l.addItem("Address Book", "org/mihalis/opal/launcher/icons/x-office-address-book.png");
42 | l.addItem("Calendar", "org/mihalis/opal/launcher/icons/x-office-calendar.png");
43 | l.addItem("Presentation", "org/mihalis/opal/launcher/icons/x-office-presentation.png");
44 | l.addItem("Spreadsheet", "org/mihalis/opal/launcher/icons/x-office-spreadsheet.png");
45 |
46 | l.addSelectionListener(new SelectionAdapter() {
47 |
48 | /**
49 | * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
50 | */
51 | @Override
52 | public void widgetSelected(final SelectionEvent e) {
53 | Dialog.inform("Selection", "You have selected item #" + l.getSelection());
54 | }
55 |
56 | });
57 |
58 | final Label under = new Label(shell, SWT.NONE);
59 | under.setText("Double-click an icon to launch the program");
60 | under.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
61 |
62 | shell.setSize(new Point(436, 546));
63 | shell.open();
64 |
65 | while (!shell.isDisposed()) {
66 | if (!display.readAndDispatch()) {
67 | display.sleep();
68 | }
69 | }
70 | display.dispose();
71 |
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/launcher/icons/x-office-address-book.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/launcher/icons/x-office-address-book.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/launcher/icons/x-office-calendar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/launcher/icons/x-office-calendar.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/launcher/icons/x-office-presentation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/launcher/icons/x-office-presentation.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/launcher/icons/x-office-spreadsheet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/launcher/icons/x-office-spreadsheet.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/login/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/login/image.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/obutton/user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/obutton/user.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/opalDialog/warning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/opalDialog/warning.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/preferenceWindow/images/document.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/preferenceWindow/images/document.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/preferenceWindow/images/info.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/preferenceWindow/images/info.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/preferenceWindow/images/openterm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/preferenceWindow/images/openterm.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/preferenceWindow/images/printer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/preferenceWindow/images/printer.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/preferenceWindow/images/system.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/preferenceWindow/images/system.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/roundedToolbar/icons/bubble1_b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/roundedToolbar/icons/bubble1_b.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/roundedToolbar/icons/bubble1_w.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/roundedToolbar/icons/bubble1_w.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/roundedToolbar/icons/bubble2_b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/roundedToolbar/icons/bubble2_b.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/roundedToolbar/icons/bubble2_w.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/roundedToolbar/icons/bubble2_w.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/roundedToolbar/icons/bubble3_b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/roundedToolbar/icons/bubble3_b.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/roundedToolbar/icons/bubble3_w.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/roundedToolbar/icons/bubble3_w.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/roundedToolbar/icons/email_b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/roundedToolbar/icons/email_b.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/roundedToolbar/icons/email_w.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/roundedToolbar/icons/email_w.png
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/textAssist/TextAssistSnippet.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2011 Laurent CARON.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Laurent CARON (laurent.caron@gmail.com)
10 | *******************************************************************************/
11 | package org.mihalis.opal.textAssist;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | import org.eclipse.swt.SWT;
17 | import org.eclipse.swt.layout.GridData;
18 | import org.eclipse.swt.layout.GridLayout;
19 | import org.eclipse.swt.widgets.Display;
20 | import org.eclipse.swt.widgets.Shell;
21 |
22 | /**
23 | * A simple snippet for the TextAssist Widget
24 | */
25 | public class TextAssistSnippet {
26 | public static void main(final String[] args) {
27 | final Display display = new Display();
28 | final Shell shell = new Shell(display);
29 | shell.setLayout(new GridLayout());
30 |
31 | final TextAssistContentProvider contentProvider = new TextAssistContentProvider() {
32 |
33 | private final String[] EUROZONE = new String[] { "Austria", "Belgium", "Cyprus", "Estonia", "Finland", "France", "Germany", "Greece", "Ireland", "Italy", "Luxembourg", "Malta", "Netherlands", "Portugal", "Slovakia", "Slovenia", "Spain" };
34 |
35 | @Override
36 | public List getContent(final String entry) {
37 | final List returnedList = new ArrayList();
38 |
39 | for (final String country : this.EUROZONE) {
40 | if (country.toLowerCase().startsWith(entry.toLowerCase())) {
41 | returnedList.add(country);
42 | }
43 | }
44 |
45 | return returnedList;
46 | }
47 | };
48 |
49 | final TextAssist text = new TextAssist(shell, SWT.SINGLE | SWT.BORDER, contentProvider);
50 | text.setLayoutData(new GridData(150, SWT.DEFAULT));
51 | shell.pack();
52 | shell.open();
53 |
54 | while (!shell.isDisposed()) {
55 | if (!display.readAndDispatch()) {
56 | display.sleep();
57 | }
58 | }
59 | display.dispose();
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/test/java/org/mihalis/opal/titledSeparator/user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lcaron/opal/c099935c1d5f25fe7eb44fe57386cb82c65fb950/src/test/java/org/mihalis/opal/titledSeparator/user.png
--------------------------------------------------------------------------------