List of usage examples for org.eclipse.jface.preference PreferenceDialog open
public int open()
From source file:org.eclipse.team.internal.ccvs.ui.repo.RepositoryEncodingPropertyPage.java
License:Open Source License
protected Control createContents(Composite parent) { initialize();//from w ww. ja va2 s . c o m Composite composite = new Composite(parent, SWT.NULL); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); GridLayout layout = new GridLayout(); composite.setLayout(layout); Label label = createWrappingLabel(composite, CVSUIMessages.RepositoryEncodingPropertyPage_2, 1); encoding = new EncodingFieldEditor(CVSRepositoryLocation.PREF_SERVER_ENCODING, CVSUIMessages.RepositoryEncodingPropertyPage_3, composite); encoding.setPage(this); encoding.setPreferenceStore(getLocationPreferenceStore()); encoding.load(); encoding.setPropertyChangeListener(this); Link pageLink = new Link(composite, SWT.LEFT | SWT.WRAP); pageLink.addSelectionListener(new SelectionAdapter() { /* * (non-Javadoc) * * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent e) { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.ui.preferencePages.Workspace", null, null); //$NON-NLS-1$ dialog.open(); } }); pageLink.setLayoutData(label.getLayoutData()); pageLink.setText(CVSUIMessages.RepositoryEncodingPropertyPage_4); PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.REPOSITORY_ENCODING_PROPERTY_PAGE); Dialog.applyDialogFont(parent); return composite; }
From source file:org.eclipse.team.internal.ui.SWTUtils.java
License:Open Source License
public static Link createPreferenceLink(final Shell shell, Composite parent, final String pageId, final String[] displayIds, String message) { Link link = new Link(parent, SWT.NONE); link.setText(getLinkLabel(pageId, message)); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { PreferenceDialog prefDialog = PreferencesUtil.createPreferenceDialogOn(shell, pageId, displayIds, null);/*from w w w .j a v a2 s.c om*/ prefDialog.open(); } }); return link; }
From source file:org.eclipse.thym.android.ui.internal.statushandler.MissingSDKStatusHandler.java
License:Open Source License
@Override public void handle(IStatus status) { boolean define = MessageDialog.openQuestion(AbstractStatusHandler.getShell(), "Missing Android SDK", "Location of the Android SDK must be defined. Define Now?"); if (define) { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), AndroidPreferencePage.PAGE_ID, null, null); dialog.open(); }// w w w .j a v a 2 s . co m }
From source file:org.eclipse.thym.blackberry.ui.internal.statushandler.MissingSDKStatusHandler.java
License:Open Source License
@Override public void handle(IStatus status) { boolean define = MessageDialog.openQuestion(AbstractStatusHandler.getShell(), "Missing BlackBerry SDK", "Location of the BlackBerry SDK must be defined. Define Now?"); if (define) { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), BlackBerryPreferencePage.PAGE_ID, null, null); dialog.open(); }/*from w w w . j ava 2 s . c o m*/ }
From source file:org.eclipse.thym.ui.internal.status.EngineStatusHandler.java
License:Open Source License
@Override public Object handleStatus(IStatus status, Object source) throws CoreException { HybridMobileStatus hs = (HybridMobileStatus) status; final boolean open = MessageDialog.openQuestion(AbstractStatusHandler.getShell(), "Missing or incomplete Hybrid Mobile Engine", NLS.bind("{0} \n\nWould you like to modify Hybrid Mobile Engine preferences to correct this issue?", hs.getMessage()));/* w w w . java 2 s .c o m*/ if (open) { PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(getShell(), hs.getProject(), EnginePropertyPage.PAGE_ID, new String[] { EnginePropertyPage.PAGE_ID }, null); return (dialog != null && dialog.open() == Window.OK) ? Boolean.TRUE : Boolean.FALSE; } return Boolean.FALSE; }
From source file:org.eclipse.thym.wp.internal.ui.statushandler.SDKStatusHandler.java
License:Open Source License
@Override public void handle(IStatus status) { boolean define = MessageDialog.openQuestion(AbstractStatusHandler.getShell(), Messages.SDKStatusHandler_Title, Messages.SDKStatusHandler_Message); if (define) { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), WPPreferencePage.PAGE_ID, null, null);//ww w. j ava 2 s . com dialog.open(); } }
From source file:org.eclipse.titan.designer.actions.NatureConverter.java
License:Open Source License
private void convertNatureOnProject(final IProject tempProject) throws CoreException { final IProjectDescription description = tempProject.getDescription(); if (!TITANNature.hasTITANNature(tempProject)) { Activator.getDefault().pauseHandlingResourceChanges(); TITANNature.addTITANNatureToProject(description); tempProject.setDescription(description, IResource.FORCE, null); tempProject.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, ProjectBuildPropertyData.GENERATE_MAKEFILE_PROPERTY), "true"); tempProject.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, TTCN3PreprocessorOptionsData.TTCN3_PREPROCESSOR_PROPERTY), "cpp"); tempProject.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, CCompilerOptionsData.CXX_COMPILER_PROPERTY), "g++"); tempProject.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, TITANFlagsOptionsData.ADD_SOURCELINEINFO_PROPERTY), "true"); tempProject.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakeAttributesData.TEMPORAL_WORKINGDIRECTORY_PROPERTY), "bin"); ProjectFileHandler pfHandler = new ProjectFileHandler(tempProject); final WorkspaceJob job = pfHandler.saveProjectSettingsJob(); try {/*w w w . j a va2 s. co m*/ job.join(); } catch (InterruptedException e) { ErrorReporter.logExceptionStackTrace("Interrupted", e); } try { tempProject.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace("Error while refreshing resources", e); } Activator.getDefault().resumeHandlingResourceChanges(); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(null, tempProject, GeneralConstants.PROJECT_PROPERTY_PAGE, null, null); if (dialog != null) { dialog.open(); } } }); } else { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { if (MessageDialog.openConfirm(null, NATURE_REMOVAL_TITLE, NATURE_REMOVAL_MESSAGE + tempProject.getName() + '?')) { TITANNature.removeTITANNature(description); try { tempProject.setDescription(description, IResource.FORCE, null); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace(e); } } } }); } }
From source file:org.eclipse.titan.designer.wizards.NewTITANProjectWizard.java
License:Open Source License
@Override public boolean performFinish() { if (!isCreated) { createNewProject();/* ww w .j av a 2 s. c o m*/ } if (newProject == null) { IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription(); if (description.isAutoBuilding() != wasAutoBuilding) { description.setAutoBuilding(wasAutoBuilding); try { ResourcesPlugin.getWorkspace().setDescription(description); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace(e); } } Activator.getDefault().resumeHandlingResourceChanges(); return false; } try { TITANNature.addTITANBuilderToProject(newProject); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace(e); } try { newProject.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakeAttributesData.TEMPORAL_WORKINGDIRECTORY_PROPERTY), optionsPage.getWorkingFolder()); String executable = MakefileCreationData.getDefaultTargetExecutableName(newProject); newProject.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.TARGET_EXECUTABLE_PROPERTY), executable); } catch (CoreException ce) { ErrorReporter.logExceptionStackTrace(ce); } ProjectDocumentHandlingUtility.createDocument(newProject); ProjectFileHandler pfHandler; pfHandler = new ProjectFileHandler(newProject); final WorkspaceJob job = pfHandler.saveProjectSettingsJob(); try { job.join(); } catch (InterruptedException e) { ErrorReporter.logExceptionStackTrace(e); } try { newProject.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace(e); } IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription(); if (description.isAutoBuilding() != wasAutoBuilding) { description.setAutoBuilding(wasAutoBuilding); try { ResourcesPlugin.getWorkspace().setDescription(description); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace(e); } } Activator.getDefault().resumeHandlingResourceChanges(); BasicNewProjectResourceWizard.updatePerspective(config); selectAndReveal(newProject); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(null, newProject, GeneralConstants.PROJECT_PROPERTY_PAGE, null, null); if (dialog != null) { dialog.open(); } IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription(); if (description.isAutoBuilding() != wasAutoBuilding) { description.setAutoBuilding(wasAutoBuilding); try { ResourcesPlugin.getWorkspace().setDescription(description); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace(e); } } Activator.getDefault().resumeHandlingResourceChanges(); } }); return true; }
From source file:org.eclipse.titan.designer.wizards.projectFormat.TpdImporter.java
License:Open Source License
/** * Internal function used to do the import job. It is needed to extract this * functionality in order to be able to handle erroneous situations. * * @param projectFile// w w w .j a va2 s .co m * the file path string of the project descriptor file (tpd) * @param projectsCreated * the list of projects created so far. In case of problems we * will try to delete them. * @param monitor * the monitor used to report progress. * * @return true if the import was successful, false otherwise. * */ public boolean internalFinish(final String projectFile, final boolean isSkipExistingProjects, final boolean isOpenPropertiesForAllImports, final List<IProject> projectsCreated, final IProgressMonitor monitor, final List<String> searchPaths) { if (projectFile == null || "".equals(projectFile.trim())) { return false; } if (searchPaths != null) { this.searchPaths = new ArrayList<String>(searchPaths); } System.setProperty(DOMImplementationRegistry.PROPERTY, ProjectFormatConstants.DOM_IMPLEMENTATION_SOURCE); DOMImplementationRegistry registry = null; try { registry = DOMImplementationRegistry.newInstance(); } catch (Exception e) { ErrorReporter.logExceptionStackTrace("While importing from `" + projectFile + "'", e); activatePreviousSettings(); return false; } // Specifying "LS 3.0" in the features list ensures that the // DOMImplementation // object implements the load and save features of the DOM 3.0 // specification. final DOMImplementation domImpl = registry.getDOMImplementation(ProjectFormatConstants.LOAD_SAVE_VERSION); domImplLS = (DOMImplementationLS) domImpl; // If the mode is MODE_SYNCHRONOUS, the parse and parseURI // methods of the LSParser // object return the org.w3c.dom.Document object. If the mode is // MODE_ASYNCHRONOUS, the parse and parseURI methods return null. parser = domImplLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, ProjectFormatConstants.XML_SCHEMA); config = parser.getDomConfig(); DOMErrorHandlerImpl errorHandler = new DOMErrorHandlerImpl(); config.setParameter("error-handler", errorHandler); config.setParameter("validate", Boolean.TRUE); config.setParameter("schema-type", ProjectFormatConstants.XML_SCHEMA); config.setParameter("well-formed", Boolean.TRUE); config.setParameter("validate-if-schema", Boolean.TRUE); Validator tpdValidator = null; try { final Schema tpdXsd = getTPDSchema(); tpdValidator = tpdXsd.newValidator(); } catch (Exception e) { ErrorReporter.INTERNAL_ERROR(e.getMessage()); // Hint: cp $TTCN3_DIR/etc/xsd/TPD.xsd designer/schema/ } URI resolvedProjectFileURI = TITANPathUtilities.resolvePath(projectFile, (URI) null); //==================================== // Loading all URI Documents (tpds) // and collect projects to be imported //==================================== if (!loadURIDocuments(resolvedProjectFileURI, tpdValidator)) { return false; } final SubMonitor progress = SubMonitor.convert(monitor, 3); progress.setTaskName("Loading data"); IProgressMonitor projectCreationMonitor = progress.newChild(1); projectCreationMonitor.beginTask("Creating required projects", projectsToImport.size()); //======================== // Create projects and // store load location // (where they are loaded from) //======================== Map<URI, IProject> projectMap = new HashMap<URI, IProject>(); for (URI file : projectsToImport.keySet()) { Document actualDocument = projectsToImport.get(file); IProject project = createProject(actualDocument.getDocumentElement(), file.equals(resolvedProjectFileURI) || !isSkipExistingProjects); if (project == null) { projectCreationMonitor.worked(1); continue; } projectsCreated.add(project); projectMap.put(file, project); try { project.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, ProjectBuildPropertyData.LOAD_LOCATION), file.getPath().toString()); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace( "While loading referenced project from `" + file.getPath() + "'", e); } projectCreationMonitor.worked(1); } projectCreationMonitor.done(); IProgressMonitor normalInformationLoadingMonitor = progress.newChild(1); normalInformationLoadingMonitor.beginTask("Loading directly stored project information", projectsToImport.size()); //==================================== //Load Project Data from all projects: //==================================== for (URI file : projectsToImport.keySet()) { if (!projectMap.containsKey(file)) { normalInformationLoadingMonitor.worked(1); continue; } IProject project = projectMap.get(file); IPath projectFileFolderPath = new Path(file.getPath()).removeLastSegments(1); URI projectFileFolderURI = URIUtil.toURI(projectFileFolderPath); Document actualDocument = projectsToImport.get(file); if (this.searchPaths != null && !this.searchPaths.isEmpty()) { String tpdNameAttrVal = tpdNameAttrMap.get(project.getName()); String tpdURIVal = tpdURIMap.get(project.getName()); if (tpdNameAttrVal != null) { try { project.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, ProjectBuildPropertyData.USE_TPD_NAME), tpdNameAttrVal); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace( "While setting `useTpdName' for project `" + project.getName() + "'", e); } } if (tpdURIVal != null) { try { project.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, ProjectBuildPropertyData.ORIG_TPD_URI), tpdURIVal); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace( "While setting `origTpdURI' for project `" + project.getName() + "'", e); } } } Element mainElement = actualDocument.getDocumentElement(); if (!loadProjectDataFromNode(mainElement, project, projectFileFolderURI)) { return false; } normalInformationLoadingMonitor.worked(1); } normalInformationLoadingMonitor.done(); //===================================== //Load information from packed projects //===================================== IPath mainProjectFileFolderPath = new Path(resolvedProjectFileURI.getPath()).removeLastSegments(1); URI mainProjectFileFolderURI = URIUtil.toURI(mainProjectFileFolderPath); List<Node> packedProjects = loadPackedProjects(projectsToImport.get(resolvedProjectFileURI)); IProgressMonitor packedInformationLoadingMonitor = progress.newChild(1); packedInformationLoadingMonitor.beginTask("Loading packed project information", packedProjects.size()); for (Node node : packedProjects) { IProject project = createProject(node, false); if (project == null) { packedInformationLoadingMonitor.worked(1); continue; } projectsCreated.add(project); try { project.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, ProjectBuildPropertyData.LOAD_LOCATION), resolvedProjectFileURI.toString()); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace("While loading packed project `" + project.getName() + "'", e); } if (!loadProjectDataFromNode(node, project, mainProjectFileFolderURI)) { return false; } packedInformationLoadingMonitor.worked(1); } packedInformationLoadingMonitor.done(); IProject mainProject = projectMap.get(resolvedProjectFileURI); if (mainProject == null) { progress.done(); return false; } try { mainProject.setPersistentProperty( new QualifiedName(ProjectBuildPropertyData.QUALIFIER, ProjectBuildPropertyData.USE_TPD_NAME), mainProject.getName() + ".tpd"); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace( "While setting `useTpdName' for project `" + mainProject.getName() + "'", e); } List<WorkspaceJob> jobs = new ArrayList<WorkspaceJob>(); List<IProject> projectsToBeConfigured; if (isOpenPropertiesForAllImports) { projectsToBeConfigured = projectsCreated; } else { projectsToBeConfigured = new ArrayList<IProject>(); projectsToBeConfigured.add(mainProject); } if (!headless) { for (final IProject project : projectsToBeConfigured) { WorkspaceJob loadJob = new WorkspaceJob("Property initilizer for " + project.getName()) { @Override public IStatus runInWorkspace(final IProgressMonitor monitor) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(null, project, GeneralConstants.PROJECT_PROPERTY_PAGE, null, null); if (dialog != null) { dialog.open(); } } }); return Status.OK_STATUS; } }; loadJob.setUser(false); loadJob.setSystem(true); loadJob.setRule(project.getWorkspace().getRuleFactory().refreshRule(project)); loadJob.setProperty(IProgressConstants.ICON_PROPERTY, ImageCache.getImageDescriptor("titan.gif")); loadJob.schedule(); jobs.add(loadJob); } for (WorkspaceJob job : jobs) { try { job.join(); } catch (InterruptedException e) { ErrorReporter.logExceptionStackTrace("Interrupted while performing: " + job.getName(), e); } } } activatePreviousSettings(); progress.done(); return true; }
From source file:org.eclipse.titan.designer.wizards.TITANProjectImportWizard.java
License:Open Source License
@Override public boolean performFinish() { URI targetLocation = null;/* w w w . j a v a2 s .c o m*/ if (!newProjectPage.useDefaults()) { targetLocation = newProjectPage.getLocationURI(); } final IProject newProject = GUIProjectImporter.createNewProject(newProjectPage.getProjectHandle(), mainPage.getInformation(), targetLocation); if (newProject == null) { IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription(); if (description.isAutoBuilding() != wasAutoBuilding) { description.setAutoBuilding(wasAutoBuilding); try { ResourcesPlugin.getWorkspace().setDescription(description); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace(e); } } Activator.getDefault().resumeHandlingResourceChanges(); return true; } try { TITANNature.addTITANBuilderToProject(newProject); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace(e); } ProjectFileHandler pfHandler; pfHandler = new ProjectFileHandler(newProject); pfHandler.saveProjectSettings(); try { newProject.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace(e); } BasicNewProjectResourceWizard.updatePerspective(config); selectAndReveal(newProject); ProjectInformation information = mainPage.getInformation(); List<IncludedProject> includedProjects = information.getIncludedProjects(); if (!includedProjects.isEmpty() && (recursivelyPage == null || recursivelyPage.getRecursiveImport())) { final IWorkspace workspace = ResourcesPlugin.getWorkspace(); List<String> processedProjectFiles = new ArrayList<String>(); processedProjectFiles.add(information.getSourceFile()); List<IPath> projectFilesToBeProcessed = new ArrayList<IPath>(); for (IncludedProject includedProject : includedProjects) { IPath temp = includedProject.getAbsolutePath(); if (temp != null) { projectFilesToBeProcessed.add(temp); } } while (!projectFilesToBeProcessed.isEmpty()) { IPath tempPath = projectFilesToBeProcessed.remove(projectFilesToBeProcessed.size() - 1); if (processedProjectFiles.contains(tempPath.toOSString())) { continue; } GUIProjectImporter importer = new GUIProjectImporter(); ProjectInformation tempProjectInformation = importer.loadProjectFile(tempPath.toOSString(), null, false); //false: not headless IPath tempPath2 = tempPath.removeFileExtension(); String includedProjectName = tempPath2.lastSegment(); IProject tempProject = workspace.getRoot().getProject(includedProjectName); if (tempProject.exists()) { continue; } tempProject = GUIProjectImporter.createNewProject(tempProject, tempProjectInformation, targetLocation); if (tempProject == null) { continue; } try { TITANNature.addTITANBuilderToProject(tempProject); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace(e); } pfHandler = new ProjectFileHandler(tempProject); pfHandler.saveProjectSettings(); try { tempProject.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace(e); } includedProjects = tempProjectInformation.getIncludedProjects(); for (IncludedProject includedProject : includedProjects) { IPath temp = includedProject.getAbsolutePath(); if (temp != null) { projectFilesToBeProcessed.add(temp); } } } } Display.getDefault().asyncExec(new Runnable() { @Override public void run() { PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(null, newProject, GeneralConstants.PROJECT_PROPERTY_PAGE, null, null); if (dialog != null) { dialog.open(); } IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription(); if (description.isAutoBuilding() != wasAutoBuilding) { description.setAutoBuilding(wasAutoBuilding); try { ResourcesPlugin.getWorkspace().setDescription(description); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace(e); } } Activator.getDefault().resumeHandlingResourceChanges(); } }); return true; }