Example usage for org.eclipse.jface.dialogs Dialog applyDialogFont

List of usage examples for org.eclipse.jface.dialogs Dialog applyDialogFont

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs Dialog applyDialogFont.

Prototype

public static void applyDialogFont(Control control) 

Source Link

Document

Applies the dialog font to all controls that currently have the default font.

Usage

From source file:com.aptana.ruby.ui.wizards.WizardNewRubyProjectCreationPage.java

License:Open Source License

/**
 * (non-Javadoc) Method declared on IDialogPage.
 *///from  w  ww  .  j  a  va2 s .c om
public void createControl(Composite parent) {
    Composite pageComposite = new Composite(parent, SWT.NONE);
    GridLayout pageLayout = GridLayoutFactory.fillDefaults().spacing(0, 5).create();
    pageComposite.setLayout(pageLayout);
    pageComposite.setLayoutData(GridDataFactory.fillDefaults().create());

    stepIndicatorComposite = new StepIndicatorComposite(pageComposite, stepNames);
    stepIndicatorComposite.setSelection(getStepName());

    initializeDialogUnits(parent);

    PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComposite,
            IIDEHelpContextIds.NEW_PROJECT_WIZARD_PAGE);

    createProjectNameGroup(pageComposite);

    // create Location section
    createDestinationLocationArea(pageComposite);

    // Create the project template section (if required)
    createProjectTemplateSection(pageComposite);

    // create warning section
    createWarningArea(pageComposite);

    // Add the generate app section
    createGenerateGroup(pageComposite);

    // Scale the button based on the rest of the dialog
    setButtonLayoutData(browseButton);

    updateProjectName(getProjectNameFieldValue());

    setPageComplete(validatePage());
    // Show description on opening
    setErrorMessage(null);
    setMessage(null);
    setControl(pageComposite);
    Dialog.applyDialogFont(pageComposite);
}

From source file:com.aptana.scripting.keybindings.internal.KeybindingsManager.java

License:Open Source License

