Commit [aed6fb] Maximize Restore History

rewrote layout

added JFXUtils#addFadeEffect()
MultipleEntriesView now fully working with Pagination
added TranslationResource to provide mapping of current Translation to ResourceBundle
MaiNGUI now supports key-shortcuts and delegates them to active ComponentController
javafx-gui now supports localization
moved Categories_Tree to new ComponentController
added EntryAttributeProperty to provide (bidirectional) binding to an EntryAttribute

doe300 doe300 2014-07-13

1 2 > >> (Page 1 of 2)
added javaFX/mediaCenter/gui/javafx/components/table.fxml
changed javaFX/mediaCenter/gui/javafx/components/AddImportController.java
changed javaFX/mediaCenter/gui/javafx/components/BrowserController.java
changed javaFX/mediaCenter/gui/javafx/components/ComponentController.java
changed javaFX/mediaCenter/gui/javafx/components/EntryViewController.java
changed javaFX/mediaCenter/gui/javafx/components/NotificationsController.java
changed javaFX/mediaCenter/gui/javafx/components/StatusBarController.java
changed javaFX/mediaCenter/gui/javafx/components/TagCloudController.java
changed javaFX/mediaCenter/gui/javafx/components/addImport.fxml
changed javaFX/mediaCenter/gui/javafx/components/browser.fxml
changed javaFX/mediaCenter/gui/javafx/components/entryView.fxml
changed javaFX/mediaCenter/gui/javafx/components/notifications.fxml
changed javaFX/mediaCenter/gui/javafx/components/options.fxml
changed javaFX/mediaCenter/gui/javafx/components/slideshow.fxml
changed javaFX/mediaCenter/gui/javafx/components/statusBar.fxml
changed javaFX/mediaCenter/gui/javafx/components/tagCloud.fxml
changed javaFX/mediaCenter/gui/javafx/controls/InputControl.java
changed javaFX/mediaCenter/gui/javafx/view/EntryMediaView.java
changed javaFX/mediaCenter/gui/javafx/view/MultipleEntriesView.java
changed javaFX/mediaCenter/gui/javafx/wrappers/EntryWrapper.java
changed javaFX/mediaCenter/gui/javafx/wrappers/ParameterValueProperty.java
copied javaFX/mediaCenter/gui/javafx/components/TreeTableController.java -> javaFX/mediaCenter/gui/javafx/components/TableController.java
copied javaFX/mediaCenter/gui/javafx/components/treeTable.fxml -> javaFX/mediaCenter/gui/javafx/components/tree.fxml
javaFX/mediaCenter/gui/javafx/components/table.fxml Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/AddImportController.java Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/BrowserController.java Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/ComponentController.java Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/EntryViewController.java Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/NotificationsController.java Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/StatusBarController.java Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/TagCloudController.java Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/addImport.fxml Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/browser.fxml Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/entryView.fxml Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/notifications.fxml Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/options.fxml Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/slideshow.fxml Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/statusBar.fxml Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/tagCloud.fxml Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/controls/InputControl.java Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/view/EntryMediaView.java Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/view/MultipleEntriesView.java Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/wrappers/EntryWrapper.java Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/wrappers/ParameterValueProperty.java Diff Switch to side-by-side view
Loading...
javaFX/mediaCenter/gui/javafx/components/TreeTableController.java to javaFX/mediaCenter/gui/javafx/components/TableController.java
--- a/javaFX/mediaCenter/gui/javafx/components/TreeTableController.java
+++ b/javaFX/mediaCenter/gui/javafx/components/TableController.java
@@ -3,21 +3,16 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Comparator;
 import java.util.List;
 import java.util.ResourceBundle;
-import java.util.TreeSet;
 import javafx.application.Platform;
 import javafx.beans.property.ReadOnlyObjectWrapper;
 import javafx.beans.property.ReadOnlyStringWrapper;
 import javafx.fxml.FXML;
 import javafx.scene.control.SelectionMode;
-import javafx.scene.control.SplitPane;
 import javafx.scene.control.TableCell;
 import javafx.scene.control.TableColumn;
 import javafx.scene.control.TableView;
