List of usage examples for org.eclipse.jface.dialogs MessageDialog openInformation
public static void openInformation(Shell parent, String title, String message)
From source file:ar.com.tadp.xml.rinzo.core.wizards.NewXMLStructureDefinitionWizardPage.java
License:Open Source License
@Override public IFile createNewFile() { try {/*www. j ava 2 s. co m*/ ErrorHandlerImpl errorHandler = new ErrorHandlerImpl(); OutputFormat outputFormat = this.formats.get(this.formatCombo.getText()); XmlInputFormat inputFormat = new XmlInputFormat(); SchemaCollection schemaCollection = inputFormat.load(this.getFiles(), new String[0], "xsd", errorHandler, null); IFile fileHandle = createFileHandle(this.getContainerFullPath().append(this.getFileName())); OutputDirectory outputDirectory = new LocalOutputDirectory(schemaCollection.getMainUri(), new File(fileHandle.getLocation().toString()), "xml", this.encodingCombo.getText(), Integer.valueOf(this.width.getText()), 4); outputFormat.output(schemaCollection, outputDirectory, new String[0], "xml", errorHandler); fileHandle.refreshLocal(IResource.DEPTH_ZERO, null); return fileHandle; } catch (Exception e) { MessageDialog.openInformation(null, "Definition Generation", "Error generating definition for file " + this.getFiles() + "\n\nError message:\n" + e.getLocalizedMessage()); e.printStackTrace(); return null; } }
From source file:aspectminingtool.dialogs.Sinergia.SinergiaSettings.java
License:Open Source License
public void open() { try {/*from w w w. j av a 2 s .co m*/ Shell parent = getParent(); dialogShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); { // Register as a resource user - SWTResourceManager will // handle the obtaining and disposing of resources // SWTResourceManager.registerResourceUser(dialogShell); } GridLayout dialogShellLayout = new GridLayout(); dialogShellLayout.makeColumnsEqualWidth = true; dialogShell.setLayout(dialogShellLayout); dialogShell.setText("Sinergia Settings"); dialogShell.setDragDetect(false); dialogShell.setSize(398, 355); { group1 = new Group(dialogShell, SWT.NONE); group1.setText("Fan-In Analysis"); GridLayout composite1Layout = new GridLayout(); composite1Layout.numColumns = 2; composite1Layout.marginLeft = 60; composite1Layout.makeColumnsEqualWidth = true; GridData composite1LData = new GridData(); composite1LData.horizontalAlignment = GridData.FILL; composite1LData.grabExcessHorizontalSpace = true; composite1LData.heightHint = 37; group1.setLayoutData(composite1LData); group1.setLayout(composite1Layout); { GridData compositeUmbralLData = new GridData(); compositeUmbralLData.horizontalAlignment = GridData.FILL; compositeUmbralLData.heightHint = 31; composite111 = new Composite(group1, SWT.NONE); GridLayout compositeUmbralLayout = new GridLayout(); compositeUmbralLayout.makeColumnsEqualWidth = true; compositeUmbralLayout.numColumns = 2; composite111.setLayout(compositeUmbralLayout); composite111.setLayoutData(compositeUmbralLData); { LabelUmbralFanIn = new CLabel(composite111, SWT.NONE); GridData labelUmbralLData = new GridData(); labelUmbralLData.horizontalIndent = -5; labelUmbralLData.widthHint = 65; labelUmbralLData.heightHint = 21; LabelUmbralFanIn.setLayoutData(labelUmbralLData); LabelUmbralFanIn.setText("Threshold"); } { TextUmbralFanIn = new Text(composite111, SWT.BORDER); GridData UmbralLData = new GridData(); UmbralLData.widthHint = 24; UmbralLData.heightHint = 15; TextUmbralFanIn.setLayoutData(UmbralLData); TextUmbralFanIn.setText("10"); } } { GridData compositeUmbral2LData = new GridData(); compositeUmbral2LData.horizontalAlignment = GridData.FILL; compositeUmbral2LData.heightHint = 31; composite112 = new Composite(group1, SWT.NONE); GridLayout compositeUmbral2Layout = new GridLayout(); compositeUmbral2Layout.makeColumnsEqualWidth = true; compositeUmbral2Layout.numColumns = 3; composite112.setLayout(compositeUmbral2Layout); composite112.setLayoutData(compositeUmbral2LData); { LabelConfianzaFanIn = new CLabel(composite112, SWT.NONE); GridData labelConfianzaLData = new GridData(); labelConfianzaLData.horizontalIndent = -5; labelConfianzaLData.widthHint = 40; labelConfianzaLData.heightHint = 21; LabelConfianzaFanIn.setLayoutData(labelConfianzaLData); LabelConfianzaFanIn.setText("Trust"); } { TextConfianzaFanIn = new Text(composite112, SWT.BORDER); GridData UmbralLData = new GridData(); UmbralLData.widthHint = 24; UmbralLData.heightHint = 15; TextConfianzaFanIn.setLayoutData(UmbralLData); TextConfianzaFanIn.setText("33"); } { PercentLabel = new Label(composite112, SWT.NONE); GridData PercentLabelLData = new GridData(); PercentLabel.setLayoutData(PercentLabelLData); PercentLabel.setText("%"); } } } group9 = new Group(dialogShell, SWT.NONE); group9.setText("Unique Methods Analysis"); GridLayout composite9Layout = new GridLayout(); composite9Layout.numColumns = 2; composite9Layout.marginLeft = 60; GridData composite9LData = new GridData(); composite9LData.horizontalAlignment = GridData.FILL; composite9LData.grabExcessHorizontalSpace = true; composite9LData.heightHint = 37; group9.setLayoutData(composite9LData); group9.setLayout(composite9Layout); { GridData composite2LData = new GridData(); composite991 = new Composite(group9, SWT.NONE); GridLayout composite2Layout = new GridLayout(); composite2Layout.makeColumnsEqualWidth = true; composite2Layout.numColumns = 2; composite991.setLayout(composite2Layout); composite991.setLayoutData(composite2LData); } { LabelUmbralUniqueM = new CLabel(composite991, SWT.NONE); GridData LabelUmbralUniqueMLData = new GridData(); LabelUmbralUniqueMLData.horizontalIndent = -5; LabelUmbralUniqueMLData.widthHint = 65; LabelUmbralUniqueMLData.heightHint = 21; LabelUmbralUniqueM.setLayoutData(LabelUmbralUniqueMLData); LabelUmbralUniqueM.setText("Threshold"); } { TextUmbralUniqueM = new Text(composite991, SWT.BORDER); GridData TextUmbralUniqueMLData = new GridData(); TextUmbralUniqueMLData.widthHint = 24; TextUmbralUniqueMLData.heightHint = 15; TextUmbralUniqueM.setLayoutData(TextUmbralUniqueMLData); TextUmbralUniqueM.setText("10"); } { GridData composite12LData = new GridData(); composite992 = new Composite(group9, SWT.NONE); GridLayout composite12Layout = new GridLayout(); composite12Layout.makeColumnsEqualWidth = true; composite12Layout.numColumns = 3; composite992.setLayout(composite12Layout); composite992.setLayoutData(composite12LData); } { LabelConfianzaUniqueM = new CLabel(composite992, SWT.NONE); GridData LabelConfianzaUniqueMLData = new GridData(); LabelConfianzaUniqueMLData.horizontalIndent = -5; LabelConfianzaUniqueMLData.widthHint = 40; LabelConfianzaUniqueMLData.heightHint = 21; LabelConfianzaUniqueM.setLayoutData(LabelConfianzaUniqueMLData); LabelConfianzaUniqueM.setText("Trust"); } { TextConfianzaUniqueM = new Text(composite992, SWT.BORDER); GridData TextConfianzaUniqueMLData = new GridData(); TextConfianzaUniqueMLData.widthHint = 24; TextConfianzaUniqueMLData.heightHint = 15; TextConfianzaUniqueM.setLayoutData(TextConfianzaUniqueMLData); TextConfianzaUniqueM.setText("33"); } { PercentLabelUnique = new Label(composite992, SWT.NONE); GridData PercentLabelUniqueLData = new GridData(); PercentLabelUnique.setLayoutData(PercentLabelUniqueLData); PercentLabelUnique.setText("%"); } { group6 = new Group(dialogShell, SWT.NONE); group6.setText("Execution Relations Analysis"); GridLayout composite6Layout = new GridLayout(); composite6Layout.makeColumnsEqualWidth = true; composite6Layout.marginLeft = 60; composite6Layout.numColumns = 2; GridData composite6LData = new GridData(); composite6LData.horizontalAlignment = GridData.FILL; composite6LData.grabExcessHorizontalSpace = true; group6.setLayoutData(composite6LData); group6.setLayout(composite6Layout); { GridData composite3LData = new GridData(); composite661 = new Composite(group6, SWT.NONE); GridLayout composite3Layout = new GridLayout(); composite3Layout.makeColumnsEqualWidth = true; composite3Layout.numColumns = 2; composite661.setLayout(composite3Layout); composite661.setLayoutData(composite3LData); } { LabelUmbralFlowGraph = new CLabel(composite661, SWT.NONE); GridData LabelUmbralFlowGraphLData = new GridData(); LabelUmbralFlowGraphLData.horizontalIndent = -5; LabelUmbralFlowGraphLData.widthHint = 65; LabelUmbralFlowGraphLData.heightHint = 21; LabelUmbralFlowGraph.setLayoutData(LabelUmbralFlowGraphLData); LabelUmbralFlowGraph.setText("Threshold"); } { TextUmbralFlowGraph = new Text(composite661, SWT.BORDER); GridData TextUmbralFlowGraphLData = new GridData(); TextUmbralFlowGraphLData.widthHint = 24; TextUmbralFlowGraphLData.heightHint = 15; TextUmbralFlowGraph.setLayoutData(TextUmbralFlowGraphLData); TextUmbralFlowGraph.setText("10"); } { GridData composite13LData = new GridData(); composite662 = new Composite(group6, SWT.NONE); GridLayout composite3Layout = new GridLayout(); composite3Layout.makeColumnsEqualWidth = true; composite3Layout.numColumns = 3; composite662.setLayout(composite3Layout); composite662.setLayoutData(composite13LData); } { LabelConfianzaFlowGraph = new CLabel(composite662, SWT.NONE); GridData LabelConfianzaFlowGraphLData = new GridData(); LabelConfianzaFlowGraphLData.horizontalIndent = -5; LabelConfianzaFlowGraphLData.widthHint = 40; LabelConfianzaFlowGraphLData.heightHint = 21; LabelConfianzaFlowGraph.setLayoutData(LabelConfianzaFlowGraphLData); LabelConfianzaFlowGraph.setText("Trust"); } { TextConfianzaFlowGraph = new Text(composite662, SWT.BORDER); GridData TextUmbralFlowGraphLData = new GridData(); TextUmbralFlowGraphLData.widthHint = 24; TextUmbralFlowGraphLData.heightHint = 15; TextConfianzaFlowGraph.setLayoutData(TextUmbralFlowGraphLData); TextConfianzaFlowGraph.setText("33"); } { PercentLabelFlow = new Label(composite662, SWT.NONE); GridData PercentLabelFlowLData = new GridData(); PercentLabelFlow.setLayoutData(PercentLabelFlowLData); PercentLabelFlow.setText("%"); } group0 = new Group(dialogShell, SWT.NONE); group0.setText("Sinergia Analysis"); GridLayout composite11Layout = new GridLayout(); composite11Layout.makeColumnsEqualWidth = true; composite11Layout.marginLeft = 60; composite11Layout.numColumns = 2; GridData composite11LData = new GridData(); composite11LData.horizontalAlignment = GridData.FILL; composite11LData.grabExcessHorizontalSpace = true; group0.setLayoutData(composite11LData); group0.setLayout(composite11Layout); { composite001 = new Composite(group0, SWT.NONE); GridLayout composite7Layout = new GridLayout(); GridData composite7LData = new GridData(); composite7LData.widthHint = 166; composite7LData.heightHint = 31; composite001.setLayoutData(composite7LData); composite001.setLayout(composite7Layout); composite7Layout.numColumns = 3; { LabelUmbralSinergia = new CLabel(composite001, SWT.NONE); GridData LabelUmbralSinergiaLData = new GridData(); LabelUmbralSinergiaLData.horizontalIndent = -5; LabelUmbralSinergiaLData.widthHint = 65; LabelUmbralSinergiaLData.heightHint = 21; LabelUmbralSinergia.setLayoutData(LabelUmbralSinergiaLData); LabelUmbralSinergia.setText("Threshold"); } { TextUmbralSinergia = new Text(composite001, SWT.BORDER); GridData TextUmbralSinergiaLData = new GridData(); TextUmbralSinergiaLData.widthHint = 24; TextUmbralSinergiaLData.heightHint = 15; TextUmbralSinergia.setLayoutData(TextUmbralSinergiaLData); TextUmbralSinergia.setText("50"); } { PercentLabelSinergia = new Label(composite001, SWT.NONE); GridData PercentLabelSinergiaLData = new GridData(); PercentLabelSinergia.setLayoutData(PercentLabelSinergiaLData); PercentLabelSinergia.setText("%"); } } } { composite5 = new Composite(dialogShell, SWT.NONE); GridLayout composite5Layout = new GridLayout(); composite5Layout.numColumns = 2; GridData composite5LData = new GridData(); composite5LData.horizontalAlignment = GridData.FILL; composite5LData.grabExcessHorizontalSpace = true; composite5.setLayoutData(composite5LData); composite5.setLayout(composite5Layout); { okButton = new Button(composite5, SWT.PUSH | SWT.CENTER); GridData okButtonLData = new GridData(); okButtonLData.horizontalAlignment = GridData.END; okButtonLData.grabExcessHorizontalSpace = true; okButtonLData.widthHint = 60; okButtonLData.heightHint = 33; okButton.setLayoutData(okButtonLData); okButton.setText("OK"); okButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { SinergiaAnalysis sA = new SinergiaAnalysis(javaProject); sA.assertRestricciones(getRestricciones()); // sA.calculateFacts(); // Shell shell = new Shell(); // // try { // new ProgressMonitorDialog(shell).run(true, true, // sA); // // } catch (InvocationTargetException e) { // MessageDialog.openError(shell, "Error", // e.getMessage()); // } catch (InterruptedException e) { // // TODO Auto-generated catch block // MessageDialog.openInformation(shell, "Cancelled", // e.getMessage()); // } Shell shell = new Shell(); try { sA.ejecutar(); } catch (InvocationTargetException e) { MessageDialog.openError(shell, "Error", e.getMessage()); } catch (InterruptedException e) { MessageDialog.openInformation(shell, "Cancelled", e.getMessage()); } // leer seleccion de rbol // leer los checkboxs // mandar a hacer filtrados dialogShell.dispose(); } }); } { CancelButton = new Button(composite5, SWT.PUSH | SWT.CENTER); GridData cancelButtonLData = new GridData(); cancelButtonLData.horizontalAlignment = GridData.END; cancelButtonLData.widthHint = 60; cancelButtonLData.heightHint = 33; CancelButton.setLayoutData(cancelButtonLData); CancelButton.setText("Cancelar"); CancelButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { System.out.println("okButton.widgetSelected, event=" + evt); dialogShell.dispose(); } }); } } dialogShell.layout(); dialogShell.pack(); // dialogShell.setLocation(getParent().toDisplay(100, 100)); dialogShell.open(); Display display = dialogShell.getDisplay(); while (!dialogShell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:at.bestsolution.code.swt.resources.handlers.NewFileHandler.java
License:Open Source License
@Execute public void createFile(Shell shell, @Named(WorkspaceViewer.SELECTED_RESOURCE_KEY) IResource selectedResource) { IContainer container = null;//www. j av a 2 s . co m if (selectedResource instanceof IContainer) { container = (IContainer) selectedResource; } else { container = selectedResource.getParent(); } if (container != null) { NewFileDialog d = new NewFileDialog(shell, container); d.open(); } else { MessageDialog.openInformation(shell, "No parent selected", "You need to select a parent folder"); } }
From source file:at.bestsolution.code.swt.resources.handlers.NewFolderHandler.java
License:Open Source License
@Execute public void createFolder(Shell shell, @Named(WorkspaceViewer.SELECTED_RESOURCE_KEY) IResource selectedResource) { IContainer container = null;//from ww w . j a va2s.c o m if (selectedResource instanceof IContainer) { container = (IContainer) selectedResource; } else { container = selectedResource.getParent(); } if (container != null) { NewFolderDialog d = new NewFolderDialog(shell, container); d.open(); } else { MessageDialog.openInformation(shell, "No parent selected", "You need to select a parent folder"); } }
From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.AddFontDialog.java
License:Open Source License
@Override protected Control createDialogContent(Composite parent) { o = ParametersFactory.eINSTANCE.createKeyValuePair(); Composite area = new Composite(parent, SWT.NONE); area.setLayout(new GridLayout(1, false)); area.setLayoutData(new GridData(GridData.FILL_BOTH)); getShell().setText("Add font "); setTitle("Add font"); setMessage("Enter informations about the font to add"); Composite container = new Composite(area, SWT.NONE); container.setLayout(new GridLayout(3, false)); container.setLayoutData(new GridData(GridData.FILL_BOTH)); IWidgetValueProperty tProp = WidgetProperties.text(SWT.Modify); {// www .ja v a2s. c o m Label l = new Label(container, SWT.NONE); l.setText("Font name*:"); tFontName = new Text(container, SWT.BORDER); GridData tFontGD = new GridData(GridData.FILL_HORIZONTAL); tFontGD.horizontalSpan = 2; tFontName.setLayoutData(tFontGD); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, KEY_VALUE_PAIR__KEY); dbContext.bindValue(tProp.observeDelayed(DELAY, tFontName), prop.observe(o), new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST), new EMFUpdateValueStrategy()); } { Label l = new Label(container, SWT.NONE); l.setText("File*:"); tFile = new Text(container, SWT.BORDER); tFile.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); tFile.setEditable(false); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, KEY_VALUE_PAIR__VALUE); dbContext.bindValue(tProp.observeDelayed(DELAY, tFile), prop.observe(o), new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST), new EMFUpdateValueStrategy()); Button b = new Button(container, SWT.NONE); b.setText("Browse ..."); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { FilteredResourcesSelectionDialog d = new FilteredResourcesSelectionDialog(getShell(), false, resourceContainer, IResource.FILE) { @Override protected IStatus validateItem(final Object item) { IFile f = (IFile) item; if (f.getParent() instanceof IProject) { return new Status(IStatus.ERROR, JavaFXUIPlugin.PLUGIN_ID, "The selected resource has to be part of the source folder"); } if (!f.getName().endsWith(".ttf")) { return new Status(IStatus.ERROR, JavaFXUIPlugin.PLUGIN_ID, "The selected resource does not seem to be a font"); } return super.validateItem(item); } }; if (d.open() == ResourceSelectionDialog.OK) { Object[] rv = d.getResult(); if (rv.length == 1) { IFile f = (IFile) rv[0]; IJavaElement j = JavaCore.create(f.getParent()); if (j instanceof IPackageFragment) { IPackageFragment p = (IPackageFragment) j; tFile.setText(p.getElementName().replace('.', '/') + "/" + f.getName()); } else if (j instanceof IPackageFragmentRoot) { IPackageFragmentRoot p = (IPackageFragmentRoot) j; tFile.setText(f.getName()); } else { MessageDialog.openInformation(getShell(), "Not valid", "The selected resource has to be part of the source folder"); } } } } }); } return area; }
From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.JFXBuildConfigurationEditor.java
License:Open Source License
private void createPageDeploy(final AntTask task) { Composite composite = new Composite(getContainer(), SWT.NONE); FillLayout layout = new FillLayout(); composite.setLayout(layout);//from w w w . j a v a 2s .c o m PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, JavaFXUIPlugin.PLUGIN_ID + ".JFXBuildConfigurationEditor_deploy"); // TODO final WritableValue bean = new WritableValue(); bean.setValue(task); toolkit = new FormToolkit(composite.getDisplay()); final Form form = toolkit.createForm(composite); form.setText("FX Build Configuration"); form.setImage(getTitleImage()); form.getBody().setLayout(new FillLayout()); toolkit.decorateFormHeading(form); initToolbar(form); ScrolledForm scrolledForm = toolkit.createScrolledForm(form.getBody()); scrolledForm.getBody().setLayout(new GridLayout(2, false)); Composite sectionParent = scrolledForm.getBody(); dbc = new DataBindingContext(); IWidgetValueProperty textModify = WidgetProperties.text(SWT.Modify); IWidgetValueProperty selChange = WidgetProperties.selection(); { Section section = toolkit.createSection(sectionParent, Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED); section.setText("Deploy Properties"); section.setDescription("The following properties are needed to create a Java Webstart Deployment"); section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite sectionClient = toolkit.createComposite(section); final int COLUMN_COUNT = 3; sectionClient.setLayout(new GridLayout(COLUMN_COUNT, false)); { toolkit.createLabel(sectionClient, "Applet Width*:"); Text t = toolkit.createText(sectionClient, "", SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = COLUMN_COUNT - 1; t.setLayoutData(gd); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__WIDTH)); dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean)); } { toolkit.createLabel(sectionClient, "Applet Height*:"); Text t = toolkit.createText(sectionClient, "", SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = COLUMN_COUNT - 1; t.setLayoutData(gd); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__HEIGHT)); dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean)); } { Button b = toolkit.createButton(sectionClient, "Embed JNLP", SWT.CHECK); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, COLUMN_COUNT, 1)); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__EMBEDJNLP)); dbc.bindValue(selChange.observe(b), prop.observeDetail(bean)); } { Button b = toolkit.createButton(sectionClient, "Treat files as extensions", SWT.CHECK); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, COLUMN_COUNT, 1)); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__EXTENSION)); dbc.bindValue(selChange.observe(b), prop.observeDetail(bean)); } { Button b = toolkit.createButton(sectionClient, "Include deployment toolkit", SWT.CHECK); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, COLUMN_COUNT, 1)); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__INCLUDE_DT)); dbc.bindValue(selChange.observe(b), prop.observeDetail(bean)); } { Button b = toolkit.createButton(sectionClient, "Native Package", SWT.CHECK); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, COLUMN_COUNT, 1)); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__NATIVE_PACKAGE)); dbc.bindValue(selChange.observe(b), prop.observeDetail(bean)); } { Button b = toolkit.createButton(sectionClient, "Offline allowed", SWT.CHECK); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, COLUMN_COUNT, 1)); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__OFFLINE_ALLOWED)); dbc.bindValue(selChange.observe(b), prop.observeDetail(bean)); } { toolkit.createLabel(sectionClient, "Placeholder Ref.*:"); Text t = toolkit.createText(sectionClient, "", SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = COLUMN_COUNT - 1; t.setLayoutData(gd); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__PLACEHOLDERREF)); dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean)); } { toolkit.createLabel(sectionClient, "Placeholder ID*:"); Text t = toolkit.createText(sectionClient, "", SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = COLUMN_COUNT - 1; t.setLayoutData(gd); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__PLACEHOLDERID)); dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean)); } { toolkit.createLabel(sectionClient, "HTML Template:"); Text t = toolkit.createText(sectionClient, "", SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__TEMPLATE, TEMPLATE__FILE)); dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean)); Button b = toolkit.createButton(sectionClient, "Workspace ...", SWT.NONE); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { FilteredResourcesSelectionDialog d = new FilteredResourcesSelectionDialog( getSite().getShell(), false, ((IFileEditorInput) getEditorInput()).getFile().getProject(), IResource.FILE) { @Override protected IStatus validateItem(final Object item) { IFile f = (IFile) item; if (f.getParent() instanceof IProject) { return new Status(IStatus.ERROR, JavaFXUIPlugin.PLUGIN_ID, "The selected resource has to be part of the source folder"); } if (!f.getName().endsWith(JavaFXUIPlugin.FILEEXTENSION_HTML_TEMPLATE)) { return new Status(IStatus.ERROR, JavaFXUIPlugin.PLUGIN_ID, "The selected resource does not seem to be a html file"); } return super.validateItem(item); } }; if (d.open() == ResourceSelectionDialog.OK) { Object[] rv = d.getResult(); if (rv.length == 1) { IFile f = (IFile) rv[0]; IJavaElement j = JavaCore.create(f.getParent()); String template = null; if (j instanceof IPackageFragment) { IPackageFragment p = (IPackageFragment) j; template = p.getElementName().replace('.', '/') + "/" + f.getName(); } else if (j instanceof IPackageFragmentRoot) { IPackageFragmentRoot p = (IPackageFragmentRoot) j; template = f.getName(); } else { MessageDialog.openInformation(getSite().getShell(), "Not valid", "The selected resource has to be part of the source folder"); } if (template != null) { if (getTask().getDeploy().getTemplate() == null) { Command cmd = new SetCommand(editingDomain, getTask().getDeploy(), DEPLOY__TEMPLATE, ParametersFactory.eINSTANCE.createTemplate()); if (cmd.canExecute()) { cmd.execute(); } } Command cmd = new SetCommand(editingDomain, getTask().getDeploy().getTemplate(), TEMPLATE__FILE, template); if (cmd.canExecute()) { cmd.execute(); } } } } } }); } { toolkit.createLabel(sectionClient, "Template Output File:"); Text t = toolkit.createText(sectionClient, "", SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = COLUMN_COUNT - 1; t.setLayoutData(gd); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__TEMPLATE, TEMPLATE__TO_FILE)); dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean)); } { toolkit.createLabel(sectionClient, "Webstart Splash:") .setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false)); Composite container = toolkit.createComposite(sectionClient); GridLayout gl = new GridLayout(2, false); gl.marginBottom = gl.marginHeight = gl.marginLeft = gl.marginRight = gl.marginTop = gl.marginWidth = 0; container.setLayout(gl); GridData gdContainer = new GridData(GridData.FILL_HORIZONTAL); gdContainer.horizontalSpan = COLUMN_COUNT - 1; container.setLayoutData(gdContainer); Composite tableContainer = toolkit.createComposite(container); Table t = toolkit.createTable(tableContainer, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); t.setHeaderVisible(true); t.setLinesVisible(true); GridData gdTable = new GridData(GridData.FILL_HORIZONTAL); gdTable.heightHint = t.getItemHeight() * 5; tableContainer.setLayoutData(gdTable); TableColumnLayout tablelayout = new TableColumnLayout(); final TableViewer v = new TableViewer(t); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = t.getItemHeight() * 5; v.getControl().setLayoutData(gd); v.setContentProvider(ArrayContentProvider.getInstance()); { TableViewerColumn c = new TableViewerColumn(v, SWT.NONE); c.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(final Object element) { return ((Splash) element).getMode().getName(); } }); tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(10, 100, false)); c.getColumn().setText("Mode"); } { TableViewerColumn c = new TableViewerColumn(v, SWT.NONE); c.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(final Object element) { return ((Splash) element).getHref(); } }); tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(90)); c.getColumn().setText("URL"); } tableContainer.setLayout(tablelayout); v.setInput(task.getDeploy().getInfo().getSplash()); Composite buttonComp = toolkit.createComposite(container); buttonComp.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false)); buttonComp.setLayout(new GridLayout()); { Button b = toolkit.createButton(buttonComp, "Add ...", SWT.PUSH); b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (handleAddSplash()) { v.setInput(task.getDeploy().getInfo().getSplash()); v.setSelection(new StructuredSelection(task.getDeploy().getInfo().getSplash() .get(task.getDeploy().getInfo().getSplash().size() - 1))); } } }); } { Button b = toolkit.createButton(buttonComp, "Remove", SWT.PUSH); b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { Splash value = (Splash) ((IStructuredSelection) v.getSelection()).getFirstElement(); if (value != null) { if (handleRemoveSplash(value)) { v.setInput(getTask().getDeploy().getInfo().getSplash()); } } else { MessageDialog.openWarning(getSite().getShell(), "Warning", "Please select an entry"); } } }); } } { toolkit.createLabel(sectionClient, "Webstart Icons:") .setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false)); Composite container = toolkit.createComposite(sectionClient); GridLayout gl = new GridLayout(2, false); gl.marginBottom = gl.marginHeight = gl.marginLeft = gl.marginRight = gl.marginTop = gl.marginWidth = 0; container.setLayout(gl); GridData gdContainer = new GridData(GridData.FILL_HORIZONTAL); gdContainer.horizontalSpan = COLUMN_COUNT - 1; container.setLayoutData(gdContainer); Composite tableContainer = toolkit.createComposite(container); Table t = toolkit.createTable(tableContainer, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); t.setHeaderVisible(true); t.setLinesVisible(true); GridData gdTable = new GridData(GridData.FILL_HORIZONTAL); gdTable.heightHint = t.getItemHeight() * 5; tableContainer.setLayoutData(gdTable); TableColumnLayout tablelayout = new TableColumnLayout(); final TableViewer v = new TableViewer(t); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = t.getItemHeight() * 5; v.getControl().setLayoutData(gd); v.setContentProvider(ArrayContentProvider.getInstance()); { TableViewerColumn c = new TableViewerColumn(v, SWT.NONE); c.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((Icon) element).getDepth(); } }); tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(10, 50, false)); c.getColumn().setText("Depth"); } { TableViewerColumn c = new TableViewerColumn(v, SWT.NONE); c.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((Icon) element).getKind().getName(); } }); tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(10, 100, false)); c.getColumn().setText("Kind"); } { TableViewerColumn c = new TableViewerColumn(v, SWT.NONE); c.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((Icon) element).getWidth(); } }); tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(10, 50, false)); c.getColumn().setText("Width"); } { TableViewerColumn c = new TableViewerColumn(v, SWT.NONE); c.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((Icon) element).getHeight(); } }); tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(10, 50, false)); c.getColumn().setText("Height"); } { TableViewerColumn c = new TableViewerColumn(v, SWT.NONE); c.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((Icon) element).getHref(); } }); tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(60)); c.getColumn().setText("Url"); } tableContainer.setLayout(tablelayout); v.setInput(task.getDeploy().getInfo().getIcon()); Composite buttonComp = toolkit.createComposite(container); buttonComp.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false)); buttonComp.setLayout(new GridLayout()); { Button b = toolkit.createButton(buttonComp, "Add ...", SWT.PUSH); b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (handleAddIcon()) { v.setInput(task.getDeploy().getInfo().getIcon()); v.setSelection(new StructuredSelection(task.getDeploy().getInfo().getIcon() .get(task.getDeploy().getInfo().getIcon().size() - 1))); } } }); } { Button b = toolkit.createButton(buttonComp, "Remove", SWT.PUSH); b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { Icon value = (Icon) ((IStructuredSelection) v.getSelection()).getFirstElement(); if (value != null) { if (handleRemoveIcon(value)) { v.setInput(task.getDeploy().getInfo().getIcon()); } } else { MessageDialog.openWarning(getSite().getShell(), "Warning", "Please select an entry"); } } }); } } { toolkit.createLabel(sectionClient, "Additional META-INF files:") .setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false)); Composite container = toolkit.createComposite(sectionClient); GridLayout gl = new GridLayout(2, false); gl.marginBottom = gl.marginHeight = gl.marginLeft = gl.marginRight = gl.marginTop = gl.marginWidth = 0; container.setLayout(gl); GridData gdContainer = new GridData(GridData.FILL_HORIZONTAL); gdContainer.horizontalSpan = COLUMN_COUNT - 1; container.setLayoutData(gdContainer); Composite tableContainer = toolkit.createComposite(container); Table t = toolkit.createTable(tableContainer, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); t.setHeaderVisible(true); t.setLinesVisible(true); GridData gdTable = new GridData(GridData.FILL_HORIZONTAL); gdTable.heightHint = t.getItemHeight() * 5; tableContainer.setLayoutData(gdTable); TableColumnLayout tablelayout = new TableColumnLayout(); final TableViewer v = new TableViewer(t); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = t.getItemHeight() * 5; v.getControl().setLayoutData(gd); v.setContentProvider(ArrayContentProvider.getInstance()); { TableViewerColumn c = new TableViewerColumn(v, SWT.NONE); c.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((KeyValuePair) element).getKey(); } }); tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(33)); c.getColumn().setText("Folder"); } { TableViewerColumn c = new TableViewerColumn(v, SWT.NONE); c.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((KeyValuePair) element).getValue(); } }); tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(67)); c.getColumn().setText("File"); } tableContainer.setLayout(tablelayout); v.setInput(task.getFiles()); Composite buttonComp = toolkit.createComposite(container); buttonComp.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false)); buttonComp.setLayout(new GridLayout()); { Button b = toolkit.createButton(buttonComp, "Add ...", SWT.PUSH); b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (handleAddMetaInfFile()) { v.setInput(task.getFiles()); v.setSelection( new StructuredSelection(task.getFiles().get(task.getFiles().size() - 1))); } } }); } { Button b = toolkit.createButton(buttonComp, "Remove", SWT.PUSH); b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { KeyValuePair value = (KeyValuePair) ((IStructuredSelection) v.getSelection()) .getFirstElement(); if (value != null) { if (handleRemoveMetaInfFile(value)) { v.setInput(task.getFiles()); } } else { MessageDialog.openWarning(getSite().getShell(), "Warning", "Please select an entry"); } } }); } } { toolkit.createLabel(sectionClient, "Fonts:") .setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false)); Composite container = toolkit.createComposite(sectionClient); GridLayout gl = new GridLayout(2, false); gl.marginBottom = gl.marginHeight = gl.marginLeft = gl.marginRight = gl.marginTop = gl.marginWidth = 0; container.setLayout(gl); GridData gdContainer = new GridData(GridData.FILL_HORIZONTAL); gdContainer.horizontalSpan = COLUMN_COUNT - 1; container.setLayoutData(gdContainer); Composite tableContainer = toolkit.createComposite(container); Table t = toolkit.createTable(tableContainer, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); t.setHeaderVisible(true); t.setLinesVisible(true); GridData gdTable = new GridData(GridData.FILL_HORIZONTAL); gdTable.heightHint = t.getItemHeight() * 5; tableContainer.setLayoutData(gdTable); TableColumnLayout tablelayout = new TableColumnLayout(); final TableViewer v = new TableViewer(t); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = t.getItemHeight() * 5; v.getControl().setLayoutData(gd); final ArrayContentProvider cp = new ArrayContentProvider(); v.setContentProvider(cp); { IEMFValueProperty prop = EMFEditProperties.value(editingDomain, ParametersPackage.Literals.KEY_VALUE_PAIR__KEY); TableViewerColumn c = new TableViewerColumn(v, SWT.NONE); TableColumn tc = c.getColumn(); tc.setText("Font name"); c.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((KeyValuePair) element).getKey(); } }); tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(33)); } { IEMFValueProperty prop = EMFEditProperties.value(editingDomain, ParametersPackage.Literals.KEY_VALUE_PAIR__VALUE); TableViewerColumn c = new TableViewerColumn(v, SWT.NONE); TableColumn tc = c.getColumn(); tc.setText("File"); c.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((KeyValuePair) element).getValue(); } }); tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(67)); } tableContainer.setLayout(tablelayout); v.setInput(task.getFonts()); Composite buttonComp = toolkit.createComposite(container); buttonComp.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false)); buttonComp.setLayout(new GridLayout()); { Button b = toolkit.createButton(buttonComp, "Add ...", SWT.PUSH); b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (handleAddFont()) { final KeyValuePair newFont = task.getFonts().get(task.getFonts().size() - 1); v.refresh(); v.setSelection(new StructuredSelection(newFont)); } } }); } { Button b = toolkit.createButton(buttonComp, "Remove", SWT.PUSH); b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { KeyValuePair value = (KeyValuePair) ((IStructuredSelection) v.getSelection()) .getFirstElement(); if (value != null) { if (handleRemoveFont(value)) { v.setInput(task.getFonts()); } } else { MessageDialog.openWarning(getSite().getShell(), "Warning", "Please select an entry"); } } }); } } section.setClient(sectionClient); } int index = addPage(composite); setPageText(index, "Deploy"); }
From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.JFXBuildConfigurationEditor.java
License:Open Source License
private String handleSplashImage(Shell shell) { FilteredResourcesSelectionDialog d = new FilteredResourcesSelectionDialog(shell, false, ((IFileEditorInput) getEditorInput()).getFile().getProject(), IResource.FILE) { @Override/*w w w . ja v a 2 s . c om*/ protected IStatus validateItem(Object item) { IFile f = (IFile) item; if (f.getParent() instanceof IProject) { return new Status(IStatus.ERROR, JavaFXUIPlugin.PLUGIN_ID, "The selected resource has to part of the source folder"); } return super.validateItem(item); } }; if (d.open() == ResourceSelectionDialog.OK) { Object[] rv = d.getResult(); if (rv.length == 1) { IFile f = (IFile) rv[0]; IJavaElement j = JavaCore.create(f.getParent()); if (j instanceof IPackageFragment) { IPackageFragment p = (IPackageFragment) j; return p.getElementName().replace('.', '/') + "/" + f.getName(); } else if (j instanceof IPackageFragmentRoot) { return f.getName(); } else { MessageDialog.openInformation(shell, "Not valid", "The selected resource has to part of the source folder"); } } } return null; }
From source file:at.bestsolution.efxclipse.tooling.ui.handler.OpenWithFXMLHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IEvaluationContext context = (IEvaluationContext) event.getApplicationContext(); ISelection s = (ISelection) context.getVariable(ISources.ACTIVE_MENU_SELECTION_NAME); if (s instanceof IStructuredSelection) { Object o = ((IStructuredSelection) s).getFirstElement(); if (o instanceof IFile) { IFile f = (IFile) o;/*w ww. j a va2 s. c om*/ String scenebuilder = InstanceScope.INSTANCE.getNode("at.bestsolution.efxclipse.tooling.ui") .get("scenebuilder.exe", null); if (scenebuilder != null) { try { String executable = scenebuilder; if (Util.isMac()) { executable += "/Contents/MacOS/scenebuilder-launcher.sh"; } Runtime.getRuntime() .exec(new String[] { executable, f.getLocation().toFile().getAbsolutePath() }); } catch (IOException e) { MessageDialog.openError(HandlerUtil.getActiveShell(event), "Launch failed", "Failed to launch SceneBuilder. The error message was: " + e.getMessage()); } } else { if (Program.findProgram(".fxml") != null) { if (!Program.launch(f.getLocation().toFile().getAbsolutePath())) { MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Unable to open file", "Opening the file with SceneBuilder failed. Try setting the absolute path to scenebuilder in your the preferences"); } } else { MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Unable to open file", "Opening the file with SceneBuilder failed. Try setting the absolute path to scenebuilder in your the preferences"); } } } } return null; }
From source file:at.bitandart.zoubek.mervin.swt.comments.examples.CommentEditorExample.java
License:Open Source License
/** * @param args//from w w w. j av a 2s .com */ public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); FormToolkit toolkit = new FormToolkit(display); /* * create a scrolled composite that allows wrapping (based on SWT * Snippet 166) * * It is *NOT* recommended to use the same technique with a * ScrolledForm, as a call of ScrolledForm#reflow() may change the * minimum size (depending on the style bits and layout manager of the * body) and break the computation of the correct wrapped layout. */ final ScrolledComposite scrollComposite = new ScrolledComposite(shell, SWT.V_SCROLL | SWT.H_SCROLL); final Composite body = new Composite(scrollComposite, SWT.NONE); body.setLayout(new GridLayout()); scrollComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); scrollComposite.setContent(body); scrollComposite.setExpandVertical(true); scrollComposite.setExpandHorizontal(true); scrollComposite.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { Rectangle r = scrollComposite.getClientArea(); scrollComposite.setMinSize(body.computeSize(r.width, SWT.DEFAULT)); } }); // ################################## // # create the comment editor // ################################## final CommentEditor editor = new CommentEditor(body, SWT.NONE, toolkit); editor.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); String text = "This is an example "; String linkText = "link"; editor.setText(text + linkText); editor.addCommentLink(new CommentLink(text.length(), linkText.length(), new ExampleLinkTarget(new String[] { "predefined item" }))); editor.addCommentEditorListener(new CommentEditorListener() { @Override public void doSave(CommentEditor commentEditor) { // retrieve links java.util.List<ICommentLink> commentLinks = commentEditor.getCommentLinks(); StringBuilder sb = new StringBuilder(); for (ICommentLink commentLink : commentLinks) { sb.append(commentLink.toString()); sb.append("\n"); } // retrieve raw comment text String commentText = commentEditor.getText(); MessageDialog.openInformation(shell, "Save called", "Comment has been saved with the following text:\n\n" + commentText + "\n\n and " + commentLinks.size() + " link(s):\n\n" + commentLinks.toString()); } }); // ################################## // create a list with items to select final List itemList = new List(body, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); GridData listGridData = new GridData(SWT.FILL, SWT.FILL, true, true); listGridData.heightHint = 100; itemList.setLayoutData(listGridData); for (int i = 0; i < 30; i++) { itemList.add("Item " + i); } itemList.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { /* * items have been selected that can be a target of the link, so * create a link target for then and update the editor */ String[] selection = itemList.getSelection(); ExampleLinkTarget linkTarget = new ExampleLinkTarget(selection); editor.setCurrentLinkTarget(linkTarget); } @Override public void widgetDefaultSelected(SelectionEvent e) { // intentionally left empty } }); Button deselectButton = new Button(body, SWT.PUSH); deselectButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); deselectButton.setText("deselect all"); deselectButton.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { itemList.deselectAll(); // nothing is selected -> also update the editor editor.setCurrentLinkTarget(null); } @Override public void widgetDefaultSelected(SelectionEvent e) { // Intentionally left empty } }); body.layout(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:at.rc.tacos.client.editors.AddressEditor.java
License:Open Source License
@Override public void propertyChange(PropertyChangeEvent evt) { if ("ADDRESS_ADD".equals(evt.getPropertyName()) || "ADDRESS_UPDATE".equals(evt.getPropertyName())) { Address updateAddress = null;/*w w w.j a va 2 s.c o m*/ // get the new value if (evt.getNewValue() instanceof Address) updateAddress = (Address) evt.getNewValue(); // assert we have a value if (updateAddress == null) return; // is this job the current -> update it if (address.equals(updateAddress)) { // save the updated address setInput(new AddressEditorInput(updateAddress, false)); setPartName(address.getZip() + "," + address.getCity() + "," + address.getStreet()); address = updateAddress; isNew = false; // update the editor loadData(); // show the result isDirty = false; infoLabel.setText("nderungen gespeichert"); infoLabel.setImage(ImageFactory.getInstance().getRegisteredImage("info.ok")); Display.getCurrent().beep(); } } if ("ADDRESS_REMOVE".equals(evt.getPropertyName())) { // get the removed address Address removedAddress = (Address) evt.getOldValue(); // current open if (address.equals(removedAddress)) { MessageDialog.openInformation(getSite().getShell(), "Adresse wurde gelscht", "Die Adresse, welches Sie gerade editieren, wurde gelscht"); EditorCloseAction closeAction = new EditorCloseAction( PlatformUI.getWorkbench().getActiveWorkbenchWindow()); closeAction.run(); } } }