Example usage for java.beans PropertyChangeEvent getNewValue

List of usage examples for java.beans PropertyChangeEvent getNewValue

Introduction

In this page you can find the example usage for java.beans PropertyChangeEvent getNewValue.

Prototype

public Object getNewValue() 

Source Link

Document

Gets the new value for the property, expressed as an Object.

Usage

From source file:org.talend.designer.runprocess.ui.ProcessComposite.java

private void runProcessContextChanged(final PropertyChangeEvent evt) {
    if (isDisposed()) {
        return;/*  ww w .ja  v  a 2  s. c o  m*/
    }
    String propName = evt.getPropertyName();
    if (ProcessMessageManager.UPDATE_CONSOLE.equals(propName)) {
        processNextMessage();
    } else if (ProcessMessageManager.PROP_MESSAGE_ADD.equals(propName)
            || ProcessMessageManager.PROP_DEBUG_MESSAGE_ADD.equals(propName)) {
        IProcessMessage psMess = (IProcessMessage) evt.getNewValue();

        if (errorMessMap.size() <= CorePlugin.getDefault().getPreferenceStore()
                .getInt(ITalendCorePrefConstants.PREVIEW_LIMIT)) {
            if (!(LanguageManager.getCurrentLanguage().equals(ECodeLanguage.PERL))) {
                getAllErrorMess(psMess);
            } else {
                addPerlMark(psMess);
            }
        }
        appendToConsole(psMess);
    } else if (ProcessMessageManager.PROP_MESSAGE_CLEAR.equals(propName)) {
        newMessages.clear();
        messagesToDisplay.clear();
        getDisplay().asyncExec(new Runnable() {

            @Override
            public void run() {
                if (!consoleText.isDisposed()) {
                    consoleText.setText(""); //$NON-NLS-1$
                }
            }
        });
    } else if (RunProcessContext.PROP_MONITOR.equals(propName)) {
        // perfBtn.setSelection(((Boolean) evt.getNewValue()).booleanValue());
    } else if (RunProcessContext.TRACE_MONITOR.equals(propName)) {
        // traceBtn.setSelection(((Boolean) evt.getNewValue()).booleanValue());
    } else if (RunProcessContext.PROP_RUNNING.equals(propName)) {
        getDisplay().asyncExec(new Runnable() {

            @Override
            public void run() {
                if (isDisposed()) {
                    return;
                }
                boolean running = ((Boolean) evt.getNewValue()).booleanValue();
                setRunnable(!running);
                killBtn.setEnabled(running);
                while (!newMessages.isEmpty()) {
                    messagesToDisplay.add(newMessages.poll());
                }
                doAppendToConsole(messagesToDisplay);
                scrollToEnd();
                messagesToDisplay.clear();
            }
        });
    }
}

From source file:GUI.MainWindow.java

private void ImportScanScreenWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_ImportScanScreenWindowActivated

    Object obj = ImportFile.getModel().getElementAt(0);
    if (obj != null && obj instanceof ImportFile) {
        ImportFile imFile = (ImportFile) obj;
        System.out.println("Importing File: " + imFile.getAbsolutePath());
        ProgressBar.setIndeterminate(true);

        ImportScanTask ist = new ImportScanTask(ProgressBar, imFile, ImportScanScreen);
        ist.addPropertyChangeListener(new PropertyChangeListener() {
            @Override/*from  ww  w . j a v a2  s.  c om*/
            public void propertyChange(PropertyChangeEvent e) {
                if ("progress".equals(e.getPropertyName())) {
                    ProgressBar.setIndeterminate(false);
                    ProgressBar.setValue((Integer) e.getNewValue());
                    System.out.println("**: " + e.getNewValue());
                }
            }
        });
        ist.execute();

        try {
            DefaultMutableTreeNode new_root = ist.get();
            System.out.println("Import Finished");
            DefaultMutableTreeNode existing_root = (DefaultMutableTreeNode) VulnTree.getModel().getRoot();
            if (existing_root.getChildCount() == 0) {
                // The tree was empty so simply set the importe one into the model
                VulnTree.setModel(new DefaultTreeModel(new_root));
            } else {
                // The tree had existing children so we need to merge them
                VulnTree.setModel(new DefaultTreeModel(new TreeUtils().mergeTrees(existing_root, new_root)));
            }

        } catch (InterruptedException ex) {
            //Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println(ex.getStackTrace());
        } catch (ExecutionException ex) {
            //Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println(ex.getStackTrace());
        }

    }
}

From source file:nz.dataview.websyncclientgui.WebSYNCClientGUIView.java

