use of org.eclipse.swt.widgets.FileDialog in project cubrid-manager by CUBRID.
the class ImportExportConnectionDialog method okPressed.
protected void okPressed() {
ActionExecutor executor = null;
if (export) {
FileDialog dialog = new FileDialog(getParentShell(), (export) ? SWT.SAVE : SWT.OPEN);
dialog.setText(com.cubrid.cubridquery.ui.connection.Messages.exportConnectionsSelectPathMsg);
dialog.setFilterExtensions(new String[] { "*.xml" });
dialog.setFileName("export_connections");
String fileName = dialog.open();
if (fileName == null) {
return;
}
executor = new ExportAction(fileName);
} else {
executor = new ImportAction();
}
if (executor.execute() == SUCCESS_CODE) {
String msg = export ? com.cubrid.cubridquery.ui.connection.Messages.exportConnectionsSuccessMsg : com.cubrid.cubridquery.ui.connection.Messages.importConnectionsSuccessMsg;
CommonUITool.openInformationBox(com.cubrid.common.ui.common.Messages.titleSuccess, msg);
super.okPressed();
}
}
use of org.eclipse.swt.widgets.FileDialog in project eclipse.platform.text by eclipse.
the class TemplatePreferencePage method import_.
private void import_() {
FileDialog dialog = new FileDialog(getShell());
dialog.setText(TemplatesMessages.TemplatePreferencePage_import_title);
dialog.setFilterExtensions(new String[] { TemplatesMessages.TemplatePreferencePage_import_extension });
String path = dialog.open();
if (path == null)
return;
try {
ArrayList<TemplatePersistenceData> selection = new ArrayList<>();
TemplateReaderWriter reader = new TemplateReaderWriter();
File file = new File(path);
if (file.exists()) {
try (InputStream input = new BufferedInputStream(new FileInputStream(file))) {
TemplatePersistenceData[] datas = reader.read(input, null);
for (int i = 0; i < datas.length; i++) {
TemplatePersistenceData data = datas[i];
fTemplateStore.add(data);
String id = data.getId();
if (id == null) {
selection.add(data);
} else {
data = fTemplateStore.getTemplateData(id);
if (data != null) {
selection.add(data);
}
}
}
}
}
fTableViewer.refresh();
fTableViewer.setAllChecked(false);
fTableViewer.setCheckedElements(getEnabledTemplates());
fTableViewer.setSelection(new StructuredSelection(selection), true);
selectionChanged1();
} catch (FileNotFoundException e) {
openReadErrorDialog(e);
} catch (IOException e) {
openReadErrorDialog(e);
}
}
use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.
the class SaveChartAction method askForAndPrepareFile.
/**
* Ask the user for the path to save the file at, and check if this path overwrites any existing file.
* (Note that using dialog.setOverwrite(true) is insufficient, as the path name may be appended with a
* file extension after the standard overwrite checks occur.)
* @return A file with the specified pathname, appended with an appropriate extension.
*/
private File askForAndPrepareFile() {
final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
final FileDialog dialog = new FileDialog(shell, SWT.SAVE);
dialog.setFilterExtensions(EXTENSIONS);
dialog.setText(Messages.ChartConstants_SAVE_CHART_DIALOG_TEXT);
dialog.setFileName(title);
do {
String path = dialog.open();
if (path == null) {
// Cancelled
return null;
}
path = makePathWithVerifiedExt(path);
File file = new File(path);
if (shouldOverwrite(file, shell)) {
return file;
}
// If not overwriting, bring up dialog again (loop)
dialog.setFileName(file.getName());
} while (true);
}
use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.
the class PerfOptionsTab method showFileDialog.
// Displays a file dialog to allow the user to select the kernel image file
private void showFileDialog(Shell shell) {
FileDialog fDialog = new FileDialog(shell, SWT.OPEN);
File kernel = new File(txtKernelLocation.getText());
if (!kernel.exists()) {
// $NON-NLS-1$
kernel = new File("/boot");
if (!kernel.exists()) {
// $NON-NLS-1$
kernel = new File("/");
}
}
fDialog.setFileName(kernel.toString());
fDialog.setText(Messages.PerfOptionsTab_Kernel_Prompt);
String newKernel = fDialog.open();
if (newKernel != null) {
kernel = new File(newKernel);
if (!kernel.exists()) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.RETRY | SWT.CANCEL);
mb.setMessage(Messages.PerfOptionsTab_File_DNE);
switch(mb.open()) {
case SWT.RETRY:
showFileDialog(shell);
break;
default:
}
} else {
txtKernelLocation.setText(newKernel);
}
}
}
use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.
the class STCSourceNotFoundEditor method locateFile.
private void locateFile() {
FileDialog dialog = new FileDialog(getEditorSite().getShell(), SWT.NONE);
IPath missingPath = getMissingFile();
dialog.setFilterNames(new String[] { Messages.STCSourceNotFoundEditor_missing_source_file });
// $NON-NLS-1$
dialog.setFilterExtensions(new String[] { "*." + missingPath.getFileExtension() });
String res = dialog.open();
if (res != null) {
Path newPath = new Path(res);
if (newPath.lastSegment().equalsIgnoreCase(missingPath.lastSegment())) {
if (missingPath.segmentCount() > 1) {
int missingPathSegCount = missingPath.segmentCount() - 2;
int newPathSegCount = newPath.segmentCount() - 2;
while (missingPathSegCount >= 0 && newPathSegCount >= 0) {
if (!newPath.segment(newPathSegCount).equalsIgnoreCase(missingPath.segment(missingPathSegCount))) {
break;
}
newPathSegCount--;
missingPathSegCount--;
}
IPath compPath = missingPath.removeLastSegments(missingPath.segmentCount() - missingPathSegCount - 1);
IPath newSourcePath = newPath.removeLastSegments(newPath.segmentCount() - newPathSegCount - 1);
try {
addSourceMappingToCommon(compPath, newSourcePath);
} catch (CoreException e) {
}
}
openSourceFileAtLocation(getProject(), newPath, getLineNumber());
closeEditor();
}
}
}
Aggregations