• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ProgressUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.netbeans.api.progress.ProgressUtils的典型用法代码示例。如果您正苦于以下问题:Java ProgressUtils类的具体用法?Java ProgressUtils怎么用?Java ProgressUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ProgressUtils类属于org.netbeans.api.progress包,在下文中一共展示了ProgressUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: open

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
/**
 * Opens given {@link TreePathHandle}.
 * @param toSearch the {@link FileObject} used to resolve the {@link TreePathHandle} in
 * @param toOpen   {@link TreePathHandle} of the {@link Tree} which should be opened.
 * @return true if and only if the declaration was correctly opened,
 *                false otherwise
 * @since 1.45
 */
public static boolean open(
        @NonNull final FileObject toSearch,
        @NonNull final TreePathHandle toOpen) {
    final AtomicBoolean cancel = new AtomicBoolean();
    if (SwingUtilities.isEventDispatchThread() && !JavaSourceAccessor.holdsParserLock()) {
        final boolean[] result = new boolean[1];
        ProgressUtils.runOffEventDispatchThread(new Runnable() {
                public void run() {
                    result[0] = open(toSearch, toOpen, cancel);
                }
            },
            NbBundle.getMessage(ElementOpen.class, "TXT_CalculatingDeclPos"),
            cancel,
            false);
        return result[0];
    } else {
        return open(toSearch, toOpen, cancel);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:ElementOpen.java


示例2: showCustomizer

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
@Messages({
    "PROGRESS_loading_data=Loading project information",
    "# {0} - project display name", "LBL_CustomizerTitle=Project Properties - {0}"
})
public void showCustomizer(String preselectedCategory, final String preselectedSubCategory) {
    if (dialog != null) {
        dialog.setVisible(true);
    } else {
        final String category = (preselectedCategory != null) ? preselectedCategory : lastSelectedCategory;
        final AtomicReference<Lookup> context = new AtomicReference<Lookup>();
        ProgressUtils.runOffEventDispatchThread(new Runnable() {
            @Override public void run() {
                context.set(new ProxyLookup(prepareData(), Lookups.fixed(new SubCategoryProvider(category, preselectedSubCategory))));
            }
        }, PROGRESS_loading_data(), /* currently unused */new AtomicBoolean(), false);
        if (context.get() == null) { // canceled
            return;
        }
        OptionListener listener = new OptionListener();
        dialog = ProjectCustomizer.createCustomizerDialog(layerPath, context.get(), category, listener, null);
        dialog.addWindowListener(listener);
        dialog.setTitle(LBL_CustomizerTitle(ProjectUtils.getInformation(getProject()).getDisplayName()));
        dialog.setVisible(true);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:BasicCustomizer.java


示例3: findAndOpenJavaClass

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
@NbBundle.Messages("JavaUtils.title.class.searching=Searching Class...")
public static void findAndOpenJavaClass(final String classBinaryName, FileObject fileObject) {
    if (classBinaryName == null || fileObject == null) {
        return;
    }

    final JavaSource js = JavaUtils.getJavaSource(fileObject);
    if (js != null) {
        final AtomicBoolean cancel = new AtomicBoolean(false);
        final ClassFinder classFinder = new ClassFinder(js, classBinaryName, cancel);
        if (SourceUtils.isScanInProgress()) {
            ScanDialog.runWhenScanFinished(new Runnable() {
                @Override
                public void run() {
                    ProgressUtils.runOffEventDispatchThread(classFinder, Bundle.JavaUtils_title_class_searching(), cancel, false);
                }
            }, Bundle.JavaUtils_title_class_searching());
        } else {
            ProgressUtils.runOffEventDispatchThread(classFinder, Bundle.JavaUtils_title_class_searching(), cancel, false);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:JavaUtils.java


示例4: fixButtonActionPerformed

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
private void fixButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fixButtonActionPerformed
    final List<FixDescription> fixes = new LinkedList<FixDescription>();

    for (FixDescription fd : this.fixes) {
        if (fd.isSelected()) {
            fixes.add(fd);
        }
    }

    applyingFixes = true;

    try {
        ProgressUtils.showProgressDialogAndRun(new FixWorker(fixes), NbBundle.getMessage(AnalyzerTopComponent.class, "CAP_ApplyingFixes"), false);
    } finally {
        applyingFixes = false;
        stateChanged(null);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:AnalyzerTopComponent.java


示例5: actionPerformed

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
public void actionPerformed(ActionEvent evt, final JTextComponent target) {
    final JavaSource js = JavaSource.forDocument(target.getDocument());
    
    if (js == null) {
        StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(GoToSupport.class, "WARN_CannotGoToGeneric",1));
        return;
    }
    
    final int caretPos = target.getCaretPosition();
    final AtomicBoolean cancel = new AtomicBoolean();
    
    ProgressUtils.runOffEventDispatchThread(new Runnable() {
        @Override
        public void run() {
            goToImpl(target, js, caretPos, cancel);
        }
    }, NbBundle.getMessage(JavaKit.class, "goto-super-implementation"), cancel, false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:GoToSuperTypeAction.java


示例6: propertyChange

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
@NbBundle.Messages({"Loading_HelpCtx_Lengthy_Operation=Please wait while help context is being loaded."})
@Override
public void propertyChange (PropertyChangeEvent ev) {
    if (ev.getPropertyName ().equals ("buran" + OptionsPanelController.PROP_HELP_CTX)) {               //NOI18N
        AtomicBoolean helpCtxLoadingCancelled = new AtomicBoolean(false);
        ProgressUtils.runOffEventDispatchThread(new Runnable() {
            @Override
            public void run() {
                helpCtx = optionsPanel.getHelpCtx();
            }
        }, Bundle.Loading_HelpCtx_Lengthy_Operation(), helpCtxLoadingCancelled, false, 50, 5000);
        if(helpCtxLoadingCancelled.get()) {
            log.fine("Options Dialog - HelpCtx loading cancelled by user."); //NOI18N
        }
        descriptor.setHelpCtx(helpCtx);
    } else if (ev.getPropertyName ().equals ("buran" + OptionsPanelController.PROP_VALID)) {                  //NOI18N            
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                bOK.setEnabled(optionsPanel.dataValid());
                bAPPLY.setEnabled(optionsPanel.isChanged() && optionsPanel.dataValid());
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:OptionsDisplayerImpl.java


示例7: saveOptionsOffEDT

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
@NbBundle.Messages({"Saving_Options_Lengthy_Operation_Title=Lengthy operation in progress",
"Saving_Options_Lengthy_Operation=Please wait while options are being saved."})
private void saveOptionsOffEDT(final boolean okPressed) {
    savingInProgress = true;
    JPanel content = new JPanel();
    content.add(new JLabel(Bundle.Saving_Options_Lengthy_Operation()));
    ProgressUtils.runOffEventThreadWithCustomDialogContent(new Runnable() {
        @Override
        public void run() {
            if(okPressed) {
                optionsPanel.save();
            } else {
                optionsPanel.save(true);
            }
        }
    }, Bundle.Saving_Options_Lengthy_Operation_Title(), content, 50, 5000);
    savingInProgress = false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:OptionsDisplayerImpl.java


示例8: instantiate

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
/**
 * Returns set of instantiated objects.
 *
 * @return set of instantiated objects.
 * @throws IOException when the objects cannot be instantiated.
 */
@Override
public Set instantiate() throws IOException {
    final IOException[] ex = new IOException[1];
    String msgKey = (delegateIterator==null) ? "MSG_DBAppCreate" : "MSG_MasterDetailCreate"; // NOI18N
    String msg = NbBundle.getMessage(MasterDetailWizard.class, msgKey);
    Set set = ProgressUtils.showProgressDialogAndRun(new ProgressRunnable<Set>() {
        @Override
        public Set run(ProgressHandle handle) {
            Set innerSet = null;
            try {
                innerSet = instantiate0();
            } catch (IOException ioex) {
                ex[0] = ioex;
            }
            return innerSet;
        }
    }, msg, false);
    if (ex[0] != null) {
        throw ex[0];
    }
    return set;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:MasterDetailWizard.java


示例9: doTransfer

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
/**
 * Note: The streams will be closed after this method was invoked
 * 
 * @return true if transfer is complete and not interrupted 
 */
private boolean doTransfer(InputStream is, OutputStream os, Integer size, String title) throws IOException {
    MonitorableStreamTransfer ft = new MonitorableStreamTransfer(is, os, size);
    Throwable t;
    // Only show dialog, if the filesize is large enougth and has a use for the user
    if (size == null || size > (1024 * 1024)) {
        t = ProgressUtils.showProgressDialogAndRun(ft, title, false);
    } else {
        t = ft.run(null);
    }
    is.close();
    os.close();
    if (t != null && t instanceof RuntimeException) {
        throw (RuntimeException) t;
    } else if (t != null && t instanceof IOException) {
        throw (IOException) t;
    } else if (t != null) {
        throw new RuntimeException(t);
    }
    return !ft.isCancel();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:BlobFieldTableCellEditor.java


示例10: doTransfer

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
/**
 * Note: The character streams will be closed after this method was invoked
 * 
 * @return true if transfer is complete and not interrupted 
 */
private boolean doTransfer(Reader in, Writer out, Integer size, String title, boolean sizeEstimated) throws IOException {
    // Only pass size if it is _not_ estimated
    MonitorableCharacterStreamTransfer ft = new MonitorableCharacterStreamTransfer(in, out, sizeEstimated ? null : size);
    Throwable t;
    // Only show dialog, if the filesize is large enougth and has a use for the user
    if (size == null || size > (1024 * 1024)) {
        t = ProgressUtils.showProgressDialogAndRun(ft, title, false);
    } else {
        t = ft.run(null);
    }
    in.close();
    out.close();
    if (t != null && t instanceof RuntimeException) {
        throw (RuntimeException) t;
    } else if (t != null && t instanceof IOException) {
        throw (IOException) t;
    } else if (t != null) {
        throw new RuntimeException(t);
    }
    return !ft.isCancel();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ClobFieldTableCellEditor.java


示例11: addAllOpenProducts

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
private static void addAllOpenProducts(final FileTableModel tableModel) {
    final ProgressHandleMonitor pm = ProgressHandleMonitor.create("Populating table");
    Runnable operation = () -> {
        final Product[] products = SnapApp.getDefault().getProductManager().getProducts();
        pm.beginTask("Populating table...", products.length);
        for (Product prod : products) {
            final File file = prod.getFileLocation();
            if (file != null && file.exists()) {
                tableModel.addFile(file);
            }
            pm.worked(1);
        }
        pm.done();
    };

    ProgressUtils.runOffEventThreadWithProgressDialog(operation, "Adding Products", pm.getProgressHandle(), true, 50, 1000);
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:18,代码来源:ProductSetPanel.java


示例12: onApply

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
@Override
protected void onApply() {

    BenchmarkExecutor executor = new BenchmarkExecutor();

    //launch processing with a progress bar
    ProgressHandleMonitor pm = ProgressHandleMonitor.create("Running benchmark", executor);

    executor.setProgressHandleMonitor(pm);

    ProgressUtils.runOffEventThreadWithProgressDialog(executor, "Benchmarking....",
                                                      pm.getProgressHandle(),
                                                      true,
                                                      50,
                                                      1000);
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:17,代码来源:BenchmarkDialog.java


示例13: findLocalFile

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
public static File findLocalFile(String productName, boolean runOffEDT, boolean showError) {
    File productFile;

    if (runOffEDT) {
        AtomicReference<File> returnValue = new AtomicReference<>();
        Runnable operation = () -> returnValue.set(findLocalFile(productName));
        ProgressUtils.runOffEventDispatchThread(operation, "Find Local Product", new AtomicBoolean(), false, 50, 1000);
        productFile = returnValue.get();
    } else {
        productFile = findLocalFile(productName);
    }

    if (productFile == null && showError) {
        Dialogs.showError(String.format("A product named '%s'\n" +
                                                    "couldn't be found in any of your local search paths.\n" +
                                                    "(See tab 'ESA PFA' in the Tools / Options dialog.)", productName));
        return null;
    }

    return productFile;
}
 
开发者ID:bcdev,项目名称:esa-pfa,代码行数:22,代码来源:ProductAccessUtils.java


示例14: openProduct

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
public static Product openProduct(final File productFile) {

        Product product = ProductAccessUtils.findOpenedProduct(productFile);
        if (product != null) {
            return product;
        }

        AtomicReference<Product> returnValue = new AtomicReference<>();
        Runnable operation = () -> {
            try {
                returnValue.set(ProductIO.readProduct(productFile));
            } catch (IOException e) {
                SystemUtils.LOG.log(Level.SEVERE, "Failed to open product.", e);
                Dialogs.showError("Failed to open product.");
            }
        };
        ProgressUtils.runOffEventDispatchThread(operation, "Open Product", new AtomicBoolean(), false, 100, 2000);

        return returnValue.get();
    }
 
开发者ID:bcdev,项目名称:esa-pfa,代码行数:21,代码来源:OpenProductAction.java


示例15: actionPerformed

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    Runnable r = new Runnable() {
        @Override
        public void run() {
            URL url = project.getURL();
            Project prj = null;

            FileObject dir = URLMapper.findFileObject( url );
            if ( dir != null && dir.isFolder() ) {
                try {
                    prj = ProjectManager.getDefault().findProject( dir );
                }
                catch ( IOException ioEx ) {
                    // Ignore invalid folders
                }
            }

            if ( prj != null ) {
                OpenProjects.getDefault().open( new Project[] { prj }, false, true );
            } else {
                String msg = BundleSupport.getMessage("ERR_InvalidProject", project.getDisplayName()); //NOI18N
                NotifyDescriptor nd = new NotifyDescriptor.Message( msg );
                DialogDisplayer.getDefault().notify( nd );
                startBuildingContent();
            }
        }
    };
    ProgressUtils.runOffEventDispatchThread( r, BundleSupport.getLabel("OPEN_RECENT_PROJECT"), new AtomicBoolean(false), false );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:RecentProjectsPanel.java


示例16: findRoot

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
@NbBundle.Messages({
    "TXT_JavadocSearch=Searching Javadoc in {0}"
})
private static Collection<? extends URL> findRoot(final File file, final int type) throws MalformedURLException {
    if (type != CLASSPATH) {                
        final FileObject fo = URLMapper.findFileObject(FileUtil.urlForArchiveOrDir(file));
        if (fo != null) {
            final Collection<FileObject> result = Collections.synchronizedCollection(new ArrayList<FileObject>());
            if (type == SOURCES) {
                final FileObject root = JavadocAndSourceRootDetection.findSourceRoot(fo);
                if (root != null) {
                    result.add(root);
                }
            } else if (type == JAVADOC) {
                final AtomicBoolean cancel = new AtomicBoolean();
                class Task implements ProgressRunnable<Void>, Cancellable {
                    @Override
                    public Void run(ProgressHandle handle) {
                        result.addAll(JavadocAndSourceRootDetection.findJavadocRoots(fo, cancel));
                        return null;
                    }

                    @Override
                    public boolean cancel() {
                        cancel.set(true);
                        return true;
                    }
                }
                final ProgressRunnable<Void> task = new Task();
                ProgressUtils.showProgressDialogAndRun(task, Bundle.TXT_JavadocSearch(file.getAbsolutePath()), false);
            }
            if (!result.isEmpty()) {
                return result.stream()
                        .map(FileObject::toURL)
                        .collect(Collectors.toList());
            }                    
        }
    }
    return Collections.singleton(Utilities.toURI(file).toURL());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:J2SEPlatformCustomizer.java


示例17: addLibraryToProject

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
/**
 * add library to the project to specified classpath
 * Method is called off of AWT thread
 * @param project
 * @param library
 * @param classpathType
 */
public static void addLibraryToProject(Project project, Library library, String classpathType) {
    if(SwingUtilities.isEventDispatchThread()){
        AtomicBoolean cancel = new AtomicBoolean();
        ProgressUtils.runOffEventDispatchThread( new AddLibrary(project, library, classpathType), 
               NbBundle.getMessage(Util.class, 
             "TTL_ExtendProjectClasspath"), cancel, false );  // NOI18N
    } else {
        addLibraryToProject0(project, library, classpathType);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:Util.java


示例18: performClickAction

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
@Override
public void performClickAction(final Document doc, final int offset, HyperlinkType type) {
    final AtomicBoolean cancel = new AtomicBoolean();
    ProgressUtils.runOffEventDispatchThread(new Runnable() {
        @Override
        public void run() {
            goToNQ(doc, offset);
        }
    }, NbBundle.getMessage(NamedQueryHyperlinkProvider.class, "LBL_GoToNamedQuery"), cancel, false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:NamedQueryHyperlinkProvider.java


示例19: showCustomizer

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
@Messages({
    "PROGRESS_checking_for_upgrade=Checking for old harnesses to upgrade",
    "CTL_Close=&Close",
    "CTL_NbPlatformManager_Title=NetBeans Platform Manager"
})
public static Object showCustomizer() {
    final AtomicBoolean canceled = new AtomicBoolean();
    ProgressUtils.runOffEventDispatchThread(new Runnable() { // #207451
        @Override public void run() {
            HarnessUpgrader.checkForUpgrade();
        }
    }, PROGRESS_checking_for_upgrade(), canceled, false);
    NbPlatformCustomizer customizer = new NbPlatformCustomizer();
    JButton closeButton = new JButton();
    Mnemonics.setLocalizedText(closeButton, CTL_Close());
    DialogDescriptor descriptor = new DialogDescriptor(
            customizer,
            CTL_NbPlatformManager_Title(),
            true,
            new Object[] {closeButton},
            closeButton,
            DialogDescriptor.DEFAULT_ALIGN,
            new HelpCtx("org.netbeans.modules.apisupport.project.ui.platform.NbPlatformCustomizer"),
            null);
    Dialog dlg = DialogDisplayer.getDefault().createDialog(descriptor);
    dlg.setVisible(true);
    dlg.dispose();
    return customizer.getSelectedNbPlatform();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:NbPlatformCustomizer.java


示例20: testShowProgressDialogAndRunLater

import org.netbeans.api.progress.ProgressUtils; //导入依赖的package包/类
public void testShowProgressDialogAndRunLater() throws Exception {
    final WM wm = Lookup.getDefault().lookup(WM.class);
    //make sure main window is on screen before proceeding
    wm.await();
    final JFrame jf = (JFrame) WindowManager.getDefault().getMainWindow();
    final CountDownLatch countDown = new CountDownLatch(1);
    final AtomicBoolean glassPaneFound = new AtomicBoolean(false);
    final boolean testGlassPane = canTestGlassPane();
    class R implements ProgressRunnable<String> {
        volatile boolean hasRun;
        @Override
        public String run(ProgressHandle handle) {
            try {
                wm.waitForGlassPane();
                if (testGlassPane) {
                    glassPaneFound.set(jf.getGlassPane() instanceof RunOffEDTImpl.TranslucentMask);
                }
                hasRun = true;
                return "Done";
            } finally {
                countDown.countDown();
            }
        }
    }
    R r = new R();
    Future<String> f = ProgressUtils.showProgressDialogAndRunLater(r, ProgressHandleFactory.createHandle("Something"), true);
    assertNotNull (f);
    assertEquals ("Done", f.get());
    countDown.await();
    assertTrue (r.hasRun);
    assertFalse (f.isCancelled());
    assertTrue (f.isDone());
    assertEquals ("Done", f.get());
    assertTrue ("Glass pane not set", !testGlassPane || glassPaneFound.get());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:RunOffEDTImplTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JDABuilder类代码示例发布时间:2022-05-22
下一篇:
Java ImageLoader类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap