Example usage for org.eclipse.jface.preference IPreferenceStore setValue

List of usage examples for org.eclipse.jface.preference IPreferenceStore setValue

Introduction

In this page you can find the example usage for org.eclipse.jface.preference IPreferenceStore setValue.

Prototype

void setValue(String name, boolean value);

Source Link

Document

Sets the current value of the boolean-valued preference with the given name.

Usage

From source file:com.nokia.sdt.sourcegen.SourceGenUtils.java

License:Open Source License

public static void setSourceFileHeaderTemplate(String path) {
    IPreferenceStore preferenceStore = getPreferenceStore();
    if (preferenceStore == null)
        return;//  www.j ava  2s. c  o  m
    preferenceStore.setValue(PreferenceConstants.P_FILE_HEADER_TEMPLATE_LOCATION, path == null ? "" : path); //$NON-NLS-1$
}

From source file:com.nokia.tools.s60.editor.actions.CopyImageAction.java

License:Open Source License

@Override
public void doRun(Object sel) {

    if (clip == null)
        clip = Toolkit.getDefaultToolkit().getSystemClipboard();

    IContentData data = getContentData(sel);
    ISkinnableEntityAdapter skAdapter = (ISkinnableEntityAdapter) data
            .getAdapter(ISkinnableEntityAdapter.class);

    if (sel instanceof IAnimationFrame) {
        if (isMaskNode()) {
            IAnimationFrame frame = (IAnimationFrame) sel;
            if (frame.getMaskFile() != null) {
                ClipboardHelper.copyImageToClipboard(clip, frame.getMaskFile());
            } else {
                ClipboardHelper.copyImageToClipboard(clip, frame.getMask());
            }/*  ww w .  j  a v  a 2  s.c  o  m*/
        } else if (isImageNode()) {
            IAnimationFrame frame = (IAnimationFrame) sel;
            if (frame.getImageFile() != null) {
                ClipboardHelper.copyImageToClipboard(clip, frame.getImageFile());
            } else {
                ClipboardHelper.copyImageToClipboard(clip, frame.getRAWImage(false));
            }
        } else {
            ((IAnimationFrame) sel).copyImageToClipboard(clip);
        }
        return;
    }

    // when layer is selected in tree
    if (sel instanceof ILayer) {

        try {
            ILayer l = (ILayer) sel;
            if (isLayerNode() || isNodeOfType(AbstractAction.TYPE_PART)) {

                if (skAdapter instanceof S60SkinnableEntityAdapter) {
                    // copy image + mask
                    l.copyImageToClipboard(clip);
                }
            } else if (isImageNode()) {
                // copy image only
                Object param = l.getFileName(false) == null ? l.getRAWImage() : l.getFileName(true);
                ClipboardHelper.copyImageToClipboard(clip, param);
            } else if (isMaskNode()) {
                // copy mask only
                if (l.getMaskFileName(true) != null) {
                    ClipboardHelper.copyImageToClipboard(clip, l.getMaskFileName(true));
                } else {
                    ClipboardHelper.copyImageToClipboard(clip, l.getMaskImage());
                }
            } else {
                l.copyImageToClipboard(clip);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return;
    }

    IImageHolder holder = getImageHolder(sel);
    if (holder != null) {
        holder.copyImageToClipboard(clip);
        return;
    }

    // IContentData data = getContentData(sel);

    if (data != null) {

        ISkinnableContentDataAdapter skinableAdapter = (ISkinnableContentDataAdapter) data
                .getAdapter(ISkinnableContentDataAdapter.class);
        if (skinableAdapter != null) {
            skinableAdapter.copyToClipboard(null);
            return;
        }

        /*
         * ISkinnableEntityAdapter skAdapter = (ISkinnableEntityAdapter)
         * data .getAdapter(ISkinnableEntityAdapter.class);
         */
        if (skAdapter != null) {

            if (skAdapter.hasMask()) {

            }

            if (skAdapter instanceof S60SkinnableEntityAdapter)
                skAdapter.copyImageToClipboard(clip);

            else {
                copyIdAndFileToClipboard(data, skAdapter);
            }
            // if (skAdapter.isNinePiece()) {
            if (skAdapter.isMultiPiece()) {
                // copy from 9-piece was performed, show info dialog
                IPreferenceStore store = S60WorkspacePlugin.getDefault().getPreferenceStore();
                Boolean showState = store.getBoolean(skAdapter.getCopyPieceInfo());
                // .getBoolean(IMediaConstants.NINE_PIECE_COPY_INFO);
                if (showState || silent)
                    return;

                IBrandingManager branding = BrandingExtensionManager.getBrandingManager();
                Image image = null;
                if (branding != null) {
                    image = branding.getIconImageDescriptor().createImage();
                }
                MessageDialog messageDialog = new MessageDialogWithCheckBox(
                        PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                        Messages.CopyAction_9piece_title, image, MultiPieceManager.getCopyMessageText(),
                        // MultipieceHelper.getCopyMessageText(),
                        Messages.CopyAction_9piece_checkbox, false, null, null, null, 2,
                        new String[] { IDialogConstants.OK_LABEL }, 0);
                messageDialog.open();
                if (image != null) {
                    image.dispose();
                }

                // store.setValue(IMediaConstants.NINE_PIECE_COPY_INFO,
                store.setValue(skAdapter.getCopyPieceInfo(),
                        ((MessageDialogWithCheckBox) messageDialog).getCheckBoxValue());
            }
        }
        return;
    }

    ILayer layer = getLayer(true, sel);
    if (layer != null) {
        layer.copyImageToClipboard(clip);
    }
}

From source file:com.nokia.tools.s60.editor.actions.ElevenPieceConvertAction.java

License:Open Source License

@Override
protected void doRun(Object element) {
    IContentData data = getContentData(element);
    if (data == null) {
        return;/*  ww  w  . ja v a  2 s  .  c o  m*/
    }
    if (type == TYPE_CONVERT2SINGLE) {

        IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
        boolean ask = !iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE_ASK);

        boolean replaceGfx = iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE);

        if (ask) {
            int result = IDialogConstants.YES_ID;

            ISkinnableEntityAdapter ska = (ISkinnableEntityAdapter) data
                    .getAdapter(ISkinnableEntityAdapter.class);
            boolean isElementSkinned = ska.isSkinned();

            if (isElementSkinned) {
                ElevenPieceOperationConfirmDialog dialog = new ElevenPieceOperationConfirmDialog(
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        ElevenPieceOperationConfirmDialog.TYPE_2SINGLE);
                result = dialog.open();

                if (result == IDialogConstants.OK_ID)
                    replaceGfx = true;
                else
                    return; // cancel pressed
            } else {
                replaceGfx = false;
            }

            /*if (result == IDialogConstants.YES_ID)
               replaceGfx = true;
            else if (result == IDialogConstants.NO_ID)
                  replaceGfx = false;*/

        }

        if (ask && iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE_ASK)) {
            // user selects to remeber settings this time - store
            // selected option
            iPreferenceStore.setValue(IMediaConstants.PREF_NINE_PIECE_2SINGLE, replaceGfx);
        }

        EditPart ep = getEditPart(element);
        // special way of update / undo / redo
        Convert2SingleBitmapCommand cmd = new Convert2SingleBitmapCommand(getContentData(element), ep,
                replaceGfx);
        execute(cmd, ep);
    } else {
        if (type == TYPE_ELEVEN_PIECE) {

            IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
            boolean ask = !iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE_ASK);

            boolean fillParts = iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE);

            if (ask) {
                ElevenPieceOperationConfirmDialog dialog = new ElevenPieceOperationConfirmDialog(
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        ElevenPieceOperationConfirmDialog.TYPE_2ELEVEN);
                int result = dialog.open();
                /*if (result == IDialogConstants.YES_ID)
                   fillParts = true;
                else if (result == IDialogConstants.NO_ID)
                   fillParts = false;*/
                if (result == IDialogConstants.OK_ID)
                    fillParts = true;
                else
                    return; // cancel pressed
            }

            if (ask && iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE_ASK)) {
                // user selects to remeber settings this time - store
                // selected option
                iPreferenceStore.setValue(IMediaConstants.PREF_SINGLE_PIECE_2NINE, fillParts);
            }

            EditPart ep = getEditPart(element);
            // special way of update / undo / redo
            Convert2ElevenBitmapCommand cmd = new Convert2ElevenBitmapCommand(data, ep, fillParts);
            execute(cmd, ep);
        }
    }
}

