Search in sources :

Example 56 with IPropertyChangeListener

use of org.eclipse.jface.util.IPropertyChangeListener in project tdi-studio-se by Talend.

the class ProcessComposite method initGraphicComponents.

/**
     * DOC amaumont Comment method "initGraphicComponents".
     * 
     * @param parent
     */
private void initGraphicComponents(Composite parent) {
    setExpandHorizontal(true);
    setExpandVertical(true);
    this.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
    FormData layouData = new FormData();
    layouData.left = new FormAttachment(0, 0);
    layouData.right = new FormAttachment(100, 0);
    layouData.top = new FormAttachment(0, 0);
    layouData.bottom = new FormAttachment(100, 0);
    setLayoutData(layouData);
    this.setLayout(new FormLayout());
    final Composite panel = new Composite(this, SWT.NONE);
    setContent(panel);
    // panel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_RED));
    FormLayout layout2 = new FormLayout();
    layout2.marginWidth = 5 + 2;
    layout2.marginHeight = 4;
    layout2.spacing = 6 + 1;
    panel.setLayout(layout2);
    GridData data;
    GridLayout layout = new GridLayout();
    // panel.setLayout(layout);
    // Splitter
    // sash = new SashForm(this, SWT.HORIZONTAL | SWT.SMOOTH);
    // sash.setLayoutData(new GridData(GridData.FILL_BOTH));
    //
    // layout = new GridLayout();
    // sash.setLayout(layout);
    //
    // // group Button
    // // qli,see the feature 6366.
    //
    // Composite buttonComposite = new Composite(sash, SWT.ERROR);
    // buttonComposite.setLayout(new GridLayout());
    //
    // moveButton = new Button(buttonComposite, SWT.PUSH);
    //        moveButton.setText("<<"); //$NON-NLS-1$
    //        moveButton.setToolTipText(Messages.getString("ProcessComposite.hideContext")); //$NON-NLS-1$
    //
    // final GridData layoutData = new GridData();
    // layoutData.verticalAlignment = GridData.CENTER;
    // layoutData.horizontalAlignment = GridData.CENTER;
    // layoutData.grabExcessHorizontalSpace = true;
    // layoutData.grabExcessVerticalSpace = true;
    // moveButton.setLayoutData(layoutData);
    // Group execution
    Group execGroup = new Group(panel, SWT.NONE);
    //$NON-NLS-1$
    execGroup.setText(Messages.getString("ProcessComposite.execGroup"));
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    execGroup.setLayout(layout);
    FormData layouDatag = new FormData();
    layouDatag.left = new FormAttachment(0, 0);
    layouDatag.right = new FormAttachment(100, 0);
    layouDatag.top = new FormAttachment(0, 0);
    layouDatag.bottom = new FormAttachment(100, 0);
    execGroup.setLayoutData(layouDatag);
    // leftTabFolder = new CTabFolder(this, SWT.BORDER);
    // leftTabFolder.setSimple(false);
    // //
    // leftTabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    // //
    // // // Group context
    // //
    // CTabItem contextTabItem = new CTabItem(leftTabFolder, SWT.BORDER);
    //        contextTabItem.setText(Messages.getString("ProcessComposite.contextTab")); //$NON-NLS-1$
    // // contextComposite = new ProcessContextComposite(this, SWT.NONE);
    // // contextComposite.setBackground(leftTabFolder.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    // // contextTabItem.setControl(contextComposite);
    // //
    // Composite targetExecutionComposite = createTargetExecutionComposite(leftTabFolder);
    // targetExecutionComposite.setBackground(leftTabFolder.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    // //
    // targetExecutionTabItem = new CTabItem(leftTabFolder, SWT.BORDER);
    //        targetExecutionTabItem.setText(Messages.getString("ProcessComposite.targetExecutionTab")); //$NON-NLS-1$
    // targetExecutionTabItem.setToolTipText(Messages.getString("ProcessComposite.targetExecutionTabTooltipAvailable"));
    // targetExecutionTabItem.setControl(targetExecutionComposite);
    // //
    // // // Job Run VM Arguments Tab if language is java.
    // if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
    // jobVMTabItem = new CTabItem(leftTabFolder, SWT.BORDER);
    //            jobVMTabItem.setText(Messages.getString("ProcessComposite.JVMTab")); //$NON-NLS-1$
    // argumentsComposite = new Composite(leftTabFolder, SWT.NONE);
    // argumentsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    // GridLayout gridLayoutArguments = new GridLayout(1, false);
    // argumentsComposite.setLayout(gridLayoutArguments);
    // argumentsViewer = new JobVMArgumentsComposite("vmarguments", Messages
    //                    .getString("RunProcessPreferencePage.vmArgument"), //$NON-NLS-1$
    // argumentsComposite);
    // // argumentsViewer.setEnabled(false, argumentsComposite);
    // jobVMTabItem.setControl(argumentsComposite);
    // }
    ScrolledComposite execScroll = new ScrolledComposite(execGroup, SWT.V_SCROLL | SWT.H_SCROLL);
    execScroll.setExpandHorizontal(true);
    execScroll.setExpandVertical(true);
    execScroll.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite execContent = new Composite(execScroll, SWT.NONE);
    layout = new GridLayout();
    execContent.setLayout(new FormLayout());
    execScroll.setContent(execContent);
    Composite execHeader = new Composite(execContent, SWT.NONE);
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 7;
    formLayout.marginHeight = 4;
    formLayout.spacing = 7;
    execHeader.setLayout(formLayout);
    FormData layoutData = new FormData();
    layoutData.left = new FormAttachment(0, 0);
    layoutData.right = new FormAttachment(100, 0);
    layoutData.top = new FormAttachment(0, 0);
    layoutData.bottom = new FormAttachment(0, 50);
    // new GridData(GridData.FILL_HORIZONTAL)
    execHeader.setLayoutData(layoutData);
    // qli
    // see the feature 6366
    run = new Button(execHeader, SWT.PUSH);
    // itemDropDown = new ToolItem(toolBar, SWT.ARROW);
    //$NON-NLS-1$//$NON-NLS-2$
    run.setText(" " + Messages.getString("ProcessComposite.exec"));
    run.setData(ProcessView.EXEC_ID);
    //$NON-NLS-1$
    run.setToolTipText(Messages.getString("ProcessComposite.execHint"));
    run.setImage(ImageProvider.getImage(ERunprocessImages.RUN_PROCESS_ACTION));
    // final Menu menu = new Menu(execHeader);
    run.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            execRun();
        }
    });
    // Run
    // final MenuItem menuItem1 = new MenuItem(menu, SWT.PUSH);
    //        menuItem1.setText(" " + Messages.getString("ProcessComposite.exec"));//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
    // menuItem1.setImage(ImageProvider.getImage(ERunprocessImages.RUN_PROCESS_ACTION));
    // menuItem1.setData(ProcessView.EXEC_ID);
    // menuItem1.addSelectionListener(new SelectionAdapter() {
    //
    // public void widgetSelected(SelectionEvent event) {
    // if (!itemDropDown.getData().equals(ProcessView.PAUSE_ID) &&
    // !itemDropDown.getData().equals(ProcessView.RESUME_ID)) {
    // itemDropDown.setText(menuItem1.getText());
    // itemDropDown.setData(ProcessView.EXEC_ID);
    // itemDropDown.setImage(ImageProvider.getImage(ERunprocessImages.RUN_PROCESS_ACTION));
    //                    itemDropDown.setToolTipText(Messages.getString("ProcessComposite.execHint"));//$NON-NLS-1$
    // toolBar.getParent().layout();
    // }
    // }
    // });
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    // }
    if (processContext == null) {
        run.setEnabled(false);
    }
    // toolBar.setEnabled(false);
    FormData formData = new FormData();
    // see the feature 6366,qli comment.
    // make a judge when the text change in diffrent languages.
    Point debugSize = null;
    Point execSize = null;
    formData.left = new FormAttachment(0);
    // if (brandingService.getBrandingConfiguration().isAllowDebugMode()) {
    // // set debug text to judge size
    // itemDropDown.setText(debugMenuItem.getText());
    // debugSize = computeSize(itemDropDown.getText());
    //
    // // set exec text to judge size
    // itemDropDown.setText(menuItem1.getText());
    // execSize = computeSize(itemDropDown.getText());
    // if (debugSize.x > execSize.x) {
    // formData.right = new FormAttachment(0, debugSize.x + 70);
    // } else {
    // formData.right = new FormAttachment(0, execSize.x + 70);
    // }
    // } else {
    // set exec text to judge size
    execSize = computeSize(run.getText());
    formData.right = new FormAttachment(0, execSize.x + 70);
    formData.height = 30;
    // }
    run.setLayoutData(formData);
    killBtn = new Button(execHeader, SWT.PUSH);
    //$NON-NLS-1$
    killBtn.setText(Messages.getString("ProcessComposite.kill"));
    //$NON-NLS-1$
    killBtn.setToolTipText(Messages.getString("ProcessComposite.killHint"));
    killBtn.setImage(ImageProvider.getImage(ERunprocessImages.KILL_PROCESS_ACTION));
    setButtonLayoutData(killBtn);
    killBtn.setEnabled(false);
    formData = new FormData();
    formData.top = new FormAttachment(run, 0, SWT.TOP);
    formData.left = new FormAttachment(run, 0, SWT.RIGHT);
    // qli modified to fix the bug "7302".
    Point killSize = computeSize(killBtn.getText());
    // if (brandingService.getBrandingConfiguration().isAllowDebugMode()) {
    // if ((killSize.x > debugSize.x) && (killSize.x > execSize.x)) {
    // formData.right = new FormAttachment(toolBar, killSize.x + 70, SWT.RIGHT);
    // } else if (debugSize.x > execSize.x) {
    // formData.right = new FormAttachment(toolBar, debugSize.x + 70, SWT.RIGHT);
    // } else {
    // formData.right = new FormAttachment(toolBar, execSize.x + 70, SWT.RIGHT);
    // }
    // } else {
    // if (killSize.x > execSize.x) {
    // formData.right = new FormAttachment(toolBar, killSize.x + 70, SWT.RIGHT);
    // } else {
    // formData.right = new FormAttachment(toolBar, execSize.x + 70, SWT.RIGHT);
    // }
    // }
    formData.right = new FormAttachment(run, 30 + 70, SWT.RIGHT);
    formData.height = 30;
    killBtn.setLayoutData(formData);
    // saveJobBeforeRunButton = new Button(execHeader, SWT.CHECK);
    //        saveJobBeforeRunButton.setText(Messages.getString("ProcessComposite.saveBeforeRun")); //$NON-NLS-1$
    //        saveJobBeforeRunButton.setToolTipText(Messages.getString("ProcessComposite.saveBeforeRunHint")); //$NON-NLS-1$
    // // saveJobBeforeRunButton.setEnabled(false);
    // saveJobBeforeRunButton.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISSAVEBEFORERUN));
    // data = new GridData();
    // data.horizontalSpan = 2;
    // data.horizontalAlignment = SWT.END;
    // saveJobBeforeRunButton.setLayoutData(data);
    // formData = new FormData();
    // formData.top = new FormAttachment(toolBar, 0, SWT.BOTTOM);
    // formData.left = new FormAttachment(toolBar, 0, SWT.LEFT);
    // saveJobBeforeRunButton.setLayoutData(formData);
    // clearBeforeExec = new Button(execHeader, SWT.CHECK);
    //        clearBeforeExec.setText(Messages.getString("ProcessComposite.clearBefore")); //$NON-NLS-1$
    //        clearBeforeExec.setToolTipText(Messages.getString("ProcessComposite.clearBeforeHint")); //$NON-NLS-1$
    // // clearBeforeExec.setEnabled(false);
    // clearBeforeExec.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISCLEARBEFORERUN));
    // data = new GridData();
    // data.horizontalSpan = 2;
    // data.horizontalAlignment = SWT.END;
    // clearBeforeExec.setLayoutData(data);
    // formData = new FormData();
    // formData.top = new FormAttachment(toolBar, 0, SWT.BOTTOM);
    // formData.left = new FormAttachment(saveJobBeforeRunButton, 0, SWT.RIGHT);
    // clearBeforeExec.setLayoutData(formData);
    //
    // watchBtn = new Button(execHeader, SWT.CHECK);
    //        watchBtn.setText(Messages.getString("ProcessComposite.execTime")); //$NON-NLS-1$
    //        watchBtn.setToolTipText(Messages.getString("ProcessComposite.execTimeHint")); //$NON-NLS-1$
    // watchBtn.setEnabled(false);
    // watchBtn.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISEXECTIMERUN));
    // data = new GridData();
    // data.horizontalSpan = 2;
    // data.horizontalAlignment = SWT.END;
    // watchBtn.setLayoutData(data);
    // formData = new FormData();
    // formData.top = new FormAttachment(killBtn, 0, SWT.BOTTOM);
    // formData.left = new FormAttachment(clearBeforeExec, 0, SWT.RIGHT);
    // watchBtn.setLayoutData(formData);
    //
    // Group statisticsComposite = new Group(execHeader, SWT.NONE);
    //        statisticsComposite.setText(Messages.getString("ProcessComposite2.statsComposite")); //$NON-NLS-1$
    // layout = new GridLayout(3, false);
    // layout.marginWidth = 0;
    // statisticsComposite.setLayout(layout);
    // formData = new FormData();
    // // formData.right = new FormAttachment(100, 0);
    // / formData.left = new FormAttachment(watchBtn, 0, SWT.RIGHT);
    // statisticsComposite.setLayoutData(formData);
    //
    // Composite statisticsButtonComposite = new Composite(statisticsComposite, SWT.NONE);
    // layout = new GridLayout(1, false);
    // layout.marginWidth = 0;
    // statisticsButtonComposite.setLayout(layout);
    // statisticsButtonComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
    // perfBtn = new Button(statisticsButtonComposite, SWT.CHECK);
    //        perfBtn.setText(Messages.getString("ProcessComposite.stat")); //$NON-NLS-1$
    //        perfBtn.setToolTipText(Messages.getString("ProcessComposite.statHint")); //$NON-NLS-1$
    // perfBtn.setEnabled(false);
    // perfBtn.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISSTATISTICSRUN));
    // traceBtn = new Button(statisticsButtonComposite, SWT.CHECK);
    //        traceBtn.setText(Messages.getString("ProcessComposite.trace")); //$NON-NLS-1$
    //        traceBtn.setToolTipText(Messages.getString("ProcessComposite.traceHint")); //$NON-NLS-1$
    // traceBtn.setEnabled(false);
    // traceBtn
    // .setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(RunProcessPrefsConstants.ISTRACESRUN));
    clearTracePerfBtn = new Button(execHeader, SWT.PUSH);
    //$NON-NLS-1$
    clearTracePerfBtn.setText(Messages.getString("ProcessComposite.clear"));
    //$NON-NLS-1$
    clearTracePerfBtn.setToolTipText(Messages.getString("ProcessComposite.clearHint"));
    clearTracePerfBtn.setImage(ImageProvider.getImage(RunProcessPlugin.imageDescriptorFromPlugin(RunProcessPlugin.PLUGIN_ID, //$NON-NLS-1$
    "icons/process_stat_clear.gif")));
    clearTracePerfBtn.setEnabled(false);
    formData = new FormData();
    formData.top = new FormAttachment(killBtn, 0, SWT.TOP);
    formData.left = new FormAttachment(killBtn, 0, SWT.RIGHT);
    formData.right = new FormAttachment(killBtn, 10 + 70, SWT.RIGHT);
    formData.height = 30;
    clearTracePerfBtn.setLayoutData(formData);
    consoleText = new StyledText(execContent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    consoleText.setWordWrap(true);
    data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    data.minimumHeight = MINIMUM_HEIGHT;
    data.minimumWidth = MINIMUM_WIDTH;
    layouData = new FormData();
    layouData.left = new FormAttachment(0, 10);
    layouData.right = new FormAttachment(100, 0);
    layouData.top = new FormAttachment(0, 50);
    layouData.bottom = new FormAttachment(100, -30);
    consoleText.setLayoutData(layouData);
    // feature 6875, add searching capability, nma
    consoleText.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent evt) {
            // select all
            if ((evt.stateMask == SWT.CTRL) && (evt.keyCode == 'a')) {
                if (consoleText.getText().length() > 0) {
                    consoleText.setSelection(0, (consoleText.getText().length() - 1));
                }
            } else // search special string value
            if ((evt.stateMask == SWT.CTRL) && (evt.keyCode == 'f')) {
                FindDialog td = new FindDialog(Display.getCurrent().getActiveShell());
                td.setConsoleText(consoleText);
                td.setBlockOnOpen(true);
                td.open();
            }
        }

        @Override
        public void keyReleased(KeyEvent arg0) {
        }
    });
    // see feature 0004895: Font size of the output console are very small
    setConsoleFont();
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    preferenceStore.addPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
            if (TalendDesignerPrefConstants.CONSOLT_TEXT_FONT.endsWith(event.getProperty())) {
                setConsoleFont();
            }
        }
    });
    // execScroll.setMinSize(execContent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    // sash.setSashWidth(1);
    // sash.setWeights(new int[] { 7, 1, H_WEIGHT });
    pcl = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            runProcessContextChanged(evt);
        }
    };
    streamListener = new IStreamListener() {

        @Override
        public void streamAppended(String text, IStreamMonitor monitor) {
            IProcessMessage message = new ProcessMessage(ProcessMessage.MsgType.STD_OUT, text);
            processContext.addDebugResultToConsole(message);
        }
    };
    addListeners();
    createLineLimitedControl(execContent);
}
Also used : IStreamListener(org.eclipse.debug.core.IStreamListener) Group(org.eclipse.swt.widgets.Group) PropertyChangeListener(java.beans.PropertyChangeListener) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) ProcessMessage(org.talend.designer.runprocess.ProcessMessage) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormData(org.eclipse.swt.layout.FormData) FormLayout(org.eclipse.swt.layout.FormLayout) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(java.beans.PropertyChangeEvent) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IBrandingService(org.talend.core.ui.branding.IBrandingService) Point(org.eclipse.swt.graphics.Point) IStreamMonitor(org.eclipse.debug.core.model.IStreamMonitor) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) GridData(org.eclipse.swt.layout.GridData) KeyListener(org.eclipse.swt.events.KeyListener) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 57 with IPropertyChangeListener

