Package pivot.demos.roweditor

Source Code of pivot.demos.roweditor.Demo

/*
* 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 pivot.demos.roweditor;

import pivot.collections.Dictionary;
import pivot.collections.EnumList;
import pivot.wtk.Application;
import pivot.wtk.DesktopApplicationContext;
import pivot.wtk.Display;
import pivot.wtk.ListButton;
import pivot.wtk.Spinner;
import pivot.wtk.TableView;
import pivot.wtk.TextInput;
import pivot.wtk.Window;
import pivot.wtk.content.CalendarDateSpinnerData;
import pivot.wtk.content.TableViewRowEditor;
import pivot.wtkx.Bindable;

/**
* Demonstrates a flip transition used to initiate a table view row editor.
*
* @author tvolkert
*/
public class Demo extends Bindable implements Application {
    @Load(resourceName="demo.wtkx") private Window window;
    @Bind(fieldName="window") TableView tableView;

    public void startup(Display display, Dictionary<String, String> properties)
        throws Exception {
        bind();

        TableViewRowEditor tableViewRowEditor = new TableViewRowEditor();
        tableView.setRowEditor(tableViewRowEditor);

        // Date uses a Spinner with a CalendarDateSpinnerData model
        Spinner dateSpinner = new Spinner(new CalendarDateSpinnerData());
        dateSpinner.setSelectedItemKey("date");
        tableViewRowEditor.getCellEditors().put("date", dateSpinner);

        // Expense type uses a ListButton that presents the expense types
        ListButton typeListButton = new ListButton(new EnumList<ExpenseType>(ExpenseType.class));
        typeListButton.setSelectedItemKey("type");
        tableViewRowEditor.getCellEditors().put("type", typeListButton);

        // Amount uses a TextInput with strict currency validation
        TextInput amountTextInput = new TextInput();
        amountTextInput.setValidator(new CurrencyValidator());
        amountTextInput.getStyles().put("strictValidation", true);
        amountTextInput.setTextKey("amount");
        tableViewRowEditor.getCellEditors().put("amount", amountTextInput);

        window.open(display);
    }

    public boolean shutdown(boolean optional) throws Exception {
        if (window != null) {
            window.close();
        }

        return true;
    }

    public void suspend() {
    }

    public void resume() {
    }

    public static void main(String[] args) {
        DesktopApplicationContext.main(Demo.class, args);
    }
}
TOP

Related Classes of pivot.demos.roweditor.Demo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.