Search in sources :

Example 1 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project tdi-studio-se by Talend.

the class ToolbarInputZone method addPreviewToolItems.

private void addPreviewToolItems() {
    if (PluginChecker.isTraceDebugPluginLoaded() && getMapperManager().isTracesActive()) {
        final RunProcessContext activeContext = RunProcessPlugin.getDefault().getRunProcessContextManager().getActiveContext();
        if (activeContext == null) {
            return;
        }
        new ToolItem(getToolBarActions(), SWT.SEPARATOR);
        previousRow = new ToolItem(getToolBarActions(), SWT.PUSH);
        previousRow.setEnabled(activeContext.isRunning());
        previousRow.setToolTipText("Previous Row");
        previousRow.setImage(ImageProvider.getImage(EImage.LEFT_ICON));
        currentRowLabel = new ToolItem(getToolBarActions(), SWT.PUSH | SWT.BORDER);
        currentRowLabel.setEnabled(false);
        currentRowLabel.setText(getCurrentRowString());
        currentRowLabel.setToolTipText("Current Row");
        currentRowLabel.setWidth(50);
        nextRow = new ToolItem(getToolBarActions(), SWT.PUSH);
        nextRow.setEnabled(!getMapperManager().componentIsReadOnly());
        nextRow.setToolTipText("Next Row");
        nextRow.setImage(ImageProvider.getImage(EImage.RIGHT_ICON));
        nextBreakpoint = new ToolItem(getToolBarActions(), SWT.PUSH);
        nextBreakpoint.setToolTipText("Next Breakpoint");
        nextBreakpoint.setImage(ImageProvider.getImage(EImage.RIGHTX_ICON));
        Boolean bc = activeContext.checkBreakpoint();
        if (!bc) {
            nextBreakpoint.setEnabled(bc);
        } else {
            nextBreakpoint.setEnabled(activeContext.isRunning());
        }
        killBtn = new ToolItem(getToolBarActions(), SWT.PUSH);
        killBtn.setToolTipText("Kill");
        killBtn.setImage(ImageProvider.getImage(ERunprocessImages.KILL_PROCESS_ACTION));
        killBtn.setEnabled(activeContext.isRunning());
        previousRow.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                activeContext.setPreviousRow(true);
            }
        });
        nextRow.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (!activeContext.isRunning()) {
                    for (DataMapTableView dataMapTableView : getMapperManager().getUiManager().getOutputsTablesView()) {
                        dataMapTableView.notifyFocusLost();
                    }
                    if (getMapperManager().isDataChanged()) {
                        boolean closeWindow = MessageDialog.openConfirm(getComposite().getShell(), //$NON-NLS-1$
                        "tMap configuration modified", //$NON-NLS-1$
                        "Do you want to apply the modification of the tMap now ?");
                        // save change and regenerate code
                        if (closeWindow) {
                            IExternalNode externalNode = getMapperManager().getAbstractMapComponent().getExternalNode();
                            IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
                            if (externalNode != null && (part instanceof AbstractMultiPageTalendEditor)) {
                                INode node = externalNode.getOriginalNode();
                                if (node != null && node instanceof Node) {
                                    Command cmd = new ExternalNodeChangeCommand((Node) node, externalNode);
                                    CommandStack cmdStack = (CommandStack) part.getAdapter(CommandStack.class);
                                    cmdStack.execute(cmd);
                                }
                            }
                        }
                    }
                    activeContext.setLastIsRow(true);
                    IDebugProcessService service = (IDebugProcessService) GlobalServiceRegister.getDefault().getService(IDebugProcessService.class);
                    service.debugProcess();
                } else {
                    activeContext.setNextRow(true);
                }
            }
        });
        nextBreakpoint.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                activeContext.setNextBreakPoint(true);
            }
        });
        killBtn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                IDebugProcessService service = (IDebugProcessService) GlobalServiceRegister.getDefault().getService(IDebugProcessService.class);
                service.debugKill();
                killBtn.setEnabled(false);
                previousRow.setEnabled(false);
                nextBreakpoint.setEnabled(false);
            }
        });
        propertyListener = new PropertyChangeListener() {

            public void propertyChange(final PropertyChangeEvent evt) {
                final String propName = evt.getPropertyName();
                ProcessManager.getInstance().getProcessShell().getDisplay().syncExec(new Runnable() {

                    public void run() {
                        if (RunProcessContext.PREVIOUS_ROW.equals(propName)) {
                            boolean enabled = ((Boolean) evt.getNewValue()).booleanValue();
                            if (!previousRow.isDisposed() && enabled != previousRow.isEnabled()) {
                                previousRow.setEnabled(enabled);
                            }
                        } else if (RunProcessContext.PROP_RUNNING.equals(propName)) {
                            boolean enabled = ((Boolean) evt.getNewValue()).booleanValue();
                            if (!previousRow.isDisposed() && enabled != previousRow.isEnabled()) {
                                previousRow.setEnabled(enabled);
                            }
                            if (!nextBreakpoint.isDisposed() && enabled != nextBreakpoint.isEnabled()) {
                                Boolean bc = activeContext.checkBreakpoint();
                                if (!bc) {
                                    nextBreakpoint.setEnabled(bc);
                                } else {
                                    nextBreakpoint.setEnabled(enabled);
                                }
                            }
                            if (!killBtn.isDisposed() && enabled != killBtn.isEnabled()) {
                                killBtn.setEnabled(enabled);
                            }
                            if (!nextRow.isDisposed()) {
                                nextRow.setEnabled(true);
                            }
                        } else if (RunProcessContext.NEXTBREAKPOINT.equals(propName)) {
                            boolean running = ((Boolean) evt.getNewValue()).booleanValue();
                            if (!nextBreakpoint.isDisposed()) {
                                nextBreakpoint.setEnabled(running);
                            }
                            if (!nextRow.isDisposed()) {
                                nextRow.setEnabled(true);
                            }
                        } else if (RunProcessContext.BREAKPOINT_BAR.equals(propName)) {
                            boolean enable = ((Boolean) evt.getNewValue()).booleanValue();
                            if (!enable) {
                                if (!previousRow.isDisposed()) {
                                    previousRow.setEnabled(false);
                                }
                                if (!nextRow.isDisposed()) {
                                    nextRow.setEnabled(false);
                                }
                                if (!nextBreakpoint.isDisposed()) {
                                    nextBreakpoint.setEnabled(false);
                                }
                            }
                        }
                    }
                });
            }
        };
        activeContext.addPropertyChangeListener(propertyListener);
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) RunProcessContext(org.talend.designer.runprocess.RunProcessContext) INode(org.talend.core.model.process.INode) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) Command(org.eclipse.gef.commands.Command) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IDebugProcessService(org.talend.core.model.runprocess.IDebugProcessService) ToolItem(org.eclipse.swt.widgets.ToolItem) IExternalNode(org.talend.core.model.process.IExternalNode)

