コード例 #1
0
  /** @see IActionDelegate#run(IAction) */
  public void run(final IAction action) {
    if (fBreakpoint != null) {
      IShellProvider provider;
      if (fPart != null) {
        provider = fPart.getSite();
      } else {
        provider =
            new IShellProvider() {
              public Shell getShell() {
                final IWorkbench workbench = PlatformUI.getWorkbench();
                final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
                return (window == null) ? null : window.getShell();
              }
            };
      }
      final PropertyDialogAction propertyAction =
          new PropertyDialogAction(
              provider,
              new ISelectionProvider() {
                public void addSelectionChangedListener(final ISelectionChangedListener listener) {}

                public ISelection getSelection() {
                  return new StructuredSelection(fBreakpoint);
                }

                public void removeSelectionChangedListener(
                    final ISelectionChangedListener listener) {}

                public void setSelection(final ISelection selection) {}
              });
      propertyAction.run();
    }
  }
コード例 #2
0
ファイル: RDBConnectionUtility.java プロジェクト: eclipse/edt
  public static IStatus connectWithPromptIfNeeded(IConnectionProfile profile, boolean reprompt) {
    String profileName = profile.getName();

    Shell shell = Display.getCurrent().getActiveShell();
    IStatus connectionStatus = null;
    ConnectionInfo info = null;
    if (profile != null) {
      if (shell == null) {
        connectionStatus = profile.connect();
      } else {
        connectionStatus = profile.connectWithoutJob();
        if (reprompt
            && profile.getConnectionState() != IConnectionProfile.CONNECTED_STATE
            && connectionStatus.getCode()
                != IStatus.OK) // could be marked OK if the profile can't be found for some reason
        {
          String title = NLS.bind(SQLNlsStrings.SQL_CONNECTION_FAILURE_MSG, profile.getName());
          MessageDialog.openInformation(
              shell, title, connectionStatus.getChildren()[0].getException().getLocalizedMessage());

          // Prompt to fix properties
          PropertyDialogAction propertyDialogAction =
              new PropertyDialogAction(
                  new SameShellProvider(shell),
                  new ConnectionPropertiesWizardSelectionProvider(profile));

          StructuredSelection selection = new StructuredSelection(profile);
          propertyDialogAction.selectionChanged(selection);
          if (!profile.arePropertiesComplete() && propertyDialogAction.isApplicableForSelection()) {
            // something in createDialog is failing to initialize the properties correctly the first
            // time
            // around. I can't debug it because it crashes the debugger when I set a breakpoint, so
            // I'll
            // call twice for now to get the initialization to happen until I figure it out.
            PreferenceDialog dialog = propertyDialogAction.createDialog();
            dialog = propertyDialogAction.createDialog();
            String shellText =
                NLS.bind(SQLNlsStrings.SQL_CONNECTION_PROPERTIES_FOR, profile.getName());
            dialog.getShell().setText(shellText);
            IConnectionProfileProvider provider = profile.getProvider();
            IPropertiesPersistenceHook hook =
                ((ConnectionProfileProvider) provider).getPropertiesPersistenceHook();
            String initialPage = hook.getConnectionPropertiesPageID();
            if (initialPage != null) {
              ((IWorkbenchPreferenceContainer) dialog).openPage(initialPage, null);
            }
            if (dialog.open() == Dialog.CANCEL) {
              reprompt = false;
            }
          }
          if (reprompt) {
            connectionStatus = profile.connectWithoutJob();
          }
        }
      }
    }

    return connectionStatus;
  }
