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


Java ProgressUtils类代码示例

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


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


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