public Image loadImage(File file) { if (OSExplorer.getInstance().isRoot(file)) { return loadImage("drive.png"); } else if (file.isDirectory()) { return loadImage("folder.png"); } else { String extension = OSExplorer.getInstance().getExtension(file); if (extension.equals("")) { return loadImage("file.png"); } else { Program program = Program.findProgram(extension); if (program == null) { return loadImage("file.png"); } else { return loadImage(program); } } } }
@Override protected Composite createViewerToolTipContentArea(Event event, ViewerCell cell, Composite parent) { final Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false)); composite.setBackground(rowColorBack); Plugin plugin = (Plugin) cell.getElement(); Hyperlink button = new Hyperlink(composite, SWT.FLAT); button.setText("\uf05A"); button.setFont(fontAwesome); button.setBackground(composite.getBackground()); button.setForeground(rowColorTitle); button.setUnderlined(false); button.addListener (SWT.MouseDown, e -> Program.launch(GLUON_PLUGIN_URL + plugin.getUrl())); button.setToolTipText("Click to access the service's JavaDoc"); Label text = new Label(composite, SWT.LEFT); final String description = plugin.getDescription(); text.setText(description.contains(".") ? description.substring(0, description.indexOf(".")) : description); text.setBackground(composite.getBackground()); text.setForeground(rowColorTitle); composite.pack(); return composite; }
public LinkComposite ( final Composite parent, final int style, final String format ) { super ( parent, style ); final RowLayout layout = new RowLayout (); layout.wrap = false; layout.center = true; layout.spacing = 7; layout.pack = true; setLayout ( layout ); this.textLabel = new Link ( this, SWT.NONE ); this.textLabel.setText ( format ); this.textLabel.addSelectionListener ( new SelectionAdapter () { @Override public void widgetSelected ( final SelectionEvent event ) { logger.info ( "LinkComponent selected: {}", event.text ); //$NON-NLS-1$ Program.launch ( event.text ); } } ); }
private static void launchURL(String s) { Program program = Program.findProgram(".html"); if (program != null && program.getName().contains("Chrome")) { try { Field field = Program.class.getDeclaredField("command"); field.setAccessible(true); String command = (String) field.get(program); command = command.replaceAll("%[1lL]", s); command = command.replace(" --", ""); PluginInitializer.getDefaultInterface().getUtilities().createProcess(command + " -incognito"); } catch (Exception e1) { e1.printStackTrace(); Utils.launch(s); } } else { Utils.launch(s); } }
@Override public boolean isProgramInstalled( String extension, String name ) { if ( !extension.startsWith( "." )){ extension = "." + extension; } Program program = Program.findProgram( extension ); return( program == null ? false:(program.getName().toLowerCase(Locale.US) .contains(name.toLowerCase(Locale.US)))); }
/** * * void */ protected void createCompleteMessageDialog() { boolean result = MessageDialog.openConfirm(getShell(), UMLMessage.MESSAGE_COMPLETE_DOCUMENT_CREATION,//"문서산출물 생성완료", fileLocation + UMLMessage.MESSAGE_DOCUMENT_HAS_BEEN_CREATED);//" 문서가 생성되었습니다. 생성된 문서를 보시겠습니까?"); if( result ) { File file = new File(fileLocation); if( file.exists() ) { Program program = Program.findProgram(file.getName().substring(file.getName().lastIndexOf(UICoreConstant.PROJECT_CONSTANTS__DOT))); if (null != program) { String string = file.getAbsolutePath().toString(); program.execute(string); } } } }
protected void createControls() { group = new Group(this, SWT.NONE); group.setLayout(new GridLayout(3, false)); imageLabel = new Label(group, SWT.NONE); GridDataFactory.fillDefaults().grab(false, false).align(SWT.BEGINNING, SWT.CENTER).applyTo(imageLabel); textLabel = new Link(group, SWT.WRAP); textLabel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (DOWNLOAD_LINK.equals(e.text)) { Program.launch(DOWNLOAD_LINK); } else { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), PREF_PAGE_ID, new String[] { DISPLAY_ID }, null); dialog.setSelectedNode("DISPLAY_ID"); dialog.open(); } } }); GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(textLabel); button = new Button(group, SWT.FLAT); button.setText("Download"); GridDataFactory.fillDefaults().grab(false, false).align(SWT.END, SWT.CENTER).applyTo(button); }
private void initialToolBar() { IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager(); toolBarManager.add(new Action("Save", ImageUtil.getImageDescriptor(Images.save)) { @Override public void run() { saveContents(); } }); toolBarManager.add(new Action("help", ImageUtil.getImageDescriptor(Images.help)) { @Override public void run() { Program.launch(HelpConstants.HELP_ALERT_SCRIPT); } }); }
private void displayHelp() { String curLang = CommonFunction.getSystemLanguage(); StringBuffer sbHelp = new StringBuffer("help"); if (Util.isWindows()) { sbHelp.append(File.separator).append("csv2tbxdoc").append(File.separator); if (curLang.equalsIgnoreCase("zh")) { sbHelp.append("tbxmaker_zh-cn.chm"); } else { sbHelp.append("tbxmaker.chm"); } Program.launch(PluginUtil.getConfigurationFilePath(sbHelp.toString())); } else { sbHelp.append(File.separator).append("csv2tbxdoc").append(File.separator); if (curLang.equalsIgnoreCase("zh")) { sbHelp.append("zh-cn"); } else { sbHelp.append("en"); } sbHelp.append(File.separator).append("toc.xml"); PluginHelpDialog dialog = new PluginHelpDialog(getShell(), PluginUtil.getConfigurationFilePath(sbHelp.toString()), Messages.getString("dialog.TBXMakerDialog.helpDialogTitle")); dialog.open(); } }
@Override protected Control createMessageArea(Composite composite) { Image image = getImage(); if (image != null) { imageLabel = new Label(composite, SWT.NULL); image.setBackground(imageLabel.getBackground()); imageLabel.setImage(image); GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).applyTo(imageLabel); } if (message != null) { Link link = new Link(composite, getMessageLabelStyle()); link.setText(message); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, false) .hint(convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH), SWT.DEFAULT).applyTo(link); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Program.launch(linkUrl); } }); } return composite; }
protected void menuEventsForecast() { { MenuItem eventForecast = new MenuItem(eventsSubMenu, SWT.CASCADE); eventForecast.setText("Run a forecast based on technical analysis"); eventForecast.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent evt) { ActionDialog actionDialog = new ActionDialog(getShell(), "Info", "Running a neural network forecast on technical analysis is not available in this version.\n"+ "This feature is part of the advanced version including "+MainGui.APP_NAME+" Forecast engine.\n", null, "Click here for more information and a workable demo", new ActionDialogAction() { @Override public void action() { Program.launch("http://"+siteUrl); } }); actionDialog.open(); } }); } }
/** * build plugin info cell. */ protected void buildPluginInfoCell() { this.ascLink = new Link(this.dialog, SWT.NONE); this.ascLink.setText(BaseMessages.getString(PKG, "SapInputDialog.About.Plugin.Info")); GridData grdData = new GridData(); grdData.horizontalIndent = DEFAULT_INDENT; grdData.verticalIndent = DEFAULT_INDENT; this.ascLink.setLayoutData(grdData); this.ascLink.addListener(SWT.Selection, new Listener() { public void handleEvent(final Event event) { Program.launch(event.text); } }); }
/** * build plugin info cell. */ protected void buildPluginInfoCell() { this.ascLink = new Link(this.dialog, SWT.NONE); this.ascLink.setText(BaseMessages.getString(PKG, "TeraFastDialog.About.Plugin.Info")); GridData grdData = new GridData(); grdData.horizontalIndent = DEFAULT_INDENT; grdData.verticalIndent = DEFAULT_INDENT; this.ascLink.setLayoutData(grdData); this.ascLink.addListener(SWT.Selection, new Listener() { public void handleEvent(final Event event) { Program.launch(event.text); } }); }
/** * build plugin info cell. */ protected void buildPluginInfoCell() { this.ascLink = new Link(this.dialog, SWT.NONE); this.ascLink.setText(BaseMessages.getString(PKG, "OlapInputDialog.About.Plugin.Info")); GridData grdData = new GridData(); grdData.horizontalIndent = DEFAULT_INDENT; grdData.verticalIndent = DEFAULT_INDENT; this.ascLink.setLayoutData(grdData); this.ascLink.addListener(SWT.Selection, new Listener() { public void handleEvent(final Event event) { Program.launch(event.text); } }); }
protected void createDetailsMessage(Composite topControl, IDetailsMessage detailsMessage) { if(!detailsMessage.getDetailsMessage2().isPresent()) { return; } String additionalMessage = "\n" + detailsMessage.getDetailsMessage2().get(); helpControl = SWTFactoryUtil.createLink(topControl, SWT.WRAP, additionalMessage, gdfFillDefaults().grab(true, true).span(2, 1).create() ); helpControl.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String uri = e.text; if(uri.startsWith("http")) { Program.launch(uri); } else if(uri.startsWith("pref:")) { String prefId = StringUtil.removeStart("pref:", uri); WorkbenchUtils.openPreferencePage(helpControl.getShell(), prefId); } else { UIOperationsStatusHandler.handleInternalError("Unknown link URI:\n" + uri, null); } } }); }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { KinectManager kinectManager=KinectManager.INSTANCE; kinectManager.startKinect(); kinectManager.addSpeechListener(new SpeechListener() { @Override public void notifySpeech(String speech) { if(START_DEMO.equalsIgnoreCase(speech)){ Program.launch(FILE_PATH); } } @Override public Set<String> getWords() { Set<String> words=new HashSet<String>(); words.add(START_DEMO); return words; } }); kinectManager.startSpeechRecognition(); return null; }
/** * Creates a link. * * @param parent * @param text * @param tooltip * @param url */ private void createLink(Composite parent, String text, String tooltip, final String url){ Link link = new Link(parent, SWT.NONE); link.setLayoutData(SWTUtil.createFillHorizontallyGridData()); link.setText(text); link.setToolTipText(tooltip); link.setBackground(parent.getBackground()); link.addListener (SWT.Selection, new Listener () { public void handleEvent(Event event) { try { Program.launch(url); } catch (Exception e){ /* Ignore*/ } } }); }
protected void addLink(String label, final String url) { Link link = new Link(dialog, SWT.NONE); GridData linkLayout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER); linkLayout.horizontalSpan = 4; link.setLayoutData(linkLayout); link.setText(label + ": <a href=\"" + url + "\">" + url + "</a>"); link.addListener(SWT.Selection, new Listener() { public void handleEvent(Event evt) { Program.launch(url); } }); }
private void startEditLocal(Object object, ILocalDocumentService service, Shell parentShell){ Optional<File> file = service.add(object, new IConflictHandler() { @Override public Result getResult(){ if (MessageDialog.openQuestion(parentShell, Messages.StartEditLocalDocumentHandler_conflicttitle, Messages.StartEditLocalDocumentHandler_conflictmessage)) { return Result.KEEP; } else { return Result.OVERWRITE; } } }); if (file.isPresent()) { Program.launch(file.get().getAbsolutePath()); } else { MessageDialog.openError(parentShell, Messages.StartEditLocalDocumentHandler_errortitle, Messages.StartEditLocalDocumentHandler_errormessage); } }
public boolean doXRef(String refProvider, String refID){ try { int r = refID.lastIndexOf('.'); String ext = ""; //$NON-NLS-1$ if (r != -1) { ext = refID.substring(r + 1); } Program proggie = Program.findProgram(ext); if (proggie != null) { proggie.execute(refID); } else { if (Program.launch(refID) == false) { Runtime.getRuntime().exec(refID); } } } catch (Exception ex) { ElexisStatus status = new ElexisStatus(ElexisStatus.ERROR, Hub.PLUGIN_ID, ElexisStatus.CODE_NONE, Messages.ExternalLink_CouldNotStartFile, ex); StatusManager.getManager().handle(status); } return true; }
@Test public void exportEMediplanPdf() throws FileNotFoundException, IOException{ EMediplanServiceImpl impl = new EMediplanServiceImpl(); List<Patient> patients = TestData.getTestSzenarioInstance().getPatients(); ByteArrayOutputStream output = new ByteArrayOutputStream(); impl.exportEMediplanPdf( TestData.getTestSzenarioInstance().getMandator(), patients.get(0), getPatientMedication(patients.get(0)), output); if (WRITE_AND_OPEN) { try (FileOutputStream fout = new FileOutputStream( new File(CoreHub.getWritableUserDir(), "emediplan_test.pdf"))) { fout.write(output.toByteArray()); } Program.launch(CoreHub.getWritableUserDir().getAbsolutePath() + File.separator + "emediplan_test.pdf"); } assertTrue(output.size() > 100); }
/** * Run a program to view an external file * * @param filename */ public void execute(String filename){ try { int r = filename.lastIndexOf('.'); String ext = ""; //$NON-NLS-1$ if (r != -1) { ext = filename.substring(r + 1); } Program proggie = Program.findProgram(ext); if (proggie != null) { proggie.execute(filename); } else { if (Program.launch(filename) == false) { Runtime.getRuntime().exec(filename); } } } catch (Exception ex) { ExHandler.handle(ex); SWTHelper.showError(Messages.NotesDetail_couldNotLaunch, ex.getMessage()); } }
@Override public void run(){ // get actual fix medication of the patient Prescription medication = (Prescription) ElexisEventDispatcher.getSelected(Prescription.class); String ean = null; String num = ""; if (medication != null) { ean = medication.getArtikel().getEAN(); } if (ean != null && !ean.isEmpty() && ean.length() >= 9) { num = ean.substring(4, 9); } String url = "http://www.swissmedicinfo.ch/ShowText.aspx?textType=FI&lang=DE&authNr=" + num; //$NON-NLS-1$ Program.launch(url); }
public void execute(){ try { String ext = StringConstants.SPACE; //""; //$NON-NLS-1$ File temp = createTemporaryFile(null); Program proggie = Program.findProgram(ext); if (proggie != null) { proggie.execute(temp.getAbsolutePath()); } else { if (Program.launch(temp.getAbsolutePath()) == false) { Runtime.getRuntime().exec(temp.getAbsolutePath()); } } } catch (Exception ex) { ExHandler.handle(ex); SWTHelper.showError(Messages.DocHandle_runErrorHeading, ex.getMessage()); } }
public void run(IAction action) { try { lastAuthToken = UUID.randomUUID().toString(); lastAuthTokenExpiration = System.currentTimeMillis() + 5000; Program.launch(EnginePropertiesManager.PropertyName.APPLICATION_SERVER_CONVERTIGO_URL.getDefaultValue() + "/admin/login.html#authToken=" + lastAuthToken); } catch (Exception e) { ConvertigoPlugin.logException(e, "Error while opening the Convertigo administration page"); } }
public void run(IAction action) { try { Program.launch( EnginePropertiesManager.PropertyName.APPLICATION_SERVER_CONVERTIGO_URL.getDefaultValue()+"/swagger/ui/index.html?url=" + URLEncoder.encode(EnginePropertiesManager.PropertyName.APPLICATION_SERVER_CONVERTIGO_URL.getDefaultValue()+"/api?YAML","UTF-8")); } catch (Exception e) { ConvertigoPlugin.logException(e, "Error while opening the Swagger console"); } }
public void run(IAction action) { try { Program.launch("http://www.convertigo.com/technical-documentation/"); } catch (Exception e) { ConvertigoPlugin.logException(e, "Error while opening the Convertigo administration page"); } }
public void run() { Display display = Display.getDefault(); Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT); Shell shell = getParentShell(); shell.setCursor(waitCursor); try { ProjectExplorerView explorerView = getProjectExplorerView(); if (explorerView != null) { TreeObject treeObject = explorerView.getFirstSelectedTreeObject(); Object databaseObject = treeObject.getObject(); if ((databaseObject != null) && (databaseObject instanceof Project)) { Project project = (Project)treeObject.getObject(); Program.launch( EnginePropertiesManager.PropertyName.APPLICATION_SERVER_CONVERTIGO_URL.getDefaultValue()+"/projects/" + project.getName()); } } } catch (Throwable e) { ConvertigoPlugin.logException(e, "Unable to open the selected project!"); } finally { shell.setCursor(null); waitCursor.dispose(); } }
public void run() { Display display = Display.getDefault(); Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT); Shell shell = getParentShell(); shell.setCursor(waitCursor); try { ProjectExplorerView explorerView = getProjectExplorerView(); if (explorerView != null) { TreeObject treeObject = explorerView.getFirstSelectedTreeObject(); Object databaseObject = treeObject.getObject(); if ((databaseObject != null) && (databaseObject instanceof Project)) { Project project = (Project)treeObject.getObject(); Program.launch( EnginePropertiesManager.PropertyName.APPLICATION_SERVER_CONVERTIGO_URL.getDefaultValue()+"/swagger/ui/index.html?url=" + URLEncoder.encode(EnginePropertiesManager.PropertyName.APPLICATION_SERVER_CONVERTIGO_URL.getDefaultValue()+"/api?YAML&__project=" + project.getName(),"UTF-8")); } } } catch (Throwable e) { ConvertigoPlugin.logException(e, "Unable to open the Swagger console for selected project!"); } finally { shell.setCursor(null); waitCursor.dispose(); } }
@Override public void run() { Display display = Display.getDefault(); Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT); Shell shell = getParentShell(); shell.setCursor(waitCursor); try { ProjectExplorerView explorerView = getProjectExplorerView(); if (explorerView != null) { TreeObject treeObject = explorerView.getFirstSelectedTreeObject(); Object databaseObject = treeObject.getObject(); if ((databaseObject != null) && (databaseObject instanceof MobileApplication)) { MobileApplication mobileApplication = (MobileApplication) databaseObject; // Test plateform Program.launch( EnginePropertiesManager.PropertyName.APPLICATION_SERVER_CONVERTIGO_URL.getDefaultValue()+"/project.html#" + mobileApplication.getProject() + "?launch=webapp"); } } } catch (Throwable e) { ConvertigoPlugin.logException(e, "Unable to launch the mobile device selected project!"); } finally { shell.setCursor(null); waitCursor.dispose(); } }
@Override public void run() { Display display = Display.getDefault(); Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT); Shell shell = getParentShell(); shell.setCursor(waitCursor); try { ProjectExplorerView explorerView = getProjectExplorerView(); if (explorerView != null) { TreeObject treeObject = explorerView.getFirstSelectedTreeObject(); Object databaseObject = treeObject.getObject(); if ((databaseObject != null) && (databaseObject instanceof MobileApplication)) { MobileApplication mobileApplication = (MobileApplication) databaseObject; String SERVER_C8O_URL = EnginePropertiesManager.getProperty(PropertyName.APPLICATION_SERVER_CONVERTIGO_URL); Program.launch( SERVER_C8O_URL + "/projects/" + mobileApplication.getProject().getName() + "/DisplayObjects/mobile/index.html"); } } } catch (Throwable e) { ConvertigoPlugin.logException(e, "Unable to launch the mobile application selected!"); } finally { shell.setCursor(null); waitCursor.dispose(); } }