private void popup(final Shell shell, final IBindingService bindingService,
        final IContextService contextService, final ICommandElementsProvider commandElementsProvider,
        final List<CommandElement> commandElements, final Event event, final Binding binding,
        final Point initialLocation) {
    PopupDialog popupDialog = new PopupDialog(shell, PopupDialog.INFOPOPUP_SHELLSTYLE, true, false, false,
            false, false, null, null) {/*from  ww  w.  j ava2s  . c o  m*/

        @Override
        protected Point getInitialLocation(Point initialSize) {
            Display display = shell.getDisplay();
            Point cursorLocation = display.getCursorLocation();
            if (initialLocation != null) {
                // Warp the cursor ?
                // if (!cursorLocation.equals(initialLocation))
                // {
                // display.setCursorLocation(initialLocation);
                // }
                return initialLocation;
            }
            return cursorLocation;
        }

        protected Control createDialogArea(Composite parent) {

            registerShellType();

            // Create a composite for the dialog area.
            final Composite composite = new Composite(parent, SWT.NONE);
            final GridLayout compositeLayout = new GridLayout();
            compositeLayout.marginHeight = 1;
            compositeLayout.marginWidth = 1;
            composite.setLayout(compositeLayout);
            composite.setLayoutData(new GridData(GridData.FILL_BOTH));

            // Layout the table.
            final Table commandElementTable = new Table(composite,
                    SWT.FULL_SELECTION | SWT.SINGLE | SWT.NO_SCROLL);
            final GridData gridData = new GridData(GridData.FILL_BOTH);
            commandElementTable.setLayoutData(gridData);
            commandElementTable.setLinesVisible(true);

            // Initialize the columns and rows.
            final TableColumn columnCommandName = new TableColumn(commandElementTable, SWT.LEFT, 0);
            final TableColumn columnAccelerator = new TableColumn(commandElementTable, SWT.CENTER, 1);

            int mnemonic = 0;
            for (CommandElement commandElement : commandElements) {
                final String[] text = { commandElement.getDisplayName(),
                        (mnemonic < MNEMONICS.length() ? String.valueOf(MNEMONICS.charAt(mnemonic++)) : "") }; //$NON-NLS-1$
                final TableItem item = new TableItem(commandElementTable, SWT.NULL);
                item.setText(text);
                item.setData(CommandElement.class.getName(), commandElement);
            }

            if (binding != null) {
                ParameterizedCommand originalParameterizedCommand = binding.getParameterizedCommand();
                // Add original command
                if (originalParameterizedCommand != null) {
                    try {
                        String name = originalParameterizedCommand.getName();
                        final TableItem item = new TableItem(commandElementTable, SWT.NULL);
                        item.setText(new String[] { name,
                                (mnemonic < MNEMONICS.length() ? String.valueOf(MNEMONICS.charAt(mnemonic++))
                                        : "") }); //$NON-NLS-1$
                        item.setData(ParameterizedCommand.class.getName(), originalParameterizedCommand);
                    } catch (NotDefinedException nde) {
                        IdeLog.logError(ScriptingActivator.getDefault(), nde.getMessage(), nde);
                    }
                }
            }

            Dialog.applyDialogFont(parent);
            columnAccelerator.pack();
            columnCommandName.pack();
            columnAccelerator.setWidth(columnAccelerator.getWidth() * 4);

            /*
             * If the user double-clicks on the table row, it should execute the selected command.
             */
            commandElementTable.addListener(SWT.DefaultSelection, new Listener() {
                public final void handleEvent(final Event event) {
                    // Try to execute the corresponding command.
                    Object commandElement = null;
                    Object parameterizedCommand = null;
                    final TableItem[] selection = commandElementTable.getSelection();
                    if (selection.length > 0) {
                        commandElement = selection[0].getData(CommandElement.class.getName());
                        parameterizedCommand = selection[0].getData(ParameterizedCommand.class.getName());
                    }
                    close();
                    if (commandElement instanceof CommandElement) {
                        executeCommandElement(commandElementsProvider, (CommandElement) commandElement);
                    } else if (parameterizedCommand instanceof ParameterizedCommand) {
                        try {
                            executeCommand(binding, event);
                        } catch (CommandException e) {
                            IdeLog.logError(ScriptingActivator.getDefault(), e.getMessage(), e);
                        }
                    }
                }
            });

            commandElementTable.addKeyListener(new KeyListener() {
                public void keyReleased(KeyEvent e) {
                }

                public void keyPressed(KeyEvent e) {
                    if (!e.doit) {
                        return;
                    }
                    int index = MNEMONICS.indexOf(e.character);
                    if (index != -1) {
                        if (index < commandElementTable.getItemCount()) {
                            e.doit = false;
                            TableItem tableItem = commandElementTable.getItem(index);
                            Object commandElement = tableItem.getData(CommandElement.class.getName());
                            Object parameterizedCommand = tableItem
                                    .getData(ParameterizedCommand.class.getName());
                            close();
                            if (commandElement instanceof CommandElement) {
                                executeCommandElement(commandElementsProvider, (CommandElement) commandElement);
                            } else if (parameterizedCommand instanceof ParameterizedCommand) {
                                try {
                                    executeCommand(binding, event);
                                } catch (CommandException ex) {
                                    IdeLog.logError(ScriptingActivator.getDefault(), ex.getMessage(), ex);
                                }
                            }
                        }
                    }
                }
            });
            return composite;
        }

        protected Color getBackground() {
            return getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
        }

        @Override
        protected Control createContents(Composite parent) {
            return super.createContents(parent);
        }

        @Override
        public int open() {
            showingCommandsMenu = true;
            bindingService.setKeyFilterEnabled(false);
            return super.open();
        }

        @Override
        public boolean close() {
            boolean closed = super.close();
            if (closed) {
                showingCommandsMenu = false;
                bindingService.setKeyFilterEnabled(true);
            }
            return closed;
        }

        /**
         * Registers the shell as the same type as its parent with the context support. This ensures that it does
         * not modify the current state of the application.
         */
        private final void registerShellType() {
            final Shell shell = getShell();
            contextService.registerShell(shell, contextService.getShellType((Shell) shell.getParent()));
        }
    };

    popupDialog.open();
}

From source file:com.aptana.ui.dialogs.ProjectSelectionDialog.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
 *///www . j  a va2  s  .  com