From source file:com.nokia.tools.s60.editor.actions.NinePieceConvertAction.java

License:Open Source License

@Override
protected void doRun(Object element) {
    IContentData data = getContentData(element);
    if (data == null) {
        return;//from   w w w  .  j av a  2 s.  c  om
    }

    if (type == TYPE_CONVERT2SINGLE) {

        IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
        boolean ask = !iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE_ASK);

        boolean replaceGfx = iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE);

        ISkinnableEntityAdapter ska = (ISkinnableEntityAdapter) data.getAdapter(ISkinnableEntityAdapter.class);
        boolean isElementSkinned = false;
        if (ask) {
            int result = IDialogConstants.OK_ID;

            isElementSkinned = ska.isSkinned();

            if (isElementSkinned) {
                NinePieceOperationConfirmDialog dialog = new NinePieceOperationConfirmDialog(
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        NinePieceOperationConfirmDialog.TYPE_2SINGLE);
                result = dialog.open();

                if (result == IDialogConstants.OK_ID)
                    replaceGfx = true;
                else
                    return; // cancel pressed

            } else {
                replaceGfx = false;
            }

        }

        if (ask && iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE_ASK)) {
            // user selects to remeber settings this time - store
            // selected option
            iPreferenceStore.setValue(IMediaConstants.PREF_NINE_PIECE_2SINGLE, replaceGfx);
        }

        EditPart ep = getEditPart(element);
        if (isElementSkinned && !replaceGfx)
            ska.clearThemeGraphics();
        // special way of update / undo / redo
        Convert2SingleBitmapCommand cmd = new Convert2SingleBitmapCommand(getContentData(element), ep,
                replaceGfx);
        execute(cmd, ep);
    } else {
        if (type == TYPE_CONVERT2NINE) {

            IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
            boolean ask = !iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE_ASK);

            boolean fillParts = iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE);

            if (ask) {
                NinePieceOperationConfirmDialog dialog = new NinePieceOperationConfirmDialog(
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        NinePieceOperationConfirmDialog.TYPE_2NINE);
                int result = dialog.open();
                if (result == IDialogConstants.OK_ID)
                    fillParts = true;
                else
                    return; // cancel pressed
            }

            if (ask && iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE_ASK)) {
                // user selects to remeber settings this time - store
                // selected option
                iPreferenceStore.setValue(IMediaConstants.PREF_SINGLE_PIECE_2NINE, fillParts);
            }

            EditPart ep = getEditPart(element);
            // special way of update / undo / redo
            Convert2NineBitmapCommand cmd = new Convert2NineBitmapCommand(data, ep, fillParts);
            execute(cmd, ep);
        }
    }
}