Example 2 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project tdi-studio-se by Talend.

the class ProcessView method createPartControl.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
     */
@Override
public void createPartControl(Composite parent) {
    this.parent = parent;
    parent.setLayout(new FillLayout());
    sash = new SashForm(parent, SWT.HORIZONTAL | SWT.SMOOTH);
    sash.setLayoutData(new GridData(GridData.FILL_BOTH));
    sash.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    GridLayout layout = new GridLayout();
    sash.setLayout(layout);
    Composite left = new Composite(sash, SWT.NONE);
    left.setLayout(new FillLayout());
    Composite right = new Composite(sash, SWT.NONE);
    right.setLayout(new FormLayout());
    FormData layouDatag = new FormData();
    layouDatag.left = new FormAttachment(0, 0);
    layouDatag.width = 32;
    layouDatag.top = new FormAttachment(0, 0);
    layouDatag.bottom = new FormAttachment(100, 0);
    final Composite buttonComposite = new Composite(right, SWT.ERROR);
    buttonComposite.setLayoutData(layouDatag);
    buttonComposite.setLayout(new GridLayout());
    Composite cotextCom = new Composite(right, SWT.NONE);
    layouDatag = new FormData();
    layouDatag.left = new FormAttachment(0, 32);
    layouDatag.right = new FormAttachment(100, 0);
    layouDatag.top = new FormAttachment(0, 0);
    layouDatag.bottom = new FormAttachment(100, 0);
    cotextCom.setLayoutData(layouDatag);
    cotextCom.setLayout(new GridLayout());
    tabFactory.initComposite(left, false);
    moveButton = new Button(buttonComposite, SWT.PUSH);
    //$NON-NLS-1$
    moveButton.setText(">>");
    moveButton.setToolTipText(Messages.getString("ProcessComposite.hideContext"));
    final GridData layoutData = new GridData();
    layoutData.verticalAlignment = GridData.CENTER;
    layoutData.horizontalAlignment = GridData.CENTER;
    layoutData.grabExcessHorizontalSpace = true;
    layoutData.grabExcessVerticalSpace = true;
    moveButton.setLayoutData(layoutData);
    addListeners();
    sash.setSashWidth(5);
    sash.setWeights(new int[] { 18, 5 });
    contextComposite = new ProcessContextComposite(cotextCom, SWT.NONE);
    contextComposite.setBackground(right.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    // processComposite = new ProcessComposite(tabFactory.getTabComposite(), SWT.H_SCROLL | SWT.V_SCROLL |
    // SWT.NO_FOCUS);
    // dc = processComposite;
    // createBasicComposite(tabFactory.getTabComposite(), element, null);
    tabFactory.getTabComposite().layout();
    tabFactory.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            TalendPropertyTabDescriptor descriptor = (TalendPropertyTabDescriptor) selection.getFirstElement();
            if (descriptor == null) {
                return;
            }
            if (currentSelectedTab != null && (currentSelectedTab.getCategory() != descriptor.getCategory())) {
                for (Control curControl : tabFactory.getTabComposite().getChildren()) {
                    curControl.dispose();
                }
            }
            if (currentSelectedTab == null || currentSelectedTab.getCategory() != descriptor.getCategory() || selectedPrimary) {
                currentSelectedTab = descriptor;
                selectedPrimary = false;
                createDynamicComposite(tabFactory.getTabComposite(), (Element) descriptor.getData(), descriptor.getCategory());
            }
        }
    });
    setElement();
    IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
    IHandler handler1;
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    if (brandingService.getBrandingConfiguration().isAllowDebugMode()) {
        Action debugAction = new DebugAction();
        handler1 = new ActionHandler(debugAction);
        handlerService.activateHandler(debugAction.getActionDefinitionId(), handler1);
    }
    Action killAction = new KillAction();
    handler1 = new ActionHandler(killAction);
    handlerService.activateHandler(killAction.getActionDefinitionId(), handler1);
    FocusListener fl = new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
            //$NON-NLS-1$
            log.trace(Messages.getString("ProcessView.gainFocusLog"));
            IContextService contextService = (IContextService) RunProcessPlugin.getDefault().getWorkbench().getAdapter(IContextService.class);
            //$NON-NLS-1$
            ca = contextService.activateContext("talend.runProcess");
        }

        @Override
        public void focusLost(FocusEvent e) {
            //$NON-NLS-1$
            log.trace(Messages.getString("ProcessView.lostFocusLog"));
            if (ca != null) {
                IContextService contextService = (IContextService) RunProcessPlugin.getDefault().getWorkbench().getAdapter(IContextService.class);
                contextService.deactivateContext(ca);
            }
        }
    };
    addListenerOnChildren(parent, fl);
    rubjobManager.setProcessShell(getSite().getShell());
    contextManagerListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (RunProcessContextManager.PROP_ACTIVE.equals(evt.getPropertyName())) {
                // rubjobManager.setBooleanTrace(false);
                runningProcessChanged();
            }
        }
    };
    RunProcessPlugin.getDefault().getRunProcessContextManager().addPropertyChangeListener(contextManagerListener);
    runAction = new RunAction();
}
Also used : Action(org.eclipse.jface.action.Action) ClearPerformanceAction(org.talend.designer.runprocess.ui.actions.ClearPerformanceAction) PropertyChangeListener(java.beans.PropertyChangeListener) Element(org.talend.core.model.process.Element) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) FocusEvent(org.eclipse.swt.events.FocusEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ProcessContextComposite(org.talend.designer.runprocess.ui.ProcessContextComposite) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) IContextService(org.eclipse.ui.contexts.IContextService) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) PropertyChangeEvent(java.beans.PropertyChangeEvent) TraceDebugProcessComposite(org.talend.designer.runprocess.ui.TraceDebugProcessComposite) Composite(org.eclipse.swt.widgets.Composite) TargetExecComposite(org.talend.designer.runprocess.ui.TargetExecComposite) MemoryRuntimeComposite(org.talend.designer.runprocess.ui.MemoryRuntimeComposite) AdvanceSettingComposite(org.talend.designer.runprocess.ui.AdvanceSettingComposite) MultipleThreadDynamicComposite(org.talend.designer.core.ui.views.properties.MultipleThreadDynamicComposite) ProcessComposite(org.talend.designer.runprocess.ui.ProcessComposite) ProcessContextComposite(org.talend.designer.runprocess.ui.ProcessContextComposite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) FillLayout(org.eclipse.swt.layout.FillLayout) TalendPropertyTabDescriptor(org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor) IBrandingService(org.talend.core.ui.branding.IBrandingService) SashForm(org.eclipse.swt.custom.SashForm) IHandlerService(org.eclipse.ui.handlers.IHandlerService) GridData(org.eclipse.swt.layout.GridData) IHandler(org.eclipse.core.commands.IHandler) ActionHandler(org.eclipse.ui.commands.ActionHandler) FocusListener(org.eclipse.swt.events.FocusListener)