public WebSYNCClientGUIView(SingleFrameApplication app) {
    super(app);/* www. ja v  a  2  s.co m*/

    // do this before anything else...
    try {
        client = new WebSYNC();
    } catch (java.io.IOException e) {
        // nonono!
    }
    // stuff that needs initialising before the components initialise
    proxyEnabled = client.getProxyEnabled();

    initComponents();

    System.setProperty("java.rmi.server.hostname", "localhost");

    // status bar initialization - message timeout, idle icon and busy animation, etc
    ResourceMap resourceMap = getResourceMap();
    int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
    progressBar.setVisible(false);

    // connecting action tasks to status bar via TaskMonitor
    TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
    taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

        public void propertyChange(java.beans.PropertyChangeEvent evt) {
            String propertyName = evt.getPropertyName();
            if ("started".equals(propertyName)) {
                progressBar.setVisible(true);
                progressBar.setIndeterminate(true);
            } else if ("done".equals(propertyName)) {
                progressBar.setVisible(false);
                progressBar.setValue(0);
            } else if ("message".equals(propertyName)) {
            } else if ("progress".equals(propertyName)) {
                int value = (Integer) (evt.getNewValue());
                progressBar.setVisible(true);
                progressBar.setIndeterminate(false);
                progressBar.setValue(value);
            } else if ("icon".equals(propertyName)) {
            } else if ("largeIcon".equals(propertyName)) {
                Icon icon = (Icon) evt.getNewValue();
                //          if (mainTabbedPane.getSelectedIndex() == 0) {
                connectPanelCurrentStatusOverviewLabel.setIcon(icon);
                //          }
            } else if ("largeMessage".equals(propertyName)) {
                String text = (String) (evt.getNewValue());
                if (text != null/* && mainTabbedPane.getSelectedIndex() == 0*/) {
                    connectPanelCurrentStatusOverviewLabel.setText(text);
                }
            } else if ("detailMessage".equals(propertyName)) {
                String text = (String) (evt.getNewValue());
                if (text != null
                        && (jScrollPane1.getVerticalScrollBar() == null
                                || !jScrollPane1.getVerticalScrollBar().getValueIsAdjusting())
                        && (jScrollPane1.getHorizontalScrollBar() == null
                                || !jScrollPane1.getHorizontalScrollBar().getValueIsAdjusting())) {
                    connectPanelCurrentStatusDetailsLabel.setText(text);
                }
            } else if ("isRunning".equals(propertyName)) {
                isRunning = ((Boolean) evt.getNewValue()).booleanValue();
                ResourceMap map = getResourceMap();
                String keyName = "runButton.toolTipText";
                if (!isRunning && isUp) {
                    keyName = "runButton.okToolTipText";
                }
                testConnectionButton.setEnabled(isUp && !isRunning);
            } else if ("isUp".equals(propertyName)) {
                isUp = ((Boolean) evt.getNewValue()).booleanValue();
                ResourceMap map = getResourceMap();
                String keyName = "testConnectionButton.toolTipText";
                if (isUp) {
                    // service is reachable (doesn't mean its running)
                    keyName = "testConnectionButton.okToolTipText";
                }
                testConnectionButton.setEnabled(isUp && !isRunning);
                testConnectionButton.setToolTipText(map.getString(keyName, new Object[0]));
                //          viewLogTextPane.setEnabled(isUp);
            } else if ("testIcon".equals(propertyName)) {
                Icon icon = (Icon) evt.getNewValue();
                testConnectionResult.setIcon(icon);
            } else if ("testMessage".equals(propertyName)) {
                String text = (String) evt.getNewValue();
                testConnectionResult.setText(text);
            } else if ("testFinished".equals(propertyName)) {
                testConnectionButton.setEnabled(isUp && !isRunning);
            } else if ("badAlertMessage".equals(propertyName)) {
                String text = (String) evt.getNewValue();
                if (text != null) {
                    showErrorDialog("Error", text);
                    WebSYNCClientGUIApp app = WebSYNCClientGUIApp.getApplication();
                    LogWriter worker = app.logWriteService(isUp, text, "WARN");
                    app.getContext().getTaskService().execute(worker);
                }
            } else if ("okAlertMessage".equals(propertyName)) {
                String text = (String) evt.getNewValue();
                if (text != null) {
                    showNoticeDialog("Confirmation", text);
                    WebSYNCClientGUIApp app = WebSYNCClientGUIApp.getApplication();
                    LogWriter worker = app.logWriteService(isUp, text, "INFO");
                    app.getContext().getTaskService().execute(worker);
                }
            } else if ("log".equals(propertyName)) {
                String text = (String) evt.getNewValue();
                String orig = viewLogTextPane.getText();
                String log = (StringUtils.isEmpty(text)
                        && (orig.equals(VIEW_LOG_INITIAL) || orig.equals(VIEW_LOG_EMPTY))) ? VIEW_LOG_EMPTY
                                : text;
                if (log.length() > MAX_LOG_VIEW_SIZE) {
                    int start = log.length() - MAX_LOG_VIEW_SIZE;
                    int end = log.length();
                    log = log.substring(start, end);
                }
                viewLogTextPane.setText(log);
            }
        }
    });

    // custom code

    // NetBeans uses the Swing Application Framework
    // Information on this framework is available here:
    // https://appframework.dev.java.net/
    // http://jsourcery.com/api/java.net/appframework/0.21/application/SingleFrameApplication.html
    // http://weblogs.java.net/blog/joconner/archive/2007/06/swing_applicati_1.html
    // https://appframework.dev.java.net/intro/index.html
    // API docs: https://appframework.dev.java.net/nonav/javadoc/AppFramework-1.03/index.html

    // Note: any tweaking of the main frame eg the size etc,
    // should be done in the WebSYNCClientGUIApp.properties file
    // located in src/nz/dataview/websyncclientgui/resources/   
    // (seems overly complex for what I'm trying to achieve, but I guess its convenient)

    initialConfigDone = false;
    initConfig();
    if (!client.isProxyConfigured())
        detectProxy();

    viewLogTimer = new Timer(3000, this);
    viewLogTimer.start();

    /*mainTabbedPane.getModel().addChangeListener(
    new ChangeListener() {
    public void stateChanged(ChangeEvent e) {
    javax.swing.DefaultSingleSelectionModel root = (javax.swing.DefaultSingleSelectionModel)e.getSource();
    if (root.getSelectedIndex() == 2) {
    viewLogTimer.start();
    } else {
    viewLogTimer.stop();
    }
    }
    }
    );*/

    statusTimer = new Timer(3 * 1000, this);
    statusTimer.start();

    browseUploadDirButton.addActionListener(this);
}

