Example usage for org.eclipse.jface.dialogs IDialogConstants OK_ID

List of usage examples for org.eclipse.jface.dialogs IDialogConstants OK_ID

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants OK_ID.

Prototype

int OK_ID

To view the source code for org.eclipse.jface.dialogs IDialogConstants OK_ID.

Click Source Link

Document

Button id for an "Ok" button (value 0).

Usage

From source file:com.clustercontrol.accesscontrol.view.action.ModifyPasswordAction.java

License:Open Source License

/**
 * []????????<BR>//from   w w  w.  ja va2 s  .  co m
 * []?????
 * <p>
 * <ol>
 * <li>[]??????ID????</li>
 * <li>[]???</li>
 * <li>[]?????</li>
 * <li>????</li>
 * </ol>
 *
 * @see org.eclipse.core.commands.IHandler#execute
 * @see com.clustercontrol.accesscontrol.dialog.ModifyPasswordDialog
 * @see com.clustercontrol.accesscontrol.view.UserListView
 * @see com.clustercontrol.accesscontrol.action.ModifyPassword#change(String, String)
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ???
    this.viewPart = HandlerUtil.getActivePart(event);

    // ??????UID?
    UserListView view = null;
    try {
        view = (UserListView) this.viewPart.getAdapter(UserListView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

    if (view == null) {
        m_log.info("execute: view is null");
        return null;
    }

    StructuredSelection selection = (StructuredSelection) view.getComposite().getTableViewer().getSelection();

    List<?> list = (List<?>) selection.getFirstElement();
    String managerName = null;
    String uid = null;
    if (list != null) {
        managerName = (String) list.get(GetUserListTableDefine.MANAGER_NAME);
        uid = (String) list.get(GetUserListTableDefine.UID);
    }

    if (uid != null) {
        // ?
        ModifyPasswordDialog dialog = new ModifyPasswordDialog(this.viewPart.getSite().getShell());
        dialog.setUserid(uid);

        // ???????????
        if (dialog.open() == IDialogConstants.OK_ID) {
            String password = dialog.getPassword();

            // ?????
            try {
                boolean isLoginUser = EndpointManager.hasLoginUser(managerName, uid);

                //String passwordHash = CryptoUtil.createPasswordHash("MD5", CryptoUtil.BASE64_ENCODING, null, uid, password);
                String passwordHash = Base64
                        .encodeBase64String(MessageDigest.getInstance("MD5").digest(password.getBytes()));
                AccessEndpointWrapper wrapper = AccessEndpointWrapper.getWrapper(managerName);
                if (isLoginUser) {
                    wrapper.changeOwnPassword(passwordHash);
                } else {
                    wrapper.changePassword(uid, passwordHash);
                }

                Object[] arg = { managerName };
                // ??
                MessageDialog.openInformation(null, Messages.getString("successful"),
                        Messages.getString("message.accesscontrol.14", arg));

                // ?????
                if (isLoginUser) {
                    MessageDialog.openInformation(null, Messages.getString("info"),
                            Messages.getString("message.accesscontrol.25", arg));

                    LoginManager.disconnect(managerName);
                    return null;
                }

            } catch (Exception e) {
                String errMessage = "";
                if (e instanceof InvalidRole_Exception) {
                    // ???
                    MessageDialog.openInformation(null, Messages.getString("message"),
                            Messages.getString("message.accesscontrol.16"));
                } else {
                    errMessage = ", " + HinemosMessage.replace(e.getMessage());
                }
                // ?
                MessageDialog.openError(null, Messages.getString("failed"),
                        Messages.getString("message.accesscontrol.15") + errMessage);
            }

            view.update();
        }
    }
    return null;
}

From source file:com.clustercontrol.accesscontrol.view.action.RoleAddAction.java

License:Open Source License

/**
 * []?????????<BR>/*from   w w  w.  j av a 2  s.c o  m*/
 * [??]??????
 * <p>
 * <ol>
 * <li>[??]???</li>
 * <li>[]???</li>
 * </ol>
 *
 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
 * @see com.clustercontrol.accesscontrol.dialog.UserDialog
 * @see com.clustercontrol.accesscontrol.view.UserListView
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ?
    this.viewPart = HandlerUtil.getActivePart(event);
    RoleListView roleListView = null;
    try {
        roleListView = (RoleListView) this.viewPart.getAdapter(RoleListView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }
    String managerName = EndpointManager.getActiveManagerNameList().get(0);

    RoleDialog dialog = new RoleDialog(this.viewPart.getSite().getShell(), managerName, null, false);

    // ???????????
    if (dialog.open() == IDialogConstants.OK_ID) {
        if (roleListView == null) {
            m_log.info("execute: role list view is null");
        } else {
            roleListView.update();
        }
        //?
        IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();

        //?
        IViewPart roleTreeViewPart = page.findView(RoleSettingTreeView.ID);
        if (roleTreeViewPart != null) {
            RoleSettingTreeView treeView = (RoleSettingTreeView) roleTreeViewPart
                    .getAdapter(RoleSettingTreeView.class);

            if (treeView == null) {
                m_log.info("execute: tree View is null");
            } else {
                treeView.update();
            }
        }
    }
    return null;
}

