List of usage examples for org.eclipse.jface.dialogs IDialogConstants NO_LABEL
String NO_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants NO_LABEL.
Click Source Link
From source file:org.eclipse.compare.codereview.compareEditor.RefacContentMergeViewer.java
License:Open Source License
/** * This method is called from the <code>Viewer</code> method <code>inputChanged</code> * to save any unsaved changes of the old input. * <p>//w ww . ja va 2 s .c om * The <code>ContentMergeViewer</code> implementation of this * method calls <code>saveContent(...)</code>. If confirmation has been turned on * with <code>setConfirmSave(true)</code>, a confirmation alert is posted before saving. * </p> * Clients can override this method and are free to decide whether * they want to call the inherited method. * @param newInput the new input of this viewer, or <code>null</code> if there is no new input * @param oldInput the old input element, or <code>null</code> if there was previously no input * @return <code>true</code> if saving was successful, or if the user didn't want to save (by pressing 'NO' in the confirmation dialog). * @since 2.0 */ protected boolean doSave(Object newInput, Object oldInput) { // before setting the new input we have to save the old if (isLeftDirty() || isRightDirty()) { if (Utilities.RUNNING_TESTS) { if (Utilities.TESTING_FLUSH_ON_COMPARE_INPUT_CHANGE) { flushContent(oldInput, null); } } else if (fConfirmSave) { // post alert Shell shell = fComposite.getShell(); MessageDialog dialog = new MessageDialog(shell, Utilities.getString(getResourceBundle(), "saveDialog.title"), //$NON-NLS-1$ null, // accept the default window icon Utilities.getString(getResourceBundle(), "saveDialog.message"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, }, 0); // default button index switch (dialog.open()) { // open returns index of pressed button case 0: flushContent(oldInput, null); break; case 1: setLeftDirty(false); setRightDirty(false); break; case 2: throw new ViewerSwitchingCancelled(); } } else flushContent(oldInput, null); return true; } return false; }
From source file:org.eclipse.compare.codereview.compareEditor.RefacContentMergeViewer.java
License:Open Source License
/** * Handle a change to the given input reported from an {@link org.eclipse.compare.structuremergeviewer.ICompareInputChangeListener}. * This class registers a listener with its input and reports any change events through * this method. By default, this method prompts for any unsaved changes and then refreshes * the viewer. Subclasses may override./* w ww. j a va2 s .co m*/ * @since 3.3 */ protected void handleCompareInputChange() { // before setting the new input we have to save the old Object input = getInput(); if (!isSaving() && (isLeftDirty() || isRightDirty())) { if (Utilities.RUNNING_TESTS) { if (Utilities.TESTING_FLUSH_ON_COMPARE_INPUT_CHANGE) { flushContent(input, null); } } else { // post alert Shell shell = fComposite.getShell(); MessageDialog dialog = new MessageDialog(shell, CompareMessages.ContentMergeViewer_resource_changed_title, null, // accept the default window icon CompareMessages.ContentMergeViewer_resource_changed_description, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, // 0 IDialogConstants.NO_LABEL, // 1 }, 0); // default button index switch (dialog.open()) { // open returns index of pressed button case 0: flushContent(input, null); break; case 1: setLeftDirty(false); setRightDirty(false); break; } } } if (isSaving() && (isLeftDirty() || isRightDirty())) { return; // Do not refresh until saving both sides is complete } refresh(); }
From source file:org.eclipse.contribution.visualiser.internal.preference.VisualiserPreferencePage.java
License:Open Source License
/** * Called when the user presses OK. Updates the Visualiser with the * selections chosen./*from www . j ava 2 s . c om*/ * * @see PreferencePage#performOk() */ public boolean performOk() { if (super.performOk()) { ProviderDefinition[] definitions = ProviderManager.getAllProviderDefinitions(); for (int i = 0; i < definitions.length; i++) { boolean checked = checkboxViewer.getChecked(definitions[i]); if (definitions[i].isEnabled() != checked) { definitions[i].setEnabled(checked); } } String rname = styleList.getSelection()[0]; VisualiserPreferences.setRendererName(rname); String pname = colourList.getSelection()[0]; ProviderDefinition def = ProviderManager.getCurrent(); String defp = PaletteManager.getDefaultForProvider(def).getName(); if (PaletteManager.getPaletteByName(pname).getPalette() instanceof PatternVisualiserPalette) { // Using Patterns if (stripeHeight.getSelection() < VisualiserPreferences.getDefaultPatternStripeHeight() && !VisualiserPreferences.getUsePatterns() && !VisualiserPreferences.getDontAutoIncreaseStripeHeight()) { if (VisualiserPreferences.getDoAutoIncreaseStripeHeight()) { VisualiserPreferences .setStripeHeight(VisualiserPreferences.getDefaultPatternStripeHeight()); } else { MessageDialogWithToggle toggleDialog = new MessageDialogWithToggle(null, VisualiserMessages.VisualiserPreferencePage_stripeSizeDialog_title, null, VisualiserMessages.VisualiserPreferencePage_stripeSizeDialog_message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, VisualiserMessages.VisualiserPreferencePage_stripeSizeDialog_togglemessage, VisualiserPreferences.getDoAutoIncreaseStripeHeight()); if (toggleDialog.getReturnCode() == 0) { // Yes pressed VisualiserPreferences.setDoIncreaseStripeHeight(toggleDialog.getToggleState()); VisualiserPreferences .setStripeHeight(VisualiserPreferences.getDefaultPatternStripeHeight()); } else // No pressed VisualiserPreferences.setDontIncreaseStripeHeight(toggleDialog.getToggleState()); } } else VisualiserPreferences.setStripeHeight(stripeHeight.getSelection()); VisualiserPreferences.setBarWidth(prefWidth.getSelection()); VisualiserPreferences.setUsePatterns(true); String pid = PaletteManager.getPaletteByName(pname).getID(); VisualiserPreferences.setPaletteIDForProvider(def, pid); } else { // Not using patterns VisualiserPreferences.setStripeHeight(stripeHeight.getSelection()); VisualiserPreferences.setBarWidth(prefWidth.getSelection()); VisualiserPreferences.setUsePatterns(false); if (defp.equals(pname)) { // going with provider defintion, clear preference setting VisualiserPreferences.setPaletteIDForProvider(def, ""); //$NON-NLS-1$ } else { // update preference setting for this provider String pid = PaletteManager.getPaletteByName(pname).getID(); VisualiserPreferences.setPaletteIDForProvider(def, pid); } } PaletteManager.resetCurrent(); IMarkupProvider markupP = ProviderManager.getMarkupProvider(); if (markupP instanceof SimpleMarkupProvider) { ((SimpleMarkupProvider) markupP).resetColours(); } // if the Visualiser is showing, update to use the new settings if (VisualiserPlugin.visualiser != null) { if (VisualiserPlugin.menu != null) { VisualiserPlugin.menu.setVisMarkupProvider(markupP); } VisualiserPlugin.visualiser.updateDisplay(true); } return true; } return false; }
From source file:org.eclipse.datatools.enablement.sybase.asa.schemaobjecteditor.examples.routineeditor.ProceduralObjectEditorHandler.java
License:Open Source License
public Object getAdapter(Class adapter) { if (adapter == SQLEditor.class) { return getSQLEditor(); } else if (IContentOutlinePage.class.equals(adapter)) { IEditorPart editor = getSQLEditor(); if (editor != null) { _outlinePage = (SQLOutlinePage) editor.getAdapter(adapter); _fOutlineSelectionChangedListener.install(_outlinePage); return _outlinePage; }// ww w . j a va2 s . c om } else if (IRoutineEditorDocumentProvider.class.equals(adapter)) { return new RoutineFormDocumentProviderAdapter() { public void refreshFromDatabase(Object element, IControlConnection controlCon, ProcIdentifier proc) throws CoreException, SQLException { if (_editor == null) { return; } if (_editor.isDirty()) { String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; MessageDialog d = new MessageDialog(ExamplePlugin.getActiveWorkbenchShell(), Messages.ProceduralObjectEditorHandler_refresh_editor, null, Messages.ProceduralObjectEditorHandler_refresh_q, MessageDialog.QUESTION, buttons, 0); int result = d.open(); switch (result) { case IDialogConstants.CANCEL_ID: return; default: break; } } RefreshSchemaEditorJob refreshJob = new RefreshSchemaEditorJob( Messages.ProceduralObjectEditorHandler_refresh, ProceduralObjectEditorHandler.this); refreshJob.setUser(true); refreshJob.schedule(); } }; } return super.getAdapter(adapter); }
From source file:org.eclipse.datatools.sqltools.schemaobjecteditor.ui.action.RefreshSchemaEditorAction.java
License:Open Source License
public void run() { if (_editor == null) { return;/*from w w w .j a va 2 s . co m*/ } if (_editor.isDirty()) { String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; MessageDialog d = new MessageDialog(SOEUIPlugin.getActiveWorkbenchShell(), Messages.RefreshSchemaEditorAction_referesh_editor, null, Messages.RefreshSchemaEditorAction_question, MessageDialog.QUESTION, buttons, 0); int result = d.open(); switch (result) { case IDialogConstants.CANCEL_ID: return; default: break; } } ISchemaObjectEditorHandler handler = _editor.getEditorHandler(); RefreshSchemaEditorJob refreshJob = new RefreshSchemaEditorJob( Messages.RefreshSchemaEditorAction_refresh_job, handler); refreshJob.setUser(true); refreshJob.schedule(); }
From source file:org.eclipse.datatools.sqltools.schemaobjecteditor.ui.core.DefaultSchemaObjectEditorHandler.java
License:Open Source License
/** * If the model object is lost, prompt the user to save the DDL, and close the editor. *///w w w . j av a2 s. co m private void promptSaveAndCloseEditor() { MessageDialog dialog = new MessageDialog(SOEUIPlugin.getActiveWorkbenchShell(), Messages.MainSQLObjectLostPromoptSavingTitle, null, Messages.MainSQLObjectLostPromoptSavingMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (dialog.open() == IDialogConstants.OK_ID) { ISchemaObjectEditModel schemaObjectEditModel = getEditorInput().getEditModelObject(); String ddl = null; if (schemaObjectEditModel instanceof AbstractSchemaObjectEditModel) { ddl = ((AbstractSchemaObjectEditModel) schemaObjectEditModel).getBackupedDDL(); } final SaveAsDialog dia = new SaveAsDialog(SOEUIPlugin.getActiveWorkbenchShell(), ddl); dia.setOriginalName(_editor.getDisplayName() + "_ddl.sql"); dia.setOpenMode(getOpenFileAfterSaveasOption()); dia.open(); IEditorPart editor = dia.getEditor(); if (editor != null && (editor instanceof SQLEditor)) { ISchemaObjectEditorInput input = (ISchemaObjectEditorInput) _editor.getEditorInput(); DatabaseIdentifier databaseIdentifier = input.getDatabaseIdentifier(); ISQLEditorConnectionInfo connInfo = new SQLEditorConnectionInfo( SQLToolsFacade.getConfigurationByProfileName(databaseIdentifier.getProfileName()) .getDatabaseVendorDefinitionId(), databaseIdentifier.getProfileName(), databaseIdentifier.getDBname(), databaseIdentifier.getDBname()); ((SQLEditor) editor).setConnectionInfo(connInfo); } } final IWorkbenchPage workPage = SOEUIPlugin.getActiveWorkbenchPage(); workPage.closeEditor((IEditorPart) _editor, false); }
From source file:org.eclipse.datatools.sqltools.schemaobjecteditor.ui.core.DefaultSchemaObjectEditorHandler.java
License:Open Source License
/** * Do check based on the parameter doCheck. * //w w w. j av a 2 s.c o m * @param doCheck * @return * @author sul */ public boolean checkSchemaObjectExistence(boolean doCheck) { if (!doCheck) { return true; } ISchemaObjectEditModel editModel = getEditorInput().getEditModelObject(); if (!editModel.checkModelExistence()) { promptObjectLost(editModel); MessageDialog dialog = new MessageDialog(SOEUIPlugin.getActiveWorkbenchShell(), Messages.MainSQLObjectLostPromoptSavingTitle, null, Messages.MainSQLObjectLostPromoptSavingMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); ISchemaObjectEditModel schemaObjectEditModel = getEditorInput().getEditModelObject(); String ddl = null; if (schemaObjectEditModel instanceof AbstractSchemaObjectEditModel) { ddl = ((AbstractSchemaObjectEditModel) schemaObjectEditModel).getBackupedDDL(); } // if ddl is not null, prompt to save it. if (ddl != null && dialog.open() == IDialogConstants.OK_ID) { final SaveAsDialog dia = new SaveAsDialog(SOEUIPlugin.getActiveWorkbenchShell(), ddl); dia.setOriginalName(_editor.getDisplayName() + "_ddl.sql"); dia.setOpenMode(getOpenFileAfterSaveasOption()); // SOEUIPlugin.getActiveWorkbenchShell().getDisplay().asyncExec(new Runnable() { public void run() { dia.open(); IEditorPart editor = dia.getEditor(); if (editor != null && (editor instanceof SQLEditor)) { ISchemaObjectEditorInput input = (ISchemaObjectEditorInput) _editor.getEditorInput(); DatabaseIdentifier databaseIdentifier = input.getDatabaseIdentifier(); ISQLEditorConnectionInfo connInfo = new SQLEditorConnectionInfo( SQLToolsFacade .getConfigurationByProfileName(databaseIdentifier.getProfileName()) .getDatabaseVendorDefinitionId(), databaseIdentifier.getProfileName(), databaseIdentifier.getDBname(), databaseIdentifier.getDBname()); ((SQLEditor) editor).setConnectionInfo(connInfo); } } }); } final IWorkbenchPage workPage = SOEUIPlugin.getActiveWorkbenchPage(); SOEUIPlugin.getActiveWorkbenchShell().getDisplay().asyncExec(new Runnable() { public void run() { workPage.closeEditor((IEditorPart) _editor, false); } }); return false; } return true; }
From source file:org.eclipse.datatools.sqltools.schemaobjecteditor.ui.internal.preference.SchemaObjectEditorPreferencePage.java
License:Open Source License
protected Control createContents(Composite parent) { _parent = parent;//from w w w .j a va 2s . c om GridLayout layout = new GridLayout(); parent.setLayout(layout); Composite container = new Composite(parent, SWT.NONE); layout = new GridLayout(); container.setLayout(layout); GridData gd = new GridData(GridData.FILL_BOTH); container.setLayoutData(gd); Group editorsComp = new Group(container, SWT.NONE); gd = new GridData(GridData.FILL_HORIZONTAL); layout = new GridLayout(); layout.numColumns = 4; layout.makeColumnsEqualWidth = true; editorsComp.setLayout(layout); editorsComp.setText(Messages.SchemaObjectEditorPreferencePage_available_editors); editorsComp.setLayoutData(gd); Composite dbdefsComp = new Composite(editorsComp, SWT.NONE); layout = new GridLayout(); layout.numColumns = 2; dbdefsComp.setLayout(layout); gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 2; dbdefsComp.setLayoutData(gd); Label dbTypeLabel = new Label(dbdefsComp, SWT.NONE); dbTypeLabel.setText(Messages.SchemaObjectEditorPreferencePage_databaseType); _dbType = new Combo(dbdefsComp, SWT.READ_ONLY); gd = new GridData(GridData.FILL_HORIZONTAL); gd.minimumWidth = 130; _dbType.setLayoutData(gd); Composite edComp = new Composite(editorsComp, SWT.NONE); layout = new GridLayout(); layout.numColumns = 2; edComp.setLayout(layout); gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 2; edComp.setLayoutData(gd); Label editorTypeLabel = new Label(edComp, SWT.NONE); editorTypeLabel.setText(Messages.SchemaObjectEditorPreferencePage_editors); _editorName = new Combo(edComp, SWT.READ_ONLY); gd = new GridData(GridData.FILL_HORIZONTAL); gd.minimumWidth = 130; _editorName.setLayoutData(gd); Group pagesComp = new Group(container, SWT.NONE); gd = new GridData(GridData.FILL_BOTH); layout = new GridLayout(); layout.numColumns = 3; pagesComp.setLayout(layout); pagesComp.setLayoutData(gd); pagesComp.setText(Messages.SchemaObjectEditorPreferencePage_pagesSetting); Composite selectedComposite = new Composite(pagesComp, SWT.NONE); gd = new GridData(GridData.FILL_BOTH); selectedComposite.setLayoutData(gd); layout = new GridLayout(); selectedComposite.setLayout(layout); Label selectedPages = new Label(selectedComposite, SWT.NONE); selectedPages.setText(Messages.SchemaObjectEditorPreferencePage_selected_pages); gd = new GridData(); gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; selectedPages.setLayoutData(gd); _displayedPages = new List(selectedComposite, SWT.BORDER | SWT.MULTI); gd = new GridData(GridData.FILL_BOTH); _displayedPages.setLayoutData(gd); Composite buttonsComp = new Composite(pagesComp, SWT.NONE); gd = new GridData(GridData.FILL_VERTICAL); buttonsComp.setLayoutData(gd); layout = new GridLayout(); buttonsComp.setLayout(layout); GC gc = new GC(buttonsComp); int maxAddRemoveButtonsWidth = computeMaxAddRemoveButtonsWidth(gc); gc.dispose(); new Label(buttonsComp, SWT.NONE); _rightOne = new Button(buttonsComp, SWT.NONE | SWT.LEFT); gd = new GridData(); gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER; gd.widthHint = maxAddRemoveButtonsWidth; _rightOne.setLayoutData(gd); _rightOne.setText(Messages.SchemaObjectEditorPreferencePage_remove); _rightOne.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { String[] selectedItems = _displayedPages.getSelection(); boolean isSucceeded = false; int movedNum = 0; for (int i = 0; i < selectedItems.length; i++) { String name = selectedItems[i]; Object data = _displayedPages.getData(name); IEditorPageDescriptor page = (IEditorPageDescriptor) data; if (page.isRequired()) { continue; } _hiddenPages.add(name); _hiddenPages.setData(name, data); _displayedPages.remove(name); isSucceeded = true; movedNum++; } setOrClearErrorMsg(); if (!isSucceeded) { String[] buttons = new String[] { IDialogConstants.OK_LABEL }; MessageDialog d = new MessageDialog(_parent.getShell(), Messages.SchemaObjectEditorPreferencePage_error, null, Messages.SchemaObjectEditorPreferencePage_can_not_remove, MessageDialog.ERROR, buttons, 0); d.open(); } else { _dirty = true; int[] indecies = new int[movedNum]; for (int i = 0; i < movedNum; i++) { indecies[i] = _hiddenPages.getItemCount() - 1 - i; } _hiddenPages.setSelection(indecies); } setButtonStatus(); } }); _rightAll = new Button(buttonsComp, SWT.NONE | SWT.LEFT); gd = new GridData(); gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER; gd.widthHint = maxAddRemoveButtonsWidth; _rightAll.setLayoutData(gd); _rightAll.setText(Messages.SchemaObjectEditorPreferencePage_remove_all); _rightAll.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { String[] selectedItems = _displayedPages.getItems(); boolean isSucceeded = false; for (int i = 0; i < selectedItems.length; i++) { String name = selectedItems[i]; Object data = _displayedPages.getData(name); IEditorPageDescriptor page = (IEditorPageDescriptor) data; if (page.isRequired()) { continue; } _hiddenPages.add(name); _hiddenPages.setData(name, data); _displayedPages.remove(name); isSucceeded = true; } setOrClearErrorMsg(); setButtonStatus(); if (!isSucceeded) { String[] buttons = new String[] { IDialogConstants.OK_LABEL }; MessageDialog d = new MessageDialog(_parent.getShell(), Messages.SchemaObjectEditorPreferencePage_erroe, null, Messages.SchemaObjectEditorPreferencePage_can_not_remove, MessageDialog.ERROR, buttons, 0); d.open(); } else { _dirty = true; } } }); _leftOne = new Button(buttonsComp, SWT.NONE | SWT.LEFT); gd = new GridData(); gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER; gd.widthHint = maxAddRemoveButtonsWidth; _leftOne.setLayoutData(gd); _leftOne.setText(Messages.SchemaObjectEditorPreferencePage_add); _leftOne.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { String[] selectedItems = _hiddenPages.getSelection(); int movedNum = 0; for (int i = 0; i < selectedItems.length; i++) { String name = selectedItems[i]; Object data = _hiddenPages.getData(name); IEditorDescriptor editor = (IEditorDescriptor) _editorName.getData(_editorName.getText()); IEditorPageDescriptor page = (IEditorPageDescriptor) data; boolean isPageMandatoryFirstOne = editor.getMandatoryFirstPage() != null && editor.getMandatoryFirstPage().getPageId().equals(page.getPageId()); boolean isPageMandatoryLastOne = editor.getMandatoryLastPage() != null && editor.getMandatoryLastPage().getPageId().equals(page.getPageId()); if (isPageMandatoryFirstOne) { _displayedPages.add(name, 0); _displayedPages.setData(name, data); } else if (isPageMandatoryLastOne) { _displayedPages.add(name, _displayedPages.getItemCount()); _displayedPages.setData(name, data); } else { // Check if the last visible page is a mandatory page if (_displayedPages.getItemCount() > 0) { String displayedLastOne = _displayedPages.getItem(_displayedPages.getItemCount() - 1); IEditorPageDescriptor displayedLast = (IEditorPageDescriptor) _displayedPages .getData(displayedLastOne); boolean isLastPageMandatory = editor.getMandatoryLastPage() != null && editor.getMandatoryLastPage().getPageId().equals(displayedLast.getPageId()); if (isLastPageMandatory) { _displayedPages.add(name, _displayedPages.getItemCount() - 1); _displayedPages.setData(name, data); } else { _displayedPages.add(name); _displayedPages.setData(name, data); } } else { _displayedPages.add(name); _displayedPages.setData(name, data); } } _hiddenPages.remove(name); movedNum++; } setOrClearErrorMsg(); if (movedNum > 0) { _dirty = true; } int[] indecies = new int[movedNum]; for (int i = 0; i < movedNum; i++) { indecies[i] = _displayedPages.getItemCount() - 1 - i; } _displayedPages.setSelection(indecies); setButtonStatus(); } }); _leftAll = new Button(buttonsComp, SWT.NONE | SWT.LEFT); gd = new GridData(); gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER; gd.widthHint = maxAddRemoveButtonsWidth; _leftAll.setLayoutData(gd); _leftAll.setText(Messages.SchemaObjectEditorPreferencePage_add_all); _leftAll.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { String[] selectedItems = _hiddenPages.getItems(); for (int i = 0; i < selectedItems.length; i++) { _dirty = true; String name = selectedItems[i]; Object data = _hiddenPages.getData(name); IEditorDescriptor editor = (IEditorDescriptor) _editorName.getData(_editorName.getText()); IEditorPageDescriptor page = (IEditorPageDescriptor) data; boolean isPageMandatoryFirstOne = editor.getMandatoryFirstPage() != null && editor.getMandatoryFirstPage().getPageId().equals(page.getPageId()); boolean isPageMandatoryLastOne = editor.getMandatoryLastPage() != null && editor.getMandatoryLastPage().getPageId().equals(page.getPageId()); if (isPageMandatoryFirstOne) { _displayedPages.add(name, 0); _displayedPages.setData(name, data); } else if (isPageMandatoryLastOne) { _displayedPages.add(name, _displayedPages.getItemCount()); _displayedPages.setData(name, data); } else { // Check if the last visible page is a mandatory page if (_displayedPages.getItemCount() > 0) { String displayedLastOne = _displayedPages.getItem(_displayedPages.getItemCount() - 1); IEditorPageDescriptor displayedLast = (IEditorPageDescriptor) _displayedPages .getData(displayedLastOne); boolean isLastPageMandatory = editor.getMandatoryLastPage() != null && editor.getMandatoryLastPage().getPageId().equals(displayedLast.getPageId()); if (isLastPageMandatory) { _displayedPages.add(name, _displayedPages.getItemCount() - 1); _displayedPages.setData(name, data); } else { _displayedPages.add(name); _displayedPages.setData(name, data); } } else { _displayedPages.add(name); _displayedPages.setData(name, data); } } _hiddenPages.remove(name); } setOrClearErrorMsg(); setButtonStatus(); } }); _upMove = new Button(buttonsComp, SWT.NONE | SWT.LEFT); gd = new GridData(); gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER; gd.widthHint = maxAddRemoveButtonsWidth; _upMove.setLayoutData(gd); _upMove.setText(Messages.SchemaObjectEditorPreferencePage_move_up); _upMove.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { moveItem(_displayedPages, true); } }); _downMove = new Button(buttonsComp, SWT.NONE | SWT.LEFT); gd = new GridData(); gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER; gd.widthHint = maxAddRemoveButtonsWidth; _downMove.setLayoutData(gd); _downMove.setText(Messages.SchemaObjectEditorPreferencePage_move_down); _downMove.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { moveItem(_displayedPages, false); } }); Composite availableComp = new Composite(pagesComp, SWT.NONE); gd = new GridData(GridData.FILL_BOTH); availableComp.setLayoutData(gd); layout = new GridLayout(); availableComp.setLayout(layout); Label availablePages = new Label(availableComp, SWT.NONE); availablePages.setText(Messages.SchemaObjectEditorPreferencePage_available_pages); gd = new GridData(); gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; availablePages.setLayoutData(gd); _hiddenPages = new List(availableComp, SWT.BORDER | SWT.MULTI); gd = new GridData(GridData.FILL_BOTH); _hiddenPages.setLayoutData(gd); final Map editorsMap = SchemaObjectEditorUtils.getEditorsCatalogedByDBDefinition(); // Sort the dbdefinitions java.util.List keys = new ArrayList(); Iterator iter = editorsMap.keySet().iterator(); while (iter.hasNext()) { String dbdefi = (String) iter.next(); keys.add(dbdefi); } Collections.sort(keys); iter = keys.iterator(); while (iter.hasNext()) { String dbdefi = (String) iter.next(); _dbType.add(dbdefi); } _dbType.setFocus(); _dbType.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { String dbdefi = _dbType.getText(); if (dbdefi != null && dbdefi.trim().length() != 0) { _editorName.removeAll(); java.util.List editors = (java.util.List) editorsMap.get(dbdefi); if (editors != null) { Collections.sort(editors, new EditorComparator()); Iterator iter = editors.iterator(); while (iter.hasNext()) { IEditorDescriptor editor = (IEditorDescriptor) iter.next(); _editorName.add(editor.getEditorName()); _editorName.setData(editor.getEditorName(), editor); } } if (_editorName.getItemCount() > 0) { _editorName.select(0); _editorName.notifyListeners(SWT.Selection, new Event()); } } } }); _editorName.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { String name = _editorName.getText(); if (_dirty && isValid()) { String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; MessageDialog d = new MessageDialog(_parent.getShell(), Messages.SchemaObjectEditorPreferencePage_question, null, Messages.SchemaObjectEditorPreferencePage_save_modification, MessageDialog.QUESTION, buttons, 0); int result = d.open(); switch (result) { case 0: savePreferences(); break; case 1: break; default: break; } } _dirty = false; if (name != null && name.trim().length() != 0) { _displayedPages.removeAll(); _hiddenPages.removeAll(); IEditorDescriptor editor = (IEditorDescriptor) _editorName.getData(name); if (editor != null) { IEditorPageDescriptor[] pages = editor.getPageDescriptors(); for (int i = 0; i < pages.length; i++) { if (!_store.getBoolean(Constants.EDITOR_PAGE_VISIABILITY + pages[i].getEditorId() + pages[i].getPageId())) { _hiddenPages.add(pages[i].getPageName()); _hiddenPages.setData(pages[i].getPageName(), pages[i]); } } IEditorPageDescriptor[] sortedPages = editor.getSortedPages(); for (int j = 0; j < sortedPages.length; j++) { if (sortedPages[j].isSelectedToShow()) { _displayedPages.add(sortedPages[j].getPageName()); _displayedPages.setData(sortedPages[j].getPageName(), sortedPages[j]); } } } setOrClearErrorMsg(); setButtonStatus(); } } }); String preDBdef = _store.getString(Constants.PREFERENCE_PREVIOUS_DB_DEFINITION); String preEditor = _store.getString(Constants.PREFERENCE_PREVIOUS_EDIOR_NAME); if (preDBdef != null) { int index = _dbType.indexOf(preDBdef); if (index != -1) { _dbType.select(index); _dbType.notifyListeners(SWT.Selection, new Event()); } } if (preEditor != null) { int index = _editorName.indexOf(preEditor); if (index != -1) { _editorName.select(index); _editorName.notifyListeners(SWT.Selection, new Event()); } } _displayedPages.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { setButtonStatus(); } }); _hiddenPages.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { setButtonStatus(); } }); setButtonStatus(); _alwaysShowPreview = new Button(container, SWT.CHECK); _alwaysShowPreview.setText(Messages.SchemaObjectEditorPreferencePage_always_show_preview); _alwaysShowPreview.setSelection(_store.getBoolean(Constants.PREFERENCE_ALWAYS_SHOW_PREVIEW)); _promptIfNoExactEditorFound = new Button(container, SWT.CHECK); _promptIfNoExactEditorFound.setText(Messages.SchemaObjectEditorPreferencePage_use_latest_version_to_open); _promptIfNoExactEditorFound .setToolTipText(Messages.SchemaObjectEditorPreferencePage_latest_version_open_tooltip); _promptIfNoExactEditorFound.setSelection(_store.getBoolean(Constants.PREFERENCE_USE_LATEST_VERSION)); // add by sul - CR470356-2 _checkWhenActivated = new Button(container, SWT.CHECK); _checkWhenActivated.setText(Messages.SchemaObjectEditorPreferencePage_check_existence_when_activated); _checkWhenActivated.setSelection(_store.getBoolean(Constants.PREFERENCE_CHECK_EXISTENCE)); _checkWhenActivated .setToolTipText(Messages.SchemaObjectEditorPreferencePage_check_existence_when_activated_tooltip); // add end // add by sul - CR497357-1 _openFileAfterSaveas = new Button(container, SWT.CHECK); _openFileAfterSaveas.setText(Messages.SchemaObjectEditorPreferencePage_open_file_after_saveas); _openFileAfterSaveas.setSelection(_store.getBoolean(Constants.PREFERENCE_OPEN_FILE_AFTER_SAVEAS)); _openFileAfterSaveas .setToolTipText(Messages.SchemaObjectEditorPreferencePage_open_file_after_saveas_tooltip); // add end return container; }
From source file:org.eclipse.datatools.sqltools.schemaobjecteditor.ui.internal.ui.SaveAsDialog.java
License:Open Source License
protected void okPressed() { String filename = _resourceGroup.getResource(); IPath path = _resourceGroup.getContainerFullPath().append(filename); // If the path already exists then confirm overwrite. IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); if (file.exists()) { String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; String question = NLS.bind(Messages.SaveAsDialog_overwrite, new Object[] { path.toOSString() }); MessageDialog d = new MessageDialog(getShell(), Messages.SaveAsDialog_question, null, question, MessageDialog.QUESTION, buttons, 0); int overwrite = d.open(); switch (overwrite) { case 0: // Yes break; case 1: // No return; case 2: // Cancel default:// w w w . j a v a 2 s. c om cancelPressed(); return; } } // Store path and close. _result = path; try { String resource = _resourceGroup.getContainerFullPath().toString(); if (ResourcesPlugin.getWorkspace().getRoot().findMember(resource) != null) { String fullpath = ResourcesPlugin.getWorkspace().getRoot().findMember(resource).getLocation() .toOSString() + File.separator + filename; PrintWriter output = new PrintWriter( new OutputStreamWriter(new FileOutputStream(fullpath), ENCODING)); //$NON-NLS-1$ if (_content != null) { output.write(_content); } if (output != null) { output.close(); } try { if (file != null && file.getProject() != null) { file.getProject().refreshLocal(IResource.DEPTH_INFINITE, null); // set the correct charset for this file file.setCharset(ENCODING, new NullProgressMonitor()); //$NON-NLS-1$ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IDE.openEditor(page, file, true); } } catch (CoreException e) { _log.error("SaveAsDialog_open_error", e); //$NON-NLS-1$ } } } catch (IOException ex) { ErrorDialog.openError(getShell(), Messages.SaveAsDialog_error, Messages.SaveAsDialog_error_msg, new Status(IStatus.ERROR, SOEUIPlugin.PLUGIN_ID, 0, ex.getMessage(), ex)); } close(); }
From source file:org.eclipse.debug.internal.ui.launchConfigurations.CompileErrorPromptStatusHandler.java
License:Open Source License
public Object handleStatus(IStatus status, Object source) throws CoreException { if (source instanceof ILaunchConfiguration) { ILaunchConfiguration config = (ILaunchConfiguration) source; if (DebugUITools.isPrivate(config)) { return Boolean.TRUE; }//from w w w . j a v a 2 s. co m } Shell shell = DebugUIPlugin.getShell(); String title = LaunchConfigurationsMessages.CompileErrorPromptStatusHandler_0; String message = LaunchConfigurationsMessages.CompileErrorPromptStatusHandler_1; IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); String pref = store.getString(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR); if (pref != null) { if (pref.equals(MessageDialogWithToggle.ALWAYS)) { return Boolean.TRUE; } } MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message, MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1, LaunchConfigurationsMessages.CompileErrorProjectPromptStatusHandler_1, false); dialog.setPrefKey(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR); dialog.setPrefStore(store); dialog.open(); int returnValue = dialog.getReturnCode(); if (returnValue == IDialogConstants.YES_ID) { return Boolean.TRUE; } return Boolean.FALSE; }