From source file:com.interface21.beans.BeanWrapperImpl.java

/**
 * Set an individual field./*from  w w  w .j  a v a 2s .  co m*/
 * All other setters go through this.
 * @param pv property value to use for update
 * @throws PropertyVetoException if a listeners throws a JavaBeans API veto
 * @throws BeansException if there's a low-level, fatal error
 */
public void setPropertyValue(PropertyValue pv) throws PropertyVetoException, BeansException {

    if (isNestedProperty(pv.getName())) {
        try {
            BeanWrapper nestedBw = getBeanWrapperForNestedProperty(pv.getName());
            nestedBw.setPropertyValue(new PropertyValue(getFinalPath(pv.getName()), pv.getValue()));
            return;
        } catch (NullValueInNestedPathException ex) {
            // Let this through
            throw ex;
        } catch (FatalBeanException ex) {
            // Error in the nested path
            throw new NotWritablePropertyException(pv.getName(), getWrappedClass());
        }
    }

    if (!isWritableProperty(pv.getName())) {
        throw new NotWritablePropertyException(pv.getName(), getWrappedClass());
    }

    PropertyDescriptor pd = getPropertyDescriptor(pv.getName());
    Method writeMethod = pd.getWriteMethod();
    Method readMethod = pd.getReadMethod();
    Object oldValue = null; // May stay null if it's not a readable property
    PropertyChangeEvent propertyChangeEvent = null;

    try {
        if (readMethod != null && eventPropagationEnabled) {
            // Can only find existing value if it's a readable property
            try {
                oldValue = readMethod.invoke(object, new Object[] {});
            } catch (Exception ex) {
                // The getter threw an exception, so we couldn't retrieve the old value.
                // We're not really interested in any exceptions at this point,
                // so we merely log the problem and leave oldValue null
                logger.warn("Failed to invoke getter '" + readMethod.getName()
                        + "' to get old property value before property change: getter probably threw an exception",
                        ex);
            }
        }

        // Old value may still be null
        propertyChangeEvent = createPropertyChangeEventWithTypeConversionIfNecessary(object, pv.getName(),
                oldValue, pv.getValue(), pd.getPropertyType());

        // May throw PropertyVetoException: if this happens the PropertyChangeSupport
        // class fires a reversion event, and we jump out of this method, meaning
        // the change was never actually made
        if (eventPropagationEnabled) {
            vetoableChangeSupport.fireVetoableChange(propertyChangeEvent);
        }

        if (pd.getPropertyType().isPrimitive() && (pv.getValue() == null || "".equals(pv.getValue()))) {
            throw new IllegalArgumentException("Invalid value [" + pv.getValue() + "] for property ["
                    + pd.getName() + "] of primitive type [" + pd.getPropertyType() + "]");
        }

        // Make the change
        if (logger.isDebugEnabled())
            logger.debug("About to invoke write method [" + writeMethod + "] on object of class '"
                    + object.getClass().getName() + "'");
        writeMethod.invoke(object, new Object[] { propertyChangeEvent.getNewValue() });
        if (logger.isDebugEnabled())
            logger.debug("Invoked write method [" + writeMethod + "] ok");

        // If we get here we've changed the property OK and can broadcast it
        if (eventPropagationEnabled)
            propertyChangeSupport.firePropertyChange(propertyChangeEvent);
    } catch (InvocationTargetException ex) {
        if (ex.getTargetException() instanceof PropertyVetoException)
            throw (PropertyVetoException) ex.getTargetException();
        if (ex.getTargetException() instanceof ClassCastException)
            throw new TypeMismatchException(propertyChangeEvent, pd.getPropertyType(), ex.getTargetException());
        throw new MethodInvocationException(ex.getTargetException(), propertyChangeEvent);
    } catch (IllegalAccessException ex) {
        throw new FatalBeanException("illegal attempt to set property [" + pv + "] threw exception", ex);
    } catch (IllegalArgumentException ex) {
        throw new TypeMismatchException(propertyChangeEvent, pd.getPropertyType(), ex);
    }
}

From source file:com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.java

