Java Code Examples for org.eclipse.jdt.ui.JavaUI#createTypeDialog()

The following examples show how to use org.eclipse.jdt.ui.JavaUI#createTypeDialog() . 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: GotoTypeAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
	Shell shell= JavaPlugin.getActiveWorkbenchShell();
	SelectionDialog dialog= null;
	try {
		dialog= JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell),
			SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_ALL_TYPES, false);
	} catch (JavaModelException e) {
		String title= getDialogTitle();
		String message= PackagesMessages.GotoType_error_message;
		ExceptionHandler.handle(e, title, message);
		return;
	}

	dialog.setTitle(getDialogTitle());
	dialog.setMessage(PackagesMessages.GotoType_dialog_message);
	if (dialog.open() == IDialogConstants.CANCEL_ID) {
		return;
	}

	Object[] types= dialog.getResult();
	if (types != null && types.length > 0) {
		gotoType((IType) types[0]);
	}
}
 
Example 2
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 3
Source File: GenerateToStringDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void browseForBuilderClass() {
	try {
		IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaElement[] { getType().getJavaProject() });
		SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), PlatformUI.getWorkbench().getProgressService(), scope,
				IJavaElementSearchConstants.CONSIDER_CLASSES, false, "*ToString", fExtension); //$NON-NLS-1$
		dialog.setTitle(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_classSelection_windowTitle);
		dialog.setMessage(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_classSelection_message);
		dialog.open();
		if (dialog.getReturnCode() == OK) {
			IType type= (IType)dialog.getResult()[0];
			fBuilderClassName.setText(type.getFullyQualifiedParameterizedName());
			List<String> suggestions= fValidator.getAppendMethodSuggestions(type);
			if (!suggestions.contains(fAppendMethodName.getText()))
				fAppendMethodName.setText(suggestions.get(0));
			suggestions= fValidator.getResultMethodSuggestions(type);
			if (!suggestions.contains(fResultMethodName.getText()))
				fResultMethodName.setText(suggestions.get(0));
		}
	} catch (JavaModelException e) {
		JavaPlugin.log(e);
	}
}
 
Example 4
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 5
Source File: ProblemSeveritiesConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void doBrowseTypes(StringButtonDialogField dialogField) {
	IRunnableContext context= new BusyIndicatorRunnableContext();
	IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
	int style= IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES;
	try {
		SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, dialogField.getText());
		dialog.setTitle(PreferencesMessages.NullAnnotationsConfigurationDialog_browse_title);
		dialog.setMessage(PreferencesMessages.NullAnnotationsConfigurationDialog_choose_annotation);
		if (dialog.open() == Window.OK) {
			IType res= (IType) dialog.getResult()[0];
			dialogField.setText(res.getFullyQualifiedName('.'));
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, getShell(), PreferencesMessages.NullAnnotationsConfigurationDialog_error_title, PreferencesMessages.NullAnnotationsConfigurationDialog_error_message);
	}
}
 
Example 6
Source File: ImportOrganizeInputDialog.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.ImportOrganizeInputDialog_ChooseTypeDialog_title);
		dialog.setMessage(PreferencesMessages.ImportOrganizeInputDialog_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.ImportOrganizeInputDialog_ChooseTypeDialog_title, PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_error_message);
	}
}
 
Example 7
Source File: PrimitiveSection.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
@Override
public void handleEvent(Event event) {
  valueChanged = false;
  OperationalProperties ops = getOperationalProperties();
  if (event.widget == findButton) {
    String className = null;
    try {
      String implKind = editor.getAeDescription().getFrameworkImplementation();
      if (Constants.CPP_FRAMEWORK_NAME.equals(implKind)) {
        FileDialog dialog = new FileDialog(getSection().getShell(), SWT.NONE);
        String[] extensions = { "*.dll" };
        dialog.setFilterExtensions(extensions);
        String sStartDir = Platform.getLocation().toString();
        dialog.setFilterPath(sStartDir);
        className = dialog.open();

      } else {
        SelectionDialog typeDialog = JavaUI.createTypeDialog(getSection().getShell(), editor
                .getEditorSite().getWorkbenchWindow(), editor.getSearchScopeForDescriptorType(),
                IJavaElementSearchConstants.CONSIDER_CLASSES, false, "*");
        typeDialog.setTitle(MessageFormat.format("Choose the {0} implementation class",
                new Object[] { editor.descriptorTypeString() }));
        typeDialog.setMessage("Filter/mask:");
        if (typeDialog.open() == Window.CANCEL)
          return;
        Object[] result = typeDialog.getResult();
        if (result != null && result.length > 0)
          className = ((IType) result[0]).getFullyQualifiedName();
      }
      if (className == null || className.equals("")) //$NON-NLS-1$
        return;
      implName.setText(className);
      editor.getAeDescription().setAnnotatorImplementationName(className);
      valueChanged = true;
    } catch (JavaModelException e) {
      throw new InternalErrorCDE("unexpected Exception", e);
    }
  } else if (event.widget == modifiesCas) {
    ops.setModifiesCas(setValueChangedBoolean(modifiesCas.getSelection(), ops.getModifiesCas()));
  } else if (event.widget == multipleDeploymentAllowed) {
    ops.setMultipleDeploymentAllowed(setValueChangedBoolean(multipleDeploymentAllowed
            .getSelection(), ops.isMultipleDeploymentAllowed()));
  } else if (event.widget == outputsNewCASes) {
    ops.setOutputsNewCASes(setValueChangedBoolean(outputsNewCASes.getSelection(), ops
            .getOutputsNewCASes()));
  } else if (event.widget == implName) {
    editor.getAeDescription().setAnnotatorImplementationName(
            setValueChanged(implName.getText(), editor.getAeDescription()
                    .getAnnotatorImplementationName()));
  }
  if (valueChanged)
    editor.setFileDirty();
}