-import javafx.scene.control.TreeItem;
-import javafx.scene.control.TreeView;
 import javafx.scene.image.Image;
 import javafx.scene.image.ImageView;
 import javafx.scene.input.KeyCode;
@@ -27,11 +22,9 @@
 import mediaCenter.content.ViewContent;
 import mediaCenter.content.categories.Category;
 import mediaCenter.content.entries.Entry;
+import mediaCenter.content.entries.EntryUtilities;
 import mediaCenter.content.entries.attributes.EntryAttribute;
-import mediaCenter.data.Data;
-import mediaCenter.data.search.SearchEngine;
 import mediaCenter.data.search.SearchResult;
-import mediaCenter.data.search.Searchable;
 import mediaCenter.gui.javafx.JavaFXGUI;
 import mediaCenter.gui.javafx.wrappers.ContentWrapper;
 import mediaCenter.gui.javafx.wrappers.EntryWrapper;
@@ -42,51 +35,33 @@
  * @author daniel
  * @since 0.42
  */
-public class TreeTableController implements ComponentController
+public class TableController implements ComponentController
 {
-	private static final TableColumn<ViewContent,Image> iconC=new TableColumn<>("Image" );
-	private static final TableColumn<ViewContent,String> nameC=new TableColumn<>("Name" );
-	private static final TableColumn<ViewContent,String> tagsC=new TableColumn<>("Tags" );
-	private static final TableColumn<ViewContent,String> pathC=new TableColumn<>("Path" );
-	private static final TableColumn<ViewContent,String> metaC=new TableColumn<>("Meta" );
-	private static final TableColumn<ViewContent,Number> sizeC=new TableColumn<>("Size" );
-	private static final TableColumn<ViewContent,String> categoriesC=new TableColumn<>("Categories" );
-	
-	@FXML
-	private SplitPane root;
-	@FXML
-	private TreeView<Category> categoryTree;
+	@FXML
+	private TableColumn<ViewContent,Image> iconC;
+	@FXML
+	private TableColumn<ViewContent,String> nameC;
+	@FXML
+	private TableColumn<ViewContent,String> tagsC;
+	@FXML
+	private TableColumn<ViewContent,String> pathC;
+	@FXML
+	private TableColumn<ViewContent,String> metaC;
+	@FXML
+	private TableColumn<ViewContent,Number> sizeC;
+	@FXML
+	private TableColumn<ViewContent,String> categoriesC;
+	
 	@FXML
 	private TableView<ViewContent> mainTable;
 
-	/**
-	 * Initializes the controller class.
-	 */
 	@Override
 	public void initialize( URL url, ResourceBundle rb )
 	{
-		root.setUserData( this);
+		mainTable.setUserData( this);
 		//TODO columns for AntryAttributes
 
-		//XXX OnKeyTyped don't work on both
-		//add search to table
-		//XXX Tree throws StackOverflows in generateTree() on several potions
-		categoryTree.setOnKeyTyped( (KeyEvent e)->{
-			if(e.getCode()==KeyCode.ENTER)
-			{
-				TreeItem<Category> item=categoryTree.getSelectionModel().getSelectedItem();
-				SearchResult result=generateFolder( item );
-				JavaFXGUI.getMainController().showFolder( result );
-			}
-		});
-		categoryTree.setOnMouseClicked( (MouseEvent e)->{
-			if(e.getButton()==MouseButton.PRIMARY&&e.getClickCount()==2)
-			{
-				TreeItem<Category> item=categoryTree.getSelectionModel().getSelectedItem();
-				SearchResult result=generateFolder( item );
-				JavaFXGUI.getMainController().showFolder( result );
-			}
-		});
+		//XXX OnKeyTyped doesn't work
 		
 		//Table
 		mainTable.addEventFilter( KeyEvent.ANY, (KeyEvent e)->
@@ -95,16 +70,20 @@
 			if(e.getCode()==KeyCode.ENTER)
 			{
 				openTable( mainTable.getSelectionModel().getSelectedItems());
+				e.consume();
 			}
 		});
 		mainTable.setOnMouseClicked( (MouseEvent e)->{
 			if(e.getButton()==MouseButton.PRIMARY&&e.getClickCount()==2)
 			{
 				openTable(mainTable.getSelectionModel().getSelectedItem());
+				e.consume();
 			}
 		});
 		mainTable.getSelectionModel().setSelectionMode( SelectionMode.MULTIPLE );
+		
 		//XXX contextmenu
+		
 		//init columns
 		iconC.setCellValueFactory( (TableColumn.CellDataFeatures<ViewContent, Image> p) ->
 		{
@@ -135,7 +114,6 @@
 		{
 			return ContentWrapper.getNameProperty( p.getValue());
 		});
-		tagsC.setEditable( true);
 		tagsC.setCellValueFactory( (TableColumn.CellDataFeatures<ViewContent, String> p) ->
 		{
 			if(p.getValue() instanceof Entry)
@@ -176,15 +154,25 @@
 		{
 			return ContentWrapper.getSizeProperty( p.getValue());
 		});
-		//add
-		List<TableColumn<ViewContent,?>> columns=mainTable.getColumns();
-		columns.add( iconC );
-		columns.add( nameC);
-		columns.add( tagsC);
-		columns.add( pathC);
-		columns.add( metaC);
-		columns.add( categoriesC);
-		columns.add( sizeC);
+		sizeC.setCellFactory(( TableColumn<ViewContent, Number> p )->
+		{
+			return new TableCell<ViewContent,Number>()
+			{
+				@Override
+				protected void updateItem( Number t, boolean empty )
+				{
+					if(t!=null&&!empty)
+					{
+						setText( EntryUtilities.getFileSizeString( t.longValue()));
+					}
+					else
+					{
+						setText( "");
+					}
+				}
+			};
+		});
+		//XXX add custom Columns
 	}
 	
 	private void addAttributeColumn(EntryAttribute<?> att)
@@ -224,16 +212,6 @@
 		JavaFXGUI.getMainController().showFolder( JavaFXGUI.getMainController().getFolder().searchCategory(cat));
 	}
 	
-	//Generates SearchResult out of TreeView
-	private SearchResult generateFolder(TreeItem<Category> item)
-	{
-		if(item.getParent()==null)
-		{
-			return SearchEngine.searchCategory( Data.getData(), item.getValue());
-		}
-		return generateFolder(item.getParent()).searchCategory( item.getValue());
-	}
-	
 	@Override
 	public void setFolder( SearchResult folder, boolean show )
 	{
@@ -241,20 +219,6 @@
 		{
 			return;
 		}
-		//tree
-		Platform.runLater( ()->
-		{
-			TreeItem<Category> it=generateTree( folder );//XXX this is wrong, root must be Data
-			if(it==null)
-			{
-				return;
-			}
-			it.setExpanded( true);
-			categoryTree.setRoot( it );
-			//XXX set selection -> same problem as in swing??
-			//need to follow path of Searchable up to root
-			categoryTree.getSelectionModel().select( getForPath( it, folder));
-		});
 		if(folder==null)
 		{
 			return;
@@ -278,64 +242,6 @@
 		//XXX sometimes has refreshing-problems
 	}
 	
-	//XXX not sure, if it works
-	private TreeItem<Category> getForPath(TreeItem<Category> parent, Searchable path)
-	{
-		TreeItem<Category> item;
-		if(path.getParent()!=null)
-		{
-			//Need to walk up the Searchable-Tree up to root
-			item= getForPath( parent, path.getParent() );
-		}
-		else
-		{
-			item=parent;
-		}
-		List<TreeItem<Category>>l=item.getChildren().filtered( (TreeItem<Category> it)->
-		{
-			return it.getValue().equals( path.getSearchObject());
-		});
-		if(l.isEmpty())
-		{
-			return item;
-		}
-		return l.get(0);
-	}
-	
-	//Returns the root Item
-	private TreeItem<Category> generateTree(Searchable folder)
-	{
-		if(folder==null||!(folder.getSearchObject() instanceof Category))
-		{
-			return null;
-		}
-		Category cat=( Category ) folder.getSearchObject();
-		Collection<Category> cats=folder.getCategories();
-		TreeItem<Category> item=new TreeItem<>(cat );
-		if(!cats.isEmpty())
-		{
-			final Comparator<SearchResult> sorter=(SearchResult a, SearchResult b)-> {return b.getEntries().size()-a.getEntries().size();};
-			TreeSet<SearchResult> results=new TreeSet<>(sorter);
-			for(Category c:cats)
-			{
-			if(c.isSilentTag())
-			{
-				continue;
-			}
-			if(!c.isShowInRoot()&&folder.getSearchObject().equals( Category.ALL))
-			{
-				continue;
-			}
-			results.add( folder.searchCategory( c) );
-		}
-		for(SearchResult res:results)
-		{
-			item.getChildren().add( generateTree( res));
-		}
-		}
-		return item;
-	}
-	
 	@Override
 	public void cleanUp()
 	{
@@ -345,5 +251,63 @@
 	public void stopLoading()
 	{
 	}
+	
+	private long searchLastUpdated=0;
+	private static final long searchTimeout=3000; //3 secs.
+	private String searchString=null;
+
+	@Override
+	public boolean handleKeyEvent( KeyEvent e )
+	{
+		// If text input, type in search
+		if(e.getCode().isLetterKey()||e.getCode().isDigitKey()||e.getCode().isWhitespaceKey())
+		{
+			if(searchString==null || (System.currentTimeMillis()-searchLastUpdated)>searchTimeout)
+			{
+				searchString=e.getText();
+			}
+			else
+			{
+				searchString=searchString.concat( e.getText());
+			}
+			searchLastUpdated=System.currentTimeMillis();
+			//TODO search + somewhere display search string
+			e.consume();
+		}
+		//On Escape, clear search + unselect all
+		else if(e.getCode()==KeyCode.ESCAPE)
+		{
+			searchLastUpdated=0;
+			searchString=null;
+			mainTable.getSelectionModel().clearSelection();
+			e.consume();
+		}
+		//Del -> remove char from search or move up
+		else if(e.getCode()==KeyCode.BACK_SPACE)
+		{
+			if((System.currentTimeMillis()-searchLastUpdated)<searchTimeout)
+			{
+				searchLastUpdated=System.currentTimeMillis();
+				searchString=searchString.substring( 0, searchString.length()-2);
+			}
+			else
+			{
+				//move up
+				JavaFXGUI.getMainController().showFolder( JavaFXGUI.getMainController().getFolder().getParent());
+			}
+		}
+		//E -> edit Entry/Category
+		//Entf -> Delete
+		//T -> edit tags
+		//m -> context-menu
+		//TODO
+		return e.isConsumed();
+	}
+	
+	@FXML
+	private void editTags(TableColumn.CellEditEvent<ViewContent,String> e)
+	{
+		System.err.println( e );
+	}
 }
 
javaFX/mediaCenter/gui/javafx/components/treeTable.fxml to javaFX/mediaCenter/gui/javafx/components/tree.fxml
--- a/javaFX/mediaCenter/gui/javafx/components/treeTable.fxml
+++ b/javaFX/mediaCenter/gui/javafx/components/tree.fxml
@@ -6,9 +6,8 @@
 <?import javafx.scene.*?>
 <?import javafx.scene.control.*?>
 <?import javafx.scene.layout.*?>
-<SplitPane fx:id="root" dividerPositions="0.3" xmlns:fx="http://javafx.com/fxml" fx:controller="mediaCenter.gui.javafx.components.TreeTableController">
-	<items>
-		<TreeView fx:id="categoryTree" editable="false" showRoot="true" />
-		<TableView fx:id="mainTable" />
-	</items>
-</SplitPane>+<TreeView id="vCategories" fx:id="categoryTree" editable="false" showRoot="true" styleClass="categoriesTree" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mediaCenter.gui.javafx.components.CategoriesTreeController">
+	<stylesheets>
+		<URL value="@../main.css"/>
+	</stylesheets>
+</TreeView>
1 2 > >> (Page 1 of 2)