org.eclipse.ui.dialogs.PreferencesUtil源码实例Demo

类org.eclipse.ui.dialogs.PreferencesUtil源码实例Demo

下面列出了org.eclipse.ui.dialogs.PreferencesUtil 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: corrosion   文件: RLSStreamConnectionProvider.java
private static void showSetupRustNotification() {
	Display.getDefault().asyncExec(() -> {
		if (hasCancelledSetup) {
			return;
		}
		setHasCancelledSetup(true);
		Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
		int dialogResponse = MessageDialog.open(MessageDialog.CONFIRM, shell,
				Messages.RLSStreamConnectionProvider_rustSupportNotFound,
				Messages.RLSStreamConnectionProvider_requirementsNotFound, SWT.NONE,
				Messages.RLSStreamConnectionProvider_OpenPreferences, IDialogConstants.CANCEL_LABEL); // $NON-NLS-4$
		if (dialogResponse == 0) {
			PreferenceDialog preferenceDialog = PreferencesUtil.createPreferenceDialogOn(shell,
					CorrosionPreferencePage.PAGE_ID, new String[] { CorrosionPreferencePage.PAGE_ID }, null);
			preferenceDialog.setBlockOnOpen(true);
			preferenceDialog.open();
			setHasCancelledSetup(false);
		}
	});
}
 
源代码2 项目: tracecompass   文件: LoadDialog.java
@Override
protected void createButtonsForButtonBar(final Composite parent) {
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    Button manageButton = createButton(parent, IDialogConstants.CLIENT_ID + 1, Messages.TraceControl_ManageButtonText, false);
    manageButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            PreferenceDialog dialog =
                    PreferencesUtil.createPreferenceDialogOn(parent.getShell(),
                            ControlRemoteProfilesPreferencePage.ID,
                            new String[] { ControlRemoteProfilesPreferencePage.ID },
                            null);
            dialog.open();
            if (fLocalComposite != null) {
                fFolderViewer.setInput(LTTngProfileViewer.getViewerInput());
                enableLocalButtons();
            }
        }
    });
    Button button = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
    button.setEnabled(false);
}
 
public final Object execute(final ExecutionEvent event)
{
	final String preferencePageId = event.getParameter(IWorkbenchCommandConstants.WINDOW_PREFERENCES_PARM_PAGEID);
	final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);

	final Shell shell;
	if (activeWorkbenchWindow == null)
	{
		shell = null;
	}
	else
	{
		shell = activeWorkbenchWindow.getShell();
	}

	final PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, preferencePageId,
			new String[] { preferencePageId }, null);
	dialog.open();

	return null;
}
 
@Override
public void init(IPageSite site) {
	super.init(site);
	IMenuManager menuManager = site.getActionBars().getMenuManager();
	menuManager.insertBefore(IContextMenuConstants.GROUP_PROPERTIES, new Separator(GROUP_FILTERING));
	fActionGroup.fillActionBars(site.getActionBars());
	menuManager.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, new Action(SearchMessages.JavaSearchResultPage_preferences_label) {
		@Override
		public void run() {
			String pageId= "org.eclipse.search.preferences.SearchPreferencePage"; //$NON-NLS-1$
			String[] displayedPages= { pageId,
					"org.eclipse.ui.editors.preferencePages.Annotations", //$NON-NLS-1$
					"org.eclipse.ui.preferencePages.ColorsAndFonts" //$NON-NLS-1$
			};
			PreferencesUtil.createPreferenceDialogOn(JavaPlugin.getActiveWorkbenchShell(), pageId, displayedPages, null).open();
		}
	});
}
 
private void createHeader(Composite contents) {
	String text= PreferencesMessages.PropertiesFileEditorPreferencePage_link;
	Link link= new Link(contents, SWT.NONE);
	link.setText(text);
	link.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			if ("org.eclipse.ui.preferencePages.GeneralTextEditor".equals(e.text)) //$NON-NLS-1$
				PreferencesUtil.createPreferenceDialogOn(getShell(), e.text, null, null);
			else if ("org.eclipse.ui.preferencePages.ColorsAndFonts".equals(e.text)) //$NON-NLS-1$
				PreferencesUtil.createPreferenceDialogOn(getShell(), e.text, null, "selectFont:org.eclipse.jdt.ui.PropertiesFileEditor.textfont"); //$NON-NLS-1$
		}
	});

	GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
	gridData.widthHint= 150; // only expand further if anyone else requires it
	link.setLayoutData(gridData);

	addFiller(contents);
}
 
