Java Code Examples for org.netbeans.api.progress.ProgressHandle#switchToIndeterminate()
The following examples show how to use
org.netbeans.api.progress.ProgressHandle#switchToIndeterminate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NetworkSupport.java From netbeans with Apache License 2.0 | 6 votes |
@NbBundle.Messages("NetworkSupport.progress.prepare=Preparing download...")
private static Pair<InputStream, Integer> prepareDownload(String url, @NullAllowed ProgressHandle progressHandle) throws NetworkException, InterruptedException {
try {
int contentLength = -1;
URL resource = new URL(url);
if (progressHandle != null) {
progressHandle.switchToIndeterminate();
progressHandle.progress(Bundle.NetworkSupport_progress_prepare());
contentLength = getContentLength(resource);
if (contentLength != -1) {
progressHandle.switchToDeterminate(contentLength);
}
}
checkInterrupted();
// #255861
HttpURLConnection connection = (HttpURLConnection) resource.openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0"); // NOI18N
return Pair.of(connection.getInputStream(), contentLength);
} catch (IOException ex) {
LOGGER.log(Level.INFO, null, ex);
throw new NetworkException(url, ex);
}
}
Example 2
Source File: AttachmentsPanel.java From netbeans with Apache License 2.0 | 6 votes |
private void saveToFile() {
final File file = new FileChooserBuilder(AttachmentsPanel.class)
.setFilesOnly(true).showSaveDialog();
if (file != null) {
String progressFormat = NbBundle.getMessage(
SaveAttachmentAction.class,
"Attachment.saveToFile.progress"); //NOI18N
String progressMessage = MessageFormat.format(progressFormat, getFilename());
final ProgressHandle handle = ProgressHandleFactory.createHandle(progressMessage);
handle.start();
handle.switchToIndeterminate();
Support.getInstance().getParallelRP().post(new Runnable() {
@Override
public void run() {
try {
getAttachmentData(file);
} catch (IOException ioex) {
LOG.log(Level.INFO, ioex.getMessage(), ioex);
} finally {
handle.finish();
}
}
});
}
}
Example 3
Source File: AttachmentsPanel.java From netbeans with Apache License 2.0 | 6 votes |
private void applyPatch() {
String progressFormat = NbBundle.getMessage(AttachmentsPanel.class,"Attachment.applyPatch.progress"); //NOI18N
String progressMessage = MessageFormat.format(progressFormat, getFilename());
final ProgressHandle handle = ProgressHandleFactory.createHandle(progressMessage);
handle.start();
handle.switchToIndeterminate();
Support.getInstance().getParallelRP().post(
new Runnable() {
@Override
public void run() {
IDEServices ideServices = Support.getInstance().getIDEServices();
if(ideServices != null) {
try {
ideServices.applyPatch(saveToTempFile());
} catch (IOException ex) {
LOG.log(Level.WARNING, ex.getMessage(), ex);
} finally {
handle.finish();
}
}
}
});
}
Example 4
Source File: MySQLDatabaseServer.java From netbeans with Apache License 2.0 | 6 votes |
@Override
public void execute() throws Exception {
ProgressHandle handle = ProgressHandleFactory.createHandle(Utils.getMessage("LBL_StoppingMySQLServer"), this);
try {
handle.start();
handle.switchToIndeterminate();
proc = runProcess(getStopPath(), getStopArgs());
// wait until server is shut down
proc.waitFor();
} finally {
if (proc != null) {
proc.destroy();
closeOutput();
}
handle.finish();
}
}
Example 5
Source File: ExecutionService.java From netbeans with Apache License 2.0 | 6 votes |
private ProgressHandle createProgressHandle(InputOutput inputOutput,
String displayName, Cancellable cancellable) {
if (!descriptor.showProgress() && !descriptor.showSuspended()) {
return null;
}
ProgressHandle handle = ProgressHandleFactory.createHandle(displayName,
cancellable, new ProgressAction(inputOutput));
handle.setInitialDelay(0);
handle.start();
handle.switchToIndeterminate();
if (descriptor.showSuspended()) {
handle.suspend(NbBundle.getMessage(ExecutionService.class, "Running"));
}
return handle;
}
Example 6
Source File: DBSchemaTablesPanel.java From netbeans with Apache License 2.0 | 5 votes |
private void invokeHandlers(final List<Handler> handlers, final Parameters params) {
final ProgressPanel progressPanel = new ProgressPanel();
ProgressHandle progressHandle = ProgressHandleFactory.createHandle(null);
JComponent progressComponent = ProgressHandleFactory.createProgressComponent(progressHandle);
progressHandle.start();
progressHandle.switchToIndeterminate();
final int[] index = new int[1];
try {
RequestProcessor.Task task = RequestProcessor.getDefault().create(new Runnable() {
public void run() {
index[0] = invokeHandlers(handlers, index[0], params, progressPanel);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
progressPanel.close();
}
});
}
});
while (index[0] < handlers.size()) {
index[0] = invokeHandlers(handlers, index[0], params, null);
if (index[0] < handlers.size()) {
task.schedule(0);
progressPanel.open(progressComponent);
}
}
} finally {
progressHandle.finish();
}
}
Example 7
Source File: FaceletsLibrarySupport.java From netbeans with Apache License 2.0 | 5 votes |
private Map<String, Library> findLibraries() {
ProgressHandle progress = ProgressHandleFactory.createHandle(
NbBundle.getMessage(FaceletsLibrarySupport.class, "MSG_ParsingFaceletsLibraries")); //NOI18N
progress.start();
progress.switchToIndeterminate();
try {
return _findLibraries();
} finally {
progress.finish();
}
}
Example 8
Source File: RetrieverEngineImpl.java From netbeans with Apache License 2.0 | 5 votes |
public void run() {
ProgressHandle ph = ProgressHandleFactory.createHandle(
NbBundle.getMessage(RetrieverEngineImpl.class,"LBL_PROGRESSBAR_Retrieve_XML"),
new Cancellable(){
public boolean cancel() {
synchronized(RetrieverEngineImpl.this){
if(!RetrieverEngineImpl.this.STOP_PULL){
RetrieverEngineImpl.this.STOP_PULL = true;
//taskThread.interrupt();
}
}
return true;
}
}, new AbstractAction(){
public void actionPerformed(ActionEvent e) {
getOPWindow().setOutputVisible(true);
getOPWindow().select();
}
});
ph.start();
ph.switchToIndeterminate();
try{
pullRecursively();
}finally{
ph.finish();
}
}
Example 9
Source File: CustomizationWSEditor.java From netbeans with Apache License 2.0 | 4 votes |
private void saveAndRefresh(final Node node) {
Collection<SaveableSectionInnerPanel> panels = wsTopComponent.getPanels();
for (SaveableSectionInnerPanel panel : panels) {
panel.save();
if (!wsdlIsDirty) {
wsdlIsDirty = panel.wsdlIsDirty();
}
}
try {
if (wsdlIsDirty) {
Set<WSDLModel> modelSet = wsdlModels.keySet();
for (WSDLModel wsdlModel : modelSet) {
ModelSource ms = wsdlModel.getModelSource();
FileObject fo = (FileObject) ms.getLookup().lookup(FileObject.class);
DataObject wsdlDO = DataObject.find(fo);
SaveCookie wsdlSaveCookie = (SaveCookie) wsdlDO.getCookie(SaveCookie.class);
if (wsdlSaveCookie != null) {
wsdlSaveCookie.save();
}
}
}
final ProgressHandle handle = ProgressHandleFactory.createHandle
(NbBundle.getMessage(CustomizationWSEditor.class, "TXT_Refreshing")); //NOI18N
handle.start(100);
handle.switchToIndeterminate();
Runnable r = new Runnable() {
public void run() {
try {
if (wsdlIsDirty) {
RefreshCookie refreshCookie =
(RefreshCookie) node.getCookie(RefreshCookie.class);
if (refreshCookie != null) {
refreshCookie.refreshService(false);
}
}
} finally {
handle.finish();
}
}
};
RequestProcessor.getDefault().post(r);
} catch (Exception e) {
ErrorManager.getDefault().notify(e);
}
}
Example 10
Source File: CustomizationWSEditor.java From netbeans with Apache License 2.0 | 4 votes |
private void saveAndRefresh(final Node node, JaxWsModel jaxWsModel) {
if (wsTopComponent == null) return; // top component cannot be initialized for some reason - see error message from createWSEditorComponent()
Collection<SaveableSectionInnerPanel> panels = wsTopComponent.getPanels();
for (SaveableSectionInnerPanel panel : panels) {
panel.save();
if (!wsdlIsDirty) {
wsdlIsDirty = panel.wsdlIsDirty();
}
if (!jaxwsDirty) {
jaxwsDirty = panel.jaxwsIsDirty();
}
}
try {
if (wsdlIsDirty) {
Set<WSDLModel> modelSet = wsdlModels.keySet();
for (WSDLModel wsdlModel : modelSet) {
ModelSource ms = wsdlModel.getModelSource();
FileObject fo = (FileObject) ms.getLookup().lookup(FileObject.class);
DataObject wsdlDO = DataObject.find(fo);
SaveCookie wsdlSaveCookie = (SaveCookie) wsdlDO.getCookie(SaveCookie.class);
if (wsdlSaveCookie != null) {
wsdlSaveCookie.save();
}
}
}
if (jaxwsDirty) {
jaxWsModel.write();
}
final ProgressHandle handle = ProgressHandleFactory.createHandle
(NbBundle.getMessage(CustomizationWSEditor.class, "TXT_Refreshing")); //NOI18N
handle.start(100);
handle.switchToIndeterminate();
Runnable r = new Runnable() {
public void run() {
try {
if (wsdlIsDirty || jaxwsDirty) {
JaxWsRefreshCookie refreshCookie =
(JaxWsRefreshCookie) node.getCookie(JaxWsRefreshCookie.class);
if (refreshCookie != null) {
refreshCookie.refreshService(false);
}
}
} finally {
handle.finish();
}
}
};
RequestProcessor.getDefault().post(r);
} catch (Exception e) {
ErrorManager.getDefault().notify(e);
}
}
Example 11
Source File: MySQLDatabaseServer.java From netbeans with Apache License 2.0 | 4 votes |
@Override
public void reconnect(long timeToWait) throws DatabaseException, TimeoutException {
ArrayBlockingQueue<Runnable> queue = null;
checkNotOnDispatchThread();
queue = new ArrayBlockingQueue<Runnable>(1);
DatabaseCommand cmd = new DatabaseCommand(queue) {
@Override
public void execute() throws Exception {
disconnectSync();
checkConfiguration();
ProgressHandle progress = ProgressHandleFactory.createHandle(
Utils.getMessage("MSG_ConnectingToServer"));
try {
progress.start();
progress.switchToIndeterminate();
Connection conn = DatabaseUtils.connect(getURL(), getUser(), getPassword());
if (conn == null) {
throw new DatabaseException(NbBundle.getMessage(MySQLDatabaseServer.class, "MSG_UnableToConnect", getURL(), getUser())); // NOI8N
}
connProcessor.setConnection(conn);
setState(ServerState.CONNECTED);
} catch (DatabaseException dbe) {
disconnect();
throw dbe;
} catch (TimeoutException te) {
disconnect();
throw te;
}
finally {
refreshDatabaseList();
progress.finish();
}
}
};
cmd.postCommand("reconnect"); // NOI18N
// Sync up
try {
cmd.syncUp();
if (cmd.getException() != null) {
if (cmd.getException() instanceof DatabaseException) {
throw new DatabaseException(cmd.getException());
} else if (cmd.getException() instanceof TimeoutException) {
TimeoutException newte = new TimeoutException(cmd.getException().getMessage());
newte.initCause(cmd.getException());
throw newte;
} else {
throw Utils.launderThrowable(cmd.getException());
}
}
} catch (InterruptedException ie) {
LOGGER.log(Level.INFO, null, ie);
Thread.currentThread().interrupt();
}
}