Example usage for org.eclipse.jface.action Action addPropertyChangeListener

List of usage examples for org.eclipse.jface.action Action addPropertyChangeListener

Introduction

In this page you can find the example usage for org.eclipse.jface.action Action addPropertyChangeListener.

Prototype

@Override
    public void addPropertyChangeListener(final IPropertyChangeListener listener) 

Source Link

Usage

From source file:de.fhg.igd.swingrcp.ActionAdapter.java

License:Open Source License

/**
 * Creates an ActionAdapter//from  w ww .  j a v a 2 s .c om
 * 
 * @param action the internal swing action
 * @param style the action style
 */
public ActionAdapter(final javax.swing.Action action, int style) {
    super(null, style);

    if (action == null)
        throw new IllegalArgumentException();

    this.action = action;

    this.display = Display.getCurrent();
    if (this.display == null)
        throw new IllegalArgumentException("ActionAdapter has to be created in display thread");

    action.addPropertyChangeListener(this);

    loadImage();
}

From source file:eu.esdihumboldt.hale.ui.util.swing.RcpActionAdapter.java

License:Open Source License

/**
 * Creates an ActionAdapter/*from w w  w . j a va 2  s  .c  o  m*/
 * 
 * @param action the Swing action to wrap
 * @param style the JFace action style
 * 
 * @see Action#Action(String, int)
 */
public RcpActionAdapter(final javax.swing.Action action, int style) {
    super(null, style);

    if (action == null)
        throw new IllegalArgumentException();

    this.action = action;

    this.display = Display.getCurrent();
    if (this.display == null)
        throw new IllegalArgumentException("ActionAdapter has to be created in display thread"); //$NON-NLS-1$

    action.addPropertyChangeListener(this);

    loadImage();
}

From source file:org.eclipse.emf.emfstore.client.ui.views.emfstorebrowser.dialogs.admin.GroupTabContent.java

License:Open Source License

/**
 * {@inheritDoc}/*from  ww w. jav  a 2 s  .c  om*/
 * 
 * @see org.eclipse.emf.emfstore.client.ui.views.emfstorebrowser.dialogs.admin.TabContent#initActions()
 */
@Override
protected List<Action> initActions() {

    Action createNewGroup = new Action("Create new group") {
        @Override
        public void run() {
            try {
                getAdminBroker().createGroup("New Group");
            } catch (EmfStoreException e) {
                EMFStoreMessageDialog.showExceptionDialog(e);
            }
            getTableViewer().refresh();
            getForm().getTableViewer().refresh();
        }
    };

    createNewGroup.setImageDescriptor(Activator.getImageDescriptor("icons/Group.gif"));
    createNewGroup.setToolTipText("Create new group");

    Action deleteGroup = new Action("Delete group") {
        @Override
        public void run() {
            IStructuredSelection selection = (IStructuredSelection) getTableViewer().getSelection();
            Iterator<?> iterator = selection.iterator();
            while (iterator.hasNext()) {
                ACGroup ou = (ACGroup) iterator.next();
                if (ou == null) {
                    return;
                }
                try {
                    getAdminBroker().deleteGroup(ou.getId());
                } catch (EmfStoreException e) {
                    EMFStoreMessageDialog.showExceptionDialog(e);
                }

                if (getForm().getCurrentInput() instanceof ACOrgUnit
                        && getForm().getCurrentInput().equals(ou)) {
                    getForm().setInput(null);
                }
            }
            getTableViewer().refresh();
        }
    };

    deleteGroup.setImageDescriptor(Activator.getImageDescriptor("icons/delete.gif"));
    deleteGroup.setToolTipText("Delete group");

    Action importOrgUnit = new AcUserImportAction(getAdminBroker());
    importOrgUnit.addPropertyChangeListener(this);

    return Arrays.asList(createNewGroup, deleteGroup, importOrgUnit);
}

From source file:org.eclipse.emf.emfstore.client.ui.views.emfstorebrowser.dialogs.admin.UserTabContent.java

License:Open Source License

/**
 * {@inheritDoc}//  w w  w  .  j av  a  2  s . c om
 * 
 * @see org.eclipse.emf.emfstore.client.ui.views.emfstorebrowser.dialogs.admin.TabContent#initActions()
 */