use of org.eclipse.jface.util.IPropertyChangeListener in project tdi-studio-se by Talend.

the class AttributeSelectionDialog method createColorSelector.

/**
     * Creates the color selector.
     * 
     * @param parent The parent composite
     * @return The color selector
     */
private ColorSelector createColorSelector(Composite parent) {
    final ColorSelector selector = new ColorSelector(parent);
    selector.addListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            AttributeNode attribute = (AttributeNode) selection.getFirstElement();
            if (attribute != null) {
                attribute.setRgb(selector.getColorValue());
            }
        }
    });
    selector.setEnabled(false);
    return selector;
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ColorSelector(org.eclipse.jface.preference.ColorSelector)

Example 58 with IPropertyChangeListener

use of org.eclipse.jface.util.IPropertyChangeListener in project tdi-studio-se by Talend.

the class ConfigureChartDialog method createColorSelector.

/**
     * Creates the color selector.
     * 
     * @param parent The parent composite
     * @return The color selector
     */
private ColorSelector createColorSelector(Composite parent) {
    final ColorSelector selector = new ColorSelector(parent);
    selector.addListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            IStructuredSelection selection = (IStructuredSelection) attributesViewer.getSelection();
            MBeanAttribute attribute = (MBeanAttribute) selection.getFirstElement();
            if (attribute != null) {
                attribute.setRgb(selector.getColorValue());
            }
        }
    });
    selector.setEnabled(false);
    return selector;
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ColorSelector(org.eclipse.jface.preference.ColorSelector)

