当前位置: 首页>>代码示例>>Java>>正文


Java DialogDescriptor.setMessageType方法代码示例

本文整理汇总了Java中org.openide.DialogDescriptor.setMessageType方法的典型用法代码示例。如果您正苦于以下问题:Java DialogDescriptor.setMessageType方法的具体用法?Java DialogDescriptor.setMessageType怎么用?Java DialogDescriptor.setMessageType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.DialogDescriptor的用法示例。


在下文中一共展示了DialogDescriptor.setMessageType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showAcceptCancelDialog

import org.openide.DialogDescriptor; //导入方法依赖的package包/类
/**
 * Show an OK/cancel-type dialog with customized button texts.
 * Only a separate method because it is otherwise cumbersome to replace
 * the OK button with a button that is set as the default.
 * @param title the dialog title
 * @param message the body of the message (usually HTML text)
 * @param acceptButton a label for the default accept button; should not use mnemonics
 * @param accDescrAcceptButton a accessible description for acceptButton 
 * @param cancelButton a label for the cancel button (or null for default); should not use mnemonics
 * @param messageType {@link NotifyDescriptor#WARNING_MESSAGE} or similar
 * @return true if user accepted the dialog
 */
public static boolean showAcceptCancelDialog(String title, String message, 
        String acceptButton, String accDescrAcceptButton , 
        String cancelButton, int messageType) 
{
    DialogDescriptor d = new DialogDescriptor(message, title);
    d.setModal(true);
    JButton accept = new JButton(acceptButton);
    accept.setDefaultCapable(true);
    if ( accDescrAcceptButton != null ){
        accept.getAccessibleContext().
        setAccessibleDescription( accDescrAcceptButton);
    }
    d.setOptions(new Object[] {
        accept,
        cancelButton != null ? new JButton(cancelButton) : NotifyDescriptor.CANCEL_OPTION,
    });
    d.setMessageType(messageType);
    return DialogDisplayer.getDefault().notify(d).equals(accept);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:ApisupportAntUIUtils.java

示例2: showPlatformWarning

import org.openide.DialogDescriptor; //导入方法依赖的package包/类
@NbBundle.Messages({
    "CTL_BrokenPlatform_Close=Close",
    "AD_BrokenPlatform_Close=N/A",
    "# {0} - project name", "TEXT_BrokenPlatform=<html><p><strong>The project {0} has a broken platform reference.</strong></p><br><p> You have to fix the broken reference and invoke the action again.</p>",
    "MSG_BrokenPlatform_Title=Broken Platform Reference"
})
static void showPlatformWarning (@NonNull final Project project) {
    final JButton closeOption = new JButton(CTL_BrokenPlatform_Close());
    closeOption.getAccessibleContext().setAccessibleDescription(AD_BrokenPlatform_Close());
    final String projectDisplayName = ProjectUtils.getInformation(project).getDisplayName();
    final DialogDescriptor dd = new DialogDescriptor(
        TEXT_BrokenPlatform(projectDisplayName),
        MSG_BrokenPlatform_Title(),
        true,
        new Object[] {closeOption},
        closeOption,
        DialogDescriptor.DEFAULT_ALIGN,
        null,
        null);
    dd.setMessageType(DialogDescriptor.WARNING_MESSAGE);
    final Dialog dlg = DialogDisplayer.getDefault().createDialog(dd);
    dlg.setVisible(true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ActionProviderSupport.java

示例3: handleSaveAllFailed

import org.openide.DialogDescriptor; //导入方法依赖的package包/类
protected void handleSaveAllFailed(Collection<String> errMsgs) {
    JButton btnShowMoreInfo = new JButton();
    DialogDescriptor errDescr = new DialogDescriptor(
            new ExpandableMessage(
                  "MSG_ExceptionWhileSavingMoreFiles_Intro",        //NOI18N
                  errMsgs,
                  null,
                  btnShowMoreInfo),
            getMessage("MSG_Title_SavingError"),                    //NOI18N
            true,                                   //modal
            DEFAULT_OPTION,
            OK_OPTION,
            null);                                  //no button listener
    errDescr.setMessageType(ERROR_MESSAGE);
    errDescr.setOptions(new Object[] { OK_OPTION });
    errDescr.setAdditionalOptions(new Object[] { btnShowMoreInfo });
    errDescr.setClosingOptions(new Object[] { OK_OPTION });

    DialogDisplayer.getDefault().notify(errDescr);
    closeDialog(btnSaveAll);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:FilesModifiedConfirmation.java

示例4: displayAlert

import org.openide.DialogDescriptor; //导入方法依赖的package包/类
/**
 * Just show the dialog but do not do anything about it.
 */
private boolean displayAlert(String projectDisplayName) {
    String title = NbBundle.getMessage(UnboundTargetAlert.class, "UTA_TITLE", label, projectDisplayName);
    final DialogDescriptor d = new DialogDescriptor(this, title);
    d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION);
    d.setMessageType(NotifyDescriptor.ERROR_MESSAGE);
    d.setValid(false);
    selectCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            d.setValid(((String) selectCombo.getSelectedItem()).trim().length() > 0);
        }
    });
    Dialog dlg = DialogDisplayer.getDefault().createDialog(d);
    selectCombo.requestFocusInWindow();
    // XXX combo box gets cut off at the bottom unless you do something - why??
    Dimension sz = dlg.getSize();
    dlg.setSize(sz.width, sz.height + 30);
    dlg.setVisible(true);
    return d.getValue() == NotifyDescriptor.OK_OPTION;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:UnboundTargetAlert.java

示例5: getProblemDesriptor

import org.openide.DialogDescriptor; //导入方法依赖的package包/类
private DialogDescriptor getProblemDesriptor(String message) {
    Object [] options;
    if (buttons == null || buttons.length == 0) {
        options = new Object [] { DialogDescriptor.OK_OPTION };
    } else {
        options = buttons;
    }
    DialogDescriptor descriptor = new DialogDescriptor(
         this,
         isWarning ? NbBundle.getMessage(ProblemPanel.class, "CTL_Warning") : message,
         true,                              // Modal
         options,                           // Option list
         null,                              // Default
         DialogDescriptor.DEFAULT_ALIGN,    // Align
         null,                              // Help
         null
    );

    descriptor.setMessageType (isWarning ? NotifyDescriptor.WARNING_MESSAGE : NotifyDescriptor.ERROR_MESSAGE);
    descriptor.setClosingOptions(null);
    return descriptor;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ProblemPanel.java

示例6: showConfirmation

import org.openide.DialogDescriptor; //导入方法依赖的package包/类
/** Opens confirmation dialog. */
void showConfirmation() {
    DialogDescriptor dd = new DialogDescriptor(
            this,
            NbBundle.getMessage(ImportConfirmationPanel.class, "ImportConfirmationPanel.title"),
            true,
            DialogDescriptor.YES_NO_OPTION,
            DialogDescriptor.YES_OPTION,
            null);
    dd.setMessageType(DialogDescriptor.WARNING_MESSAGE);
    DialogDisplayer.getDefault().createDialog(dd).setVisible(true);
    if (DialogDescriptor.OK_OPTION.equals(dd.getValue())) {
        confirmed = true;
    } else {
        confirmed = false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ImportConfirmationPanel.java

示例7: showConfirmation

import org.openide.DialogDescriptor; //导入方法依赖的package包/类
/** Opens confirmation dialog. */
void showConfirmation() {
    DialogDescriptor dd = new DialogDescriptor(
            this,
            NbBundle.getMessage(ExportConfirmationPanel.class, "ExportConfirmationPanel.title"),
            true,
            DialogDescriptor.YES_NO_OPTION,
            DialogDescriptor.YES_OPTION,
            null);
    dd.setMessageType(DialogDescriptor.WARNING_MESSAGE);
    DialogDisplayer.getDefault().createDialog(dd).setVisible(true);
    if (DialogDescriptor.OK_OPTION.equals(dd.getValue())) {
        confirmed = true;
        storeSkipOption();
    } else {
        confirmed = false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ExportConfirmationPanel.java

示例8: checkLanguageToolchain

import org.openide.DialogDescriptor; //导入方法依赖的package包/类
private LanguageToolchain checkLanguageToolchain() {
    Optional<LanguageToolchain> opt = new LanguageToolchainLocator().findSuitableLanguageToolchain();
    if (!opt.isPresent()) {
        LOGGER.log(Level.INFO, "No valid XC32 toolchain found. Asking the user to download one and aborting the procedure");
        String messageTemplate = NbBundle.getMessage(getClass(), "LanguageToolchainVersionErrorDialog.message");
        String message = MessageFormat.format(messageTemplate, Requirements.MINIMUM_XC_TOOLCHAIN_VERSION);

        JEditorPane messagePane = createMessagePane(message);

        JPanel contentPane = new JPanel();
        contentPane.setLayout(new BorderLayout(5, 5));
        contentPane.add(messagePane, BorderLayout.CENTER);

        DialogDescriptor dd = new DialogDescriptor(contentPane, NbBundle.getMessage(getClass(), "LanguageToolchainVersionErrorDialog.title"));
        dd.setMessageType(DialogDescriptor.ERROR_MESSAGE);
        dd.setOptionsAlign(DialogDescriptor.BOTTOM_ALIGN);
        dd.setOptions(new Object[]{DialogDescriptor.OK_OPTION});

        DialogDisplayer.getDefault().notify(dd);
        return null;
    } else {
        LOGGER.log(Level.INFO, "Found XC32 toolchain. Version: {0}", opt.get().getVersion());
        return opt.get();
    }
}
 
开发者ID:chipKIT32,项目名称:chipKIT-importer,代码行数:26,代码来源:ShowChipKitImportWizardAction.java

示例9: showWritePermissionDialog

import org.openide.DialogDescriptor; //导入方法依赖的package包/类
@Messages({"cancel=Cancel", "installAnyway=Install anyway", "warning=Write permission problem",
    "writePermissionDetails=<html>You don't have permission to install JUnit Library into the installation directory which is recommened.<br><br>"
    + "To perform installation into the shared directory, you should run IDE as a user with administrative<br>"
    + "privilege, or install the JUnit Library into your user directory."})
private static void showWritePermissionDialog(Runnable installAnyway) {
    JButton cancel = new JButton();
    Mnemonics.setLocalizedText(cancel, cancel());
    JButton install = new JButton();
    Mnemonics.setLocalizedText(install, installAnyway());
    DialogDescriptor descriptor = new DialogDescriptor(
            new JLabel(writePermissionDetails()),
            warning(),
            true, // Modal
            new JButton[]{install, cancel}, // Option list
            null, // Default
            DialogDescriptor.DEFAULT_ALIGN, // Align
            null, // Help
            null);
    
    descriptor.setMessageType(NotifyDescriptor.QUESTION_MESSAGE);
    descriptor.setClosingOptions(null);
    DialogDisplayer.getDefault().createDialog(descriptor).setVisible(true);
    if (install.equals(descriptor.getValue())) {
        // install anyway
        LOG.info("user install JUnit into userdir anyway");
        InstallLibraryTask.RP.post(installAnyway);
    } else {
        LOG.info("user canceled install JUnit into userdir");
    }
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:JUnitLibraryInstaller.java

示例10: warnContainsErrors

import org.openide.DialogDescriptor; //导入方法依赖的package包/类
@Override
public boolean warnContainsErrors(Preferences pref) {
    JButton btnRunAnyway = new JButton();
    org.openide.awt.Mnemonics.setLocalizedText(btnRunAnyway, NbBundle.getMessage(UIProviderImpl.class, "BTN_RunAnyway"));
    btnRunAnyway.getAccessibleContext().setAccessibleName(NbBundle.getMessage(UIProviderImpl.class, "ACSN_BTN_RunAnyway"));
    btnRunAnyway.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(UIProviderImpl.class, "ACSD_BTN_RunAnyway"));

    JButton btnCancel = new JButton();
    org.openide.awt.Mnemonics.setLocalizedText(btnCancel, NbBundle.getMessage(UIProviderImpl.class, "BTN_Cancel"));
    btnCancel.getAccessibleContext().setAccessibleName(NbBundle.getMessage(UIProviderImpl.class, "ACSN_BTN_Cancel"));
    btnCancel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(UIProviderImpl.class, "ACSD_BTN_Cancel"));

    ContainsErrorsWarning panel = new ContainsErrorsWarning();
    DialogDescriptor dd = new DialogDescriptor(panel,
            NbBundle.getMessage(UIProviderImpl.class, "TITLE_ContainsErrorsWarning"),
            true,
            new Object[]{btnRunAnyway, btnCancel},
            btnRunAnyway,
            DialogDescriptor.DEFAULT_ALIGN,
            null,
            null);

    dd.setMessageType(DialogDescriptor.WARNING_MESSAGE);

    Object option = DialogDisplayer.getDefault().notify(dd);

    if (option == btnRunAnyway) {
        pref.putBoolean(ASK_BEFORE_RUN_WITH_ERRORS, panel.getAskBeforeRunning());
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:UIProviderImpl.java

示例11: selectDevice

import org.openide.DialogDescriptor; //导入方法依赖的package包/类
/**
 * Selects a device
 *
 * @return device info or {@code null}
 */
@Override
public LaunchData selectDevice(AvdManager avdManager, IDevice[] devices) {
    final DeviceUiChooser panel = new DeviceUiChooser(avdManager, devices);
    final Object[] options = new Object[]{
        DialogDescriptor.OK_OPTION,
        DialogDescriptor.CANCEL_OPTION
    };

    final DialogDescriptor desc = new DialogDescriptor(panel,
            "Select device",
            true, options, options[0], DialogDescriptor.BOTTOM_ALIGN, null, null);
    desc.setMessageType(DialogDescriptor.INFORMATION_MESSAGE);
    desc.setValid(false); // no selection yet
    panel.addLaunchDataListener(new LaunchDeviceListener() {

        @Override
        public void lauchDeviceChanged(LaunchData launchData) {
            desc.setValid(launchData != null);
        }
    });

    final Dialog dlg = DialogDisplayer.getDefault().createDialog(desc);
    panel.addSelectCallback(new Runnable() {

        @Override
        public void run() {
            dlg.setVisible(false);
            desc.setValue(options[0]);
        }
    });
    dlg.setVisible(true);
    dlg.dispose();
    if (desc.getValue() == options[0]) {
        return panel.getLaunchData();
    }
    return null;
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:43,代码来源:DeviceChooserImpl.java

示例12: selectProcessToKill

import org.openide.DialogDescriptor; //导入方法依赖的package包/类
static List<BuildExecutionSupport.Item> selectProcessToKill(List<BuildExecutionSupport.Item> toStop) {
    // Add all threads, sorted by display name.
    DefaultListModel model = new DefaultListModel();
    StopBuildingAlert alert = new StopBuildingAlert();
    final JList list = alert.buildsList;
    Comparator<BuildExecutionSupport.Item> comp = new Comparator<BuildExecutionSupport.Item>() {
        private final Collator coll = Collator.getInstance();
        @Override
        public int compare(BuildExecutionSupport.Item t1, BuildExecutionSupport.Item t2) {
            String n1 = t1.getDisplayName();
            String n2 = t2.getDisplayName();
            int r = coll.compare(n1, n2);
            if (r != 0) {
                return r;
            } else {
                // Arbitrary. XXX Note that there is no way to predict which is
                // which if you have more than one build running. Ideally it
                // would be subsorted by creation time, probably.
                return System.identityHashCode(t1) - System.identityHashCode(t2);
            }
        }
    };
    SortedSet<BuildExecutionSupport.Item> items = new TreeSet<BuildExecutionSupport.Item>(comp);
    items.addAll(toStop);

    for (BuildExecutionSupport.Item t : items) {
        model.addElement(t);
    }
    list.setModel(model);
    list.setSelectedIndex(0);
    // Make a dialog with buttons "Stop Building" and "Cancel".
    DialogDescriptor dd = new DialogDescriptor(alert, NbBundle.getMessage(StopBuildingAlert.class, "TITLE_SBA"));
    dd.setMessageType(NotifyDescriptor.PLAIN_MESSAGE);
    final JButton stopButton = new JButton(NbBundle.getMessage(StopBuildingAlert.class, "LBL_SBA_stop"));
    list.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            stopButton.setEnabled(list.getSelectedValue() != null);
        }
    });
    dd.setOptions(new Object[] {stopButton, DialogDescriptor.CANCEL_OPTION});
    DialogDisplayer.getDefault().createDialog(dd).setVisible(true);
    List<BuildExecutionSupport.Item> toRet = new ArrayList<BuildExecutionSupport.Item>();
    if (dd.getValue() == stopButton) {
        Object[] selectedItems = list.getSelectedValues();
        for (Object o : selectedItems) {
            toRet.add((BuildExecutionSupport.Item)o);
        }
    }
    return toRet;

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:53,代码来源:StopBuildingAlert.java

示例13: selectMainClass

import org.openide.DialogDescriptor; //导入方法依赖的package包/类
/**
 * Asks user for name of main class
 *
 * @param project     the project in question
 * @param mainClass   current main class
 * @param projectName the name of project
 * @param messageType type of dialog -1 when the main class is not set, -2 when the main class in not valid
 * @return true if user selected main class
 */
@NbBundle.Messages({
    "LBL_MainClassWarning_ChooseMainClass_OK=OK",
    "LBL_MainClassNotFound=Project {0} does not have a main class set correctly.",
    "CTL_MainClassWarning_Title=Profile Project",
    "AD_MainClassWarning_ChooseMainClass_OK=N/A",
    "LBL_MainClassWrong=Main class of Project {0} is incorrect."
})
public static String selectMainClass(Project project, String mainClass, String projectName, int messageType) {
    boolean canceled;
    final JButton okButton = new JButton(Bundle.LBL_MainClassWarning_ChooseMainClass_OK());
    okButton.getAccessibleContext().setAccessibleDescription(Bundle.AD_MainClassWarning_ChooseMainClass_OK());

    // main class goes wrong => warning
    String message;

    switch (messageType) {
        case -1:
            message = Bundle.LBL_MainClassNotFound(projectName);

            break;
        case -2:
            message = Bundle.LBL_MainClassWrong(projectName);

            break;
        default:
            throw new IllegalArgumentException();
    }

    final MainClassWarning panel = new MainClassWarning(message, project);
    Object[] options = new Object[] { okButton, DialogDescriptor.CANCEL_OPTION };

    panel.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                if (e.getSource() instanceof MouseEvent && MouseUtils.isDoubleClick(((MouseEvent) e.getSource()))) {
                    // click button and the finish dialog with selected class
                    okButton.doClick();
                } else {
                    okButton.setEnabled(panel.getSelectedMainClass() != null);
                }
            }
        });

    okButton.setEnabled(false);

    DialogDescriptor desc = new DialogDescriptor(panel,
                                                 Bundle.CTL_MainClassWarning_Title(),
                                                 true, options, options[0], DialogDescriptor.BOTTOM_ALIGN, null, null);
    desc.setMessageType(DialogDescriptor.INFORMATION_MESSAGE);

    Dialog dlg = DialogDisplayer.getDefault().createDialog(desc);
    dlg.setVisible(true);

    if (desc.getValue() != options[0]) {
        canceled = true;
    } else {
        mainClass = panel.getSelectedMainClass();
        canceled = false;
    }

    dlg.dispose();

    if (canceled) {
        return null;
    } else {
        return mainClass;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:77,代码来源:ProjectUtilities.java

示例14: showCustomizer

import org.openide.DialogDescriptor; //导入方法依赖的package包/类
@NbBundle.Messages({
    "LBL_MainClassWarning_ChooseMainClass_OK=OK",
    "AD_MainClassWarning_ChooseMainClass_OK=N/A",
    "# {0} - project name", "LBL_MainClassNotFound=Project {0} does not have a main class set.",
    "# {0} - name of class", "# {1} - project name", "LBL_MainClassWrong={0} class wasn''t found in {1} project.",
    "CTL_MainClassWarning_Title=Run Project"
    })
static boolean showCustomizer(
        @NonNull final Project project,
        @NonNull final UpdateHelper updateHelper,
        @NonNull final PropertyEvaluator evaluator,
        @NonNull final SourceRoots projectSourceRoots,
        @NonNull final Function<String,ClassPath> classpaths) {
    boolean result = false;
    final JButton okButton = new JButton(LBL_MainClassWarning_ChooseMainClass_OK());
    okButton.getAccessibleContext().setAccessibleDescription(AD_MainClassWarning_ChooseMainClass_OK());
    // main class goes wrong => warning
    String mainClass = getProjectMainClass(project, evaluator, projectSourceRoots, classpaths, false);
    String message;
    if (mainClass == null) {
        message = LBL_MainClassNotFound(ProjectUtils.getInformation(project).getDisplayName());
    } else {
        message = LBL_MainClassWrong(
            mainClass,
            ProjectUtils.getInformation(project).getDisplayName());
    }
    final MainClassWarning panel = new MainClassWarning (message, projectSourceRoots.getRoots());
    Object[] options = new Object[] {
        okButton,
        DialogDescriptor.CANCEL_OPTION
    };
    panel.addChangeListener (new ChangeListener () {
        @Override
       public void stateChanged (ChangeEvent e) {
           if (e.getSource () instanceof MouseEvent && MouseUtils.isDoubleClick (((MouseEvent)e.getSource ()))) {
               // click button and the finish dialog with selected class
               okButton.doClick ();
           } else {
               okButton.setEnabled (panel.getSelectedMainClass () != null);
           }
       }
    });
    okButton.setEnabled (false);
    DialogDescriptor desc = new DialogDescriptor (panel,
        CTL_MainClassWarning_Title(),
        true, options, options[0], DialogDescriptor.BOTTOM_ALIGN, null, null);
    desc.setMessageType (DialogDescriptor.INFORMATION_MESSAGE);
    Dialog dlg = DialogDisplayer.getDefault ().createDialog (desc);
    dlg.setVisible (true);
    if (desc.getValue() == options[0]) {
        mainClass = panel.getSelectedMainClass ();
        String config = evaluator.getProperty(ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG);
        String path;
        if (config == null || config.length() == 0) {
            path = AntProjectHelper.PROJECT_PROPERTIES_PATH;
        } else {
            // Set main class for a particular config only.
            path = "nbproject/configs/" + config + ".properties"; // NOI18N
        }
        final EditableProperties ep = updateHelper.getProperties(path);
        ep.put(ProjectProperties.MAIN_CLASS, mainClass == null ? "" : mainClass);
        try {
            if (updateHelper.requestUpdate()) {
                updateHelper.putProperties(path, ep);
                ProjectManager.getDefault().saveProject(project);
                result = true;
            }
        } catch (IOException ioe) {
            Exceptions.printStackTrace(ioe);
        }
    }
    dlg.dispose();
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:75,代码来源:ActionProviderSupport.java

示例15: allowAccess

import org.openide.DialogDescriptor; //导入方法依赖的package包/类
/** Requests access for address addr. If necessary asks the user. Returns true it the access
* has been granted. */  
boolean allowAccess(InetAddress addr, String requestPath) {
    if (accessAllowedNow(addr, requestPath))
        return true;

    Thread askThread = null;
    synchronized (whoAsking) {
        // one more test in the synchronized block
        if (accessAllowedNow(addr, requestPath))
            return true;

        askThread = (Thread)whoAsking.get(addr);
        if (askThread == null) {
            askThread = Thread.currentThread();
            whoAsking.put(addr, askThread);
        }
    }

    // now ask the user
    synchronized (HttpServerSettings.class) {
        if (askThread != Thread.currentThread()) {
            return accessAllowedNow(addr, requestPath);
        }

        try {
            if (!isShowGrantAccessDialog ())
                return false;
            
            String msg = NbBundle.getMessage (HttpServerSettings.class, "MSG_AddAddress", addr.getHostAddress ());
            
            final GrantAccessPanel panel = new GrantAccessPanel (msg);
            DialogDescriptor descriptor = new DialogDescriptor (
                panel,
                NbBundle.getMessage (HttpServerSettings.class, "CTL_GrantAccessTitle"),
                true,
                NotifyDescriptor.YES_NO_OPTION,
                NotifyDescriptor.NO_OPTION,
                null
            );
            descriptor.setMessageType (NotifyDescriptor.QUESTION_MESSAGE);
            // descriptor.setOptionsAlign (DialogDescriptor.BOTTOM_ALIGN);
            final Dialog d  = DialogDisplayer.getDefault ().createDialog (descriptor);
            d.setSize (580, 180);
            d.setVisible(true);

            setShowGrantAccessDialog (panel.getShowDialog ());
            if (NotifyDescriptor.YES_OPTION.equals(descriptor.getValue ())) {
                appendAddressToGranted(addr.getHostAddress());
                return true;
            }
            else
                return false;
        }
        finally {
            whoAsking.remove(addr);
        }
    } // end synchronized
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:60,代码来源:HttpServerSettings.java


注:本文中的org.openide.DialogDescriptor.setMessageType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。