Example usage for java.awt Dialog setVisible

List of usage examples for java.awt Dialog setVisible

Introduction

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

Prototype

public void setVisible(boolean b) 

Source Link

Document

Shows or hides this Dialog depending on the value of parameter b .

Usage

From source file:Main.java

public static void fadeIn(final Dialog win) {
    if (!win.isUndecorated()) {
        return;//  w ww.  ja  v  a2  s .c o m
    }
    final Timer timer = new Timer(30, null);
    timer.setRepeats(true);
    timer.addActionListener(new ActionListener() {
        private float opacity = 0;

        @Override
        public void actionPerformed(ActionEvent e) {
            opacity += 0.05f;
            win.setOpacity(Math.min(opacity, 1f));
            if (opacity >= 1) {
                timer.stop();
            }
        }
    });
    win.setOpacity(0);
    timer.start();
    win.setVisible(true);
}

From source file:it.unibas.spicygui.controllo.mapping.ActionExportTranslatedInstancesSQL.java

@Override
public void performAction() {
    insertBeanForBinding();/*from w ww . j  av  a2 s .co m*/
    Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO);
    MappingTask mappingTask = scenario.getMappingTask();
    WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels());
    wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
    wizardDescriptor.setTitle("Database Configuration");
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
    dialog.setVisible(true);
    dialog.toFront();
    boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
    if (!cancelled) {
        try {
            RelationalConfigurationPM conf = (RelationalConfigurationPM) modello
                    .getBean(Costanti.RELATIONAL_CONFIGURATION_SOURCE);
            String driver = conf.getDriver();
            String uri = conf.getUri();
            String userName = conf.getLogin();
            String password = conf.getPassword();
            DAOSql dao = new DAOSql();
            dao.exportTranslatedSQLInstances(mappingTask, scenario.getNumber(), driver, uri, userName,
                    password);
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                    NbBundle.getMessage(Costanti.class, Costanti.EXPORT_COMPLETED_OK)));
        } catch (DAOException ex) {
            logger.error(ex);
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                    NbBundle.getMessage(Costanti.class, Costanti.EXPORT_ERROR) + " : " + ex.getMessage(),
                    DialogDescriptor.ERROR_MESSAGE));
        }
    }
}

From source file:it.unibas.spicygui.controllo.addtable.ActionAddSourceTable.java

public void performAction() {
    insertBeanForBinding();/*from  w  ww.j av  a 2  s. c om*/
    WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels());
    wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
    wizardDescriptor.setTitle("Choose input");
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
    dialog.setVisible(true);
    dialog.toFront();
    boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
    if (!cancelled) {
        try {
            MappingTask mappingTask = (MappingTask) this.modello.getBean(Costanti.MAPPINGTASK_SHOWED);
            NewMappingTaskPM newMappingTaskPM = (NewMappingTaskPM) this.modello
                    .getBean(Costanti.NEW_MAPPING_TASK_PM);
            IDataSourceProxy source = loadDataSource(newMappingTaskPM.getSourceElement(), true);
            mappingTask.addSource(source);
            updateScenario(mappingTask);
            enableActions();
            actionViewSchema.performAction();
            actionProjectTree.performAction();
        } catch (Exception ex) {
            logger.error(ex);
            Scenarios.releaseNumber();
            DialogDisplayer.getDefault()
                    .notify(new NotifyDescriptor.Message(
                            NbBundle.getMessage(Costanti.class, Costanti.NEW_ERROR) + " : " + ex.getMessage(),
                            DialogDescriptor.ERROR_MESSAGE));
        }
    }
}

From source file:it.unibas.spicygui.controllo.addtable.ActionAddTargetTable.java