@Override
protected List<Action> initActions() {
    Action createNewUser = new Action("Create new user") {
        @Override
        public void run() {
            try {
                getAdminBroker().createUser("New User");
            } catch (EmfStoreException e) {
                EMFStoreMessageDialog.showExceptionDialog(e);
            }
            getTableViewer().refresh();
            getForm().getTableViewer().refresh();

        }
    };
    createNewUser.setImageDescriptor(Activator.getImageDescriptor("icons/user.png"));
    createNewUser.setToolTipText("Create new user");

    Action deleteUser = new DeleteUserAction("Delete user");
    deleteUser.setImageDescriptor(Activator.getImageDescriptor("icons/delete.gif"));
    deleteUser.setToolTipText("Delete user");

    Action importOrgUnit = new AcUserImportAction(getAdminBroker());
    importOrgUnit.addPropertyChangeListener(this);

    return Arrays.asList(createNewUser, deleteUser, importOrgUnit);
}

From source file:org.eclipse.emf.emfstore.internal.client.ui.dialogs.admin.GroupTabContent.java

License:Open Source License

/**
 * {@inheritDoc}/*from w ww .  j ava  2  s  . com*/
 * 
 * @see org.eclipse.emf.emfstore.internal.client.ui.dialogs.admin.TabContent#initActions()
 */
@Override
protected List<Action> initActions() {

    final Action createNewGroup = new CreateGroupAction(getAdminBroker(), getTableViewer(), getForm());
    createNewGroup.setImageDescriptor(Activator.getImageDescriptor(GROUP_ICON));
    createNewGroup.setToolTipText(Messages.GroupTabContent_Create_New_Group);

    final Action deleteGroup = new DeleteGroupAction(getAdminBroker(), getTableViewer(), getForm());
    deleteGroup.setImageDescriptor(Activator.getImageDescriptor(DELETE_ICON));
    deleteGroup.setToolTipText(Messages.GroupTabContent_Delete_Group);

    final Action importOrgUnit = new AcUserImportAction(getAdminBroker());
    importOrgUnit.addPropertyChangeListener(this);

    return Arrays.asList(createNewGroup, deleteGroup, importOrgUnit);
}

From source file:org.eclipse.emf.emfstore.internal.client.ui.dialogs.admin.UserTabContent.java

License:Open Source License

/**
 * {@inheritDoc}/*  w  w w . j a va 2s  .  com*/
 * 
 * @see org.eclipse.emf.emfstore.internal.client.ui.dialogs.admin.TabContent#initActions()
 */
@Override
protected List<Action> initActions() {
    final Action createNewUserAction = new CreateUserAction(getAdminBroker(), getTableViewer(), getForm());
    createNewUserAction.setImageDescriptor(Activator.getImageDescriptor(USER_ICON));
    createNewUserAction.setToolTipText(Messages.UserTabContent_Create_New_User);

    final Action deleteUserAction = new DeleteUserAction(getAdminBroker(), getTableViewer(), getForm());
    deleteUserAction.setImageDescriptor(Activator.getImageDescriptor(DELETE_ICON));
    deleteUserAction.setToolTipText(Messages.UserTabContent_Delete_User);

    final Action importOrgUnitAction = new AcUserImportAction(getAdminBroker());
    importOrgUnitAction.addPropertyChangeListener(this);

    final Action changePassword = new ChangePasswordAction();
    changePassword.setImageDescriptor(Activator.getImageDescriptor(LOCK_ICON));
    changePassword.setToolTipText(Messages.UserTabContent_Change_Password);

    final List<Action> actions = new ArrayList<Action>();
    actions.add(createNewUserAction);
    actions.add(deleteUserAction);
    actions.add(importOrgUnitAction);

    final ESExtensionPoint showPasswordControls = new ESExtensionPoint(
            "org.eclipse.emf.emfstore.client.ui.showPasswordControls"); //$NON-NLS-1$

    if (showPasswordControls.getBoolean("enabled", false)) { //$NON-NLS-1$
        actions.add(changePassword);
    }

    return actions;
}

From source file:org.eclipse.emf.emfstore.internal.client.ui.views.emfstorebrowser.dialogs.admin.GroupTabContent.java

License:Open Source License

