List of usage examples for org.eclipse.jface.dialogs MessageDialog openInformation
public static void openInformation(Shell parent, String title, String message)
From source file:com.cloudbees.eclipse.run.ui.wizards.CBWebAppWizardFinishOperation.java
License:Open Source License
@Override public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { org.eclipse.core.runtime.jobs.Job job = new org.eclipse.core.runtime.jobs.Job( "Provisioning CloudBees ClickStart project. This may take a few minutes.") { @Override//w w w.j a v a2s. com protected void canceling() { // notify user "ClickStart project provisioning cannot be cancelled." //MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Cannot be cancelled.", "ClickStart project provisioning cannot be cancelled."); MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Cannot be canceled.", "This operation cannot be canceled."); //MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Cancelled.", "Partially cancelled:\n1) Provisioning cannot be cancelled and will continue.\n2) After the provisioning completes Eclipse won't be configured for the app."); //super.canceling(); } @Override protected IStatus run(final IProgressMonitor monitor) { monitor.beginTask("Provisioning CloudBees ClickStart project. This may take a few minutes.", 100); try { ClickStartService service = CloudBeesCorePlugin.getDefault().getClickStartService(); String accountName = CloudBeesCorePlugin.getDefault().getGrandCentralService() .getActiveAccountName(); monitor.worked(25); monitor.setTaskName("Creating '" + nameAndLocPage.getProjectName() + "' for account '" + accountName + "' using ClickStart template '" + CBWebAppWizardFinishOperation.this.template.name + "'"); // Invoke provisioning request in a separate job // If request returns keep polling and reporting progress of the provisioning to the job label // As progress=100, bring up a modal background job while configuring and refreshing workspace. // Setup: // Clone from the repo and have git repo accessible // Configure datatools connection to the database // Refresh jenkins job lists and run@cloud app list. ClickStartCreateResponse resp = service.create(CBWebAppWizardFinishOperation.this.template.id, accountName, nameAndLocPage.getProjectName()); // Set appId for the project settings String resId = resp.reservationId; int pr = service.getCreateProgress(resId); int lastpr = pr; if (SUPPORT_CANCEL && monitor.isCanceled()) { return Status.CANCEL_STATUS; } monitor.beginTask( "Waiting for the servers to provision ClickStart components. This may take a few minutes.", 100); monitor.worked(pr); while (pr < 100) { Thread.currentThread().sleep(1000); lastpr = pr; if (SUPPORT_CANCEL && monitor.isCanceled()) { return Status.CANCEL_STATUS; } pr = service.getCreateProgress(resId); if (SUPPORT_CANCEL && monitor.isCanceled()) { return Status.CANCEL_STATUS; } monitor.worked(pr - lastpr); } if (SUPPORT_CANCEL && monitor.isCanceled()) { return Status.CANCEL_STATUS; } monitor.beginTask("Configuring local workspace for CloudBees ClickStart project", 100); //if (CBWebAppWizardFinishOperation.this.isAddNewRepo) { //GrandCentralService service = CloudBeesCorePlugin.getDefault().getGrandCentralService(); //service.getForgeSyncService().addToRepository(this.repo, this.project, monitor); //} if (project == null) { return Status.OK_STATUS; } // Clone generated project. monitor.subTask("Cloning git repository into the newly created project. From: " + resp.forgeUrl + " to " + project.getLocation()); ForgeEGitSync.cloneRepo(resp.source, CBWebAppWizardFinishOperation.this.locationURI, monitor); monitor.worked(30); monitor.subTask( "Creating local project '" + CBWebAppWizardFinishOperation.this.template.id + "'"); if (CBWebAppWizardFinishOperation.this.useDefaultLocation) { CBWebAppWizardFinishOperation.this.importOperation .setContext(CBWebAppWizardFinishOperation.this.wizard.getShell()); CBWebAppWizardFinishOperation.this.importOperation.setCreateContainerStructure(false); CBWebAppWizardFinishOperation.this.importOperation.run(monitor); } else { BuildPathsBlock.createProject(project, CBWebAppWizardFinishOperation.this.locationURI, monitor); } monitor.worked(10); monitor.subTask("Adding CloudBees and Java project nature"); //JavaCore.NATURE_ID NatureUtil.addNatures(project, new String[] { CloudBeesNature.NATURE_ID, JavaCore.NATURE_ID }, monitor); monitor.worked(10); String[] s1 = resp.appUrl.split("\\."); String account = s1[1]; int idx1 = s1[0].lastIndexOf('/'); String appId = s1[0].substring(idx1 + 1); project.setPersistentProperty(CloudBeesCorePlugin.PRJ_APPID_KEY, appId); project.setPersistentProperty(CloudBeesCorePlugin.PRJ_ACCOUNT_KEY, account); // Refresh project to refresh the project nature project.refreshLocal(IProject.DEPTH_INFINITE, monitor); // Let's add back the CB nature in case it was not configured by the maven script NatureUtil.addNatures(project, new String[] { CloudBeesNature.NATURE_ID, JavaCore.NATURE_ID }, monitor); // Run ant or maven build task to generate eclipse files for the project // Refresh run@cloud and dev@cloud items CloudBeesUIPlugin.getDefault().reloadAllCloudJenkins(true); ReloadRunAtCloudAction.reload(); for (NewClickStartProjectHook hook : getHooks()) { hook.hookProject(resp, project, monitor); } // initialize database components /* Provisioning database for: null COMPONENT: key:Source_repository; name:Source repository; url:ssh://git@git.cloudbees.com/grandomstate/sw1.git COMPONENT: key:Jenkins_build; name:Jenkins build; url:null COMPONENT: key:Web_Application_sw1; name:Web Application sw1; url:http://sw1.grandomstate.cloudbees.net COMPONENT: key:Database_sw1_fu9l; name:Database sw1_fu9l; url:null */ /*project.accept(new IResourceVisitor() { @Override public boolean visit(final IResource resource) throws CoreException { if (resource.getType() == IResource.FILE && "war".equalsIgnoreCase(resource.getFileExtension())) { //wars.add(resource.getProjectRelativePath().toOSString()); } return true; } }); */ return Status.OK_STATUS; } catch (Exception e) { if (e instanceof CloudBeesException) { e = (Exception) e.getCause(); } Throwable iterT = e; Throwable realT = e; while (iterT.getCause() != null) { iterT = iterT.getCause(); if (iterT.getMessage() != null && iterT.getMessage().contains("CloudBees Forge")) { realT = iterT; } } String msg = realT.getLocalizedMessage(); if (msg == null) { msg = realT.getMessage(); } CBRunUiActivator.getDefault().getLogger().error(msg, realT); String rmsg = "Failed to complete ClickStart project provisioning: " + msg; if (realT instanceof CloudBeesException && realT.getMessage() != null) { rmsg = realT.getMessage(); } return new Status(IStatus.ERROR, CBRunUiActivator.PLUGIN_ID, rmsg, realT); } finally { monitor.done(); } } }; job.setUser(true); job.schedule(); }
From source file:com.cloudbees.eclipse.ui.internal.ConfigureSshKeysAction.java
License:Open Source License
@Override public void run() { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { MessageDialog.openInformation(CloudBeesUIPlugin.getActiveWindow().getShell(), "Configure SSH keys", "In order to access Git or SVN via SSH you need to configure public-private keys.\n\n" + "In the next step the Eclipse SSH preferences page will open. Also in the browser will be open the corresponding 'User settings' configuration page at CloudBees site.\n\n" + "Either load an existing key or generate a new one on the 'Key Management' tab and then copy-paste the public key to the browser into the CloudBees 'User settings/Public Key' field."); }/*ww w. ja v a 2 s . c o m*/ }); PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn( CloudBeesUIPlugin.getActiveWindow().getShell(), "org.eclipse.jsch.ui.SSHPreferences", new String[] { "org.eclipse.ui.net.NetPreferences", "org.eclipse.jsch.ui.SSHPreferences" }, null); CloudBeesUIPlugin.getDefault().openWithBrowser(GrandCentralService.GC_BASE_URL + "/account/edit"); if (pref != null) { pref.open(); } }
From source file:com.cloudbees.eclipse.ui.internal.preferences.GeneralPreferencePage.java
License:Open Source License
private void createCompositeLogin() { Group group = new Group(getFieldEditorParent(), SWT.SHADOW_ETCHED_IN); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout gl = new GridLayout(1, false); gl.marginLeft = 5;/*from w w w . j ava 2s . c o m*/ gl.marginRight = 5; gl.marginTop = 5; gl.marginBottom = 5; gl.horizontalSpacing = 5; group.setLayout(gl); Composite groupInnerComp = new Composite(group, SWT.NONE); groupInnerComp.setLayout(new GridLayout(2, false)); groupInnerComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); group.setText(Messages.pref_group_login); final StringFieldEditor fieldEmail = new StringFieldEditor(PreferenceConstants.P_EMAIL, Messages.pref_email, 30, groupInnerComp); fieldEmail.getTextControl(groupInnerComp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); addField(fieldEmail); final StringFieldEditor fieldPassword = new StringFieldEditor(PreferenceConstants.P_PASSWORD, Messages.pref_password, 30, groupInnerComp) { @Override protected void doLoad() { try { if (getTextControl() != null) { String value = CloudBeesUIPlugin.getDefault().readP(); getTextControl().setText(value); this.oldValue = value; } } catch (StorageException e) { // Ignore StorageException, very likely just // "No password provided." } } @Override protected void doStore() { try { CloudBeesUIPlugin.getDefault().storeP(getTextControl().getText()); } catch (Exception e) { CloudBeesUIPlugin.showError( "Saving password failed!\nPossible cause: Eclipse security master password is not set.", e); } } @Override protected void doFillIntoGrid(Composite parent, int numColumns) { super.doFillIntoGrid(parent, numColumns); getTextControl().setEchoChar('*'); } }; fieldPassword.getTextControl(groupInnerComp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); addField(fieldPassword); Composite signupAndValidateRow = new Composite(groupInnerComp, SWT.NONE); GridData signupRowData = new GridData(GridData.FILL_HORIZONTAL); signupRowData.horizontalSpan = 2; signupAndValidateRow.setLayoutData(signupRowData); GridLayout gl2 = new GridLayout(2, false); gl2.marginWidth = 0; gl2.marginHeight = 0; gl2.marginTop = 5; signupAndValidateRow.setLayout(gl2); createSignUpLink(signupAndValidateRow); Button b = new Button(signupAndValidateRow, SWT.PUSH); GridData validateButtonLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_END); validateButtonLayoutData.widthHint = 75; b.setLayoutData(validateButtonLayoutData); b.setText(Messages.pref_validate_login); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final String email = fieldEmail.getStringValue(); final String password = fieldPassword.getStringValue(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { monitor.beginTask("Validating CloudBees account...", 100); //TODO i18n monitor.subTask("Connecting...");//TODO i18n monitor.worked(10); GrandCentralService gcs = new GrandCentralService(); gcs.setAuthInfo(email, password); monitor.worked(20); monitor.subTask("Validating...");//TODO i18n final boolean loginValid = gcs.validateUser(monitor); monitor.worked(50); PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { if (loginValid) { MessageDialog.openInformation( CloudBeesUIPlugin.getDefault().getWorkbench().getDisplay() .getActiveShell(), "Validation result", "Validation successful!");//TODO i18n } else { MessageDialog.openError( CloudBeesUIPlugin.getDefault().getWorkbench().getDisplay() .getActiveShell(), "Validation result", "Validation was not successful!\nWrong email or password?");//TODO i18n } } }); monitor.worked(20); } catch (CloudBeesException e1) { throw new RuntimeException(e1); } finally { monitor.done(); } } }); } catch (InvocationTargetException e1) { Throwable t1 = e1.getTargetException().getCause() != null ? e1.getTargetException().getCause() : e1.getTargetException(); Throwable t2 = t1.getCause() != null ? t1.getCause() : null; CloudBeesUIPlugin.showError("Failed to validate your account.", t1.getMessage(), t2); } catch (InterruptedException e1) { CloudBeesUIPlugin.showError("Failed to validate your account.", e1); } } }); }
From source file:com.clustercontrol.accesscontrol.composite.action.UserDoubleClickListener.java
License:Open Source License
/** * ?????<BR>//from ww w. j a v a 2 s . c o m * []????????????? * <P> * <ol> * <li>???????ID????</li> * <li>ID????????</li> * </ol> * * @param event * * @see com.clustercontrol.accesscontrol.dialog.UserDialog * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent) */ @Override public void doubleClick(DoubleClickEvent event) { String managerName = null; String uid = null; //UID? if (((StructuredSelection) event.getSelection()).getFirstElement() != null) { ArrayList<?> info = (ArrayList<?>) ((StructuredSelection) event.getSelection()).getFirstElement(); managerName = (String) info.get(GetUserListTableDefine.MANAGER_NAME); uid = (String) info.get(GetUserListTableDefine.UID); } if (uid != null) { // ? 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; } catch (Exception e) { MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); return; } UserDialog dialog = new UserDialog(m_composite.getShell(), managerName, info, true); // ??????????? if (dialog.open() == IDialogConstants.OK_ID) { //? IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); //? IViewPart roleTreeViewPart = page.findView(RoleSettingTreeView.ID); if (roleTreeViewPart != null) { RoleSettingTreeView treeView = (RoleSettingTreeView) roleTreeViewPart .getAdapter(RoleSettingTreeView.class); if (treeView == null) { m_log.info("double click: tree view is null"); } else { treeView.update(); } } //? IViewPart userListViewPart = page.findView(UserListView.ID); if (userListViewPart != null) { UserListView userListView = (UserListView) userListViewPart.getAdapter(UserListView.class); if (userListView == null) { m_log.info("double click: user list view is null"); } else { userListView.update(); } } } } }
From source file:com.clustercontrol.accesscontrol.composite.SystemPrivilegeListComposite.java
License:Open Source License
/** * ???<BR>/* w w w .j av a 2 s . c om*/ * ??????<BR> * ???? * * @param selectedInfo ???RoleInfo/UserInfo<br> * ???????null? * * @see com.clustercontrol.accesscontrol.action.GetUserList#getJobEditState(Property) */ public void update(String managerName, Object selectedInfo) { //?? List<SystemPrivilegeInfo> infoList = null; try { if (selectedInfo != null) { AccessEndpointWrapper wrapper = AccessEndpointWrapper.getWrapper(managerName); if (selectedInfo instanceof RoleInfo) { if (!((RoleInfo) selectedInfo).getRoleId().equals(RoleSettingTreeConstant.ROOT_ID) && !((RoleInfo) selectedInfo).getRoleId().equals(RoleSettingTreeConstant.MANAGER)) { infoList = wrapper .getSystemPrivilegeInfoListByRoleId(((RoleInfo) selectedInfo).getRoleId()); } } else if (selectedInfo instanceof UserInfo) { infoList = wrapper.getSystemPrivilegeInfoListByUserId(((UserInfo) selectedInfo).getUserId()); } } } catch (InvalidRole_Exception e) { // ??? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); // TODO?????? // // ?????????? // infoList = getOwnUserList(); } catch (Exception e) { // ? m_log.warn("update(), " + HinemosMessage.replace(e.getMessage()), e); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); } ArrayList<Object> listInput = new ArrayList<Object>(); if (selectedInfo != null && infoList != null) { for (SystemPrivilegeInfo info : infoList) { ArrayList<Object> obj = new ArrayList<Object>(); obj.add(SystemPrivilegePropertyUtil.getSystemPrivilegeName(managerName, info)); obj.add(null); listInput.add(obj); } } m_viewer.setInput(listInput); Object[] args = { listInput.size() }; if (selectedInfo == null) { m_labelType.setText(""); m_labelCount.setText(Messages.getString("records", args)); } else { if (selectedInfo instanceof RoleInfo) { if (((RoleInfo) selectedInfo).getRoleId().equals(RoleSettingTreeConstant.ROOT_ID)) { m_labelType.setText(""); m_labelCount.setText(Messages.getString("records", args)); } else { RoleInfo roleInfo = (RoleInfo) selectedInfo; m_labelType.setText(Messages.getString("role.name") + " : " + roleInfo.getRoleName() + "(" + roleInfo.getRoleId() + ")"); m_labelCount.setText(Messages.getString("filtered.records", args)); } } else if (selectedInfo instanceof UserInfo) { UserInfo userInfo = (UserInfo) selectedInfo; m_labelType.setText(Messages.getString("user.name") + " : " + userInfo.getUserName() + "(" + userInfo.getUserId() + ")"); m_labelCount.setText(Messages.getString("filtered.records", args)); } } }
From source file:com.clustercontrol.accesscontrol.composite.UserListComposite.java
License:Open Source License
/** * ????????<BR>//from www.ja v a2 s .c o m * * @return */ public List<UserInfo> getOwnUserList(String managerName) { // List<UserInfo> infoList = new ArrayList<UserInfo>(); UserInfo info = null; try { AccessEndpointWrapper wrapper = AccessEndpointWrapper.getWrapper(managerName); info = wrapper.getOwnUserInfo(); } catch (InvalidRole_Exception e) { // ??? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); } catch (Exception e) { // ? m_log.warn("getOwnUserList(), " + HinemosMessage.replace(e.getMessage()), e); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); } if (info == null) { info = new UserInfo(); info.setCreateDate(0L); info.setModifyDate(0L); } infoList.add(info); return infoList; }
From source file:com.clustercontrol.accesscontrol.dialog.ObjectPrivilegeEditDialog.java
License:Open Source License
/** * ?????//from w w w . j a va 2 s . c om * * @return true?false * * @see com.clustercontrol.dialog.CommonDialog#action() */ @Override protected boolean action() { boolean result = true; java.util.List<ObjectPrivilegeInfo> inputdata = createInputData(); StringBuffer confirmList = new StringBuffer(); StringBuffer successList = new StringBuffer(); StringBuffer failureList = new StringBuffer(); String[] args = null; // ???????? if (m_objects.size() > 1) { for (ObjectBean objectBean : m_objects) { confirmList.append(objectBean.getObjectId() + "\n"); } args = new String[] { confirmList.toString() }; if (!MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString("message.accesscontrol.53", args))) { return false; } } for (ObjectBean objectBean : m_objects) { String objectPrivilegeParam = Messages.getString("object.privilege.param", new String[] { HinemosModuleMessage.nameToString(objectBean.getObjectType()), objectBean.getObjectId() }); String managerName = objectBean.getManagerName(); AccessEndpointWrapper wrapper = AccessEndpointWrapper.getWrapper(managerName); try { wrapper.replaceObjectPrivilegeInfo(objectBean.getObjectType(), objectBean.getObjectId(), inputdata); successList.append(objectPrivilegeParam + "(" + managerName + ")\n"); } catch (UsedObjectPrivilege_Exception e) { args = new String[] { HinemosModuleMessage.nameToString(e.getFaultInfo().getObjectType()), e.getFaultInfo().getObjectId() }; // ????????????? failureList.append( objectPrivilegeParam + " (" + Messages.getString("message.accesscontrol.36", args) + ")\n"); } catch (InvalidRole_Exception e) { // ??? failureList.append( objectPrivilegeParam + " (" + Messages.getString("message.accesscontrol.16") + ")\n"); } catch (JobMasterNotFound_Exception e) { // ???? failureList.append( objectPrivilegeParam + " (" + Messages.getString("message.accesscontrol.46") + ")\n"); } catch (Exception e) { // ? m_log.warn("getOwnUserList(), " + HinemosMessage.replace(e.getMessage()), e); failureList.append( objectPrivilegeParam + " (" + Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage()) + ")\n"); } } // ? if (successList.length() != 0) { args = new String[] { successList.toString() }; MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.accesscontrol.49", args)); } // if (failureList.length() != 0) { args = new String[] { failureList.toString() }; MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.accesscontrol.50", args)); } return result; }
From source file:com.clustercontrol.accesscontrol.dialog.RoleDialog.java
License:Open Source License
/** * ????/*from ww w . ja va 2s .co m*/ * * @param parent ? * * @see com.clustercontrol.dialog.CommonDialog#customizeDialog(org.eclipse.swt.widgets.Composite) */ @Override protected void customizeDialog(Composite parent) { Shell shell = this.getShell(); // shell.setText(Messages.getString("dialog.accesscontrol.role.create.modify")); // GridLayout layout = new GridLayout(1, true); layout.marginWidth = 10; layout.marginHeight = 10; layout.numColumns = 15; parent.setLayout(layout); /* * ? */ Label labelManager = new Label(parent, SWT.LEFT); WidgetTestUtil.setTestId(this, "manager", labelManager); GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = WIDTH_LABEL; labelManager.setLayoutData(gridData); labelManager.setText(Messages.getString("facility.manager") + " : "); if (this.isModifyDialog) { this.m_managerComposite = new ManagerListComposite(parent, SWT.NONE, false); } else { this.m_managerComposite = new ManagerListComposite(parent, SWT.NONE, true); } WidgetTestUtil.setTestId(this, "managerComposite", this.m_managerComposite); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.horizontalSpan = WIDTH_TEXT; gridData.grabExcessHorizontalSpace = true; this.m_managerComposite.setLayoutData(gridData); if (this.managerName != null) { this.m_managerComposite.setText(this.managerName); } /* * ID */ // Label label = new Label(parent, SWT.NONE); WidgetTestUtil.setTestId(this, null, label); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = WIDTH_LABEL; label.setLayoutData(gridData); label.setText(Messages.getString("role.id") + " : "); // this.textRoleId = new Text(parent, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "id", textRoleId); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TEXT; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.textRoleId.setLayoutData(gridData); this.textRoleId.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); // ???? if (this.isModifyDialog) { if (permission) { this.mode = PropertyDefineConstant.MODE_MODIFY; } else { this.mode = PropertyDefineConstant.MODE_SHOW; } } else { this.mode = PropertyDefineConstant.MODE_ADD; } /* * ?? */ // label = new Label(parent, SWT.NONE); WidgetTestUtil.setTestId(this, "role", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_LABEL; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("role.name") + " : "); // this.textRoleName = new Text(parent, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "name", textRoleName); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TEXT; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.textRoleName.setLayoutData(gridData); this.textRoleName.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); /* * */ // label = new Label(parent, SWT.NONE); WidgetTestUtil.setTestId(this, "description", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_LABEL; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("description") + " : "); // this.textDescription = new Text(parent, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "description", textDescription); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TEXT; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.textDescription.setLayoutData(gridData); this.textDescription.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); // ? // ???????????????????? shell.pack(); shell.setSize(new Point(550, shell.getSize().y)); // ?? Display display = shell.getDisplay(); shell.setLocation((display.getBounds().width - shell.getSize().x) / 2, (display.getBounds().height - shell.getSize().y) / 2); // ID??????????? RoleInfo info = null; if (this.roleId != null) { try { AccessEndpointWrapper wrapper = AccessEndpointWrapper.getWrapper(m_managerComposite.getText()); info = wrapper.getRoleInfo(this.roleId); this.setInputData(info); } catch (InvalidRole_Exception e) { MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); } catch (Exception e) { m_log.warn("customizeDialog(), " + HinemosMessage.replace(e.getMessage()), e); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); } } else { info = new RoleInfo(); this.setInputData(info); } }
From source file:com.clustercontrol.accesscontrol.dialog.RoleDialog.java
License:Open Source License
/** * ?????//from w w w. j ava2s.c om * * @return true?false * * @see com.clustercontrol.dialog.CommonDialog#action() */ @Override protected boolean action() { boolean result = false; RoleInfo roleInfo = this.inputData; if (roleInfo == null) { return result; } AccessEndpointWrapper wrapper = AccessEndpointWrapper.getWrapper(this.m_managerComposite.getText()); if (!this.isModifyDialog) { // ??? try { wrapper.addRoleInfo(roleInfo); result = true; Object[] arg = { this.m_managerComposite.getText() }; // MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.accesscontrol.26", arg)); } catch (RoleDuplicate_Exception e) { //ID? String args[] = { roleInfo.getRoleId() }; // ID???????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.33", args)); } catch (FacilityDuplicate_Exception e) { //ID? String args[] = { roleInfo.getRoleId() }; // ID???????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.repository.26", args)); } 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.27") + errMessage); } } else { // ?? try { wrapper.modifyRoleInfo(roleInfo); result = true; Object[] arg = { this.m_managerComposite.getText() }; // MessageDialog.openInformation(null, Messages.getString("successful"), Messages.getString("message.accesscontrol.28", arg)); } catch (Exception e) { String errMessage = ""; if (e instanceof InvalidRole_Exception) { // ??? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); } else if (e instanceof UnEditableRole_Exception) { //??????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.40")); } else { errMessage = ", " + HinemosMessage.replace(e.getMessage()); } MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.accesscontrol.29") + errMessage); } } return result; }
From source file:com.clustercontrol.accesscontrol.dialog.RoleSettingDialog.java
License:Open Source License
/** * ????/*from w ww . j a va 2 s. c o m*/ * * @param parent ? * * @see com.clustercontrol.dialog.CommonDialog#customizeDialog(org.eclipse.swt.widgets.Composite) */ @Override protected void customizeDialog(Composite parent) { Shell shell = this.getShell(); // shell.setText(Messages.getString("dialog.accesscontrol.role.setting")); // ?? RoleInfo info = null; try { AccessEndpointWrapper wrapper = AccessEndpointWrapper.getWrapper(this.managerName); info = wrapper.getRoleInfo(this.roleId); } catch (InvalidRole_Exception e) { MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); throw new InternalError(e.getMessage()); } catch (Exception e) { m_log.warn("customizeDialog(), " + HinemosMessage.replace(e.getMessage()), e); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); throw new InternalError(e.getMessage()); } // GridLayout layout = new GridLayout(1, true); layout.marginWidth = 10; layout.marginHeight = 10; layout.numColumns = WIDTH; parent.setLayout(layout); /* * ?? */ // Label label = new Label(parent, SWT.NONE); WidgetTestUtil.setTestId(this, "role", label); GridData gridData = new GridData(); gridData.horizontalSpan = WIDTH; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("role.name") + " : " + info.getRoleName()); /* * ? */ Composite compositeNotRole = new Composite(parent, SWT.NONE); WidgetTestUtil.setTestId(this, "all", compositeNotRole); layout = new GridLayout(1, true); layout.numColumns = 1; compositeNotRole.setLayout(layout); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.horizontalSpan = 6; gridData.verticalSpan = 2; compositeNotRole.setLayoutData(gridData); // label = new Label(compositeNotRole, SWT.NONE); WidgetTestUtil.setTestId(this, "alluserlist", label); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("RoleSettingDialog.not_role_user")); // this.listNotRoleUser = new List(compositeNotRole, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); WidgetTestUtil.setTestId(this, "all", compositeNotRole); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.heightHint = this.listNotRoleUser.getItemHeight() * 12; this.listNotRoleUser.setLayoutData(gridData); // ? this.mapNotRoleUser = new HashMap<String, String>(); /* * ?? */ Composite compositeButton = new Composite(parent, SWT.NONE); WidgetTestUtil.setTestId(this, "composite", compositeButton); layout = new GridLayout(1, true); layout.numColumns = 1; compositeButton.setLayout(layout); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.horizontalSpan = 3; compositeButton.setLayoutData(gridData); // label = new Label(compositeButton, SWT.NONE); WidgetTestUtil.setTestId(this, "blank1", label); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); // Label dummy = new Label(compositeButton, SWT.NONE); WidgetTestUtil.setTestId(this, "dummy", dummy); this.buttonRoleUser = this.createButton(compositeButton, Messages.getString("RoleSettingDialog.role_user_button")); WidgetTestUtil.setTestId(this, "assign", buttonRoleUser); this.buttonRoleUser.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String[] items = listNotRoleUser.getSelection(); for (String item : items) { listNotRoleUser.remove(item); listRoleUser.add(item); // ?????ID?HashMap??????? mapRoleUser.put(item, mapNotRoleUser.get(item)); mapNotRoleUser.remove(item); } } }); // dummy = new Label(compositeButton, SWT.NONE); WidgetTestUtil.setTestId(this, "unassign", dummy); this.buttonNotRoleUser = this.createButton(compositeButton, Messages.getString("RoleSettingDialog.not_role_user_button")); WidgetTestUtil.setTestId(this, "unassign", buttonNotRoleUser); this.buttonNotRoleUser.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String[] items = listRoleUser.getSelection(); for (String item : items) { listRoleUser.remove(item); listNotRoleUser.add(item); // ?????ID?HashMap??????? mapNotRoleUser.put(item, mapRoleUser.get(item)); mapRoleUser.remove(item); } } }); // label = new Label(compositeButton, SWT.NONE); WidgetTestUtil.setTestId(this, "blank", label); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); /* * ? */ Composite compositeRole = new Composite(parent, SWT.NONE); WidgetTestUtil.setTestId(this, "role", compositeRole); layout = new GridLayout(1, true); layout.numColumns = 1; compositeRole.setLayout(layout); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.horizontalSpan = 6; gridData.verticalSpan = 2; compositeRole.setLayoutData(gridData); // label = new Label(compositeRole, SWT.NONE); WidgetTestUtil.setTestId(this, "userlist", label); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("RoleSettingDialog.role_user")); // this.listRoleUser = new List(compositeRole, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); WidgetTestUtil.setTestId(this, "roleuserlist", listRoleUser); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.heightHint = this.listRoleUser.getItemHeight() * 12; this.listRoleUser.setLayoutData(gridData); // ? this.mapRoleUser = new HashMap<String, String>(); // ? // ???????????????????? shell.pack(); shell.setSize(new Point(550, shell.getSize().y)); // ?? Display display = shell.getDisplay(); shell.setLocation((display.getBounds().width - shell.getSize().x) / 2, (display.getBounds().height - shell.getSize().y) / 2); this.setInputData(this.managerName, info); }