org.eclipse.jface.window.Window Java Examples

The following examples show how to use org.eclipse.jface.window.Window. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CodeAssistFavoritesConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void doBrowseTypes() {
	IRunnableContext context= new BusyIndicatorRunnableContext();
	IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
	int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
	try {
		SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText());
		dialog.setTitle(PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_title);
		dialog.setMessage(PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_description);
		if (dialog.open() == Window.OK) {
			IType res= (IType) dialog.getResult()[0];
			fNameDialogField.setText(res.getFullyQualifiedName('.'));
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, getShell(), PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_title, PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_error_message);
	}
}
 
Example #2
Source File: Controller.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * File->New project.
 */
public void actionMenuFileNew() {

    if ((model != null) && model.isModified()) {
        if (main.showQuestionDialog(main.getShell(),
                                    Resources.getMessage("Controller.61"), //$NON-NLS-1$
                                    Resources.getMessage("Controller.62"))) { //$NON-NLS-1$
            actionMenuFileSave();
        }
    }

    // Separator
    final DialogProject dialog = new DialogProject(main.getShell());
    dialog.create();
    if (dialog.open() != Window.OK) {
        return;
    }

    // Set project
    reset();
    model = dialog.getProject();
    update(new ModelEvent(this, ModelPart.MODEL, model));
}
 
Example #3
Source File: NewResourceFileDialog.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public int open( )
{
	int rt = super.open( );

	if ( rt == Window.OK && parentPath != null )
	{
		File file = new File(parentPath + File.separator + fileName);
		try
		{
			file.createNewFile();
		}
		catch ( IOException e )
		{
			ExceptionHandler.handle(e);
		}
	}

	return rt;
}
 
Example #4
Source File: ModelEditor.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void doSaveAs() {
	InputDialog diag = new InputDialog(UI.shell(), M.SaveAs, M.SaveAs,
			model.name + " - Copy", (name) -> {
				if (Strings.nullOrEmpty(name))
					return M.NameCannotBeEmpty;
				if (Strings.nullOrEqual(name, model.name))
					return M.NameShouldBeDifferent;
				return null;
			});
	if (diag.open() != Window.OK)
		return;
	String newName = diag.getValue();
	try {
		T clone = (T) model.clone();
		clone.name = newName;
		clone = dao.insert(clone);
		App.openEditor(clone);
		Navigator.refresh();
	} catch (Exception e) {
		log.error("failed to save " + model + " as " + newName, e);
	}
}
 
Example #5
Source File: AddGetterSetterAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private int showQueryDialog(final String message, final String[] buttonLabels, int[] returnCodes) {
	final Shell shell= getShell();
	if (shell == null) {
		JavaPlugin.logErrorMessage("AddGetterSetterAction.showQueryDialog: No active shell found"); //$NON-NLS-1$
		return IRequestQuery.CANCEL;
	}
	final int[] result= { Window.CANCEL};
	shell.getDisplay().syncExec(new Runnable() {

		public void run() {
			String title= ActionMessages.AddGetterSetterAction_QueryDialog_title;
			MessageDialog dialog= new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, buttonLabels, 0);
			result[0]= dialog.open();
		}
	});
	int returnVal= result[0];
	return returnVal < 0 ? IRequestQuery.CANCEL : returnCodes[returnVal];
}
 
Example #6
Source File: ExpandWithConstructorsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the type hierarchy for type selection.
 */
private void doBrowseTypes() {
	IRunnableContext context= new BusyIndicatorRunnableContext();
	IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
	int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
	try {
		SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText());
		dialog.setTitle(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title);
		dialog.setMessage(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_description);
		if (dialog.open() == Window.OK) {
			IType res= (IType)dialog.getResult()[0];
			fNameDialogField.setText(res.getFullyQualifiedName('.'));
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, getShell(), CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title,
				CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_error_message);
	}
}
 
Example #7
Source File: FlowSection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Handle specify flow controller.
 */
