Java 类org.eclipse.ui.internal.ide.IDEInternalPreferences 实例源码

项目:mesfavoris    文件:ShowInSystemExplorer.java   
/**
 * Prepare command for launching system explorer to show a path
 *
 * @param path
 *            the path to show
 * @return the command that shows the path
 */
private String formShowInSystemExplorerCommand(File path) throws IOException {
    String command = IDEWorkbenchPlugin.getDefault().getPreferenceStore()
            .getString(IDEInternalPreferences.WORKBENCH_SYSTEM_EXPLORER);

    command = Util.replaceAll(command, VARIABLE_RESOURCE, quotePath(path.getCanonicalPath()));
    command = Util.replaceAll(command, VARIABLE_RESOURCE_URI, path.getCanonicalFile().toURI().toString());
    File parent = path.getParentFile();
    if (parent != null) {
        command = Util.replaceAll(command, VARIABLE_FOLDER, quotePath(parent.getCanonicalPath()));
    }
    return command;
}
项目:typescript.java    文件:AbstractNewProjectWizard.java   
/**
 * Prompts the user for whether to switch perspectives.
 *
 * @param window
 *            The workbench window in which to switch perspectives; must not
 *            be <code>null</code>
 * @param finalPersp
 *            The perspective to switch to; must not be <code>null</code>.
 *
 * @return <code>true</code> if it's OK to switch, <code>false</code>
 *         otherwise
 */
private static boolean confirmPerspectiveSwitch(IWorkbenchWindow window, IPerspectiveDescriptor finalPersp) {
    IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
    String pspm = store.getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE);
    if (!IDEInternalPreferences.PSPM_PROMPT.equals(pspm)) {
        // Return whether or not we should always switch
        return IDEInternalPreferences.PSPM_ALWAYS.equals(pspm);
    }
    String desc = finalPersp.getDescription();
    String message;
    if (desc == null || desc.length() == 0)
        message = NLS.bind(ResourceMessages.NewProject_perspSwitchMessage, finalPersp.getLabel());
    else
        message = NLS.bind(ResourceMessages.NewProject_perspSwitchMessageWithDesc,
                new String[] { finalPersp.getLabel(), desc });

    MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(window.getShell(),
            ResourceMessages.NewProject_perspSwitchTitle, message,
            null /* use the default message for the toggle */,
            false /* toggle is initially unchecked */, store, IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE);
    int result = dialog.getReturnCode();

    // If we are not going to prompt anymore propogate the choice.
    if (dialog.getToggleState()) {
        String preferenceValue;
        if (result == IDialogConstants.YES_ID) {
            // Doesn't matter if it is replace or new window
            // as we are going to use the open perspective setting
            preferenceValue = IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE;
        } else {
            preferenceValue = IWorkbenchPreferenceConstants.NO_NEW_PERSPECTIVE;
        }

        // update PROJECT_OPEN_NEW_PERSPECTIVE to correspond
        PrefUtil.getAPIPreferenceStore().setValue(IDE.Preferences.PROJECT_OPEN_NEW_PERSPECTIVE, preferenceValue);
    }
    return result == IDialogConstants.YES_ID;
}
项目:limpet    文件:ApplicationWorkbenchAdvisor.java   
private void refreshFromLocal()
{
  String[] commandLineArgs = Platform.getCommandLineArgs();
  IPreferenceStore store =
      IDEWorkbenchPlugin.getDefault().getPreferenceStore();
  boolean refresh =
      store.getBoolean(IDEInternalPreferences.REFRESH_WORKSPACE_ON_STARTUP);
  if (!refresh)
  {
    return;
  }

  // Do not refresh if it was already done by core on startup.
  for (int i = 0; i < commandLineArgs.length; i++)
  {
    if (commandLineArgs[i].equalsIgnoreCase("-refresh"))
    {
      //$NON-NLS-1$
      return;
    }
  }

  final IContainer root = ResourcesPlugin.getWorkspace().getRoot();
  Job job = new WorkspaceJob(IDEWorkbenchMessages.Workspace_refreshing)
  {
    public IStatus runInWorkspace(IProgressMonitor monitor)
        throws CoreException
    {
      root.refreshLocal(IResource.DEPTH_INFINITE, monitor);
      return Status.OK_STATUS;
    }
  };
  job.setRule(root);
  job.schedule();
}
项目:translationstudio8    文件:ApplicationWorkbenchWindowAdvisor.java   
/**
 * 设置在拖动文件到导航视图时的模式为直接复制,见类 {@link CopyFilesAndFoldersOperation} 的方法 CopyFilesAndFoldersOperation
 * robert   09-26
 */
private void setDragModle(){
    IPreferenceStore store= IDEWorkbenchPlugin.getDefault().getPreferenceStore();
    store.setValue(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE,
            IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY);
    store.setValue(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE,
            IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY);
}
项目:tmxeditor8    文件:ApplicationWorkbenchWindowAdvisor.java   
/**
 * 设置在拖动文件到导航视图时的模式为直接复制,见类 {@link CopyFilesAndFoldersOperation} 的方法 CopyFilesAndFoldersOperation
 * robert   09-26
 */
