Package org.eclipse.jface.dialogs

Examples of org.eclipse.jface.dialogs.IDialogSettings


   * between several find/replace dialogs.
   *
   * @return the dialog settings to be used
   */
  private IDialogSettings getDialogSettings() {
    IDialogSettings settings= TextEditorPlugin.getDefault().getDialogSettings();
    fDialogSettings= settings.getSection(FindReplaceDialog.class.getName());
    if (fDialogSettings == null)
      fDialogSettings= settings.addNewSection(FindReplaceDialog.class.getName());
    return fDialogSettings;
  }
View Full Code Here


  /**
   * Initializes itself from the dialog settings with the same state
   * as at the previous invocation.
   */
  private void readConfiguration() {
    IDialogSettings s= getDialogSettings();

    fWrapInit= s.getBoolean("wrap"); //$NON-NLS-1$
    fCaseInit= s.getBoolean("casesensitive"); //$NON-NLS-1$
    fWholeWordInit= s.getBoolean("wholeword"); //$NON-NLS-1$
    fRegExSearch= s.getBoolean("isRegEx"); //$NON-NLS-1$
    fSelection= s.get("selection"); //$NON-NLS-1$

    String[] findHistory= s.getArray("findhistory"); //$NON-NLS-1$
    if (findHistory != null) {
      fFindHistory.clear();
      for (int i= 0; i < findHistory.length; i++)
        fFindHistory.add(findHistory[i]);
    }
View Full Code Here

   */
  private void writeConfiguration() {
    if (fFindString == null)
      return;

    IDialogSettings s= getDialogSettings();

    String selection= fTarget.getSelectionText();
    if (selection == null)
      selection= ""; //$NON-NLS-1$
    s.put("selection", selection); //$NON-NLS-1$

    if (!fFindHistory.isEmpty() && fFindString.equals(fFindHistory.get(0)))
      return;

    int index= fFindHistory.indexOf(fFindString);
    if (index != -1)
      fFindHistory.remove(index);
    fFindHistory.add(0, fFindString);

    while (fFindHistory.size() > 8)
      fFindHistory.remove(8);
    String[] names= new String[fFindHistory.size()];
    fFindHistory.toArray(names);
    s.put("findhistory", names); //$NON-NLS-1$
  }
View Full Code Here

     * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
     * @since 3.2
     */
    protected IDialogSettings getDialogBoundsSettings() {
      String sectionName= getClass().getName() + "_dialogBounds"; //$NON-NLS-1$
      IDialogSettings settings= TextEditorPlugin.getDefault().getDialogSettings();
      IDialogSettings section= settings.getSection(sectionName);
      if (section == null)
        section= settings.addNewSection(sectionName);
      return section;
    }
View Full Code Here

     * IDialogSettings associated with this plugin then it will be created.
     * @param sectionName the name of the section
     * @return the IDialogSettings for the named section
   */
  public IDialogSettings getDialogSettings(String sectionName) {
        IDialogSettings settings = getDialogSettings();
        IDialogSettings section = settings.getSection(sectionName);
        if(section==null) {
            section = settings.addNewSection(sectionName);
        }

        return section;
View Full Code Here

     *
     * @param sectionName the name of the section
     * @return the IDialogSettings for the named section
     */
    public IDialogSettings getDialogSettings(String sectionName) {
        IDialogSettings settings = getDialogSettings();
        IDialogSettings section = settings.getSection(sectionName);
        if (section == null) {
            section = settings.addNewSection(sectionName);
        }

        return section;
View Full Code Here

    setTitle(ClickPlugin.getString("wizard.newPage.title"));
    setDescription(ClickPlugin.getString("wizard.newPage.description"));
  }

  public void createControl(Composite parent) {
    IDialogSettings settings =
      ClickPlugin.getDefault().getDialogSettings().getSection(
          NewClickPageWizard.SECTION_NEW_CLICK_PAGE);

    String initClassName = this.initialClassName;
    String initPackage = "";
    if(this.initialClassName != null){
      int index = this.initialClassName.lastIndexOf('.');
      if(index >= 0){
        initPackage   = this.initialClassName.substring(0, index);
        initClassName = this.initialClassName.substring(index + 1);
      }
    }

    Composite composite = new Composite(parent, SWT.NULL);

    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setLayout(new GridLayout(1, false));

    Composite projectPanel = new Composite(composite, SWT.NULL);
    GridLayout layout = new GridLayout(3, false);
    projectPanel.setLayout(layout);
    projectPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    ClickUtils.createLabel(projectPanel, ClickPlugin.getString("wizard.newPage.project"));

    project = new Text(projectPanel, SWT.BORDER);
    project.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    IJavaProject initProject = null;

    if(selection!=null){
      initProject = ClickUtils.getJavaProject(selection);
      try {
        if(initProject!=null && initProject.getProject().hasNature(JavaCore.NATURE_ID)){
          project.setText(initProject.getElementName());
        }
      } catch(Exception ex){}
    }
    project.addModifyListener(new ModifyListener(){
      public void modifyText(ModifyEvent e){
        validate();
      }
    });
    browseProject = new Button(projectPanel, SWT.PUSH);
    browseProject.setText(ClickPlugin.getString("action.browse"));
    browseProject.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(SelectionEvent evt){
        selectProject();
        validate();
      }
    });

    packageAssistProvider = new PackageNameContentProposalProvider(initProject);
    typeAssistProvider = new TypeNameContentProposalProvider(initProject);

    ClickUtils.createLabel(projectPanel, ClickPlugin.getString("preferences.template") + ":");
    template = new Combo(projectPanel, SWT.READ_ONLY);
    for(int i=0;i<templates.size();i++){
      template.add(((Template)templates.get(i)).getName());
      if(i==0){
        template.setText(((Template)templates.get(i)).getName());
      }
    }

    Group htmlGroup = new Group(composite, SWT.NULL);
    htmlGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    htmlGroup.setLayout(new GridLayout(3, false));
    htmlGroup.setText(ClickPlugin.getString("wizard.newPage.templateGroup"));

    createPageHTML = new Button(htmlGroup, SWT.CHECK);
    createPageHTML.setText(ClickPlugin.getString("wizard.newPage.templateGroup.checkbox"));
    createPageHTML.setLayoutData(createGridData(3));
    createPageHTML.setSelection(settings.getBoolean(NewClickPageWizard.SHOULD_CREATE_HTML));
    createPageHTML.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(SelectionEvent evt){
        updateHTMLGroup();
        validate();
      }
    });

    String initFolder = "";
    String initPageName = this.initialPageName;
    if(initPageName!=null){
      int index = initPageName.indexOf('/');
      if(index >= 0){
        initFolder   = initPageName.substring(0, index);
        initPageName = initPageName.substring(index + 1);
        if(!initFolder.startsWith("/")){
          initFolder = "/" + initFolder;
        }
      }
    }

    ClickUtils.createLabel(htmlGroup, ClickPlugin.getString("wizard.newPage.templateGroup.parentFolder"));
    parentFolder = new Text(htmlGroup, SWT.BORDER);
    parentFolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if(selection instanceof IFolder){
      parentFolder.setText(((IFolder)selection).getProjectRelativePath().toString() + initFolder);
    } else if(selection!=null){
      IJavaProject project = ClickUtils.getJavaProject(selection);
      if(project!=null){
        parentFolder.setText(ClickUtils.getWebAppRootFolder(project.getProject()) + initFolder);
      }
    }
    parentFolder.addModifyListener(new ModifyListener(){
      public void modifyText(ModifyEvent e){
        validate();
      }
    });

    browseParent = new Button(htmlGroup, SWT.PUSH);
    browseParent.setText(ClickPlugin.getString("action.browse"));
    browseParent.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(SelectionEvent evt){
        selectFolder();
      }
    });

    ClickUtils.createLabel(htmlGroup, ClickPlugin.getString("wizard.newPage.templateGroup.filename"));
    pageName = new Text(htmlGroup, SWT.BORDER);
    pageName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if(initPageName!=null){
      pageName.setText(initPageName);
    }
    pageName.addModifyListener(new ModifyListener(){
      public void modifyText(ModifyEvent e){
        if(className.getText().length()==0){
          insertClassName = true;
        }
        if(insertClassName && createPageClass.getSelection()){
          String page = pageName.getText(); //.replaceFirst("\\..*?$", "");
          int index = page.lastIndexOf('.');
          if(index >= 0){
            page = page.substring(0, index);
          }
              StringTokenizer tokenizer = new StringTokenizer(page, "_-");
              String name = "";
              while (tokenizer.hasMoreTokens()) {
                  String token = tokenizer.nextToken();
                  token = Character.toUpperCase(token.charAt(0)) + token.substring(1);
                  name += token;
              }
          className.setText(name);
        }
        validate();
      }
    });
    pageName.addFocusListener(new FocusAdapter(){
      public void focusLost(FocusEvent e) {
        insertClassName = className.getText().length()==0;
      }
    });

    Group classGroup = new Group(composite, SWT.NULL);
    classGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    classGroup.setLayout(new GridLayout(3, false));
    classGroup.setText(ClickPlugin.getString("wizard.newPage.pageClassGroup"));

    createPageClass = new Button(classGroup, SWT.CHECK);
    createPageClass.setText(ClickPlugin.getString("wizard.newPage.pageClassGroup.checkbox"));
    createPageClass.setLayoutData(createGridData(3));
    createPageClass.setSelection(settings.getBoolean(NewClickPageWizard.SHOULD_CREATE_CLASS));
    createPageClass.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(SelectionEvent evt){
        updateClassGroup();
        validate();
      }
    });

    ClickUtils.createLabel(classGroup, ClickPlugin.getString("wizard.newPage.pageClassGroup.sourceFolder"));
    Composite sourceField = FieldAssistUtils.createNullDecoratedPanel(classGroup, false);
    sourceFolder = new Text(sourceField, SWT.BORDER);
    sourceField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    sourceFolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    IJavaProject project = ClickUtils.getJavaProject(selection);
    IPackageFragmentRoot root = ClickUtils.getSourceFolder(selection);

    if(root != null){
      sourceFolder.setText(root.getPath().makeRelativeTo(project.getPath()).toString());
    } else if(selection != null){
      try {
        if(project!=null){
          IPackageFragmentRoot[] roots = project.getPackageFragmentRoots();
          if(roots.length >= 1){
            sourceFolder.setText(roots[0].getPath().makeRelativeTo(project.getPath()).toString());
          }
        }
      } catch(Exception ex){
        ClickPlugin.log(ex);
      }
    }
    sourceFolder.addModifyListener(new ModifyListener(){
      public void modifyText(ModifyEvent e){
        validate();
      }
    });

    browseSource = new Button(classGroup, SWT.PUSH);
    browseSource.setText(ClickPlugin.getString("action.browse"));
    browseSource.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(SelectionEvent evt){
        selectSourceFolder();
      }
    });

    ClickUtils.createLabel(classGroup, ClickPlugin.getString("wizard.newPage.pageClassGroup.package"));
    ContentAssistField packageField = new ContentAssistField(classGroup, SWT.BORDER,
        new TextControlCreator(), new TextContentAdapter(), packageAssistProvider,
        ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new char[0]);
    packageName = (Text)packageField.getControl();
    packageField.getLayoutControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    if(selection instanceof IPackageFragment){
      packageName.setText(((IPackageFragment)selection).getElementName());
    } else if(initPackage!=null && initPackage.length()!=0){
      packageName.setText(initPackage);
    } else if(getProject()!=null){
      String pagesPackage = ClickUtils.getPagePackageName(getProject());
      if(pagesPackage != null){
        packageName.setText(pagesPackage);
      }
    }
    packageName.addModifyListener(new ModifyListener(){
      public void modifyText(ModifyEvent e){
        validate();
      }
    });

    browsePackage = new Button(classGroup, SWT.PUSH);
    browsePackage.setText(ClickPlugin.getString("action.browse"));
    browsePackage.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(SelectionEvent evt){
        IRunnableContext context= new BusyIndicatorRunnableContext();
        int style = PackageSelectionDialog.F_REMOVE_DUPLICATES |
                    PackageSelectionDialog.F_SHOW_PARENTS |
                    PackageSelectionDialog.F_HIDE_DEFAULT_PACKAGE;

        JavaSearchScope scope = new JavaSearchScope();
        try {
          IJavaProject project = JavaCore.create(getProject());
          scope.add((JavaProject)project, JavaSearchScope.SOURCES, new HashSet<Integer>(2, 1));
        } catch(Exception ex){
          ClickPlugin.log(ex);
        }

        PackageSelectionDialog dialog = new PackageSelectionDialog(getShell(), context, style, scope);
        dialog.setMultipleSelection(false);
        if(dialog.open()==PackageSelectionDialog.OK){
          Object[] result = dialog.getResult();
          if(result.length >= 1){
            IPackageFragment fragment = (IPackageFragment)result[0];
            packageName.setText(fragment.getElementName());
          }
        }
      }
    });

    ClickUtils.createLabel(classGroup, ClickPlugin.getString("wizard.newPage.pageClassGroup.classname"));
    Composite classField = FieldAssistUtils.createNullDecoratedPanel(classGroup, false);
    className = new Text(classField, SWT.BORDER);
    classField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    className.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if(initClassName!=null){
      className.setText(initClassName);
    }
    className.addModifyListener(new ModifyListener(){
      public void modifyText(ModifyEvent e){
        validate();
      }
    });

    ClickUtils.createLabel(classGroup, "");

    ClickUtils.createLabel(classGroup, ClickPlugin.getString("wizard.newPage.pageClassGroup.superclass"));
    ContentAssistField superClassField = new ContentAssistField(classGroup, SWT.BORDER,
        new TextControlCreator(), new TextContentAdapter(), typeAssistProvider,
        ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new char[0]);
    superClass = (Text)superClassField.getControl();
    superClassField.getLayoutControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    superClass.setText(settings.get(NewClickPageWizard.SUPERCLASS));
    superClass.addModifyListener(new ModifyListener(){
      public void modifyText(ModifyEvent e){
        validate();
      }
    });
    browseSuperClass = new Button(classGroup, SWT.PUSH);
    browseSuperClass.setText(ClickPlugin.getString("action.browse"));
    browseSuperClass.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(SelectionEvent evt){
        Shell shell = getShell();
        try {
          IJavaProject project = JavaCore.create(getProject());

          SelectionDialog dialog = JavaUI.createTypeDialog(
              shell, new ProgressMonitorDialog(shell),
              SearchEngine.createJavaSearchScope(new IJavaElement[]{project}),
              IJavaElementSearchConstants.CONSIDER_CLASSES,false);

          if(dialog.open()==SelectionDialog.OK){
            Object[] result = dialog.getResult();
            superClass.setText(((IType)result[0]).getFullyQualifiedName());
          }
        } catch(Exception ex){
          ClickPlugin.log(ex);
        }
      }
    });

    ClickUtils.createLabel(composite, "");

    addToClickXML = new Button(composite, SWT.CHECK);
    addToClickXML.setText(ClickPlugin.getString("wizard.newPage.addMapping"));
    addToClickXML.setSelection(settings.getBoolean(NewClickPageWizard.SHOULD_ADD_TO_CLICK_XML));
    if(getProject()!=null && ClickUtils.getAutoMapping(getProject())){
      addToClickXML.setSelection(false);
    }

    updateHTMLGroup();