private void handleSpecifyFlowController() {
  MultiResourceSelectionDialog dialog = new MultiResourceSelectionDialog(getSection().getShell(),
          editor.getFile().getProject().getParent(), "Flow Controller Selection", editor
                  .getFile().getLocation(), editor);
  dialog.setTitle("Flow Controller Selection");
  dialog.setMessage("Select a Flow Controller descriptor from the workspace:");
  if (Window.CANCEL  == dialog.open()) {
    return;
  }
  Object[] files = dialog.getResult();

  if (files != null && checkForOneSelection(files.length)) {
    FileAndShortName fsn = new FileAndShortName(files[0]);
    produceKeyAddFlowController(fsn.shortName, fsn.fileName, dialog.isImportByName);
  }
}
 
Example #8
Source File: WorkingSetConfigurationDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void createWorkingSet() {
	IWorkingSetManager manager= PlatformUI.getWorkbench().getWorkingSetManager();
	IWorkingSetNewWizard wizard= manager.createWorkingSetNewWizard(new String[] {IWorkingSetIDs.JAVA});
	// the wizard can't be null since we have at least the Java working set.
	WizardDialog dialog= new WizardDialog(getShell(), wizard);
	dialog.create();
	if (dialog.open() == Window.OK) {
		IWorkingSet workingSet= wizard.getSelection();
		if (WorkingSetModel.isSupportedAsTopLevelElement(workingSet)) {
			fAllWorkingSets.add(workingSet);
			fTableViewer.add(workingSet);
			fTableViewer.setSelection(new StructuredSelection(workingSet), true);
			fTableViewer.setChecked(workingSet, true);
			manager.addWorkingSet(workingSet);
			fAddedWorkingSets.add(workingSet);
		}
	}
}
 
Example #9
Source File: DialogError.java    From arx with Apache License 2.0 6 votes vote down vote up
@Override
protected void createButtonsForButtonBar(final Composite parent) {

    // Create OK Button
    parent.setLayoutData(SWTUtil.createFillGridData());
    final Button okButton = createButton(parent,
                                         Window.OK,
                                         Resources.getMessage("AboutDialog.15"), true); //$NON-NLS-1$
    okButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            setReturnCode(Window.OK);
            close();
        }
    });
}
 
Example #10
Source File: SourceContainerWorkbookPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void editAttributeEntry(CPListElementAttribute elem) {
	String key= elem.getKey();
	if (key.equals(CPListElement.OUTPUT)) {
		CPListElement selElement=  elem.getParent();
		OutputLocationDialog dialog= new OutputLocationDialog(getShell(), selElement, fClassPathList.getElements(), new Path(fOutputLocationField.getText()).makeAbsolute(), true);
		if (dialog.open() == Window.OK) {
			selElement.setAttribute(CPListElement.OUTPUT, dialog.getOutputLocation());
			fFoldersList.refresh();
			fClassPathList.dialogFieldChanged(); // validate
		}
	} else if (key.equals(CPListElement.EXCLUSION) || key.equals(CPListElement.INCLUSION)) {
		EditFilterWizard wizard= newEditFilterWizard(elem.getParent(), fFoldersList.getElements(), fOutputLocationField.getText());
		OpenBuildPathWizardAction action= new OpenBuildPathWizardAction(wizard);
		action.run();
	} else if (key.equals(CPListElement.IGNORE_OPTIONAL_PROBLEMS)) {
		String newValue= "true".equals(elem.getValue()) ? null : "true"; //$NON-NLS-1$ //$NON-NLS-2$
		elem.setValue(newValue);
		fFoldersList.refresh(elem);
	} else {
		if (editCustomAttribute(getShell(), elem)) {
			fFoldersList.refresh();
			fClassPathList.dialogFieldChanged(); // validate
		}
	}
}
 