private void createHeader(Composite contents) {
	final Shell shell= contents.getShell();
	String text= PreferencesMessages.JavaEditorPreferencePage_link;
	Link link= new Link(contents, SWT.NONE);
	link.setText(text);
	link.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			if ("org.eclipse.ui.preferencePages.GeneralTextEditor".equals(e.text)) //$NON-NLS-1$
				PreferencesUtil.createPreferenceDialogOn(shell, e.text, null, null);
			else if ("org.eclipse.ui.preferencePages.ColorsAndFonts".equals(e.text)) //$NON-NLS-1$
				PreferencesUtil.createPreferenceDialogOn(shell, e.text, null, "selectFont:org.eclipse.jdt.ui.editors.textfont"); //$NON-NLS-1$
		}
	});

	GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
	gridData.widthHint= 150; // only expand further if anyone else requires it
	link.setLayoutData(gridData);

	addFiller(contents);
}
 
private void createKeysLink(Composite composite, int h_span) {
   Link link= new Link(composite, SWT.NONE | SWT.WRAP);
link.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_key_binding_hint);
link.addSelectionListener(new SelectionAdapter() {
	@Override
	public void widgetSelected(SelectionEvent e) {
		PreferencesUtil.createPreferenceDialogOn(getShell(), e.text, null, null);
	}
});

PixelConverter pixelConverter= new PixelConverter(composite);
int width= pixelConverter.convertWidthInCharsToPixels(40);

// limit the size of the Link as it would take all it can get
GridData gd= new GridData(GridData.FILL, GridData.FILL, false, false, h_span, 1);
gd.widthHint= width;
link.setLayoutData(gd);
  }
 
源代码8 项目: sarl   文件: MainProjectWizardPage.java
@SuppressWarnings("synthetic-access")
@Override
public void widgetDefaultSelected(SelectionEvent event) {
	final String jreID = BuildPathSupport.JRE_PREF_PAGE_ID;
	final String eeID = BuildPathSupport.EE_PREF_PAGE_ID;
	final String complianceId = CompliancePreferencePage.PREF_ID;
	final Map<String, Boolean> data = new HashMap<>();
	data.put(PropertyAndPreferencePage.DATA_NO_LINK, Boolean.TRUE);
	PreferencesUtil.createPreferenceDialogOn(
			getShell(), jreID,
			new String[] {jreID, complianceId, eeID},
			data).open();

	handlePossibleJVMChange();
	MainProjectWizardPage.this.detectGroup.handlePossibleJVMChange();
}
 
源代码9 项目: olca-app   文件: AddRepositoryDialog.java
private void createConfigViewer(Composite container, FormToolkit toolkit) {
	UI.formLabel(container, toolkit, M.ServerUrl);
	configViewer = new ConfigViewer(container);
	configViewer.setInput(CloudConfigurations.get());
	Hyperlink editConfig = UI.formLink(container, toolkit, M.Edit);
	editConfig.setForeground(Colors.linkBlue());
	editConfig.addHyperlinkListener(new HyperlinkAdapter() {
		@Override
		public void linkActivated(HyperlinkEvent e) {
			PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, CloudPreferencePage.ID,
					null, null);
			dialog.setBlockOnOpen(true);
			dialog.open();
			configViewer.setInput(CloudConfigurations.get());
			configViewer.select(CloudConfigurations.getDefault());
		}
	});
}
 
源代码10 项目: sarl   文件: MainProjectWizardPage.java
@SuppressWarnings("synthetic-access")
@Override
public void widgetDefaultSelected(SelectionEvent event) {
	final String jreID = BuildPathSupport.JRE_PREF_PAGE_ID;
	final String eeID = BuildPathSupport.EE_PREF_PAGE_ID;
	final String complianceId = CompliancePreferencePage.PREF_ID;
	final Map<String, Boolean> data = new HashMap<>();
	data.put(PropertyAndPreferencePage.DATA_NO_LINK, Boolean.TRUE);
	final String id = "JRE".equals(event.text) ? jreID : complianceId; //$NON-NLS-1$
	PreferencesUtil.createPreferenceDialogOn(getShell(), id,
			new String[] {jreID, complianceId, eeID},
			data).open();

	MainProjectWizardPage.this.jreGroup.handlePossibleJVMChange();
	handlePossibleJVMChange();
}
 