protected Control createDialogArea(Composite parent) {
    // page group
    Composite composite = (Composite) super.createDialogArea(parent);

    Font font = parent.getFont();
    composite.setFont(font);

    createMessageArea(composite);

    fTableViewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            doSelectionChanged(((IStructuredSelection) event.getSelection()).toArray());
        }
    });
    fTableViewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            okPressed();
        }
    });
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
    data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
    fTableViewer.getTable().setLayoutData(data);

    fTableViewer.setLabelProvider(new WorkbenchLabelProvider());
    fTableViewer.setContentProvider(ArrayContentProvider.getInstance());

    fTableViewer.getControl().setFont(font);

    if (!CollectionsUtil.isEmpty(natureIDs)) {
        fTableViewer.addFilter(new ViewerFilter() {
            public boolean select(Viewer viewer, Object parentElement, Object element) {
                if (element instanceof IProject) {
                    IProject project = (IProject) element;
                    if (project.isAccessible()) {
                        try {
                            String[] allNatures = project.getDescription().getNatureIds();
                            for (String nature : allNatures) {
                                if (natureIDs.contains(nature)) {
                                    return true;
                                }
                            }
                        } catch (CoreException e) {
                            IdeLog.logError(UIEplPlugin.getDefault(), e);
                            return false;
                        }
                    }
                }
                return false;
            }
        });
    }

    Button checkbox = new Button(composite, SWT.CHECK);
    checkbox.setText(EplMessages.ProjectSelectionDialog_filter);
    checkbox.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
    checkbox.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            updateFilter(((Button) e.widget).getSelection());
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            updateFilter(((Button) e.widget).getSelection());
        }
    });
    IDialogSettings dialogSettings = UIEplPlugin.getDefault().getDialogSettings();
    boolean doFilter = !dialogSettings.getBoolean(DIALOG_SETTINGS_SHOW_ALL)
            && !fProjectsWithSpecifics.isEmpty();
    checkbox.setSelection(doFilter);
    updateFilter(doFilter);

    IProject[] input = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    fTableViewer.setInput(input);
    doSelectionChanged(new Object[0]);
    Dialog.applyDialogFont(composite);
    return composite;
}

From source file:com.aptana.ui.preferences.PropertyAndPreferenceFieldEditorPage.java

License:Open Source License

protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;//from w  w w  . j  a  v a2 s . c  o  m
    layout.marginWidth = 0;
    composite.setLayout(layout);
    composite.setFont(parent.getFont());

    GridData data = new GridData(GridData.FILL, GridData.FILL, true, true);

    fConfigurationBlockControl = super.createContents(composite);
    fConfigurationBlockControl.setLayoutData(data);

    if (isProjectPreferencePage()) {
        boolean useProjectSettings = hasProjectSpecificOptions(getProject());
        enableProjectSpecificSettings(useProjectSettings);
    }

    Dialog.applyDialogFont(composite);
    return composite;
}

From source file:com.aptana.ui.QuickMenuDialog.java

License:Open Source License

/**
 * Creates a dialog area with a table of the partial matches for the current key binding state. The table will be
 * either the minimum width, or <code>previousWidth</code> if it is not <code>NO_REMEMBERED_WIDTH</code>.
 * /*from  w  ww . j  a  v a2s.c  o m*/
 * @param parent
 *            The parent composite for the dialog area; must not be <code>null</code>.
 * @param partialMatches
 *            The lexicographically sorted map of partial matches for the current state; must not be
 *            <code>null</code> or empty.
 */