Example 3 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project tdi-studio-se by Talend.

the class MemoryRuntimeComposite method addListeners.

private void addListeners() {
    runtimeButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            getRemoteStatus();
            boolean isRunButtonPressed = runtimeButton.getText().equals(Messages.getString("ProcessComposite.exec"));
            boolean isKillButtonPressed = runtimeButton.getText().equals(Messages.getString("ProcessComposite.kill"));
            if (lock && isRunButtonPressed) {
                // $NON-NLS-1$
                //$NON-NLS-1$ //$NON-NLS-2$
                MessageDialog.openWarning(getShell(), "Warning", Messages.getString("ProcessView.anotherJobMonitoring"));
                return;
            }
            if (isCommandlineRun) {
                //$NON-NLS-1$ //$NON-NLS-2$
                MessageDialog.openWarning(getShell(), "Warning", Messages.getString("ProcessView.commandlineForbidden"));
                return;
            }
            if (isRemoteRun && !isRemoteMonitoring) {
                //$NON-NLS-1$ //$NON-NLS-2$
                MessageDialog.openWarning(getShell(), "Warning", Messages.getString("ProcessView.remoteMonitoringUnavailable"));
                return;
            }
            if (processContext != null && !processContext.isRunning() && isRunButtonPressed) {
                // $NON-NLS-1$
                runtimeButton.setEnabled(false);
                isReadyToStart = true;
                exec();
            }
            if (processContext != null && (processContext.isRunning() || isReadyToStart)) {
                if (isRunButtonPressed) {
                    if (!acquireJVM()) {
                        isReadyToStart = false;
                        runtimeButton.setEnabled(true);
                        //$NON-NLS-1$
                        MessageDialog.openWarning(//$NON-NLS-1$
                        getShell(), //$NON-NLS-1$
                        "Warning", //$NON-NLS-1$
                        Messages.getString("ProcessView.connectToMonitorServerFailed"));
                        return;
                    }
                    initMonitoringModel();
                    refreshMonitorComposite();
                    processContext.setMonitoring(true);
                    AbstractRuntimeGraphcsComposite.setMonitoring(true);
                    setRuntimeButtonByStatus(false);
                    isReadyToStart = false;
                    if (periodCombo.isEnabled() && periodCombo.getSelectionIndex() != 0) {
                        startCustomerGCSchedule();
                    }
                    //$NON-NLS-1$
                    String content = getExecutionInfo("Start");
                    messageManager.setStartMessage(content, getDisplay().getSystemColor(SWT.COLOR_BLUE), getDisplay().getSystemColor(SWT.COLOR_WHITE));
                    ((RuntimeGraphcsComposite) chartComposite).displayReportField();
                    lock = true;
                } else if (isKillButtonPressed) {
                    // $NON-NLS-1$
                    processContext.kill();
                }
            } else {
                //$NON-NLS-1$ //$NON-NLS-2$
                MessageDialog.openWarning(getShell(), "Warning", Messages.getString("ProcessView.noJobRunning"));
            }
            runtimeButton.setEnabled(true);
        }
    });
    gcCheckButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            isGCSelected = gcCheckButton.getSelection();
            periodCombo.setEnabled(isGCSelected);
            if (!isGCSelected) {
                periodCombo.select(0);
                if (processContext != null && processContext.isRunning()) {
                    // cancel GC timer task during job running.
                    doScheduledGc(0);
                }
            }
        }
    });
    periodCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            startCustomerGCSchedule();
        }
    });
    propertyChangeListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            runProcessContextChanged(evt);
        }
    };
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 4 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project pcgen by PCGen.

