Example usage for java.awt Dialog setModalityType

List of usage examples for java.awt Dialog setModalityType

Introduction

In this page you can find the example usage for java.awt Dialog setModalityType.

Prototype

public void setModalityType(ModalityType type) 

Source Link

Document

Sets the modality type for this dialog.

Usage

From source file:uk.ac.lkl.cram.ui.ModuleFrame.java

private void addTLALineItem() {
    //Disable the menu item
    addTLALineItemMI.setEnabled(false);/*  w  ww  .  j  a  v  a  2 s  . c o  m*/
    TLACreatorWizardIterator iterator = new TLACreatorWizardIterator(module);
    WizardDescriptor wizardDescriptor = new WizardDescriptor(iterator);
    iterator.initialize(wizardDescriptor);
    // {0} will be replaced by WizardDescriptor.Panel.getComponent().getName()
    // {1} will be replaced by WizardDescriptor.Iterator.name()
    wizardDescriptor.setTitleFormat(new MessageFormat("{0} ({1})"));
    wizardDescriptor.setTitle("TLA Creator Wizard for " + module.getModuleName() + " module");
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
    //Modeless within the document
    dialog.setModalityType(Dialog.ModalityType.DOCUMENT_MODAL);
    dialog.setVisible(true);
    dialog.toFront();
    boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
    //LOGGER.info("Cancelled: " + cancelled);
    if (!cancelled) {
        //Get the newly created line item
        TLALineItem lineItem = iterator.getLineItem();
        //If the user created a new TLA, add it to their preferences
        if (iterator.isVanilla()) {
            UserTLALibrary.getDefaultLibrary().addActivity(lineItem.getActivity());
        }
        module.addTLALineItem(lineItem);
        //No undo support here--assume user will just remove the line item
    }
    //Enable the menu item
    addTLALineItemMI.setEnabled(true);
}