private void setDragModle(){
    IPreferenceStore store= IDEWorkbenchPlugin.getDefault().getPreferenceStore();
    store.setValue(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE,
            IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY);
    store.setValue(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE,
            IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY);
}
项目:gama    文件:NavigatorResourceDropAssistant.java   
/**
 * Performs a resource copy
 */
private IStatus performResourceCopy(final CommonDropAdapter dropAdapter, final Shell shell,
        final IResource[] sources) {
    final MultiStatus problems =
            new MultiStatus(PlatformUI.PLUGIN_ID, 1, WorkbenchNavigatorMessages.DropAdapter_problemsMoving, null);
    mergeStatus(problems, validateTarget(dropAdapter.getCurrentTarget(), dropAdapter.getCurrentTransfer(),
            dropAdapter.getCurrentOperation()));

    final IContainer target = getActualTarget(ResourceManager.getResource(dropAdapter.getCurrentTarget()));

    boolean shouldLinkAutomatically = false;
    if (target.isVirtual()) {
        shouldLinkAutomatically = true;
        for (int i = 0; i < sources.length; i++) {
            if (sources[i].getType() != IResource.FILE && sources[i].getLocation() != null) {
                // If the source is a folder, but the location is null (a
                // broken link, for example),
                // we still generate a link automatically (the best option).
                shouldLinkAutomatically = false;
                break;
            }
        }
    }

    final CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(shell);
    // if the target is a virtual folder and all sources are files, then
    // automatically create links
    if (shouldLinkAutomatically) {
        operation.setCreateLinks(true);
        operation.copyResources(sources, target);
    } else {
        boolean allSourceAreLinksOrVirtualFolders = true;
        for (int i = 0; i < sources.length; i++) {
            if (!sources[i].isVirtual() && !sources[i].isLinked()) {
                allSourceAreLinksOrVirtualFolders = false;
                break;
            }
        }
        // if all sources are either links or groups, copy then normally,
        // don't show the dialog
        if (!allSourceAreLinksOrVirtualFolders) {
            final IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
            final String dndPreference = store.getString(
                    target.isVirtual() ? IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE
                            : IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE);

            if (dndPreference.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT)) {
                final ImportTypeDialog dialog =
                        new ImportTypeDialog(getShell(), dropAdapter.getCurrentOperation(), sources, target);
                dialog.setResource(target);
                if (dialog.open() == Window.OK) {
                    if (dialog.getSelection() == ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS)
                        operation.setVirtualFolders(true);
                    if (dialog.getSelection() == ImportTypeDialog.IMPORT_LINK)
                        operation.setCreateLinks(true);
                    if (dialog.getVariable() != null)
                        operation.setRelativeVariable(dialog.getVariable());
                    operation.copyResources(sources, target);
                } else
                    return problems;
            } else
                operation.copyResources(sources, target);
        } else
            operation.copyResources(sources, target);
    }

    return problems;
}
项目:limpet    文件:ApplicationWorkbenchWindowAdvisor.java   
private String computeTitle()
{
  IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
  IWorkbenchPage currentPage = configurer.getWindow().getActivePage();
  IEditorPart activeEditor = null;
  if (currentPage != null)
  {
    activeEditor = lastActiveEditor;
  }

  String title = null;
  IProduct product = Platform.getProduct();
  if (product != null)
  {
    title = product.getName();
  }
  if (title == null)
  {
    title = ""; //$NON-NLS-1$
  }

  if (currentPage != null)
  {
    if (activeEditor != null)
    {
      lastEditorTitle = activeEditor.getTitleToolTip();
      title =
          NLS.bind(IDEWorkbenchMessages.WorkbenchWindow_shellTitle,
              lastEditorTitle, title);
    }
    IPerspectiveDescriptor persp = currentPage.getPerspective();
    String label = ""; //$NON-NLS-1$
    if (persp != null)
    {
      label = persp.getLabel();
    }
    IAdaptable input = currentPage.getInput();
    if (input != null && !input.equals(wbAdvisor.getDefaultPageInput()))
    {
      label = currentPage.getLabel();
    }
    if (label != null && !label.equals(""))
    { //$NON-NLS-1$
      title =
          NLS.bind(IDEWorkbenchMessages.WorkbenchWindow_shellTitle, label,
              title);
    }
  }

  String workspaceLocation = wbAdvisor.getWorkspaceLocation();
  if (workspaceLocation != null)
  {
    title =
        NLS.bind(IDEWorkbenchMessages.WorkbenchWindow_shellTitle, title,
            workspaceLocation);
  }

  // Bug 284447: Prepend workspace name to the title
  String workspaceName =
      IDEWorkbenchPlugin.getDefault().getPreferenceStore().getString(
          IDEInternalPreferences.WORKSPACE_NAME);
  if (workspaceName != null && workspaceName.length() > 0)
  {
    title =
        NLS.bind(IDEWorkbenchMessages.WorkbenchWindow_shellTitle,
            workspaceName, title);
  }

  return title;
}
项目:limpet    文件:ApplicationWorkbenchWindowAdvisor.java   
private void openWelcomeEditors(IWorkbenchWindow window)
{
  if (IDEWorkbenchPlugin.getDefault().getPreferenceStore().getBoolean(
      IDEInternalPreferences.WELCOME_DIALOG))
  {
    // show the welcome page for the product the first time the
    // workbench opens
    IProduct product = Platform.getProduct();
    if (product == null)
    {
      return;
    }

    AboutInfo productInfo = new AboutInfo(product);
    URL url = productInfo.getWelcomePageURL();
    if (url == null)
    {
      return;
    }

    IDEWorkbenchPlugin.getDefault().getPreferenceStore().setValue(
        IDEInternalPreferences.WELCOME_DIALOG, false);
    openWelcomeEditor(window, new WelcomeEditorInput(productInfo), null);
  }
  else
  {
    // Show the welcome page for any newly installed features
    List<AboutInfo> welcomeFeatures = new ArrayList<AboutInfo>();
    for (Iterator<Entry<String, AboutInfo>> it =
        wbAdvisor.getNewlyAddedBundleGroups().entrySet().iterator(); it
        .hasNext();)
    {
      Entry<String, AboutInfo> entry = it.next();
      AboutInfo info = (AboutInfo) entry.getValue();

      if (info != null && info.getWelcomePageURL() != null)
      {
        welcomeFeatures.add(info);
        // activate the feature plug-in so it can run some install
        // code
        String pi = info.getBrandingBundleId();
        if (pi != null)
        {
          // Start the bundle if there is one
          Bundle bundle = Platform.getBundle(pi);
          if (bundle != null)
          {
            try
            {
              bundle.start(Bundle.START_TRANSIENT);
            }
            catch (BundleException exception)
            {
              StatusManager.getManager().handle(
                  new Status(IStatus.ERROR, IDEApplication.PLUGIN_ID,
                      "Failed to load feature", exception)); //$NON-NLS-1$
            }
          }
        }
      }
    }

    int wCount = getWorkbench().getWorkbenchWindowCount();
    for (int i = 0; i < welcomeFeatures.size(); i++)
    {
      AboutInfo newInfo = (AboutInfo) welcomeFeatures.get(i);
      String id = newInfo.getWelcomePerspectiveId();
      // Other editors were already opened in postWindowRestore(..)
      if (id == null || i >= wCount)
      {
        openWelcomeEditor(window, new WelcomeEditorInput(newInfo), id);
      }
    }
  }
}
项目:OpenSPIFe    文件:EnsembleBasicNewProjectResourceWizard.java   
/**
 * Prompts the user for whether to switch perspectives.
 * 
 * @param window
 *            The workbench window in which to switch perspectives; must not
 *            be <code>null</code>
 * @param finalPersp
 *            The perspective to switch to; must not be <code>null</code>.
 * 
 * @return <code>true</code> if it's OK to switch, <code>false</code>
 *         otherwise
 */