the class Utils method buildFloatField.

/**
	 * <p>Builds a formatted text field with specified min and max</p>
	 * 
	 * @param min minimum value
	 * @param max maximum value
	 * @return JFormattedTextField
	 */
public static JFormattedTextField buildFloatField(float min, float max) {
    java.text.NumberFormat numberFormat = java.text.NumberFormat.getNumberInstance();
    // numberFormat.setParseIntegerOnly(false);
    NumberFormatter formatter = new NumberFormatter(numberFormat);
    //formatter.getCommitsOnValidEdit();
    formatter.setMinimum(min);
    formatter.setMaximum(max);
    final JFormattedTextField returnValue = new JFormattedTextField(formatter);
    returnValue.setColumns(4);
    returnValue.addPropertyChangeListener(new PropertyChangeListener() {

        Border m_originalBorder = returnValue.getBorder();

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName() != null && evt.getPropertyName().equals("editValid")) {
                if (evt.getNewValue() != null && evt.getNewValue() instanceof Boolean) {
                    if (((Boolean) evt.getNewValue()).booleanValue()) {
                        returnValue.setBorder(m_originalBorder);
                    } else {
                        returnValue.setBorder(BorderFactory.createLineBorder(Color.red));
                    }
                }
            }
        }
    });
    return returnValue;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) JFormattedTextField(javax.swing.JFormattedTextField) Border(javax.swing.border.Border) NumberFormatter(javax.swing.text.NumberFormatter)