源代码11 项目: goclipse   文件: GoUIPlugin.java
protected void checkPrefPageIdIsValid(String prefId) {
	Shell shell = WorkbenchUtils.getActiveWorkbenchShell();
	PreferenceDialog prefDialog = PreferencesUtil.createPreferenceDialogOn(shell, prefId, null, null);
	assertNotNull(prefDialog); // Don't create, just eagerly check that it exits, that the ID is correct
	ISelection selection = prefDialog.getTreeViewer().getSelection();
	if(selection instanceof IStructuredSelection) {
		IStructuredSelection ss = (IStructuredSelection) selection;
		if(ss.getFirstElement() instanceof IPreferenceNode) {
			IPreferenceNode prefNode = (IPreferenceNode) ss.getFirstElement();
			if(prefNode.getId().equals(prefId)) {
				return; // Id exists
			}
		}
	}
	assertFail();
}
 
private void configurePreferenceLink(Link link, final IJavaProject javaProject, final String preferenceId, final String propertyId) {
	link.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			if (fContainer instanceof IWorkbenchPreferenceContainer) {
				IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer)fContainer;
				if (javaProject != null) {
					container.openPage(propertyId, null);
				} else {
					container.openPage(preferenceId, null);
				}
			} else {
				PreferencesUtil.createPreferenceDialogOn(fShell, preferenceId, null, null);
			}
		}
	});
}
 
@Override
public void createControl(Composite parent) {

	Composite container = new Composite(parent, SWT.NULL);
	container.setLayout(new GridLayout(3, false));

	Label ghidraInstallDirLabel = new Label(container, SWT.NULL);
	ghidraInstallDirLabel.setText("Ghidra installation:");
	ghidraInstallDirCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
	ghidraInstallDirCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	populateGhidraInstallationCombo();
	ghidraInstallDirCombo.addModifyListener(evt -> validate());
	ghidraInstallDirCombo.setToolTipText("The wizard requires a Ghidra installation to be " +
		"selected.  Click the + button to add or manage Ghidra installations.");
	addGhidraInstallDirButton = new Button(container, SWT.BUTTON1);
	addGhidraInstallDirButton.setText("+");
	addGhidraInstallDirButton.setToolTipText("Adds/manages Ghidra installations.");
	addGhidraInstallDirButton.addListener(SWT.Selection, evt -> {
		PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null,
			GhidraProjectCreatorPreferencePage.class.getName(), null, null);
		dialog.open();
		populateGhidraInstallationCombo();
		validate();
	});

	validate();
	setControl(container);
}
 
源代码14 项目: n4js   文件: AbstractN4JSPreferencePage.java
/** copied from PropertyAndPreferencePage */
protected final void openProjectProperties(IProject proj, Object data) {
	String id = getPropertyPageID();
	if (id != null) {
		PreferencesUtil.createPropertyDialogOn(getShell(), proj, id, new String[] { id }, data).open();
	}
}
 
源代码15 项目: aCute   文件: AcutePlugin.java
private static void openCommandErrorDialog(String title, String content) {
	Display.getDefault().asyncExec(() -> {
		Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
		int dialogResponse = MessageDialog.open(MessageDialog.CONFIRM, shell, title,
				content, SWT.NONE, Messages.acutePlugin_openPreferences, Messages.acutePlugin_cancel);
		if (dialogResponse == 0) {
			PreferenceDialog preferenceDialog = PreferencesUtil.createPreferenceDialogOn(shell,
					AcutePreferencePage.PAGE_ID,
					new String[] { AcutePreferencePage.PAGE_ID }, null);
			preferenceDialog.setBlockOnOpen(false);
			preferenceDialog.open();
		}
	});
}
 
源代码16 项目: workspacemechanic   文件: OpenPreferencesAction.java
/**
 * Opens the preferences dialog.
 */
private void openPreferences() {
  Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
  PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
      shell, pageId, null, null);
  dialog.open();

  // not sure if I have to do any cleanup. If so, the we probably want to:
  // dialog.blockOnOpen(true), then do the cleanup
}
 
@Override
public void widgetDisposed(DisposeEvent event) {
  if (openPreferenceDialog) {
    // switch to Cloud SDK preferences panel
    event.display.asyncExec(() -> {
      PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
          null, CloudSdkPreferenceArea.PAGE_ID, null, null);
      dialog.open();
   });   
  }
}
 