@Override
public PropertyChangeListener createPropertyChangeListener(VFSJFileChooser fc) {
    return new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            String s = e.getPropertyName();

            if (s.equals(VFSJFileChooserConstants.SELECTED_FILE_CHANGED_PROPERTY)) {
                doSelectedFileChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.SELECTED_FILES_CHANGED_PROPERTY)) {
                doSelectedFilesChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.DIRECTORY_CHANGED_PROPERTY)) {
                doDirectoryChanged(e);//from w w  w. j  av  a2 s.  c  om
            } else if (s.equals(VFSJFileChooserConstants.FILE_FILTER_CHANGED_PROPERTY)) {
                doFilterChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.FILE_SELECTION_MODE_CHANGED_PROPERTY)) {
                doFileSelectionModeChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.ACCESSORY_CHANGED_PROPERTY)) {
                doAccessoryChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY)
                    || s.equals(VFSJFileChooserConstants.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY)) {
                doApproveButtonTextChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.DIALOG_TYPE_CHANGED_PROPERTY)) {
                doDialogTypeChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY)) {
                doApproveButtonMnemonicChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY)) {
                doControlButtonsChanged(e);
            } else if (s.equals("componentOrientation")) {
                ComponentOrientation o = (ComponentOrientation) e.getNewValue();
                VFSJFileChooser cc = (VFSJFileChooser) e.getSource();

                if (o != (ComponentOrientation) e.getOldValue()) {
                    cc.applyComponentOrientation(o);
                }
            } else if (s.equals("FileChooser.useShellFolder")) {
                updateUseShellFolder();
                doDirectoryChanged(e);
            } else if (s.equals("ancestor")) {
                if ((e.getOldValue() == null) && (e.getNewValue() != null)) {
                    // Ancestor was added, set initial focus
                    fileNameTextField.selectAll();
                    fileNameTextField.requestFocus();
                }
            }
        }
    };
}

From source file:org.talend.dataprofiler.core.ui.editor.analysis.MatchAnalysisDetailsPage.java

public void propertyChange(PropertyChangeEvent evt) {
    if (PluginConstant.ISDIRTY_PROPERTY.equals(evt.getPropertyName())) {
        setDirty(Boolean.TRUE);/*from   w  w  w .  j a  v a2s.c o m*/
    } else
    // when the user switch the matchrule tab, receive the event, here should change the table's column color
    // according to current tab
    if (MatchAnalysisConstant.MATCH_RULE_TAB_SWITCH.equals(evt.getPropertyName())) {
        // find the current rule tab, and change the color of the table column
        if (isMatchingKeyButtonPushed) {
            if (selectAlgorithmSection.isVSRMode()) {
                changeColumnColorByCurrentKeys(matchingKeySection.getCurrentMatchKeyColumn(), true);
            } else {
                changeColumnColorByCurrentKeys(matchAndSurvivorKeySection.getCurrentMatchKeyColumn(), true);
            }
        } else if (this.isBlockingKeyButtonPushed) {
            changeColumnColorByCurrentKeys(blockingKeySection.getSelectedColumnAsBlockKeys(), false);
        }
    } else if (MatchAnalysisConstant.NEED_REFRESH_DATA.equals(evt.getPropertyName())) {
        refreshDataFromConnection();
    } else if (MatchAnalysisConstant.DATA_SAMPLE_TABLE_COLUMN_SELECTION.equals(evt.getPropertyName())) {
        handleColumnSelectionChange();
    } else if (MatchAnalysisConstant.HIDE_GROUPS.equals(evt.getPropertyName())) {
        String minGrpSizeText = evt.getNewValue().toString();
        sampleTable.setMinGroupSize(Integer.valueOf(minGrpSizeText));
        if (selectAlgorithmSection.isVSRMode()) {
            matchingKeySection.refreshChart(false);
        } else {
            matchAndSurvivorKeySection.refreshChart(false);
        }
    }
}

From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java

public void propertyChange(PropertyChangeEvent e) {
    if (viewType == -1) {
        setViewType(VIEWTYPE_LIST);//from  w w  w. j  a  v a  2  s .  co m
    }

    String s = e.getPropertyName();

    if (s.equals(VFSJFileChooserConstants.SELECTED_FILE_CHANGED_PROPERTY)) {
        doSelectedFileChanged(e);
    } else if (s.equals(VFSJFileChooserConstants.SELECTED_FILES_CHANGED_PROPERTY)) {
        doSelectedFilesChanged(e);
    } else if (s.equals(VFSJFileChooserConstants.DIRECTORY_CHANGED_PROPERTY)) {
        doDirectoryChanged(e);
    } else if (s.equals(VFSJFileChooserConstants.FILE_FILTER_CHANGED_PROPERTY)) {
        doFilterChanged(e);
    } else if (s.equals(VFSJFileChooserConstants.FILE_SELECTION_MODE_CHANGED_PROPERTY)) {
        doFileSelectionModeChanged(e);
    } else if (s.equals(VFSJFileChooserConstants.MULTI_SELECTION_ENABLED_CHANGED_PROPERTY)) {
        doMultiSelectionChanged(e);
    } else if (s.equals(VFSJFileChooserConstants.CANCEL_SELECTION)) {
        applyEdit();
    } else if (s.equals("busy")) {
        setCursor((Boolean) e.getNewValue() ? waitCursor : null);
    } else if (s.equals("componentOrientation")) {
        ComponentOrientation o = (ComponentOrientation) e.getNewValue();
        VFSJFileChooser cc = (VFSJFileChooser) e.getSource();

        if (o != e.getOldValue()) {
            cc.applyComponentOrientation(o);
        }
    }
}

From source file:de.huxhorn.lilith.swing.ViewActions.java