Example 59 with IPropertyChangeListener

use of org.eclipse.jface.util.IPropertyChangeListener in project sling by apache.

the class ServersActionModeFiddlerActionDelegate method selectionChanged.

@Override
public void selectionChanged(IAction action, ISelection selection) {
    server = null;
    modules = null;
    if (selection != null && (selection instanceof IStructuredSelection)) {
        IStructuredSelection iss = (IStructuredSelection) selection;
        Object first = iss.getFirstElement();
        if (first instanceof IServer) {
            server = (IServer) first;
            modules = null;
            if (iss.size() > 1) {
                // verify that all selected elements are of type IServer
                Iterator<?> it = iss.iterator();
                // skip the first, we have that above already
                it.next();
                while (it.hasNext()) {
                    Object next = it.next();
                    if (!(next instanceof IServer)) {
                        server = null;
                        modules = null;
                        break;
                    }
                }
            }
        } else if (first instanceof IServerModule) {
            modules = new LinkedList<>();
            IServerModule module = (IServerModule) first;
            modules.add(module.getModule());
            server = module.getServer();
            if (iss.size() > 1) {
                // verify that all selected elements are of type IServerModule
                // plus add the module[] to the modules list
                Iterator<?> it = iss.iterator();
                // skip the first, we have that above already
                it.next();
                while (it.hasNext()) {
                    Object next = it.next();
                    if (!(next instanceof IServerModule)) {
                        server = null;
                        module = null;
                        break;
                    } else {
                        module = (IServerModule) next;
                        modules.add(module.getModule());
                    }
                }
            }
        }
    }
    if (server != null) {
        if (server.getServerState() != IServer.STATE_STARTED) {
            server = null;
            modules = null;
        }
    }
    cleanAction.setEnabled(server != null);
    publishAction.setEnabled(server != null);
    action.setEnabled(true);
    final IAction serverRunAction = actionBars.getGlobalActionHandler("org.eclipse.wst.server.run");
    final IAction serverDebugAction = actionBars.getGlobalActionHandler("org.eclipse.wst.server.debug");
    IAction stopRunAction = actionBars.getGlobalActionHandler("org.eclipse.wst.server.stop");
    if (serverRunAction == null || stopRunAction == null || serverDebugAction == null) {
        return;
    }
    //		serverRunAction.setHoverImageDescriptor(SharedImages.SLING_LOG);
    serverRunAction.setHoverImageDescriptor(SharedImages.RUN_CONNECT);
    serverDebugAction.setHoverImageDescriptor(SharedImages.DEBUG_CONNECT);
    stopRunAction.setHoverImageDescriptor(SharedImages.DISCONNECT);
    findWstPublishAction();
    for (ActionContributionItem appendedAction : appendedToolbarActionContributionItems) {
        if (!contributionAdded(appendedAction)) {
            actionBars.getToolBarManager().add(appendedAction);
        }
    }
    if (wstPublishAction != null) {
        wstPublishAction.setVisible(false);
        publishActionContributionItem.setVisible(true);
    } else {
        // otherwise hide it, as it is an unexpected situation
        publishActionContributionItem.setVisible(false);
    }
    final String runText = "Connect to server in run mode";
    if (runTooltipListener == null) {
        runTooltipListener = new IPropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent event) {
                if (event.getProperty().equals(IAction.TOOL_TIP_TEXT)) {
                    if (!event.getNewValue().equals(runText)) {
                        serverRunAction.setToolTipText(runText);
                    }
                }
            }
        };
        serverRunAction.addPropertyChangeListener(runTooltipListener);
    }
    final String debugText = "Connect to server in debug mode";
    if (debugTooltipListener == null) {
        debugTooltipListener = new IPropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent event) {
                if (event.getProperty().equals(IAction.TOOL_TIP_TEXT)) {
                    if (!event.getNewValue().equals(debugText)) {
                        serverDebugAction.setToolTipText(debugText);
                    }
                }
            }
        };
        serverDebugAction.addPropertyChangeListener(debugTooltipListener);
    }
    final String disconnectText = "Disconnect from server";
    if (disconnectTooltipListener == null) {
        disconnectTooltipListener = new IPropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent event) {
                if (event.getProperty().equals(IAction.TOOL_TIP_TEXT)) {
                    if (!event.getNewValue().equals(disconnectText)) {
                        serverRunAction.setToolTipText(disconnectText);
                    }
                }
            }
        };
        stopRunAction.addPropertyChangeListener(disconnectTooltipListener);
    }
    serverRunAction.setToolTipText(runText);
    serverDebugAction.setToolTipText(debugText);
    stopRunAction.setToolTipText(disconnectText);
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) IServer(org.eclipse.wst.server.core.IServer) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) IAction(org.eclipse.jface.action.IAction) IServerModule(org.eclipse.wst.server.ui.IServerModule) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) LinkedList(java.util.LinkedList) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) Iterator(java.util.Iterator)