源代码18 项目: xds-ide   文件: AddWordProposal.java
public final void apply(final IDocument document) {

		final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
		final ISpellChecker checker= engine.getSpellChecker();

		if (checker == null)
			return;

		if (!checker.acceptsWords()) {
			final Shell shell;
			if (fContext != null && fContext.getSourceViewer() != null)
				shell= fContext.getSourceViewer().getTextWidget().getShell();
			else
				shell= WorkbenchUtils.getWorkbenchWindowShell();

			if (!canAskToConfigure() || !askUserToConfigureUserDictionary(shell))
				return;

			String[] preferencePageIds= new String[] { "org.eclipse.ui.editors.preferencePages.Spelling" }; //$NON-NLS-1$
			PreferencesUtil.createPreferenceDialogOn(shell, preferencePageIds[0], preferencePageIds, null).open();
		}

		if (checker.acceptsWords()) {
			checker.addWord(fWord);
			if (fContext != null && fContext.getSourceViewer() != null)
				SpellingProblem.removeAll(fContext.getSourceViewer(), fWord);
		}
	}
 
源代码19 项目: xds-ide   文件: MarkOccurrencesPreferencePage.java
@Override
protected Control createContents(final Composite parent) {
    Composite composite= new Composite(parent, SWT.NONE);
    GridLayout layout= new GridLayout();
    layout.numColumns= 1;
    layout.marginHeight= 0;
    layout.marginWidth= 0;
    composite.setLayout(layout);

    Link link= new Link(composite, SWT.NONE);
    link.setText(Messages.MarkOccurrencesPreferencePage_LinkText);
    link.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            String data= null;
            AnnotationPreference preference= EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference("org.eclipse.jdt.ui.occurrences"); //$NON-NLS-1$
            if (preference != null)
                data= preference.getPreferenceLabel();
            PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, data);
        }
    });
    
    SWTFactory.createLabel(composite, "", 1); //$NON-NLS-1$
    
    cboxOnOff = SWTFactory.createCheckbox(composite, Messages.MarkOccurrencesPreferencePage_MarkOccurrencesOfElement, 1);
    
    initFromStore();
    return composite;
}
 
源代码20 项目: xds-ide   文件: XFindPanel.java
protected void fillSettingsMenu(final IMenuManager menu) {
    menu.add(new Separator());
    newCheckAction( menu, FIND_CASE_SENSITIVE, Messages.XFindPanel_Settings_MatchCase_label
                  , true );
    newCheckAction( menu, FIND_WHOLE_WORD, Messages.XFindPanel_Settings_WholeWord_label
                  , isWholeWordSearchEnabled(searchText.getText()) );
    newCheckAction( menu, FIND_REGEXP, Messages.XFindPanel_Settings_RegExpr_label
                  , isRegExSupported );
    newCheckAction( menu, FIND_INCREMENTAL, Messages.XFindPanel_Settings_Incremental
                  , isIncrementalSearchEnabled() );

    menu.add(new Separator());
    menu.add(new Action(Messages.XFindPanel_Settings_ClearHistory_label) {
        @Override
        public void run() {
            clearHistory();
        }
    });
    menu.add(new Separator());
    menu.add(new Action(Messages.XFindPanel_Settings_ShowPreferences_label) {
        @Override
        public void run() {
            PreferencesUtil.createPreferenceDialogOn(toolBar.getShell(),
                    PREFERENCE_PAGE_ID, null, null).open();
        }
    });
}
 
源代码21 项目: gef   文件: GraphvizConfigurationDialog.java
@Override
protected Control createMessageArea(Composite composite) {
	// prevent creation of messageLabel by super implementation
	String linkText = message;
	message = null;
	super.createMessageArea(composite);
	message = linkText;

	Link messageLink = new Link(composite, SWT.WRAP);
	messageLink.setText(message);
	GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
			.grab(true, false).applyTo(messageLink);
	messageLink.addListener(SWT.Selection, new Listener() {
		@Override
		public void handleEvent(Event event) {
			Shell shell = PlatformUI.getWorkbench()
					.getActiveWorkbenchWindow().getShell();
			PreferenceDialog pref = PreferencesUtil
					.createPreferenceDialogOn(shell,
							"org.eclipse.gef.dot.internal.ui.GraphvizPreferencePage", //$NON-NLS-1$
							null, null);
			if (pref != null) {
				close();
				pref.open();
			}
		}
	});
	return composite;
}
 
源代码22 项目: thym   文件: MissingSDKStatusHandler.java
@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();
	}
}
 