Example #11
Source File: PackageFilterEditor.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public int openEditor(Shell parent) {

  this.mDialog = new CheckedTreeSelectionDialog(parent,
          WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
          new SourceFolderContentProvider());

  // initialize the dialog with the filter data
  initCheckedTreeSelectionDialog();

  // open the dialog
  int retCode = this.mDialog.open();

  // actualize the filter data
  if (Window.OK == retCode) {
    this.mFilterData = this.getFilterDataFromDialog();

    if (!mDialog.isRecursivelyExcludeSubTree()) {
      mFilterData.add(PackageFilter.RECURSE_OFF_MARKER);
    }
  }

  return retCode;
}
 
Example #12
Source File: DialogHelpers.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
public static Integer openAskInt(String title, String message, int initial) {
    Shell shell = EditorUtils.getShell();
    String initialValue = "" + initial;
    IInputValidator validator = new IInputValidator() {

        @Override
        public String isValid(String newText) {
            if (newText.length() == 0) {
                return "At least 1 char must be provided.";
            }
            try {
                Integer.parseInt(newText);
            } catch (Exception e) {
                return "A number is required.";
            }
            return null;
        }
    };
    InputDialog dialog = new InputDialog(shell, title, message, initialValue, validator);
    dialog.setBlockOnOpen(true);
    if (dialog.open() == Window.OK) {
        return Integer.parseInt(dialog.getValue());
    }
    return null;
}
 
Example #13
Source File: ComplexFileSetsEditor.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void addFileSet() {
  try {
    FileSetEditDialog dialog = new FileSetEditDialog(mComposite.getShell(), null, mProject,
            mPropertyPage);
    if (Window.OK == dialog.open()) {
      FileSet fileSet = dialog.getFileSet();
      mFileSets.add(fileSet);
      mViewer.refresh();
      mViewer.setChecked(fileSet, fileSet.isEnabled());

      mPropertyPage.getContainer().updateButtons();
    }
  } catch (CheckstylePluginException e) {
    CheckstyleUIPlugin.errorDialog(mComposite.getShell(),
            NLS.bind(Messages.errorFailedAddFileset, e.getMessage()), e, true);
  }
}
 
Example #14
Source File: FileSetEditDialog.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void editFileMatchPattern() {
  IStructuredSelection selection = (IStructuredSelection) mPatternViewer.getSelection();
  FileMatchPattern pattern = (FileMatchPattern) selection.getFirstElement();
  if (pattern == null) {
    //
    // Nothing is selected.
    //
    return;
  }

  FileMatchPatternEditDialog dialog = new FileMatchPatternEditDialog(getShell(), pattern.clone());

  if (Window.OK == dialog.open()) {

    FileMatchPattern editedPattern = dialog.getPattern();
    mFileSet.getFileMatchPatterns().set(mFileSet.getFileMatchPatterns().indexOf(pattern),
            editedPattern);
    mPatternViewer.refresh();
    mPatternViewer.setChecked(editedPattern, editedPattern.isIncludePattern());
  }
}
 
Example #15
Source File: SortMembersAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(ITextSelection selection) {
	Shell shell= getShell();
	IJavaElement input= SelectionConverter.getInput(fEditor);
	if (input instanceof ICompilationUnit) {
		if (!ActionUtil.isEditable(fEditor)) {
			return;
		}
		SortMembersMessageDialog dialog= new SortMembersMessageDialog(getShell());
		if (dialog.open() != Window.OK) {
			return;
		}
		if (!ElementValidator.check(input, getShell(), getDialogTitle(), true)) {
			return;
		}
		run(shell, (ICompilationUnit) input, fEditor, dialog.isNotSortingFieldsEnabled());
	} else {
		MessageDialog.openInformation(shell, getDialogTitle(), ActionMessages.SortMembersAction_not_applicable);
	}
}
 
Example #16
Source File: TypeSection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Edits the allowed value.
 *
 * @param item the item
 * @param parent the parent
 */