private static boolean confirmPerspectiveSwitch(IWorkbenchWindow window,
        IPerspectiveDescriptor finalPersp) {
    IPreferenceStore store = IDEWorkbenchPlugin.getDefault()
            .getPreferenceStore();
    String pspm = store
            .getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE);
    if (!IDEInternalPreferences.PSPM_PROMPT.equals(pspm)) {
        // Return whether or not we should always switch
        return IDEInternalPreferences.PSPM_ALWAYS.equals(pspm);
    }
    String desc = finalPersp.getDescription();
    String message;
    if (desc == null || desc.length() == 0)
        message = NLS.bind(ResourceMessages.NewProject_perspSwitchMessage,
                finalPersp.getLabel());
    else
        message = NLS.bind(
                ResourceMessages.NewProject_perspSwitchMessageWithDesc,
                new String[] { finalPersp.getLabel(), desc });

    MessageDialogWithToggle dialog = MessageDialogWithToggle
            .openYesNoQuestion(window.getShell(),
                    ResourceMessages.NewProject_perspSwitchTitle, message,
                    null /* use the default message for the toggle */,
                    false /* toggle is initially unchecked */, store,
                    IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE);
    int result = dialog.getReturnCode();

    // If we are not going to prompt anymore propogate the choice.
    if (dialog.getToggleState()) {
        String preferenceValue;
        if (result == IDialogConstants.YES_ID) {
            // Doesn't matter if it is replace or new window
            // as we are going to use the open perspective setting
            preferenceValue = IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE;
        } else {
            preferenceValue = IWorkbenchPreferenceConstants.NO_NEW_PERSPECTIVE;
        }

        // update PROJECT_OPEN_NEW_PERSPECTIVE to correspond
        PrefUtil.getAPIPreferenceStore().setValue(
                IDE.Preferences.PROJECT_OPEN_NEW_PERSPECTIVE,
                preferenceValue);
    }
    return result == IDialogConstants.YES_ID;
}