|
From: <pat...@us...> - 2010-08-05 19:07:07
|
Revision: 1113
http://cishell.svn.sourceforge.net/cishell/?rev=1113&view=rev
Author: pataphil
Date: 2010-08-05 19:06:58 +0000 (Thu, 05 Aug 2010)
Log Message:
-----------
* Changed org.cishell.utilities.swt to org.cishell.utility.swt.
Modified Paths:
--------------
trunk/core/org.cishell.utilities.swt/.project
trunk/core/org.cishell.utilities.swt/META-INF/MANIFEST.MF
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/model/datasynchronizer/CheckBoxDataSynchronizer.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/model/datasynchronizer/DateDataSynchronizer.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/model/datasynchronizer/DropDownDataSynchronizer.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/model/datasynchronizer/ModelDataSynchronizer.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/model/datasynchronizer/SingleListSelectionDataSynchronizer.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/model/datasynchronizer/TextDataSynchronizer.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/model/datasynchronizer/TimeDataSynchronizer.java
Added Paths:
-----------
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/ExpandableComponentWidget.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/FileSaveAs.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/GUIBuilderUtilities.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/GUICanceledException.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/GridContainer.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/SWTUtilities.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/ScrolledComponentFactory.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/URLClickedListener.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/URLMouseCursorListener.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/model/
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/model/GUIModel.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/model/GUIModelField.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/model/GUIModelGroup.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/model/ModelFieldException.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/model/datasynchronizer/
Removed Paths:
-------------
trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/ExpandableComponentWidget.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/FileSaveAs.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/GUIBuilderUtilities.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/GUICanceledException.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/GridContainer.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/SWTUtilities.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/ScrolledComponentFactory.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/URLClickedListener.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/URLMouseCursorListener.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/GUIModel.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/GUIModelField.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/GUIModelGroup.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/ModelFieldException.java
trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/datasynchronizer/
Modified: trunk/core/org.cishell.utilities.swt/.project
===================================================================
--- trunk/core/org.cishell.utilities.swt/.project 2010-08-05 18:59:05 UTC (rev 1112)
+++ trunk/core/org.cishell.utilities.swt/.project 2010-08-05 19:06:58 UTC (rev 1113)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>org.cishell.utilities.swt</name>
+ <name>org.cishell.utility.swt</name>
<comment></comment>
<projects>
</projects>
Modified: trunk/core/org.cishell.utilities.swt/META-INF/MANIFEST.MF
===================================================================
--- trunk/core/org.cishell.utilities.swt/META-INF/MANIFEST.MF 2010-08-05 18:59:05 UTC (rev 1112)
+++ trunk/core/org.cishell.utilities.swt/META-INF/MANIFEST.MF 2010-08-05 19:06:58 UTC (rev 1113)
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CIShell SWT Utilities
-Bundle-SymbolicName: org.cishell.utilities.swt
+Bundle-SymbolicName: org.cishell.utility.swt
Bundle-Version: 1.0.0
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.ui,
@@ -9,6 +9,6 @@
Import-Package: com.google.common.collect,
org.cishell.utilities,
org.cishell.utilities.datastructure
-Export-Package: org.cishell.utilities.swt,
- org.cishell.utilities.swt.model,
- org.cishell.utilities.swt.model.datasynchronizer
+Export-Package: org.cishell.utility.swt,
+ org.cishell.utility.swt.model,
+ org.cishell.utility.swt.model.datasynchronizer
Deleted: trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/ExpandableComponentWidget.java
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/ExpandableComponentWidget.java 2010-08-05 18:59:05 UTC (rev 1112)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/ExpandableComponentWidget.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -1,243 +0,0 @@
-package org.cishell.utilities.swt;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-
-/**
- * This is meant to be subclassed.
- */
-public class ExpandableComponentWidget<T> extends Composite {
- public static final int COLUMN_AREA_LAYOUT_VERTICAL_SPACING = 1;
- public static final int VERTICAL_SCROLL_INCREMENT = 50;
-
- private ScrolledComponentFactory<T> componentFactory;
- private Composite headerArea;
- private ScrolledComposite scrollingArea;
- private GridContainer scrolledAreaGrid;
- private Composite footerArea;
- private List<T> components = new ArrayList<T>();
- private int uniqueComponentCount = 0;
- private Collection<Label> columnLabels;
-
- public ExpandableComponentWidget(
- Composite parent, ScrolledComponentFactory<T> componentFactory) {
- super(parent, SWT.NONE);
- this.componentFactory = componentFactory;
-
- setLayout(createLayout());
- this.headerArea = createHeaderArea();
- this.scrollingArea = createScrollingArea();
- this.footerArea = createFooterArea();
- this.scrolledAreaGrid = createScrolledAreaGrid(this.scrollingArea);
-
- this.scrollingArea.setExpandHorizontal(true);
- this.scrollingArea.setExpandVertical(true);
- this.scrollingArea.setAlwaysShowScrollBars(true);
- fixSize();
- this.scrollingArea.setContent(this.scrolledAreaGrid.getActualParent());
- this.scrollingArea.getVerticalBar().setPageIncrement(VERTICAL_SCROLL_INCREMENT);
- this.columnLabels = createColumnLabels(this.scrolledAreaGrid.getActualParent(), SWT.NONE);
- }
-
- public Composite getHeaderArea() {
- return this.headerArea;
- }
-
- public Composite getFooterArea() {
- return this.footerArea;
- }
-
- public List<T> getComponents() {
- return Collections.unmodifiableList(this.components);
- }
-
- public int getColumnCount() {
- return 1;
- }
-
- public T addComponent(int style, Map<String, Object> arguments) {
- // TODO: Fix this terrible hack?
- if (this.components.size() == 0) {
- for (Label columnLabel : this.columnLabels) {
- columnLabel.setVisible(true);
- }
- }
-
- final int componentCount = this.components.size();
- T component = this.componentFactory.constructWidget(
- this, this.scrolledAreaGrid, style, arguments, componentCount, this.uniqueComponentCount);
- this.uniqueComponentCount++;
-
- fixSize();
-
- this.components.add(component);
-
- return component;
- }
-
- public void removeComponent(int index) {
- this.scrolledAreaGrid.removeRow(index);
- this.components.remove(index);
- fixSize();
-
- for (int ii = 0; ii < this.components.size(); ii++) {
- this.componentFactory.reindexComponent(this.components.get(ii), ii);
- }
-
- // TODO: Fix this terrible hack?
- if (this.components.size() == 0) {
- for (Label columnLabel : this.columnLabels) {
- columnLabel.setVisible(false);
- }
- }
- }
-
- public Collection<Label> createColumnLabels(Composite parent, int style) {
- List<Label> columnLabels = new ArrayList<Label>();
-
- for (String columnLabelText : createColumnLabelTexts()) {
- Label columnLabel = new Label(parent, style);
- columnLabel.setLayoutData(createColumnLabelLayoutData());
- columnLabel.setText(columnLabelText);
- columnLabels.add(columnLabel);
- }
-
- return columnLabels;
- }
-
- public Collection<String> createColumnLabelTexts() {
- List<String> columnLabelTexts = new ArrayList<String>();
-
- for (int ii = 0; ii < getColumnCount(); ii++) {
- columnLabelTexts.add("Column " + ii);
- }
-
- return columnLabelTexts;
- }
-
- private void fixSize() {
- Composite scrolledArea = this.scrolledAreaGrid.getActualParent();
- this.scrollingArea.setMinSize(scrolledArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- scrolledArea.pack();
- }
-
- protected Composite createHeaderArea() {
- Composite headerArea = new Composite(this, SWT.NONE);
- headerArea.setLayoutData(createHeaderAreaLayoutData());
- headerArea.setLayout(createHeaderLayout());
-
- return headerArea;
- }
-
- protected GridData createHeaderAreaLayoutData() {
- GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
-
- return layoutData;
- }
-
- protected GridLayout createHeaderLayout() {
- GridLayout layout = new GridLayout(1, false);
- GUIBuilderUtilities.clearMargins(layout);
- GUIBuilderUtilities.clearSpacing(layout);
-
- return layout;
- }
-
- protected ScrolledComposite createScrollingArea() {
- ScrolledComposite scrollingArea =
- new ScrolledComposite(this, SWT.BORDER | SWT.V_SCROLL);
- scrollingArea.setLayoutData(createScrollingAreaLayoutData());
- scrollingArea.setLayout(createScrollingLayout());
-
- return scrollingArea;
- }
-
- protected GridData createScrollingAreaLayoutData() {
- GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
-
- return layoutData;
- }
-
- private GridLayout createScrollingLayout() {
- GridLayout layout = new GridLayout(1, true);
- GUIBuilderUtilities.clearMargins(layout);
- GUIBuilderUtilities.clearSpacing(layout);
-
- return layout;
- }
-
- protected Composite createFooterArea() {
- Composite footerArea = new Composite(this, SWT.BORDER);
- footerArea.setLayoutData(createFooterAreaLayoutData());
- footerArea.setLayout(createFooterLayout());
-
- return footerArea;
- }
-
- protected GridData createFooterAreaLayoutData() {
- GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
-
- return layoutData;
- }
-
- protected GridLayout createFooterLayout() {
- GridLayout layout = new GridLayout(1, false);
- GUIBuilderUtilities.clearMargins(layout);
- GUIBuilderUtilities.clearSpacing(layout);
-
- return layout;
- }
-
- private GridContainer createScrolledAreaGrid(Composite parent) {
- Composite columnArea = new Composite(parent, SWT.NONE);
- columnArea.setLayoutData(createScrolledAreaLayoutData());
- final int columnCount = getColumnCount();
- columnArea.setLayout(createScrolledAreaLayout(columnCount));
-
- return new GridContainer(columnArea, columnCount);
- }
-
- protected GridData createScrolledAreaLayoutData() {
- GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
-
- return layoutData;
- }
-
- protected GridLayout createScrolledAreaLayout(int columnCount) {
- GridLayout layout = new GridLayout(columnCount, false);
-// GUIBuilderUtilities.clearMargins(layout);
-// GUIBuilderUtilities.clearSpacing(layout);
-
- return layout;
- }
-
- protected GridData createColumnLabelLayoutData() {
- GridData layoutData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
-
- return layoutData;
- }
-
- protected GridData createComponentLayoutData() {
- GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
-
- return layoutData;
- }
-
- private static GridLayout createLayout() {
- GridLayout layout = new GridLayout(1, true);
- GUIBuilderUtilities.clearMargins(layout);
- GUIBuilderUtilities.clearSpacing(layout);
-
- return layout;
- }
-}
\ No newline at end of file
Deleted: trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/FileSaveAs.java
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/FileSaveAs.java 2010-08-05 18:59:05 UTC (rev 1112)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/FileSaveAs.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -1,52 +0,0 @@
-package org.cishell.utilities.swt;
-
-import java.io.File;
-
-import org.cishell.utilities.StringUtilities;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Shell;
-
-public class FileSaveAs {
- public static final String DEFAULT_WINDOW_TITLE = "Save As";
- public static final String CONFIRMATION_DIALOG_FORMAT =
- "%s already exists.\nDo you want to replace it?";
-// public static final String YES_BUTTON_LABEL = "Yes";
-// public static final String NO_BUTTON_LABEL = "No";
-// public static final String[] BUTTON_LABELS = { YES_BUTTON_LABEL, NO_BUTTON_LABEL };
-
- public static String saveFileAs(Shell parent) {
- FileDialog saveDialog = new FileDialog(parent);
- saveDialog.setText(DEFAULT_WINDOW_TITLE);
-
- return saveFileAs(saveDialog);
- }
-
- public static String saveFileAs(Shell parent, int style) {
- FileDialog saveDialog = new FileDialog(parent, style);
- saveDialog.setText(DEFAULT_WINDOW_TITLE);
-
- return saveFileAs(saveDialog);
- }
-
- public static String saveFileAs(FileDialog saveDialog) {
- while (true) {
- String selectedFilePath = saveDialog.open();
-
- if (StringUtilities.isNull_Empty_OrWhitespace(selectedFilePath)) {
- return null;
- } else {
- if (new File(selectedFilePath).exists()) {
- if (MessageDialog.openConfirm(
- saveDialog.getParent(),
- saveDialog.getText(),
- String.format(CONFIRMATION_DIALOG_FORMAT, selectedFilePath))) {
- return selectedFilePath;
- }
- } else {
- return selectedFilePath;
- }
- }
- }
- }
-}
\ No newline at end of file
Deleted: trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/GUIBuilderUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/GUIBuilderUtilities.java 2010-08-05 18:59:05 UTC (rev 1112)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/GUIBuilderUtilities.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -1,124 +0,0 @@
-package org.cishell.utilities.swt;
-
-import org.cishell.utilities.datastructure.ObjectContainer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.events.ShellListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-
-public class GUIBuilderUtilities {
- public static Display createDisplay() {
- return new Display();
- }
-
- public static Shell createShell(
- Display display,
- String windowTitle,
- int windowWidth,
- int windowHeight,
- int columnCount,
- boolean clearSpacing) {
- Shell shell = new Shell(display, SWT.CLOSE | SWT.MIN | SWT.TITLE);
- shell.setText(windowTitle);
- shell.setSize(windowWidth, windowHeight);
- shell.setLayout(createShellLayout(columnCount, clearSpacing));
-
- return shell;
- }
-
- public static GridLayout createShellLayout(int columnCount, boolean clearSpacing) {
- GridLayout layout = new GridLayout(columnCount, true);
-
- if (clearSpacing) {
- clearSpacing(layout);
- }
-
- return layout;
- }
-
- public static void openShell(
- Shell shell, int windowHeight, boolean useWindowHeightToSizeShell) {
-// if (useWindowHeightToSizeShell) {
-// /* (So far, we've created the shell at the maximum possible size we'll allow
-// * (according to windowHeight). This line shrinks the shell to be a more fitting size
-// * if the actual contents (i.e. our (number of) columns) are smaller than the maximum
-// * size we set.)
-// */
-// Point shellSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-// shell.setMinimumSize(shellSize.x, Math.min(windowHeight, shellSize.y));
-// }
-
- shell.pack();
- shell.open();
-
- if (useWindowHeightToSizeShell) {
- Point shellSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- shell.setSize(shell.getSize().x, Math.min(windowHeight, shellSize.y));
- }
- }
-
- public static void swtLoop(Display display, Shell shell) {
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
-
- display.dispose();
- }
-
- public static void clearMargins(GridLayout layout) {
- layout.marginTop = layout.marginBottom = layout.marginHeight = 0;
- layout.marginLeft = layout.marginRight = layout.marginWidth = 0;
- }
-
- public static void clearSpacing(GridLayout layout) {
- layout.horizontalSpacing = layout.verticalSpacing = 0;
- }
-
- public static void setCancelable(
- final Shell shell, final ObjectContainer<GUICanceledException> exceptionThrown) {
- shell.addListener(SWT.Traverse, new Listener() {
- public void handleEvent(Event event) {
- switch (event.detail) {
- case SWT.TRAVERSE_ESCAPE:
- shell.close();
- event.detail = SWT.TRAVERSE_NONE;
- event.doit = false;
-
-// if (exceptionThrown != null) {
-// String exceptionMessage = "Canceled by user.";
-// exceptionThrown.object = new GUICanceledException(exceptionMessage);
-// }
-
- break;
- }
- }
- });
- shell.addShellListener(new ShellListener() {
- public void shellActivated(ShellEvent event) {
- }
-
- public void shellClosed(ShellEvent event) {
- if (exceptionThrown != null) {
- String exceptionMessage = "Canceled by user.";
- exceptionThrown.object = new GUICanceledException(exceptionMessage);
- }
- }
-
- public void shellDeactivated(ShellEvent event) {
- }
-
- public void shellDeiconified(ShellEvent event) {
- }
-
- public void shellIconified(ShellEvent event) {
- }
- });
- }
-}
\ No newline at end of file
Deleted: trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/GUICanceledException.java
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/GUICanceledException.java 2010-08-05 18:59:05 UTC (rev 1112)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/GUICanceledException.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -1,21 +0,0 @@
-package org.cishell.utilities.swt;
-
-public class GUICanceledException extends Exception {
- private static final long serialVersionUID = 1L;
-
- public GUICanceledException() {
- super();
- }
-
- public GUICanceledException(String arg0) {
- super(arg0);
- }
-
- public GUICanceledException(Throwable arg0) {
- super(arg0);
- }
-
- public GUICanceledException(String arg0, Throwable arg1) {
- super(arg0, arg1);
- }
-}
\ No newline at end of file
Deleted: trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/GridContainer.java
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/GridContainer.java 2010-08-05 18:59:05 UTC (rev 1112)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/GridContainer.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -1,92 +0,0 @@
-package org.cishell.utilities.swt;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Widget;
-
-public class GridContainer {
- private Composite actualParent;
- private int columnCount;
- private List<GridRow> rows = new ArrayList<GridRow>();
-
- public GridContainer(Composite actualParent, int columnCount) {
- this.actualParent = actualParent;
- this.columnCount = columnCount;
- }
-
- public Composite getActualParent() {
- return this.actualParent;
- }
-
- public int getColumnCount() {
- return this.columnCount;
- }
-
- public int getRowCount() {
- return this.rows.size();
- }
-
- public GridRow addComponent(Widget component) {
- GridRow lastRow = getOrCreateLastUsableRow();
- lastRow.addComponent(component);
-
- return lastRow;
- }
-
- public void removeRow(int rowIndex) {
- this.rows.get(rowIndex).dispose();
- this.rows.remove(rowIndex);
- }
-
- private GridRow getOrCreateLastUsableRow() {
- final int rowCount = getRowCount();
-
- if (rowCount == 0) {
- return addNewRow();
- } else {
- GridRow lastRow = this.rows.get(rowCount - 1);
-
- if (lastRow.componentCount < getColumnCount()) {
- return lastRow;
- } else {
- return addNewRow();
- }
- }
- }
-
- private GridRow addNewRow() {
- GridRow row = new GridRow(getRowCount());
- this.rows.add(row);
-
- return row;
- }
-
- public class GridRow {
- private int rowIndex;
- private int componentCount = 0;
- private Collection<Widget> components =
- new ArrayList<Widget>(GridContainer.this.columnCount);
-
- private GridRow(int rowIndex) {
- this.rowIndex = rowIndex;
- }
-
- public int getRowIndex() {
- return this.rowIndex;
- }
-
- private void addComponent(Widget component) {
- this.components.add(component);
- this.componentCount++;
- }
-
- private void dispose() {
- for (Widget component : this.components) {
- component.dispose();
- }
- }
- }
-}
Deleted: trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/SWTUtilities.java
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/SWTUtilities.java 2010-08-05 18:59:05 UTC (rev 1112)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/SWTUtilities.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -1,123 +0,0 @@
-package org.cishell.utilities.swt;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-public class SWTUtilities {
- /*
- * Append the given string to the console with the given color, this will do the job of
- * checking for URLs within the string and registering the proper listeners on them as well.
- */
- public static void appendStringWithURL(
- StyledText textField,
- URLClickedListener urlListener,
- URLMouseCursorListener urlCursorListener,
- String message,
- Color normalColor,
- Color urlColor) {
-
- //find a URL in the message
-
- int index = message.indexOf("http://");
- if (index == -1) {
- index = message.indexOf("https://");
- }
- if (index == -1) {
- index = message.indexOf("www.");
- }
-
- if (index > -1) {
- String url = message.substring(index);
- if (url.indexOf(") ") > -1) {
- url = url.substring(0, url.indexOf(") "));
- }
- else if (url.indexOf(" ") > -1) {
- url = url.substring(0, url.indexOf(" "));
- if (url.trim().endsWith(".") ){
- url=url.substring(0, url.length()-1);
- }
- }
- if (url.endsWith(".\n") || url.endsWith(".\t")){
- url=url.substring(0, url.length()-2);
- }
- if (url.indexOf("\n") > -1) {
- url = url.substring(0, url.indexOf("\n"));
- }
- if (url.indexOf("\t") > -1) {
- url = url.substring(0, url.indexOf("\n"));
- }
-
-
- syncedStyledPrint(textField, message.substring(0, index), normalColor, SWT.NORMAL);
- urlListener.addURL(textField.getText().length(), url);
- urlCursorListener.addURL(textField.getText().length(), url);
- syncedStyledPrint(textField, url, urlColor, SWT.BOLD);
- appendStringWithURL(
- textField,
- urlListener,
- urlCursorListener,
- message.substring(index + url.length()),
- normalColor,urlColor);
- } else {
- syncedStyledPrint(textField, message, normalColor, SWT.NORMAL);
- }
- }
-
- /*
- * Helper to actually format the string with a style range and
- * append it to the StyledText control.
- */
-
- public static void syncedStyledPrint(
- final StyledText textField, final String message, final Color color, final int style) {
- Display.getDefault().syncExec(new Runnable() {
- public void run(){
- styledPrint(textField, message, color, style);
- }
- });
- }
-
- public static void styledPrint(StyledText textField, String message, Color color, int style) {
- if (!textField.isDisposed()) {
- textField.append(message);
-
- StyleRange styleRange = new StyleRange();
- styleRange.start = textField.getText().length() - message.length();
- styleRange.length = message.length();
- styleRange.foreground = color;
- styleRange.fontStyle = style;
- textField.setStyleRange(styleRange);
-
- // This makes it autoscroll.
- textField.setTopIndex(textField.getLineCount());
- }
- }
-
- public static void printURL(
- Composite parent,
- StyledText textField,
- String url,
- String displayURL,
- Color color,
- int style) {
- URLClickedListener urlClickedListener = new URLClickedListener(textField);
- URLMouseCursorListener urlCursorListener =
- new URLMouseCursorListener(parent, textField);
- textField.addMouseListener(urlClickedListener);
- textField.addMouseMoveListener(urlCursorListener);
-
- urlClickedListener.addURL(
- textField.getText().length(), url, displayURL);
- urlCursorListener.addURL(
- textField.getText().length(), url, displayURL);
- SWTUtilities.styledPrint(
- textField,
- displayURL,
- color,
- style);
- }
-}
\ No newline at end of file
Deleted: trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/ScrolledComponentFactory.java
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/ScrolledComponentFactory.java 2010-08-05 18:59:05 UTC (rev 1112)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/ScrolledComponentFactory.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -1,15 +0,0 @@
-package org.cishell.utilities.swt;
-
-import java.util.Map;
-
-public interface ScrolledComponentFactory<T> {
- public T constructWidget(
- ExpandableComponentWidget<T> componentWidget,
- GridContainer scrolledAreaGrid,
- int style,
- Map<String, Object> arguments,
- int index,
- int uniqueIndex);
-
- public void reindexComponent(T component, int newIndex);
-}
\ No newline at end of file
Deleted: trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/URLClickedListener.java
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/URLClickedListener.java 2010-08-05 18:59:05 UTC (rev 1112)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/URLClickedListener.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -1,70 +0,0 @@
-package org.cishell.utilities.swt;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.program.Program;
-
-/*
- * Listens for clicks on urls and launches a browser.
- */
-public class URLClickedListener extends MouseAdapter {
- private Map<Integer, String> offsetsToURLs = new HashMap<Integer, String>();
- private Map<String, String> urlsToDisplayURLs = new HashMap<String, String>();
- private StyledText textField;
-
- public URLClickedListener(StyledText textField) {
- super();
- this.textField = textField;
- }
-
- public void addURL(int offset, String url) {
- addURL(offset, url, url);
- }
-
- public void addURL(int offset, String url, String displayURL) {
- this.offsetsToURLs.put(offset, url);
- this.urlsToDisplayURLs.put(url, displayURL);
- }
-
- public void mouseDown(MouseEvent event) {
- if (event.button != 1) {
- return;
- }
-
- int clickedPosition = determineClickedPosition(event);
-
- if (clickedPosition < 0) {
- return;
- }
-
- for (Integer offset : this.offsetsToURLs.keySet().toArray(new Integer[0])) {
- String url = this.offsetsToURLs.get(offset);
- String displayURL = this.urlsToDisplayURLs.get(url);
-
- if ((displayURL != null) &&
- (clickedPosition >= offset.intValue()) &&
- (clickedPosition <= (offset.intValue() + displayURL.length()))) {
- try {
- Program.launch(url);
- } catch (Exception e) {
- }
- }
- }
- }
-
- private int determineClickedPosition(MouseEvent event) {
- int clickedPosition = -1;
-
- try {
- clickedPosition = this.textField.getOffsetAtLocation(new Point(event.x, event.y));
- } catch (IllegalArgumentException ex) {
- }
-
- return clickedPosition;
- }
-}
\ No newline at end of file
Deleted: trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/URLMouseCursorListener.java
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/URLMouseCursorListener.java 2010-08-05 18:59:05 UTC (rev 1112)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/URLMouseCursorListener.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -1,79 +0,0 @@
-package org.cishell.utilities.swt;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-
-/*
- * Monitors the mouse and changes the cursor when it is over a URL.
- */
-public class URLMouseCursorListener implements MouseMoveListener {
- private Map<Integer, String> offsetsToURLs = new HashMap<Integer, String>();
- private Map<String, String> urlsToDisplayURLs = new HashMap<String, String>();
- private Composite parent;
- private StyledText textField;
-
- public URLMouseCursorListener(Composite parent, StyledText textField) {
- this.parent = parent;
- this.textField = textField;
- }
-
- public void addURL(int offset, String url) {
- addURL(offset, url, url);
- }
-
- public void addURL(int offset, String url, String displayURL) {
- this.offsetsToURLs.put(new Integer(offset), url);
- this.urlsToDisplayURLs.put(url, displayURL);
- }
-
- public void mouseMove(MouseEvent event) {
- int urlOffsetOfMousePosition = determineURLOffsetOfMousePosition(event);
- Integer[] urlOffsets = this.offsetsToURLs.keySet().toArray(new Integer[0]);
- boolean mouseIsOverURL = determineIfMouseIsHoveringOverURL(urlOffsetOfMousePosition, urlOffsets);
- Cursor cursor = new Cursor(parent.getDisplay(), determineMouseCursor(mouseIsOverURL));
- textField.setCursor(cursor);
- }
-
- private int determineURLOffsetOfMousePosition(MouseEvent event) {
- try {
- return textField.getOffsetAtLocation(new Point(event.x, event.y));
- } catch (IllegalArgumentException e) {
- Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_ARROW);
- textField.setCursor(cursor);
- }
-
- return -1;
- }
-
- private boolean determineIfMouseIsHoveringOverURL(
- int urlOffsetOfMousePosition, Integer[] urlOffsets) {
- for (Integer urlOffset : urlOffsets) {
- String url = this.offsetsToURLs.get(urlOffset);
-
- if ((urlOffset != null) &&
- (url != null) &&
- (urlOffsetOfMousePosition >= urlOffset.intValue()) &&
- (urlOffsetOfMousePosition <= (urlOffset.intValue() + url.length()))) {
- return true;
- }
- }
-
- return false;
- }
-
- private int determineMouseCursor(boolean mouseIsOverURL) {
- if (mouseIsOverURL) {
- return SWT.CURSOR_HAND;
- } else {
- return SWT.CURSOR_ARROW;
- }
- }
-}
\ No newline at end of file
Deleted: trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/GUIModel.java
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/GUIModel.java 2010-08-05 18:59:05 UTC (rev 1112)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/GUIModel.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -1,190 +0,0 @@
-package org.cishell.utilities.swt.model;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.cishell.utilities.swt.model.datasynchronizer.CheckBoxDataSynchronizer;
-import org.cishell.utilities.swt.model.datasynchronizer.DropDownDataSynchronizer;
-import org.cishell.utilities.swt.model.datasynchronizer.ModelDataSynchronizer;
-import org.cishell.utilities.swt.model.datasynchronizer.SingleListSelectionDataSynchronizer;
-import org.cishell.utilities.swt.model.datasynchronizer.TextDataSynchronizer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Widget;
-
-public class GUIModel {
- private Map<String, GUIModelGroup> groups = new HashMap<String, GUIModelGroup>();
-
- public GUIModel() {
- }
-
- public Collection<String> getGroupNames() {
- return this.groups.keySet();
- }
-
- public Collection<GUIModelGroup> getGroups() {
- return this.groups.values();
- }
-
- public GUIModelGroup getGroup(String name) {
- if (!this.groups.containsKey(name)) {
- GUIModelGroup newGroup = new GUIModelGroup(name);
- this.groups.put(name, newGroup);
-
- return newGroup;
- } else {
- return this.groups.get(name);
- }
- }
-
- public GUIModelField<Boolean, Button, CheckBoxDataSynchronizer> addCheckBox(
- String groupName, String name, boolean on, Composite parent, int style) {
- Button checkBox = new Button(parent, style | SWT.CHECK);
- CheckBoxDataSynchronizer dataSynchronizer = new CheckBoxDataSynchronizer(checkBox, on);
- GUIModelField<Boolean, Button, CheckBoxDataSynchronizer> field =
- new GUIModelField<Boolean, Button, CheckBoxDataSynchronizer>(
- name, on, checkBox, dataSynchronizer);
- addField(groupName, field);
-
- return field;
- }
-
- public GUIModelField<String, Combo, DropDownDataSynchronizer> addDropDown(
- String groupName,
- String name,
- int selectedIndex,
- Collection<String> unorderedOptionLabels,
- Map<String, String> optionValuesByLabels,
- Composite parent,
- int style) {
- java.util.List<String> orderedOptionLabels = new ArrayList<String>(unorderedOptionLabels);
- Combo dropDown = new Combo(parent, style | SWT.DROP_DOWN);
- DropDownDataSynchronizer dataSynchronizer = new DropDownDataSynchronizer(
- dropDown, selectedIndex, orderedOptionLabels, optionValuesByLabels);
- GUIModelField<String, Combo, DropDownDataSynchronizer> field =
- new GUIModelField<String, Combo, DropDownDataSynchronizer>(
- name,
- optionValuesByLabels.get(orderedOptionLabels.get(selectedIndex)),
- dropDown,
- dataSynchronizer);
- addField(groupName, field);
-
- return field;
- }
-
- // TODO: addMultiSelectionDropDown
-
- // TODO: Test this out.
- // TODO: Make it so the build works with this stuff.
-// public GUIModelField<
-// org.joda.time.DateTime, org.eclipse.swt.widgets.DateTime, DateDataSynchronizer>
-// addDate(String name, org.joda.time.DateTime date, Composite parent, int style) {
-// org.eclipse.swt.widgets.DateTime dateSelector =
-// new org.eclipse.swt.widgets.DateTime(parent, style | SWT.DATE);
-// DateDataSynchronizer dataSynchronizer = new DateDataSynchronizer(dateSelector, date);
-// GUIModelField<
-// org.joda.time.DateTime, org.eclipse.swt.widgets.DateTime, DateDataSynchronizer> field =
-// new GUIModelField<
-// org.joda.time.DateTime,
-// org.eclipse.swt.widgets.DateTime,
-// DateDataSynchronizer>(
-// name, date, dateSelector, dataSynchronizer);
-// addField(field);
-//
-// return field;
-// }
-
- // TODO: Test this out.
-// public GUIModelField<
-// org.joda.time.DateTime, org.eclipse.swt.widgets.DateTime, TimeDataSynchronizer>
-// addTime(String name, org.joda.time.DateTime time, Composite parent, int style) {
-// org.eclipse.swt.widgets.DateTime timeSelector =
-// new org.eclipse.swt.widgets.DateTime(parent, style | SWT.TIME);
-// TimeDataSynchronizer dataSynchronizer = new TimeDataSynchronizer(timeSelector, time);
-// GUIModelField<
-// org.joda.time.DateTime, org.eclipse.swt.widgets.DateTime, TimeDataSynchronizer> field =
-// new GUIModelField<
-// org.joda.time.DateTime,
-// org.eclipse.swt.widgets.DateTime,
-// TimeDataSynchronizer>(
-// name, time, timeSelector, dataSynchronizer);
-// addField(field);
-//
-// return field;
-// }
-
- // TODO: addCalendar
-
- // TODO: Test this out.
- public GUIModelField<String, List, SingleListSelectionDataSynchronizer> addList(
- String groupName,
- String name,
- int selectedIndex,
- Collection<String> unorderedOptionLabels,
- Map<String, String> optionValuesByLabels,
- Composite parent,
- int style) {
- java.util.List<String> orderedOptionLabels = new ArrayList<String>(unorderedOptionLabels);
- List list = new List(parent, style | SWT.SINGLE);
- SingleListSelectionDataSynchronizer dataSynchronizer =
- new SingleListSelectionDataSynchronizer(
- list, selectedIndex, orderedOptionLabels, optionValuesByLabels);
- GUIModelField<String, List, SingleListSelectionDataSynchronizer> field =
- new GUIModelField<String, List, SingleListSelectionDataSynchronizer>(
- name, list.getItem(selectedIndex), list, dataSynchronizer);
- addField(groupName, field);
-
- return field;
- }
-
- // TODO: addMultiSelectionList
- // TODO: addProgressBar
- // TODO: addSash?
- // TODO: addSlider
- // TODO: addScale
- // TODO: addSpinner
- // TODO: addStyledText
-
- public GUIModelField<String, Text, TextDataSynchronizer> addText(
- String groupName,
- String name,
- String value,
- boolean isMultiLined,
- Composite parent,
- int style) {
- if (isMultiLined) {
- style = style | SWT.MULTI;
- } else {
- style = style | SWT.SINGLE;
- }
-
- Text text = new Text(parent, style);
- TextDataSynchronizer dataSynchronizer = new TextDataSynchronizer(text, value);
- GUIModelField<String, Text, TextDataSynchronizer> field =
- new GUIModelField<String, Text, TextDataSynchronizer>(
- name, value, text, dataSynchronizer);
- addField(groupName, field);
-
- return field;
- }
-
- public<T> void addField(
- String groupName,
- GUIModelField<T, ? extends Widget, ? extends ModelDataSynchronizer<?>> field) {
- GUIModelGroup group = getGroup(groupName);
- group.addField(field);
- }
-
- public<T> void removeField(
- GUIModelField<T, ? extends Widget, ? extends ModelDataSynchronizer<?>> field) {
- for (GUIModelGroup group : this.groups.values()) {
- group.removeField(field);
- }
- }
-}
\ No newline at end of file
Deleted: trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/GUIModelField.java
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/GUIModelField.java 2010-08-05 18:59:05 UTC (rev 1112)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/GUIModelField.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -1,65 +0,0 @@
-package org.cishell.utilities.swt.model;
-
-import org.cishell.utilities.swt.model.datasynchronizer.ModelDataSynchronizer;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Widget;
-
-public class GUIModelField<T, U extends Widget, V extends ModelDataSynchronizer<T>> {
- private String name;
- private T defaultValue;
- private T previousValue;
- private T value;
- private U widget;
- private V dataSynchronizer;
-
- public GUIModelField(
- String name,
- T defaultValue,
- U widget,
- V dataSynchronizer) {
- this.name = name;
- this.defaultValue = defaultValue;
- this.value = this.defaultValue;
- this.widget = widget;
- this.dataSynchronizer = dataSynchronizer;
-
- this.widget.addListener(this.dataSynchronizer.swtUpdateListenerCode(), new Listener() {
- public void handleEvent(Event event) {
- if (event.type == GUIModelField.this.dataSynchronizer.swtUpdateListenerCode()) {
- GUIModelField.this.previousValue = GUIModelField.this.value;
- GUIModelField.this.value =
- GUIModelField.this.dataSynchronizer.synchronizeFromGUI();
- }
- }
- });
- }
-
- public String getName() {
- return this.name;
- }
-
- public T getPreviousValue() {
- return this.previousValue;
- }
-
- public T getValue() {
- return this.value;
- }
-
- public U getWidget() {
- return this.widget;
- }
-
- public V getDataSynchronizer() {
- return this.dataSynchronizer;
- }
-
- public void setValue(T value) {
- this.value = this.dataSynchronizer.synchronizeToGUI(value);
- }
-
- public void reset() {
- this.value = this.dataSynchronizer.reset(this.defaultValue);
- }
-}
\ No newline at end of file
Deleted: trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/GUIModelGroup.java
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/GUIModelGroup.java 2010-08-05 18:59:05 UTC (rev 1112)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/GUIModelGroup.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -1,57 +0,0 @@
-package org.cishell.utilities.swt.model;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.cishell.utilities.swt.model.datasynchronizer.ModelDataSynchronizer;
-import org.eclipse.swt.widgets.Widget;
-
-public class GUIModelGroup {
- private String name;
- private Map<String, GUIModelField<?, ? extends Widget, ? extends ModelDataSynchronizer<?>>>
- inputFieldsByName = new HashMap<
- String, GUIModelField<?, ? extends Widget, ? extends ModelDataSynchronizer<?>>>();
-
- public GUIModelGroup(String name) {
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
-
- public Collection<String> getFieldNames() {
- return this.inputFieldsByName.keySet();
- }
-
- public Collection<
- GUIModelField<?, ? extends Widget, ? extends ModelDataSynchronizer<?>>> getFields() {
- return this.inputFieldsByName.values();
- }
-
- public GUIModelField<
- ?, ? extends Widget, ? extends ModelDataSynchronizer<?>> getField(String name) {
- return this.inputFieldsByName.get(name);
- }
-
- public<T> void addField(
- GUIModelField<T, ? extends Widget, ? extends ModelDataSynchronizer<?>> field) {
- String fieldName = field.getName();
-
- if (this.inputFieldsByName.containsKey(fieldName)) {
- String exceptionMessage =
- "A field with the name \"" + fieldName + "\" already exists. Unable to continue.";
- throw new ModelFieldException(exceptionMessage);
- }
-
- this.inputFieldsByName.put(fieldName, field);
- }
-
- public<T> void removeField(
- GUIModelField<T, ? extends Widget, ? extends ModelDataSynchronizer<?>> field) {
- if (this.inputFieldsByName.containsValue(field)) {
- this.inputFieldsByName.remove(field.getName());
- }
- }
-}
\ No newline at end of file
Deleted: trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/ModelFieldException.java
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/ModelFieldException.java 2010-08-05 18:59:05 UTC (rev 1112)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/model/ModelFieldException.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -1,21 +0,0 @@
-package org.cishell.utilities.swt.model;
-
-public class ModelFieldException extends RuntimeException {
- private static final long serialVersionUID = 1L;
-
- public ModelFieldException() {
- super();
- }
-
- public ModelFieldException(String arg0) {
- super(arg0);
- }
-
- public ModelFieldException(Throwable arg0) {
- super(arg0);
- }
-
- public ModelFieldException(String arg0, Throwable arg1) {
- super(arg0, arg1);
- }
-}
\ No newline at end of file
Copied: trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/ExpandableComponentWidget.java (from rev 1105, trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/ExpandableComponentWidget.java)
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/ExpandableComponentWidget.java (rev 0)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/ExpandableComponentWidget.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -0,0 +1,243 @@
+package org.cishell.utility.swt;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * This is meant to be subclassed.
+ */
+public class ExpandableComponentWidget<T> extends Composite {
+ public static final int COLUMN_AREA_LAYOUT_VERTICAL_SPACING = 1;
+ public static final int VERTICAL_SCROLL_INCREMENT = 50;
+
+ private ScrolledComponentFactory<T> componentFactory;
+ private Composite headerArea;
+ private ScrolledComposite scrollingArea;
+ private GridContainer scrolledAreaGrid;
+ private Composite footerArea;
+ private List<T> components = new ArrayList<T>();
+ private int uniqueComponentCount = 0;
+ private Collection<Label> columnLabels;
+
+ public ExpandableComponentWidget(
+ Composite parent, ScrolledComponentFactory<T> componentFactory) {
+ super(parent, SWT.NONE);
+ this.componentFactory = componentFactory;
+
+ setLayout(createLayout());
+ this.headerArea = createHeaderArea();
+ this.scrollingArea = createScrollingArea();
+ this.footerArea = createFooterArea();
+ this.scrolledAreaGrid = createScrolledAreaGrid(this.scrollingArea);
+
+ this.scrollingArea.setExpandHorizontal(true);
+ this.scrollingArea.setExpandVertical(true);
+ this.scrollingArea.setAlwaysShowScrollBars(true);
+ fixSize();
+ this.scrollingArea.setContent(this.scrolledAreaGrid.getActualParent());
+ this.scrollingArea.getVerticalBar().setPageIncrement(VERTICAL_SCROLL_INCREMENT);
+ this.columnLabels = createColumnLabels(this.scrolledAreaGrid.getActualParent(), SWT.NONE);
+ }
+
+ public Composite getHeaderArea() {
+ return this.headerArea;
+ }
+
+ public Composite getFooterArea() {
+ return this.footerArea;
+ }
+
+ public List<T> getComponents() {
+ return Collections.unmodifiableList(this.components);
+ }
+
+ public int getColumnCount() {
+ return 1;
+ }
+
+ public T addComponent(int style, Map<String, Object> arguments) {
+ // TODO: Fix this terrible hack?
+ if (this.components.size() == 0) {
+ for (Label columnLabel : this.columnLabels) {
+ columnLabel.setVisible(true);
+ }
+ }
+
+ final int componentCount = this.components.size();
+ T component = this.componentFactory.constructWidget(
+ this, this.scrolledAreaGrid, style, arguments, componentCount, this.uniqueComponentCount);
+ this.uniqueComponentCount++;
+
+ fixSize();
+
+ this.components.add(component);
+
+ return component;
+ }
+
+ public void removeComponent(int index) {
+ this.scrolledAreaGrid.removeRow(index);
+ this.components.remove(index);
+ fixSize();
+
+ for (int ii = 0; ii < this.components.size(); ii++) {
+ this.componentFactory.reindexComponent(this.components.get(ii), ii);
+ }
+
+ // TODO: Fix this terrible hack?
+ if (this.components.size() == 0) {
+ for (Label columnLabel : this.columnLabels) {
+ columnLabel.setVisible(false);
+ }
+ }
+ }
+
+ public Collection<Label> createColumnLabels(Composite parent, int style) {
+ List<Label> columnLabels = new ArrayList<Label>();
+
+ for (String columnLabelText : createColumnLabelTexts()) {
+ Label columnLabel = new Label(parent, style);
+ columnLabel.setLayoutData(createColumnLabelLayoutData());
+ columnLabel.setText(columnLabelText);
+ columnLabels.add(columnLabel);
+ }
+
+ return columnLabels;
+ }
+
+ public Collection<String> createColumnLabelTexts() {
+ List<String> columnLabelTexts = new ArrayList<String>();
+
+ for (int ii = 0; ii < getColumnCount(); ii++) {
+ columnLabelTexts.add("Column " + ii);
+ }
+
+ return columnLabelTexts;
+ }
+
+ private void fixSize() {
+ Composite scrolledArea = this.scrolledAreaGrid.getActualParent();
+ this.scrollingArea.setMinSize(scrolledArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ scrolledArea.pack();
+ }
+
+ protected Composite createHeaderArea() {
+ Composite headerArea = new Composite(this, SWT.NONE);
+ headerArea.setLayoutData(createHeaderAreaLayoutData());
+ headerArea.setLayout(createHeaderLayout());
+
+ return headerArea;
+ }
+
+ protected GridData createHeaderAreaLayoutData() {
+ GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
+
+ return layoutData;
+ }
+
+ protected GridLayout createHeaderLayout() {
+ GridLayout layout = new GridLayout(1, false);
+ GUIBuilderUtilities.clearMargins(layout);
+ GUIBuilderUtilities.clearSpacing(layout);
+
+ return layout;
+ }
+
+ protected ScrolledComposite createScrollingArea() {
+ ScrolledComposite scrollingArea =
+ new ScrolledComposite(this, SWT.BORDER | SWT.V_SCROLL);
+ scrollingArea.setLayoutData(createScrollingAreaLayoutData());
+ scrollingArea.setLayout(createScrollingLayout());
+
+ return scrollingArea;
+ }
+
+ protected GridData createScrollingAreaLayoutData() {
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+
+ return layoutData;
+ }
+
+ private GridLayout createScrollingLayout() {
+ GridLayout layout = new GridLayout(1, true);
+ GUIBuilderUtilities.clearMargins(layout);
+ GUIBuilderUtilities.clearSpacing(layout);
+
+ return layout;
+ }
+
+ protected Composite createFooterArea() {
+ Composite footerArea = new Composite(this, SWT.BORDER);
+ footerArea.setLayoutData(createFooterAreaLayoutData());
+ footerArea.setLayout(createFooterLayout());
+
+ return footerArea;
+ }
+
+ protected GridData createFooterAreaLayoutData() {
+ GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
+
+ return layoutData;
+ }
+
+ protected GridLayout createFooterLayout() {
+ GridLayout layout = new GridLayout(1, false);
+ GUIBuilderUtilities.clearMargins(layout);
+ GUIBuilderUtilities.clearSpacing(layout);
+
+ return layout;
+ }
+
+ private GridContainer createScrolledAreaGrid(Composite parent) {
+ Composite columnArea = new Composite(parent, SWT.NONE);
+ columnArea.setLayoutData(createScrolledAreaLayoutData());
+ final int columnCount = getColumnCount();
+ columnArea.setLayout(createScrolledAreaLayout(columnCount));
+
+ return new GridContainer(columnArea, columnCount);
+ }
+
+ protected GridData createScrolledAreaLayoutData() {
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+
+ return layoutData;
+ }
+
+ protected GridLayout createScrolledAreaLayout(int columnCount) {
+ GridLayout layout = new GridLayout(columnCount, false);
+// GUIBuilderUtilities.clearMargins(layout);
+// GUIBuilderUtilities.clearSpacing(layout);
+
+ return layout;
+ }
+
+ protected GridData createColumnLabelLayoutData() {
+ GridData layoutData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
+
+ return layoutData;
+ }
+
+ protected GridData createComponentLayoutData() {
+ GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
+
+ return layoutData;
+ }
+
+ private static GridLayout createLayout() {
+ GridLayout layout = new GridLayout(1, true);
+ GUIBuilderUtilities.clearMargins(layout);
+ GUIBuilderUtilities.clearSpacing(layout);
+
+ return layout;
+ }
+}
\ No newline at end of file
Copied: trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/FileSaveAs.java (from rev 1105, trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/FileSaveAs.java)
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/FileSaveAs.java (rev 0)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/FileSaveAs.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -0,0 +1,52 @@
+package org.cishell.utility.swt;
+
+import java.io.File;
+
+import org.cishell.utilities.StringUtilities;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+
+public class FileSaveAs {
+ public static final String DEFAULT_WINDOW_TITLE = "Save As";
+ public static final String CONFIRMATION_DIALOG_FORMAT =
+ "%s already exists.\nDo you want to replace it?";
+// public static final String YES_BUTTON_LABEL = "Yes";
+// public static final String NO_BUTTON_LABEL = "No";
+// public static final String[] BUTTON_LABELS = { YES_BUTTON_LABEL, NO_BUTTON_LABEL };
+
+ public static String saveFileAs(Shell parent) {
+ FileDialog saveDialog = new FileDialog(parent);
+ saveDialog.setText(DEFAULT_WINDOW_TITLE);
+
+ return saveFileAs(saveDialog);
+ }
+
+ public static String saveFileAs(Shell parent, int style) {
+ FileDialog saveDialog = new FileDialog(parent, style);
+ saveDialog.setText(DEFAULT_WINDOW_TITLE);
+
+ return saveFileAs(saveDialog);
+ }
+
+ public static String saveFileAs(FileDialog saveDialog) {
+ while (true) {
+ String selectedFilePath = saveDialog.open();
+
+ if (StringUtilities.isNull_Empty_OrWhitespace(selectedFilePath)) {
+ return null;
+ } else {
+ if (new File(selectedFilePath).exists()) {
+ if (MessageDialog.openConfirm(
+ saveDialog.getParent(),
+ saveDialog.getText(),
+ String.format(CONFIRMATION_DIALOG_FORMAT, selectedFilePath))) {
+ return selectedFilePath;
+ }
+ } else {
+ return selectedFilePath;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Copied: trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/GUIBuilderUtilities.java (from rev 1105, trunk/core/org.cishell.utilities.swt/src/org/cishell/utilities/swt/GUIBuilderUtilities.java)
===================================================================
--- trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/GUIBuilderUtilities.java (rev 0)
+++ trunk/core/org.cishell.utilities.swt/src/org/cishell/utility/swt/GUIBuilderUtilities.java 2010-08-05 19:06:58 UTC (rev 1113)
@@ -0,0 +1,124 @@
+package org.cishell.utility.swt;
+
+import org.cishell.utilities.datastructure.ObjectContainer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.events.ShellListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+public class GUIBuilderUtilities {
+ public static Display createDisplay() {
+ return new Display();
+ }
+
+ public static Shell createShell(
+ Display display,
+ String windowTitle,
+ int windowWidth,
+ int windowHeight,
+ int columnCount,
+ boolean clearSpacing) {
+ Shell shell = new Shell(display, SWT.CLOSE | SWT.MIN | SWT.TITLE);
+ shell.setText(windowTitle);
+ shell.setSize(windowWidth, windowHeight);
+ shell.setLayout(createShellLayout(columnCount, clearSpacing));
+
+ return shell;
+ }
+
+ public static GridLayout createShellLayout(int columnCount, boolean clearSpacing) {
+ GridLayout layout = new GridLayout(columnCount, true);
+
+ if (clearSpacing) {
+ clearSpacing(layout);
+ }
+
+ return layout;
+ }
+
+ public static void openShell(
+ Shell shell, int windowHeight, boolean useWindowHeightToSizeShell) {
+// if (useWindowHeightToSizeShell) {
+// /* (So far, we've created the shell at the maximum possible size we'll allow
+// * (according to windowHeight). This line shrinks the shell to be a more fitting size
+// * if the actual contents (i.e. our (number of) columns) are smaller than the maximum
+// * size we set.)
+// */
+// Point shellSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+// shell.setMinimumSize(shellSize.x, Math.min(windowHeight, shellSize.y));
+// }
+
+ shell.pack();
+ shell.open();
+
+ if (useWindowHeightToSizeShell) {
+ Point shellSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ shell.setSize(shell.getSize().x, Math.min(windowHeight, shellSize.y));
+ }
+ }
+
+ public static void swtLoop(Display display, Shell shell) {
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+ }
+
+ public static void clearMargins(GridLayout layout) {
+ layout.marginTop = layout.marginBottom = layout.marginHeight = 0;
+ layout.marginLeft = layout.marginRight = layout.marginWidth = 0;
+ }
+
+ public static void clearSpacing(GridLayout layout) {
+ layout.horizontalSpacing = layout.verticalSpacing = 0;
+ }
+
+ public static void setCancelable(
+ final Shell shell, final ObjectContainer<GUICanceledException> exceptionThrown) {
+ shell.addListener(SWT.Traverse, new Listener() {
+ public void handleEvent(Event event) {
+ switch (event.detail) {
+ case SWT.TRAVERSE_ESCAPE:
+ shell.close();
+ event.detail = SWT.TRAVERSE_NONE;
+ event.doit = false;
+
+// if (exceptionThrown != null) {
+// String exceptionMessage = "Canceled by user.";
+// exceptionThrown.object = new GUICanceledException(exceptionMessage);
+// }
+
+ break;
+ }
+ }
+ });
+ shell.addShellListener(new ShellListener() {
+ public void shellActivated(ShellEvent event) {
+ }
+
+ public void shellClosed(ShellEvent event) {
+ if (exceptionThrown != null) {
+ String exceptionMessage = "Canceled by user.";
+ exceptionThrown.object = new GUICanceledException(except...
[truncated message content] |