private void editAllowedValue(TreeItem item, TreeItem parent) {

  TypeDescription td = getTypeDescriptionFromTableTreeItem(parent);
  AllowedValue av = getAllowedValueFromTableTreeItem(item);
  AllowedValue localAv = getLocalAllowedValue(td, av); // must use unmodified value of "av"
  AddAllowedValueDialog dialog = new AddAllowedValueDialog(this, av);
  if (dialog.open() == Window.CANCEL)
    return;

  allowedValueUpdate(av, dialog);
  allowedValueUpdate(localAv, dialog);
  if (!valueChanged)
    return;

  // update the GUI
  item.setText(AV_COL, av.getString());

  editor.addDirtyTypeName(td.getName());
  finishActionPack();
}
 
Example #17
Source File: CustomFiltersActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void openDialog() {
	CustomFiltersDialog dialog= new CustomFiltersDialog(
		fViewer.getControl().getShell(),
		fTargetId,
		areUserDefinedPatternsEnabled(),
		fUserDefinedPatterns,
		internalGetEnabledFilterIds());

	if (dialog.open() == Window.OK) {
		setEnabledFilterIds(dialog.getEnabledFilterIds());
		setUserDefinedPatternsEnabled(dialog.areUserDefinedPatternsEnabled());
		setUserDefinedPatterns(dialog.getUserDefinedPatterns());
		setRecentlyChangedFilters(dialog.getFilterDescriptorChangeHistory());

		storeViewDefaults();

		updateViewerFilters();
	}
}
 
Example #18
Source File: SREsPreferencePage.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Add a SRE.
 */
protected void addSRE() {
	final AddSREInstallWizard wizard = new AddSREInstallWizard(
			createUniqueIdentifier(),
			this.sreArray.toArray(new ISREInstall[this.sreArray.size()]));
	final WizardDialog dialog = new WizardDialog(getShell(), wizard);
	if (dialog.open() == Window.OK) {
		final ISREInstall result = wizard.getCreatedSRE();
		if (result != null) {
			this.sreArray.add(result);
			//refresh from model
			refreshSREListUI();
			this.sresList.setSelection(new StructuredSelection(result));
			//ensure labels are updated
			if (!this.sresList.isBusy()) {
				this.sresList.refresh(true);
			}
			updateUI();
			// Autoselect the default SRE
			if (getDefaultSRE() == null) {
				setDefaultSRE(result);
			}
		}
	}
}
 
Example #19
Source File: ErrorDialogWithStackTraceUtil.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Shows JFace ErrorDialog but improved by constructing full stack trace in detail area.
 *
 * @return true if OK was pressed
 */
public static boolean showErrorDialogWithStackTrace(String msg, Throwable throwable) {

	// Temporary holder of child statuses
	List<Status> childStatuses = new ArrayList<>();

	for (StackTraceElement stackTraceElement : throwable.getStackTrace()) {
		childStatuses.add(new Status(IStatus.ERROR, "N4js-plugin-id", stackTraceElement.toString()));
	}

	MultiStatus ms = new MultiStatus("N4js-plugin-id", IStatus.ERROR,
			childStatuses.toArray(new Status[] {}), // convert to array of statuses
			throwable.getLocalizedMessage(), throwable);

	final AtomicBoolean result = new AtomicBoolean(true);
	Display.getDefault()
			.syncExec(
					() -> result.set(
							ErrorDialog.openError(null, "Error occurred while organizing ", msg, ms) == Window.OK));

	return result.get();
}
 
Example #20
Source File: PyCodeCoverageView.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
    ContainerSelectionDialog dialog = new ContainerSelectionDialog(getSite().getShell(), null, false,
            "Choose folder to be analyzed in the code-coverage");
    dialog.showClosedProjects(false);
    if (dialog.open() != Window.OK) {
        return;
    }
    Object[] objects = dialog.getResult();
    if (objects.length == 1) { //only one folder can be selected
        if (objects[0] instanceof IPath) {
            IPath p = (IPath) objects[0];

            IWorkspace w = ResourcesPlugin.getWorkspace();
            IContainer folderForLocation = (IContainer) w.getRoot().findMember(p);
            setSelectedContainer(folderForLocation);
        }
    }
}
 
