Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.pivot.wtk;
import java.util.Comparator;
import org.apache.pivot.collections.ArrayList;
import org.apache.pivot.collections.List;
import org.apache.pivot.collections.ListListener;
import org.apache.pivot.collections.Sequence;
import org.apache.pivot.util.ListenerList;
import org.apache.pivot.util.Vote;
import org.apache.pivot.wtk.content.ListViewItemRenderer;
/**
* Popup that presents a list of text suggestions to the user.
*/
public class SuggestionPopup extends Window {
private static class SuggestionPopupListenerList extends WTKListenerList
implements SuggestionPopupListener {
@Override
public void suggestionDataChanged(SuggestionPopup suggestionPopup,
List> previousSuggestionData) {
for (SuggestionPopupListener listener : this) {
listener.suggestionDataChanged(suggestionPopup, previousSuggestionData);
}
}
@Override
public void suggestionRendererChanged(SuggestionPopup suggestionPopup,
ListView.ItemRenderer previousSuggestionRenderer) {
for (SuggestionPopupListener listener : this) {
listener.suggestionRendererChanged(suggestionPopup, previousSuggestionRenderer);
}
}
@Override
public void listSizeChanged(SuggestionPopup suggestionPopup, int previousListSize) {
for (SuggestionPopupListener listener : this) {
listener.listSizeChanged(suggestionPopup, previousListSize);
}
}
}
private static class SuggestionPopupItemListenerList extends WTKListenerList
implements SuggestionPopupItemListener {
@Override
public void itemInserted(SuggestionPopup suggestionPopup, int index) {
for (SuggestionPopupItemListener listener : this) {
listener.itemInserted(suggestionPopup, index);
}
}
@Override
public void itemsRemoved(SuggestionPopup suggestionPopup, int index, int count) {
for (SuggestionPopupItemListener listener : this) {
listener.itemsRemoved(suggestionPopup, index, count);
}
}
@Override
public void itemUpdated(SuggestionPopup suggestionPopup, int index) {
for (SuggestionPopupItemListener listener : this) {
listener.itemUpdated(suggestionPopup, index);
}
}
@Override
public void itemsCleared(SuggestionPopup suggestionPopup) {
for (SuggestionPopupItemListener listener : this) {
listener.itemsCleared(suggestionPopup);
}
}
@Override
public void itemsSorted(SuggestionPopup suggestionPopup) {
for (SuggestionPopupItemListener listener : this) {
listener.itemsSorted(suggestionPopup);
}
}
}
private static class SuggestionPopupSelectionListenerList extends WTKListenerList
implements SuggestionPopupSelectionListener {
@Override
public void selectedIndexChanged(SuggestionPopup suggestionPopup,
int previousSelectedIndex) {
for (SuggestionPopupSelectionListener listener : this) {
listener.selectedIndexChanged(suggestionPopup, previousSelectedIndex);
}
}
@Override
public void selectedSuggestionChanged(SuggestionPopup suggestionPopup, Object previousSelectedSuggestion) {
for (SuggestionPopupSelectionListener listener : this) {
listener.selectedSuggestionChanged(suggestionPopup, previousSelectedSuggestion);
}
}
}
private static class SuggestionPopupStateListenerList extends WTKListenerList
implements SuggestionPopupStateListener {
@Override
public Vote previewSuggestionPopupClose(SuggestionPopup suggestionPopup, boolean result) {
Vote vote = Vote.APPROVE;
for (SuggestionPopupStateListener listener : this) {
vote = vote.tally(listener.previewSuggestionPopupClose(suggestionPopup, result));
}
return vote;
}
@Override
public void suggestionPopupCloseVetoed(SuggestionPopup suggestionPopup, Vote reason) {
for (SuggestionPopupStateListener listener : this) {
listener.suggestionPopupCloseVetoed(suggestionPopup, reason);
}
}
@Override
public void suggestionPopupClosed(SuggestionPopup suggestionPopup) {
for (SuggestionPopupStateListener listener : this) {
listener.suggestionPopupClosed(suggestionPopup);
}
}
}
private TextInput textInput = null;
private SuggestionPopupCloseListener suggestionPopupCloseListener = null;
private List> suggestionData;
private ListView.ItemRenderer suggestionRenderer;
private int selectedIndex = -1;
private int listSize = -1;
private boolean result = false;
private boolean closing = false;
private ListListener