/**
 * {@inheritDoc}// ww  w  .ja  v a 2s  .co m
 * 
 * @see org.eclipse.emf.emfstore.internal.client.ui.views.emfstorebrowser.dialogs.admin.TabContent#initActions()
 */
@Override
protected List<Action> initActions() {

    Action createNewGroup = new Action("Create new group") {
        @Override
        public void run() {
            try {
                getAdminBroker().createGroup("New Group");
            } catch (ESException e) {
                EMFStoreMessageDialog.showExceptionDialog(e);
            }
            getTableViewer().refresh();
            getForm().getTableViewer().refresh();
        }
    };

    createNewGroup.setImageDescriptor(Activator.getImageDescriptor("icons/Group.gif"));
    createNewGroup.setToolTipText("Create new group");

    Action deleteGroup = new Action("Delete group") {
        @Override
        public void run() {
            IStructuredSelection selection = (IStructuredSelection) getTableViewer().getSelection();
            Iterator<?> iterator = selection.iterator();
            while (iterator.hasNext()) {
                ACGroup ou = (ACGroup) iterator.next();
                if (ou == null) {
                    return;
                }
                try {
                    getAdminBroker().deleteGroup(ou.getId());
                } catch (ESException e) {
                    EMFStoreMessageDialog.showExceptionDialog(e);
                }

                if (getForm().getCurrentInput() instanceof ACOrgUnit
                        && getForm().getCurrentInput().equals(ou)) {
                    getForm().setInput(null);
                }
            }
            getTableViewer().refresh();
        }
    };

    deleteGroup.setImageDescriptor(Activator.getImageDescriptor("icons/delete.gif"));
    deleteGroup.setToolTipText("Delete group");

    Action importOrgUnit = new AcUserImportAction(getAdminBroker());
    importOrgUnit.addPropertyChangeListener(this);

    return Arrays.asList(createNewGroup, deleteGroup, importOrgUnit);
}

From source file:org.eclipse.emf.emfstore.internal.client.ui.views.emfstorebrowser.dialogs.admin.UserTabContent.java

License:Open Source License

/**
 * {@inheritDoc}// w  w w .  ja  v a 2 s  . c om
 * 
 * @see org.eclipse.emf.emfstore.internal.client.ui.views.emfstorebrowser.dialogs.admin.TabContent#initActions()
 */
@Override
protected List<Action> initActions() {
    final Action createNewUser = new Action("Create new user") {
        @Override
        public void run() {
            try {
                if (userExists(NEW_USER_NAME)) {
                    MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "User already exists",
                            "A user with the given name '" + NEW_USER_NAME + "' already exists.");
                } else {
                    getAdminBroker().createUser(NEW_USER_NAME);
                }
            } catch (final ESException e) {
                EMFStoreMessageDialog.showExceptionDialog(e);
            }
            getTableViewer().refresh();
            getForm().getTableViewer().refresh();

        }
    };
    createNewUser.setImageDescriptor(Activator.getImageDescriptor("icons/user.png"));
    createNewUser.setToolTipText("Create new user");

    final Action deleteUser = new DeleteUserAction("Delete user");
    deleteUser.setImageDescriptor(Activator.getImageDescriptor("icons/delete.gif"));
    deleteUser.setToolTipText("Delete user");

    final Action importOrgUnit = new AcUserImportAction(getAdminBroker());
    importOrgUnit.addPropertyChangeListener(this);

    final Action changePassword = new ChangePasswordAction("Change password of selected user");
    changePassword.setImageDescriptor(Activator.getImageDescriptor("icons/lock.png"));
    changePassword.setToolTipText("Change password of selected user");

    return Arrays.asList(createNewUser, deleteUser, importOrgUnit, changePassword);
}

From source file:org.eclipse.rap.demo.presentation.ActionBarButton.java

License:Open Source License

ActionBarButton(Action action, Composite actionBar) {
    this.action = action;
    this.label = new Label(actionBar, SWT.NONE);
    this.display = label.getDisplay();
    label.setText(action.getText());// ww w .j  a v  a  2  s .  c  om
    FontData fontData = label.getFont().getFontData()[0];
    int height = fontData.getHeight() + 2;
    label.setFont(new Font(display, fontData.getName(), height, fontData.getStyle()));
    label.pack();
    action.addPropertyChangeListener(this);
    adjustEnablement(action.isEnabled());
}