Example #21
Source File: BundledResourcesSelectionBlock.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private void addResource() {
  if (javaProject == null) {
    MessageDialog.openError(shell, "Resource Selection Error",
        "A valid Java project must be selected.");
    return;
  }

  ClientBundleResourceDialog dialog = new ClientBundleResourceDialog(shell,
      javaProject, pckgFragment, extendedInterfaces,
      getAllMethodsBeingAdded());
  if (dialog.open() == Window.OK) {
    ClientBundleResource resource = dialog.getClientBundleResource();
    if (resource != null && !resourcesField.getElements().contains(resource)) {
      resourcesField.addElement(resource);
      resourcesChanged();
    }
  }
}
 
Example #22
Source File: NewSourceFolderWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private IJavaProject chooseProject() {
	IJavaProject[] projects;
	try {
		projects= JavaCore.create(fWorkspaceRoot).getJavaProjects();
	} catch (JavaModelException e) {
		JavaPlugin.log(e);
		projects= new IJavaProject[0];
	}

	ILabelProvider labelProvider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT);
	ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
	dialog.setTitle(NewWizardMessages.NewSourceFolderWizardPage_ChooseProjectDialog_title);
	dialog.setMessage(NewWizardMessages.NewSourceFolderWizardPage_ChooseProjectDialog_description);
	dialog.setElements(projects);
	dialog.setInitialSelections(new Object[] { fCurrJProject });
	dialog.setHelpAvailable(false);
	if (dialog.open() == Window.OK) {
		return (IJavaProject) dialog.getFirstResult();
	}
	return null;
}
 
Example #23
Source File: RenameElementHandler.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	NamedElement element = refactoring.getContextObject();
	if (element != null) {
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

		List<Issue> issues = validator.validate(element.eResource(), CheckMode.NORMAL_AND_FAST,
				CancelIndicator.NullImpl);
		Stream<Issue> errors = issues.stream().filter(issue -> issue.getSeverity() == Severity.ERROR);

		RenameDialog dialog = new RenameDialog(window.getShell(), "Rename..", "Please enter new name: ",
				element.getName(), new NameUniquenessValidator(element), errors.count() > 0);

		if (dialog.open() == Window.OK) {
			String newName = dialog.getNewName();
			if (newName != null) {
				((RenameRefactoring) refactoring).setNewName(newName);
				refactoring.execute();
			}
		}

	}
	return null;
}
 
Example #24
Source File: JavadocStandardWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Method doEditButtonPressed.
 */
private void doEditButtonPressed() {

	List<JavadocLinkRef> selected= fListDialogField.getSelectedElements();
	if (selected.isEmpty()) {
		return;
	}
	JavadocLinkRef obj= selected.get(0);
	if (obj != null) {
		JavadocPropertyDialog jdialog= new JavadocPropertyDialog(getShell(), obj);
		if (jdialog.open() == Window.OK) {
			fListDialogField.refresh();
		}
	}

}
 
Example #25
Source File: MultipleHyperlinksComposite.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void doAdd( )
{
	HyperlinkEditorDialog dialog = new HyperlinkEditorDialog( getShell( ),
			null,
			fContext,
			fTriggerMatrix,
			fOptionalStyles );
	java.util.List<String> labels = Arrays.asList( fListHyperlinks.getItems( ) );
	dialog.setExistingLabels( labels );

	if ( dialog.open( ) == Window.OK )
	{
		URLValue value = dialog.getURLValue( );
		fMultiURLValues.getURLValues( ).add( value );
		value.eAdapters( ).addAll( fMultiURLValues.eAdapters( ) );

		String text = value.getLabel( ).getCaption( ).getValue( );
		fListHyperlinks.add( text );
		fURLValuesMap.put( text, value );
	}

	fListHyperlinks.setSelection( fListHyperlinks.getItemCount( ) - 1 );
}
 