private final void createTableDialogArea(final Composite parent, final List<MenuDialogItem> partialMatches) {
    // Layout the table.
    fTable = new Table(parent, SWT.FULL_SELECTION | SWT.SINGLE);
    final GridData gridData = new GridData(GridData.FILL_BOTH);
    fTable.setLayoutData(gridData);
    fTable.setBackground(parent.getBackground());
    fTable.setLinesVisible(false);

    List<TableColumn> columns = new ArrayList<TableColumn>();

    // Initialize the columns and rows.
    int mnemonic = 0;
    int index = -1;

    // image, display, insert, tool_tip
    columns.add(new TableColumn(fTable, SWT.LEFT, 0));
    columns.add(new TableColumn(fTable, SWT.LEFT, 1));
    columns.add(new TableColumn(fTable, SWT.CENTER, 2));

    for (MenuDialogItem item : partialMatches) {
        index++;
        if (item.isSeparator()) {
            insertSeparator(3);
            continue;
        }
        final TableItem tableItem = new TableItem(fTable, SWT.NULL);
        Image image = item.getImage();
        if (image != null) {
            tableItem.setImage(0, image);
        }

        tableItem.setText(1, item.getText());
        tableItem.setData(MNEMONIC, mnemonic); // FIXME This is really off by one, but we expect it to be later.
        // Funky code from Sandip. Just use real value maybe?
        tableItem.setText(2, (mnemonic < MNEMONICS.length()) ? String.valueOf(MNEMONICS.charAt(mnemonic++))
                : StringUtil.EMPTY);
        tableItem.setData(INDEX, index);
    }

    Dialog.applyDialogFont(parent);
    for (TableColumn tableColumn : columns) {
        tableColumn.pack();
    }
    // FIXME Need to limit vertical size of list! If we have 100 items we shouldn't let this dialog grow to take up
    // entire vertical space of screen/IDE!

    /*
     * If you double-click on the table, it should execute the selected command.
     */
    fTable.addListener(SWT.DefaultSelection, new Listener() {
        public final void handleEvent(final Event event) {
            select();
        }
    });

    fTable.addKeyListener(new KeyListener() {
        public void keyReleased(KeyEvent e) {
        }

        public void keyPressed(KeyEvent e) {
            if (!e.doit) {
                return;
            }
            int index = MNEMONICS.indexOf(e.character);
            if (index != -1) {
                if (index < fTable.getItemCount()) {
                    e.doit = false;
                    // I need to return the index of the item as it was in partialMatches!
                    int returnCode = index;
                    for (TableItem item : fTable.getItems()) {
                        Object data = item.getData(MNEMONIC);
                        if (data instanceof Integer) {
                            Integer value = (Integer) data;
                            if (value == index) // does mnemonic match?
                            {
                                // OK We found the table item that was assigned this mnemonic, now we need to find
                                // it's index in partialMatches!
                                returnCode = (Integer) item.getData(INDEX);
                                break;
                            }
                        }
                    }
                    setReturnCode(returnCode);
                    close();
                }
            }
        }
    });

    // Don't ever draw separators as selected!
    fTable.addListener(SWT.EraseItem, new Listener() {

        public void handleEvent(Event event) {
            if ((event.detail & SWT.SELECTED) != 0) {
                TableItem item = (TableItem) event.item;
                if (isSeparator(item)) {
                    event.detail &= ~SWT.SELECTED;
                    event.detail &= ~SWT.BACKGROUND;
                }
            }
        }
    });

    fTable.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent e) {
            int selectionIndex = fTable.getSelectionIndex();
            final int initialIndex = selectionIndex;
            if (e.detail == SWT.TRAVERSE_ARROW_NEXT) {
                selectionIndex++;
                while (isSeparator(fTable.getItem(selectionIndex))) {
                    selectionIndex++;
                    if (selectionIndex >= fTable.getItemCount())
                        return;
                }
                selectionIndex--;
            } else if (e.detail == SWT.TRAVERSE_ARROW_PREVIOUS) {
                selectionIndex--;
                while (isSeparator(fTable.getItem(selectionIndex))) {
                    selectionIndex--;
                    if (selectionIndex < 0) {
                        // HACK have to run this in a job for some reason. Just setting selection index doesn't
                        // work.
                        new UIJob("retaining selection") //$NON-NLS-1$
                        {

                            @Override
                            public IStatus runInUIThread(IProgressMonitor monitor) {
                                fTable.setSelection(initialIndex);
                                return Status.OK_STATUS;
                            }
                        }.schedule();
                        e.doit = false;
                        return;
                    }
                }
                selectionIndex++;
            } else {
                return;
            }

            if (selectionIndex < fTable.getItemCount() && selectionIndex >= 0) {
                fTable.setSelection(selectionIndex);
                e.doit = false;
            }
        }
    });
}

From source file:com.aptana.ui.wizards.WizardFolderImportPage.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
 *///from  w  w w  . j av  a2s. co  m