public ViewActions(MainFrame mainFrame) {
    this.mainFrame = mainFrame;

    containerChangeListener = new ChangeListener() {
        /**/*  w  ww  . ja v  a  2  s . c  om*/
         * Invoked when the target of the listener has changed its state.
         *
         * @param e a ChangeEvent object
         */
        public void stateChanged(ChangeEvent e) {
            updateActions();
        }
    };

    containerPropertyChangeListener = new PropertyChangeListener() {

        /**
         * This method gets called when a bound property is changed.
         *
         * @param evt A PropertyChangeEvent object describing the event source
         *            and the property that has changed.
         */

        public void propertyChange(PropertyChangeEvent evt) {
            if (ViewContainer.SELECTED_EVENT_PROPERTY_NAME.equals(evt.getPropertyName())) {
                setEventWrapper((EventWrapper) evt.getNewValue());
            }

        }
    };

    keyStrokeActionMapping = new HashMap<KeyStroke, CopyToClipboardAction>();
    // ##### Menu Actions #####
    // File
    OpenMenuAction openMenuAction = new OpenMenuAction();
    clearRecentFilesAction = new ClearRecentFilesAction();
    OpenInactiveLogMenuAction openInactiveLogMenuAction = new OpenInactiveLogMenuAction();
    ImportMenuAction importMenuAction = new ImportMenuAction();
    exportMenuAction = new ExportMenuAction();
    CleanAllInactiveLogsMenuAction cleanAllInactiveLogsMenuAction = new CleanAllInactiveLogsMenuAction();
    preferencesMenuAction = new PreferencesMenuAction();
    ExitMenuAction exitMenuAction = new ExitMenuAction();

    // Edit
    showUnfilteredEventAction = new ShowUnfilteredEventAction();
    gotoSourceAction = new GotoSourceAction();
    copySelectionAction = new CopySelectionAction();
    copyEventAction = new CopyToClipboardAction(new EventFormatter());
    copyLoggingActions = new ArrayList<CopyToClipboardAction>();
    copyLoggingActions.add(new CopyToClipboardAction(new EventJsonFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new EventXmlFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingMessageFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingMessagePatternFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingLoggerNameFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingThrowableFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingCallStackFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingCallLocationFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingMarkerFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingMdcFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingNdcFormatter()));
    copyAccessActions = new ArrayList<CopyToClipboardAction>();
    copyAccessActions.add(new CopyToClipboardAction(new AccessUriFormatter()));

    prepareClipboardActions(copyLoggingActions, keyStrokeActionMapping);
    prepareClipboardActions(copyAccessActions, keyStrokeActionMapping);

    // Search
    findMenuAction = new FindMenuAction();
    findPreviousAction = new FindPreviousAction();
    findNextAction = new FindNextAction();
    findPreviousActiveAction = new FindPreviousActiveAction();
    findNextActiveAction = new FindNextActiveAction();
    resetFindAction = new ResetFindAction();

    // View
    scrollToBottomMenuAction = new ScrollToBottomMenuAction();
    pauseMenuAction = new PauseMenuAction();
    clearMenuAction = new ClearMenuAction();
    attachMenuAction = new AttachMenuAction();
    disconnectMenuAction = new DisconnectMenuAction();

    focusMessageAction = new FocusMessageAction();
    focusEventsAction = new FocusEventsAction();

    //statisticsMenuAction = new StatisticsMenuAction();
    editSourceNameMenuAction = new EditSourceNameMenuAction();
    saveLayoutAction = new SaveLayoutAction();
    resetLayoutAction = new ResetLayoutAction();
    saveConditionMenuAction = new SaveConditionMenuAction();

    zoomInMenuAction = new ZoomInMenuAction();
    zoomOutMenuAction = new ZoomOutMenuAction();
    resetZoomMenuAction = new ResetZoomMenuAction();

    previousTabAction = new PreviousTabAction();
    nextTabAction = new NextTabAction();
    closeFilterAction = new CloseFilterAction();
    closeOtherFiltersAction = new CloseOtherFiltersAction();
    closeAllFiltersAction = new CloseAllFiltersAction();

    // Window
    ShowTaskManagerAction showTaskManagerAction = new ShowTaskManagerAction();
    closeAllAction = new CloseAllAction();
    closeOtherAction = new CloseOtherAction();
    minimizeAllAction = new MinimizeAllAction();
    minimizeAllOtherAction = new MinimizeAllOtherAction();
    removeInactiveAction = new RemoveInactiveAction();
    //clearAndRemoveInactiveAction=new ClearAndRemoveInactiveAction();

    // Help
    KeyboardHelpAction keyboardHelpAction = new KeyboardHelpAction();
    ShowLoveMenuAction showLoveMenuAction = new ShowLoveMenuAction();
    TipOfTheDayAction tipOfTheDayAction = new TipOfTheDayAction();
    DebugAction debugAction = new DebugAction();
    aboutAction = new AboutAction();
    CheckForUpdateAction checkForUpdateAction = new CheckForUpdateAction();
    TroubleshootingAction troubleshootingAction = new TroubleshootingAction();

    // ##### ToolBar Actions #####
    scrollToBottomToolBarAction = new ScrollToBottomToolBarAction();
    pauseToolBarAction = new PauseToolBarAction();
    clearToolBarAction = new ClearToolBarAction();
    findToolBarAction = new FindToolBarAction();
    //statisticsToolBarAction = new StatisticsToolBarAction();
    attachToolBarAction = new AttachToolBarAction();
    disconnectToolBarAction = new DisconnectToolBarAction();

    showTaskManagerItem = new JMenuItem(showTaskManagerAction);
    closeAllItem = new JMenuItem(closeAllAction);
    closeAllOtherItem = new JMenuItem(closeOtherAction);
    minimizeAllItem = new JMenuItem(minimizeAllAction);
    minimizeAllOtherItem = new JMenuItem(minimizeAllOtherAction);
    removeInactiveItem = new JMenuItem(removeInactiveAction);
    //clearAndRemoveInactiveItem = new JMenuItem(clearAndRemoveInactiveAction);

    toolbar = new JToolBar(SwingConstants.HORIZONTAL);
    toolbar.setFloatable(false);

    scrollToBottomButton = new JToggleButton(scrollToBottomToolBarAction);
    toolbar.add(scrollToBottomButton);

    JButton pauseButton = new JButton(pauseToolBarAction);
    toolbar.add(pauseButton);

    JButton clearButton = new JButton(clearToolBarAction);
    toolbar.add(clearButton);

    JButton findButton = new JButton(findToolBarAction);
    toolbar.add(findButton);

    JButton disconnectButton = new JButton(disconnectToolBarAction);
    toolbar.add(disconnectButton);

    toolbar.addSeparator();

    //JButton statisticsButton = new JButton(statisticsToolBarAction);
    //toolbar.add(statisticsButton);
    //toolbar.addSeparator();

    JButton attachButton = new JButton(attachToolBarAction);
    toolbar.add(attachButton);

    toolbar.addSeparator();

    PreferencesToolBarAction preferencesToolBarAction = new PreferencesToolBarAction();
    JButton preferencesButton = new JButton(preferencesToolBarAction);
    toolbar.add(preferencesButton);

    toolbar.addSeparator();

    ShowLoveToolbarAction showLoveToolbarAction = new ShowLoveToolbarAction();
    JButton showLoveButton = new JButton(showLoveToolbarAction);
    toolbar.add(showLoveButton);

    recentFilesMenu = new JMenu("Recent Files");

    Application app = mainFrame.getApplication();

    menubar = new JMenuBar();

    // File
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('f');
    fileMenu.add(openMenuAction);
    fileMenu.add(recentFilesMenu);
    fileMenu.add(openInactiveLogMenuAction);
    fileMenu.add(cleanAllInactiveLogsMenuAction);
    fileMenu.add(importMenuAction);
    fileMenu.add(exportMenuAction);
    if (!app.isMac()) {
        fileMenu.addSeparator();
        fileMenu.add(preferencesMenuAction);
        fileMenu.addSeparator();
        fileMenu.add(exitMenuAction);
    }

    // Edit
    editMenu = new JMenu("Edit");
    editMenu.setMnemonic('e');
    editMenu.add(copySelectionAction);
    editMenu.addSeparator();
    editMenu.add(copyEventAction);
    editMenu.addSeparator();
    for (CopyToClipboardAction current : copyLoggingActions) {
        editMenu.add(current);
    }
    editMenu.addSeparator();
    for (CopyToClipboardAction current : copyAccessActions) {
        editMenu.add(current);
    }
    editMenu.addSeparator();
    customCopyMenu = new JMenu("Custom copy");
    customCopyPopupMenu = new JMenu("Custom copy");
    editMenu.add(customCopyMenu);
    editMenu.addSeparator();
    PasteStackTraceElementAction pasteStackTraceElementAction = new PasteStackTraceElementAction();
    editMenu.add(pasteStackTraceElementAction);

    // Search
    searchMenu = new JMenu("Search");
    searchMenu.setMnemonic('s');
    searchMenu.add(findMenuAction);
    searchMenu.add(resetFindAction);
    searchMenu.add(findPreviousAction);
    searchMenu.add(findNextAction);
    searchMenu.add(findPreviousActiveAction);
    searchMenu.add(findNextActiveAction);
    searchMenu.addSeparator();
    searchMenu.add(saveConditionMenuAction);
    searchMenu.addSeparator();

    focusMenu = new FocusMenu(mainFrame.getApplicationPreferences());
    excludeMenu = new ExcludeMenu(mainFrame.getApplicationPreferences());
    searchMenu.add(focusMenu);
    searchMenu.add(excludeMenu);

    // View
    viewMenu = new JMenu("View");
    viewMenu.setMnemonic('v');
    viewMenu.add(scrollToBottomMenuAction);
    viewMenu.add(pauseMenuAction);
    viewMenu.add(clearMenuAction);
    viewMenu.add(attachMenuAction);
    viewMenu.add(disconnectMenuAction);
    viewMenu.add(focusEventsAction);
    viewMenu.add(focusMessageAction);
    //viewMenu.add(statisticsMenuAction);
    viewMenu.add(editSourceNameMenuAction);
    viewMenu.addSeparator();
    viewMenu.add(zoomInMenuAction);
    viewMenu.add(zoomOutMenuAction);
    viewMenu.add(resetZoomMenuAction);
    viewMenu.addSeparator();
    JMenu layoutMenu = new JMenu("Layout");
    columnsMenu = new JMenu("Columns");
    layoutMenu.add(columnsMenu);
    layoutMenu.addSeparator();
    layoutMenu.add(saveLayoutAction);
    layoutMenu.add(resetLayoutAction);
    viewMenu.add(layoutMenu);
    viewMenu.addSeparator();
    viewMenu.add(previousTabAction);
    viewMenu.add(nextTabAction);
    viewMenu.addSeparator();
    viewMenu.add(closeFilterAction);
    viewMenu.add(closeOtherFiltersAction);
    viewMenu.add(closeAllFiltersAction);

    // Window
    windowMenu = new JMenu("Window");
    windowMenu.setMnemonic('w');

    // Help
    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic('h');

    helpMenu.add(keyboardHelpAction);
    helpMenu.add(showLoveMenuAction);
    helpMenu.add(tipOfTheDayAction);
    helpMenu.add(checkForUpdateAction);
    helpMenu.add(troubleshootingAction);
    helpMenu.addSeparator();
    helpMenu.add(debugAction);
    if (!app.isMac()) {
        helpMenu.addSeparator();
        helpMenu.add(aboutAction);
    }

    menubar.add(fileMenu);
    menubar.add(editMenu);
    menubar.add(searchMenu);
    menubar.add(viewMenu);
    menubar.add(windowMenu);
    menubar.add(helpMenu);

    updateWindowMenu();
    updateRecentFiles();
    updateActions();
}

