@Override protected Viewer createViewer(final Composite parent) { listViewer = new ListViewer(parent, SWT.BORDER); listViewer.setLabelProvider(new ModuleItemLabelProvider()); contentProvider = new InterpretedModuleListContentProvider(); listViewer.setContentProvider(contentProvider); getSite().setSelectionProvider(listViewer); listViewer.addDoubleClickListener( new IDoubleClickListener() { @Override public void doubleClick(final DoubleClickEvent event) { final IStructuredSelection ss = (IStructuredSelection) event.getSelection(); for (final Object o : ss.toArray()) { try { EditorUtility.openInEditor(o); } catch (final PartInitException e) { ErlLogger.warn(e); } } } }); DebugUITools.getDebugContextManager().addDebugContextListener(this); DebugPlugin.getDefault().addDebugEventListener(this); return listViewer; }
/** * Create contents of the dialog * * @param parent */ protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; container.setLayout(gridLayout); final Label label = new Label(container, SWT.NONE); label.setText("查找:"); text = new Text(container, SWT.BORDER); text.addModifyListener( new ModifyListener() { public void modifyText(final ModifyEvent e) { searchCondition = text.getText(); StructuredSelection sel = (StructuredSelection) listViewer.getSelection(); Object selObj = sel.isEmpty() ? null : sel.getFirstElement(); listViewer.refresh(); if (selObj != null) { sel = new StructuredSelection(selObj); listViewer.setSelection(sel); } } }); text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); listViewer = new ListViewer(container, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI); listViewer.setContentProvider(new ListContentProvider()); list = listViewer.getList(); list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); listViewer.addDoubleClickListener( new IDoubleClickListener() { public void doubleClick(final DoubleClickEvent event) { StructuredSelection sel = (StructuredSelection) event.getSelection(); if (sel.isEmpty()) { return; } buttonPressed(IDialogConstants.OK_ID); } }); listViewer.setInput(ProjectData.getActiveProject()); List<SkillConfig> selObjs = new ArrayList<SkillConfig>(); for (int id : selectedSkills) { try { SkillConfig q = (SkillConfig) ProjectData.getActiveProject().findObject(SkillConfig.class, id); if (q != null) { selObjs.add(q); } } catch (Exception e) { } } StructuredSelection sel = new StructuredSelection(selObjs); listViewer.setSelection(sel); return container; }
protected void initGUI() { getGridLayout().numColumns = 2; // fileExtList = new List(this, SWT.BORDER); // fileExtList.setLayoutData(new GridData(GridData.FILL_BOTH)); fileExtListViewer = new ListViewer(this, SWT.BORDER | SWT.V_SCROLL); fileExtListViewer.setContentProvider(new ListViewerContentProvider()); fileExtListViewer.setLabelProvider(new ListViewerLabelProvider()); fileExtListViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); buttonWrapper = new XComposite(this, SWT.NONE, LayoutMode.TIGHT_WRAPPER, LayoutDataMode.NONE); buttonWrapper.setLayoutData(new GridData(GridData.FILL_VERTICAL)); addDelegation = new Button(buttonWrapper, SWT.PUSH); addDelegation.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); addDelegation.setText( Messages.getString( "org.nightlabs.base.ui.print.pref.EditDocumentPrinterTypeRegsComposite.addDelegation.text")); //$NON-NLS-1$ addDelegation.addSelectionListener( new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) {} public void widgetSelected(SelectionEvent arg0) { String fileExt = openFileExtDlg(); if (fileExt != null && !"".equals(fileExt)) { // $NON-NLS-1$ addTypeReg(fileExt); // TODO: Removed, as the SelectionListener does not get notified. Why not? // fileExtList.setSelection(new String[]{fileExt}); } } }); removeDelegation = new Button(buttonWrapper, SWT.PUSH); removeDelegation.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); removeDelegation.setText( Messages.getString( "org.nightlabs.base.ui.print.pref.EditDocumentPrinterTypeRegsComposite.removeDelegation.text")); //$NON-NLS-1$ removeDelegation.addSelectionListener( new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) {} public void widgetSelected(SelectionEvent arg0) { removeTypeReg(getSelectedFileExt()); } }); }
public void createControl(Composite parent) { comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(1, true)); Label label = new Label(comp, SWT.NONE); GridDataFactory.swtDefaults().applyTo(label); label.setText("Dateien wählen..."); createUpload(comp); viewer = new ListViewer(comp, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new UploadItemLabelProvider()); GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl()); setControl(comp); }
@Override public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(GridLayoutFactory.fillDefaults().create()); composite.setLayoutData(GridDataFactory.fillDefaults().create()); // Create list viewer listViewer = new ListViewer(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); GridData data = new GridData(GridData.FILL_BOTH); data.heightHint = convertHeightInCharsToPixels(LIST_HEIGHT); data.widthHint = convertWidthInCharsToPixels(LIST_WIDTH); listViewer.getList().setLayoutData(data); listViewer.getList().setFont(parent.getFont()); // Set the label provider listViewer.setLabelProvider( new LabelProvider() { public String getText(Object element) { // Return the features's label. return element == null ? "" : ((CommPortIdentifier) element).getName(); // $NON-NLS-1$ } }); // Set the content provider ArrayContentProvider cp = new ArrayContentProvider(); listViewer.setContentProvider(cp); listViewer.setInput(availableCommPortIdentifiers); listViewer.addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { if (event.getSelection() instanceof IStructuredSelection) { ((ArduinoConnectionSelectionWizard) getWizard()) .cfg.setUsbComm( (CommPortIdentifier) ((IStructuredSelection) event.getSelection()).getFirstElement()); } } }); listViewer.setSelection(new StructuredSelection(availableCommPortIdentifiers.get(0))); setControl(composite); }
/** Create contents of the dialog. */ private void createContents() { shlBundler = new Shell(getParent(), getStyle()); shlBundler.setSize(626, 447); shlBundler.setText("Bundler"); shlBundler.setLayout(new FormLayout()); listViewerFiles = new ListViewer(shlBundler, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI); list = listViewerFiles.getList(); FormData fd_list = new FormData(); fd_list.left = new FormAttachment(0, 10); list.setLayoutData(fd_list); listViewerFiles.setContentProvider( new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector) inputElement; return v.toArray(); } public void dispose() {} public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }); listViewerFiles.setLabelProvider( new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return ((File) element).getName(); } }); listViewerFiles.setSorter( new ViewerSorter() { public int compare(Viewer viewer, Object e1, Object e2) { return ((File) e1).getName().compareTo(((File) e2).getName()); } }); lblNewLabel_3 = new Label(shlBundler, SWT.NONE); fd_list.top = new FormAttachment(lblNewLabel_3, 6); fd_lblNewLabel = new FormData(); fd_lblNewLabel.left = new FormAttachment(0, 10); lblNewLabel_3.setLayoutData(fd_lblNewLabel); lblNewLabel_3.setText("folder list :"); composite_5 = new Composite(shlBundler, SWT.NONE); fd_list.bottom = new FormAttachment(composite_5, 0, SWT.BOTTOM); composite_5.setLayout(new TreeColumnLayout()); FormData fd_composite_5 = new FormData(); fd_composite_5.top = new FormAttachment(lblNewLabel_3, 6); fd_composite_5.right = new FormAttachment(100, -10); composite_5.setLayoutData(fd_composite_5); treeViewerCategories = new TreeViewer(composite_5, SWT.BORDER | SWT.MULTI); Tree treeCategories = treeViewerCategories.getTree(); treeCategories.setHeaderVisible(true); treeCategories.setLinesVisible(true); treeViewerCategories.setContentProvider(new CategoriesContentProvider()); treeViewerCategories.setLabelProvider(new SinfilesLabelProvider()); treeViewerCategories.setSorter( new ViewerSorter() { public int compare(Viewer viewer, Object e1, Object e2) { int cat1 = category(e1); int cat2 = category(e2); if (cat1 != cat2) return cat1 - cat2; if ((e1 instanceof Category) && (e2 instanceof Category)) return ((Category) e1).getName().compareTo(((Category) e2).getName()); else return ((File) e1).getName().compareTo(((File) e2).getName()); } }); // Expand the tree treeViewerCategories.setAutoExpandLevel(2); // Provide the input to the ContentProvider treeViewerCategories.setInput(new CategoriesModel(meta)); treeViewerCategories.refresh(); Button btnCancel = new Button(shlBundler, SWT.NONE); fd_composite_5.bottom = new FormAttachment(btnCancel, -5); fd_composite_5.bottom = new FormAttachment(btnCancel, -5); btnCancel.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = new String("Cancel"); shlBundler.dispose(); } }); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100, -10); fd_btnCancel.bottom = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.setText("Cancel"); Button btnCreate = new Button(shlBundler, SWT.NONE); btnCreate.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (sourceFolder.getText().length() == 0) { showErrorMessageBox("You must point to a folder containing sin files"); return; } if ((device.getText().length() == 0) || (version.getText().length() == 0) || (branding.getText().length() == 0)) { showErrorMessageBox("Device, Versio, Branding : all fields must be set"); return; } File f = new File( OS.getWorkDir() + File.separator + "firmwares" + File.separator + _variant + "_" + version.getText() + "_" + branding.getText() + ".ftf"); if (f.exists()) { showErrorMessageBox("This bundle name already exists"); return; } Bundle b = new Bundle(); b.setMeta(meta); b.setDevice(_variant); b.setVersion(version.getText()); b.setBranding(branding.getText()); b.setCmd25(btnNoFinalVerification.getSelection() ? "true" : "false"); if (!b.hasLoader()) { String result = Devices.getIdFromVariant(_variant); DeviceEntry ent = new DeviceEntry(result); System.out.println(ent.getLoader()); if (ent.hasUnlockedLoader()) { String res = WidgetTask.openLoaderSelect(shlBundler); if (res.equals("U")) b.setLoader(new File(ent.getLoaderUnlocked())); else if (res.equals("L")) b.setLoader(new File(ent.getLoader())); else { showErrorMessageBox("This bundle must contain a loader"); return; } } else { b.setLoader(new File(ent.getLoader())); } } createFTFJob j = new createFTFJob("Create FTF"); j.setBundle(b); j.schedule(); shlBundler.dispose(); } }); FormData fd_btnCreate = new FormData(); fd_btnCreate.bottom = new FormAttachment(btnCancel, 0, SWT.BOTTOM); fd_btnCreate.right = new FormAttachment(btnCancel, -6); btnCreate.setLayoutData(fd_btnCreate); btnCreate.setText("Create"); btnNewButton_1 = new Button(shlBundler, SWT.NONE); fd_list.right = new FormAttachment(btnNewButton_1, -6); fd_composite_5.left = new FormAttachment(btnNewButton_1, 6); btnNewButton_1.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) listViewerFiles.getSelection(); Iterator i = selection.iterator(); while (i.hasNext()) { File f = (File) i.next(); files.remove(f); try { meta.process(f.getName(), f.getAbsolutePath()); model.refresh(meta); treeViewerCategories.setInput(model); } catch (Exception ex) { ex.printStackTrace(); } treeViewerCategories.setAutoExpandLevel(2); treeViewerCategories.refresh(); listViewerFiles.refresh(); } } }); fd_btnNewButton_1 = new FormData(); fd_btnNewButton_1.left = new FormAttachment(0, 353); fd_btnNewButton_1.right = new FormAttachment(100, -224); btnNewButton_1.setLayoutData(fd_btnNewButton_1); btnNewButton_1.setText("->"); Button btnNewButton_2 = new Button(shlBundler, SWT.NONE); fd_btnNewButton_1.bottom = new FormAttachment(100, -143); btnNewButton_2.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) treeViewerCategories.getSelection(); Iterator i = selection.iterator(); while (i.hasNext()) { Object o = i.next(); if (o instanceof Category) { Category c = (Category) o; Iterator<File> j = c.getSinfiles().iterator(); while (j.hasNext()) { File f = j.next(); files.add(f); meta.remove(f.getName()); model.refresh(meta); treeViewerCategories.setAutoExpandLevel(2); treeViewerCategories.refresh(); listViewerFiles.refresh(); } } if (o instanceof File) { String internal = ((File) o).getName(); files.add(new File(meta.getPath(internal))); meta.remove(internal); model.refresh(meta); treeViewerCategories.setAutoExpandLevel(2); treeViewerCategories.refresh(); listViewerFiles.refresh(); } } } }); FormData fd_btnNewButton_2 = new FormData(); fd_btnNewButton_2.top = new FormAttachment(btnNewButton_1, 23); fd_btnNewButton_2.right = new FormAttachment(btnNewButton_1, 0, SWT.RIGHT); fd_btnNewButton_2.left = new FormAttachment(0, 353); btnNewButton_2.setLayoutData(fd_btnNewButton_2); btnNewButton_2.setText("<-"); Composite composite = new Composite(shlBundler, SWT.NONE); composite.setLayout(new GridLayout(3, false)); FormData fd_composite = new FormData(); fd_composite.left = new FormAttachment(0, 10); fd_composite.right = new FormAttachment(100, -10); fd_composite.top = new FormAttachment(0, 10); composite.setLayoutData(fd_composite); lblSelectSourceFolder = new Label(composite, SWT.NONE); GridData gd_lblSelectSourceFolder = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblSelectSourceFolder.widthHint = 121; lblSelectSourceFolder.setLayoutData(gd_lblSelectSourceFolder); lblSelectSourceFolder.setText("Select source folder :"); sourceFolder = new Text(composite, SWT.BORDER); sourceFolder.setEditable(false); GridData gd_sourceFolder = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_sourceFolder.widthHint = 428; sourceFolder.setLayoutData(gd_sourceFolder); btnNewButton = new Button(composite, SWT.NONE); btnNewButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); btnNewButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DirectoryDialog dlg = new DirectoryDialog(shlBundler); // Set the initial filter path according // to anything they've selected or typed in dlg.setFilterPath(sourceFolder.getText()); // Change the title bar text dlg.setText("Directory chooser"); // Customizable message displayed in the dialog dlg.setMessage("Select a directory"); // Calling open() will open and run the dialog. // It will return the selected directory, or // null if user cancels String dir = dlg.open(); if (dir != null) { // Set the text box to the new selection if (!sourceFolder.getText().equals(dir)) { sourceFolder.setText(dir); meta.clear(); files = new Vector(); File srcdir = new File(sourceFolder.getText()); File[] chld = srcdir.listFiles(); for (int i = 0; i < chld.length; i++) { if (chld[i].getName().toUpperCase().endsWith("SIN") || (chld[i].getName().toUpperCase().endsWith("TA") && !chld[i].getName().toUpperCase().contains("SIMLOCK")) || (chld[i].getName().toUpperCase().endsWith("XML") && !chld[i].getName().toUpperCase().contains("UPDATE"))) { files.add(chld[i]); } } srcdir = new File(sourceFolder.getText() + File.separator + "boot"); if (srcdir.exists()) { chld = srcdir.listFiles(); for (int i = 0; i < chld.length; i++) { if (chld[i].getName().toUpperCase().endsWith("XML")) { files.add(chld[i]); } } } model.refresh(meta); treeViewerCategories.setInput(model); listViewerFiles.setInput(files); } } } }); btnNewButton.setText("..."); Composite composite_1 = new Composite(shlBundler, SWT.NONE); fd_lblNewLabel.top = new FormAttachment(0, 154); composite_1.setLayout(new GridLayout(3, false)); FormData fd_composite_1 = new FormData(); fd_composite_1.bottom = new FormAttachment(lblNewLabel_3, -6); fd_composite_1.right = new FormAttachment(composite_5, 0, SWT.RIGHT); fd_composite_1.top = new FormAttachment(composite, 2); fd_composite_1.left = new FormAttachment(0, 10); composite_1.setLayoutData(fd_composite_1); lblNewLabel = new Label(composite_1, SWT.NONE); GridData gd_lblNewLabel = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); gd_lblNewLabel.widthHint = 68; lblNewLabel.setLayoutData(gd_lblNewLabel); lblNewLabel.setText("Device :"); device = new Text(composite_1, SWT.BORDER); device.setToolTipText("Double click to get list of devices"); device.addMouseListener( new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { String result = WidgetTask.openDeviceSelector(shlBundler); if (result.length() > 0) { DeviceEntry ent = new DeviceEntry(result); String variant = WidgetTask.openVariantSelector(ent.getId(), shlBundler); device.setText(ent.getName() + " (" + variant + ")"); _variant = variant; } } }); device.setEditable(false); GridData gd_device = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_device.widthHint = 355; device.setLayoutData(gd_device); new Label(composite_1, SWT.NONE); lblNewLabel_2 = new Label(composite_1, SWT.NONE); lblNewLabel_2.setText("Branding :"); branding = new Text(composite_1, SWT.BORDER); GridData gd_branding = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_branding.widthHint = 355; branding.setLayoutData(gd_branding); btnNoFinalVerification = new Button(composite_1, SWT.CHECK); btnNoFinalVerification.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1)); btnNoFinalVerification.setText("No final verification"); Label lblNewLabel_1 = new Label(composite_1, SWT.NONE); lblNewLabel_1.setText("Version :"); version = new Text(composite_1, SWT.BORDER); GridData gd_version = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_version.widthHint = 355; version.setLayoutData(gd_version); new Label(composite_1, SWT.NONE); Label lblFirmwareContent = new Label(shlBundler, SWT.NONE); fd_lblNewLabel.right = new FormAttachment(lblFirmwareContent, -67); FormData fd_lblFirmwareContent = new FormData(); fd_lblFirmwareContent.right = new FormAttachment(composite_5, 0, SWT.RIGHT); fd_lblFirmwareContent.bottom = new FormAttachment(composite_5, -6); fd_lblFirmwareContent.left = new FormAttachment(composite_5, 0, SWT.LEFT); lblFirmwareContent.setLayoutData(fd_lblFirmwareContent); lblFirmwareContent.setText("Firmware content :"); branding.setText(_branding); version.setText(_version); if (_deviceName.length() > 0) device.setText(_deviceName + " (" + _variant + ")"); }
private void createLanguagesGroup(Composite parent) { final Group langGroup = NSISWizardDialogUtil.createGroup( parent, 1, "language.support.group.label", null, false); // $NON-NLS-1$ GridData data = (GridData) langGroup.getLayoutData(); data.verticalAlignment = SWT.FILL; data.grabExcessVerticalSpace = true; data.horizontalAlignment = SWT.FILL; data.grabExcessHorizontalSpace = true; NSISWizardSettings settings = mWizard.getSettings(); final Button enableLangSupport = NSISWizardDialogUtil.createCheckBox( langGroup, "enable.language.support.label", settings.isEnableLanguageSupport(), true, null, false); //$NON-NLS-1$ enableLangSupport.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean selection = enableLangSupport.getSelection(); mWizard.getSettings().setEnableLanguageSupport(selection); validateField(LANG_CHECK); } }); final MasterSlaveController m = new MasterSlaveController(enableLangSupport); final Composite listsComposite = new Composite(langGroup, SWT.NONE); data = new GridData(SWT.FILL, SWT.FILL, true, true); listsComposite.setLayoutData(data); GridLayout layout = new GridLayout(2, true); layout.marginHeight = 0; layout.marginWidth = 0; listsComposite.setLayout(layout); java.util.List<NSISLanguage> selectedLanguages = settings.getLanguages(); if (selectedLanguages.isEmpty()) { NSISLanguage defaultLanguage = NSISLanguageManager.getInstance().getDefaultLanguage(); if (defaultLanguage != null) { selectedLanguages.add(defaultLanguage); } } java.util.List<NSISLanguage> availableLanguages = NSISLanguageManager.getInstance().getLanguages(); availableLanguages.removeAll(selectedLanguages); Composite leftComposite = new Composite(listsComposite, SWT.NONE); leftComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); layout = new GridLayout(2, false); layout.marginHeight = 0; layout.marginWidth = 0; leftComposite.setLayout(layout); ((GridData) NSISWizardDialogUtil.createLabel( leftComposite, "available.languages.label", //$NON-NLS-1$ true, m, false) .getLayoutData()) .horizontalSpan = 2; final List availableLangList = new List(leftComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); data = new GridData(SWT.FILL, SWT.FILL, true, true); Dialog.applyDialogFont(availableLangList); data.heightHint = Common.calculateControlSize(availableLangList, 0, 12).y; availableLangList.setLayoutData(data); m.addSlave(availableLangList); final ListViewer availableLangViewer = new ListViewer(availableLangList); CollectionContentProvider collectionContentProvider = new CollectionContentProvider(); availableLangViewer.setContentProvider(collectionContentProvider); availableLangViewer.setInput(availableLanguages); availableLangViewer.setSorter(new ViewerSorter(cLanguageCollator)); final Composite buttonsComposite1 = new Composite(leftComposite, SWT.NONE); layout = new GridLayout(1, false); layout.marginHeight = 0; layout.marginWidth = 0; buttonsComposite1.setLayout(layout); data = new GridData(SWT.FILL, SWT.CENTER, false, false); buttonsComposite1.setLayoutData(data); final Button allRightButton = new Button(buttonsComposite1, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); allRightButton.setLayoutData(data); allRightButton.setImage( EclipseNSISPlugin.getImageManager() .getImage(EclipseNSISPlugin.getResourceString("all.right.icon"))); // $NON-NLS-1$ allRightButton.setToolTipText( EclipseNSISPlugin.getResourceString("all.right.tooltip")); // $NON-NLS-1$ final Button rightButton = new Button(buttonsComposite1, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); rightButton.setLayoutData(data); rightButton.setImage( EclipseNSISPlugin.getImageManager() .getImage(EclipseNSISPlugin.getResourceString("right.icon"))); // $NON-NLS-1$ rightButton.setToolTipText(EclipseNSISPlugin.getResourceString("right.tooltip")); // $NON-NLS-1$ final Button leftButton = new Button(buttonsComposite1, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); leftButton.setLayoutData(data); leftButton.setImage( EclipseNSISPlugin.getImageManager() .getImage(EclipseNSISPlugin.getResourceString("left.icon"))); // $NON-NLS-1$ leftButton.setToolTipText(EclipseNSISPlugin.getResourceString("left.tooltip")); // $NON-NLS-1$ final Button allLeftButton = new Button(buttonsComposite1, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); allLeftButton.setLayoutData(data); allLeftButton.setImage( EclipseNSISPlugin.getImageManager() .getImage(EclipseNSISPlugin.getResourceString("all.left.icon"))); // $NON-NLS-1$ allLeftButton.setToolTipText( EclipseNSISPlugin.getResourceString("all.left.tooltip")); // $NON-NLS-1$ Composite rightComposite = new Composite(listsComposite, SWT.NONE); rightComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); layout = new GridLayout(2, false); layout.marginHeight = 0; layout.marginWidth = 0; rightComposite.setLayout(layout); ((GridData) NSISWizardDialogUtil.createLabel( rightComposite, "selected.languages.label", //$NON-NLS-1$ true, m, isScriptWizard()) .getLayoutData()) .horizontalSpan = 2; final List selectedLangList = new List(rightComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); data = new GridData(SWT.FILL, SWT.FILL, true, true); Dialog.applyDialogFont(selectedLangList); data.heightHint = Common.calculateControlSize(selectedLangList, 0, 12).y; selectedLangList.setLayoutData(data); m.addSlave(selectedLangList); final ListViewer selectedLangViewer = new ListViewer(selectedLangList); selectedLangViewer.setContentProvider(collectionContentProvider); selectedLangViewer.setInput(selectedLanguages); final ListViewerUpDownMover<java.util.List<NSISLanguage>, NSISLanguage> mover = new ListViewerUpDownMover<java.util.List<NSISLanguage>, NSISLanguage>() { @Override @SuppressWarnings("unchecked") protected java.util.List<NSISLanguage> getAllElements() { return (java.util.List<NSISLanguage>) ((ListViewer) getViewer()).getInput(); } @Override protected void updateStructuredViewerInput( java.util.List<NSISLanguage> input, java.util.List<NSISLanguage> elements, java.util.List<NSISLanguage> move, boolean isDown) { (input).clear(); (input).addAll(elements); } }; mover.setViewer(selectedLangViewer); final Composite buttonsComposite2 = new Composite(rightComposite, SWT.NONE); layout = new GridLayout(1, false); layout.marginHeight = 0; layout.marginWidth = 0; buttonsComposite2.setLayout(layout); data = new GridData(SWT.FILL, SWT.CENTER, false, false); buttonsComposite2.setLayoutData(data); final Button upButton = new Button(buttonsComposite2, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); upButton.setLayoutData(data); upButton.setImage( EclipseNSISPlugin.getImageManager() .getImage(EclipseNSISPlugin.getResourceString("up.icon"))); // $NON-NLS-1$ upButton.setToolTipText(EclipseNSISPlugin.getResourceString("up.tooltip")); // $NON-NLS-1$ m.addSlave(upButton); final Button downButton = new Button(buttonsComposite2, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); downButton.setLayoutData(data); downButton.setImage( EclipseNSISPlugin.getImageManager() .getImage(EclipseNSISPlugin.getResourceString("down.icon"))); // $NON-NLS-1$ downButton.setToolTipText(EclipseNSISPlugin.getResourceString("down.tooltip")); // $NON-NLS-1$ m.addSlave(downButton); Composite langOptions = langGroup; boolean showSupportedLangOption = NSISPreferences.getInstance().getNSISVersion().compareTo(INSISVersions.VERSION_2_26) >= 0; if (showSupportedLangOption) { langOptions = new Composite(langGroup, SWT.None); layout = new GridLayout(2, false); layout.marginHeight = 0; layout.marginWidth = 0; langOptions.setLayout(layout); data = new GridData(SWT.FILL, SWT.FILL, true, false); langOptions.setLayoutData(data); } final Button selectLang = NSISWizardDialogUtil.createCheckBox( langOptions, "select.language.label", settings.isSelectLanguage(), true, m, false); //$NON-NLS-1$ final Button displaySupported; if (showSupportedLangOption) { ((GridData) selectLang.getLayoutData()).horizontalSpan = 1; displaySupported = NSISWizardDialogUtil.createCheckBox( langOptions, "display.supported.languages.label", settings.isDisplaySupportedLanguages(), // $NON-NLS-1$ true, m, false); ((GridData) displaySupported.getLayoutData()).horizontalSpan = 1; displaySupported.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mWizard.getSettings().setDisplaySupportedLanguages(displaySupported.getSelection()); } }); } else { displaySupported = null; } final MasterSlaveEnabler mse = new MasterSlaveEnabler() { public void enabled(Control control, boolean flag) {} @SuppressWarnings("unchecked") public boolean canEnable(Control control) { NSISWizardSettings settings = mWizard.getSettings(); if (control == allRightButton) { return settings.isEnableLanguageSupport() && availableLangViewer.getList().getItemCount() > 0; } else if (control == rightButton) { return settings.isEnableLanguageSupport() && !availableLangViewer.getSelection().isEmpty(); } else if (control == allLeftButton) { return settings.isEnableLanguageSupport() && selectedLangViewer.getList().getItemCount() > 0; } else if (control == leftButton) { return settings.isEnableLanguageSupport() && !selectedLangViewer.getSelection().isEmpty(); } else if (control == upButton) { return settings.isEnableLanguageSupport() && mover.canMoveUp(); } else if (control == downButton) { return settings.isEnableLanguageSupport() && mover.canMoveDown(); } else if (control == selectLang) { java.util.List<NSISLanguage> selectedLanguages = (java.util.List<NSISLanguage>) selectedLangViewer.getInput(); return settings.getInstallerType() != INSTALLER_TYPE_SILENT && settings.isEnableLanguageSupport() && selectedLanguages.size() > 1; } else if (control == displaySupported && displaySupported != null) { java.util.List<NSISLanguage> selectedLanguages = (java.util.List<NSISLanguage>) selectedLangViewer.getInput(); return settings.getInstallerType() != INSTALLER_TYPE_SILENT && settings.isEnableLanguageSupport() && selectedLanguages.size() > 1 && selectLang.getSelection(); } else { return true; } } }; m.addSlave(rightButton, mse); m.addSlave(allRightButton, mse); m.addSlave(leftButton, mse); m.addSlave(allLeftButton, mse); m.setEnabler(upButton, mse); m.setEnabler(downButton, mse); m.setEnabler(selectLang, mse); if (displaySupported != null) { m.setEnabler(displaySupported, mse); } selectLang.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mWizard.getSettings().setSelectLanguage(selectLang.getSelection()); if (displaySupported != null) { displaySupported.setEnabled(mse.canEnable(displaySupported)); } } }); final Runnable langRunnable = new Runnable() { public void run() { availableLangViewer.refresh(false); selectedLangViewer.refresh(false); allRightButton.setEnabled(mse.canEnable(allRightButton)); allLeftButton.setEnabled(mse.canEnable(allLeftButton)); rightButton.setEnabled(mse.canEnable(rightButton)); leftButton.setEnabled(mse.canEnable(leftButton)); upButton.setEnabled(mse.canEnable(upButton)); downButton.setEnabled(mse.canEnable(downButton)); selectLang.setEnabled(mse.canEnable(selectLang)); if (displaySupported != null) { displaySupported.setEnabled(mse.canEnable(displaySupported)); } setPageComplete(validateField(LANG_CHECK)); } }; rightButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { moveAcross( availableLangViewer, selectedLangViewer, Common.makeGenericList( NSISLanguage.class, ((IStructuredSelection) availableLangViewer.getSelection()).toList())); langRunnable.run(); } }); allRightButton.addSelectionListener( new SelectionAdapter() { @Override @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent se) { moveAcross( availableLangViewer, selectedLangViewer, (java.util.List<NSISLanguage>) availableLangViewer.getInput()); langRunnable.run(); } }); leftButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { moveAcross( selectedLangViewer, availableLangViewer, Common.makeGenericList( NSISLanguage.class, ((IStructuredSelection) selectedLangViewer.getSelection()).toList())); langRunnable.run(); } }); allLeftButton.addSelectionListener( new SelectionAdapter() { @Override @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent se) { moveAcross( selectedLangViewer, availableLangViewer, (java.util.List<NSISLanguage>) selectedLangViewer.getInput()); langRunnable.run(); } }); upButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { mover.moveUp(); langRunnable.run(); } }); downButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { mover.moveDown(); langRunnable.run(); } }); availableLangViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { rightButton.setEnabled(mse.canEnable(rightButton)); allRightButton.setEnabled(mse.canEnable(allRightButton)); } }); availableLangViewer .getList() .addSelectionListener( new SelectionAdapter() { @Override public void widgetDefaultSelected(SelectionEvent event) { IStructuredSelection sel = (IStructuredSelection) availableLangViewer.getSelection(); if (!sel.isEmpty()) { moveAcross( availableLangViewer, selectedLangViewer, Common.makeGenericList(NSISLanguage.class, sel.toList())); selectedLangViewer.reveal(sel.getFirstElement()); langRunnable.run(); } } }); selectedLangViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { leftButton.setEnabled(mse.canEnable(leftButton)); allLeftButton.setEnabled(mse.canEnable(allLeftButton)); upButton.setEnabled(mse.canEnable(upButton)); downButton.setEnabled(mse.canEnable(downButton)); selectLang.setEnabled(mse.canEnable(selectLang)); if (displaySupported != null) { displaySupported.setEnabled(mse.canEnable(displaySupported)); } } }); selectedLangViewer .getList() .addSelectionListener( new SelectionAdapter() { @Override public void widgetDefaultSelected(SelectionEvent event) { IStructuredSelection sel = (IStructuredSelection) selectedLangViewer.getSelection(); if (!sel.isEmpty()) { moveAcross( selectedLangViewer, availableLangViewer, Common.makeGenericList(NSISLanguage.class, sel.toList())); availableLangViewer.reveal(sel.getFirstElement()); langRunnable.run(); } } }); m.updateSlaves(); listsComposite.addListener( SWT.Resize, new Listener() { boolean init = false; public void handleEvent(Event e) { if (!init) { // Stupid hack so that the height hint doesn't get changed // on the first resize, // i.e., when the page is drawn for the first time. init = true; } else { Point size = listsComposite.getSize(); GridLayout layout = (GridLayout) listsComposite.getLayout(); int heightHint = size.y - 2 * layout.marginHeight; ((GridData) availableLangList.getLayoutData()).heightHint = heightHint; ((GridData) selectedLangList.getLayoutData()).heightHint = heightHint; int totalWidth = size.x - 2 * layout.marginWidth - 3 * layout.horizontalSpacing; int listWidth = (int) (totalWidth * 0.4); int buttonWidth = (int) (0.5 * (totalWidth - 2 * listWidth)); size = availableLangList.computeSize(listWidth, SWT.DEFAULT); int delta = 0; if (size.x > listWidth) { delta = size.x - listWidth; listWidth = listWidth - delta; } ((GridData) availableLangList.getLayoutData()).widthHint = listWidth; ((GridData) buttonsComposite1.getLayoutData()).widthHint = totalWidth - 2 * (listWidth + delta) - buttonWidth; ((GridData) selectedLangList.getLayoutData()).widthHint = listWidth; ((GridData) buttonsComposite2.getLayoutData()).widthHint = buttonWidth; listsComposite.layout(); } } }); addPageChangedRunnable( new Runnable() { public void run() { if (isCurrentPage()) { selectLang.setEnabled(mse.canEnable(selectLang)); if (displaySupported != null) { displaySupported.setEnabled(mse.canEnable(displaySupported)); } } } }); mWizard.addSettingsListener( new INSISWizardSettingsListener() { public void settingsChanged( NSISWizardSettings oldSettings, NSISWizardSettings newSettings) { enableLangSupport.setSelection(newSettings.isEnableLanguageSupport()); m.updateSlaves(); selectLang.setSelection(newSettings.isSelectLanguage()); if (displaySupported != null) { displaySupported.setSelection(newSettings.isDisplaySupportedLanguages()); } java.util.List<NSISLanguage> selectedLanguages = newSettings.getLanguages(); java.util.List<NSISLanguage> availableLanguages = NSISLanguageManager.getInstance().getLanguages(); if (selectedLanguages.isEmpty()) { NSISWizardWelcomePage welcomePage = (NSISWizardWelcomePage) mWizard.getPage(NSISWizardWelcomePage.NAME); if (welcomePage != null) { if (!welcomePage.isCreateFromTemplate()) { NSISLanguage defaultLanguage = NSISLanguageManager.getInstance().getDefaultLanguage(); if (defaultLanguage != null && availableLanguages.contains(defaultLanguage)) { selectedLanguages.add(defaultLanguage); } } } } selectedLangViewer.setInput(selectedLanguages); availableLanguages.removeAll(selectedLanguages); availableLangViewer.setInput(availableLanguages); } }); }
/** * Create the composite * * @param parent * @param style */ public PigCategoryComposite(Composite parent, int style, CategoryManager manager) { super(parent, style); this.manager = manager; setLayout(new FillLayout()); final SashForm sashForm = new SashForm(this, SWT.NONE); final SashForm sashForm1 = new SashForm(sashForm, SWT.HORIZONTAL); final Composite composite = new Composite(sashForm1, SWT.BORDER); final GridLayout gridLayout = new GridLayout(); gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; gridLayout.verticalSpacing = 0; gridLayout.horizontalSpacing = 0; composite.setLayout(gridLayout); final CLabel categoryLabel = new CLabel(composite, SWT.SHADOW_OUT); categoryLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); categoryLabel.setText(Messages.getString("CategoryComposite.category")); // $NON-NLS-1$ final ListViewer categoryViewer = new ListViewer(composite, SWT.V_SCROLL | SWT.H_SCROLL); categoryViewer.setLabelProvider( new LabelProvider() { @Override public String getText(Object element) { return ((Category) element).getName(); } }); categoryViewer.setContentProvider(new ArrayContentProvider()); categoryViewer.setSorter(new ViewerSorter()); categoryList = categoryViewer.getList(); categoryList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final Composite composite1 = new Composite(sashForm1, SWT.BORDER); final GridLayout gridLayout1 = new GridLayout(); gridLayout1.verticalSpacing = 0; gridLayout1.horizontalSpacing = 0; gridLayout1.marginWidth = 0; gridLayout1.marginHeight = 0; composite1.setLayout(gridLayout1); final CLabel functionLabel = new CLabel(composite1, SWT.SHADOW_OUT); functionLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); functionLabel.setText(Messages.getString("CategoryComposite.functions")); // $NON-NLS-1$ functionViewer = new ListViewer(composite1, SWT.V_SCROLL | SWT.H_SCROLL); functionViewer.setContentProvider(new ArrayContentProvider()); functionViewer.setLabelProvider( new LabelProvider() { @Override public String getText(Object element) { return ((Function) element).getName(); } }); functionViewer.setSorter(new ViewerSorter()); functionList = functionViewer.getList(); functionList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // create DND in Expression Editor. This is CategoryComposite drag. DragSource source = new DragSource(functionList, DND.DROP_MOVE | DND.DROP_COPY); source.setTransfer(new Transfer[] {textTransfer}); source.addDragListener( new DragSourceListener() { @Override public void dragStart(DragSourceEvent event) { if (functionList.getSelection().equals("")) { event.doit = false; } } @Override public void dragSetData(DragSourceEvent event) { if (textTransfer.isSupportedType(event.dataType)) { Function function = (Function) ((IStructuredSelection) functionViewer.getSelection()).getFirstElement(); VirtualMetadataColumn column = new VirtualMetadataColumn(); column.setTalendType(function.getTalendType().getName()); column.setFunction(function); if (function.isUserDefined()) { event.data = (JavaUtils.JAVA_PIGUDF_DIRECTORY + "." + function.getName() + "()"); } else { event.data = (FunctionManagerExt.getOneColData(column, false)); } } } @Override public void dragFinished(DragSourceEvent event) {} }); sashForm1.setWeights(new int[] {1, 1}); Composite docComposite = new Composite(sashForm, SWT.BORDER); GridLayout docLayout = new GridLayout(); docLayout.marginTop = 0; docLayout.marginBottom = 0; docLayout.marginHeight = 0; docLayout.marginLeft = 0; docLayout.marginWidth = 0; docLayout.marginHeight = 0; docComposite.setLayout(docLayout); Label docLabel = new Label(docComposite, SWT.NONE); docLabel.setText(Messages.getString("CategoryComposite.Help")); // $NON-NLS-1$ if (TalendPropertiesUtil.isEnabledUseBrowser()) { final Browser docDisplayer = new Browser(docComposite, SWT.BORDER); docDisplayer.setText( Messages.getString("CategoryComposite.SelectCategoryAndFunction")); // $NON-NLS-1$ docDisplayer.setLayoutData(new GridData(GridData.FILL_BOTH)); sashForm.setWeights(new int[] {2, 1}); new UIRelationShipLinker(categoryViewer, functionViewer, docDisplayer); } else { final Text descriptionText = new Text(docComposite, SWT.BORDER | SWT.WRAP); descriptionText.setText( Messages.getString("CategoryComposite.SelectCategoryAndFunction")); // $NON-NLS-1$ GridData gd = new GridData(GridData.FILL_BOTH); descriptionText.setLayoutData(gd); sashForm.setWeights(new int[] {2, 1}); new UIRelationShipLinker(categoryViewer, functionViewer, descriptionText); } initializeData(categoryViewer); categoryViewer.getList().setFocus(); }
@Override public void create() { super.create(); super.getShell().setText(Messages.CustomizationDialog_customization); super.getShell().setImage(Activator.getDefault().getImage("/icons/papyrus.png")); // $NON-NLS-1$ Composite contents = new Composite(getDialogArea(), SWT.NONE); contents.setLayout(new GridLayout(2, false)); contents.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Label label = new Label(contents, SWT.NONE); label.setText(Messages.CustomizationDialog_selectContextToEdit); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); Collection<Context> contexts = ConfigurationManager.instance.getContexts(); availableContexts = new List(contents, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); availableContexts.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); availableContextsViewer = new ListViewer(availableContexts); availableContextsViewer.setContentProvider(CollectionContentProvider.instance); availableContextsViewer.setLabelProvider( new LabelProvider() { @Override public String getText(final Object element) { if (element != null && element instanceof Context) { Context context = (Context) element; return context.getName() + (ConfigurationManager.instance.isPlugin(context) ? Messages.CustomizationDialog_plugin : ""); //$NON-NLS-1$ } return super.getText(element); } }); availableContextsViewer.setInput(contexts); availableContexts.addSelectionListener(this); Composite controls = new Composite(contents, SWT.NONE); controls.setLayout(new FillLayout(SWT.VERTICAL)); copyContext = new Button(controls, SWT.PUSH); copyContext.setText(Messages.CustomizationDialog_copy); copyContext.setToolTipText(Messages.CustomizationDialog_createNewCopyByCopy); copyContext.setEnabled(false); copyContext.addSelectionListener(this); editContext = new Button(controls, SWT.PUSH); editContext.setText(Messages.CustomizationDialog_edit); editContext.setToolTipText(Messages.CustomizationDialog_editSelectedContext); editContext.setEnabled(false); editContext.addSelectionListener(this); removeContext = new Button(controls, SWT.PUSH); removeContext.setText(Messages.CustomizationDialog_delete); removeContext.setToolTipText(Messages.CustomizationDialog_removeSelectedContext); removeContext.setEnabled(false); removeContext.addSelectionListener(this); availableContextsViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); boolean activate = false; if (!selection.isEmpty()) { Context context = (Context) selection.getFirstElement(); activate = !ConfigurationManager.instance.isPlugin(context); } editContext.setEnabled(activate); copyContext.setEnabled(!selection.isEmpty()); removeContext.setEnabled(activate); } }); // generateContext = new Button(controls, SWT.PUSH); // generateContext.setText("Generate"); // generateContext.setToolTipText("Generates a new Context from a Metamodel"); // generateContext.setEnabled(false); getShell().pack(); }
/** Create contents of the dialog. */ private void createContents() { shlBusyboxSelector = new Shell(getParent(), getStyle()); shlBusyboxSelector.setSize(168, 434); shlBusyboxSelector.setText("Busybox Selector"); shlBusyboxSelector.setLayout(new FormLayout()); btnCancel = new Button(shlBusyboxSelector, SWT.NONE); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = null; shlBusyboxSelector.dispose(); } }); btnCancel.setText("Cancel"); ListViewer listBusyboxViewer = new ListViewer(shlBusyboxSelector, SWT.BORDER | SWT.V_SCROLL); listBusybox = listBusyboxViewer.getList(); fd_btnCancel.top = new FormAttachment(listBusybox, 6); FormData fd_listBusybox = new FormData(); fd_listBusybox.bottom = new FormAttachment(100, -41); fd_listBusybox.top = new FormAttachment(0, 10); fd_listBusybox.right = new FormAttachment(100, -10); fd_listBusybox.left = new FormAttachment(0, 10); listBusybox.setLayoutData(fd_listBusybox); listBusybox.addListener( SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { int selected = listBusybox.getSelectionIndex(); String string = listBusybox.getItem(selected); result = string; shlBusyboxSelector.dispose(); } }); listBusyboxViewer.setContentProvider( new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector) inputElement; return v.toArray(); } public void dispose() {} public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }); listBusyboxViewer.setLabelProvider( new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return ((File) element).getName(); } }); Vector<File> folders = new Vector(); File srcdir = new File(OS.getWorkDir() + File.separator + "devices" + File.separator + "busybox"); File[] chld = srcdir.listFiles(); for (int i = 0; i < chld.length; i++) { if (chld[i].isDirectory()) folders.add(chld[i]); } listBusyboxViewer.setInput(folders); }
@Override protected Control createDialogArea(Composite parent) { Composite control = (Composite) super.createDialogArea(parent); Composite container = new Composite(control, SWT.NONE); GridLayout layout = new GridLayout(); container.setLayout(layout); container.setLayoutData(new GridData(GridData.FILL_BOTH)); // port name Label lblTemp = new Label(container, SWT.LEFT); lblTemp.setText("Port Name:"); textPortName = new Text(container, SWT.SINGLE | SWT.BORDER); textPortName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); textPortName.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { validate(); } }); // port family lblTemp = new Label(container, SWT.LEFT); lblTemp.setText("Port Family:"); familyList = new ListViewer(container); familyList.getList().setLayoutData(new GridData(GridData.FILL_BOTH)); familyList.setContentProvider(new ListContentProvider<Integer>(family)); familyList.setLabelProvider( new LabelProvider() { @Override public String getText(Object element) { return Util.getProtocolString((Integer) element); } }); familyList.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { validate(); } }); // server address lblTemp = new Label(container, SWT.LEFT); lblTemp.setText("Server Address"); chkUdp = new Button(container, SWT.CHECK); chkUdp.setText("UDP Server"); chkUdp.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { validate(); } }); Composite comp = new Composite(container, SWT.NONE); comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); layout = new GridLayout(4, false); layout.marginHeight = layout.marginWidth = 0; comp.setLayout(layout); lblTemp = new Label(comp, SWT.LEFT); lblTemp.setText("Server Address:"); textServerAddress = new Text(comp, SWT.SINGLE | SWT.BORDER); textServerAddress.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); textServerAddress.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { validate(); } }); lblTemp = new Label(comp, SWT.LEFT); lblTemp.setText("Server Port:"); textServerPort = new Text(comp, SWT.SINGLE | SWT.BORDER); GridData gd = new GridData(); gd.widthHint = 80; textServerPort.setLayoutData(gd); textServerPort.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { validate(); } }); // proxy type lblTemp = new Label(container, SWT.LEFT); lblTemp.setText("Proxy Type:"); comboProxyType = new CCombo(container, SWT.DROP_DOWN | SWT.BORDER); comboProxyType.add("None"); comboProxyType.add("Http"); comboProxyType.add("Socks"); comboProxyType.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { validate(); } }); comboProxyType.select(0); // proxy address lblTemp = new Label(container, SWT.LEFT); lblTemp.setText("Proxy:"); comp = new Composite(container, SWT.NONE); comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); layout = new GridLayout(4, false); layout.marginHeight = layout.marginWidth = 0; comp.setLayout(layout); lblTemp = new Label(comp, SWT.LEFT); lblTemp.setText("Proxy Address:"); textProxyAddress = new Text(comp, SWT.SINGLE | SWT.BORDER); textProxyAddress.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); textProxyAddress.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { validate(); } }); lblTemp = new Label(comp, SWT.LEFT); lblTemp.setText("Proxy Port:"); textProxyPort = new Text(comp, SWT.SINGLE | SWT.BORDER); gd = new GridData(); gd.widthHint = 80; textProxyPort.setLayoutData(gd); textProxyPort.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { validate(); } }); // proxy username and password comp = new Composite(container, SWT.NONE); comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); layout = new GridLayout(4, false); layout.marginHeight = layout.marginWidth = 0; comp.setLayout(layout); lblTemp = new Label(comp, SWT.LEFT); lblTemp.setText("Proxy Username:"******"Proxy Password:"******"Before create a port, some arguments must be decided"); setTitle("Select port argument"); return control; }
/** * Create the composite * * @param parent * @param style */ public AnimateEdgeEditor(Composite parent, int style, AnimateEditor oo, PipAnimateSet aset) { super(parent, style); this.owner = oo; this.animateSet = aset; final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; setLayout(gridLayout); buttonFlag = new Button(this, SWT.CHECK); buttonFlag.addSelectionListener( new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { owner.setDirty(true); } }); buttonFlag.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); buttonFlag.setText("包含轮廓定义"); borderListViewer = new ListViewer(this, SWT.BORDER); borderListViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent arg0) { edgeSelectionChanged(); } }); borderListViewer.setLabelProvider(new ListLabelProvider()); borderListViewer.setContentProvider(new ContentProvider()); borderList = borderListViewer.getList(); final GridData gd_borderList = new GridData(SWT.FILL, SWT.FILL, false, true); gd_borderList.widthHint = 237; borderList.setLayoutData(gd_borderList); final Composite composite = new Composite(this, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final GridLayout gridLayout_1 = new GridLayout(); gridLayout_1.numColumns = 4; composite.setLayout(gridLayout_1); final Label label = new Label(composite, SWT.NONE); label.setText("起始动画ID:"); textFirstAnimate = new Text(composite, SWT.BORDER); textFirstAnimate.addModifyListener( new ModifyListener() { public void modifyText(final ModifyEvent arg0) { if (updating) { return; } try { EdgeExtension.Edge edge = getEditingEdge(); int value = Integer.parseInt(textFirstAnimate.getText()); if (value == -1 || (value >= 0 && value < animateSet.getAnimateCount())) { edge.beginAnimateIndex = value; owner.setDirty(true); textFirstAnimate.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK)); return; } } catch (Exception e) { } textFirstAnimate.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED)); } }); final GridData gd_textFirstAnimate = new GridData(SWT.FILL, SWT.CENTER, true, false); textFirstAnimate.setLayoutData(gd_textFirstAnimate); final Label label_1 = new Label(composite, SWT.NONE); label_1.setText("结束动画ID:"); textLastAnimate = new Text(composite, SWT.BORDER); textLastAnimate.addModifyListener( new ModifyListener() { public void modifyText(final ModifyEvent arg0) { if (updating) { return; } try { EdgeExtension.Edge edge = getEditingEdge(); int value = Integer.parseInt(textLastAnimate.getText()); if (value == -1 || (value >= 0 && value <= animateSet.getAnimateCount())) { edge.endAnimateIndex = value; owner.setDirty(true); textLastAnimate.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK)); return; } } catch (Exception e) { } textLastAnimate.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED)); } }); final GridData gd_textLastAnimate = new GridData(SWT.FILL, SWT.CENTER, true, false); textLastAnimate.setLayoutData(gd_textLastAnimate); final Composite editViewerContainer = new Composite(composite, SWT.NONE); editViewerContainer.setLayout(new FillLayout()); final GridData gd_editViewerContainer = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1); editViewerContainer.setLayoutData(gd_editViewerContainer); editViewer = new EdgeEditViewer(editViewerContainer, SWT.NONE); editViewer.setImageViewerListener(this); MenuManager mgr = new MenuManager(); mgr.add( new Action("添加") { public void run() { onAddEdge(); } }); mgr.add( new Action("删除") { public void run() { onDeleteEdge(); } }); Menu menu = mgr.createContextMenu(borderList); borderList.setMenu(menu); // 设置初始值 borderListViewer.setInput(new Object()); EdgeExtension ext = (EdgeExtension) animateSet.findExtension("EDGE"); if (ext == null) { buttonFlag.setSelection(false); } else { buttonFlag.setSelection(true); } edgeSelectionChanged(); }
/** * Create contents of the dialog. * * @param parent */ @Override protected Control createDialogArea(Composite parent) { super.setMessage(message, IMessageProvider.INFORMATION); super.setTitle(title); Composite area = (Composite) super.createDialogArea(parent); Composite container = new Composite(area, SWT.NONE); container.setLayout(new GridLayout(3, false)); container.setLayoutData(new GridData(GridData.FILL_BOTH)); Label nameLabel = new Label(container, SWT.NONE); nameLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); nameLabel.setText("Name:"); nameText = new Text(container, SWT.BORDER); nameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); nameText.setText(configName); nameText.addModifyListener(getModifyListener()); nameText.setEnabled(nameEditable); defaultButton = new Button(container, SWT.CHECK); defaultButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); defaultButton.setAlignment(SWT.CENTER); defaultButton.setText("Default"); defaultButton.setSelection(isDefault); defaultButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setOkButtonEnabled(true); } }); Label initNodeLabel = new Label(container, SWT.NONE); initNodeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); initNodeLabel.setText("Initial Node:"); initNodeText = new Text(container, SWT.BORDER); initNodeText.setText(initNodeName); initNodeText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); initNodeText.addModifyListener(getModifyListener()); Button initNodeButton = new Button(container, SWT.NONE); initNodeButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 0, 1)); initNodeButton.setText("Find ..."); initNodeButton.addSelectionListener( new ClassSelectionAdapter(getParentShell(), initNodeText, project.getSearchScope())); Label classpathLabel = new Label(container, SWT.NONE); classpathLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); classpathLabel.setText("Classpath:"); listViewer = new ListViewer(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); listViewer.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); listViewer.setContentProvider(new ArrayContentProvider()); listViewer.setLabelProvider(new LabelProvider()); listViewer.setInput(cpEntries); Composite classpathComposite = new Composite(container, SWT.NONE); classpathComposite.setLayout(new GridLayout(1, true)); Button btnAddFile = new Button(classpathComposite, SWT.NONE); btnAddFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnAddFile.setText("Add Files ..."); btnAddFile.addSelectionListener(new ResourceSelectionAdapter(DialogType.RESOURCE, this)); Button btnAddFolder = new Button(classpathComposite, SWT.NONE); btnAddFolder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnAddFolder.setText("Add Binary Folder ..."); btnAddFolder.addSelectionListener(new ResourceSelectionAdapter(DialogType.CONTAINER, this)); Button btnAddAbsolute = new Button(classpathComposite, SWT.NONE); btnAddAbsolute.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnAddAbsolute.setText("Add Entry ..."); btnAddAbsolute.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { InputDialog dialog = new InputDialog(getParentShell(), "Add Entry...", "", "", null); dialog.setBlockOnOpen(true); if (dialog.open() == Dialog.OK) { cpEntries.add(dialog.getValue()); setOkButtonEnabled(true); listViewer.refresh(); } } }); Composite composite = new Composite(classpathComposite, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); final Button btnRemove = new Button(classpathComposite, SWT.NONE); btnRemove.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnRemove.setText("Remove"); btnRemove.setEnabled(false); btnRemove.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String selectedString = ViewerUtils.getSelection(listViewer.getSelection(), String.class); if (selectedString != null && !selectedString.equals("")) { int oldIndex = cpEntries.indexOf(selectedString); cpEntries.remove(selectedString); listViewer.refresh(); int size = cpEntries.size(); if (size == 0) { btnRemove.setEnabled(false); } else { int select = Math.min(oldIndex, size - 1); listViewer.setSelection(new StructuredSelection(cpEntries.get(select))); } setOkButtonEnabled(true); } } }); new Label(container, SWT.NONE); Label lblNoteToAdd = new Label(container, SWT.NONE); lblNoteToAdd.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); lblNoteToAdd.setText("Note: To add Java archives (*.jar) use 'Add Files ...' "); new Label(container, SWT.NONE); Composite spacer = new Composite(container, SWT.NONE); GridData gd_spacer = new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1); gd_spacer.heightHint = 30; spacer.setLayoutData(gd_spacer); listViewer.addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { boolean enable = false; String selectedString = ViewerUtils.getSelection(event.getSelection(), String.class); if (selectedString != null && !selectedString.equals("")) { enable = true; } btnRemove.setEnabled(enable); } }); return area; }
/** * This is the method used by the framework to install your own controls. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ public void createPages() { // Creates the model from the editor input // createModel(); // Create a page for the selection tree view. // { ViewerPane viewerPane = new ViewerPane(getSite().getPage(), ProvervisualEditor.this) { public Viewer createViewer(Composite composite) { Tree tree = new Tree(composite, SWT.MULTI); TreeViewer newTreeViewer = new TreeViewer(tree); return newTreeViewer; } public void requestActivation() { super.requestActivation(); setCurrentViewerPane(this); } }; viewerPane.createControl(getContainer()); selectionViewer = (TreeViewer) viewerPane.getViewer(); selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); selectionViewer.setInput(editingDomain.getResourceSet()); viewerPane.setTitle(editingDomain.getResourceSet()); new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory); createContextMenuFor(selectionViewer); int pageIndex = addPage(viewerPane.getControl()); setPageText(pageIndex, getString("_UI_SelectionPage_label")); } // Create a page for the parent tree view. // { ViewerPane viewerPane = new ViewerPane(getSite().getPage(), ProvervisualEditor.this) { public Viewer createViewer(Composite composite) { Tree tree = new Tree(composite, SWT.MULTI); TreeViewer newTreeViewer = new TreeViewer(tree); return newTreeViewer; } public void requestActivation() { super.requestActivation(); setCurrentViewerPane(this); } }; viewerPane.createControl(getContainer()); parentViewer = (TreeViewer) viewerPane.getViewer(); parentViewer.setAutoExpandLevel(30); parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory)); parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); createContextMenuFor(parentViewer); int pageIndex = addPage(viewerPane.getControl()); setPageText(pageIndex, getString("_UI_ParentPage_label")); } // This is the page for the list viewer // { ViewerPane viewerPane = new ViewerPane(getSite().getPage(), ProvervisualEditor.this) { public Viewer createViewer(Composite composite) { return new ListViewer(composite); } public void requestActivation() { super.requestActivation(); setCurrentViewerPane(this); } }; viewerPane.createControl(getContainer()); listViewer = (ListViewer) viewerPane.getViewer(); listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); createContextMenuFor(listViewer); int pageIndex = addPage(viewerPane.getControl()); setPageText(pageIndex, getString("_UI_ListPage_label")); } // This is the page for the tree viewer // { ViewerPane viewerPane = new ViewerPane(getSite().getPage(), ProvervisualEditor.this) { public Viewer createViewer(Composite composite) { return new TreeViewer(composite); } public void requestActivation() { super.requestActivation(); setCurrentViewerPane(this); } }; viewerPane.createControl(getContainer()); treeViewer = (TreeViewer) viewerPane.getViewer(); treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory); createContextMenuFor(treeViewer); int pageIndex = addPage(viewerPane.getControl()); setPageText(pageIndex, getString("_UI_TreePage_label")); } // This is the page for the table viewer. // { ViewerPane viewerPane = new ViewerPane(getSite().getPage(), ProvervisualEditor.this) { public Viewer createViewer(Composite composite) { return new TableViewer(composite); } public void requestActivation() { super.requestActivation(); setCurrentViewerPane(this); } }; viewerPane.createControl(getContainer()); tableViewer = (TableViewer) viewerPane.getViewer(); Table table = tableViewer.getTable(); TableLayout layout = new TableLayout(); table.setLayout(layout); table.setHeaderVisible(true); table.setLinesVisible(true); TableColumn objectColumn = new TableColumn(table, SWT.NONE); layout.addColumnData(new ColumnWeightData(3, 100, true)); objectColumn.setText(getString("_UI_ObjectColumn_label")); objectColumn.setResizable(true); TableColumn selfColumn = new TableColumn(table, SWT.NONE); layout.addColumnData(new ColumnWeightData(2, 100, true)); selfColumn.setText(getString("_UI_SelfColumn_label")); selfColumn.setResizable(true); tableViewer.setColumnProperties(new String[] {"a", "b"}); tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); createContextMenuFor(tableViewer); int pageIndex = addPage(viewerPane.getControl()); setPageText(pageIndex, getString("_UI_TablePage_label")); } // This is the page for the table tree viewer. // { ViewerPane viewerPane = new ViewerPane(getSite().getPage(), ProvervisualEditor.this) { public Viewer createViewer(Composite composite) { return new TreeViewer(composite); } public void requestActivation() { super.requestActivation(); setCurrentViewerPane(this); } }; viewerPane.createControl(getContainer()); treeViewerWithColumns = (TreeViewer) viewerPane.getViewer(); Tree tree = treeViewerWithColumns.getTree(); tree.setLayoutData(new FillLayout()); tree.setHeaderVisible(true); tree.setLinesVisible(true); TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE); objectColumn.setText(getString("_UI_ObjectColumn_label")); objectColumn.setResizable(true); objectColumn.setWidth(250); TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE); selfColumn.setText(getString("_UI_SelfColumn_label")); selfColumn.setResizable(true); selfColumn.setWidth(200); treeViewerWithColumns.setColumnProperties(new String[] {"a", "b"}); treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); createContextMenuFor(treeViewerWithColumns); int pageIndex = addPage(viewerPane.getControl()); setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label")); } setActivePage(0); getContainer() .addControlListener( new ControlAdapter() { boolean guard = false; public void controlResized(ControlEvent event) { if (!guard) { guard = true; hideTabs(); guard = false; } } }); }
private void createContent() { GridData gridData; Composite composite = new Composite(this, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); composite.setLayout(new GridLayout(3, false)); FontRegistry fontRegistry = new FontRegistry(shell.getDisplay()); fontRegistry.put( "WidgetTitle", new FontData[] {new FontData("Arial", 10, SWT.BOLD)}); // $NON-NLS-1$ //$NON-NLS-2$ Label label = new Label(composite, SWT.NONE); label.setFont(fontRegistry.get("WidgetTitle")); // $NON-NLS-1$ label.setText(Messages.getString("RTCTypeToRTTypeWidget.3")); // $NON-NLS-1$ gridData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 3, 1); label.setLayoutData(gridData); Label titleBarSeparator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR); titleBarSeparator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); Label currentTerminoRelationTypeLabel = new Label(composite, SWT.NONE); currentTerminoRelationTypeLabel.setText( Messages.getString("RTCTypeToRTTypeWidget.4") + " :"); // $NON-NLS-1$ //$NON-NLS-2$ currentTerminoRelationTypeText = new Text(composite, SWT.SINGLE | SWT.BORDER); currentTerminoRelationTypeText.setLayoutData( new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); Label associatedTypeLabel = new Label(composite, SWT.NONE); associatedTypeLabel.setLayoutData( new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 1, 2)); associatedTypeLabel.setText( Messages.getString("RTCTypeToRTTypeWidget.6") + " :"); // $NON-NLS-1$ //$NON-NLS-2$ rtTypeListViewer = new ListViewer(composite, SWT.BORDER | SWT.V_SCROLL); rtTypeListViewer.setContentProvider(new RTTypeContentProvider()); rtTypeListViewer.setLabelProvider(new RTLabelProvider()); gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 2); gridData.heightHint = 100; rtTypeListViewer.getList().setLayoutData(gridData); rtTypeListViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection.getFirstElement() != null) { unlinkAction.setEnabled(true); currentRTType = (ITypeRelationTermino) selection.getFirstElement(); propertyChangeSupport.firePropertyChange( rtTypeSelectionEventType, null, currentRTType); } else { unlinkAction.setEnabled(false); } } }); Label newRTTypeLabel = new Label(composite, SWT.NONE); gridData = new GridData(); gridData.verticalAlignment = SWT.CENTER; newRTTypeLabel.setLayoutData(gridData); newRTTypeLabel.setText( Messages.getString("RTCTypeToRTTypeWidget.8") + " :"); // $NON-NLS-1$ //$NON-NLS-2$ newRTTypeText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.WRAP); gridData = new GridData(); gridData.horizontalAlignment = SWT.FILL; gridData.widthHint = 150; gridData.grabExcessHorizontalSpace = true; newRTTypeText.setLayoutData(gridData); Button newRTTypeButton = new Button(composite, SWT.NONE); String imageId = org.dafoe.terminologiclevel.Activator.NEW_IMG_ID; ImageDescriptor imgDesc = org.dafoe.terminologiclevel.Activator.getDefault() .getImageRegistry() .getDescriptor(imageId); Image imageAdd = imgDesc.createImage(); newRTTypeButton.setImage(imageAdd); newRTTypeButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false)); newRTTypeButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { String newRTTypeLabel = newRTTypeText.getText().trim(); ; if (newRTTypeLabel.compareTo("") != 0) { // $NON-NLS-1$ ITypeRelationTermino testRTType = DatabaseAdapter.getRTTypeByLabel(newRTTypeLabel); // there isn't another RT type with the same label if (testRTType == null) { ITypeRelationTermino newRTType = DatabaseAdapter.createRelationType(newRTTypeLabel); org.dafoe.terminoontologiclevel.common.DatabaseAdapter.linkRTCTypeWithRTType( currentRTCType, newRTType); newRTTypeText.setText(""); // $NON-NLS-1$ updateContent(currentRTCType); propertyChangeSupport.firePropertyChange(newRTEventType, null, newRTType); } else { String msg = Messages.getString("RTCTypeToRTTypeWidget.12") + newRTTypeLabel + Messages.getString( "RTCTypeToRTTypeWidget.13"); //$NON-NLS-1$ //$NON-NLS-2$ msg += Messages.getString("RTCTypeToRTTypeWidget.14"); // $NON-NLS-1$ MessageDialog.openWarning( shell, Messages.getString("RTCTypeToRTTypeWidget.15"), msg); // $NON-NLS-1$ newRTTypeText.selectAll(); } } } }); composite.addListener( SWT.Resize, new Listener() { public void handleEvent(Event event) { Rectangle rect = RTCTypeToRTTypeWidget.this.getClientArea(); Image newImage = new Image(shell.getDisplay(), Math.max(1, rect.width), 1); GC gc = new GC(newImage); gc.setForeground(terminologic_level_color); gc.setBackground(terminoontologic_level_color); gc.fillGradientRectangle(rect.x, rect.y, rect.width, 1, false); gc.dispose(); RTCTypeToRTTypeWidget.this.setBackgroundImage(newImage); if (oldImage != null) { oldImage.dispose(); } oldImage = newImage; } }); makeActions(); hookPopupMenu(); }
/** Create contents of the dialog. */ private void createContents() { shlDecruptWizard = new Shell(getParent(), getStyle()); shlDecruptWizard.setSize(539, 497); shlDecruptWizard.setText("ROM Cleaner"); shlDecruptWizard.setLayout(new FormLayout()); listViewerInstalled = new ListViewer(shlDecruptWizard, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI); listInstalled = listViewerInstalled.getList(); listViewerInstalled.setSorter(new ViewerSorter()); FormData fd_listInstalled = new FormData(); fd_listInstalled.bottom = new FormAttachment(0, 229); fd_listInstalled.right = new FormAttachment(0, 223); fd_listInstalled.top = new FormAttachment(0, 71); fd_listInstalled.left = new FormAttachment(0, 10); listInstalled.setLayoutData(fd_listInstalled); listViewerInstalled.setContentProvider( new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector) inputElement; return v.toArray(); } public void dispose() {} public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }); listViewerInstalled.setLabelProvider( new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return (String) element; } }); Label lblInstalled = new Label(shlDecruptWizard, SWT.NONE); FormData fd_lblInstalled = new FormData(); fd_lblInstalled.right = new FormAttachment(0, 173); fd_lblInstalled.top = new FormAttachment(0, 51); fd_lblInstalled.left = new FormAttachment(0, 10); lblInstalled.setLayoutData(fd_lblInstalled); lblInstalled.setText("Installed on device :"); listViewerToRemove = new ListViewer(shlDecruptWizard, SWT.BORDER | SWT.V_SCROLL); listViewerToRemove.setSorter(new ViewerSorter()); listToRemove = listViewerToRemove.getList(); FormData fd_listToRemove = new FormData(); fd_listToRemove.bottom = new FormAttachment(listInstalled, 0, SWT.BOTTOM); fd_listToRemove.top = new FormAttachment(listInstalled, 0, SWT.TOP); fd_listToRemove.right = new FormAttachment(0, 522); fd_listToRemove.left = new FormAttachment(0, 282); listToRemove.setLayoutData(fd_listToRemove); listViewerToRemove.setContentProvider( new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector) inputElement; return v.toArray(); } public void dispose() {} public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }); listViewerToRemove.setLabelProvider( new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return (String) element; } }); Label lbltoremove = new Label(shlDecruptWizard, SWT.NONE); FormData fd_lbltoremove = new FormData(); fd_lbltoremove.right = new FormAttachment(0, 415); fd_lbltoremove.top = new FormAttachment(0, 51); fd_lbltoremove.left = new FormAttachment(0, 282); lbltoremove.setLayoutData(fd_lbltoremove); lbltoremove.setText("To be removed :"); btnCancel = new Button(shlDecruptWizard, SWT.NONE); FormData fd_btnCancel = new FormData(); fd_btnCancel.bottom = new FormAttachment(100, -10); fd_btnCancel.right = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { apps = null; shlDecruptWizard.dispose(); } }); btnCancel.setText("Cancel"); Button btnClean = new Button(shlDecruptWizard, SWT.NONE); FormData fd_btnClean = new FormData(); fd_btnClean.bottom = new FormAttachment(100, -10); fd_btnClean.right = new FormAttachment(btnCancel, -6); btnClean.setLayoutData(fd_btnClean); btnClean.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { apps.saveProfile(); shlDecruptWizard.dispose(); } }); btnClean.setText("Clean"); Composite compositeProfile = new Composite(shlDecruptWizard, SWT.NONE); compositeProfile.setLayout(new GridLayout(2, false)); FormData fd_compositeProfile = new FormData(); fd_compositeProfile.bottom = new FormAttachment(lblInstalled, -6); fd_compositeProfile.top = new FormAttachment(0, 10); fd_compositeProfile.left = new FormAttachment(listInstalled, 0, SWT.LEFT); fd_compositeProfile.right = new FormAttachment(listToRemove, 0, SWT.RIGHT); compositeProfile.setLayoutData(fd_compositeProfile); Label lblProfile = new Label(compositeProfile, SWT.NONE); GridData gd_lblProfile = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); gd_lblProfile.widthHint = 92; lblProfile.setLayoutData(gd_lblProfile); lblProfile.setText("Profile :"); comboProfile = new Combo(compositeProfile, SWT.READ_ONLY); comboProfile.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!apps.getCurrentProfile().equals(comboProfile.getText())) { apps.setProfile(comboProfile.getText()); init(); listViewerInstalled.refresh(); listViewerToRemove.refresh(); listViewerToInstall.refresh(); listViewerAvailable.refresh(); } } }); comboProfile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); comboProfile.setText("default"); Iterator<String> itprofiles = apps.getProfiles().iterator(); while (itprofiles.hasNext()) { comboProfile.add(itprofiles.next()); } comboProfile.select(comboProfile.indexOf("default")); compositeButtongroup1 = new Composite(shlDecruptWizard, SWT.NONE); compositeButtongroup1.setLayout(new GridLayout(1, false)); FormData fd_compositeButtongroup1 = new FormData(); fd_compositeButtongroup1.bottom = new FormAttachment(listInstalled, -36, SWT.BOTTOM); fd_compositeButtongroup1.top = new FormAttachment(compositeProfile, 61); fd_compositeButtongroup1.right = new FormAttachment(listToRemove, -6); fd_compositeButtongroup1.left = new FormAttachment(listInstalled, 5); compositeButtongroup1.setLayoutData(fd_compositeButtongroup1); Button btnAddToRemove = new Button(compositeButtongroup1, SWT.NONE); GridData gd_btnAddToRemove = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_btnAddToRemove.heightHint = 26; gd_btnAddToRemove.widthHint = 40; btnAddToRemove.setLayoutData(gd_btnAddToRemove); btnAddToRemove.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) listViewerInstalled.getSelection(); Iterator i = selection.iterator(); while (i.hasNext()) { String f = (String) i.next(); installed.remove(f); toremove.add(f); apps.setSafe(apps.getApkName(f)); listViewerInstalled.refresh(); listViewerToRemove.refresh(); } } }); btnAddToRemove.setText("->"); new Label(compositeButtongroup1, SWT.NONE); Button btnAddToInstalled = new Button(compositeButtongroup1, SWT.NONE); GridData gd_btnAddToInstalled = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_btnAddToInstalled.heightHint = 26; gd_btnAddToInstalled.widthHint = 40; btnAddToInstalled.setLayoutData(gd_btnAddToInstalled); btnAddToInstalled.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) listViewerToRemove.getSelection(); Iterator i = selection.iterator(); while (i.hasNext()) { String f = (String) i.next(); toremove.remove(f); installed.add(f); apps.setUnsafe(apps.getApkName(f)); listViewerInstalled.refresh(); listViewerToRemove.refresh(); } } }); btnAddToInstalled.setText("<-"); Label lblAvailable = new Label(shlDecruptWizard, SWT.NONE); FormData fd_lblAvailable = new FormData(); fd_lblAvailable.top = new FormAttachment(listInstalled, 6); fd_lblAvailable.left = new FormAttachment(0, 10); lblAvailable.setLayoutData(fd_lblAvailable); lblAvailable.setText("Available for installation :"); Label lblToInstall = new Label(shlDecruptWizard, SWT.NONE); FormData fd_lblToInstall = new FormData(); fd_lblToInstall.top = new FormAttachment(listToRemove, 6); fd_lblToInstall.left = new FormAttachment(listToRemove, 0, SWT.LEFT); lblToInstall.setLayoutData(fd_lblToInstall); lblToInstall.setText("To be installed :"); listViewerAvailable = new ListViewer(shlDecruptWizard, SWT.BORDER | SWT.V_SCROLL); listViewerAvailable.setSorter(new ViewerSorter()); List listAvailable = listViewerAvailable.getList(); FormData fd_listAvailable = new FormData(); fd_listAvailable.top = new FormAttachment(lblAvailable, 6); fd_listAvailable.right = new FormAttachment(listInstalled, 0, SWT.RIGHT); fd_listAvailable.left = new FormAttachment(0, 10); listAvailable.setLayoutData(fd_listAvailable); listViewerAvailable.setContentProvider( new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector) inputElement; return v.toArray(); } public void dispose() {} public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }); listViewerAvailable.setLabelProvider( new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return (String) element; } }); listViewerToInstall = new ListViewer(shlDecruptWizard, SWT.BORDER | SWT.V_SCROLL); listViewerToInstall.setSorter(new ViewerSorter()); List listToInstall = listViewerToInstall.getList(); fd_listAvailable.bottom = new FormAttachment(listToInstall, 0, SWT.BOTTOM); FormData fd_listToInstall = new FormData(); fd_listToInstall.bottom = new FormAttachment(btnCancel, -6); fd_listToInstall.top = new FormAttachment(lblToInstall, 6); fd_listToInstall.left = new FormAttachment(listToRemove, 0, SWT.LEFT); fd_listToInstall.right = new FormAttachment(100, -11); listToInstall.setLayoutData(fd_listToInstall); listViewerToInstall.setContentProvider( new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector) inputElement; return v.toArray(); } public void dispose() {} public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }); listViewerToInstall.setLabelProvider( new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return (String) element; } }); Composite compositeButtongroup2 = new Composite(shlDecruptWizard, SWT.NONE); compositeButtongroup2.setLayout(new GridLayout(1, false)); FormData fd_compositeButtongroup2 = new FormData(); fd_compositeButtongroup2.bottom = new FormAttachment(100, -89); fd_compositeButtongroup2.right = new FormAttachment(compositeButtongroup1, 0, SWT.RIGHT); compositeButtongroup2.setLayoutData(fd_compositeButtongroup2); Button btnAddToBeInstalled = new Button(compositeButtongroup2, SWT.NONE); GridData gd_btnAddToBeInstalled = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_btnAddToBeInstalled.widthHint = 40; gd_btnAddToBeInstalled.heightHint = 26; btnAddToBeInstalled.setLayoutData(gd_btnAddToBeInstalled); btnAddToBeInstalled.setText("->"); new Label(compositeProfile, SWT.NONE); btnAddToBeInstalled.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) listViewerAvailable.getSelection(); Iterator i = selection.iterator(); while (i.hasNext()) { String f = (String) i.next(); toinstall.add(f); available.remove(f); apps.setUnsafe(apps.getApkName(f)); listViewerToInstall.refresh(); listViewerAvailable.refresh(); } } }); Button btnAddToAvailable = new Button(compositeButtongroup2, SWT.NONE); GridData gd_btnAddToAvailable = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_btnAddToAvailable.widthHint = 40; gd_btnAddToAvailable.heightHint = 26; btnAddToAvailable.setLayoutData(gd_btnAddToAvailable); btnAddToAvailable.setText("<-"); new Label(compositeProfile, SWT.NONE); btnAddToAvailable.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) listViewerToInstall.getSelection(); Iterator i = selection.iterator(); while (i.hasNext()) { String f = (String) i.next(); toinstall.remove(f); available.add(f); apps.setSafe(apps.getApkName(f)); listViewerToInstall.refresh(); listViewerAvailable.refresh(); } } }); listViewerInstalled.setInput(installed); listViewerToRemove.setInput(toremove); listViewerToInstall.setInput(toinstall); listViewerAvailable.setInput(available); }
protected Control bindListOfValues(FormToolkit toolkit, Composite parent, final Object id) { final Composite panel = toolkit.createComposite(parent); panel.setLayoutData(new GridData(GridData.FILL_BOTH)); GridLayout layout = new GridLayout(3, false); zeroMargins(layout); panel.setLayout(layout); final Text name = toolkit.createText(panel, ""); name.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); final Button add = new Button(panel, SWT.PUSH | SWT.BORDER); add.setText("Add"); add.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); final Button delete = new Button(panel, SWT.PUSH | SWT.BORDER); delete.setText("Delete"); // delete.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); final ListViewer viewer = new ListViewer(panel, SWT.BORDER); viewer.setContentProvider(new ObservableListContentProvider()); final Control control = viewer.getControl(); control.setLayoutData(new GridData(GridData.FILL_BOTH)); if (control instanceof org.eclipse.swt.widgets.List) { org.eclipse.swt.widgets.List list = (org.eclipse.swt.widgets.List) control; list.setSize(400, 300); } List<String> listData; Object value = node.getPropertyValue(id); if (value instanceof List) { listData = (List<String>) value; } else { listData = new ArrayList<String>(); } final WritableList input = new WritableList(listData, String.class); node.setPropertyValue(id, input); viewer.setInput(input); final Runnable addAction = new Runnable() { @Override public void run() { String p = name.getText(); name.setText(""); if (!input.contains(p)) { input.add(p); fireNodePropertyChangedEvent(id); // lets layout to make things a bit bigger if need be if (control instanceof org.eclipse.swt.widgets.List) { org.eclipse.swt.widgets.List list = (org.eclipse.swt.widgets.List) control; list.pack(true); } panel.layout(true, true); layoutForm(); } } }; final Runnable deleteAction = new Runnable() { @Override public void run() { if (!viewer.getSelection().isEmpty()) { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); Iterator iter = selection.iterator(); while (iter.hasNext()) { String p = (String) iter.next(); input.remove(p); } fireNodePropertyChangedEvent(id); } } }; // return on entry field adds name.addKeyListener( new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.stateMask == 0 && e.keyCode == '\r') { addAction.run(); } } }); // backspace on list to delete control.addKeyListener( new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if ((e.stateMask == 0 && e.keyCode == SWT.BS) || (e.stateMask == 0 && e.keyCode == SWT.DEL)) { deleteAction.run(); } } }); // enable / disable buttons add.setEnabled(false); delete.setEnabled(false); name.addModifyListener( new ModifyListener() { @Override public void modifyText(ModifyEvent e) { add.setEnabled(name.getText().length() > 0); } }); viewer.addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { delete.setEnabled(!event.getSelection().isEmpty()); } }); delete.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { deleteAction.run(); } }); add.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { addAction.run(); } }); toolkit.adapt(control, true, true); return control; }