From source file:com.clustercontrol.accesscontrol.view.action.RoleModifyAction.java

License:Open Source License

/**
 * []???<BR>/*from ww  w  .  j a v a 2  s. c o  m*/
 *
 * []????????<BR>
 * [??]?????
 * <p>
 * <ol>
 * <li>[]??????ID????</li>
 * <li>ID???[??]???</li>
 * <li>[??]?????</li>
 * <li>????</li>
 * <li>[]???</li>
 * </ol>
 *
 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
 * @see com.clustercontrol.accesscontrol.dialog.UserDialog
 * @see com.clustercontrol.accesscontrol.view.UserListView
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ??????ID?
    this.viewPart = HandlerUtil.getActivePart(event);
    RoleListView roleListView = null;
    try {
        roleListView = (RoleListView) this.viewPart.getAdapter(RoleListView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

    if (roleListView == null) {
        m_log.info("execute: role list view is null");
        return null;
    }

    StructuredSelection selection = (StructuredSelection) roleListView.getComposite().getTableViewer()
            .getSelection();

    List<?> list = (List<?>) selection.getFirstElement();
    String managerName = null;
    String roleId = null;
    if (list != null) {
        roleId = (String) list.get(GetRoleListTableDefine.ROLE_ID);
        managerName = (String) list.get(GetRoleListTableDefine.MANAGER_NAME);
    }

    if (roleId != null) {
        // ?
        RoleDialog dialog = new RoleDialog(this.viewPart.getSite().getShell(), managerName, roleId, true);

        // ???????????
        if (dialog.open() == IDialogConstants.OK_ID) {
            roleListView.update();

            //?
            IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();

            //?
            IViewPart roleTreeViewPart = page.findView(RoleSettingTreeView.ID);
            if (roleTreeViewPart != null) {
                RoleSettingTreeView treeView = (RoleSettingTreeView) roleTreeViewPart
                        .getAdapter(RoleSettingTreeView.class);
                if (treeView == null) {
                    m_log.info("execute: tree View is null");
                    return null;
                }
                treeView.update();
            }
        }
    }
    return null;
}

From source file:com.clustercontrol.accesscontrol.view.action.RoleSettingAssignSystemPrivilegeAction.java

License:Open Source License

/**
 * []??????<BR>/*  ww  w.  j  av  a 2  s  . c om*/
 *
 * []???????????<BR>
 * [???]?????
 *
 * @see org.eclipse.core.commands.IHandler#execute
 * @see com.clustercontrol.accesscontrol.dialog.UserDialog
 * @see com.clustercontrol.accesscontrol.view.UserListView
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ??????ID?
    this.viewPart = HandlerUtil.getActivePart(event);
    RoleSettingTreeView roleSettingTreeView = null;
    try {
        roleSettingTreeView = (RoleSettingTreeView) this.viewPart.getAdapter(RoleSettingTreeView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

    if (roleSettingTreeView == null) {
        m_log.info("execute: role setting tree view is null");
        return null;
    }

    StructuredSelection selection = (StructuredSelection) roleSettingTreeView.getTreeComposite().getTreeViewer()
            .getSelection();

    RoleTreeItem item = (RoleTreeItem) selection.getFirstElement();
    Object data = item.getData();
    RoleTreeItem manager = RoleSettingTreeView.getManager(item);
    String managerName = ((RoleInfo) manager.getData()).getRoleName();

    if (data instanceof RoleInfo && !((RoleInfo) data).getRoleId().equals(RoleSettingTreeConstant.ROOT_ID)
            && !((RoleInfo) data).getRoleId().equals(RoleSettingTreeConstant.MANAGER)) {

        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);

        SystemPrivilegeDialog dialog = new SystemPrivilegeDialog(window.getShell(), managerName,
                ((RoleInfo) data).getRoleId());
        //
        if (dialog.open() == IDialogConstants.OK_ID) {
            roleSettingTreeView.update();

            //?
            IWorkbenchPage page = window.getActivePage();

            //??
            IViewPart systemPrivilegeListView = page.findView(SystemPrivilegeListView.ID);
            if (systemPrivilegeListView != null) {
                SystemPrivilegeListView listView = (SystemPrivilegeListView) systemPrivilegeListView
                        .getAdapter(SystemPrivilegeListView.class);
                if (listView == null) {
                    m_log.info("execute: list view is null");
                    return null;
                }
                listView.update();
            }
        }
    }
    return null;
}

From source file:com.clustercontrol.accesscontrol.view.action.RoleSettingAssignUserAction.java

License:Open Source License

/**
 * []?????<BR>//from   www . j  av  a2s  . co  m
 *
 * []??????????<BR>
 * [??]?????
 *
 * @see org.eclipse.core.commands.IHandler#execute
 * @see com.clustercontrol.accesscontrol.dialog.UserDialog
 * @see com.clustercontrol.accesscontrol.view.UserListView
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ??????ID?

    this.viewPart = HandlerUtil.getActivePart(event);
    RoleSettingTreeView roleSettingTreeView = null;
    try {
        roleSettingTreeView = (RoleSettingTreeView) this.viewPart.getAdapter(RoleSettingTreeView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

    if (roleSettingTreeView == null) {
        m_log.info("execute: role setting tree view is null");
        return null;
    }

    StructuredSelection selection = (StructuredSelection) roleSettingTreeView.getTreeComposite().getTreeViewer()
            .getSelection();

    RoleTreeItem item = (RoleTreeItem) selection.getFirstElement();
    Object data = item.getData();
    RoleTreeItem manager = RoleSettingTreeView.getManager(item);
    String managerName = ((RoleInfo) manager.getData()).getRoleName();

    if (data instanceof RoleInfo && !((RoleInfo) data).getRoleId().equals(RoleSettingTreeConstant.ROOT_ID)
            && !((RoleInfo) data).getRoleId().equals(RoleSettingTreeConstant.MANAGER)) {
        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
        RoleSettingDialog dialog = new RoleSettingDialog(window.getShell(), managerName,
                ((RoleInfo) data).getRoleId());
        //
        if (dialog.open() == IDialogConstants.OK_ID) {
            roleSettingTreeView.update();

            //?
            IWorkbenchPage page = window.getActivePage();

            //??
            IViewPart systemPrivilegeListView = page.findView(SystemPrivilegeListView.ID);
            if (systemPrivilegeListView != null) {
                SystemPrivilegeListView listView = (SystemPrivilegeListView) systemPrivilegeListView
                        .getAdapter(SystemPrivilegeListView.class);
                if (listView == null) {
                    m_log.info("execute: list view is null");
                    return null;
                }
                listView.update();
            }
        }
    }
    return null;
}

From source file:com.clustercontrol.accesscontrol.view.action.UserAddAction.java

License:Open Source License

/**
 * []?????????<BR>//from ww w  . j ava  2  s .c om
 * [??]??????
 * <p>
 * <ol>
 * <li>[??]???</li>
 * <li>[]???</li>
 * </ol>
 *
 * @see org.eclipse.core.commands.IHandler#execute
 * @see com.clustercontrol.accesscontrol.dialog.UserDialog
 * @see com.clustercontrol.accesscontrol.view.UserListView
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ???
    this.viewPart = HandlerUtil.getActivePart(event);

    String managerName = EndpointManager.getActiveManagerNameList().get(0);

    // ?
    UserDialog dialog = new UserDialog(this.viewPart.getSite().getShell(), managerName, new UserInfo(), false);

    // ???????????
    if (dialog.open() == IDialogConstants.OK_ID) {
        UserListView userListView = (UserListView) this.viewPart.getAdapter(UserListView.class);

        if (userListView == null) {
            m_log.info("execute: user list view is null");
        } else {
            userListView.update();
        }

        //?
        IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();

        //?
        IViewPart roleTreeViewPart = page.findView(RoleSettingTreeView.ID);
        if (roleTreeViewPart != null) {
            RoleSettingTreeView treeView = (RoleSettingTreeView) roleTreeViewPart
                    .getAdapter(RoleSettingTreeView.class);
            if (treeView == null) {
                m_log.info("execute: tree view is null");
            } else {
                treeView.update();
            }
        }
    }
    return null;
}

From source file:com.clustercontrol.accesscontrol.view.action.UserModifyAction.java

License:Open Source License

/**
 * []???<BR>//from w  ww .j a  v a2 s .c om
 *
 * []????????<BR>
 * [??]?????
 * <p>
 * <ol>
 * <li>[]??????ID????</li>
 * <li>ID???[??]???</li>
 * <li>[??]?????</li>
 * <li>????</li>
 * <li>[]???</li>
 * </ol>
 *
 * @see org.eclipse.core.commands.IHandler#execute
 * @see com.clustercontrol.accesscontrol.dialog.UserDialog
 * @see com.clustercontrol.accesscontrol.view.UserListView
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ???
    this.viewPart = HandlerUtil.getActivePart(event);
    UserListView userListView = null;
    try {
        userListView = (UserListView) this.viewPart.getAdapter(UserListView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

    if (userListView == null) {
        m_log.info("execute: user list view is null");
        return null;
    }

    // ??????UID?
    StructuredSelection selection = (StructuredSelection) userListView.getComposite().getTableViewer()
            .getSelection();

    List<?> list = (List<?>) selection.getFirstElement();
    String managerName = null;
    String uid = null;
    if (list != null) {
        managerName = (String) list.get(GetUserListTableDefine.MANAGER_NAME);
        uid = (String) list.get(GetUserListTableDefine.UID);
    }

    if (uid != null) {
        // ID???????????
        UserInfo info = null;
        try {
            AccessEndpointWrapper wrapper = AccessEndpointWrapper.getWrapper(managerName);
            info = wrapper.getUserInfo(uid);
        } catch (InvalidRole_Exception e) {
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.accesscontrol.16"));
            return null;
        } catch (Exception e) {
            MessageDialog.openError(null, Messages.getString("failed"),
                    Messages.getString("message.hinemos.failure.unexpected") + ", "
                            + HinemosMessage.replace(e.getMessage()));
            return null;
        }

        // ?
        UserDialog dialog = new UserDialog(this.viewPart.getSite().getShell(), managerName, info, true);

        // ???????????
        if (dialog.open() == IDialogConstants.OK_ID) {
            userListView.update();

            //?
            IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();

            //?
            IViewPart roleTreeViewPart = page.findView(RoleSettingTreeView.ID);
            if (roleTreeViewPart != null) {
                RoleSettingTreeView treeView = (RoleSettingTreeView) roleTreeViewPart
                        .getAdapter(RoleSettingTreeView.class);
                if (treeView == null) {
                    m_log.info("execute: tree view is null");
                    return null;
                }
                treeView.update();
            }
        }
    }
    return null;
}

From source file:com.clustercontrol.approval.dialog.ApprovalDetailDialog.java

License:Open Source License

private void createButtonsForApprovalButtonBar(Composite parent) {
    //?//from  www .j a va  2s.  c  o m
    createButton(parent, IDialogConstants.YES_ID, Messages.getString("approval.approve"), false);
    //??
    createButton(parent, IDialogConstants.NO_ID, Messages.getString("approval.deny"), false);
    //
    createButton(parent, IDialogConstants.OK_ID, Messages.getString("approval.comment.registration"), false);
    //
    createButton(parent, IDialogConstants.CANCEL_ID, Messages.getString("cancel"), false);
}

From source file:com.clustercontrol.approval.dialog.ApprovalDetailDialog.java

License:Open Source License

@Override
protected void buttonPressed(int buttonId) {
    if (IDialogConstants.YES_ID == buttonId) {
        OperationApprove(true);/*  w ww. j a v a  2s . c om*/
    } else if (IDialogConstants.NO_ID == buttonId) {
        OperationApprove(false);
    } else if (IDialogConstants.OK_ID == buttonId) {
        okPressed();
    } else if (IDialogConstants.CANCEL_ID == buttonId) {
        cancelPressed();
    } else if (IDialogConstants.STOP_ID == buttonId) {
        OperationStop(approvalInfo);
    }
}