Example 5 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project pcgen by PCGen.

the class SavingThrowDialog method buildIntegerField.

/**
	 *
	 * <p>Builds a formatted text field with specified min and max</p>
	 * @param min
	 * @param max
	 * @return JFormattedTextField
	 */
private JFormattedTextField buildIntegerField(int min, int max) {
    final JFormattedTextField returnValue = Utils.buildIntegerField(min, max);
    returnValue.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if ("value".equals(evt.getPropertyName())) {
                calculate();
            }
        }
    });
    return returnValue;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) JFormattedTextField(javax.swing.JFormattedTextField)

Aggregations

PropertyChangeListener (java.beans.PropertyChangeListener)454 PropertyChangeEvent (java.beans.PropertyChangeEvent)349 ActionEvent (java.awt.event.ActionEvent)42 JPanel (javax.swing.JPanel)40 ActionListener (java.awt.event.ActionListener)36 ArrayList (java.util.ArrayList)32 JLabel (javax.swing.JLabel)27 BorderLayout (java.awt.BorderLayout)23 Test (org.junit.Test)22 List (java.util.List)21 Dimension (java.awt.Dimension)18 ProxyPropertyChangeListener (com.revolsys.beans.ProxyPropertyChangeListener)17 WeakPropertyChangeListener (com.revolsys.beans.WeakPropertyChangeListener)17 File (java.io.File)17 JComponent (javax.swing.JComponent)17 IOException (java.io.IOException)16 JButton (javax.swing.JButton)15 JScrollPane (javax.swing.JScrollPane)15 Component (java.awt.Component)14 GridBagConstraints (java.awt.GridBagConstraints)14