Example #26
Source File: VariableBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void editEntries(CPVariableElement entry) {
	List<CPVariableElement> existingEntries= fVariablesList.getElements();

	VariableCreationDialog dialog= new VariableCreationDialog(getShell(), entry, existingEntries);
	if (dialog.open() != Window.OK) {
		return;
	}
	CPVariableElement newEntry= dialog.getClasspathElement();
	if (entry == null) {
		fVariablesList.addElement(newEntry);
		entry= newEntry;
		fHasChanges= true;
	} else {
		boolean hasChanges= !(entry.getName().equals(newEntry.getName()) && entry.getPath().equals(newEntry.getPath()));
		if (hasChanges) {
			fHasChanges= true;
			entry.setName(newEntry.getName());
			entry.setPath(newEntry.getPath());
			fVariablesList.refresh();
		}
	}
	fVariablesList.selectElements(new StructuredSelection(entry));
}
 
Example #27
Source File: IntroduceIndirectionInputPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private IType chooseIntermediaryType() {
	IJavaProject proj= getIntroduceIndirectionRefactoring().getProject();

	if (proj == null)
		return null;

	IJavaElement[] elements= new IJavaElement[] { proj };
	IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements);

	int elementKinds= JavaModelUtil.is18OrHigher(proj) ? IJavaSearchConstants.CLASS_AND_INTERFACE : IJavaSearchConstants.CLASS;
	FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false, getWizard().getContainer(), scope, elementKinds);

	dialog.setTitle(RefactoringMessages.IntroduceIndirectionInputPage_dialog_choose_declaring_class);
	dialog.setMessage(RefactoringMessages.IntroduceIndirectionInputPage_dialog_choose_declaring_class_long);

	if (dialog.open() == Window.OK) {
		return (IType) dialog.getFirstResult();
	}
	return null;
}
 
Example #28
Source File: DialogFuture.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
protected void processDispose ()
{
    if ( this.dlg.getReturnCode () != Window.OK )
    {
        setError ( new InterruptedException ( "Interrupted by user" ) );
    }
    else
    {
        setResult ( this.callbacks );
    }
    this.dlg = null;
}
 
Example #29
Source File: JavadocConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private String chooseWorkspaceArchive() {
	String initSelection= fArchiveField.getText();

	ILabelProvider lp= new WorkbenchLabelProvider();
	ITreeContentProvider cp= new WorkbenchContentProvider();
	Class<?>[] acceptedClasses= new Class[] { IFile.class };
	TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, true);

	IResource initSel= null;
	IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
	if (initSelection.length() > 0) {
		initSel= root.findMember(new Path(initSelection));
	}

	FilteredElementTreeSelectionDialog dialog= new FilteredElementTreeSelectionDialog(fShell, lp, cp);
	dialog.setInitialFilter(ArchiveFileFilter.JARZIP_FILTER_STRING);
	dialog.setAllowMultiple(false);
	dialog.setValidator(validator);
	dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
	dialog.setTitle(PreferencesMessages.JavadocConfigurationBlock_workspace_archive_selection_dialog_title);
	dialog.setMessage(PreferencesMessages.JavadocConfigurationBlock_workspace_archive_selection_dialog_description);
	dialog.setInput(root);
	dialog.setInitialSelection(initSel);
	dialog.setHelpAvailable(false);
	if (dialog.open() == Window.OK) {
		IResource res= (IResource) dialog.getFirstResult();
		return res.getFullPath().makeRelative().toString();
	}
	return null;
}
 
Example #30
Source File: LocationCell.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected Object openDialogBox(Control control) {
	if (exchange == null)
		return null;
	ModelSelectionDialog dialog = new ModelSelectionDialog(
			ModelType.LOCATION);
	dialog.isEmptyOk = true;
	if (dialog.open() != Window.OK)
		return null;

	CategorizedDescriptor loc = dialog.first();

	// clear the location
	if (loc == null) {
		if (exchange.location == null)
			return null;
		// delete the location
		exchange.location = null;
		editor.setDirty(true);
		return exchange;
	}

	// the same location was selected again
	if (exchange.location != null
			&& exchange.location.id == loc.id)
		return null;

	// a new location was selected
	LocationDao dao = new LocationDao(Database.get());
	exchange.location = dao.getForId(loc.id);
	editor.setDirty(true);
	return exchange;
}