Example 60 with IPropertyChangeListener

use of org.eclipse.jface.util.IPropertyChangeListener in project eclipse.platform.text by eclipse.

the class AbstractTextEditor method createActions.

/**
 * Creates this editor's standard actions and connects them with the global
 * workbench actions.
 * <p>
 * Subclasses may extend.</p>
 */
protected void createActions() {
    ResourceAction action;
    setAction(IWorkbenchCommandConstants.EDIT_CUT, null);
    // $NON-NLS-1$
    action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Cut.", this, ITextOperationTarget.CUT);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_ACTION);
    action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_CUT);
    setAction(ITextEditorActionConstants.CUT, action);
    setAction(IWorkbenchCommandConstants.EDIT_COPY, null);
    // $NON-NLS-1$
    action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Copy.", this, ITextOperationTarget.COPY, true);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_ACTION);
    action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
    setAction(ITextEditorActionConstants.COPY, action);
    setAction(IWorkbenchCommandConstants.EDIT_PASTE, null);
    // $NON-NLS-1$
    action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Paste.", this, ITextOperationTarget.PASTE);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.PASTE_ACTION);
    action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);
    setAction(ITextEditorActionConstants.PASTE, action);
    // $NON-NLS-1$
    action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Delete.", this, ITextOperationTarget.DELETE);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_ACTION);
    action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);
    setAction(ITextEditorActionConstants.DELETE, action);
    // $NON-NLS-1$
    action = new DeleteLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.DeleteLine.", this, DeleteLineAction.WHOLE, false);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_LINE_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_LINE);
    setAction(ITextEditorActionConstants.DELETE_LINE, action);
    // $NON-NLS-1$
    action = new DeleteLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.CutLine.", this, DeleteLineAction.WHOLE, true);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_LINE_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT_LINE);
    setAction(ITextEditorActionConstants.CUT_LINE, action);
    // $NON-NLS-1$
    action = new DeleteLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.DeleteLineToBeginning.", this, DeleteLineAction.TO_BEGINNING, false);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_LINE_TO_BEGINNING_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_LINE_TO_BEGINNING);
    setAction(ITextEditorActionConstants.DELETE_LINE_TO_BEGINNING, action);
    // $NON-NLS-1$
    action = new DeleteLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.CutLineToBeginning.", this, DeleteLineAction.TO_BEGINNING, true);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_LINE_TO_BEGINNING_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT_LINE_TO_BEGINNING);
    setAction(ITextEditorActionConstants.CUT_LINE_TO_BEGINNING, action);
    // $NON-NLS-1$
    action = new DeleteLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.DeleteLineToEnd.", this, DeleteLineAction.TO_END, false);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_LINE_TO_END_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_LINE_TO_END);
    setAction(ITextEditorActionConstants.DELETE_LINE_TO_END, action);
    // $NON-NLS-1$
    action = new DeleteLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.CutLineToEnd.", this, DeleteLineAction.TO_END, true);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_LINE_TO_END_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT_LINE_TO_END);
    setAction(ITextEditorActionConstants.CUT_LINE_TO_END, action);
    // $NON-NLS-1$ //$NON-NLS-2$
    action = new JoinLinesAction(EditorMessages.getBundleForConstructedKeys(), "Editor.JoinLines.", this, " ");
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.JOIN_LINES_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.JOIN_LINES);
    setAction(ITextEditorActionConstants.JOIN_LINES, action);
    // $NON-NLS-1$
    action = new MarkAction(EditorMessages.getBundleForConstructedKeys(), "Editor.SetMark.", this, MarkAction.SET_MARK);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.SET_MARK_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.SET_MARK);
    setAction(ITextEditorActionConstants.SET_MARK, action);
    // $NON-NLS-1$
    action = new MarkAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ClearMark.", this, MarkAction.CLEAR_MARK);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.CLEAR_MARK_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.CLEAR_MARK);
    setAction(ITextEditorActionConstants.CLEAR_MARK, action);
    // $NON-NLS-1$
    action = new MarkAction(EditorMessages.getBundleForConstructedKeys(), "Editor.SwapMark.", this, MarkAction.SWAP_MARK);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.SWAP_MARK_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.SWAP_MARK);
    setAction(ITextEditorActionConstants.SWAP_MARK, action);
    // $NON-NLS-1$
    action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.SelectAll.", this, ITextOperationTarget.SELECT_ALL, true);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.SELECT_ALL_ACTION);
    action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_SELECT_ALL);
    setAction(ITextEditorActionConstants.SELECT_ALL, action);
    // $NON-NLS-1$
    action = new ShiftAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ShiftRight.", this, ITextOperationTarget.SHIFT_RIGHT);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHIFT_RIGHT_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_RIGHT);
    setAction(ITextEditorActionConstants.SHIFT_RIGHT, action);
    action = new // $NON-NLS-1$
    ShiftAction(// $NON-NLS-1$
    EditorMessages.getBundleForConstructedKeys(), // $NON-NLS-1$
    "Editor.ShiftRight.", // $NON-NLS-1$
    this, // $NON-NLS-1$
    ITextOperationTarget.SHIFT_RIGHT) {

        @Override
        public void update() {
            updateForTab();
        }
    };
    setAction(ITextEditorActionConstants.SHIFT_RIGHT_TAB, action);
    // $NON-NLS-1$
    action = new ShiftAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ShiftLeft.", this, ITextOperationTarget.SHIFT_LEFT);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHIFT_LEFT_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_LEFT);
    setAction(ITextEditorActionConstants.SHIFT_LEFT, action);
    // $NON-NLS-1$
    action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Print.", this, ITextOperationTarget.PRINT, true);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.PRINT_ACTION);
    action.setActionDefinitionId(IWorkbenchCommandConstants.FILE_PRINT);
    setAction(ITextEditorActionConstants.PRINT, action);
    // $NON-NLS-1$
    action = new FindReplaceAction(EditorMessages.getBundleForConstructedKeys(), "Editor.FindReplace.", this);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_ACTION);
    action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE);
    setAction(ITextEditorActionConstants.FIND, action);
    // $NON-NLS-1$
    action = new FindNextAction(EditorMessages.getBundleForConstructedKeys(), "Editor.FindNext.", this, true);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_NEXT_ACTION);
    action.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_NEXT);
    setAction(ITextEditorActionConstants.FIND_NEXT, action);
    // $NON-NLS-1$
    action = new FindNextAction(EditorMessages.getBundleForConstructedKeys(), "Editor.FindPrevious.", this, false);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_PREVIOUS_ACTION);
    action.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_PREVIOUS);
    setAction(ITextEditorActionConstants.FIND_PREVIOUS, action);
    // $NON-NLS-1$
    action = new IncrementalFindAction(EditorMessages.getBundleForConstructedKeys(), "Editor.FindIncremental.", this, true);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_INCREMENTAL_ACTION);
    action.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_INCREMENTAL);
    setAction(ITextEditorActionConstants.FIND_INCREMENTAL, action);
    // $NON-NLS-1$
    action = new IncrementalFindAction(EditorMessages.getBundleForConstructedKeys(), "Editor.FindIncrementalReverse.", this, false);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_INCREMENTAL_REVERSE_ACTION);
    action.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_INCREMENTAL_REVERSE);
    setAction(ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE, action);
    fSaveAction = ActionFactory.SAVE.create(getSite().getWorkbenchWindow());
    setAction(ITextEditorActionConstants.SAVE, fSaveAction);
    // $NON-NLS-1$
    action = new RevertToSavedAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Revert.", this);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.REVERT_TO_SAVED_ACTION);
    action.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REVERT);
    setAction(ITextEditorActionConstants.REVERT_TO_SAVED, action);
    // $NON-NLS-1$
    action = new GotoLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.GotoLine.", this);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.GOTO_LINE_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_GOTO);
    setAction(ITextEditorActionConstants.GOTO_LINE, action);
    // $NON-NLS-1$
    action = new MoveLinesAction(EditorMessages.getBundleForConstructedKeys(), "Editor.MoveLinesUp.", this, getSourceViewer(), true, false);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.MOVE_LINES_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_UP);
    setAction(ITextEditorActionConstants.MOVE_LINE_UP, action);
    // $NON-NLS-1$
    action = new MoveLinesAction(EditorMessages.getBundleForConstructedKeys(), "Editor.MoveLinesDown.", this, getSourceViewer(), false, false);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.MOVE_LINES_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_DOWN);
    setAction(ITextEditorActionConstants.MOVE_LINE_DOWN, action);
    // $NON-NLS-1$
    action = new MoveLinesAction(EditorMessages.getBundleForConstructedKeys(), "Editor.CopyLineUp.", this, getSourceViewer(), true, true);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_LINES_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY_LINES_UP);
    setAction(ITextEditorActionConstants.COPY_LINE_UP, action);
    // $NON-NLS-1$
    action = new MoveLinesAction(EditorMessages.getBundleForConstructedKeys(), "Editor.CopyLineDown.", this, getSourceViewer(), false, true);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_LINES_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY_LINES_DOWN);
    setAction(ITextEditorActionConstants.COPY_LINE_DOWN, action);
    // $NON-NLS-1$
    action = new CaseAction(EditorMessages.getBundleForConstructedKeys(), "Editor.UpperCase.", this, true);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.UPPER_CASE_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.UPPER_CASE);
    setAction(ITextEditorActionConstants.UPPER_CASE, action);
    // $NON-NLS-1$
    action = new CaseAction(EditorMessages.getBundleForConstructedKeys(), "Editor.LowerCase.", this, false);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.LOWER_CASE_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.LOWER_CASE);
    setAction(ITextEditorActionConstants.LOWER_CASE, action);
    // $NON-NLS-1$
    action = new InsertLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.SmartEnter.", this, false);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.SMART_ENTER_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.SMART_ENTER);
    setAction(ITextEditorActionConstants.SMART_ENTER, action);
    // $NON-NLS-1$
    action = new InsertLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.SmartEnterInverse.", this, true);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.SMART_ENTER_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.SMART_ENTER_INVERSE);
    setAction(ITextEditorActionConstants.SMART_ENTER_INVERSE, action);
    // $NON-NLS-1$
    action = new ToggleInsertModeAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ToggleInsertMode.");
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.TOGGLE_INSERT_MODE_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_INSERT_MODE);
    setAction(ITextEditorActionConstants.TOGGLE_INSERT_MODE, action);
    // $NON-NLS-1$
    action = new HippieCompleteAction(EditorMessages.getBundleForConstructedKeys(), "Editor.HippieCompletion.", this);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.HIPPIE_COMPLETION_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.HIPPIE_COMPLETION);
    setAction(ITextEditorActionConstants.HIPPIE_COMPLETION, action);
    // $NON-NLS-1$
    action = new ContentAssistAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ContentAssistProposal.", this);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.CONTENT_ASSIST_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
    setAction(ITextEditorActionConstants.CONTENT_ASSIST, action);
    markAsStateDependentAction(ITextEditorActionConstants.CONTENT_ASSIST, true);
    // $NON-NLS-1$
    action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ContentAssistContextInformation.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.CONTENT_ASSIST_CONTEXT_INFORMATION_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
    setAction(ITextEditorActionConstants.CONTENT_ASSIST_CONTEXT_INFORMATION, action);
    markAsStateDependentAction(ITextEditorActionConstants.CONTENT_ASSIST_CONTEXT_INFORMATION, true);
    // $NON-NLS-1$
    action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.QuickAssist.", this, ISourceViewer.QUICK_ASSIST);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.QUICK_ASSIST_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICK_ASSIST);
    setAction(ITextEditorActionConstants.QUICK_ASSIST, action);
    markAsStateDependentAction(ITextEditorActionConstants.QUICK_ASSIST, true);
    action = new GotoAnnotationAction(this, true);
    setAction(ITextEditorActionConstants.NEXT, action);
    action = new GotoAnnotationAction(this, false);
    setAction(ITextEditorActionConstants.PREVIOUS, action);
    // $NON-NLS-1$
    action = new RecenterAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Recenter.", this);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.RECENTER_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.RECENTER);
    setAction(ITextEditorActionConstants.RECENTER, action);
    // $NON-NLS-1$
    action = new ShowWhitespaceCharactersAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ShowWhitespaceCharacters.", this, getPreferenceStore());
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHOW_WHITESPACE_CHARACTERS_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_WHITESPACE_CHARACTERS);
    setAction(ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS, action);
    // $NON-NLS-1$
    action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ShowInformation.", this, ISourceViewer.INFORMATION, true);
    // $NON-NLS-1$
    action = new InformationDispatchAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ShowInformation.", (TextOperationAction) action);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHOW_INFORMATION_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_INFORMATION);
    setAction(ITextEditorActionConstants.SHOW_INFORMATION, action);
    // $NON-NLS-1$
    final BlockSelectionModeToggleAction blockAction = new BlockSelectionModeToggleAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ToggleBlockSelectionMode.", this);
    action = blockAction;
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.BLOCK_SELECTION_MODE_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.BLOCK_SELECTION_MODE);
    setAction(ITextEditorActionConstants.BLOCK_SELECTION_MODE, action);
    if (isWordWrapSupported()) {
        // $NON-NLS-1$
        final WordWrapToggleAction wrapAction = new WordWrapToggleAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ToggleWordWrap.", this, getInitialWordWrapStatus());
        action = wrapAction;
        action.setHelpContextId(IAbstractTextEditorHelpContextIds.WORD_WRAP_TOGGLE_ACTION);
        action.setActionDefinitionId(ITextEditorActionDefinitionIds.WORD_WRAP);
        setAction(ITextEditorActionConstants.WORD_WRAP, action);
        blockAction.addPropertyChangeListener(new IPropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent event) {
                if (IAction.CHECKED == event.getProperty() && Boolean.TRUE.equals(event.getNewValue())) {
                    wrapAction.setChecked(false);
                }
            }
        });
        wrapAction.addPropertyChangeListener(new IPropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent event) {
                if (IAction.CHECKED == event.getProperty() && Boolean.TRUE.equals(event.getNewValue())) {
                    blockAction.setChecked(false);
                }
            }
        });
    }
    // $NON-NLS-1$;
    action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.OpenHyperlink.", this, HyperlinkManager.OPEN_HYPERLINK, true);
    action.setHelpContextId(IAbstractTextEditorHelpContextIds.OPEN_HYPERLINK_ACTION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.OPEN_HYPERLINK);
    setAction(ITextEditorActionConstants.OPEN_HYPERLINK, action);
    PropertyDialogAction openProperties = new PropertyDialogAction(new IShellProvider() {

        @Override
        public Shell getShell() {
            return getSite().getShell();
        }
    }, new ISelectionProvider() {

        @Override
        public void addSelectionChangedListener(ISelectionChangedListener listener) {
        }

        @Override
        public ISelection getSelection() {
            return new StructuredSelection(getEditorInput());
        }

        @Override
        public void removeSelectionChangedListener(ISelectionChangedListener listener) {
        }

        @Override
        public void setSelection(ISelection selection) {
        }
    });
    openProperties.setActionDefinitionId(IWorkbenchCommandConstants.FILE_PROPERTIES);
    setAction(ITextEditorActionConstants.PROPERTIES, openProperties);
    markAsContentDependentAction(ITextEditorActionConstants.UNDO, true);
    markAsContentDependentAction(ITextEditorActionConstants.REDO, true);
    markAsContentDependentAction(ITextEditorActionConstants.FIND, true);
    markAsContentDependentAction(ITextEditorActionConstants.FIND_NEXT, true);
    markAsContentDependentAction(ITextEditorActionConstants.FIND_PREVIOUS, true);
    markAsContentDependentAction(ITextEditorActionConstants.FIND_INCREMENTAL, true);
    markAsContentDependentAction(ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE, true);
    markAsSelectionDependentAction(ITextEditorActionConstants.CUT, true);
    markAsSelectionDependentAction(ITextEditorActionConstants.COPY, true);
    markAsSelectionDependentAction(ITextEditorActionConstants.PASTE, true);
    markAsSelectionDependentAction(ITextEditorActionConstants.DELETE, true);
    markAsSelectionDependentAction(ITextEditorActionConstants.SHIFT_RIGHT, true);
    markAsSelectionDependentAction(ITextEditorActionConstants.SHIFT_RIGHT_TAB, true);
    markAsSelectionDependentAction(ITextEditorActionConstants.UPPER_CASE, true);
    markAsSelectionDependentAction(ITextEditorActionConstants.LOWER_CASE, true);
    markAsPropertyDependentAction(ITextEditorActionConstants.UNDO, true);
    markAsPropertyDependentAction(ITextEditorActionConstants.REDO, true);
    markAsPropertyDependentAction(ITextEditorActionConstants.REVERT_TO_SAVED, true);
    markAsPropertyDependentAction(ITextEditorActionConstants.SAVE, true);
    markAsStateDependentAction(ITextEditorActionConstants.UNDO, true);
    markAsStateDependentAction(ITextEditorActionConstants.REDO, true);
    markAsStateDependentAction(ITextEditorActionConstants.CUT, true);
    markAsStateDependentAction(ITextEditorActionConstants.PASTE, true);
    markAsStateDependentAction(ITextEditorActionConstants.DELETE, true);
    markAsStateDependentAction(ITextEditorActionConstants.SHIFT_RIGHT, true);
    markAsStateDependentAction(ITextEditorActionConstants.SHIFT_RIGHT_TAB, true);
    markAsStateDependentAction(ITextEditorActionConstants.SHIFT_LEFT, true);
    markAsStateDependentAction(ITextEditorActionConstants.FIND, true);
    markAsStateDependentAction(ITextEditorActionConstants.DELETE_LINE, true);
    markAsStateDependentAction(ITextEditorActionConstants.DELETE_LINE_TO_BEGINNING, true);
    markAsStateDependentAction(ITextEditorActionConstants.DELETE_LINE_TO_END, true);
    markAsStateDependentAction(ITextEditorActionConstants.MOVE_LINE_UP, true);
    markAsStateDependentAction(ITextEditorActionConstants.MOVE_LINE_DOWN, true);
    markAsStateDependentAction(ITextEditorActionConstants.CUT_LINE, true);
    markAsStateDependentAction(ITextEditorActionConstants.CUT_LINE_TO_BEGINNING, true);
    markAsStateDependentAction(ITextEditorActionConstants.CUT_LINE_TO_END, true);
    setActionActivationCode(ITextEditorActionConstants.SHIFT_RIGHT_TAB, '\t', -1, SWT.NONE);
    setActionActivationCode(ITextEditorActionConstants.SHIFT_LEFT, '\t', -1, SWT.SHIFT);
}
Also used : IShellProvider(org.eclipse.jface.window.IShellProvider) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) PropertyDialogAction(org.eclipse.ui.dialogs.PropertyDialogAction) Shell(org.eclipse.swt.widgets.Shell) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISelection(org.eclipse.jface.viewers.ISelection) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)

Aggregations

IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)126 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)120 Composite (org.eclipse.swt.widgets.Composite)55 GridData (org.eclipse.swt.layout.GridData)44 Label (org.eclipse.swt.widgets.Label)39 GridLayout (org.eclipse.swt.layout.GridLayout)37 SelectionEvent (org.eclipse.swt.events.SelectionEvent)31 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)25 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 Button (org.eclipse.swt.widgets.Button)22 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)21 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)20 ColorSelector (org.eclipse.jface.preference.ColorSelector)14 ComboViewer (org.eclipse.jface.viewers.ComboViewer)12 Text (org.eclipse.swt.widgets.Text)11 Iterator (java.util.Iterator)10 ISelection (org.eclipse.jface.viewers.ISelection)10 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)10 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)9 SashForm (org.eclipse.swt.custom.SashForm)9