|
From: <pat...@us...> - 2009-11-30 22:25:22
|
Revision: 986
http://cishell.svn.sourceforge.net/cishell/?rev=986&view=rev
Author: pataphil
Date: 2009-11-30 22:24:29 +0000 (Mon, 30 Nov 2009)
Log Message:
-----------
* Cleaned up FileFormatSelector code a little bit.
* Implemented double-click selection behavior for file format selector.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java 2009-11-30 19:30:56 UTC (rev 985)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java 2009-11-30 22:24:29 UTC (rev 986)
@@ -15,8 +15,8 @@
import org.cishell.framework.data.Data;
import org.cishell.reference.gui.common.AbstractDialog;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
@@ -31,14 +31,9 @@
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
-/**
- *
- * @author Team IVC (Weixia Huang, James Ellis)
- */
public class FileFormatSelector extends AbstractDialog {
private File selectedFile;
private LogService logger;
-
private ServiceReference[] persisterArray;
private List persisterList;
// private StyledText detailPane;
@@ -57,31 +52,38 @@
// {"Format name", "Supported file extension", "Format description"};
/*
- * Other possible keys display values could be "Restorable model name", "Restorable model description"
- * */
+ * Other possible keys display values could be "Restorable model name",
+ * "Restorable model description"
+ */
- public FileFormatSelector(String title, File theFile,
- Shell parent, CIShellContext ciContext, BundleContext bContext,
- ServiceReference[] persisterArray, ArrayList returnList){
+ public FileFormatSelector(
+ String title,
+ File selectedFile,
+ Shell parent,
+ CIShellContext ciShellContext,
+ BundleContext bundleContext,
+ ServiceReference[] persisterArray,
+ ArrayList returnList) {
super(parent, title, AbstractDialog.QUESTION);
- this.ciShellContext = ciContext;
- this.bundleContext = bContext;
+ this.ciShellContext = ciShellContext;
+ this.bundleContext = bundleContext;
this.persisterArray = persisterArray;
this.returnList = returnList;
+ this.selectedFile = selectedFile;
+ this.logger = (LogService)ciShellContext.getService(LogService.class.getName());
- this.selectedFile = theFile;
-
- this.logger = (LogService) ciContext.getService(LogService.class.getName());
- //shall this part be moved out of the code?
- setDescription("The file you have selected can be loaded"
- + " using one or more of the following formats.\n"
- + "Please select the format you would like to try.");
- setDetails("This dialog allows the user to choose among all available " +
- "formats for loading the selected data model. Choose any of the formats " +
- "to continue loading the dataset.");
+ // Shall this part be moved out of the code?
+ setDescription(
+ "The file you have selected can be loaded" +
+ " using one or more of the following formats.\n" +
+ "Please select the format you would like to try.");
+ setDetails(
+ "This dialog allows the user to choose among all available " +
+ "formats for loading the selected data model. Choose any of the formats " +
+ "to continue loading the dataset.");
}
- private Composite initGUI(Composite parent) {
+ private Composite initializeGUI(Composite parent) {
Composite content = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
@@ -89,106 +91,130 @@
content.setLayout(layout);
Group persisterGroup = new Group(content, SWT.NONE);
- //shall this label be moved out of the code?
+ // Shall this label be moved out of the code?
persisterGroup.setText("Load as...");
persisterGroup.setLayout(new FillLayout());
GridData persisterListGridData = new GridData(GridData.FILL_BOTH);
persisterListGridData.widthHint = 200;
persisterGroup.setLayoutData(persisterListGridData);
- persisterList = new List(persisterGroup, SWT.H_SCROLL |SWT.V_SCROLL | SWT.SINGLE);
- // initPersisterArray();
+ this.persisterList = new List(persisterGroup, SWT.H_SCROLL |SWT.V_SCROLL | SWT.SINGLE);
+ // initPersisterArray();
initPersisterList();
- persisterList.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- List list = (List)e.getSource();
+ this.persisterList.addMouseListener(new MouseListener() {
+ public void mouseUp(MouseEvent mouseEvent) {
+ }
+
+ public void mouseDown(MouseEvent mouseEvent) {
+ }
+
+ public void mouseDoubleClick(MouseEvent mouseEvent) {
+ int index = FileFormatSelector.this.persisterList.getSelectionIndex();
+
+ if (index != -1) {
+ selectionMade(index);
+ }
+ }
+ });
+
+ this.persisterList.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent selectionEvent) {
+ List list = (List)selectionEvent.getSource();
int selection = list.getSelectionIndex();
- if(selection != -1){
-// updateDetailPane(persisterArray[selection]);
+
+ if (selection != -1) {
+ // updateDetailPane(persisterArray[selection]);
}
}
});
-// Group detailsGroup = new Group(content, SWT.NONE);
-// // shall this label be moved out of the code?
-// detailsGroup.setText("Details");
-// detailsGroup.setLayout(new FillLayout());
-// GridData detailsGridData = new GridData(GridData.FILL_BOTH);
-// detailsGridData.widthHint = 200;
-// detailsGroup.setLayoutData(detailsGridData);
-//
-// detailPane = initDetailPane(detailsGroup);
-//
-// persisterList.setSelection(0);
-// updateDetailPane(persisterArray[0]);
+ /* Group detailsGroup = new Group(content, SWT.NONE);
+ // Shall this label be moved out of the code?
+ detailsGroup.setText("Details");
+ detailsGroup.setLayout(new FillLayout());
+ GridData detailsGridData = new GridData(GridData.FILL_BOTH);
+ detailsGridData.widthHint = 200;
+ detailsGroup.setLayoutData(detailsGridData);
- return content;
+ detailPane = initDetailPane(detailsGroup);
+
+ persisterList.setSelection(0);
+ updateDetailPane(persisterArray[0]); */
+
+ return content;
}
- private void initPersisterList(){
- for (int i = 0; i < persisterArray.length; ++i) {
+ private void initPersisterList() {
+ for (int ii = 0; ii < this.persisterArray.length; ++ii) {
+ String name = (String)this.persisterArray[ii].getProperty("label");
- String name = (String)persisterArray[i].getProperty("label");
+ /*
+ * If someone was sloppy enough to not provide a name, then use the name of the
+ * class instead.
+ */
+ if (name == null || name.length() == 0) {
+ name = this.persisterArray[ii].getClass().getName();
+ }
- // if someone was sloppy enough to not provide a name, then use the
- // name of the class instead.
- if (name == null || name.length() == 0)
- name = persisterArray[i].getClass().getName();
- persisterList.add(name);
+ this.persisterList.add(name);
}
}
-// private StyledText initDetailPane(Group detailsGroup) {
-// StyledText detailPane = new StyledText(detailsGroup, SWT.H_SCROLL | SWT.V_SCROLL);
-// detailPane.setEditable(false);
-// detailPane.getCaret().setVisible(false);
-// return detailPane;
-// }
+ /* private StyledText initDetailPane(Group detailsGroup) {
+ StyledText detailPane = new StyledText(detailsGroup, SWT.H_SCROLL | SWT.V_SCROLL);
+ detailPane.setEditable(false);
+ detailPane.getCaret().setVisible(false);
-// private void updateDetailPane(ServiceReference persister) {
-//
-// detailPane.setText("");
-// for (int i=0; i<DETAILS_ITEM_KEY.length; i++){
-// String val = (String) persister.getProperty(DETAILS_ITEM_KEY[i]);
-//
-// StyleRange styleRange = new StyleRange();
-// styleRange.start = detailPane.getText().length();
-// detailPane.append(DETAILS_ITEM_KEY_DISPLAY_VALUE[i] + ":\n");
-// styleRange.length = DETAILS_ITEM_KEY[i].length() + 1;
-// styleRange.fontStyle = SWT.BOLD;
-// detailPane.setStyleRange(styleRange);
-//
-// detailPane.append(val + "\n");
-//
-// }
-//
-// }
+ return detailPane;
+ }*/
+ /* private void updateDetailPane(ServiceReference persister) {
+
+ detailPane.setText("");
+
+ for (int ii = 0; ii < DETAILS_ITEM_KEY.length; ii++){
+ String val = (String)persister.getProperty(DETAILS_ITEM_KEY[ii]);
+
+ StyleRange styleRange = new StyleRange();
+ styleRange.start = detailPane.getText().length();
+ detailPane.append(DETAILS_ITEM_KEY_DISPLAY_VALUE[ii] + ":\n");
+ styleRange.length = DETAILS_ITEM_KEY[ii].length() + 1;
+ styleRange.fontStyle = SWT.BOLD;
+ detailPane.setStyleRange(styleRange);
+
+ detailPane.append(val + "\n");
+ }
+ } */
+
private void selectionMade(int selectedIndex) {
- AlgorithmFactory persister =(AlgorithmFactory) bundleContext.getService(persisterArray[selectedIndex]);
- Data[] dataManager = null;
+ AlgorithmFactory persister =
+ (AlgorithmFactory)this.bundleContext.getService(this.persisterArray[selectedIndex]);
+ Data[] data = null;
boolean loadSuccess = false;
try {
- dataManager = new Data[]{new BasicData(selectedFile.getPath(),String.class.getName())};
- dataManager = persister.createAlgorithm(dataManager, null, ciShellContext).execute();
+ data =
+ new Data[] { new BasicData(this.selectedFile.getPath(), String.class.getName()) };
+ data = persister.createAlgorithm(data, null, this.ciShellContext).execute();
loadSuccess = true;
- } catch (Throwable e) {
- this.logger.log(LogService.LOG_ERROR, "Error occurred while executing selection", e);
- e.printStackTrace();
+ } catch (Throwable exception) {
+ this.logger.log(
+ LogService.LOG_ERROR, "Error occurred while executing selection", exception);
+ exception.printStackTrace();
loadSuccess = false;
}
- if (dataManager != null && loadSuccess) {
- logger.log(LogService.LOG_INFO, "Loaded: "+selectedFile.getPath());
+ if ((data != null) && loadSuccess) {
+ this.logger.log(LogService.LOG_INFO, "Loaded: " + this.selectedFile.getPath());
- for(int i = 0; i<dataManager.length; i++){
- returnList.add(dataManager[i]);
+ for (int ii = 0; ii < data.length; ii++) {
+ this.returnList.add(data[ii]);
}
+
close(true);
} else {
- logger.log(LogService.LOG_ERROR, "Unable to load with selected loader");
+ this.logger.log(LogService.LOG_ERROR, "Unable to load with selected loader");
}
}
@@ -196,9 +222,10 @@
Button select = new Button(parent, SWT.PUSH);
select.setText("Select");
select.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- int index = persisterList.getSelectionIndex();
- if(index != -1){
+ public void widgetSelected(SelectionEvent selectionEvent) {
+ int index = FileFormatSelector.this.persisterList.getSelectionIndex();
+
+ if (index != -1) {
selectionMade(index);
}
}
@@ -207,13 +234,13 @@
Button cancel = new Button(parent, SWT.NONE);
cancel.setText("Cancel");
cancel.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(SelectionEvent selectionEvent) {
close(false);
}
});
}
public Composite createContent(Composite parent) {
- return initGUI(parent);
+ return initializeGUI(parent);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pat...@us...> - 2011-02-04 16:25:28
|
Revision: 1196
http://cishell.svn.sourceforge.net/cishell/?rev=1196&view=rev
Author: pataphil
Date: 2011-02-04 16:25:21 +0000 (Fri, 04 Feb 2011)
Log Message:
-----------
* Fixed a string formatting bug.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java
Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java 2011-02-04 14:43:09 UTC (rev 1195)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java 2011-02-04 16:25:21 UTC (rev 1196)
@@ -59,7 +59,7 @@
// Shall this part be moved out of the code?
String descriptionFormat =
- "The file \'%s\' can be loaded using one or more of the following formats.%s" +
+ "The file \'%s\' can be loaded using one or more of the following formats.%n" +
"Please select the format you would like to try.";
setDescription(String.format(descriptionFormat, file.getAbsolutePath()));
setDetails(
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pat...@us...> - 2011-02-18 05:13:20
|
Revision: 1220
http://cishell.svn.sourceforge.net/cishell/?rev=1220&view=rev
Author: pataphil
Date: 2011-02-18 05:13:14 +0000 (Fri, 18 Feb 2011)
Log Message:
-----------
* Removed unused version of FileFormatSelector.
Removed Paths:
-------------
trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java
Deleted: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java 2011-02-18 03:30:41 UTC (rev 1219)
+++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/load/FileFormatSelector.java 2011-02-18 05:13:14 UTC (rev 1220)
@@ -1,196 +0,0 @@
-/*
- * InfoVis CyberInfrastructure: A Data-Code-Compute Resource for Research
- * and Education in Information Visualization (http://iv.slis.indiana.edu/).
- *
- * Created on Jan 24, 2005 at Indiana University.
- */
-package org.cishell.reference.gui.persistence.load;
-
-import java.io.File;
-
-import org.cishell.framework.algorithm.AlgorithmFactory;
-import org.cishell.reference.gui.workspace.common.AbstractDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Shell;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-public class FileFormatSelector extends AbstractDialog {
- private BundleContext bundleContext;
- private AlgorithmFactory validator;
- private ServiceReference[] validatorReferences;
- private List validatorList;
-
-// private static final String[] DETAILS_ITEM_KEY =
-// {"format_name", "supported_file_extension", "format_description" };
-
- /*
- * Other possible keys could be restorable_model_name, restorable_model_description
- * */
-
-// private static final String[] DETAILS_ITEM_KEY_DISPLAY_VALUE =
-// {"Format name", "Supported file extension", "Format description"};
-
- /*
- * Other possible keys display values could be "Restorable model name",
- * "Restorable model description"
- */
-
- public FileFormatSelector(
- String title,
- Shell parent,
- BundleContext bundleContext,
- ServiceReference[] validatorReferences,
- File file) {
- super(parent, title, AbstractDialog.QUESTION);
- this.bundleContext = bundleContext;
- this.validatorReferences = validatorReferences;
-
- // Shall this part be moved out of the code?
- String descriptionFormat =
- "The file \'%s\' can be loaded using one or more of the following formats.%n" +
- "Please select the format you would like to try.";
- setDescription(String.format(descriptionFormat, file.getAbsolutePath()));
- setDetails(
- "This dialog allows the user to choose among all available " +
- "formats for loading the selected data model. Choose any of the formats " +
- "to continue loading the dataset.");
- }
-
- public AlgorithmFactory getValidator() {
- return this.validator;
- }
-
- private Composite initializeGUI(Composite parent) {
- Composite content = new Composite(parent, SWT.NONE);
-
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- content.setLayout(layout);
-
- Group validatorGroup = new Group(content, SWT.NONE);
- // Shall this label be moved out of the code?
- validatorGroup.setText("Load as...");
- validatorGroup.setLayout(new FillLayout());
- GridData validatorListGridData = new GridData(GridData.FILL_BOTH);
- validatorListGridData.widthHint = 200;
- validatorGroup.setLayoutData(validatorListGridData);
-
- this.validatorList = new List(validatorGroup, SWT.H_SCROLL |SWT.V_SCROLL | SWT.SINGLE);
- // initPersisterArray();
- initializePersisterList();
- this.validatorList.addMouseListener(new MouseAdapter() {
- public void mouseDoubleClick(MouseEvent mouseEvent) {
- List list = (List)mouseEvent.getSource();
- int selection = list.getSelectionIndex();
-
- if (selection != -1) {
- selectionMade(selection);
- }
- }
- });
-
- this.validatorList.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent selectionEvent) {
- List list = (List)selectionEvent.getSource();
- int selection = list.getSelectionIndex();
-
- if (selection != -1) {
- // updateDetailPane(validatorReferences[selection]);
- }
- }
- });
-
- validatorList.setSelection(0);
-
- return content;
- }
-
- private void initializePersisterList() {
- for (int ii = 0; ii < this.validatorReferences.length; ++ii) {
- String name = (String)this.validatorReferences[ii].getProperty("label");
-
- /*
- * If someone was sloppy enough to not provide a name, then use the name of the
- * class instead.
- */
- if (name == null || name.length() == 0) {
- name = this.validatorReferences[ii].getClass().getName();
- }
-
- this.validatorList.add(name);
- }
- }
-
- private void selectionMade(int selectedIndex) {
- this.validator =
- (AlgorithmFactory)this.bundleContext.getService(this.validatorReferences[selectedIndex]);
- close(true);
-// AlgorithmFactory validator =
-// (AlgorithmFactory)this.bundleContext.getService(this.persisterArray[selectedIndex]);
-// Data[] data = null;
-// boolean loadSuccess = false;
-//
-// try {
-// data =
-// new Data[] { new BasicData(this.selectedFile.getPath(), String.class.getName()) };
-// data = validator.createAlgorithm(data, null, this.ciShellContext).execute();
-// loadSuccess = true;
-// } catch (Throwable exception) {
-// this.logger.log(
-// LogService.LOG_ERROR, "Error occurred while executing selection", exception);
-// exception.printStackTrace();
-// loadSuccess = false;
-// }
-//
-// if ((data != null) && loadSuccess) {
-// this.logger.log(LogService.LOG_INFO, "Loaded: " + this.selectedFile.getPath());
-//
-// for (int ii = 0; ii < data.length; ii++) {
-// this.returnList.add(data[ii]);
-// }
-//
-// close(true);
-// } else {
-// this.logger.log(LogService.LOG_ERROR, "Unable to load with selected loader");
-// }
- }
-
- public void createDialogButtons(Composite parent) {
- Button select = new Button(parent, SWT.PUSH);
- select.setText("Select");
- select.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent selectionEvent) {
- int index = FileFormatSelector.this.validatorList.getSelectionIndex();
-
- if (index != -1) {
- selectionMade(index);
- }
- }
- });
- select.setFocus();
-
- Button cancel = new Button(parent, SWT.NONE);
- cancel.setText("Cancel");
- cancel.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent selectionEvent) {
- close(false);
- }
- });
- }
-
- public Composite createContent(Composite parent) {
- return initializeGUI(parent);
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|