You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2013/02/19 18:04:22 UTC
[24/51] [abbrv] libraries/ compiling
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/dialog/task/design/TaskDialogContent.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/dialog/task/design/TaskDialogContent.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/dialog/task/design/TaskDialogContent.java
new file mode 100644
index 0000000..8d9890e
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/dialog/task/design/TaskDialogContent.java
@@ -0,0 +1,385 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.dialog.task.design;
+
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.KeyStroke;
+import javax.swing.SwingUtilities;
+import javax.swing.Timer;
+import javax.swing.UIManager;
+
+import net.miginfocom.swing.MigLayout;
+
+import org.oxbow.swingbits.dialog.task.IContentDesign;
+import org.oxbow.swingbits.dialog.task.TaskDialog;
+import org.oxbow.swingbits.util.Markup;
+import org.oxbow.swingbits.util.Strings;
+import org.oxbow.swingbits.util.swing.Icons;
+
+public class TaskDialogContent extends JPanel implements TaskDialog.Details, TaskDialog.Footer {
+
+ private static final long serialVersionUID = 1L;
+
+ final JLabel lbIcon = hidden( new JLabel());
+ final JLabel lbInstruction = hidden( new JLabel());
+ final JLabel lbText = hidden( new JLabel());
+ final JPanel pExpandable = hidden( new JPanel( new BorderLayout()));
+ final JPanel pComponent = hidden( new JPanel( new BorderLayout()));
+
+ final DetailsToggleButton cbDetails = hidden( new DetailsToggleButton());
+ final JCheckBox cbFooterCheck = hidden( new JCheckBox());
+ final JLabel lbFooter = hidden( new JLabel());
+ final JPanel pCommands = new JPanel( new MigLayout( "ins 0, nogrid, fillx, aligny 100%, gapy unrel" ));
+ final JPanel pFooter = hidden( new JPanel( new MigLayout()));
+ final JPanel pCommandPane = new JPanel( new MigLayout());
+
+ private final String[] detailsText = new String[2];
+ private String instruction = null;
+ private String text;
+ private boolean alwaysExpanded;
+
+ private static <T extends JComponent> T hidden( T c ) {
+ c.setVisible(false);
+ return c;
+ }
+
+ public TaskDialogContent() {
+
+ pExpandable.setOpaque(false);
+ pComponent.setOpaque(false);
+
+ cbDetails.addItemListener( new ItemListener() {
+
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+
+ final boolean selected = e.getStateChange() == ItemEvent.SELECTED;
+
+ cbDetails.setText( selected? getExpandedLabel():getCollapsedLabel() );
+ SwingUtilities.invokeLater( new Runnable(){
+
+ @Override
+ public void run() {
+ pExpandable.setVisible(selected);
+ SwingUtilities.getWindowAncestor(TaskDialogContent.this).pack();
+ }}
+ );
+
+ }
+ });
+
+
+ }
+
+
+ public void setInstruction( String instruction ) {
+ this.instruction = instruction;
+
+ boolean visible = instruction != null && instruction.trim().length() > 0;
+ lbInstruction.setVisible(visible);
+ if (visible) lbInstruction.setText( Markup.toHTML(instruction) );
+ }
+
+ public String getInstruction() {
+ return instruction;
+ }
+
+ public void setCommands( Set<? extends TaskDialog.Command> commands, boolean lockButtonSize ) {
+
+ pCommands.removeAll();
+
+ String group = lockButtonSize? "sgx commands, ": "";
+ TaskDialog owner = getOwner();
+ for( final TaskDialog.Command c: commands) {
+ String tag = c.getTag() == null? "": c.getTag().toString();
+ JButton button = new JButton( new CommandAction(c, owner) );
+ pCommands.add( button, group + "aligny top, " + tag );
+ }
+
+ }
+
+ public boolean isCommandsVisible() {
+ return pCommandPane.isVisible();
+ }
+
+ public void setCommandsVisible( boolean visible ) {
+ pCommandPane.setVisible(visible);
+ }
+
+ public void setMainText( String text ) {
+ this.text = text;
+ boolean isEmtpy = Strings.isEmpty(text);
+ lbText.setText( Markup.toHTML(text) );
+ lbText.setVisible( !isEmtpy );
+ }
+
+ public String getMainText() {
+ return text;
+ }
+
+ private TaskDialog getOwner() {
+ return TaskDialog.getInstance(this);
+ }
+
+ @Override
+ public String getCollapsedLabel() {
+ return Strings.isEmpty( detailsText[0])?
+ getOwner().getString( UIManager.getString(IContentDesign.TEXT_MORE_DETAILS)): detailsText[0];
+ }
+
+ @Override
+ public void setCollapsedLabel(String collapsedLabel) {
+ detailsText[0] = collapsedLabel;
+ }
+
+ @Override
+ public String getExpandedLabel() {
+ return Strings.isEmpty(detailsText[1])?
+ getOwner().getString(UIManager.getString(IContentDesign.TEXT_FEWER_DETAILS)): detailsText[1];
+ }
+
+ @Override
+ public void setExpandedLabel(String expandedLabel) {
+ detailsText[1] = expandedLabel;
+ }
+
+ @Override
+ public JComponent getExpandableComponent() {
+ return pExpandable.getComponentCount() == 0? null: (JComponent)pExpandable.getComponent(0);
+ }
+
+ @Override
+ public void setExpandableComponent(JComponent c) {
+ pExpandable.removeAll();
+ if ( c != null ) pExpandable.add( c );
+ cbDetails.setVisible(c != null && !alwaysExpanded);
+ }
+
+ @Override
+ public boolean isExpanded() {
+ return cbDetails.isSelected();
+ }
+
+ @Override
+ public void setExpanded(boolean expanded) {
+ cbDetails.setSelected( !expanded );
+ cbDetails.setSelected( expanded );
+ pExpandable.setVisible(expanded);
+ }
+
+ @Override
+ public void setAlwaysExpanded( boolean alwaysExpanded ) {
+ if (alwaysExpanded) {
+ setExpanded(true);
+ }
+ cbDetails.setVisible(getExpandableComponent() != null && !alwaysExpanded);
+ this.alwaysExpanded = alwaysExpanded;
+ }
+
+ @Override
+ public boolean isAlwaysExpanded() {
+ return alwaysExpanded;
+ }
+
+ @Override
+ public String getCheckBoxText() {
+ return cbFooterCheck.getText();
+ }
+
+ private Icon icon;
+
+
+ public void setMainIcon( Icon icon ) {
+ lbIcon.setVisible( icon != null );
+ lbIcon.setIcon(icon);
+ }
+
+ public Icon getMainIcon() {
+ return lbIcon.getIcon();
+ }
+
+ @Override
+ public Icon getIcon() {
+ return icon;
+ }
+
+ @Override
+ public void setIcon(Icon icon) {
+ this.icon = icon; // stored to preserve actual size
+ lbFooter.setIcon( Icons.scale(icon, 16, 16));
+ }
+
+ @Override
+ public String getText() {
+ return lbFooter.getText();
+ }
+
+ @Override
+ public void setText(String text) {
+ boolean footerLabelVisible = !Strings.isEmpty(text);
+ pFooter.setVisible( footerLabelVisible );
+ lbFooter.setVisible(footerLabelVisible);
+ lbFooter.setText(Markup.toHTML(text));
+ }
+
+ public void setComponent( JComponent c ) {
+ pComponent.removeAll();
+ if ( c != null ) pComponent.add( c );
+ pComponent.setVisible(c != null);
+ }
+
+ public JComponent getComponent() {
+ return pComponent.getComponentCount() == 0? null: (JComponent)pComponent.getComponent(0);
+ }
+
+ @Override
+ public boolean isCheckBoxSelected() {
+ return cbFooterCheck.isVisible() && cbFooterCheck.isSelected();
+ }
+
+ @Override
+ public void setCheckBoxSelected(boolean selected) {
+ cbFooterCheck.setSelected(selected);
+ }
+
+ @Override
+ public void setCheckBoxText(String text) {
+ cbFooterCheck.setVisible( !Strings.isEmpty( text ) );
+ cbFooterCheck.setText( text == null? "": text );
+ }
+
+ class CommandAction extends AbstractAction implements TaskDialog.ValidationListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private final TaskDialog.Command command;
+ private final TaskDialog dlg;
+ private Timer timer;
+ private int counter;
+
+ public CommandAction( TaskDialog.Command command, TaskDialog dlg ) {
+ super( dlg.getString( command.getTitle()) );
+
+ this.command = command;
+ this.dlg = dlg;
+ this.counter = command.getWaitInterval();
+
+ // setup default keystrokes
+ KeyStroke keyStroke = command.getKeyStroke();
+ if ( keyStroke != null ) {
+ String actionID = "TaskDialog.Command." + UUID.randomUUID().toString();
+ TaskDialogContent.this.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(keyStroke,actionID);
+ TaskDialogContent.this.getActionMap().put(actionID,this);
+ }
+
+
+ dlg.addValidationListener(this);
+
+ putValue( Action.NAME, getTitle() );
+
+ if ( counter > 0 ) {
+
+ setEnabled( false );
+
+ timer = new Timer(1000, new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ tick();
+ }
+
+ });
+
+ dlg.addPropertyListener("visible", new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent e) {
+ if ( Boolean.TRUE.equals(e.getNewValue())) {
+ timer.start();
+ }
+ }
+ });
+ }
+
+ }
+
+ @Override
+ public void validationFinished(boolean validationResult) {
+
+ setEnabled( command.isEnabled(validationResult) );
+
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ dlg.setResult( command );
+ if ( command.isClosing() ) dlg.setVisible(false);
+
+ }
+
+ private String getTitle() {
+ String title = dlg.getString( command.getTitle());
+ return counter > 0? String.format( "%s (%d)", title, counter): title;
+ }
+
+ private void tick() {
+ if ( --counter <= 0 ) {
+ timer.stop();
+ }
+ putValue( Action.NAME, getTitle() );
+ setEnabled(counter <= 0);
+ }
+
+ }
+
+
+}
+
+
+
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/dialog/task/design/WindowsCommandLinkPainter.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/dialog/task/design/WindowsCommandLinkPainter.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/dialog/task/design/WindowsCommandLinkPainter.java
new file mode 100644
index 0000000..b7c893d
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/dialog/task/design/WindowsCommandLinkPainter.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.dialog.task.design;
+
+import java.awt.Color;
+
+public class WindowsCommandLinkPainter extends DefaultCommandLinkPainter {
+
+ private LinkChrome selectedChrome = new LinkChrome(
+ new Color(0xFBFBFC),
+ new Color(0xE6E6E6),
+ new Color(0xDADADA),
+ 1, 7 );
+
+ private LinkChrome armedChrome = new LinkChrome(
+ new Color(0xFCFDFF),
+ new Color(0xEDF5FF),
+ new Color(0xB9D7FC),
+ 1, 7 );
+
+ private LinkChrome rolloverChrome = new LinkChrome(
+ new Color(0xFCFDFF),
+ new Color(0xEDF5FF),
+ new Color(0xB9D7FC),
+ 1, 7 );
+
+ protected LinkChrome getLinkChrome( LinkState linkState ) {
+ switch( linkState ) {
+ case SELECTED: return selectedChrome;
+ case ARMED : return armedChrome;
+ case ROLLOVER: return rolloverChrome;
+ default : return selectedChrome;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/dialog/task/design/WindowsContentDesign.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/dialog/task/design/WindowsContentDesign.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/dialog/task/design/WindowsContentDesign.java
new file mode 100644
index 0000000..cd05367
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/dialog/task/design/WindowsContentDesign.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.dialog.task.design;
+
+import java.awt.Color;
+import java.awt.Font;
+
+import javax.swing.UIManager;
+
+import org.oxbow.swingbits.dialog.task.ICommandLinkPainter;
+
+public class WindowsContentDesign extends DefaultContentDesign {
+
+ @Override
+ public void updateUIDefaults() {
+
+ super.updateUIDefaults();
+
+ UIManager.put( COLOR_INSTRUCTION_FOREGROUND, new Color(0x0033A0));
+
+ Font fontBase = new Font("Segoe UI", 0, 11);
+ UIManager.put( FONT_INSTRUCTION,
+ fontBase.deriveFont( fontBase.getStyle(), fontBase.getSize2D() * 1.4f ) );
+
+ }
+
+
+ @Override
+ public ICommandLinkPainter getCommandLinkPainter() {
+ if (commandButtonPainter == null) {
+ commandButtonPainter = new WindowsCommandLinkPainter();
+ }
+ return commandButtonPainter;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/ActionCheckListModel.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/ActionCheckListModel.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/ActionCheckListModel.java
new file mode 100644
index 0000000..b12e726
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/ActionCheckListModel.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.list;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+
+import org.oxbow.swingbits.util.IObjectToStringTranslator;
+
+public class ActionCheckListModel<T> implements ICheckListModel<T> {
+
+ private final List<ListDataListener> listeners = Collections.synchronizedList( new ArrayList<ListDataListener>());
+ private final ICheckListModel<T> originalModel;
+
+ private final ICheckListAction<T> actionCheckAll = new ICheckListAction.CheckAll<T>();
+
+ @SuppressWarnings("unchecked")
+ private final List<ICheckListAction<T>> actionItems = Arrays.asList( actionCheckAll );
+ private final Set<ICheckListAction<T>> checks = new HashSet<ICheckListAction<T>>();
+
+ public ActionCheckListModel( final ICheckListModel<T> originalModel ) {
+
+ if ( originalModel == null ) throw new NullPointerException();
+ this.originalModel = originalModel;
+
+ //react on original model changes
+ this.originalModel.addListDataListener( new ListDataListener () {
+
+ @Override
+ public void intervalAdded(ListDataEvent e) {
+ ListDataEvent event = toDecoratedEvent(e);
+ for( ListDataListener l: listeners ) {
+ l.intervalAdded(event);
+ }
+ }
+
+ @Override
+ public void intervalRemoved(ListDataEvent e) {
+ ListDataEvent event = toDecoratedEvent(e);
+ for( ListDataListener l: listeners ) {
+ l.intervalRemoved(event);
+ }
+ }
+
+ @Override
+ public void contentsChanged(ListDataEvent e) {
+ ListDataEvent event = toDecoratedEvent(e);
+ for( ListDataListener l: listeners ) {
+ l.contentsChanged(event);
+ }
+ if ( originalModel.getCheckedItems().size() < originalModel.getSize() ) {
+ checks.remove(actionCheckAll);
+ } else {
+ checks.add(actionCheckAll);
+ }
+ fireListDataChanged();
+ }
+ });
+ }
+
+ @Override
+ public int getSize() {
+ return originalModel.getSize() + actionItems.size();
+ }
+
+ @Override
+ public Object getElementAt(int index) {
+ if ( isDecoratedIndex(index)) {
+ return actionItems.get(index);
+ } else {
+ return originalModel.getElementAt( toOriginalIndex(index));
+ }
+ }
+
+ private int toOriginalIndex( int index ) {
+ return index - actionItems.size();
+ }
+
+ private int toDecoratedIndex( int index ) {
+ return index + actionItems.size();
+ }
+
+ private boolean isDecoratedIndex( int index ) {
+ int size = actionItems.size();
+ return size > 0 && index >= 0 && index < size;
+ }
+
+
+ @Override
+ public void addListDataListener(ListDataListener l) {
+ listeners.add(l);
+ }
+
+ @Override
+ public void removeListDataListener(ListDataListener l) {
+ listeners.remove(l);
+ }
+
+ private void fireListDataChanged() {
+ ListDataEvent e = new ListDataEvent( this, 0, 0, getSize() );
+ for( ListDataListener l: listeners ) {
+ l.contentsChanged(e);
+ }
+ }
+
+ private ListDataEvent toDecoratedEvent( ListDataEvent e ) {
+ return new ListDataEvent(
+ e.getSource(),
+ e.getType(),
+ toDecoratedIndex(e.getIndex0()),
+ toDecoratedIndex(e.getIndex1()));
+ }
+
+ @Override
+ public boolean isCheckedIndex(int index) {
+ if ( isDecoratedIndex(index)) {
+ return checks.contains(actionItems.get(index));
+ } else {
+ return originalModel.isCheckedIndex( toOriginalIndex(index));
+ }
+
+ }
+
+ @Override
+ public void setCheckedIndex(int index, boolean value) {
+ if ( isDecoratedIndex(index)) {
+ ICheckListAction<T> item = actionItems.get(index);
+ item.check(originalModel, value);
+ if ( value ) checks.add(item); else checks.remove(item);
+ fireListDataChanged();
+ } else {
+ originalModel.setCheckedIndex( toOriginalIndex(index), value);
+ }
+ }
+
+ @Override
+ public Collection<T> getCheckedItems() {
+ return originalModel.getCheckedItems();
+ }
+
+ @Override
+ public void setCheckedItems(Collection<T> items) {
+ originalModel.setCheckedItems(items);
+ }
+
+ @Override
+ public void filter(String filter, IObjectToStringTranslator translator, CheckListFilterType filterType) {
+ originalModel.filter(filter, translator, filterType);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckList.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckList.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckList.java
new file mode 100644
index 0000000..bf4983e
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckList.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.list;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseListener;
+import java.util.Collection;
+
+import javax.swing.AbstractAction;
+import javax.swing.JList;
+import javax.swing.KeyStroke;
+import javax.swing.ListSelectionModel;
+
+import org.oxbow.swingbits.util.IObjectToStringTranslator;
+
+/**
+ * The decorator for JList which makes it work like check list
+ * UI can be designed using JList and which can be later decorated to become a check list
+ * @author Eugene Ryzhikov
+ *
+ * @param <T> list item type
+ */
+public class CheckList<T> {
+
+ private final JList list;
+ private static final MouseAdapter checkBoxEditor = new CheckListEditor();
+
+ public static class Builder {
+
+ private JList list;
+
+ public Builder( JList list ) {
+ this.list = list == null? new JList(): list;
+ }
+
+ public Builder() {
+ this( null );
+ }
+
+ public <T> CheckList<T> build() {
+ return new CheckList<T>(list);
+ }
+
+ }
+
+
+ /**
+ * Wraps the standard JList and makes it work like check list
+ * @param list
+ */
+ private CheckList(final JList list) {
+
+ if (list == null) throw new NullPointerException();
+ this.list = list;
+ this.list.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_SELECTION);
+
+ if ( !isEditorAttached() ) list.addMouseListener(checkBoxEditor);
+ this.list.setCellRenderer(new CheckListRenderer());
+
+ setupKeyboardActions(list);
+
+ }
+
+ @SuppressWarnings("serial")
+ private void setupKeyboardActions(final JList list) {
+ String actionKey = "toggle-check";
+ list.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE,0), actionKey);
+ list.getActionMap().put(actionKey, new AbstractAction(){
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ toggleIndex(list.getSelectedIndex());
+ }});
+ }
+
+ private boolean isEditorAttached() {
+
+ for( MouseListener ml: list.getMouseListeners() ) {
+ if ( ml instanceof CheckListEditor ) return true;
+ }
+ return false;
+
+ }
+
+ public JList getList() {
+ return list;
+ }
+
+ /**
+ * Sets data to a check list. Simplification for setting new the model
+ * @param data
+ */
+ public void setData( Collection<T> data ) {
+ setModel( new DefaultCheckListModel<T>(data));
+ }
+
+ /**
+ * Sets the model for check list.
+ * @param model
+ */
+ public void setModel( ICheckListModel<T> model ) {
+ list.setModel(model);
+ }
+
+ @SuppressWarnings("unchecked")
+ public ICheckListModel<T> getModel() {
+ return (ICheckListModel<T>) list.getModel();
+ }
+
+ /**
+ * Returns a collection of checked items.
+ * @return collection of checked items. Empty collection if nothing is selected
+ */
+ public Collection<T> getCheckedItems() {
+ return getModel().getCheckedItems();
+ }
+
+ /**
+ * Resets checked elements
+ * @param elements
+ */
+ public void setCheckedItems( Collection<T> elements ) {
+ getModel().setCheckedItems(elements);
+ }
+
+ /**
+ * Filters list view without losing actual data
+ * @param filter
+ * @param translator
+ */
+ public void filter( String filter, IObjectToStringTranslator translator, CheckListFilterType filterType ) {
+ getModel().filter(filter, translator, filterType);
+ }
+
+ public void toggleIndex( int index ) {
+ if ( index >= 0 && index < list.getModel().getSize()) {
+ ICheckListModel<T> model = getModel();
+ model.setCheckedIndex(index, !model.isCheckedIndex(index));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckListEditor.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckListEditor.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckListEditor.java
new file mode 100644
index 0000000..86beab8
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckListEditor.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.list;
+
+import java.awt.Rectangle;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.Arrays;
+
+import javax.swing.JList;
+import javax.swing.SwingUtilities;
+
+
+/**
+ * Determines mouse click and
+ * 1. Toggles the check on selected item if clicked once
+ * 2. Clears checks and checks selected item if clicked more then once
+ *
+ * Created on Feb 4, 2011
+ * @author Eugene Ryzhikov
+ *
+ */
+final class CheckListEditor extends MouseAdapter {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+
+ if (!SwingUtilities.isLeftMouseButton(e)) return;
+
+ JList list = (JList) e.getSource();
+ if ( !list.isEnabled() || (!(list.getModel() instanceof ICheckListModel<?>))) return;
+
+ int index = list.locationToIndex(e.getPoint());
+ if (index < 0) return;
+
+ Rectangle bounds = list.getCellBounds(index, index);
+
+ if ( bounds.contains(e.getPoint()) ) {
+
+ @SuppressWarnings("unchecked")
+ ICheckListModel<Object> model = (ICheckListModel<Object>) list.getModel();
+
+ if ( e.getClickCount() > 1 ) {
+ // clear all and check selected for more then 1 clicks
+ model.setCheckedItems( Arrays.asList( model.getElementAt(index)));
+ } else {
+ // simple toggle for 1 click
+ model.setCheckedIndex(index, !model.isCheckedIndex(index));
+ }
+ e.consume();
+ }
+
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckListFilterType.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckListFilterType.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckListFilterType.java
new file mode 100644
index 0000000..80f433c
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckListFilterType.java
@@ -0,0 +1,31 @@
+package org.oxbow.swingbits.list;
+
+public enum CheckListFilterType {
+
+ STARTS_WITH {
+
+ @Override
+ public boolean include( String element, String filter ) {
+
+ if ( element == null || filter == null ) return false;
+ return element.startsWith(filter);
+
+ }
+
+ },
+
+ CONTAINS {
+
+ @Override
+ public boolean include( String element, String filter ) {
+
+ if ( element == null || filter == null ) return false;
+ return element.contains(filter);
+
+ }
+
+ };
+
+ public abstract boolean include( String element, String filter );
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckListRenderer.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckListRenderer.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckListRenderer.java
new file mode 100644
index 0000000..c9527a6
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/CheckListRenderer.java
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.list;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Rectangle;
+import java.io.Serializable;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.Icon;
+import javax.swing.JCheckBox;
+import javax.swing.JList;
+import javax.swing.ListCellRenderer;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+import javax.swing.border.EmptyBorder;
+
+public class CheckListRenderer extends JCheckBox implements ListCellRenderer, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Border NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1);
+ private static final Border SAFE_NO_FOCUS_BORDER = NO_FOCUS_BORDER; // may change in the feature
+
+ /**
+ * Constructs a default renderer object for an item in a list.
+ */
+ public CheckListRenderer() {
+ super();
+ setOpaque(true);
+ setBorder(getNoFocusBorder());
+ }
+
+ private static Border getNoFocusBorder() {
+ if (System.getSecurityManager() != null) {
+ return SAFE_NO_FOCUS_BORDER;
+ } else {
+ return NO_FOCUS_BORDER;
+ }
+ }
+
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
+ boolean cellHasFocus) {
+
+ setComponentOrientation(list.getComponentOrientation());
+
+ Color bg = null;
+ Color fg = null;
+
+ JList.DropLocation dropLocation = list.getDropLocation();
+ if (dropLocation != null && !dropLocation.isInsert() && dropLocation.getIndex() == index) {
+
+ bg = UIManager.getColor("List.dropCellBackground");
+ fg = UIManager.getColor("List.dropCellForeground");
+
+ isSelected = true;
+ }
+
+ if (isSelected) {
+ setBackground(bg == null ? list.getSelectionBackground() : bg);
+ setForeground(fg == null ? list.getSelectionForeground() : fg);
+ } else {
+ setBackground(list.getBackground());
+ setForeground(list.getForeground());
+ }
+
+ if (value instanceof Icon) {
+ setIcon((Icon) value);
+ setText("");
+ } else {
+ setIcon(null);
+ setText(getObjectAsText(value));
+ }
+
+ setSelected( isChecked(list, index));
+
+ setEnabled(list.isEnabled());
+ setFont(list.getFont());
+
+ Border border = null;
+ if (cellHasFocus) {
+ if (isSelected) {
+ border = UIManager.getBorder("List.focusSelectedCellHighlightBorder");
+ }
+ if (border == null) {
+ border = UIManager.getBorder("List.focusCellHighlightBorder");
+ }
+ } else {
+ border = getNoFocusBorder();
+ }
+ setBorder(border);
+
+ return this;
+ }
+
+ protected String getObjectAsText(Object obj) {
+ return (obj == null) ? "" : obj.toString();
+ }
+
+ private boolean isChecked(JList list, int index) {
+
+ if (list.getModel() instanceof ICheckListModel<?>) {
+ return ((ICheckListModel<?>) list.getModel()).isCheckedIndex(index);
+ } else {
+ return false;
+ }
+
+ }
+
+ /**
+ * @return true if the background is opaque and differs from the JList's background; false otherwise
+ */
+ @Override
+ public boolean isOpaque() {
+ Color back = getBackground();
+ Component p = getParent();
+ if (p != null) {
+ p = p.getParent();
+ }
+ // p should now be the JList.
+ boolean colorMatch = (back != null) && (p != null) && back.equals(p.getBackground()) && p.isOpaque();
+ return !colorMatch && super.isOpaque();
+ }
+
+ @Override
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+
+ if ("text".equals(propertyName) ||
+ (("font".equals(propertyName) || "foreground".equals(propertyName)) &&
+ oldValue != newValue && getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey) != null)) {
+
+ super.firePropertyChange(propertyName, oldValue, newValue);
+ }
+ }
+
+ // Methods below are overridden for performance reasons.
+
+ @Override
+ public void validate() {
+ }
+
+ @Override
+ public void invalidate() {
+ }
+
+ @Override
+ public void repaint() {
+ }
+
+ @Override
+ public void revalidate() {
+ }
+
+ @Override
+ public void repaint(long tm, int x, int y, int width, int height) {
+ }
+
+ @Override
+ public void repaint(Rectangle r) {
+ }
+
+ @Override
+ public void firePropertyChange(String propertyName, byte oldValue, byte newValue) {
+ }
+
+ @Override
+ public void firePropertyChange(String propertyName, char oldValue, char newValue) {
+ }
+
+ @Override
+ public void firePropertyChange(String propertyName, short oldValue, short newValue) {
+ }
+
+ @Override
+ public void firePropertyChange(String propertyName, int oldValue, int newValue) {
+ }
+
+ @Override
+ public void firePropertyChange(String propertyName, long oldValue, long newValue) {
+ }
+
+ @Override
+ public void firePropertyChange(String propertyName, float oldValue, float newValue) {
+ }
+
+ @Override
+ public void firePropertyChange(String propertyName, double oldValue, double newValue) {
+ }
+
+ @Override
+ public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {
+ }
+
+ @SuppressWarnings("serial")
+ public static class UIResource extends DefaultListCellRenderer implements javax.swing.plaf.UIResource {
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/DefaultCheckListModel.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/DefaultCheckListModel.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/DefaultCheckListModel.java
new file mode 100644
index 0000000..b1676b7
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/DefaultCheckListModel.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.list;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.swing.AbstractListModel;
+
+import org.oxbow.swingbits.util.DefaultObjectToStringTranslator;
+import org.oxbow.swingbits.util.IObjectToStringTranslator;
+import org.oxbow.swingbits.util.IValueWrapper;
+
+/**
+ * Default model for check list. It is based on the list of items
+ * Implementation of checks is based on HashSet of checked items
+ *
+ * @author Eugene Ryzhikov
+ *
+ * @param <T> list element type
+ */
+public class DefaultCheckListModel<T> extends AbstractListModel implements ICheckListModel<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final List<T> data = new ArrayList<T>();
+ private final Set<T> checks = new HashSet<T>();
+
+ public static IObjectToStringTranslator DEFAULT_TRANSLATOR = new DefaultObjectToStringTranslator();
+ private List<T> filteredData = null;
+
+ public DefaultCheckListModel( Collection<? extends T> data ) {
+
+ if ( data == null ) return;
+ for (T object : data) {
+ this.data.add( object );
+ checks.clear();
+ }
+ }
+
+ public DefaultCheckListModel( T... data ) {
+ this( Arrays.asList( data ));
+ }
+
+ /* (non-Javadoc)
+ * @see org.oxbow.swingbits.list.ICheckListModel#getSize()
+ */
+ @Override
+ public int getSize() {
+ return data().size();
+ }
+
+ private List<T> data() {
+ return filteredData == null? data: filteredData;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.oxbow.swingbits.list.ICheckListModel#getElementAt(int)
+ */
+ @Override
+ public Object getElementAt(int index) {
+ return data().get(index);
+ }
+
+ /* (non-Javadoc)
+ * @see org.oxbow.swingbits.list.ICheckListModel#isChecked(int)
+ */
+ @Override
+ public boolean isCheckedIndex( int index ) {
+ return checks.contains( data().get(index));
+ }
+
+ /* (non-Javadoc)
+ * @see org.oxbow.swingbits.list.ICheckListModel#setChecked(int, boolean)
+ */
+ @Override
+ public void setCheckedIndex( int index, boolean value ) {
+ T o = data().get(index);
+ if ( value ) checks.add(o); else checks.remove(o);
+ fireContentsChanged(this, index, index);
+ }
+
+ /* (non-Javadoc)
+ * @see org.oxbow.swingbits.list.ICheckListModel#getChecked()
+ */
+ @Override
+ public Collection<T> getCheckedItems() {
+ List<T> items = new ArrayList<T>(checks);
+ items.retainAll(data);
+ return Collections.unmodifiableList( items );
+ }
+
+ /* (non-Javadoc)
+ * @see org.oxbow.swingbits.list.ICheckListModel#setChecked(java.util.Collection)
+ */
+ @Override
+ public void setCheckedItems( Collection<T> items ) {
+
+// if ( CollectionUtils.isEmpty(items)) return;
+
+ List<T> correctedItems = new ArrayList<T>(items);
+ correctedItems.retainAll(data);
+
+ checks.clear();
+ checks.addAll( correctedItems );
+ fireContentsChanged(this, 0, checks.size()-1);
+
+
+ }
+
+ public void filter( String filter, IObjectToStringTranslator translator, CheckListFilterType filterType ) {
+
+ if ( filter == null || filter.trim().length() == 0 ) {
+ filteredData = null;
+ } else {
+
+ CheckListFilterType ft = filterType == null? CheckListFilterType.CONTAINS: filterType;
+
+ IObjectToStringTranslator t = translator == null? DEFAULT_TRANSLATOR: translator;
+ String f = filter.toLowerCase();
+
+ List<T> fData = new ArrayList<T>();
+
+ Object value;
+ for( T o: data ) {
+ //if ( t.translate(o).startsWith(f)) {
+ value = o instanceof IValueWrapper? ((IValueWrapper<?>)o).getValue(): o;
+ if ( ft.include(t.translate(value), f)) {
+ fData.add(o);
+ }
+ }
+ filteredData = fData;
+ }
+
+ fireContentsChanged( this, 0, data.size()-1);
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/ICheckListAction.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/ICheckListAction.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/ICheckListAction.java
new file mode 100644
index 0000000..57804ef
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/ICheckListAction.java
@@ -0,0 +1,33 @@
+package org.oxbow.swingbits.list;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+
+public interface ICheckListAction<T> {
+
+ void check( ICheckListModel<T> model, boolean value );
+
+ public static class CheckAll<T> implements ICheckListAction<T> {
+
+ @Override
+ public String toString() {
+ return "(All)";
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void check(ICheckListModel<T> model, boolean value) {
+ Collection<T> items = new ArrayList<T>();
+ if (value) {
+ for( int i=0, s=model.getSize(); i<s; i++ ) {
+ items.add((T) model.getElementAt(i));
+ }
+ }
+ model.setCheckedItems( items );
+
+ }
+
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/ICheckListModel.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/ICheckListModel.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/ICheckListModel.java
new file mode 100644
index 0000000..95bb118
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/list/ICheckListModel.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.list;
+
+import java.util.Collection;
+
+import javax.swing.ListModel;
+
+import org.oxbow.swingbits.util.IObjectToStringTranslator;
+
+public interface ICheckListModel<T> extends ListModel{
+
+ /**
+ * Returns the check state of the element at specified position
+ * @param index element index
+ * @return true if element at specified position is checked
+ * @throws IndexOutOfBoundsException if index is out of range
+ */
+ boolean isCheckedIndex(int index);
+
+ /**
+ * Sets the check state of the element at specified position
+ * @param index element index
+ * @param value
+ * @throws IndexOutOfBoundsException if index is out of range
+ */
+ void setCheckedIndex(int index, boolean value);
+
+ /**
+ * Returns a collections of checked items
+ * @return
+ */
+ Collection<T> getCheckedItems();
+
+ /**
+ * Sets checked items
+ * @param items
+ */
+ void setCheckedItems(Collection<T> items);
+
+ /**
+ * Allows filtered view. Setting empty or null filter will clear filter and show all items
+ * @param filter filter string
+ * @param translator object to string translator to aid the search
+ */
+ void filter( String filter, IObjectToStringTranslator translator, CheckListFilterType filterType );
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/misc/JSearchTextField.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/misc/JSearchTextField.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/misc/JSearchTextField.java
new file mode 100644
index 0000000..e973de4
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/misc/JSearchTextField.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.misc;
+
+import java.awt.Graphics;
+import java.awt.Image;
+
+import javax.swing.ImageIcon;
+import javax.swing.JTextField;
+
+/**
+ * A text field with search symbol painted to indicate
+ * that it is used as search field
+ *
+ * @author Eugene Ryzhikov
+ *
+ */
+public class JSearchTextField extends JTextField {
+
+ private static final String ICON_NAME = "search.png";
+ private static final long serialVersionUID = 1L;
+
+ private static ImageIcon icon;
+
+ private static Image getScaledImage( int size ) {
+
+ if (icon == null) {
+ icon = new ImageIcon( JSearchTextField.class.getResource(ICON_NAME));
+ }
+ return new ImageIcon(icon.getImage().getScaledInstance( size, size, Image.SCALE_SMOOTH )).getImage();
+ }
+
+ private static int PAD = 4;
+ private static int PAD2 = PAD*2;
+
+ @Override
+ public void paint(Graphics g) {
+ super.paint(g);
+ int size = getHeight()-PAD2;
+ g.drawImage( getScaledImage(size), getWidth()-size-PAD, PAD, null);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/misc/search.png
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/misc/search.png b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/misc/search.png
new file mode 100644
index 0000000..d239597
Binary files /dev/null and b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/misc/search.png differ
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/popup/PopupWindow.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/popup/PopupWindow.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/popup/PopupWindow.java
new file mode 100644
index 0000000..63e2684
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/popup/PopupWindow.java
@@ -0,0 +1,331 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.popup;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.Icon;
+import javax.swing.JComponent;
+import javax.swing.JPopupMenu;
+import javax.swing.SwingUtilities;
+import javax.swing.event.PopupMenuEvent;
+import javax.swing.event.PopupMenuListener;
+
+public abstract class PopupWindow {
+
+ private final JPopupMenu menu;
+ private Dimension defaultSize = new Dimension(100,100);
+
+ public PopupWindow( boolean resizable ) {
+ menu = new ResizablePopupMenu( resizable ) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
+ if ( menu.getComponentCount() == 0 ) {
+ JComponent content = buildContent();
+ defaultSize = content.getPreferredSize();
+
+ menu.add( content );
+
+ }
+ beforeShow();
+ }
+
+ @Override
+ public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
+ beforeHide();
+ }
+
+ };
+ }
+
+ public final Dimension getDefaultSize() {
+ return defaultSize;
+ }
+
+ public final Dimension getPreferredSize() {
+ return menu.getPreferredSize();
+ }
+
+ public final void setPreferredSize( Dimension preferredSize ) {
+ menu.setPreferredSize(preferredSize);
+ }
+
+ /**
+ * Override this method to add content yo the owner.
+ * This method is only executed when owner has no subcomponents
+ * @param owner
+ */
+ protected abstract JComponent buildContent();
+
+ /**
+ * Shows Popup in predefined location
+ * @param invoker
+ * @param x
+ * @param y
+ */
+ public void show( Component invoker, int x, int y ) {
+ menu.show( invoker, x, y );
+ }
+
+ /**
+ * Shows popup in predefined location
+ * @param invoker
+ * @param location
+ */
+ public void show( Component invoker, Point location ) {
+ show( invoker, location.x, location.y );
+ }
+
+ /**
+ * Hides popup
+ */
+ public final void hide() {
+ menu.setVisible(false);
+ }
+
+ protected void beforeShow() {}
+
+ protected void beforeHide() {}
+
+
+ /**
+ * Simple action to for the popup window.
+ * To use - override perform method.
+ *
+ * Created on Feb 4, 2011
+ * @author Eugene Ryzhikov
+ *
+ */
+ public class CommandAction extends AbstractAction {
+
+ private static final long serialVersionUID = 1L;
+
+ public CommandAction(String name, Icon icon) {
+ super(name, icon);
+
+ if ( icon != null ) {
+ putValue(Action.SHORT_DESCRIPTION, name);
+ putValue(Action.NAME, null);
+ }
+
+ }
+
+ public CommandAction( String name ) {
+ super(name);
+ }
+
+ @Override
+ public final void actionPerformed(ActionEvent e) {
+ if ( perform() ) hide();
+ }
+
+ /**
+ * Preforms action
+ * @return true if popup should be closed
+ */
+ protected boolean perform(){
+ return true;
+ }
+ }
+
+}
+
+class ResizablePopupMenu extends JPopupMenu implements PopupMenuListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final int DOT_SIZE = 2;
+ private static final int DOT_START = 2;
+ private static final int DOT_STEP = 4;
+
+ private final boolean resizable;
+
+ public ResizablePopupMenu( boolean resizable ) {
+ super();
+ this.resizable = resizable;
+ if ( resizable ) PopupMenuResizer.decorate(this);
+ addPopupMenuListener(this);
+ }
+
+ @Override
+ public void popupMenuWillBecomeVisible(PopupMenuEvent e) {}
+
+ @Override
+ public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {}
+
+ @Override
+ public void popupMenuCanceled(PopupMenuEvent e) {}
+
+ @Override
+ public void paintChildren(Graphics g) {
+ super.paintChildren(g);
+ if ( resizable ) drawResizer(g);
+ }
+
+ private void drawResizer(Graphics g) {
+
+ int x = getWidth()-2;
+ int y = getHeight()-2;
+
+ Graphics g2 = g.create();
+
+ try {
+ for ( int dy = DOT_START, j = 2; j > 0; j--, dy += DOT_STEP ) {
+ for( int dx = DOT_START, i = 0; i < j; i++, dx += DOT_STEP ) {
+ drawDot( g2, x-dx, y-dy );
+ }
+ }
+ } finally {
+ g2.dispose();
+ }
+
+ };
+
+ private void drawDot( Graphics g, int x, int y) {
+ g.setColor(Color.WHITE);
+ g.fillRect( x, y, DOT_SIZE, DOT_SIZE);
+ g.setColor(Color.LIGHT_GRAY);
+ g.fillRect( x-1, y-1, DOT_SIZE, DOT_SIZE);
+ }
+
+}
+
+/**
+ * Allows to resize popup with the mouse.
+ *
+ * Created on Aug 6, 2010
+ * @author exr0bs5
+ *
+ */
+final class PopupMenuResizer extends MouseAdapter {
+
+ private final JPopupMenu menu;
+
+ private static final int REZSIZE_SPOT_SIZE = 10;
+
+ private Point mouseStart = new Point( Integer.MIN_VALUE, Integer.MIN_VALUE );
+
+ private Dimension startSize;
+
+ private boolean isResizing = false;
+
+
+ public static void decorate( JPopupMenu menu ) {
+ new PopupMenuResizer( menu );
+ }
+
+ private PopupMenuResizer( JPopupMenu menu ) {
+ this.menu = menu;
+ this.menu.setLightWeightPopupEnabled(true);
+ menu.addMouseListener(this);
+ menu.addMouseMotionListener(this);
+ }
+
+ private boolean isInResizeSpot( Point point ) {
+
+ if ( point == null ) return false;
+
+ Rectangle resizeSpot = new Rectangle(
+ menu.getWidth()-REZSIZE_SPOT_SIZE,
+ menu.getHeight()-REZSIZE_SPOT_SIZE,
+ REZSIZE_SPOT_SIZE,
+ REZSIZE_SPOT_SIZE );
+
+ return resizeSpot.contains(point);
+
+ }
+
+ @Override
+ public void mouseMoved(MouseEvent e) {
+
+ menu.setCursor(
+ Cursor.getPredefinedCursor(
+ isInResizeSpot( e.getPoint() )? Cursor.SE_RESIZE_CURSOR: Cursor.DEFAULT_CURSOR ));
+ }
+
+ private Point toScreen( MouseEvent e ) {
+
+ Point p = e.getPoint();
+ SwingUtilities.convertPointToScreen(p, e.getComponent());
+ return p;
+
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ mouseStart = toScreen(e);
+ startSize = menu.getSize();
+ isResizing = isInResizeSpot(e.getPoint());
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ mouseStart = new Point( Integer.MIN_VALUE, Integer.MIN_VALUE );
+ isResizing = false;
+ }
+
+ @Override
+ public void mouseDragged(MouseEvent e) {
+
+ if ( !isResizing ) return;
+
+ Point p = toScreen(e);
+
+ int dx = p.x - mouseStart.x;
+ int dy = p.y - mouseStart.y;
+
+
+ Dimension minDim = menu.getMinimumSize();
+// Dimension maxDim = menu.getMaximumSize();
+ Dimension newDim = new Dimension(startSize.width + dx, startSize.height + dy);
+
+ if ( newDim.width >= minDim.width && newDim.height >= minDim.height /*&&
+ newDim.width <= maxDim.width && newDim.height <= maxDim.height*/ ) {
+ menu.setPopupSize( newDim );
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/TableHeaderRenderer.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/TableHeaderRenderer.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/TableHeaderRenderer.java
new file mode 100644
index 0000000..57bb572
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/TableHeaderRenderer.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.table;
+
+import java.awt.Component;
+
+import javax.swing.JComponent;
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+
+/**
+ * Common class for customizing table header renderer without loosing its L&F
+ *
+ * Created on Aug 10, 2010
+ * @author Eugene Ryzhikov
+ *
+ */
+public class TableHeaderRenderer extends JComponent implements TableCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
+ boolean hasFocus, int row, int column) {
+
+ // returns component used for default header rendering
+ // makes it independent on current L&F
+
+ return table.getTableHeader().getDefaultRenderer().
+ getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+
+ }
+
+ // following methods are overriden for performance reasons
+
+ @Override
+ public void validate() {}
+
+ @Override
+ public void revalidate() {}
+
+ @Override
+ public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {}
+
+ @Override
+ public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {}
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/AbstractTableFilter.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/AbstractTableFilter.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/AbstractTableFilter.java
new file mode 100644
index 0000000..313e684
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/AbstractTableFilter.java
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.table.filter;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.swing.JTable;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.TableModel;
+
+import static org.oxbow.swingbits.util.CollectionUtils.*;
+
+/**
+ * Partial implementation of table filter
+ *
+ * Created on Feb 10, 2011
+ * @author Eugene Ryzhikov
+ *
+ * @param <T>
+ */
+@SuppressWarnings("serial")
+public abstract class AbstractTableFilter<T extends JTable> implements ITableFilter<T> {
+
+ private final Set<IFilterChangeListener> listeners = Collections.synchronizedSet( new HashSet<IFilterChangeListener>());
+
+ private final Map<Integer, Collection<DistinctColumnItem>> distinctItemCache =
+ Collections.synchronizedMap(new HashMap<Integer, Collection<DistinctColumnItem>>());
+
+ private final T table;
+ private final TableFilterState filterState = new TableFilterState();
+
+ public AbstractTableFilter( T table ) {
+ this.table = table;
+ setupDistinctItemCacheRefresh();
+ }
+
+ private void setupDistinctItemCacheRefresh() {
+ clearDistinctItemCache();
+ this.table.addPropertyChangeListener("model", new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent e) {
+ clearDistinctItemCache();
+ TableModel model = (TableModel) e.getNewValue();
+ if ( model != null ) {
+ model.addTableModelListener( new TableModelListener() {
+
+ @Override
+ public void tableChanged(TableModelEvent e) {
+ clearDistinctItemCache();
+ }
+ });
+ }
+ }
+ });
+ }
+
+
+ private void clearDistinctItemCache() {
+ distinctItemCache.clear();
+ }
+
+ @Override
+ public T getTable() {
+ return table;
+ }
+
+ protected abstract boolean execute(int col, Collection<DistinctColumnItem> items);
+
+ @Override
+ public boolean apply(int col, Collection<DistinctColumnItem> items) {
+ setFilterState(col, items);
+ boolean result = false;
+ if ( result = execute( col, items ) ) fireFilterChange();
+ return result;
+ }
+
+
+ @Override
+ public final void addChangeListener( IFilterChangeListener listener ) {
+ if ( listener != null ) listeners.add(listener);
+ }
+
+ @Override
+ public final void removeChnageListener( IFilterChangeListener listener ) {
+ if ( listener != null ) listeners.remove(listener);
+ }
+
+ public final void fireFilterChange() {
+ for( IFilterChangeListener l: listeners ) {
+ l.filterChanged(AbstractTableFilter.this);
+ }
+ }
+
+ @Override
+ public Collection<DistinctColumnItem> getDistinctColumnItems( int column ) {
+ Collection<DistinctColumnItem> result = distinctItemCache.get(column);
+ if ( result == null ) {
+ result = collectDistinctColumnItems( column );
+ distinctItemCache.put(column, result);
+ }
+ return result;
+
+ }
+
+ private Collection<DistinctColumnItem> collectDistinctColumnItems( int column ) {
+ Set<DistinctColumnItem> set = new HashSet<DistinctColumnItem>(); // to collect unique items
+ int nullIndex = -1;
+ for( int row=0; row<table.getModel().getRowCount(); row++) {
+ Object value = table.getModel().getValueAt( row, column);
+ // adding null to TreeSet will produce NPE, just remember we had it
+ if ( value == null ) {
+ nullIndex = row;
+ } else {
+ set.add( new DistinctColumnItem(value, row ));
+ }
+ }
+ List<DistinctColumnItem> result = new ArrayList<DistinctColumnItem>(set);
+ if ( nullIndex >= 0 ) result.add(0, new DistinctColumnItem(null, nullIndex)); // add null to resulting collection if we had it
+
+ return trySort(result);
+ }
+
+ @Override
+ public Collection<DistinctColumnItem> getFilterState( int column ) {
+ return filterState.getValues(column);
+ }
+
+ @Override
+ public boolean isFiltered( int column ) {
+ Collection<DistinctColumnItem> checks = getFilterState( column );
+ return !isEmpty(checks) && getDistinctColumnItems( column ).size() != checks.size();
+ }
+
+ @Override
+ public boolean includeRow( ITableFilter.Row row ) {
+ return filterState.include(row);
+ }
+
+ public void setFilterState(int column, Collection<DistinctColumnItem> values ) {
+ filterState.setValues(column, values);
+ }
+
+ public void clear() {
+ filterState.clear();
+ Collection<DistinctColumnItem> items = Collections.emptyList();
+ for( int column=0; column<table.getModel().getColumnCount(); column++) {
+ execute(column, items);
+ }
+ fireFilterChange();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/DistinctColumnItem.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/DistinctColumnItem.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/DistinctColumnItem.java
new file mode 100644
index 0000000..57ec538
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/DistinctColumnItem.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.table.filter;
+
+import java.math.BigDecimal;
+
+import org.oxbow.swingbits.util.IValueWrapper;
+
+public class DistinctColumnItem implements Comparable<DistinctColumnItem>, IValueWrapper<Object> {
+
+ private final Object value;
+ private final int row;
+
+ public DistinctColumnItem( Object value, int row) {
+ this.value = value;
+ this.row = row;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public int getRow() {
+ return row;
+ }
+
+ @Override
+ public String toString() {
+ return value == null? "": value.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((value == null) ? 0 : value.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ DistinctColumnItem other = (DistinctColumnItem) obj;
+ if (value == null) {
+ if (other.value != null)
+ return false;
+ } else if (!value.equals(other.value))
+ return false;
+ return true;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public int compareTo(DistinctColumnItem o) {
+
+ if ( value == null ) {
+ return ( o == null || o.value == null )? 0: -1;
+ }
+ if ( o == null || o.value == null ) return 1;
+
+ if ( value.getClass() == o.value.getClass() ) {
+ if ( value instanceof Comparable) {
+ return ((Comparable<Object>)value).compareTo(o.value);
+ } else {
+ return value.toString().compareTo(o.value.toString());
+ }
+ } else {
+
+ if ( value instanceof Number && o.value instanceof Number) {
+ BigDecimal a = new BigDecimal(value.toString());
+ BigDecimal b = new BigDecimal(o.value.toString());
+ return a.compareTo(b);
+ }
+
+ return value.getClass().getName().compareTo(o.getClass().getName());
+ }
+
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/FilterTableHeaderRenderer.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/FilterTableHeaderRenderer.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/FilterTableHeaderRenderer.java
new file mode 100644
index 0000000..b74e9e2
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/FilterTableHeaderRenderer.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.table.filter;
+
+import java.awt.Component;
+import java.awt.Image;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.JTable;
+
+import org.oxbow.swingbits.table.TableHeaderRenderer;
+import org.oxbow.swingbits.util.swing.CompoundIcon;
+
+/**
+ * Table header renderer to show the column filter state
+ *
+ * Created on Feb 10, 2011
+ * @author Eugene Ryzhikov
+ *
+ */
+class FilterTableHeaderRenderer extends TableHeaderRenderer {
+
+ private static final long serialVersionUID = 1L;
+
+ private ImageIcon icon;
+ private final ITableFilter<?> tableFilter;
+ private boolean rendererInit = true;
+ private int originalHorizontalTextPosition;
+
+ public FilterTableHeaderRenderer( ITableFilter<?> tableFilter ) {
+ this.tableFilter = tableFilter;
+ }
+
+ private Icon getFilterIcon() {
+
+ if (icon == null) {
+ icon = new ImageIcon( getClass().getResource("funnel.png"));
+ icon = new ImageIcon( icon.getImage().getScaledInstance( 12, 12, Image.SCALE_SMOOTH ));
+ }
+ return icon;
+
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
+ boolean hasFocus, int row, int column) {
+
+ final JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ if ( rendererInit ) {
+ originalHorizontalTextPosition = label.getHorizontalTextPosition();
+ rendererInit = false;
+ }
+
+ int modelColumn = table.convertColumnIndexToModel(column);
+ if ( tableFilter.isFiltered(modelColumn) ) {
+
+ Icon originalIcon = label.getIcon();
+ if ( originalIcon == null ) {
+ label.setIcon( getFilterIcon() );
+ } else {
+ label.setIcon( new CompoundIcon( getFilterIcon(), originalIcon ) );
+ }
+ label.setHorizontalTextPosition( JLabel.TRAILING );
+
+ } else {
+ label.setHorizontalTextPosition( originalHorizontalTextPosition );
+ }
+
+ return label;
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/IFilterChangeListener.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/IFilterChangeListener.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/IFilterChangeListener.java
new file mode 100644
index 0000000..42f20ad
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/IFilterChangeListener.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package org.oxbow.swingbits.table.filter;
+
+public interface IFilterChangeListener {
+
+ void filterChanged( ITableFilter<?> filter );
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4c3a7698/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/ITableFilter.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/ITableFilter.java b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/ITableFilter.java
new file mode 100644
index 0000000..a237228
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/oxbow/swingbits/table/filter/ITableFilter.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2009-2011, EzWare
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.Redistributions
+ * in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.Neither the name of the
+ * EzWare nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+
+package org.oxbow.swingbits.table.filter;
+
+import java.io.Serializable;
+import java.util.Collection;
+
+import javax.swing.JTable;
+import javax.swing.table.TableModel;
+
+public interface ITableFilter<T extends JTable> extends Serializable {
+
+ /**
+ * The table under filter
+ * @return
+ */
+ T getTable();
+
+ /**
+ *
+ * @param column model column index
+ * @return
+ */
+ Collection<DistinctColumnItem> getDistinctColumnItems( int column );
+
+ /**
+ *
+ * @param column model column index
+ * @return
+ */
+ Collection<DistinctColumnItem> getFilterState( int column );
+
+ /**
+ * Checks if column is filtered
+ * @param column model column index
+ * @return true if column is filtered
+ */
+ boolean isFiltered( int column );
+
+ boolean includeRow( Row entry );
+
+ /**
+ * Apply filter for specified column based on collection of distinct items
+ * @param col
+ * @param items
+ * @return
+ */
+ boolean apply( int col, Collection<DistinctColumnItem> items );
+
+ public interface Row {
+ int getValueCount();
+ Object getValue( int column );
+ }
+
+ void addChangeListener( IFilterChangeListener listener );
+ void removeChnageListener( IFilterChangeListener listener );
+
+ /**
+ * Clear the filter
+ */
+ void clear();
+
+ /**
+ * Describes what filter has to do when table model changes
+ * @param model
+ */
+ void modelChanged( TableModel model );
+
+}