public void performAction() {
    insertBeanForBinding();/*from ww w  . j  a v  a2 s  . c o m*/
    WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels());
    wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
    wizardDescriptor.setTitle("Choose input");
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
    dialog.setVisible(true);
    dialog.toFront();
    boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
    if (!cancelled) {
        try {
            MappingTask mappingTask = (MappingTask) this.modello.getBean(Costanti.MAPPINGTASK_SHOWED);
            NewMappingTaskPM newMappingTaskPM = (NewMappingTaskPM) this.modello
                    .getBean(Costanti.NEW_MAPPING_TASK_PM);
            IDataSourceProxy target = loadDataSource(newMappingTaskPM.getTargetElement(), false);
            mappingTask.addTarget(target);
            updateScenario(mappingTask);
            enableActions();
            actionViewSchema.performAction();
            actionProjectTree.performAction();
        } catch (Exception ex) {
            logger.error(ex);
            Scenarios.releaseNumber();
            DialogDisplayer.getDefault()
                    .notify(new NotifyDescriptor.Message(
                            NbBundle.getMessage(Costanti.class, Costanti.NEW_ERROR) + " : " + ex.getMessage(),
                            DialogDescriptor.ERROR_MESSAGE));
        }
    }
}

From source file:it.unibas.spicygui.controllo.file.ActionNewMappingTask.java

public void performAction() {
    insertBeanForBinding();// w  w  w . j a v a2s  . co m
    WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels());
    wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
    wizardDescriptor.setTitle("Choose input");
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
    dialog.setVisible(true);
    dialog.toFront();
    boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
    if (!cancelled) {
        try {
            //giannisk
            Scenarios.getNextFreeNumber();
            NewMappingTaskPM newMappingTaskPM = (NewMappingTaskPM) this.modello
                    .getBean(Costanti.NEW_MAPPING_TASK_PM);
            IDataSourceProxy source = loadDataSource(newMappingTaskPM.getSourceElement(), true);
            IDataSourceProxy target = loadDataSource(newMappingTaskPM.getTargetElement(), false);
            MappingTask mappingTask = new MappingTask(source, target,
                    SpicyEngineConstants.LINES_BASED_MAPPING_TASK);
            mappingTask.setModified(true);

            //giannisk 
            //prompt for automatic loading of foreign keys disabled
            if (!source.getForeignKeyConstraints().isEmpty()) {
                confirmAddForeignKeyToJoin(source, true);
            }
            if (!target.getForeignKeyConstraints().isEmpty()) {
                confirmAddForeignKeyToJoin(target, false);
            }

            gestioneScenario(mappingTask);
            enableActions();
            actionViewSchema.performAction();
            //giannisk open scenarios on the tree panel when creating a new mapping task
            actionProjectTree.performAction();
        } catch (Exception ex) {
            logger.error(ex);
            Scenarios.releaseNumber();
            DialogDisplayer.getDefault()
                    .notify(new NotifyDescriptor.Message(
                            NbBundle.getMessage(Costanti.class, Costanti.NEW_ERROR) + " : " + ex.getMessage(),
                            DialogDescriptor.ERROR_MESSAGE));
        }
    }
}

From source file:net.mybox.mybox.ClientGUI.java

private void placeTrayIconAWT() {

    //Check the SystemTray support
    if (!SystemTray.isSupported()) {
        System.out.println("SystemTray is not supported");
        return;// w  w w. j ava  2  s.  com
    }
    final PopupMenu popup = new PopupMenu();

    final SystemTray tray = SystemTray.getSystemTray();

    // Create a popup menu components
    MenuItem aboutItem = new MenuItem("About Mybox");
    MenuItem opendirItem = new MenuItem("Open Directory");
    MenuItem prefsItem = new MenuItem("Preferences");
    MenuItem exitItem = new MenuItem("Quit Mybox");

    //Add components to popup menu

    popup.add(opendirItem);
    popup.add(pauseItem);
    popup.add(syncnowItem);

    popup.addSeparator();
    popup.add(prefsItem);
    popup.add(aboutItem);
    popup.add(connectionItem);
    popup.add(exitItem);

    trayIcon.setImageAutoSize(true);
    trayIcon.setToolTip("Mybox");

    trayIcon.setPopupMenu(popup);

    try {
        tray.add(trayIcon);
    } catch (AWTException e) {
        System.out.println("TrayIcon could not be added.");
        return;
    }

    trayIcon.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            launchFileBrowser();
        }
    });

    aboutItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //JOptionPane.showMessageDialog(null, "Mybox!");

            Dialog dialog = new Dialog((ClientGUI) client.clientGui, "Mybox...");
            dialog.setVisible(true);

            //MessageDialog dialog = new InfoMessageDialog(null, "Mybox", "... is awesome!");//ErrorMessageDialog(null, "Error", message);
            //dialog.setTitle("About Mybox");
            //dialog.run();
            //dialog.hide();
        }
    });

    prefsItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //window.showAll();
            ((ClientGUI) client.clientGui).setVisible(true);
        }
    });

    syncnowItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            client.FullSync();
        }
    });

    opendirItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            launchFileBrowser();
        }
    });

    pauseItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (pauseItem.getLabel().equals("Pause Syncing")) {
                client.pause();
                pauseItem.setLabel("Unpause Syncing");
            } else if (pauseItem.getLabel().equals("Unpause Syncing")) {
                client.unpause();
                pauseItem.setLabel("Pause Syncing");
            }
        }
    });

    connectionItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (connectionItem.getLabel().equals("Connect")) {
                client.start();
            } else if (connectionItem.getLabel().equals("Disconnect")) {
                client.stop();
            }
        }
    });

    exitItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            tray.remove(trayIcon);
            System.exit(0);
        }
    });
}