From source file:com.clustercontrol.approval.view.action.ApprovalFilterAction.java

License:Open Source License

/**
 * ?????????????????/*from   ww  w. j  a v a  2  s.com*/
 * <p>
 * <ol>
 * <li>?[?]???</li>
 * <li>??????</li>
 * <li>????</li>
 * </ol>
 *
 * @see org.eclipse.core.commands.IHandler#execute
 * @see com.clustercontrol.jobmanagement.view.JobHistoryView
 * @see com.clustercontrol.jobmanagement.dialog.ApprovalFilterDialog
 * @see com.clustercontrol.bean.Property
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    this.window = HandlerUtil.getActiveWorkbenchWindow(event);

    // ???
    this.viewPart = HandlerUtil.getActivePart(event);
    ApprovalView view = null;
    try {
        view = (ApprovalView) this.viewPart.getAdapter(ApprovalView.class);
    } catch (Exception e) {
        m_log.warn("execute " + e.getMessage());
        return null;
    }

    if (view == null) {
        m_log.info("execute: view is null");
        return null;
    }

    ICommandService commandService = (ICommandService) window.getService(ICommandService.class);
    Command command = commandService.getCommand(ID);
    boolean isChecked = !HandlerUtil.toggleCommandState(command);

    if (isChecked) { // ????

        ApprovalFilterDialog dialog = new ApprovalFilterDialog(
                HandlerUtil.getActiveWorkbenchWindow(event).getShell());

        //
        if (dialog.open() == IDialogConstants.OK_ID) {
            // ?
            Property property = dialog.getInputData();
            view.setFilterCondition(property);
            view.update();
        } else {
            State state = command.getState(RegistryToggleState.STATE_ID);
            state.setValue(false);
        }
    } else { // ????
        // ?
        view.setFilterCondition(null);
        view.update();
    }
    return null;

}