List of usage examples for org.eclipse.jface.dialogs MessageDialog openWarning
public static void openWarning(Shell parent, String title, String message)
From source file:com.cloudbees.eclipse.dev.ui.views.build.ArtifactsClickListener.java
License:Open Source License
public static void deployWar(final JenkinsBuildDetailsResponse build, final Artifact selectedWar) { final Artifact war; final ApplicationInfo app; if (build.artifacts == null) { return;//from w w w. j av a2 s.c om } final DeployWarAppDialog[] selector = new DeployWarAppDialog[1]; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { final List<Artifact> wars = new ArrayList<Artifact>(); final List<ApplicationInfo> apps = new ArrayList<ApplicationInfo>(); try { PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { @Override public void run(final IProgressMonitor monitor) { try { for (Artifact art : build.artifacts) { if (art.relativePath != null && art.relativePath.endsWith(".war")) { wars.add(art); monitor.worked(1); } } apps.addAll(BeesSDK.getList().getApplications()); monitor.worked(1); } catch (Exception e) { CloudBeesDevUiPlugin.getDefault().getLogger().error(e); } } }); } catch (InterruptedException e) { return; } catch (Exception e) { CloudBeesDevUiPlugin.getDefault().getLogger().error(e); } if (wars.isEmpty() || apps.isEmpty()) { MessageDialog.openInformation(CloudBeesUIPlugin.getActiveWindow().getShell(), "Deploy to RUN@cloud", "Deployment is not possible."); return; } selector[0] = new DeployWarAppDialog(CloudBeesUIPlugin.getActiveWindow().getShell(), wars, selectedWar, apps); selector[0].open(); } }); if (selector[0] == null) { return; } war = selector[0].getSelectedWar(); app = selector[0].getSelectedApp(); if (war == null || app == null) { return; // cancelled } org.eclipse.core.runtime.jobs.Job job = new org.eclipse.core.runtime.jobs.Job("Deploy war to RUN@cloud") { @Override protected IStatus run(final IProgressMonitor monitor) { try { String warUrl = getWarUrl(build, war); JenkinsService service = CloudBeesUIPlugin.getDefault().getJenkinsServiceForUrl(warUrl); BufferedInputStream in = new BufferedInputStream(service.getArtifact(warUrl, monitor)); String warName = warUrl.substring(warUrl.lastIndexOf("/")); final File tempWar = File.createTempFile(warName, null); tempWar.deleteOnExit(); monitor.beginTask("Deploy war to RUN@cloud", 100); SubMonitor subMonitor = SubMonitor.convert(monitor, "Downloading war file...", 50); OutputStream out = new BufferedOutputStream(new FileOutputStream(tempWar)); byte[] buf = new byte[1 << 12]; int len = 0; while ((len = in.read(buf)) >= 0) { out.write(buf, 0, len); subMonitor.worked(1); } out.flush(); out.close(); in.close(); final String[] newAppUrl = new String[1]; try { subMonitor = SubMonitor.convert(monitor, "Deploying war file to RUN@cloud...", 50); ApplicationDeployArchiveResponse result = BeesSDK.deploy(null, app.getId(), tempWar.getAbsoluteFile(), subMonitor); subMonitor.worked(50); if (result != null) { newAppUrl[0] = result.getUrl(); } } catch (Exception e) { return new Status(IStatus.ERROR, CloudBeesDevUiPlugin.PLUGIN_ID, e.getMessage(), e); } finally { monitor.done(); } PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { try { if (newAppUrl[0] != null) { boolean openConfirm = MessageDialog.openConfirm( CloudBeesUIPlugin.getActiveWindow().getShell(), "Deploy to RUN@cloud", "Deployment succeeded to RUN@cloud '" + app.getId() + "'.\nOpen " + newAppUrl[0] + " in the browser?"); if (openConfirm) { CloudBeesUIPlugin.getDefault().openWithBrowser(newAppUrl[0]); } } else { MessageDialog.openWarning(CloudBeesUIPlugin.getActiveWindow().getShell(), "Deploy to RUN@cloud", "Deployment failed to RUN@cloud '" + app.getId() + "'."); } } catch (Exception e) { CloudBeesDevUiPlugin.getDefault().getLogger().error(e); } } }); return Status.OK_STATUS; } catch (OperationCanceledException e) { return Status.CANCEL_STATUS; } catch (Exception e) { e.printStackTrace(); // TODO return new Status(IStatus.ERROR, CloudBeesDevUiPlugin.PLUGIN_ID, e.getMessage(), e); } finally { monitor.done(); } } }; job.setUser(true); job.schedule(); }
From source file:com.cloudbees.eclipse.run.ui.launchconfiguration.CBCloudLaunchShortcut.java
License:Open Source License
protected void internalLaunch(Object element, IProgressMonitor monitor, final IFile file, IProject project, final String preappid) throws CloudBeesException { // Strategy for decising if build is needed: invoke project build always when selection is project if (project != null) { try {/*from w ww . jav a2 s.c o m*/ String appId = BeesSDK.getBareAppId(project); String account = CloudBeesUIPlugin.getDefault().getActiveAccountName(monitor); BeesSDK.deploy(project, account, appId, true, monitor); return; } catch (CloudBeesException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } else if (file != null) {// deploy specified file, without build. If unknown type, confirm first. String appId; try { if (!BeesSDK.hasSupportedExtension(file.getName())) { final String ext = BeesSDK.getExtension(file.getName()); final Boolean[] openConfirm = new Boolean[] { Boolean.FALSE }; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { openConfirm[0] = MessageDialog.openConfirm( CloudBeesUIPlugin.getActiveWindow().getShell(), "Deploy to CloudBees RUN@cloud", ext + " is an unknown app package type.\nAre you sure you want to deploy '" + file.getName() + "' to '" + preappid + "'?"); } }); if (!openConfirm[0]) { return; } } String account = CloudBeesUIPlugin.getDefault().getActiveAccountName(monitor); appId = BeesSDK.getAccountAppId(account, null, file.getProject()); BeesSDK.deploy(project, appId, file.getRawLocation().toFile(), monitor); return; } catch (Exception e) { final Exception e2 = e; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { MessageDialog.openWarning(CloudBeesUIPlugin.getActiveWindow().getShell(), "Deploy failed!", "Deployment failed for '" + file.getName() + "': " + e2.getMessage()); } }); } } }
From source file:com.cloudbees.eclipse.run.ui.launchconfiguration.CBLocalLaunchDelegate.java
License:Open Source License
public void launch(ILaunchConfiguration conf, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { if (monitor == null) { monitor = new NullProgressMonitor(); }//from w w w.ja v a 2s .c om boolean debug = mode.equals("debug"); String projectName = conf.getAttribute(CBLaunchConfigurationConstants.ATTR_CB_PROJECT_NAME, ""); String warName = conf.getAttribute(CBLaunchConfigurationConstants.ATTR_CB_LAUNCH_WAR_PATH, ""); IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); IFile file = null; if (proj != null && warName != null && warName.length() > 0) { file = proj.getFile(warName); } conf = modifyLaunch(proj, conf, mode); if (conf.getAttribute(DO_NOTHING, false)) { monitor.setCanceled(true); return; } String port = conf.getAttribute(CBLaunchConfigurationConstants.ATTR_CB_PORT, CBRunUtil.getDefaultLocalPort() + ""); String debugPort = conf.getAttribute(CBLaunchConfigurationConstants.ATTR_CB_DEBUG_PORT, CBRunUtil.getDefaultLocalDebugPort() + ""); final IFile ff = file; Process p = internalLaunch(monitor, file, proj, debug, port, debugPort); if (p == null) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { MessageDialog.openWarning(CloudBeesUIPlugin.getActiveWindow().getShell(), "Deploy stopped!", "Process creation stopped for '" + ff.getName() + "'"); } }); return; //throw new CoreException(new Status(IStatus.ERROR, CBRunUiActivator.PLUGIN_ID, "Failed to create local process!")); } Map<String, String> attrs = new HashMap<String, String>(); if (debug) { //addDebugAttrs(attrs, projectName, debugPort); } String taskName = warName; if (taskName == null || taskName.length() == 0) { taskName = projectName; } IProcess runtimeProcess = DebugPlugin.newProcess(launch, p, taskName, attrs); // new RuntimeProcess(launch, p, warName, null); launch.addProcess(runtimeProcess); if (debug) { IVMConnector connector = new SocketAttachConnector();//.getDefaultVMConnector(); Map args = connector.getDefaultArguments(); Map argMap = conf.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, (Map) null); if (argMap == null) { argMap = new HashMap(); } int connectTimeout = JavaRuntime.getPreferences().getInt(JavaRuntime.PREF_CONNECT_TIMEOUT); argMap.put("timeout", Integer.toString(connectTimeout)); //$NON-NLS-1$ //String connectMapAttr = IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP; //Map<String, String> connectMap = new HashMap<String, String>(); argMap.put("hostname", "localhost"); argMap.put("port", debugPort); //argMap.put(connectMapAttr, connectMap); setDefaultSourceLocator(launch, conf); connector.connect(argMap, monitor, launch); } CBProjectProcessService.getInstance().addProcess(projectName, launch.getProcesses()[0]); //DebugPlugin.getDefault().getLaunchManager().addLaunch(launch); DebugPlugin.getDefault().getLaunchManager().addLaunchListener(new TerminateListener(projectName)); //if (debug) { //CBRunUtil.createTemporaryRemoteLaunchConfiguration(projectName).launch(mode, monitor); //} // handleExtensions(configuration, projectName); }
From source file:com.cloudbees.eclipse.run.ui.launchconfiguration.CBLocalLaunchDelegate.java
License:Open Source License
public static Process internalLaunch(IProgressMonitor monitor, final IFile file, IProject project, boolean debug, String port, String debugPort) { try {/* w w w.j a v a2 s . c o m*/ // Strategy for deciding if build is needed: invoke project build always when selection is project if (project != null) { return wrappedDeployLocal(project, file, debug, port, debugPort, monitor); } else if (file != null) {// deploy specified file, without build. If unknown type, confirm first. if (!BeesSDK.hasSupportedExtension(file.getName())) { final String ext = BeesSDK.getExtension(file.getName()); final Boolean[] openConfirm = new Boolean[] { Boolean.FALSE }; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { openConfirm[0] = MessageDialog.openConfirm( CloudBeesUIPlugin.getActiveWindow().getShell(), "Deploy to local", ext + " is an unknown app package type.\nAre you sure you want to deploy '" + file.getName() + "' to local?"); } }); if (!openConfirm[0]) { return null; } } return wrappedDeployLocal(file.getProject(), file, debug, port, debugPort, monitor); } } catch (Exception e) { e.printStackTrace(); final Exception e2 = e; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { MessageDialog.openWarning(CloudBeesUIPlugin.getActiveWindow().getShell(), "Deploy failed!", "Deployment failed for '" + file.getName() + "': " + e2.getMessage()); } }); } return null; }
From source file:com.clustercontrol.accesscontrol.dialog.LoginDialog.java
License:Open Source License
/** * ???/*www . j av a 2 s . c o m*/ * ??????? * * @param result * ValidateResult */ private void displayError(ValidateResult result) { MessageDialog.openWarning(null, result.getID(), result.getMessage()); }
From source file:com.clustercontrol.calendar.composite.CalendarDetailInfoComposite.java
License:Open Source License
/** * ?????/*w ww . jav a 2 s . c o m*/ */ private void initialize() { // ???? GridData gridData = null; GridLayout layout = new GridLayout(1, true); layout.marginHeight = 0; layout.marginWidth = 0; layout.numColumns = 15; this.setLayout(layout); /* * */ this.calInfoListComposite = new CalendarDetailListComposite(this, SWT.BORDER, this.managerName); WidgetTestUtil.setTestId(this, "list", calInfoListComposite); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.horizontalSpan = 13; this.calInfoListComposite.setLayoutData(gridData); /* * ? */ Composite calDetailInfoButtonComposite = new Composite(this, SWT.NONE); WidgetTestUtil.setTestId(this, "button", calDetailInfoButtonComposite); layout = new GridLayout(1, true); layout.numColumns = 1; calDetailInfoButtonComposite.setLayout(layout); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.horizontalSpan = 2; calDetailInfoButtonComposite.setLayoutData(gridData); // this.calDetailInfoAddButton = this.createButton(calDetailInfoButtonComposite, Messages.getString("add")); WidgetTestUtil.setTestId(this, "add", calDetailInfoAddButton); this.calDetailInfoAddButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // ? Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); //FIXME //CalendarDetailDialog dialog = new CalendarDetailDialog(shell, m_ownerRoleId); CalendarDetailDialog dialog = new CalendarDetailDialog(shell, calInfoListComposite.getManagerName(), calInfoListComposite.getOwnerRoleId()); if (dialog.open() == IDialogConstants.OK_ID) { calInfoListComposite.getDetailList().add(dialog.getInputData()); calInfoListComposite.update(); } } }); // this.calDetailInfoModifyButton = this.createButton(calDetailInfoButtonComposite, Messages.getString("modify")); WidgetTestUtil.setTestId(this, "modify", calDetailInfoModifyButton); this.calDetailInfoModifyButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Integer order = calInfoListComposite.getSelection(); if (order != null) { // ? Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); //FIXME //CalendarDetailDialog dialog = new CalendarDetailDialog(shell,m_infoListComposite.getDetailList().get(order - 1), m_ownerRoleId); CalendarDetailDialog dialog = new CalendarDetailDialog(shell, calInfoListComposite.getManagerName(), calInfoListComposite.getDetailList().get(order - 1), calInfoListComposite.getOwnerRoleId()); if (dialog.open() == IDialogConstants.OK_ID) { calInfoListComposite.getDetailList() .remove(calInfoListComposite.getDetailList().get(order - 1)); calInfoListComposite.getDetailList().add(order - 1, dialog.getInputData()); calInfoListComposite.setSelection(); } } else { MessageDialog.openWarning(null, Messages.getString("warning"), Messages.getString("message.monitor.30")); } } }); // this.calDetailInfoDeleteButton = this.createButton(calDetailInfoButtonComposite, Messages.getString("delete")); WidgetTestUtil.setTestId(this, "delete", calDetailInfoDeleteButton); this.calDetailInfoDeleteButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Integer order = calInfoListComposite.getSelection(); if (order != null) { calInfoListComposite.getDetailList().remove(order - 1); calInfoListComposite.update(); } else { MessageDialog.openWarning(null, Messages.getString("warning"), Messages.getString("message.monitor.30")); } } }); // this.calDetailInfoCopyButton = this.createButton(calDetailInfoButtonComposite, Messages.getString("copy")); WidgetTestUtil.setTestId(this, "copy", calDetailInfoCopyButton); this.calDetailInfoCopyButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Integer order = calInfoListComposite.getSelection(); if (order != null) { // ? Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); CalendarDetailDialog dialog = new CalendarDetailDialog(shell, calInfoListComposite.getManagerName(), calInfoListComposite.getDetailList().get(order - 1), calInfoListComposite.getOwnerRoleId()); if (dialog.open() == IDialogConstants.OK_ID) { calInfoListComposite.getDetailList().add(dialog.getInputData()); calInfoListComposite.setSelection(); } } else { MessageDialog.openWarning(null, Messages.getString("warning"), Messages.getString("message.monitor.30")); } } }); // ? this.calDetailInfoUpButton = this.createButton(calDetailInfoButtonComposite, Messages.getString("up")); WidgetTestUtil.setTestId(this, "up", calDetailInfoUpButton); this.calDetailInfoUpButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Integer order = calInfoListComposite.getSelection(); if (order != null) { calInfoListComposite.up(); calInfoListComposite.update(); } else { MessageDialog.openWarning(null, Messages.getString("warning"), Messages.getString("message.monitor.30")); } } }); // ? this.calDetailInfoDownButton = this.createButton(calDetailInfoButtonComposite, Messages.getString("down")); WidgetTestUtil.setTestId(this, "down", calDetailInfoDownButton); this.calDetailInfoDownButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Integer order = calInfoListComposite.getSelection(); if (order != null) { calInfoListComposite.down(); calInfoListComposite.update(); } else { MessageDialog.openWarning(null, Messages.getString("warning"), Messages.getString("message.monitor.30")); } } }); }
From source file:com.clustercontrol.composite.action.NumberVerifyListener.java
License:Open Source License
/** * ?/* w ww. j a v a 2 s.c o m*/ * * @param e * @param inputText */ protected void checkRange(VerifyEvent e, String inputText) { try { //????? if (inputText.length() == 0) { return; } //??????????? if (this.low == null || this.high == null) { return; } //?? Integer input = Integer.valueOf(inputText.toString()); //? if (input.compareTo(low) < 0 || input.compareTo(high) > 0) { //? e.doit = false; String[] args = { this.low.toString(), this.high.toString() }; // MessageDialog.openWarning(null, Messages.getString("message.hinemos.1"), Messages.getString("message.hinemos.8", args)); } } catch (NumberFormatException ex) { //???? e.doit = false; } }
From source file:com.clustercontrol.composite.action.RealNumberVerifyListener.java
License:Open Source License
/** * ?//from ww w .jav a2 s.c om * * @param e * @param inputText */ protected void checkRange(VerifyEvent e, String inputText) { try { //????? if (inputText.length() == 0) { return; } //??????????? if (this.low == null || this.high == null) { return; } //?? Double input = Double.valueOf(inputText.toString()); //? if (input.compareTo(low) < 0 || input.compareTo(high) > 0) { //? e.doit = false; String[] args = { this.low.toString(), this.high.toString() }; // MessageDialog.openWarning(null, Messages.getString("message.hinemos.1"), Messages.getString("message.hinemos.8", args)); } } catch (NumberFormatException ex) { //???? e.doit = false; } }
From source file:com.clustercontrol.composite.action.StringVerifyListener.java
License:Open Source License
/** * ?//w w w .j ava 2s . c om * * @param e * @param inputText */ private void checkLength(VerifyEvent e, String inputText) { //?? //try { // if(inputText.getBytes("UTF-8").length > length){ /* * DBMS?SQL-ASCIIUTF-8???????? * UTF8????????????? * */ if (inputText.length() > length) { //? e.doit = false; String[] args = { this.length.toString() }; // MessageDialog.openWarning(null, Messages.getString("message.hinemos.1"), Messages.getString("message.hinemos.7", args)); } /*} catch (UnsupportedEncodingException e1) { //? e.doit = false; }*/ }
From source file:com.clustercontrol.composite.action.TimeVerifyListener.java
License:Open Source License
/** * ?// w w w .j a v a 2s . com * * @param e * @param inputText */ private void checkRange(VerifyEvent e, String inputText) { //?? //try { //if(inputText.getBytes("UTF-8").length > LENGTH){ if (inputText.length() > LENGTH) { //? e.doit = false; String[] args = { LENGTH.toString() }; // MessageDialog.openWarning(null, Messages.getString("message.hinemos.1"), Messages.getString("message.hinemos.7", args)); } /*} catch (UnsupportedEncodingException e1) { //? e.doit = false; }*/ }