use of org.eclipse.jface.dialogs.Dialog in project webtools.servertools by eclipse.
the class PreferencesTestCase method testAudioPreferencePage.
public void testAudioPreferencePage() {
Dialog dialog = UITestHelper.getPreferenceDialog("org.eclipse.wst.audio.preferencePage");
UITestHelper.assertDialog(dialog);
}
use of org.eclipse.jface.dialogs.Dialog in project xtext-eclipse by eclipse.
the class RefactoringWizardOpenOperation_NonForking method run.
/**
* That one exists since
* see RefactoringWizardOpenOperation#run(Shell, String, IRunnableContext)
* - not a JavaDoc link since this breaks the build on Galileo :-)
*/
public int run(final Shell parent, final String dialogTitle, final IRunnableContext context) throws InterruptedException {
Assert.isNotNull(dialogTitle);
final Refactoring refactoring = fWizard.getRefactoring();
final IJobManager manager = Job.getJobManager();
final int[] result = new int[1];
final InterruptedException[] canceled = new InterruptedException[1];
Runnable r = new Runnable() {
@Override
public void run() {
try {
// we are getting the block dialog for free if we pass in null
manager.beginRule(ResourcesPlugin.getWorkspace().getRoot(), null);
refactoring.setValidationContext(parent);
fInitialConditions = checkInitialConditions(refactoring, parent, dialogTitle, context);
if (fInitialConditions.hasFatalError()) {
String message = fInitialConditions.getMessageMatchingSeverity(RefactoringStatus.FATAL);
MessageDialog.openError(parent, dialogTitle, message);
result[0] = INITIAL_CONDITION_CHECKING_FAILED;
} else {
fWizard.setInitialConditionCheckingStatus(fInitialConditions);
/* CHANGE: don't use package private RefactoringUI */
Dialog dialog = createRefactoringWizardDialog(fWizard, parent);
dialog.create();
IWizardContainer wizardContainer = (IWizardContainer) dialog;
if (wizardContainer.getCurrentPage() == null)
/*
* Don't show the dialog at all if there are no user
* input pages and change creation was cancelled.
*/
result[0] = Window.CANCEL;
else
result[0] = dialog.open();
}
} catch (InterruptedException e) {
canceled[0] = e;
} catch (OperationCanceledException e) {
canceled[0] = new InterruptedException(e.getMessage());
} finally {
manager.endRule(ResourcesPlugin.getWorkspace().getRoot());
refactoring.setValidationContext(null);
disposeRefactoringContext(fWizard);
}
}
};
BusyIndicator.showWhile(parent != null ? parent.getDisplay() : null, r);
if (canceled[0] != null)
throw canceled[0];
return result[0];
}
use of org.eclipse.jface.dialogs.Dialog in project sonarlint-eclipse by SonarSource.
the class EditProjectExclusionDialog method selectFile.
/**
* Opens a dialog where the user can select a file path.
*/
private void selectFile() {
ISelectionStatusValidator validator = arr -> {
if (arr.length > 1) {
return ValidationStatus.error("Only one file can be selected");
}
if (arr.length == 0) {
return ValidationStatus.ok();
}
Object obj = arr[0];
ISonarLintFile file = Adapters.adapt(obj, ISonarLintFile.class);
return file != null ? ValidationStatus.ok() : ValidationStatus.error("Select a file");
};
var viewFilter = new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IFolder) {
var folder = (IFolder) element;
return SonarLintUtils.isSonarLintFileCandidate(folder);
}
if (element instanceof IFile) {
var file = Adapters.adapt(element, ISonarLintFile.class);
return file != null;
}
return false;
}
};
var lp = new WorkbenchLabelProvider();
var cp = new WorkbenchContentProvider();
var dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
dialog.setTitle("Select File");
dialog.setInput(project.getResource());
dialog.setAllowMultiple(false);
dialog.addFilter(viewFilter);
dialog.setValidator(validator);
dialog.setMessage("Select a project file to be excluded from SonarLint analysis");
if (editItem != null) {
dialog.setInitialSelection(editItem.item());
}
if (dialog.open() == Window.OK) {
var obj = dialog.getFirstResult();
var file = Adapters.adapt(obj, ISonarLintFile.class);
if (file != null) {
editItem = new ExclusionItem(Type.FILE, file.getProjectRelativePath());
fileField.setText(editItem.item());
}
}
}
use of org.eclipse.jface.dialogs.Dialog in project pentaho-kettle by pentaho.
the class Spoon method openFile.
public void openFile(String filename, VariableSpace variableSpace, boolean importfile) {
// Open the XML and see what's in there.
// We expect a single <transformation> or <job> root at this time...
// does the file exist? If not, show an error dialog
boolean fileExists = false;
FileObject file = null;
try {
file = KettleVFS.getFileObject(filename, variableSpace);
fileExists = file.exists();
} catch (final KettleFileException | FileSystemException e) {
// nothing to do, null fileObject will be handled below
}
if (StringUtils.isBlank(filename) || !fileExists) {
final Dialog dlg = new SimpleMessageDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Message", getFileType(filename).toLowerCase()), MessageDialog.ERROR, BaseMessages.getString(PKG, "System.Button.Close"), MISSING_RECENT_DLG_WIDTH, SimpleMessageDialog.BUTTON_WIDTH);
dlg.open();
return;
}
boolean loaded = false;
FileListener listener = null;
Node root = null;
// match by extension first
int idx = filename.lastIndexOf('.');
if (idx != -1) {
for (FileListener li : fileListeners) {
if (li.accepts(filename)) {
listener = li;
break;
}
}
}
// types.
try {
Document document = XMLHandler.loadXMLFile(file);
root = document.getDocumentElement();
} catch (KettleXMLException e) {
if (log.isDetailed()) {
log.logDetailed(BaseMessages.getString(PKG, "Spoon.File.Xml.Parse.Error"));
}
}
// as XML
if (listener == null && root != null) {
for (FileListener li : fileListeners) {
if (li.acceptsXml(root.getNodeName())) {
listener = li;
break;
}
}
}
//
if (!Utils.isEmpty(filename)) {
if (listener != null) {
try {
String connection = variableSpace != null ? variableSpace.getVariable(CONNECTION) : null;
if (listener instanceof ConnectionListener) {
loaded = ((ConnectionListener) listener).open(root, filename, connection, importfile);
} else {
loaded = listener.open(root, filename, importfile);
}
} catch (KettleMissingPluginsException e) {
log.logError(e.getMessage(), e);
}
}
if (!loaded) {
// Give error back
hideSplash();
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "Spoon.UnknownFileType.Message", filename));
mb.setText(BaseMessages.getString(PKG, "Spoon.UnknownFileType.Title"));
mb.open();
} else {
// set variables in the newly loaded
applyVariables();
// transformation(s) and job(s).
}
}
}
use of org.eclipse.jface.dialogs.Dialog in project pentaho-kettle by pentaho.
the class Spoon method loadLastUsedFile.
private void loadLastUsedFile(LastUsedFile lastUsedFile, String repositoryName, boolean trackIt, boolean isStartup) throws KettleException {
boolean useRepository = repositoryName != null;
//
if (lastUsedFile.isSourceRepository()) {
if (!Utils.isEmpty(lastUsedFile.getRepositoryName())) {
if (useRepository && !lastUsedFile.getRepositoryName().equalsIgnoreCase(repositoryName)) {
// We just asked...
useRepository = false;
}
}
}
if (useRepository && lastUsedFile.isSourceRepository()) {
if (rep != null) {
// load from this repository...
if (rep.getName().equalsIgnoreCase(lastUsedFile.getRepositoryName())) {
RepositoryDirectoryInterface rdi = rep.findDirectory(lastUsedFile.getDirectory());
if (rdi != null) {
// does the file exist in the repo?
final RepositoryObjectType fileType = lastUsedFile.isJob() ? RepositoryObjectType.JOB : RepositoryObjectType.TRANSFORMATION;
if (!rep.exists(lastUsedFile.getFilename(), rdi, fileType)) {
// opening this file
if (isStartup) {
if (log.isDetailed()) {
log.logDetailed(BaseMessages.getString(PKG, "Spoon.log.openingMissingFile"));
}
} else {
final Dialog dlg = new SimpleMessageDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Message", lastUsedFile.getLongFileType().toLowerCase()), MessageDialog.ERROR, BaseMessages.getString(PKG, "System.Button.Close"), MISSING_RECENT_DLG_WIDTH, SimpleMessageDialog.BUTTON_WIDTH);
dlg.open();
}
} else {
// Are we loading a transformation or a job?
if (lastUsedFile.isTransformation()) {
if (log.isDetailed()) {
// "Auto loading transformation ["+lastfiles[0]+"] from repository directory ["+lastdirs[0]+"]"
log.logDetailed(BaseMessages.getString(PKG, "Spoon.Log.AutoLoadingTransformation", lastUsedFile.getFilename(), lastUsedFile.getDirectory()));
}
TransLoadProgressDialog tlpd = new TransLoadProgressDialog(shell, rep, lastUsedFile.getFilename(), rdi, null);
TransMeta transMeta = tlpd.open();
if (transMeta != null) {
if (trackIt) {
props.addLastFile(LastUsedFile.FILE_TYPE_TRANSFORMATION, lastUsedFile.getFilename(), rdi.getPath(), true, rep.getName(), getUsername(), null, null);
}
// transMeta.setFilename(lastUsedFile.getFilename());
transMeta.clearChanged();
addTransGraph(transMeta);
refreshTree();
}
} else if (lastUsedFile.isJob()) {
JobLoadProgressDialog progressDialog = new JobLoadProgressDialog(shell, rep, lastUsedFile.getFilename(), rdi, null);
JobMeta jobMeta = progressDialog.open();
if (jobMeta != null) {
if (trackIt) {
props.addLastFile(LastUsedFile.FILE_TYPE_JOB, lastUsedFile.getFilename(), rdi.getPath(), true, rep.getName(), getUsername(), null, null);
}
jobMeta.clearChanged();
addJobGraph(jobMeta);
}
}
refreshTree();
}
}
}
}
}
// open files stored locally, not in the repository
if (!lastUsedFile.isSourceRepository() && !Utils.isEmpty(lastUsedFile.getFilename())) {
String connection = getLastUsedConnection(lastUsedFile);
Variables variables = null;
if (connection != null) {
variables = new Variables();
variables.setVariable(CONNECTION, connection);
}
if (lastUsedFile.isTransformation()) {
openFile(lastUsedFile.getFilename(), variables, rep != null);
}
if (lastUsedFile.isJob()) {
openFile(lastUsedFile.getFilename(), variables, false);
}
refreshTree();
}
}
Aggregations