From source file:com.nokia.tools.s60.editor.actions.ThreePieceConvertAction.java

License:Open Source License

@Override
protected void doRun(Object element) {
    IContentData data = getContentData(element);
    if (data == null) {
        return;/*from www .  j  av  a  2 s . c  o  m*/
    }
    if (type == TYPE_CONVERT2SINGLE) {

        IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
        boolean ask = !iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE_ASK);

        boolean replaceGfx = iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE);

        if (ask) {
            int result = IDialogConstants.YES_ID;

            ISkinnableEntityAdapter ska = (ISkinnableEntityAdapter) data
                    .getAdapter(ISkinnableEntityAdapter.class);
            boolean isElementSkinned = ska.isSkinned();

            if (isElementSkinned) {
                ThreePieceOperationConfirmDialog dialog = new ThreePieceOperationConfirmDialog(
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        ThreePieceOperationConfirmDialog.TYPE_2SINGLE);
                result = dialog.open();
            }
            if (result == IDialogConstants.OK_ID)
                replaceGfx = true;
            else
                return; // cancel pressed
        }

        if (ask && iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE_ASK)) {
            // user selects to remeber settings this time - store
            // selected option
            iPreferenceStore.setValue(IMediaConstants.PREF_NINE_PIECE_2SINGLE, replaceGfx);
        }

        EditPart ep = getEditPart(element);
        // special way of update / undo / redo
        Convert2SingleBitmapCommand cmd = new Convert2SingleBitmapCommand(getContentData(element), ep,
                replaceGfx);
        execute(cmd, ep);
    } else {
        if (type == TYPE_CONVERT2THREE) {

            IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
            boolean ask = !iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE_ASK);

            boolean fillParts = iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE);

            if (ask) {
                ThreePieceOperationConfirmDialog dialog = new ThreePieceOperationConfirmDialog(
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        ElevenPieceOperationConfirmDialog.TYPE_2ELEVEN);
                int result = dialog.open();
                if (result == IDialogConstants.OK_ID)
                    fillParts = true;
                else
                    return; // cancel pressed
            }

            if (ask && iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE_ASK)) {
                // user selects to remeber settings this time - store
                // selected option
                iPreferenceStore.setValue(IMediaConstants.PREF_SINGLE_PIECE_2NINE, fillParts);
            }

            EditPart ep = getEditPart(element);
            // special way of update / undo / redo
            Convert2ThreeBitmapCommand cmd = new Convert2ThreeBitmapCommand(data, ep, fillParts);
            execute(cmd, ep);
        }
    }
}

