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);
}
// 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);
}
jobMeta.clearChanged();
addJobGraph(jobMeta);
}
}
refreshTree();
}
}
}
}
}
// open files stored locally, not in the repository
if (!lastUsedFile.isSourceRepository() && !Utils.isEmpty(lastUsedFile.getFilename())) {
if (lastUsedFile.isTransformation()) {
openFile(lastUsedFile.getFilename(), rep != null);
}
if (lastUsedFile.isJob()) {
openFile(lastUsedFile.getFilename(), false);
}
refreshTree();
}
}
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 cubrid-manager by CUBRID.
the class PropertyAction method run.
/**
* Open property dialog,view and set property
*/
public void run() {
final Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
return;
}
final ICubridNode node = (ICubridNode) obj[0];
Dialog dialog = PreferenceUtil.createPropertyDialog(getShell(), node);
dialog.open();
}
use of org.eclipse.jface.dialogs.Dialog in project eclipse.platform.text by eclipse.
the class TextEditorDefaultsPreferencePage method createAppearancePage.
private Control createAppearancePage(Composite parent) {
Composite appearanceComposite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
appearanceComposite.setLayout(layout);
Link fontLink = new Link(appearanceComposite, SWT.NONE);
fontLink.setText(TextEditorMessages.TextEditorPreferencePage_Font_link);
fontLink.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// $NON-NLS-1$ //$NON-NLS-2$
PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.ui.preferencePages.ColorsAndFonts", null, "selectFont:" + JFaceResources.TEXT_FONT);
}
});
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
fontLink.setLayoutData(gd);
addFiller(appearanceComposite, 2);
String label = TextEditorMessages.TextEditorPreferencePage_undoHistorySize;
Preference undoHistorySize = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNDO_HISTORY_SIZE, label, null);
IntegerDomain undoHistorySizeDomain = new IntegerDomain(0, 99999);
addTextField(appearanceComposite, undoHistorySize, undoHistorySizeDomain, 15, 0);
label = TextEditorMessages.TextEditorPreferencePage_displayedTabWidth;
Preference tabWidth = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, label, null);
IntegerDomain tabWidthDomain = new IntegerDomain(1, 16);
addTextField(appearanceComposite, tabWidth, tabWidthDomain, 15, 0);
if (isWordWrapPreferenceAllowed()) {
label = TextEditorMessages.TextEditorPreferencePage_enableWordWrap;
Preference enableWordWrap = new Preference(AbstractTextEditor.PREFERENCE_WORD_WRAP_ENABLED, label, null);
addCheckBox(appearanceComposite, enableWordWrap, new BooleanDomain(), 0);
}
label = TextEditorMessages.TextEditorPreferencePage_convertTabsToSpaces;
Preference spacesForTabs = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, label, null);
addCheckBox(appearanceComposite, spacesForTabs, new BooleanDomain(), 0);
label = TextEditorMessages.TextEditorPreferencePage_highlightCurrentLine;
Preference highlightCurrentLine = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, label, null);
addCheckBox(appearanceComposite, highlightCurrentLine, new BooleanDomain(), 0);
label = TextEditorMessages.TextEditorPreferencePage_showPrintMargin;
Preference showPrintMargin = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, label, null);
final Button showPrintMarginButton = addCheckBox(appearanceComposite, showPrintMargin, new BooleanDomain(), 0);
label = TextEditorMessages.TextEditorPreferencePage_printMarginColumn;
Preference printMarginColumn = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, label, null);
final IntegerDomain printMarginDomain = new IntegerDomain(20, 200);
final Control[] printMarginControls = addTextField(appearanceComposite, printMarginColumn, printMarginDomain, 15, 20);
createDependency(showPrintMarginButton, showPrintMargin, printMarginControls);
showPrintMarginButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateStatus(printMarginDomain);
}
});
label = TextEditorMessages.TextEditorPreferencePage_showLineNumbers;
Preference showLineNumbers = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, label, null);
addCheckBox(appearanceComposite, showLineNumbers, new BooleanDomain(), 0);
label = TextEditorMessages.TextEditorDefaultsPreferencePage_range_indicator;
Preference showMagnet = new Preference(AbstractDecoratedTextEditorPreferenceConstants.SHOW_RANGE_INDICATOR, label, null);
addCheckBox(appearanceComposite, showMagnet, new BooleanDomain(), 0);
label = TextEditorMessages.TextEditorDefaultsPreferencePage_showWhitespaceCharacters;
String linkText = TextEditorMessages.TextEditorDefaultsPreferencePage_showWhitespaceCharactersLinkText;
Preference showWhitespaceCharacters = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_WHITESPACE_CHARACTERS, label, null);
addCheckBoxWithLink(appearanceComposite, showWhitespaceCharacters, linkText, new BooleanDomain(), 0, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Dialog dialog = new WhitespaceCharacterPainterOptionsDialog(Display.getDefault().getActiveShell(), fOverlayStore);
dialog.open();
}
});
label = TextEditorMessages.TextEditorPreferencePage_showAffordance;
Preference showAffordance = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, label, null);
addCheckBox(appearanceComposite, showAffordance, new BooleanDomain(), 0);
label = TextEditorMessages.TextEditorDefaultsPreferencePage_enrichHoverMode;
Preference hoverReplace = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HOVER_ENRICH_MODE, label, null);
EnumeratedDomain hoverReplaceDomain = new EnumeratedDomain();
hoverReplaceDomain.addValue(new EnumValue(-1, TextEditorMessages.TextEditorDefaultsPreferencePage_enrichHover_disabled));
hoverReplaceDomain.addValue(new EnumValue(1, TextEditorMessages.TextEditorDefaultsPreferencePage_enrichHover_immediately));
hoverReplaceDomain.addValue(new EnumValue(0, TextEditorMessages.TextEditorDefaultsPreferencePage_enrichHover_afterDelay));
hoverReplaceDomain.addValue(new EnumValue(2, TextEditorMessages.TextEditorDefaultsPreferencePage_enrichHover_onClick));
addCombo(appearanceComposite, hoverReplace, hoverReplaceDomain, 0);
label = TextEditorMessages.TextEditorDefaultsPreferencePage_textDragAndDrop;
Preference textDragAndDrop = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TEXT_DRAG_AND_DROP_ENABLED, label, null);
addCheckBox(appearanceComposite, textDragAndDrop, new BooleanDomain(), 0);
label = TextEditorMessages.TextEditorDefaultsPreferencePage_warn_if_derived;
Preference warnIfDerived = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED, label, null);
addCheckBox(appearanceComposite, warnIfDerived, new BooleanDomain(), 0);
label = TextEditorMessages.TextEditorDefaultsPreferencePage_smartHomeEnd;
Preference smartHomeEnd = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SMART_HOME_END, label, null);
addCheckBox(appearanceComposite, smartHomeEnd, new BooleanDomain(), 0);
addFiller(appearanceComposite, 2);
Label l = new Label(appearanceComposite, SWT.LEFT);
l.setText(TextEditorMessages.TextEditorPreferencePage_appearanceOptions);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
l.setLayoutData(gd);
Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
editorComposite.setLayout(layout);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
gd.horizontalSpan = 2;
editorComposite.setLayoutData(gd);
fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_BOTH);
gd.heightHint = fAppearanceColorList.getItemHeight() * 8;
fAppearanceColorList.setLayoutData(gd);
Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
stylesComposite.setLayout(layout);
stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
l = new Label(stylesComposite, SWT.LEFT);
l.setText(TextEditorMessages.TextEditorPreferencePage_color);
gd = new GridData();
gd.horizontalAlignment = GridData.BEGINNING;
l.setLayoutData(gd);
fAppearanceColorEditor = new ColorSelector(stylesComposite);
Button foregroundColorButton = fAppearanceColorEditor.getButton();
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.BEGINNING;
foregroundColorButton.setLayoutData(gd);
SelectionListener colorDefaultSelectionListener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean systemDefault = fAppearanceColorDefault.getSelection();
fAppearanceColorEditor.getButton().setEnabled(!systemDefault);
int i = fAppearanceColorList.getSelectionIndex();
if (i == -1)
return;
String key = fAppearanceColorListModel[i][2];
if (key != null)
fOverlayStore.setValue(key, systemDefault);
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
};
fAppearanceColorDefault = new Button(stylesComposite, SWT.CHECK);
fAppearanceColorDefault.setText(TextEditorMessages.TextEditorPreferencePage_systemDefault);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.BEGINNING;
gd.horizontalSpan = 2;
fAppearanceColorDefault.setLayoutData(gd);
fAppearanceColorDefault.setVisible(false);
fAppearanceColorDefault.addSelectionListener(colorDefaultSelectionListener);
fAppearanceColorList.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
@Override
public void widgetSelected(SelectionEvent e) {
handleAppearanceColorListSelection();
}
});
foregroundColorButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
@Override
public void widgetSelected(SelectionEvent e) {
int i = fAppearanceColorList.getSelectionIndex();
if (i == -1)
return;
String key = fAppearanceColorListModel[i][1];
PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue());
}
});
Link link = new Link(appearanceComposite, SWT.NONE);
link.setText(TextEditorMessages.TextEditorPreferencePage_colorsAndFonts_link);
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// $NON-NLS-1$ //$NON-NLS-2$
PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.ui.preferencePages.ColorsAndFonts", null, "selectCategory:org.eclipse.ui.workbenchMisc");
}
});
GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
// only expand further if anyone else requires it
gridData.widthHint = 150;
gridData.horizontalSpan = 2;
link.setLayoutData(gridData);
addFiller(appearanceComposite, 2);
appearanceComposite.layout();
return appearanceComposite;
}
use of org.eclipse.jface.dialogs.Dialog in project egit by eclipse.
the class FetchGerritChangePage method getRefsForContentAssist.
private Collection<Change> getRefsForContentAssist(String originalRefText) throws InvocationTargetException, InterruptedException {
String uriText = uriCombo.getText();
if (!changeRefs.containsKey(uriText)) {
changeRefs.put(uriText, new ChangeList(repository, uriText));
}
ChangeList list = changeRefs.get(uriText);
if (!list.isFinished()) {
IWizardContainer container = getContainer();
IRunnableWithProgress operation = monitor -> {
monitor.beginTask(MessageFormat.format(UIText.AsynchronousRefProposalProvider_FetchingRemoteRefsMessage, uriText), IProgressMonitor.UNKNOWN);
Collection<Change> result = list.get();
if (monitor.isCanceled()) {
return;
}
// If we get here, the ChangeList future is done.
if (result == null || result.isEmpty() || fetching) {
// Don't bother if we didn't get any results
return;
}
// If we do have results now, open the proposals.
Job showProposals = new WorkbenchJob(UIText.AsynchronousRefProposalProvider_ShowingProposalsJobName) {
@Override
public boolean shouldRun() {
return super.shouldRun() && !fetching;
}
@Override
public IStatus runInUIThread(IProgressMonitor uiMonitor) {
// the same
try {
if (container instanceof NonBlockingWizardDialog) {
// focus will be restored
if (fetching) {
return Status.CANCEL_STATUS;
}
String uriNow = uriCombo.getText();
if (!uriNow.equals(uriText)) {
return Status.CANCEL_STATUS;
}
if (refText != refText.getDisplay().getFocusControl()) {
fillInPatchSet(result, null);
return Status.CANCEL_STATUS;
}
// Try not to interfere with the user's typing.
// Only fill in the patch set number if the text
// is still the same.
fillInPatchSet(result, originalRefText);
doAutoFill = false;
} else {
// Dialog was blocked
fillInPatchSet(result, null);
doAutoFill = false;
}
contentProposer.openProposalPopup();
} catch (SWTException e) {
// Disposed already
return Status.CANCEL_STATUS;
} finally {
doAutoFill = true;
uiMonitor.done();
}
return Status.OK_STATUS;
}
};
showProposals.schedule();
};
if (container instanceof NonBlockingWizardDialog) {
NonBlockingWizardDialog dialog = (NonBlockingWizardDialog) container;
dialog.run(operation, () -> {
if (!fetching) {
list.cancel(ChangeList.CancelMode.ABANDON);
}
});
} else {
container.run(true, true, operation);
}
return null;
}
// ChangeList is already here, so get() won't block
Collection<Change> changes = list.get();
if (doAutoFill) {
fillInPatchSet(changes, originalRefText);
}
return changes;
}
Aggregations