@Override protected void onPreExecute() { if (dialogShow) { progDialog = new ProgressDialog(RssReaderActivity.this); progDialog.setCancelable(false); progDialog.setMessage(getString(R.string.rss_fetching)); progDialog.setButton( DialogInterface.BUTTON_NEGATIVE, getString(R.string.btn_hide_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Toast.makeText( RssReaderActivity.this, R.string.rss_keep_updating, Toast.LENGTH_SHORT) .show(); } }); progDialog.show(); } else Toast.makeText(RssReaderActivity.this, R.string.rss_start_updating, Toast.LENGTH_SHORT) .show(); isTaskRunning = true; }
private void deleteObjectclass() { ArrayList<LocalizableMessage> errors = new ArrayList<>(); ProgressDialog dlg = new ProgressDialog( Utilities.createFrame(), Utilities.getParentDialog(this), INFO_CTRL_PANEL_DELETE_OBJECTCLASS_TITLE.get(), getInfo()); LinkedHashSet<ObjectClass> ocsToDelete = new LinkedHashSet<>(); ocsToDelete.add(objectClass); LinkedHashSet<AttributeType> attrsToDelete = new LinkedHashSet<>(0); DeleteSchemaElementsTask newTask = new DeleteSchemaElementsTask(getInfo(), dlg, ocsToDelete, attrsToDelete); for (Task task : getInfo().getTasks()) { task.canLaunch(newTask, errors); } Schema schema = getInfo().getServerDescriptor().getSchema(); ArrayList<String> childClasses = new ArrayList<>(); if (schema != null) { for (ObjectClass o : schema.getObjectClasses().values()) { for (ObjectClass superior : o.getSuperiorClasses()) { if (objectClass.equals(superior)) { childClasses.add(o.getNameOrOID()); } } } } else { errors.add(ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_DETAILS.get()); } if (errors.isEmpty()) { LocalizableMessageBuilder mb = new LocalizableMessageBuilder(); if (!childClasses.isEmpty()) { mb.append( INFO_OBJECTCLASS_IS_SUPERIOR.get( ocName, Utilities.getStringFromCollection(childClasses, ", "))); mb.append("<br>"); } LocalizableMessage confirmationMessage = INFO_CTRL_PANEL_CONFIRMATION_DELETE_OBJECTCLASS_DETAILS.get(ocName); mb.append(confirmationMessage); if (displayConfirmationDialog( INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(), confirmationMessage)) { launchOperation( newTask, INFO_CTRL_PANEL_DELETING_OBJECTCLASS_SUMMARY.get(ocName), INFO_CTRL_PANEL_DELETING_OBJECTCLASS_COMPLETE.get(), INFO_CTRL_PANEL_DELETING_OBJECTCLASS_SUCCESSFUL.get(ocName), ERR_CTRL_PANEL_DELETING_OBJECTCLASS_ERROR_SUMMARY.get(), ERR_CTRL_PANEL_DELETING_OBJECTCLASS_ERROR_DETAILS.get(ocName), null, dlg); dlg.setVisible(true); } } else { displayErrorDialog(errors); } }
/** @Method: showProgress @Description: ��½ʱ�������ʾ. */ private void showProgress() { mProgressDialog = new ProgressDialog(this); mProgressDialog.setIcon(R.drawable.l_cn_48); mProgressDialog.setTitle("�ϴ���,���Ժ�..."); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); mProgressDialog.show(); }
private void deleteClicked() { ArrayList<Message> errors = new ArrayList<Message>(); TreePath[] paths = treePane.getTree().getSelectionPaths(); ArrayList<AbstractIndexDescriptor> indexesToDelete = new ArrayList<AbstractIndexDescriptor>(); ArrayList<String> indexesNames = new ArrayList<String>(); if (paths != null) { for (TreePath path : paths) { Object node = path.getLastPathComponent(); if (node instanceof IndexTreeNode) { indexesToDelete.add(((IndexTreeNode) node).getIndex()); } else if (node instanceof VLVIndexTreeNode) { indexesToDelete.add(((VLVIndexTreeNode) node).getIndex()); } } } else { errors.add(ERR_CTRL_PANEL_NO_INDEX_SELECTED.get()); } for (AbstractIndexDescriptor index : indexesToDelete) { indexesNames.add(index.getName()); } String nameLabel = Utilities.getStringFromCollection(indexesNames, ", "); String backendName = indexesToDelete.get(0).getBackend().getBackendID(); if (errors.isEmpty()) { ProgressDialog dlg = new ProgressDialog( Utilities.createFrame(), Utilities.getParentDialog(this), INFO_CTRL_PANEL_DELETE_INDEXES_TITLE.get(), getInfo()); DeleteIndexTask newTask = new DeleteIndexTask(getInfo(), dlg, indexesToDelete); for (Task task : getInfo().getTasks()) { task.canLaunch(newTask, errors); } if (errors.isEmpty()) { if (displayConfirmationDialog( INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(), INFO_CTRL_PANEL_CONFIRMATION_INDEXES_DELETE_DETAILS.get(nameLabel, backendName))) { launchOperation( newTask, INFO_CTRL_PANEL_DELETING_INDEXES_SUMMARY.get(), INFO_CTRL_PANEL_DELETING_INDEXES_COMPLETE.get(), INFO_CTRL_PANEL_DELETING_INDEXES_SUCCESSFUL.get(nameLabel, backendName), ERR_CTRL_PANEL_DELETING_INDEXES_ERROR_SUMMARY.get(), ERR_CTRL_PANEL_DELETING_INDEXES_ERROR_DETAILS.get(nameLabel), null, dlg); dlg.setVisible(true); } } } if (!errors.isEmpty()) { displayErrorDialog(errors); } }
@Override protected Dialog onCreateDialog(int id) { switch (id) { case PROGRESS_DIALOG: progressDialog = new ProgressDialog(D4.this); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setMessage("Loading..."); return progressDialog; default: return null; } }
private void selfUpdate() { URL url = updateUrl; if (url != null) { SelfUpdater downloader = new SelfUpdater(launcher, url); ObservableFuture<File> future = new ObservableFuture<File>( launcher.getExecutor().submit(downloader), downloader); Futures.addCallback(future, new FutureCallback<File>() { @Override public void onSuccess(File result) { SwingHelper.showMessageDialog( LauncherFrame.this, _("launcher.selfUpdateComplete"), _("launcher.selfUpdateCompleteTitle"), null, JOptionPane.INFORMATION_MESSAGE); LauncherFrame.this.updateRequired = false; } @Override public void onFailure(Throwable t) { } }, SwingExecutor.INSTANCE); ProgressDialog.showProgress(this, future, _("launcher.selfUpdatingTitle"), _("launcher.selfUpdatingStatus")); SwingHelper.addErrorDialogCallback(this, future); } else { SwingHelper.showMessageDialog( LauncherFrame.this, _("launcher.selfUpdateCheckError"), _("launcher.genericError"), null, JOptionPane.INFORMATION_MESSAGE); } }
private void launch() { try { final Instance instance = launcher.getInstances().get(instancesTable.getSelectedRow()); boolean update = updateCheck.isSelected() && instance.isUpdatePending(); // Store last access date Date now = new Date(); instance.setLastAccessed(now); Persistence.commitAndForget(instance); // Perform login final Session session = LoginDialog.showLoginRequest(this, launcher); if (session == null) { return; } // If we have to update, we have to update if (!instance.isInstalled()) { update = true; } if (update) { // Execute the updater Updater updater = new Updater(launcher, instance); updater.setOnline(session.isOnline()); ObservableFuture<Instance> future = new ObservableFuture<Instance>( launcher.getExecutor().submit(updater), updater); // Show progress ProgressDialog.showProgress( this, future, _("launcher.updatingTitle"), _("launcher.updatingStatus", instance.getTitle())); SwingHelper.addErrorDialogCallback(this, future); // Update the list of instances after updating future.addListener(new Runnable() { @Override public void run() { instancesModel.update(); } }, SwingExecutor.INSTANCE); // On success, launch also Futures.addCallback(future, new FutureCallback<Instance>() { @Override public void onSuccess(Instance result) { launch(instance, session); } @Override public void onFailure(Throwable t) { } }, SwingExecutor.INSTANCE); } else { launch(instance, session); } } catch (ArrayIndexOutOfBoundsException e) { SwingHelper.showErrorDialog(this, _("launcher.noInstanceError"), _("launcher.noInstanceTitle")); } }
public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == okButton) { dispose(); // Starts copying files ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("progress_dialog.processing_files")); ChangeFileAttributesJob job = new ChangeFileAttributesJob( progressDialog, mainFrame, files, getPermInt(), recurseDirCheckBox.isSelected()); progressDialog.start(job); } else if (source == cancelButton) { dispose(); } }
/** * Provide a custom view to be displayed. * * @param view Must not be null * @return Current HUD */ public KProgressHUD setCustomView(View view) { if (view != null) { mProgressDialog.setView(view); } else { throw new RuntimeException("Custom view must not be null!"); } return this; }
@Override protected void onPrepareDialog(int id, Dialog dialog) { switch (id) { case PROGRESS_DIALOG: progressDialog.setProgress(0); progressThread = new ProgressThread(handler); progressThread.start(); } }
@Override public void handleMessage(Message msg) { int total = msg.arg1; progressDialog.setProgress(total); if (total >= 100) { dismissDialog(PROGRESS_DIALOG); progressThread.setState(ProgressThread.STATE_DONE); } }
private void onSetVideoParam(int flag) { mTipDlg.dismiss(); if (0 != flag) { toast(R.string.dlg_set_video_capture_param_fail_tip); } else { m_video_config = m_new_video_config; toast(R.string.dlg_set_video_capture_param_succeed_tip); finish(); } }
protected Dialog onCreateDialog(int id) { switch (id) { case 0: mProgress = new ProgressDialog(this); mProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgress.setTitle("Updating"); mProgress.setMessage("Wait..."); mProgress.setCancelable(false); mProgress.setButton( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { mQuit = true; dismissDialog(0); } }); return mProgress; } return null; }
/** * Saves the index modifications. * * @param modal whether the progress dialog for the task must be modal or not. */ private void saveIndex(boolean modal) { newModifyTask = null; if (!isModified()) { return; } List<LocalizableMessage> errors = getErrors(); if (errors.isEmpty()) { ProgressDialog dlg = new ProgressDialog( Utilities.getFrame(this), Utilities.getFrame(this), INFO_CTRL_PANEL_MODIFYING_INDEX_TITLE.get(), getInfo()); dlg.setModal(modal); newModifyTask = new ModifyIndexTask(getInfo(), dlg); for (Task task : getInfo().getTasks()) { task.canLaunch(newModifyTask, errors); } if (errors.isEmpty()) { String attributeName = index.getName(); String backendName = index.getBackend().getBackendID(); launchOperation( newModifyTask, INFO_CTRL_PANEL_MODIFYING_INDEX_SUMMARY.get(attributeName), INFO_CTRL_PANEL_MODIFYING_INDEX_COMPLETE.get(), INFO_CTRL_PANEL_MODIFYING_INDEX_SUCCESSFUL.get(attributeName, backendName), ERR_CTRL_PANEL_MODIFYING_INDEX_ERROR_SUMMARY.get(), ERR_CTRL_PANEL_MODIFYING_INDEX_ERROR_DETAILS.get(attributeName), null, dlg); saveChanges.setEnabled(false); dlg.setVisible(true); } } if (!errors.isEmpty()) { displayErrorDialog(errors); } }
// TODO: deprecate public boolean processTask( ProgressKeeper pk, ProgressDialog d, SwingWorker<Boolean, Boolean> sw) { sw.execute(); d.setVisible(true); try { return sw.get(); } catch (ExecutionException e) { handleConverterException("Exception during conversion", null, e.getCause()); return false; } catch (InterruptedException e) { handleConverterException("Conversion was cancelled or interrupted", null, e); return false; } }
protected void initWidget() { mTipDlg = new ProgressDialog(this, R.string.dlg_login_server_tip); mTipDlg.setCancelable(false); m_device_id = getIntent().getStringExtra(Constant.EXTRA_DEVICE_ID); m_tb_h_flip = (ToggleButton) findViewById(R.id.tb_image_h_flip); m_tb_v_flip = (ToggleButton) findViewById(R.id.tb_image_v_flip); Button btnFinish = (Button) findViewById(R.id.btnRight); btnFinish.setText(R.string.finish); btnFinish.setVisibility(View.VISIBLE); btnFinish.setOnClickListener(this); LibImpl.getInstance().setMediaParamHandler(m_handler); loadData(); }
public void handleMessage(Message msg) { mValue++; mText.setText(Integer.toString(mValue)); try { Thread.sleep(50); } catch (InterruptedException e) {; } if (mValue < 100 && mQuit == false) { mProgress.setProgress(mValue); mHandler.sendEmptyMessage(0); } else { dismissDialog(0); } }
private void deleteIndex() { List<LocalizableMessage> errors = new ArrayList<>(); ProgressDialog dlg = new ProgressDialog( Utilities.createFrame(), Utilities.getParentDialog(this), INFO_CTRL_PANEL_DELETE_INDEX_TITLE.get(), getInfo()); ArrayList<AbstractIndexDescriptor> indexesToDelete = new ArrayList<>(); indexesToDelete.add(index); DeleteIndexTask newTask = new DeleteIndexTask(getInfo(), dlg, indexesToDelete); for (Task task : getInfo().getTasks()) { task.canLaunch(newTask, errors); } if (errors.isEmpty()) { String indexName = index.getName(); String backendName = index.getBackend().getBackendID(); if (displayConfirmationDialog( INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(), INFO_CTRL_PANEL_CONFIRMATION_INDEX_DELETE_DETAILS.get(indexName, backendName))) { launchOperation( newTask, INFO_CTRL_PANEL_DELETING_INDEX_SUMMARY.get(), INFO_CTRL_PANEL_DELETING_INDEX_COMPLETE.get(), INFO_CTRL_PANEL_DELETING_INDEX_SUCCESSFUL.get(indexName, backendName), ERR_CTRL_PANEL_DELETING_INDEX_ERROR_SUMMARY.get(), ERR_CTRL_PANEL_DELETING_INDEX_ERROR_DETAILS.get(indexName), null, dlg); dlg.setVisible(true); } } else { displayErrorDialog(errors); } }
@Override protected void onPostExecute(Boolean result) { if (dialogShow) progDialog.cancel(); if (result) { Toast.makeText(RssReaderActivity.this, R.string.rss_items_update_done, Toast.LENGTH_SHORT) .show(); rssFeed = dbQuery.getRssFeed(name, limit); updateListView(); } else Toast.makeText(RssReaderActivity.this, R.string.rss_item_not_update, Toast.LENGTH_SHORT) .show(); dbQuery.updateRssItems(); isTaskRunning = false; }
private static void creerProgressDialog() { mProgressDialog = new ProgressDialog(AppData.currentContext); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressDialog.setTitle(AppData.currentContext.getString(R.string.loading)); mProgressDialog.setMessage(AppData.currentContext.getString(R.string.startLoading)); mProgressDialog.setMax(100); mProgressDialog.setProgress(0); mProgressDialog.setCancelable(false); }
public void saveData() { m_new_video_config = (NetSDK_Media_Video_Config) m_video_config.clone(); m_new_video_config.capture.HFlip = m_tb_h_flip.isChecked() ? "1" : "0"; m_new_video_config.capture.VFlip = m_tb_v_flip.isChecked() ? "1" : "0"; m_new_video_config.addHead(false); String xml = m_new_video_config.getCaptureXMLString(); int ret = FunclibAgent.getInstance().SetP2PDevConfig(m_device_id, 524, xml); if (0 != ret) { toast(R.string.dlg_set_video_capture_param_fail_tip); return; } mTipDlg.setCallback(null); showTipDlg( R.string.dlg_set_video_capture_param_tip, 20000, R.string.dlg_set_video_capture_param_timeout_tip); }
void requestAccountList() { prog = ProgressDialog.show( this, null, getString(R.string.account_list_progress), false, true, new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { cancel(); } }); queryThread = new Thread(this, "Requestor Thread"); queryThread.setDaemon(true); queryThread.start(); }
private void onGetVideoParam(int flag, NetSDK_Media_Video_Config cfg) { mTipDlg.dismiss(); if (flag != 0 || null == cfg) { toast(R.string.dlg_get_media_param_fail_tip); finish(); return; } m_video_config = cfg; if (cfg.encode.EncodeList.size() < 2) { toast(R.string.dlg_get_media_param_format_incorrect_tip); return; } // 根据获取到的数据设置界面 m_tb_h_flip.setChecked(1 == Integer.parseInt(m_video_config.capture.HFlip)); m_tb_v_flip.setChecked(1 == Integer.parseInt(m_video_config.capture.VFlip)); }
private void launch(Instance instance, Session session) { final File extractDir = launcher.createExtractDir(); // Get the process Runner task = new Runner(launcher, instance, session, extractDir); ObservableFuture<Process> processFuture = new ObservableFuture<Process>( launcher.getExecutor().submit(task), task); // Show process for the process retrieval ProgressDialog.showProgress( this, processFuture, _("launcher.launchingTItle"), _("launcher.launchingStatus", instance.getTitle())); // If the process is started, get rid of this window Futures.addCallback(processFuture, new FutureCallback<Process>() { @Override public void onSuccess(Process result) { dispose(); } @Override public void onFailure(Throwable t) { } }); // Watch the created process ListenableFuture<?> future = Futures.transform( processFuture, new LaunchProcessHandler(launcher), launcher.getExecutor()); SwingHelper.addErrorDialogCallback(null, future); // Clean up at the very end future.addListener(new Runnable() { @Override public void run() { try { log.info("Process ended; cleaning up " + extractDir.getAbsolutePath()); FileUtils.deleteDirectory(extractDir); } catch (IOException e) { log.log(Level.WARNING, "Failed to clean up " + extractDir.getAbsolutePath(), e); } instancesModel.update(); } }, sameThreadExecutor()); }
private void loadInstances() { InstanceList.Enumerator loader = launcher.getInstances().createEnumerator(); ObservableFuture<InstanceList> future = new ObservableFuture<InstanceList>( launcher.getExecutor().submit(loader), loader); future.addListener(new Runnable() { @Override public void run() { instancesModel.update(); if (instancesTable.getRowCount() > 0) { instancesTable.setRowSelectionInterval(0, 0); } requestFocus(); } }, SwingExecutor.INSTANCE); ProgressDialog.showProgress(this, future, _("launcher.checkingTitle"), _("launcher.checkingStatus")); SwingHelper.addErrorDialogCallback(this, future); }
/** * Specify the HUD style (not needed if you use a custom view) * * @param style One of the KProgressHUD.Style values * @return Current HUD */ public KProgressHUD setStyle(Style style) { View view = null; switch (style) { case SPIN_INDETERMINATE: view = new SpinView(mContext); break; case PIE_DETERMINATE: view = new PieView(mContext); break; case ANNULAR_DETERMINATE: view = new AnnularView(mContext); break; case BAR_DETERMINATE: view = new BarView(mContext); break; // No custom view style here, because view will be added later } mProgressDialog.setView(view); return this; }
public void loadData() { int ret = FunclibAgent.getInstance().GetP2PDevConfig(m_device_id, 501); if (0 != ret) { toast(R.string.dlg_get_media_param_fail_tip); finish(); return; } mTipDlg.setCallback( new ProgressDialog.ICallback() { @Override public void onTimeout() { finish(); } @Override public boolean onCancel() { return false; } }); showTipDlg(R.string.dlg_get_media_param_tip, 20000, R.string.dlg_get_media_param_timeout_tip); }
private void confirmHardUpdate(Instance instance) { if (!SwingHelper.confirmDialog(this, _("instance.confirmHardUpdate"), _("confirmTitle"))) { return; } // Execute the resetter HardResetter resetter = new HardResetter(instance); ObservableFuture<Instance> future = new ObservableFuture<Instance>( launcher.getExecutor().submit(resetter), resetter); // Show progress ProgressDialog.showProgress( this, future, _("instance.resettingTitle"), _("instance.resettingStatus", instance.getTitle())); SwingHelper.addErrorDialogCallback(this, future); // Update the list of instances after updating future.addListener(new Runnable() { @Override public void run() { launch(); instancesModel.update(); } }, SwingExecutor.INSTANCE); }
/** * creates a new EncryptionSwingWorker * * @param parentFrame the parent frame * @param backupMainPanel the BackupMainPanel * @param destinationPath the path of the current destination directory * @param encfsPlainDir the plaintext encfs dir where to copy the files into * @param encfsCipherPath the path of the ciphertext encfs dir * @param password the encfs password */ public EncryptionFinishSwingWorker( Frame parentFrame, BackupMainPanel backupMainPanel, String destinationPath, File encfsPlainDir, String encfsCipherPath, String password) { this.parentFrame = parentFrame; this.backupMainPanel = backupMainPanel; this.destinationPath = destinationPath; this.encfsPlainDir = encfsPlainDir; this.encfsCipherPath = encfsCipherPath; this.password = password; encfsPath = encfsPlainDir.getPath(); processExecutor = new ProcessExecutor(); ProgressDialog progressDialog = new ProgressDialog(parentFrame, processExecutor); progressDialog.setIcon(IconManager.INFORMATION_ICON); progressDialog.setMessage(BUNDLE.getString("Removing_Unencrypted_Files")); progressDialog.setSpecialIcon(null); progressDialog.setIndeterminate(true); progressDialog.setCancelButtonVisible(false); dialogHandler = new ModalDialogHandler(progressDialog); dialogHandler.show(); }
public void dismiss() { if (mProgressDialog != null && mProgressDialog.isShowing()) { mProgressDialog.dismiss(); } }