From source file:be.fedict.eid.tsl.tool.TslTool.java

@Override
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (EXIT_ACTION_COMMAND.equals(command)) {
        System.exit(0);//from   w w w . j  a v  a2s .  c om
    } else if (OPEN_ACTION_COMMAND.equals(command)) {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setDialogTitle("Open TSL");
        int returnValue = fileChooser.showOpenDialog(this);
        if (returnValue == JFileChooser.APPROVE_OPTION) {
            displayTsl(fileChooser.getSelectedFile());
        }
    } else if (ABOUT_ACTION_COMMAND.equals(command)) {
        JOptionPane.showMessageDialog(this,
                "eID TSL Tool\n" + "Copyright (C) 2009-2013 FedICT\n" + "http://code.google.com/p/eid-tsl/",
                "About", JOptionPane.INFORMATION_MESSAGE);
    } else if (CLOSE_ACTION_COMMAND.equals(command)) {
        if (this.activeTslInternalFrame.getTrustServiceList().hasChanged()) {
            int result = JOptionPane.showConfirmDialog(this, "TSL has been changed.\n" + "Save the TSL?",
                    "Save", JOptionPane.YES_NO_CANCEL_OPTION);
            if (JOptionPane.CANCEL_OPTION == result) {
                return;
            }
            if (JOptionPane.YES_OPTION == result) {
                try {
                    this.activeTslInternalFrame.save();
                } catch (IOException e) {
                    LOG.error("IO error: " + e.getMessage(), e);
                }
            }
        }
        try {
            this.activeTslInternalFrame.setClosed(true);
        } catch (PropertyVetoException e) {
            LOG.warn("property veto error: " + e.getMessage(), e);
        }
    } else if (SIGN_ACTION_COMMAND.equals(command)) {
        LOG.debug("sign");
        TrustServiceList trustServiceList = this.activeTslInternalFrame.getTrustServiceList();
        if (trustServiceList.hasSignature()) {
            int confirmResult = JOptionPane.showConfirmDialog(this,
                    "TSL is already signed.\n" + "Resign the TSL?", "Resign", JOptionPane.OK_CANCEL_OPTION);
            if (JOptionPane.CANCEL_OPTION == confirmResult) {
                return;
            }
        }
        SignSelectPkcs11FinishablePanel pkcs11Panel = new SignSelectPkcs11FinishablePanel();
        WizardDescriptor wizardDescriptor = new WizardDescriptor(
                new WizardDescriptor.Panel[] { new SignInitFinishablePanel(), pkcs11Panel,
                        new SignSelectCertificatePanel(pkcs11Panel, trustServiceList),
                        new SignFinishFinishablePanel() });
        wizardDescriptor.setTitle("Sign TSL");
        wizardDescriptor.putProperty("WizardPanel_autoWizardStyle", Boolean.TRUE);
        DialogDisplayer dialogDisplayer = DialogDisplayer.getDefault();
        Dialog wizardDialog = dialogDisplayer.createDialog(wizardDescriptor);
        wizardDialog.setVisible(true);
    } else if (SAVE_ACTION_COMMAND.equals(command)) {
        LOG.debug("save");
        try {
            this.activeTslInternalFrame.save();
            this.saveMenuItem.setEnabled(false);
        } catch (IOException e) {
            LOG.debug("IO error: " + e.getMessage(), e);
        }
    } else if (SAVE_AS_ACTION_COMMAND.equals(command)) {
        LOG.debug("save as");
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setDialogTitle("Save As");
        int result = fileChooser.showSaveDialog(this);
        if (JFileChooser.APPROVE_OPTION == result) {
            File tslFile = fileChooser.getSelectedFile();
            if (tslFile.exists()) {
                int confirmResult = JOptionPane.showConfirmDialog(this,
                        "File already exists.\n" + tslFile.getAbsolutePath() + "\n" + "Overwrite file?",
                        "Overwrite", JOptionPane.OK_CANCEL_OPTION);
                if (JOptionPane.CANCEL_OPTION == confirmResult) {
                    return;
                }
            }
            try {
                this.activeTslInternalFrame.saveAs(tslFile);
            } catch (IOException e) {
                LOG.debug("IO error: " + e.getMessage(), e);
            }
            this.saveMenuItem.setEnabled(false);
        }
    } else if (EXPORT_ACTION_COMMAND.equals(command)) {
        LOG.debug("export");
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setDialogTitle("Export to PDF");
        int result = fileChooser.showSaveDialog(this);
        if (JFileChooser.APPROVE_OPTION == result) {
            File pdfFile = fileChooser.getSelectedFile();
            if (pdfFile.exists()) {
                int confirmResult = JOptionPane.showConfirmDialog(this,
                        "File already exists.\n" + pdfFile.getAbsolutePath() + "\n" + "Overwrite file?",
                        "Overwrite", JOptionPane.OK_CANCEL_OPTION);
                if (JOptionPane.CANCEL_OPTION == confirmResult) {
                    return;
                }
            }
            try {
                this.activeTslInternalFrame.export(pdfFile);
            } catch (IOException e) {
                LOG.debug("IO error: " + e.getMessage(), e);
            }
        }
    } else if ("TSL-BE-2010-T1".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2010, Trimester.FIRST);
        displayTsl("*TSL-BE-2010-T1.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2010-T2".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2010, Trimester.SECOND);
        displayTsl("*TSL-BE-2010-T2.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2010-T3".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2010, Trimester.THIRD);
        displayTsl("*TSL-BE-2010-T3.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2011-T1".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2011, Trimester.FIRST);
        displayTsl("*TSL-BE-2011-T1.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2011-T2".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2011, Trimester.SECOND);
        displayTsl("*TSL-BE-2011-T2.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2011-T3".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2011, Trimester.THIRD);
        displayTsl("*TSL-BE-2011-T3.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2012-T1".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2012, Trimester.FIRST);
        displayTsl("*TSL-BE-2012-T1.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2012-T2".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2012, Trimester.SECOND);
        displayTsl("*TSL-BE-2012-T2.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2012-T3".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2012, Trimester.THIRD);
        displayTsl("*TSL-BE-2012-T3.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2013-T1".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2013, Trimester.FIRST);
        displayTsl("*TSL-BE-2013-T1.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2013-T2".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2013, Trimester.SECOND);
        displayTsl("*TSL-BE-2013-T2.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2013-T3".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2013, Trimester.THIRD);
        displayTsl("*TSL-BE-2013-T3.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2014-T1".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2014, Trimester.FIRST);
        displayTsl("*TSL-BE-2014-T1.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2014-T2".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2014, Trimester.SECOND);
        displayTsl("*TSL-BE-2014-T2.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2014-T3".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2014, Trimester.THIRD);
        displayTsl("*TSL-BE-2014-T3.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2015-T1".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2015, Trimester.FIRST);
        displayTsl("*TSL-BE-2015-T1.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2015-T2".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2015, Trimester.SECOND);
        displayTsl("*TSL-BE-2015-T2.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    } else if ("TSL-BE-2015-T3".equals(command)) {
        TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2015, Trimester.THIRD);
        displayTsl("*TSL-BE-2015-T3.xml", trustServiceList);
        this.saveMenuItem.setEnabled(false);
    }
}

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

private void addTLALineItem() {
    //Disable the menu item
    addTLALineItemMI.setEnabled(false);/*from  ww  w  .  ja  va 2s.co  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);
}