From source file:com.nokia.tools.s60.editor.menus.EditorActionBarContributor.java

License:Open Source License

public void zoomChanged(double zoom) {
    IPreferenceStore store = UiPlugin.getDefault().getPreferenceStore();
    store.setValue(IScreenConstants.PREF_ZOOMING_FACTOR, zoom);
}

From source file:com.nokia.tools.s60.editor.ScreenModelMediator.java

License:Open Source License

/**
 * Updates the preferences when user adds/removes gallery screens.
 * /*  w w  w .java2 s  . c om*/
 * @param newScreen the new screen to be added. 
 */
protected void updateGalleryPreferences(IGalleryScreen screenEffected, boolean isDelete) {
    if (!isGalleryPersistable()) {
        return;
    }

    IPreferenceStore store = S60WorkspacePlugin.getDefault().getPreferenceStore();
    String prefName = IS60IDEConstants.PREF_GALLERY_SCREENS + "."
            + screenEffected.getData().getRoot().getType();
    String screens = store.getString(prefName);
    StringBuffer sb = new StringBuffer();
    if (screens != null) {
        String[] strs = screens.split(",");
        for (String str : strs) {
            if (isDelete && screenEffected != null && str.equals(screenEffected.getName())) {
                continue;
            }
            sb.append(str + ",");
        }
    }
    if (!isDelete && screenEffected != null) {
        sb.append(screenEffected.getName() + ",");
    }
    if (sb.length() > 0) {
        // removes the trailing ","
        sb.deleteCharAt(sb.length() - 1);
    }
    synchronized (this) {
        suppressPreferenceChangeEvents = true;
        try {
            store.setValue(prefName, sb.toString());
            if (store.needsSaving() && store instanceof IPersistentPreferenceStore) {
                try {
                    ((IPersistentPreferenceStore) store).save();
                } catch (IOException e) {
                    S60WorkspacePlugin.error(e);
                }
            }
        } finally {
            suppressPreferenceChangeEvents = false;
        }
    }
}

From source file:com.nokia.tools.s60.editor.ui.dialogs.ElevenPieceOperationConfirmDialog.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.Dialog#
 *      createDialogArea(org.eclipse.swt.widgets.Composite) Here we fill the
 *      center area of the dialog/*from   w w w .jav a  2 s. co m*/
 */
protected Control createDialogArea(Composite parent) {
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent.getParent(), NinePieceConvertAction.HLP_CTX);

    Composite area = (Composite) super.createDialogArea(parent);

    // Create new composite as container
    final Composite composite = new Composite(area, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.marginHeight = 13;
    layout.marginWidth = 13;
    layout.verticalSpacing = 7;
    composite.setLayout(layout);

    Composite container = new Composite(composite, SWT.NONE);
    layout = new GridLayout();
    container.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 100;
    container.setLayoutData(gd);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 7;

    setTitle(type == TYPE_2ELEVEN ? Messages.ElevenPieceOperationConfirm_banner_title_11
            : Messages.NinePieceOperationConfirm_banner_title_1);
    setMessage(type == TYPE_2ELEVEN ? Messages.ElevenPieceOperationConfirm_text2_11
            : Messages.ElevenPieceOperationConfirm_text2_1);

    Label ft = new Label(container, SWT.WRAP);
    ft.setText(type == TYPE_2ELEVEN ? Messages.ElevenPieceOperationConfirm_banner_message_11
            : Messages.NinePieceOperationConfirm_banner_message_1);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 350;
    ft.setLayoutData(gd);

    // preserve mask check
    final Button checkbox = new Button(composite, SWT.CHECK);
    checkbox.setText(Messages.NinePieceOperationConfirm_checkLabel);
    checkbox.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            boolean state = checkbox.getSelection();

            IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
            iPreferenceStore.setValue(getPrefKey(), state);
        }

        public void widgetDefaultSelected(SelectionEvent e) {

        }
    });
    checkbox.setToolTipText(Messages.NinePieceOperationConfirm_checkLabelTooltip);

    IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
    checkbox.setSelection(iPreferenceStore.getBoolean(getPrefKey()));

    Composite container2 = new Composite(area, SWT.NONE);
    container2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout = new GridLayout();
    container2.setLayout(layout);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;

    final Label separator = new Label(container2, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    return area;
}