コード例 #3
0
  private void createSiteActions(IWorkbenchSite site, ISelectionProvider specialProvider) {
    fOpenImplementation = new OpenImplementationAction(site);
    fOpenImplementation.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_IMPLEMENTATION);
    fOpenImplementation.setSpecialSelectionProvider(specialProvider);

    fOpenSuperImplementation = new OpenSuperImplementationAction(site);
    fOpenSuperImplementation.setActionDefinitionId(
        IJavaEditorActionDefinitionIds.OPEN_SUPER_IMPLEMENTATION);
    fOpenSuperImplementation.setSpecialSelectionProvider(specialProvider);

    fOpenAttachedJavadoc = new OpenAttachedJavadocAction(site);
    fOpenAttachedJavadoc.setActionDefinitionId(
        IJavaEditorActionDefinitionIds.OPEN_ATTACHED_JAVADOC);
    fOpenAttachedJavadoc.setSpecialSelectionProvider(specialProvider);

    fOpenTypeHierarchy = new OpenTypeHierarchyAction(site);
    fOpenTypeHierarchy.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY);
    fOpenTypeHierarchy.setSpecialSelectionProvider(specialProvider);

    fOpenCallHierarchy = new OpenCallHierarchyAction(site);
    fOpenCallHierarchy.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_CALL_HIERARCHY);
    fOpenCallHierarchy.setSpecialSelectionProvider(specialProvider);

    ISelectionProvider provider =
        specialProvider != null ? specialProvider : site.getSelectionProvider();

    fOpenPropertiesDialog = new PropertyDialogAction(site, provider);
    fOpenPropertiesDialog.setActionDefinitionId(IWorkbenchCommandConstants.FILE_PROPERTIES);

    initialize(provider);
  }
コード例 #4
0
  /* (non-Javadoc)
   * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
   */
  public void run(IAction action) {
    PropertyDialogAction propertyAction =
        new PropertyDialogAction(
            getActivePart().getSite(),
            new ISelectionProvider() {
              public void addSelectionChangedListener(ISelectionChangedListener listener) {}

              public ISelection getSelection() {
                return new StructuredSelection(getBreakpoint());
              }

              public void removeSelectionChangedListener(ISelectionChangedListener listener) {}

              public void setSelection(ISelection selection) {}
            });
    propertyAction.run();
  }
コード例 #5
0
 private void initialize(ISelectionProvider provider) {
   fSelectionProvider = provider;
   ISelection selection = provider.getSelection();
   fOpenImplementation.update(selection);
   fOpenSuperImplementation.update(selection);
   fOpenAttachedJavadoc.update(selection);
   fOpenTypeHierarchy.update(selection);
   fOpenCallHierarchy.update(selection);
   if (!fEditorIsOwner) {
     if (fShowOpenPropertiesAction) {
       if (selection instanceof IStructuredSelection) {
         fOpenPropertiesDialog.selectionChanged((IStructuredSelection) selection);
       } else {
         fOpenPropertiesDialog.selectionChanged(selection);
       }
     }
     provider.addSelectionChangedListener(fOpenImplementation);
     provider.addSelectionChangedListener(fOpenSuperImplementation);
     provider.addSelectionChangedListener(fOpenAttachedJavadoc);
     provider.addSelectionChangedListener(fOpenTypeHierarchy);
     provider.addSelectionChangedListener(fOpenCallHierarchy);
     // no need to register the open properties dialog action since it registers itself
   }
 }
コード例 #6
0
  /* (non-Javadoc)
   * Method declared in ActionGroup
   */
  @Override
  public void fillContextMenu(IMenuManager menu) {
    super.fillContextMenu(menu);
    if (!fIsTypeHiararchyViewerOwner) appendToGroup(menu, fOpenTypeHierarchy);
    if (!fIsCallHiararchyViewerOwner) appendToGroup(menu, fOpenCallHierarchy);

    if (fShowShowInMenu) {
      MenuManager showInSubMenu = new MenuManager(getShowInMenuLabel());
      IWorkbenchWindow workbenchWindow = fOpenSuperImplementation.getSite().getWorkbenchWindow();
      showInSubMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(workbenchWindow));
      menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, showInSubMenu);
    }

    IStructuredSelection selection = getStructuredSelection();
    if (fShowOpenPropertiesAction
        && selection != null
        && fOpenPropertiesDialog.isApplicableForSelection())
      menu.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, fOpenPropertiesDialog);
  }
コード例 #7
0
 /** @see org.eclipse.ui.actions.ActionGroup#dispose() */
 public void dispose() {
   propertyDialogAction.dispose();
   super.dispose();
 }
コード例 #8
0
 /**
  * Updates the actions which were added to the action bars, delegating to the subgroups as
  * necessary.
  */
 public void updateActionBars() {
   IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
   propertyDialogAction.setEnabled(selection.size() == 1);
 }