public void run(final IMarker marker) {
  PreferenceDialog page = PreferencesUtil.createPropertyDialogOn(
      CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
      marker.getResource().getProject(), projectPropertyPageID,
      new String[] {projectPropertyPageID}, null);

  page.open();
}
 
public void run(IAction action) {
  Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

  if (resource != null && resource.getType() == IResource.PROJECT) {
    PreferenceDialog page = PreferencesUtil.createPropertyDialogOn(shell,
        resource, propertiesPageID, null, null);
    if (page != null) {
      page.open();
      return;
    }
  }

  CorePluginLog.logError("Could not create project properties dialog for resource "
      + resource.toString());
}
 
源代码25 项目: gwt-eclipse-plugin   文件: BrowserMenuPopulator.java
/**
 * Find a browser to open url
 */
private void findBrowser() {
  MessageDialog md = new MessageDialog(SWTUtilities.getShell(), "No browsers found", null, null, MessageDialog.ERROR,
      new String[] { "Ok" }, 0) {

    @Override
    protected Control createMessageArea(Composite parent) {
      super.createMessageArea(parent);
      Link link = new Link(parent, SWT.NONE);

      link.setText("There are no browsers defined, please add one (Right-click on URL -> "
          + "Open with -> Add a Browser, or <a href=\"#\">Window -> Preferences -> General -> Web Browser</a>).");
      link.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          PreferenceDialog dialog = PreferencesUtil
              .createPreferenceDialogOn(Display.getCurrent().getActiveShell(),
                  "org.eclipse.ui.browser.preferencePage", new String[] { "org.eclipse.ui.browser.preferencePage" },
                  null);

          if (dialog != null) {
            dialog.open();
          }
        }
      });
      return parent;
    }
  };
  md.open();
}
 
private void createSdkComponent(Composite parent) {
  Group group = SWTFactory.createGroup(parent, "GWT SDK", 1, 1, GridData.FILL_HORIZONTAL);

  sdkSelectionBlock = new ProjectSdkSelectionBlock<GwtSdk>(group, SWT.NONE, getJavaProject()) {
    @Override
    protected void doConfigure() {
      if (Window.OK == PreferencesUtil.createPreferenceDialogOn(getShell(), GwtPreferencePage.ID, new String[] {GwtPreferencePage.ID}, null).open()) {
        GWTProjectPropertyPage.this.fieldChanged();
      }
    }

    @Override
    protected GwtSdk doFindSdkFor(IJavaProject javaProject) {
      return GwtSdk.findSdkFor(javaProject);
    }

    @Override
    protected String doGetContainerId() {
      return GWTRuntimeContainer.CONTAINER_ID;
    }

    @Override
    protected SdkManager<GwtSdk> doGetSdkManager() {
      return GWTPreferences.getSdkManager();
    }
  };
}
 
@Override
protected void doConfigure() {
  if (Window.OK == PreferencesUtil
      .createPreferenceDialogOn(getShell(), GwtPreferencePage.ID, new String[] { GwtPreferencePage.ID }, null)
      .open()) {
    NewWebAppProjectWizardPage.this.updateControls();
  }
}
 
源代码28 项目: gama   文件: TemplatesView.java
@Override
public void createPartControl(final Composite parent) {
	PreferenceDialog dialog =
		PreferencesUtil.createPreferenceDialogOn(parent.getShell(), "msi.gama.lang.gaml.Gaml.templates",
			new String[] {}, null);
	PreferencePage selectedPage = (PreferencePage) dialog.getSelectedPage();
	selectedPage.createControl(parent);
}
 
protected final void openProjectProperties(IProject project, Object data)
{
	String id = getPropertyPageId();
	if (id != null)
	{
		PreferencesUtil.createPropertyDialogOn(getShell(), project, id, new String[] { id }, data).open();
	}
}
 
源代码30 项目: goclipse   文件: ControlUtils.java
public static Link createOpenPreferencesDialogLinkedText(final Composite topControl, String linkText,
		Consumer<Link> afterDialogOpen) {
	Link link = new Link(topControl, SWT.NONE);
	link.setText(linkText);
	link.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			PreferencesUtil.createPreferenceDialogOn(topControl.getShell(),e.text, null, null).open();
			if(afterDialogOpen != null) {
				afterDialogOpen.accept(link);
			}
		}
	});
	return link;
}
 
如果文章对您有帮助,请点击页面广告。以鼓励作者做出的努力。
 类所在包
 类方法
 同包方法