From source file:com.nokia.tools.s60.editor.ui.dialogs.NinePieceOperationConfirmDialog.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.Dialog#
 *      createDialogArea(org.eclipse.swt.widgets.Composite) Here we fill the
 *      center area of the dialog//from w  w w. ja va 2 s  .c  o m
 */
protected Control createDialogArea(Composite parent) {
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent.getParent(), NinePieceConvertAction.HLP_CTX);

    Composite area = (Composite) super.createDialogArea(parent);

    // Create new composite as container
    final Composite composite = new Composite(area, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.marginHeight = 13;
    layout.marginWidth = 13;
    layout.verticalSpacing = 7;
    composite.setLayout(layout);

    Composite container = new Composite(composite, SWT.NONE);
    layout = new GridLayout();
    container.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 100;
    container.setLayoutData(gd);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 7;

    setTitle(type == TYPE_2NINE ? Messages.NinePieceOperationConfirm_banner_title_9
            : Messages.NinePieceOperationConfirm_banner_title_1);
    setMessage(type == TYPE_2NINE ? Messages.NinePieceOperationConfirm_text2_9
            : Messages.NinePieceOperationConfirm_text2_1);

    Label ft = new Label(container, SWT.WRAP);
    ft.setText(type == TYPE_2NINE ? Messages.NinePieceOperationConfirm_banner_message_9
            : Messages.NinePieceOperationConfirm_banner_message_1);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 350;
    ft.setLayoutData(gd);

    // preserve mask check
    final Button checkbox = new Button(composite, SWT.CHECK);
    checkbox.setText(Messages.NinePieceOperationConfirm_checkLabel);
    checkbox.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            boolean state = checkbox.getSelection();

            IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
            iPreferenceStore.setValue(getPrefKey(), state);
        }

        public void widgetDefaultSelected(SelectionEvent e) {

        }
    });
    checkbox.setToolTipText(Messages.NinePieceOperationConfirm_checkLabelTooltip);

    IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
    checkbox.setSelection(iPreferenceStore.getBoolean(getPrefKey()));

    Composite container2 = new Composite(area, SWT.NONE);
    container2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout = new GridLayout();
    container2.setLayout(layout);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;

    final Label separator = new Label(container2, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    return area;
}

From source file:com.nokia.tools.s60.editor.ui.dialogs.ThreePieceOperationConfirmDialog.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.Dialog#
 *      createDialogArea(org.eclipse.swt.widgets.Composite) Here we fill the
 *      center area of the dialog//w  ww  .j  av a 2s  .  c  om
 */
protected Control createDialogArea(Composite parent) {
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent.getParent(), NinePieceConvertAction.HLP_CTX);

    Composite area = (Composite) super.createDialogArea(parent);

    // Create new composite as container
    final Composite composite = new Composite(area, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.marginHeight = 13;
    layout.marginWidth = 13;
    layout.verticalSpacing = 7;
    composite.setLayout(layout);

    Composite container = new Composite(composite, SWT.NONE);
    layout = new GridLayout();
    container.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 100;
    container.setLayoutData(gd);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 7;

    setTitle(type == TYPE_2THREE ? Messages.ThreePieceOperationConfirm_banner_title_3
            : Messages.NinePieceOperationConfirm_banner_title_1);
    setMessage(type == TYPE_2THREE ? Messages.ThreePieceOperationConfirm_text2_3
            : Messages.ThreePieceOperationConfirm_text2_1);

    Label ft = new Label(container, SWT.WRAP);
    ft.setText(type == TYPE_2THREE ? Messages.ThreePieceOperationConfirm_banner_message_3
            : Messages.NinePieceOperationConfirm_banner_message_1);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 350;
    ft.setLayoutData(gd);

    // preserve mask check
    final Button checkbox = new Button(composite, SWT.CHECK);
    checkbox.setText(Messages.NinePieceOperationConfirm_checkLabel);
    checkbox.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            boolean state = checkbox.getSelection();

            IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
            iPreferenceStore.setValue(getPrefKey(), state);
        }

        public void widgetDefaultSelected(SelectionEvent e) {

        }
    });
    checkbox.setToolTipText(Messages.NinePieceOperationConfirm_checkLabelTooltip);

    IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
    checkbox.setSelection(iPreferenceStore.getBoolean(getPrefKey()));

    Composite container2 = new Composite(area, SWT.NONE);
    container2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout = new GridLayout();
    container2.setLayout(layout);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;

    final Label separator = new Label(container2, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    return area;
}