public void createControl(Composite parent) {
    // Collect the existing project names to avoid conflicts.
    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    projectsNames = new HashSet<String>();
    for (IProject project : projects) {
        projectsNames.add(project.getName());
    }
    modifyListener = new InputModifyListener();
    initializeDialogUnits(parent);

    Composite workArea = new Composite(parent, SWT.NONE);
    setControl(workArea);

    workArea.setLayout(new GridLayout());
    workArea.setLayoutData(
            new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));

    createProjectsRoot(workArea);

    Dialog.applyDialogFont(workArea);
    fLabelProvider = new NaturesLabelProvider(fNatureDescriptions);

    Label l = new Label(workArea, SWT.NONE);
    l.setText(EplMessages.WizardFolderImportPage_project_type_title);

    natureContributors = PrimaryNaturesManager.getManager().getContributorsMap();

    Composite tableComposite = new Composite(workArea, SWT.NONE);
    tableComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
    tableComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    // Table for project natures
    fTableViewer = CheckboxTableViewer.newCheckList(tableComposite, SWT.TOP | SWT.BORDER);
    Table table = fTableViewer.getTable();
    table.setLinesVisible(true);
    table.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    TableColumn column = new TableColumn(table, SWT.LEFT);
    column.setWidth(350);

    fTableViewer.setContentProvider(getContentProvider());
    fTableViewer.setLabelProvider(getLabelProvider());
    fTableViewer.setComparator(getViewerComperator());
    fTableViewer.setInput(ResourcesPlugin.getWorkspace());
    fTableViewer.addCheckStateListener(this);
    fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            updateButtons();
        }
    });
    table.setMenu(createMenu(table));

    // Add the buttons
    Composite buttons = new Composite(tableComposite, SWT.NONE);
    buttons.setLayout(GridLayoutFactory.fillDefaults().create());
    buttons.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create());
    fMakePrimaryButton = createButton(EplMessages.WizardFolderImportPage_make_primary_label, buttons);
    updateButtons();

    setPageComplete(validate());
    setPrimaryNatureFromContributions(null);
    fTableViewer.setCheckedElements(new String[] { fPrimaryNature });

    if (directoryPath != null) {
        directoryPathField.setText(directoryPath);
        setProjectName();
        setPageComplete(true);
    }
}

From source file:com.aptana.ui.wizards.WizardNewProjectCreationPage.java

License:Open Source License

/** (non-Javadoc)
  * Method declared on IDialogPage.//from   w  w w  .  java 2  s. c  o  m
  */
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);

    initializeDialogUnits(parent);

    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IIDEHelpContextIds.NEW_PROJECT_WIZARD_PAGE);

    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    createProjectNameGroup(composite);
    locationArea = new ProjectContentsLocationArea(getErrorReporter(), composite);
    if (initialProjectFieldValue != null) {
        locationArea.updateProjectName(initialProjectFieldValue);
    }

    // Scale the button based on the rest of the dialog
    setButtonLayoutData(locationArea.getBrowseButton());

    setPageComplete(validatePage());
    // Show description on opening
    setErrorMessage(null);
    setMessage(null);
    setControl(composite);
    Dialog.applyDialogFont(composite);
}

From source file:com.arc.intro.NewWorkspaceDialog.java

License:Open Source License

/**
 * Creates and returns the contents of the upper part of this dialog (above the button bar).
 * <p>/* w  ww.j ava2s.co m*/
 * The <code>Dialog</code> implementation of this framework method creates and returns a new
 * <code>Composite</code> with no margins and spacing.
 * </p>
 * @param parent the parent composite to contain the dialog area
 * @return the dialog area control
 */
@Override
protected Control createDialogArea(Composite parent) {
    String productName = ToolchainPlugin.getTheProductName();
    if (productName == null) {
        productName = "MetaWare IDE";
    }

    Composite composite = (Composite) super.createDialogArea(parent);
    setTitle("Workspace Launcher");
    setMessage(ToolchainPlugin.getTheProductName() + " stores your projects in a folder called a workspace.\n"
            + "Choose a workspace folder to use for this session.\n");

    // bug 59934: load title image for sizing, but set it non-visible so the
    // white background is displayed
    if (getTitleImageLabel() != null)
        getTitleImageLabel().setVisible(false);

    createWorkspaceBrowseRow(composite);
    createExtraTextInfoMsgPanel(composite);

    Dialog.applyDialogFont(composite);
    return composite;
}

From source file:com.arcbees.gwtp.plugin.core.common.GWTPNewTypeWizardPage.java

License:Apache License

@Override
public void createControl(Composite parent) {
    initializeDialogUnits(parent);/*from  w w w  .  jav a  2 s  .  c om*/
    Composite container = new Composite(parent, SWT.NONE);
    container.setFont(parent.getFont());

    GridLayout layout = new GridLayout();
    layout.numColumns = getNumberOfColumns();
    container.setLayout(layout);

    createTypeNameControls(container, getNumberOfColumns());
    createPackageControls(container, getNumberOfColumns());

    extendControl(container);

    setControl(container);

    Dialog.applyDialogFont(container);
}

From source file:com.asakusafw.shafu.internal.ui.wizards.ProjectInformationPage.java

License:Apache License

@Override
public void createControl(Composite parent) {
    super.createControl(parent);
    Composite pane = (Composite) getControl();

    createWorkingSetGroup(pane, selection, WORKING_SETS);

    Dialog.applyDialogFont(pane);
}