From source file:uk.ac.lkl.cram.ui.chart.HoursChartMaker.java

/**
 * Create a dataset from the module/*from   ww  w.  j  a v a  2 s .c  o m*/
 * @return a category dataset that is used to produce a stacked bar chart
 */
@Override
protected CategoryDataset createDataSet() {
    //Create a dataset to hold the data
    final DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset();
    //populate the dataset with the data
    populateDataset(categoryDataset, module);
    //Create a listener, which repopulates the dataset when anything changes
    final PropertyChangeListener presentationListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent pce) {
            //LOGGER.info("event propertyName: " + pce.getPropertyName() + " newValue: " + pce.getNewValue());
            populateDataset(categoryDataset, module);
        }
    };
    //Add the listener to each of the module presentations
    for (ModulePresentation modulePresentation : module.getModulePresentations()) {
        //Listen for when the number of home or overseas students changes
        //This means when the number of home or overseas students changes, the dataset will be repopulated
        modulePresentation.addPropertyChangeListener(ModulePresentation.PROP_HOME_STUDENT_COUNT,
                presentationListener);
        modulePresentation.addPropertyChangeListener(ModulePresentation.PROP_OVERSEAS_STUDENT_COUNT,
                presentationListener);

        //Add the listener to the support time and preparation time of 
        //each of the module's tlaLineItems, for each presentation
        //This means that whenever a support time or a preparation time changes,
        //or its activity changes, the listener is triggered
        //Causing the dataset to be repopulated
        //Also add the listener to the activity for the tlaLineItem so that
        //when the tutor group size changes, the chart is updated
        for (TLALineItem lineItem : module.getTLALineItems()) {
            //LOGGER.info("adding listener to : " + lineItem.getName());
            SupportTime st = lineItem.getSupportTime(modulePresentation);
            st.addPropertyChangeListener(presentationListener);
            PreparationTime pt = lineItem.getPreparationTime(modulePresentation);
            pt.addPropertyChangeListener(presentationListener);
            lineItem.getActivity().addPropertyChangeListener(TLActivity.PROP_MAX_GROUP_SIZE,
                    presentationListener);
        }
        //Add the listener to the support time of each of the module's 
        //module line items, for each presentation
        for (ModuleLineItem lineItem : module.getModuleItems()) {
            //LOGGER.info("adding listener to : " + lineItem.getName());
            SupportTime st = lineItem.getSupportTime(modulePresentation);
            st.addPropertyChangeListener(presentationListener);
        }
    }

    //Add a listener to the module, listening for changes where a tlaLineItem is added or removed
    module.addPropertyChangeListener(Module.PROP_TLA_LINEITEM, new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent pce) {
            //A tlaLineItem has been added or removed
            if (pce instanceof IndexedPropertyChangeEvent) {
                //LOGGER.info("indexed change: " + pce);
                if (pce.getOldValue() != null) {
                    //This has been removed
                    TLALineItem lineItem = (TLALineItem) pce.getOldValue();
                    //So remove the listener from the preparation and support time
                    //for each presentation of this line item
                    //LOGGER.info("removing listeners from: " + lineItem.getName());
                    for (ModulePresentation modulePresentation : module.getModulePresentations()) {
                        SupportTime st = lineItem.getSupportTime(modulePresentation);
                        st.removePropertyChangeListener(presentationListener);
                        PreparationTime pt = lineItem.getPreparationTime(modulePresentation);
                        pt.removePropertyChangeListener(presentationListener);
                    }
                    //Also remove the listener from the activity
                    lineItem.removePropertyChangeListener(TLActivity.PROP_MAX_GROUP_SIZE, presentationListener);
                }
                if (pce.getNewValue() != null) {
                    //This has been added
                    TLALineItem lineItem = (TLALineItem) pce.getNewValue();
                    //So add the listener to the preparation and support time
                    //For each presentation of this line item
                    //LOGGER.info("adding listeners to: " + lineItem);
                    for (ModulePresentation modulePresentation : module.getModulePresentations()) {
                        SupportTime st = lineItem.getSupportTime(modulePresentation);
                        st.addPropertyChangeListener(presentationListener);
                        PreparationTime pt = lineItem.getPreparationTime(modulePresentation);
                        pt.addPropertyChangeListener(presentationListener);
                    }
                    //Also add the listener to the activity
                    lineItem.addPropertyChangeListener(TLActivity.PROP_MAX_GROUP_SIZE, presentationListener);
                }
            }
            //Assume the dataset is now out of date
            populateDataset(categoryDataset, module);
        }
    });
    //Do the same as above for module line items
    module.addPropertyChangeListener(Module.PROP_MODULE_LINEITEM, new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent pce) {
            if (pce instanceof IndexedPropertyChangeEvent) {
                //LOGGER.info("indexed change: " + pce);
                if (pce.getOldValue() != null) {
                    //This has been removed
                    ModuleLineItem lineItem = (ModuleLineItem) pce.getOldValue();
                    //LOGGER.info("removing listeners from: " + lineItem.getName());
                    for (ModulePresentation modulePresentation : module.getModulePresentations()) {
                        SupportTime st = lineItem.getSupportTime(modulePresentation);
                        st.removePropertyChangeListener(presentationListener);
                    }
                }
                if (pce.getNewValue() != null) {
                    //This has been added
                    ModuleLineItem lineItem = (ModuleLineItem) pce.getNewValue();
                    //LOGGER.info("adding listeners to: " + lineItem);
                    for (ModulePresentation modulePresentation : module.getModulePresentations()) {
                        SupportTime st = lineItem.getSupportTime(modulePresentation);
                        st.addPropertyChangeListener(presentationListener);
                    }
                }
            }
            populateDataset(categoryDataset, module);
        }
    });
    //Add the listner to be triggered if the tutor group size of the module changes
    module.addPropertyChangeListener(Module.PROP_GROUP_SIZE, presentationListener);
    return categoryDataset;
}