View Full Code Here

      super(parentShell, initialRoot, allowNewContainerName, message);
    }

    @Override
    protected IDialogSettings getDialogBoundsSettings() {
      IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings();
      IDialogSettings section = settings.getSection(SETTINGS_ID);
      if (section == null) {
        section = settings.addNewSection(SETTINGS_ID);
      }
      return section;
    }
View Full Code Here

    private final static String STORE_DESTINATION_NAMES_ID = "WizardParExportPage1.STORE_DESTINATION_NAMES_ID";

    @Override
    protected void internalSaveWidgetValues() {
        // update directory names history
        IDialogSettings settings = getDialogSettings();
        if (settings != null) {
            String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
            if (directoryNames == null)
                directoryNames = new String[0];

            directoryNames = addToHistory(directoryNames, getDestinationValue());
            settings.put(STORE_DESTINATION_NAMES_ID, directoryNames);
        }
    }
View Full Code Here

        }
    }

    @Override
    protected void restoreWidgetValues() {
        IDialogSettings settings = getDialogSettings();
        if (settings != null) {
            String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
            if (directoryNames == null || directoryNames.length == 0)
                return; // ie.- no settings stored
            // destination
            setDestinationValue(directoryNames[0]);
            for (int i = 0; i < directoryNames.length; i++)
View Full Code Here

TOP

Related Classes of org.eclipse.jface.dialogs.IDialogSettings

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.