List of usage examples for org.eclipse.jface.dialogs IDialogConstants CANCEL_ID
int CANCEL_ID
To view the source code for org.eclipse.jface.dialogs IDialogConstants CANCEL_ID.
Click Source Link
From source file:com.nokia.s60tools.creator.job.RunInDeviceJob.java
License:Open Source License
/** * Check if user wants to replace existing file * @return <code>true</code> if replace, <code>false</code> otherwise. * @throws JobCancelledByUserException //from www . j a v a 2s . co m */ private boolean showReplaceFileDialog() throws JobCancelledByUserException { Runnable runDlg = new Runnable() { public void run() { // Shell shell = CreatorActivator.getCurrentlyActiveWbWindowShell(); ConfirmFileReplaceDialog dlg = new ConfirmFileReplaceDialog(shell, destFilePath); dlg.open(); confirmDialogSelection = dlg.getSelection(); } }; Display.getDefault().syncExec(runDlg); if (confirmDialogSelection == IDialogConstants.CANCEL_ID) { throwJobCancelledException(); } boolean replace = confirmDialogSelection == IDialogConstants.YES_ID ? true : false; return replace; }
From source file:com.nokia.s60tools.creator.job.ShutdownCreatorInDeviceDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { GridLayout gdl = new GridLayout(1, false); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER); parent.setLayout(gdl);//from w w w . j ava 2s . c om parent.setLayoutData(gd); createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true); }
From source file:com.nokia.s60tools.creator.job.ShutdownCreatorInDeviceDialog.java
License:Open Source License
protected void buttonPressed(int buttonId) { // Save pressed button id selection = buttonId;//from ww w .ja va 2 s . c o m if (buttonId != IDialogConstants.CANCEL_ID) { // Save "Don't ask again" state CreatorPreferences.setDontAskShutdownCreator(dontShowAgainBtn.getSelection()); } super.close(); }
From source file:com.nokia.s60tools.memspy.ui.dialogs.SWMTCategoriesDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true); okActionBtn = getButton(IDialogConstants.OK_ID); }
From source file:com.nokia.s60tools.memspy.ui.wizards.MemSpyWizardDialog.java
License:Open Source License
public void enableBackCancelButtons(boolean enable) { getButton(IDialogConstants.BACK_ID).setEnabled(enable); getButton(IDialogConstants.CANCEL_ID).setEnabled(enable); }
From source file:com.nokia.s60tools.memspy.ui.wizards.MemSpyWizardDialog.java
License:Open Source License
public void setCancelText(String newText) { getButton(IDialogConstants.CANCEL_ID).setText(newText); }
From source file:com.nokia.s60tools.metadataeditor.dialogs.AddLibraryDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { // Creating just OK button createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); Button ok = getButton(IDialogConstants.OK_ID); ok.setEnabled(false);//w ww . jav a 2 s.c o m }
From source file:com.nokia.s60tools.remotecontrol.ftp.ui.view.FtpUtils.java
License:Open Source License
/** * Download file and change it's name//from w ww . j av a2 s.c om * @param viewer Viewer * @param contentProvider Content provider */ static public void downloadFileAs(TableViewer viewer, ViewContentProvider contentProvider) { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); Object selectedObject = selection.getFirstElement(); if (selectedObject == null || !FtpFileObject.class.isInstance(selectedObject)) { // Nothing selected or selection is not file return; } FtpFileObject ftpObject = (FtpFileObject) selectedObject; // Show Save as dialog to user Shell sh = RemoteControlActivator.getCurrentlyActiveWbWindowShell(); FileDialog fileDialog = new FileDialog(sh, SWT.SAVE); fileDialog.setFileName(ftpObject.getName()); fileDialog.setText(Messages.getString("FtpUtils.DownloadAs_DialogText")); //$NON-NLS-1$ // Get user selected folder String destFile = fileDialog.open(); if (destFile == null) { // User is canceled dialog return; } // Full path for remote file String currentDirectory = getCurrentPath(contentProvider); String remoteFile = currentDirectory + ftpObject.getName(); String destFileName = destFile.substring(destFile.lastIndexOf(File.separator) + File.separator.length()); // Remember last used folder String destFolder = destFile.substring(0, destFile.lastIndexOf(File.separator)); RCPreferences.setDownloadLocation(destFolder); destFolder = addFileSepatorToEnd(destFolder); FileDownloadJob job = null; boolean canWrite = true; if (RCPreferences.getDownloadConfirm()) { // Confirm replace from user if file already exists File file = new File(destFile); if (file.exists()) { // Show confirmation dialog ConfirmReplaceDialog dlg = new ConfirmReplaceDialog(sh, destFileName, false, ConfirmReplaceDialog.Operation.DOWNLOAD); dlg.open(); int sel = dlg.getSelection(); switch (sel) { case ConfirmReplaceDialog.RENAME_ID: // Rename this file RenameDialog renameDlg = new RenameDialog(sh, destFileName, true, RENAME_FILE_DLG_NAME); if (renameDlg.open() == Dialog.CANCEL) { // User canceled dialog return; } // Get new file name from dialog. If user canceled dialog the original // filename is returned destFile = destFolder + renameDlg.getFileName(); canWrite = true; break; case IDialogConstants.YES_ID: // Replace this file canWrite = true; break; case IDialogConstants.NO_ID: // Do not replace this file canWrite = false; break; case IDialogConstants.CANCEL_ID: // Cancel operation return; default: break; } } } if (canWrite) { job = new FileDownloadJob(Messages.getString("FtpUtils.Download_File_Job_Name") + ftpObject.getName(), //$NON-NLS-1$ remoteFile, destFile); job.setPriority(Job.DECORATE); job.schedule(); } }
From source file:com.nokia.s60tools.remotecontrol.ftp.ui.view.FtpUtils.java
License:Open Source License
/** * Download all selected files/*from w w w . j a v a 2 s .c o m*/ * @param viewer Viewer * @param contentProvider Content provider */ @SuppressWarnings("unchecked") static public void downloadFiles(TableViewer viewer, ViewContentProvider contentProvider) { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); Object selectedObject = selection.getFirstElement(); if (selectedObject == null || !FtpFileObject.class.isInstance(selectedObject)) { // Nothing selected or selection is not file return; } // Show select folder dialog to user Shell sh = RemoteControlActivator.getCurrentlyActiveWbWindowShell(); DirectoryDialog dirDialog = new DirectoryDialog(sh, SWT.OPEN); dirDialog.setText(Messages.getString("FtpUtils.Select_Folder_DlgText")); //$NON-NLS-1$ dirDialog.setMessage(Messages.getString("FtpUtils.Select_Folder_DlgMsg")); //$NON-NLS-1$ String downloadFilterPath = RCPreferences.getDownloadLocation(); if (downloadFilterPath == "") { //$NON-NLS-1$ // Workspace root is used as default folder IPath location = ResourcesPlugin.getWorkspace().getRoot().getLocation(); dirDialog.setFilterPath(location.toString()); } else { // use last used folder dirDialog.setFilterPath(downloadFilterPath); } // Get user selected folder String destPath = dirDialog.open(); if (destPath == null) { // User is canceled dialog return; } // Remember last used folder RCPreferences.setDownloadLocation(destPath); destPath = addFileSepatorToEnd(destPath); // Full path for remote file String currentDirectory = getCurrentPath(contentProvider); IFtpObject ftpObject = null; String remoteFile = null; String destFile = null; FileDownloadJob job = null; // Download files Iterator iter = selection.iterator(); boolean canWrite; boolean replaceAll = false; while (iter.hasNext()) { canWrite = true; ftpObject = (IFtpObject) iter.next(); if (FtpFileObject.class.isInstance(ftpObject)) { // Folders are not downloaded // Full path for destination file destFile = destPath + ftpObject.getName(); remoteFile = currentDirectory + ftpObject.getName(); if (RCPreferences.getDownloadConfirm()) { // Confirm replace from user if file already exists File file = new File(destFile); if (file.exists() && !replaceAll) { // Show confirmation dialog ConfirmReplaceDialog dlg = new ConfirmReplaceDialog(sh, ftpObject.getName(), iter.hasNext(), ConfirmReplaceDialog.Operation.DOWNLOAD); dlg.open(); int sel = dlg.getSelection(); switch (sel) { case ConfirmReplaceDialog.RENAME_ID: // Rename this file RenameDialog renameDlg = new RenameDialog(sh, ftpObject.getName(), true, RENAME_FILE_DLG_NAME); if (renameDlg.open() == Dialog.CANCEL) { // User canceled dialog return; } // Get new file name from dialog. If user canceled dialog the original // filename is returned destFile = destPath + renameDlg.getFileName(); canWrite = true; break; case IDialogConstants.YES_ID: // Replace this file canWrite = true; break; case IDialogConstants.YES_TO_ALL_ID: // Replace all files replaceAll = true; break; case IDialogConstants.NO_ID: // Do not replace this file canWrite = false; break; case IDialogConstants.CANCEL_ID: // Cancel operation return; default: break; } } } if (canWrite) { job = new FileDownloadJob( Messages.getString("FtpUtils.Download_File_Job_Name") + ftpObject.getName(), //$NON-NLS-1$ remoteFile, destFile, false); job.setPriority(Job.DECORATE); job.schedule(); } } } }
From source file:com.nokia.s60tools.remotecontrol.ftp.ui.view.FtpUtils.java
License:Open Source License
/** * Upload given source files./*from w ww .j a va2 s .c om*/ * @param uploadDir Directory where files are to be uploaded. * @param sourceFiles Files with path which are to be uploaded. */ public static void uploadFiles(String uploadDir, String[] sourceFiles) { Shell sh = RemoteControlActivator.getCurrentlyActiveWbWindowShell(); // Get file list from remote directory for checking // if file already exists String[] files = null; if (RCPreferences.getUploadConfirm()) { IFTPService ftpService = HTIServiceFactory.createFTPService(RemoteControlConsole.getInstance()); try { // Get list of files on remote folder files = ftpService.listFiles(uploadDir, LIST_CONTENTS_TIMEOUT); } catch (Exception e) { // Failed to list files. Show message to user and return RemoteControlMessageBox message = new RemoteControlMessageBox( Messages.getString("FtpUtils.Upload_Fail_ConsoleErrorMsg") //$NON-NLS-1$ , SWT.ICON_ERROR); message.open(); e.printStackTrace(); return; } } boolean replaceAll = false; String destFileName = null; for (int j = 0; j < sourceFiles.length; j++) { boolean canWrite = true; File sourceFile = new File(sourceFiles[j]); destFileName = sourceFile.getName(); if (RCPreferences.getUploadConfirm()) { // Ask confirmation for replacing files if already exists on // target directory for (int i = 0; i < files.length; i++) { if (!replaceAll && files[i].equals(destFileName)) { // No need to check other files i = files.length; // File exists on remote folder // Show confirmation dialog ConfirmReplaceDialog dlg = new ConfirmReplaceDialog(sh, destFileName, (j < sourceFiles.length - 1), ConfirmReplaceDialog.Operation.UPLOAD); dlg.open(); int sel = dlg.getSelection(); switch (sel) { case ConfirmReplaceDialog.RENAME_ID: // Rename this file RenameDialog renameDlg = new RenameDialog(sh, destFileName, true, RENAME_FILE_DLG_NAME); if (renameDlg.open() == Dialog.CANCEL) { // User canceled dialog return; } // Get new file name from dialog. If user canceled dialog the original // filename is returned destFileName = renameDlg.getFileName(); canWrite = true; break; case IDialogConstants.YES_ID: // Replace this file canWrite = true; break; case IDialogConstants.YES_TO_ALL_ID: // Replace all files replaceAll = true; break; case IDialogConstants.NO_ID: // Do not replace this file canWrite = false; break; case IDialogConstants.CANCEL_ID: // Cancel operation return; default: break; } } } } // Upload file if (canWrite) { String srcFile = null; String destFile = null; // Full path for destination file destFile = uploadDir + destFileName; srcFile = sourceFiles[j]; FileUploadJob job = new FileUploadJob(Messages.getString("FtpUtils.Upload_File_Job_Name") //$NON-NLS-1$ + " " //$NON-NLS-1$ + sourceFile.getName(), srcFile, destFile); job.setPriority(Job.DECORATE); job.schedule(); } } }