From source file:net.sf.dvstar.transmission.TransmissionView.java

/**
 * Main class for visual application//  w  w  w .j av a  2  s  . c  o m
 * @param app Parent application framework
 */
public TransmissionView(SingleFrameApplication app) {
    super(app);

    this.singleFrameApplication = app;
    this.transmissionView = this;

    initGlobals();

    initLogger();

    initComponents();

    initLocale();

    initTimers();

    ResourceMap resourceMap = getResourceMap();
    idleIcon = resourceMap.getIcon("StatusBar.idleIcon");

    statusAnimationLabel.setIcon(idleIcon);
    progressBar.setVisible(false);

    piecesGraph = new PiecesGraph();
    plPieces.add(piecesGraph, BorderLayout.CENTER);

    modelTorrentsList = new TorrentsTableModel(this);

    TorrentsTableModel.setPreferredColumnWidths(tblTorrentList);

    setRefButtonsState(connectedServer);
    setAllButtonsState(connectedServer);

    tblTorrentList.setModel(modelTorrentsList);

    /**
     * Set sorter to table
     */
    //!!tblTorrentList.setAutoCreateRowSorter(true);
    TorrentListRowSorter rorrentListRowSorter = new TorrentListRowSorter(
            (TorrentsTableModel) tblTorrentList.getModel());
    tblTorrentList.setRowSorter(rorrentListRowSorter);

    PopupListener popupListener = new PopupListener();
    tblTorrentList.addMouseListener(popupListener);
    tblTorrentList.getTableHeader().addMouseListener(popupListener);
    tblTorrentList.setRowSelectionAllowed(true);
    tblTorrentList.tableChanged(new TableModelEvent(modelTorrentsList));

    jTabbedPane1.setIconAt(0, globalResourceMap.getIcon("tpInfo.icon0"));
    jTabbedPane1.setIconAt(1, globalResourceMap.getIcon("tpInfo.icon1"));
    jTabbedPane1.setIconAt(2, globalResourceMap.getIcon("tpInfo.icon2"));
    jTabbedPane1.setIconAt(3, globalResourceMap.getIcon("tpInfo.icon3"));
    jTabbedPane1.setIconAt(4, globalResourceMap.getIcon("tpInfo.icon4"));

    // connecting action tasks to status bar via TaskMonitor
    TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
    taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

        @Override
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
            String propertyName = evt.getPropertyName();
            if ("started".equals(propertyName)) {
                if (!busyIconTimer.isRunning()) {
                    statusAnimationLabel.setIcon(busyIcons[0]);
                    busyIconIndex = 0;
                    busyIconTimer.start();
                }
                progressBar.setVisible(true);
                progressBar.setIndeterminate(true);
            } else if ("done".equals(propertyName)) {
                busyIconTimer.stop();
                statusAnimationLabel.setIcon(idleIcon);
                progressBar.setVisible(false);
                progressBar.setValue(0);
            } else if ("message".equals(propertyName)) {
                String text = (String) (evt.getNewValue());
                statusMessageLabel.setText((text == null) ? "" : text);
                messageTimer.restart();
            } else if ("progress".equals(propertyName)) {
                int value = (Integer) (evt.getNewValue());
                progressBar.setVisible(true);
                progressBar.setIndeterminate(false);
                progressBar.setValue(value);
            }
        }
    });

    //setAdditionalButtons();

    //Whenever filterText changes, invoke newFilter.
    tfFindItem.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void changedUpdate(DocumentEvent e) {
            setTorrentListFilter();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            setTorrentListFilter();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            setTorrentListFilter();
        }
    });

    checkNavigator();
    updateInfoBox(-1);
    btConnect.grabFocus();

}