@Override public void handleArtifactEvent(ArtifactEvent artifactEvent, Sender sender) { final Collection<EventBasicGuidArtifact> deletedPurgedArts = artifactEvent.get(EventModType.Deleted, EventModType.Purged); if (deletedPurgedArts.isEmpty()) { return; } Displays.ensureInDisplayThread( new Runnable() { @Override public void run() { if (getViewer() != null) { AbstractArtifactSearchResult results = getInput(); if (results != null) { for (EventBasicGuidArtifact guidArt : deletedPurgedArts) { for (Match match : results.getMatches(guidArt)) { results.removeMatch(match); } } getViewer().refresh(); } } } }); }
private static int promptUserMutlipleChoices(ConflictManagerExternal conflictManager) throws OseeCoreException { boolean isAllConflictsResolved = !conflictManager.remainingConflictsExist(); Messages = constructMessage(conflictManager, isAllConflictsResolved); Choices = constructChoices(conflictManager, isAllConflictsResolved); final MutableInteger result = new MutableInteger(CANCEL); Displays.pendInDisplayThread( new Runnable() { @Override public void run() { MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), TITLE, null, Messages, MessageDialog.QUESTION, Choices, CANCEL); result.setValue(dialog.open()); } }); if (!isAllConflictsResolved) { // Since all conflicts were not resolved, options start with // Launch Merge Manager(1) instead of Commit(0) result.getValueAndInc(); } return result.getValue(); }
@Override public void run(TableLoadOption... tableLoadOptions) throws OseeCoreException { if (AtsUtil.isProductionDb()) { AWorkbench.popup("ERROR", "This should not to be run on production DB"); return; } MessageDialog dialog = new MessageDialog( Displays.getActiveShell(), getName(), null, getName() + "\n\nSelect Source or Destination Client", MessageDialog.QUESTION, new String[] { "Source Client", "Destination Client - Start", "Destination Client - End", "Cancel" }, 2); int result = dialog.open(); resultData = new XResultData(); if (result == 0) { runClientTest(); } else if (result == 1) { EntryDialog diag = new EntryDialog(getName(), "Enter tt number of Source Client created Action"); if (diag.open() == 0) { runDestinationTestStart(diag.getEntry()); } } else if (result == 2) { EntryDialog diag = new EntryDialog(getName(), "Enter tt number of Source Client created Action"); if (diag.open() == 0) { runDestinationTestEnd(diag.getEntry()); } } }
@Override public Object executeWithException(ExecutionEvent event, IStructuredSelection selection) throws OseeCoreException { Branch selectedBranch = Handlers.getBranchesFromStructuredSelection(selection).iterator().next(); EntryDialog ed = new EntryDialog( "Set Associated Artifact", "Set Associated Artifact for Branch\n\n\"" + selectedBranch.getName() + "\"" + (selectedBranch.getAssociatedArtifactId() != null ? "\n\nCurrently: " + selectedBranch.getAssociatedArtifactId() : "") + "\n\nEnter new Artifact Id to associate:"); ed.setEntry(String.valueOf(selectedBranch.getAssociatedArtifactId())); if (ed.open() == 0) { String artId = ed.getEntry(); Artifact associatedArtifact = ArtifactQuery.getArtifactFromId(Integer.parseInt(artId), BranchManager.getCommonBranch()); if (MessageDialog.openConfirm( Displays.getActiveShell(), "Set Associated Artifact", "Set Associated Artifact for Branch\n\n\"" + selectedBranch.getName() + "\"\nto\nArtifact: " + associatedArtifact)) { selectedBranch.setAssociatedArtifactId(Integer.parseInt(artId)); BranchManager.persist(selectedBranch); } } return null; }
private void handleRunButton() { ScriptRunJob runJob = new ScriptRunJob(getTestManager()); if (runJob.isRunAllowed()) { runJob.setPriority(Job.LONG); runJob.setUser(true); runJob.schedule(); } else { MessageDialog.openError(Displays.getActiveShell(), "Error", "Test Manager Settings Error"); } }
public SMAEstimatedHoursHeader( Composite parent, int style, final AbstractWorkflowArtifact sma, final SMAEditor editor) { super(parent, style); this.awa = sma; setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); setLayout(ALayout.getZeroMarginLayout(2, false)); editor.getToolkit().adapt(this); try { if (!sma.isCancelled() && !sma.isCompleted()) { Hyperlink link = editor.getToolkit().createHyperlink(this, LABEL, SWT.NONE); link.addHyperlinkListener( new IHyperlinkListener() { @Override public void linkEntered(HyperlinkEvent e) { // do nothing } @Override public void linkExited(HyperlinkEvent e) { // do nothing } @Override public void linkActivated(HyperlinkEvent e) { try { if (editor.isDirty()) { editor.doSave(null); } PromptChangeUtil.promptChangeAttribute( sma, AtsAttributeTypes.EstimatedHours, true, false); } catch (Exception ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } } }); } else { Label origLabel = editor.getToolkit().createLabel(this, LABEL); origLabel.setLayoutData(new GridData()); } valueLabel = editor.getToolkit().createLabel(this, "0.0"); valueLabel.setToolTipText(getToolTip()); valueLabel.setLayoutData(new GridData()); updateLabel(sma); } catch (OseeCoreException ex) { Label errorLabel = editor.getToolkit().createLabel(this, "Error: " + ex.getLocalizedMessage()); errorLabel.setForeground(Displays.getSystemColor(SWT.COLOR_RED)); OseeLog.log(Activator.class, Level.SEVERE, ex); } }
private Object getWindowLocalKey() { Object key; if (PlatformUI.isWorkbenchRunning()) { Displays.ensureInDisplayThread(windowKey); key = windowKey.getKey(); } else { key = NON_WINDOW; } return key; }
public void clear(boolean forcePend) { Displays.ensureInDisplayThread( new Runnable() { @Override public void run() { if (Widgets.isAccessible(xViewer.getControl())) { xViewer.setInput(Collections.emptyList()); xViewer.refresh(); } }; }, forcePend); }
private void handleUserAuthenticated() { Displays.ensureInDisplayThread( new Runnable() { @Override public void run() { if (branchSelectEnabled != null && branchSelectEnabled.isDisposed() != true && isFeatureEnabled() != false) { handleBranchSelectEnabled(branchSelectEnabled.getSelection()); } } }); }
public void setFeatureEnabled(final boolean isEnabled) { Displays.ensureInDisplayThread( new Runnable() { @Override public void run() { featureEnabled = isEnabled; handleBranchSelectEnabled(false); statusLabel.setText(featureEnabled != true ? FEATURE_DISABLED : ""); setEnabled(featureEnabled); setSelectable(featureEnabled); } }); }
private void setSelectable(final boolean isSelectable) { Displays.ensureInDisplayThread( new Runnable() { @Override public void run() { if (isSelectable != false) { stackedLayout.topControl = selectableComposite; } else { stackedLayout.topControl = statusComposite; } group.layout(); } }); }
@Override public void run() { Displays.ensureInDisplayThread( new Runnable() { @Override public void run() { try { if (!runButton.isEnabled()) { abortBatchButton.setEnabled(true); abortButton.setEnabled(true); } } catch (Throwable th) { } } }); }
@Override public boolean onConnectionLost() { boolean result = getScriptManager().onConnectionLost(); Displays.ensureInDisplayThread( new Runnable() { @Override public void run() { runButton.setEnabled(false); abortButton.setEnabled(false); abortBatchButton.setEnabled(false); scriptTable.onConnectionChanged(false); statusWindow.setValue( UpdateableLabel.HOSTLABEL.name(), NOT_CONNECTED, SWT.BOLD, SWT.COLOR_DARK_RED); statusWindow.refresh(); } }); return result; }
public static IStatus runIt( IProgressMonitor monitor, String jobName, Collection<TeamWorkFlowArtifact> teamArts, IAttributeType attributeType) { XResultData rd = new XResultData(); try { if (teamArts.isEmpty()) { throw new OseeStateException("No Actions/Workflows Specified"); } retrieveData(monitor, teamArts, attributeType, rd); if (rd.toString().equals("")) { rd.log("No Problems Found"); } final String html = XResultDataUI.getReport(rd, jobName) .getManipulatedHtml(Arrays.asList(Manipulations.NONE)); final String title = jobName; Displays.pendInDisplayThread( new Runnable() { @Override public void run() { Result result = new HtmlExportTable(title, html, true, false).exportCsv(); if (result.isFalse()) { AWorkbench.popup(result); return; } AWorkbench.popup( title, "Completed " + title + "\n\nFile saved to " + System.getProperty("user.home") + File.separator + "table.csv"); } }); monitor.done(); return Status.OK_STATUS; } catch (Exception ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); return new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Failed", ex); } }
private static boolean promptUser(Branch sourceBranch, List<Branch> destinationBranches) throws OseeCoreException { final MutableBoolean isUserSure = new MutableBoolean(false); final String message = constructConfirmMessage(sourceBranch, destinationBranches); Displays.pendInDisplayThread( new Runnable() { @Override public void run() { isUserSure.setValue( MessageDialog.openConfirm( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Delete Merge Branch", message)); } }); return isUserSure.booleanValue(); }
public static void closeView(final String viewId, final String secondaryId) { if (Strings.isValid(viewId)) { Displays.ensureInDisplayThread( new Runnable() { @Override public void run() { IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench != null) { IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); if (workbenchWindow != null) { IWorkbenchPage workbenchPage = workbenchWindow.getActivePage(); if (workbenchPage != null) { workbenchPage.hideView(workbenchPage.findViewReference(viewId, secondaryId)); } } } } }); } }
@Override public boolean onConnection(final ConnectionEvent event) { boolean result = getScriptManager().connect(event); Displays.ensureInDisplayThread( new Runnable() { @Override public void run() { runButton.setEnabled(true); abortButton.setEnabled(false); abortBatchButton.setEnabled(false); scriptTable.onConnectionChanged(true); statusWindow.setValue( UpdateableLabel.HOSTLABEL.name(), event.getProperties().getStation(), SWT.BOLD, SWT.COLOR_DARK_GREEN); statusWindow.refresh(); } }); return result; }
private void createStatusBar(Composite parent) { statusComposite = new Composite(parent, SWT.BORDER); statusComposite.setLayout(new GridLayout(2, false)); statusComposite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false)); statusComposite.setBackground(Displays.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); statusComposite.setForeground(Displays.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); Label imageLabel = new Label(statusComposite, SWT.NONE); imageLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); imageLabel.setImage( PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK)); imageLabel.setBackground(Displays.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); imageLabel.setForeground(Displays.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); statusLabel = new Label(statusComposite, SWT.NONE); statusLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); statusLabel.setText(""); statusLabel.setBackground(Displays.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); statusLabel.setForeground(Displays.getSystemColor(SWT.COLOR_RED)); }
private void runClientTest() throws OseeCoreException { String title = getName() + " - Destination Client Test"; resultData.log("Running " + title); NewActionJob job = null; job = new NewActionJob( "tt", "description", ChangeType.Improvement, "1", null, false, getActionableItemsByToken(Arrays.asList(atsActionableItem)), null, null); job.setUser(true); job.setPriority(Job.LONG); job.schedule(); try { job.join(); } catch (InterruptedException ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); } Artifact actionArt = job.getActionArt(); resultData.log("Created Action " + actionArt); TeamWorkFlowArtifact teamArt = ActionManager.getFirstTeam(actionArt); // Make current user assignee for convenience to developer teamArt.getStateMgr().addAssignee(AtsClientService.get().getUserAdmin().getCurrentUser()); teamArt.persist(getClass().getSimpleName()); validateActionAtStart(actionArt); // Wait for destination client to start if (!MessageDialog.openConfirm( Displays.getActiveShell(), getName(), "Launch \"Destination Client - Start\" test, enter \"" + actionArt.getName().replaceFirst("tt ", "") + "\" and press Ok")) { return; } int sleepTime = 250; makeChanges1(teamArt); sleep(sleepTime); makeChanges2(teamArt); sleep(sleepTime); makeChanges3(teamArt); sleep(sleepTime); makeChanges4(teamArt); sleep(sleepTime); makeChanges5(teamArt); sleep(sleepTime); makeChanges6(teamArt); sleep(sleepTime); makeChanges7(teamArt); sleep(sleepTime); validateActionAtEnd(actionArt); // Wait for destination client to end if (!MessageDialog.openConfirm( Displays.getActiveShell(), getName(), "Launch \"Destination Client - End\" test, enter \"" + actionArt.getName().replaceFirst("tt ", "") + "\" and press Ok")) { return; } XResultDataUI.report(resultData, title); }
public Result export(String speratorChar, String fileExtension) { if (!popupConfirm || popupConfirm && MessageDialog.openConfirm( Displays.getActiveShell(), "Export Table", "Export Table to CSV?")) { StringBuilder sb = new StringBuilder(); sb.append(title + "\n"); String htmlStr = AHTML.htmlToText(html); Matcher m = Pattern.compile( "<table.*?</table>", Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE) .matcher(htmlStr); if (m.find()) { String csv = m.group(); Matcher rowM = Pattern.compile( "<tr.*?>(.*?)</tr>", Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE) .matcher(csv); while (rowM.find()) { String row = rowM.group(1); row = row.replaceAll("[\n\r]*", ""); // Handle all the headers for (String tag : elementTags) { Matcher thM = Pattern.compile( "<" + tag + ".*?>(.*?)</" + tag + ">", Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE) .matcher(row); String csvRow = ""; while (thM.find()) { String cellStr = removeLeadTrailSpaces(thM.group(1)); String excelTextPrefix = (excelTextFields && !cellStr.contains(",")) ? "=" : ""; csvRow += excelTextPrefix + "\"" + cellStr + "\"" + speratorChar; } if (!csvRow.equals("")) { csvRow = csvRow.replaceFirst(speratorChar + "$", "\n"); sb.append(csvRow); } } } String path = ""; if (popupConfirm) { FileDialog dialog = new FileDialog(Displays.getActiveShell(), SWT.SAVE | SWT.SINGLE); dialog.setFilterExtensions(new String[] {"*." + fileExtension}); dialog.setFilterPath(System.getProperty("user.home")); dialog.setFileName("table.csv"); path = dialog.open(); } else { path = System.getProperty("user.home") + File.separator + "table." + fileExtension; } if (path != null) { try { File file = new File(path); Lib.writeStringToFile(sb.toString(), file); if (openInSystem) { Program.launch(file.getAbsolutePath()); } return Result.TrueResult; } catch (IOException ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } } } else { AWorkbench.popup("ERROR", "Can't find table in results.\n\nNothing to export"); } } return Result.FalseResult; }