/* * The key listeners we add workaround a bug int Text that don't repaint * properly when they have background images. */ protected void createChatControl(Widget item) throws Exception { CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE); tabItem.setText("Chat with " + ((TreeItem) item).getText()); SashForm textForm = new SashForm(tabFolder, SWT.VERTICAL); final Text text1 = new Text(textForm, SWT.MULTI); text1.setData("id", "output"); text1.setText(OUTPUT_TEXT); text1.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent arg0) { text1.redraw(); } }); final Text text2 = new Text(textForm, SWT.MULTI); text2.setData("id", "input"); text2.setText(INPUT_TEXT); text2.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent arg0) { text2.redraw(); } }); tabItem.setControl(textForm); textForm.setWeights(new int[] {80, 20}); getCSSEngine().applyStyles(textForm, false); tabFolder.setSelection(tabItem); }
protected Composite createValueText(FormToolkit widgetFactory, Composite parent) { FormUtils.createPartLabel( widgetFactory, parent, DroidMessages.BooleanVDPropertiesEditionPart_ValueLabel, propertiesEditionComponent.isRequired( DroidViewsRepository.BooleanVD.Properties.value, DroidViewsRepository.FORM_KIND)); value = widgetFactory.createText(parent, ""); // $NON-NLS-1$ value.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); widgetFactory.paintBordersFor(parent); GridData valueData = new GridData(GridData.FILL_HORIZONTAL); value.setLayoutData(valueData); value.addFocusListener( new FocusAdapter() { /** * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent) */ @Override @SuppressWarnings("synthetic-access") public void focusLost(FocusEvent e) { if (propertiesEditionComponent != null) propertiesEditionComponent.firePropertiesChanged( new PropertiesEditionEvent( BooleanVDPropertiesEditionPartForm.this, DroidViewsRepository.BooleanVD.Properties.value, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, value.getText())); } }); value.addKeyListener( new KeyAdapter() { /** @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent) */ @Override @SuppressWarnings("synthetic-access") public void keyPressed(KeyEvent e) { if (e.character == SWT.CR) { if (propertiesEditionComponent != null) propertiesEditionComponent.firePropertiesChanged( new PropertiesEditionEvent( BooleanVDPropertiesEditionPartForm.this, DroidViewsRepository.BooleanVD.Properties.value, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, value.getText())); } } }); EditingUtils.setID(value, DroidViewsRepository.BooleanVD.Properties.value); EditingUtils.setEEFtype(value, "eef::Text"); // $NON-NLS-1$ FormUtils.createHelpButton( widgetFactory, parent, propertiesEditionComponent.getHelpContent( DroidViewsRepository.BooleanVD.Properties.value, DroidViewsRepository.FORM_KIND), null); //$NON-NLS-1$ return parent; }
private List<Text> addTextFrom(final Page page, final Composite c) { if (lines != null) { for (Composite line : lines) { line.dispose(); } } List<Text> list = new ArrayList<Text>(); this.page = page; Composite lineComposite = new Composite(c, SWT.NONE); setLineLayout(lineComposite); if (lines != null) lines.add(lineComposite); for (Word word : JavaConversions.asJavaIterable(page.words())) { if (word.original().equals(Page.ParagraphMarker())) { lineComposite = new Composite(c, SWT.NONE); setLineLayout(lineComposite); lines.add(lineComposite); } else { Text text = new Text(lineComposite, SWT.NONE); setCssName(text); text.setText(TextHelper.fixForDisplay(word.history().top().form())); handleEmptyText(text); // option: word.isPossibleError() ? UNCHECKED : DEFAULT text.setForeground(parent.getDisplay().getSystemColor(DEFAULT)); text.setData(Word.class.toString(), word); text.setData(Page.class.toString(), page); addListeners(text); text.setEditable(!word.isLocked() && !page.done()); list.add(text); } } this.layout(); return list; }
protected Composite createDescriptionText(FormToolkit widgetFactory, Composite parent) { createDescription( parent, InteractionViewsRepository.InteractionUse.Properties.description, InteractionMessages.InteractionUsePropertiesEditionPart_DescriptionLabel); description = widgetFactory.createText(parent, ""); // $NON-NLS-1$ description.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); widgetFactory.paintBordersFor(parent); GridData descriptionData = new GridData(GridData.FILL_HORIZONTAL); description.setLayoutData(descriptionData); description.addFocusListener( new FocusAdapter() { /** * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent) */ @Override @SuppressWarnings("synthetic-access") public void focusLost(FocusEvent e) { if (propertiesEditionComponent != null) propertiesEditionComponent.firePropertiesChanged( new PropertiesEditionEvent( InteractionUsePropertiesEditionPartForm.this, InteractionViewsRepository.InteractionUse.Properties.description, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, description.getText())); } }); description.addKeyListener( new KeyAdapter() { /** @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent) */ @Override @SuppressWarnings("synthetic-access") public void keyPressed(KeyEvent e) { if (e.character == SWT.CR) { if (propertiesEditionComponent != null) propertiesEditionComponent.firePropertiesChanged( new PropertiesEditionEvent( InteractionUsePropertiesEditionPartForm.this, InteractionViewsRepository.InteractionUse.Properties.description, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, description.getText())); } } }); EditingUtils.setID( description, InteractionViewsRepository.InteractionUse.Properties.description); EditingUtils.setEEFtype(description, "eef::Text"); // $NON-NLS-1$ FormUtils.createHelpButton( widgetFactory, parent, propertiesEditionComponent.getHelpContent( InteractionViewsRepository.InteractionUse.Properties.description, InteractionViewsRepository.FORM_KIND), null); //$NON-NLS-1$ return parent; }
private Composite createUserArea( Composite parent, FormToolkit toolkit, PersonIdent person, boolean author) { Composite userArea = toolkit.createComposite(parent); GridLayoutFactory.fillDefaults().spacing(2, 2).numColumns(3).applyTo(userArea); Label userLabel = toolkit.createLabel(userArea, null); userLabel.setImage(getImage(author ? UIIcons.ELCL16_AUTHOR : UIIcons.ELCL16_COMMITTER)); if (author) userLabel.setToolTipText(UIText.CommitEditorPage_TooltipAuthor); else userLabel.setToolTipText(UIText.CommitEditorPage_TooltipCommitter); boolean signedOff = isSignedOffBy(person); Text userText = new Text(userArea, SWT.FLAT | SWT.READ_ONLY); userText.setText( MessageFormat.format( author ? UIText.CommitEditorPage_LabelAuthor : UIText.CommitEditorPage_LabelCommitter, person.getName(), person.getEmailAddress(), person.getWhen())); toolkit.adapt(userText, false, false); userText.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE); GridDataFactory.fillDefaults().span(signedOff ? 1 : 2, 1).applyTo(userText); if (signedOff) { Label signedOffLabel = toolkit.createLabel(userArea, null); signedOffLabel.setImage(getImage(UIIcons.SIGNED_OFF)); if (author) signedOffLabel.setToolTipText(UIText.CommitEditorPage_TooltipSignedOffByAuthor); else signedOffLabel.setToolTipText(UIText.CommitEditorPage_TooltipSignedOffByCommitter); } return userArea; }
private Text addATextField(Composite parent, String key, int minWidth, int horizontalIndent) { Text textBox = new Text(parent, SWT.BORDER | SWT.SINGLE); textBox.setData(key); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalIndent = horizontalIndent; data.horizontalSpan = 2; data.grabExcessHorizontalSpace = true; data.minimumWidth = minWidth; textBox.setLayoutData(data); return textBox; }
/** * set a model to apply content to user interface. * * @param p a object */ public void setModel(Object p) { sqlPredicate = ((SQLPredicate) ((TreeObject) p).getUserObject()); treeObject = (TreeObject) p; textName.setText(sqlPredicate.getName() == null ? "" : sqlPredicate.getName()); textQuery.setText(sqlPredicate.getQuery() == null ? "" : sqlPredicate.getQuery()); // set the data sources DataSource ds = sqlPredicate.getDataSource() == null ? null : sqlPredicate.getDataSource(); if (ds != null && !dataSources.contains(ds)) dataSources.add(ds); setDataSources(repositoryTreeView.kbplus.repository.getDataSources()); // displayDataSources(); labelCurrentDS.setText(ds.toString()); textClass.setEnabled(false); buttonBrowse.setEnabled(false); if (sqlPredicate.getTypeMapping() != null) { textClass.setData(sqlPredicate.getTypeMapping().getClass()); textClass.setText(sqlPredicate.getTypeMapping().getClass().toString()); if (sqlPredicate.getTypeMapping().getClass() == DefaultTypeMapping.class) { rbDefault.setSelection(true); rbMeta.setSelection(false); rbCustom.setSelection(false); } else { rbCustom.setSelection(true); rbDefault.setSelection(false); rbMeta.setSelection(false); textClass.setEnabled(true); buttonBrowse.setEnabled(true); } } else { textClass.setData(null); textClass.setText(""); rbMeta.setSelection(true); rbDefault.setSelection(false); rbCustom.setSelection(false); } }
private void handleCustTableSelectionChanged() { if (getCustTableSelection() == null) { return; } CustomizeData custData = getCustTableSelection(); if (custData == null) { XViewerLog.logAndPopup( Activator.class, Level.SEVERE, new IllegalStateException("Can't obtain selection Xml")); return; } List<XViewerColumn> hideXCols = new ArrayList<XViewerColumn>(); List<XViewerColumn> showXCols = new ArrayList<XViewerColumn>(); for (XViewerColumn xCol : custData.getColumnData().getColumns()) { if (xCol.isShow()) { showXCols.add(xCol); } else { hideXCols.add(xCol); } } hiddenColTable.getViewer().setInput(hideXCols); visibleColTable.getViewer().setInput(showXCols); sorterText.setText(custData.getSortingData().getXml()); sorterText.setData(custData); filterText.setText(custData.getFilterData().getFilterText()); filterText.setData(custData); filterRegExCheckBox.setSelection(custData.getFilterData().isRegularExpression()); columnFilterText.setText(custData.getColumnFilterData().getXml()); columnFilterText.setData(custData); updateSortTextField(); updateColumnFilterField(); }
private Text addTextControl(Composite parent, Label labelControl, String key, int indent) { GridData gd = new GridData(); gd.horizontalIndent = indent; labelControl.setLayoutData(gd); gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = convertWidthInCharsToPixels(30); Text text = new Text(parent, SWT.SINGLE | SWT.BORDER); text.setText(getPreferenceStore().getString(key)); text.setData(key); text.setLayoutData(gd); fTextControls.add(text); return text; }
/** * set a model to apply content to user interface. * * @param p a dynabeanfunction */ public void setModel(Object p) { dynaBeanFunction = ((DynaBeanFunction) ((TreeObject) p).getUserObject()); treeObject = (TreeObject) p; textName.setText(dynaBeanFunction.getName() == null ? "" : dynaBeanFunction.getName()); textProperty.setText(dynaBeanFunction == null ? "" : dynaBeanFunction.getPropertyName()); listMethods.removeAll(); listParameter.removeAll(); textClass.setData(dynaBeanFunction.getMethod().getDeclaringClass()); textClass.setText(dynaBeanFunction.getMethod().getDeclaringClass().toString()); setList(dynaBeanFunction.getMethod().getDeclaringClass()); String[] items = listMethods.getItems(); for (int i = 0; i < items.length; i++) { if (items[i].equals(dynaBeanFunction.getMethod().toString())) { listMethods.select(i); displayMethodDetails(dynaBeanFunction.getMethod()); break; } } }
protected Composite createCommentText(FormToolkit widgetFactory, Composite parent) { createDescription( parent, ChecklistViewsRepository.Item.Properties.comment, ChecklistMessages.ItemPropertiesEditionPart_CommentLabel); comment = widgetFactory.createText(parent, ""); // $NON-NLS-1$ comment.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); widgetFactory.paintBordersFor(parent); GridData commentData = new GridData(GridData.FILL_HORIZONTAL); comment.setLayoutData(commentData); comment.addFocusListener( new FocusAdapter() { /** * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent) */ @Override @SuppressWarnings("synthetic-access") public void focusLost(FocusEvent e) { if (propertiesEditionComponent != null) { propertiesEditionComponent.firePropertiesChanged( new PropertiesEditionEvent( ItemPropertiesEditionPartForm.this, ChecklistViewsRepository.Item.Properties.comment, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, comment.getText())); propertiesEditionComponent.firePropertiesChanged( new PropertiesEditionEvent( ItemPropertiesEditionPartForm.this, ChecklistViewsRepository.Item.Properties.comment, PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_LOST, null, comment.getText())); } } /** * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent) */ @Override public void focusGained(FocusEvent e) { if (propertiesEditionComponent != null) { propertiesEditionComponent.firePropertiesChanged( new PropertiesEditionEvent( ItemPropertiesEditionPartForm.this, null, PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_GAINED, null, null)); } } }); comment.addKeyListener( new KeyAdapter() { /** @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent) */ @Override @SuppressWarnings("synthetic-access") public void keyPressed(KeyEvent e) { if (e.character == SWT.CR) { if (propertiesEditionComponent != null) propertiesEditionComponent.firePropertiesChanged( new PropertiesEditionEvent( ItemPropertiesEditionPartForm.this, ChecklistViewsRepository.Item.Properties.comment, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, comment.getText())); } } }); EditingUtils.setID(comment, ChecklistViewsRepository.Item.Properties.comment); EditingUtils.setEEFtype(comment, "eef::Text"); // $NON-NLS-1$ FormUtils.createHelpButton( widgetFactory, parent, propertiesEditionComponent.getHelpContent( ChecklistViewsRepository.Item.Properties.comment, ChecklistViewsRepository.FORM_KIND), null); //$NON-NLS-1$ // Start of user code for createCommentText // End of user code return parent; }
public LoginPanel(Shell page, Composite parent) { super(parent, SWT.NONE); this.shell = page; setLayout(new GridLayout()); // ´´½¨µÇ¼ÇøÓòµÄÓû§±êÇ© Óû§ÃûÊäÈë¿ò ÃÜÂë±êÇ© ÃÜÂëÊäÈë¿ò µÇ¼°´Å¥ Composite panelTop = new Composite(this, SWT.NONE); panelTop.setBackgroundMode(SWT.INHERIT_DEFAULT); RowLayout layout = new RowLayout(); layout.spacing = 40; layout.marginBottom = 0; layout.marginRight = 10; layout.marginTop = 0; layout.wrap = false; layout.pack = true; layout.center = true; panelTop.setLayout(layout); userText = new Text(panelTop, SWT.BORDER); RowData rd = new RowData(); rd.width = 240; userText.setMessage("Õʺš¢Óû§Ãû»òÕßemail"); userText.setLayoutData(rd); userText.setData(RWT.CUSTOM_VARIANT, "loginInput"); userText.setFocus(); passwordText = new Text(panelTop, SWT.BORDER | SWT.PASSWORD); rd = new RowData(); rd.width = 220; passwordText.setMessage("ÊäÈëµÇ¼ÃÜÂë"); passwordText.setLayoutData(rd); passwordText.setData(RWT.CUSTOM_VARIANT, "loginInput"); okButton = new Button(panelTop, SWT.PUSH); okButton.setData(RWT.CUSTOM_VARIANT, "loginInput"); rd = new RowData(); rd.width = 50; rd.height = 50; okButton.setLayoutData(rd); page.setDefaultButton(okButton); okButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { buttonPressed(); } }); // ´´½¨±£´æÃÜÂë¹´Ñ¡¿òºÍ±£´æÓû§Ãû¹´Ñ¡¿ò Composite panelBottom = new Composite(this, SWT.NONE); layout = new RowLayout(); layout.spacing = 4; layout.marginBottom = 0; layout.marginRight = 10; layout.marginTop = 0; layout.wrap = false; layout.pack = true; panelBottom.setLayout(layout); saveIdButton = new Button(panelBottom, SWT.CHECK); saveIdButton.setText("±£´æµÇ¼ÕʺÅ"); saveIdButton.setData(RWT.CUSTOM_VARIANT, "loginCheck"); savePassButton = new Button(panelBottom, SWT.CHECK); savePassButton.setText("±£´æµÇ¼ÃÜÂë"); savePassButton.setData(RWT.CUSTOM_VARIANT, "loginCheck"); // cookie save String uid = RWT.getSettingStore().getAttribute(COOKIE_UI_USERID); if (uid != null && uid.length() > 0) { userText.setText(uid); saveIdButton.setSelection(true); } // cookie save String psd = RWT.getSettingStore().getAttribute(COOKIE_UI_PASSWORD); if (psd != null && psd.length() > 0) { passwordText.setText(psd); savePassButton.setSelection(true); } panelTop.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false)); panelBottom.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false)); createTooltips(); }
@Override public void createControl(Composite parent) { Composite main = new Composite(parent, SWT.NONE); main.setLayout(new GridLayout(4, false)); Label sourceLabel = new Label(main, SWT.NONE); sourceLabel.setText(UIText.CreateBranchPage_SourceLabel); sourceLabel.setToolTipText(UIText.CreateBranchPage_SourceTooltip); sourceIcon = new Label(main, SWT.NONE); sourceIcon.setImage(UIIcons.getImage(resourceManager, UIIcons.BRANCH)); sourceIcon.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); sourceNameLabel = new Label(main, SWT.NONE); sourceNameLabel.setLayoutData( GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create()); Button selectButton = new Button(main, SWT.NONE); selectButton.setText(UIText.CreateBranchPage_SourceSelectButton); selectButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { selectSource(); } }); UIUtils.setButtonLayoutData(selectButton); Label nameLabel = new Label(main, SWT.NONE); nameLabel.setText(UIText.CreateBranchPage_BranchNameLabel); nameLabel.setLayoutData( GridDataFactory.fillDefaults().span(1, 1).align(SWT.BEGINNING, SWT.CENTER).create()); nameLabel.setToolTipText(UIText.CreateBranchPage_BranchNameToolTip); nameText = new Text(main, SWT.BORDER); // give focus to the nameText if label is activated using the mnemonic nameLabel.addTraverseListener( new TraverseListener() { @Override public void keyTraversed(TraverseEvent e) { nameText.setFocus(); } }); nameText.addModifyListener( new ModifyListener() { @Override public void modifyText(ModifyEvent e) { nameIsSuggestion = false; } }); // enable testing with SWTBot nameText.setData("org.eclipse.swtbot.widget.key", "BranchName"); // $NON-NLS-1$ //$NON-NLS-2$ GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(nameText); upstreamConfigComponent = new UpstreamConfigComponent(main, SWT.NONE); GridDataFactory.fillDefaults() .grab(true, false) .span(4, 1) .applyTo(upstreamConfigComponent.getContainer()); upstreamConfigComponent.addUpstreamConfigSelectionListener( new UpstreamConfigSelectionListener() { @Override public void upstreamConfigSelected(UpstreamConfig newUpstreamConfig) { upstreamConfig = newUpstreamConfig; checkPage(); } }); boolean isBare = myRepository.isBare(); checkout = new Button(main, SWT.CHECK); checkout.setText(UIText.CreateBranchPage_CheckoutButton); // most of the time, we probably will check this out // unless we have a bare repository which doesn't allow // check out at all checkout.setSelection(!isBare); checkout.setEnabled(!isBare); checkout.setVisible(!isBare); GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(checkout); checkout.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { checkPage(); } }); Dialog.applyDialogFont(main); setControl(main); if (this.myBaseCommit != null) setSourceCommit(this.myBaseCommit); else if (myBaseRef != null) setSourceRef(myBaseRef); nameText.setFocus(); // add the listener just now to avoid unneeded checkPage() nameText.addModifyListener( new ModifyListener() { @Override public void modifyText(ModifyEvent e) { checkPage(); } }); }
private Composite createRootSection(final Composite parent, FormToolkit toolkit) { final Section sectionProperties = toolkit.createSection(parent, Section.TITLE_BAR | Section.EXPANDED); sectionProperties.setText(Messages.rootFolderSectionTitle); GridData layoutData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL); sectionProperties.setLayoutData(layoutData); Composite rootgroup = toolkit.createComposite(sectionProperties); rootgroup.setLayout(new GridLayout(2, false)); workflowStartCheckbox = new Button(rootgroup, SWT.CHECK); workflowStartCheckbox.setText(Messages.selectAtStart); workflowStartCheckbox.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false, 2, 1)); workflowStartCheckbox.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent arg0) { setEnabilityRoot(!workflowStartCheckbox.getSelection()); } @Override public void widgetDefaultSelected(SelectionEvent arg0) { widgetSelected(arg0); } }); workflowStartCheckbox.setData( CONTROL_PROPERTY_KEY, OutputWriterComponentConstants.CONFIG_KEY_ONWFSTART); rootText = new Text(rootgroup, SWT.BORDER); GridData gridData = new GridData(); gridData.horizontalAlignment = SWT.FILL; gridData.grabExcessHorizontalSpace = true; rootText.setLayoutData(gridData); rootText.setEditable(true); rootText.setData(CONTROL_PROPERTY_KEY, OutputWriterComponentConstants.CONFIG_KEY_ROOT); rootButton = new Button(rootgroup, SWT.NONE); rootButton.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); rootButton.setText("..."); rootButton.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent arg0) { DirectoryDialog dialog = new DirectoryDialog(parent.getShell()); dialog.setText(Messages.selectRootFolder); dialog.setMessage(Messages.selectRootFolder); String result = dialog.open(); if (result != null) { rootText.setText(result); } } @Override public void widgetDefaultSelected(SelectionEvent arg0) { widgetSelected(arg0); } }); noteComposite = new Composite(rootgroup, SWT.NONE); gridData = new GridData(); gridData.horizontalSpan = 2; noteComposite.setLayoutData(gridData); noteComposite.setLayout(new GridLayout(2, false)); Label warnLabel = new Label(noteComposite, SWT.READ_ONLY); warnLabel.setImage(ImageManager.getInstance().getSharedImage(StandardImages.WARNING_16)); Label noteLabel = new Label(noteComposite, SWT.READ_ONLY); warnLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); noteLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); noteLabel.setText(Messages.note); sectionProperties.setClient(rootgroup); sectionProperties.setVisible(true); return rootgroup; }
private Composite createMessageAndPersonArea(Composite container) { Composite messageAndPersonArea = toolkit.createComposite(container); GridDataFactory.fillDefaults().grab(true, true).applyTo(messageAndPersonArea); GridLayoutFactory.swtDefaults().margins(0, 0).spacing(0, 0).applyTo(messageAndPersonArea); Section messageSection = toolkit.createSection( messageAndPersonArea, ExpandableComposite.TITLE_BAR | ExpandableComposite.CLIENT_INDENT); messageSection.setText(UIText.CommitDialog_CommitMessage); Composite messageArea = toolkit.createComposite(messageSection); GridLayoutFactory.fillDefaults().spacing(0, 0).extendedMargins(2, 2, 2, 2).applyTo(messageArea); toolkit.paintBordersFor(messageArea); GridDataFactory.fillDefaults().grab(true, true).applyTo(messageSection); GridLayoutFactory.swtDefaults().applyTo(messageSection); Composite headerArea = new Composite(messageSection, SWT.NONE); GridLayoutFactory.fillDefaults().spacing(0, 0).numColumns(2).applyTo(headerArea); ToolBar messageToolbar = new ToolBar(headerArea, SWT.FLAT | SWT.HORIZONTAL); GridDataFactory.fillDefaults() .align(SWT.END, SWT.FILL) .grab(true, false) .applyTo(messageToolbar); addMessageDropDown(headerArea); messageSection.setTextClient(headerArea); final CommitProposalProcessor commitProposalProcessor = new CommitProposalProcessor() { @Override protected Collection<String> computeFileNameProposals() { return getFileList(); } @Override protected Collection<String> computeMessageProposals() { return CommitMessageHistory.getCommitHistory(); } }; commitText = new CommitMessageArea(messageArea, commitMessage, SWT.NONE) { @Override protected CommitProposalProcessor getCommitProposalProcessor() { return commitProposalProcessor; } }; commitText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); messageSection.setClient(messageArea); Point size = commitText.getTextWidget().getSize(); int minHeight = commitText.getTextWidget().getLineHeight() * 3; commitText.setLayoutData( GridDataFactory.fillDefaults() .grab(true, true) .hint(size) .minSize(size.x, minHeight) .align(SWT.FILL, SWT.FILL) .create()); UIUtils.addBulbDecorator(commitText.getTextWidget(), UIText.CommitDialog_ContentAssist); Composite personArea = toolkit.createComposite(messageAndPersonArea); toolkit.paintBordersFor(personArea); GridLayoutFactory.swtDefaults().numColumns(2).applyTo(personArea); GridDataFactory.fillDefaults().grab(true, false).applyTo(personArea); toolkit .createLabel(personArea, UIText.CommitDialog_Author) .setForeground(toolkit.getColors().getColor(IFormColors.TB_TOGGLE)); authorText = toolkit.createText(personArea, null); authorText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); authorText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); if (repository != null && repository.getRepositoryState().equals(RepositoryState.CHERRY_PICKING_RESOLVED)) authorText.setEnabled(false); toolkit .createLabel(personArea, UIText.CommitDialog_Committer) .setForeground(toolkit.getColors().getColor(IFormColors.TB_TOGGLE)); committerText = toolkit.createText(personArea, null); committerText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); if (committer != null) committerText.setText(committer); amendingItem = new ToolItem(messageToolbar, SWT.CHECK); amendingItem.setSelection(amending); if (amending) amendingItem.setEnabled(false); // if already set, don't allow any // changes else if (!amendAllowed) amendingItem.setEnabled(false); amendingItem.setToolTipText(UIText.CommitDialog_AmendPreviousCommit); Image amendImage = UIIcons.AMEND_COMMIT.createImage(); UIUtils.hookDisposal(amendingItem, amendImage); amendingItem.setImage(amendImage); signedOffItem = new ToolItem(messageToolbar, SWT.CHECK); signedOffItem.setToolTipText(UIText.CommitDialog_AddSOB); Image signedOffImage = UIIcons.SIGNED_OFF.createImage(); UIUtils.hookDisposal(signedOffItem, signedOffImage); signedOffItem.setImage(signedOffImage); changeIdItem = new ToolItem(messageToolbar, SWT.CHECK); Image changeIdImage = UIIcons.GERRIT.createImage(); UIUtils.hookDisposal(changeIdItem, changeIdImage); changeIdItem.setImage(changeIdImage); changeIdItem.setToolTipText(UIText.CommitDialog_AddChangeIdLabel); final ICommitMessageComponentNotifications listener = new ICommitMessageComponentNotifications() { public void updateSignedOffToggleSelection(boolean selection) { signedOffItem.setSelection(selection); } public void updateChangeIdToggleSelection(boolean selection) { changeIdItem.setSelection(selection); } public void statusUpdated() { updateMessage(); } }; commitMessageComponent = new CommitMessageComponent(repository, listener); commitMessageComponent.enableListeners(false); commitMessageComponent.setDefaults(); commitMessageComponent.attachControls(commitText, authorText, committerText); commitMessageComponent.setCommitMessage(commitMessage); commitMessageComponent.setAuthor(author); commitMessageComponent.setCommitter(committer); commitMessageComponent.setAmending(amending); commitMessageComponent.setFilesToCommit(getFileList()); amendingItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { commitMessageComponent.setAmendingButtonSelection(amendingItem.getSelection()); } }); changeIdItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { commitMessageComponent.setChangeIdButtonSelection(changeIdItem.getSelection()); } }); signedOffItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { commitMessageComponent.setSignedOffButtonSelection(signedOffItem.getSelection()); } }); commitMessageComponent.updateUI(); commitMessageComponent.enableListeners(true); return messageAndPersonArea; }
/** {@inheritDoc} */ public void createControl(Composite parent) { container = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(4, false); container.setLayout(layout); GridData gd = null; ModifyListener modifyListener = new ModifyListener() { public void modifyText(ModifyEvent e) { validate(); } }; // alias Label labelAlias = new Label(container, SWT.NULL); labelAlias.setText("Alias:"); textAlias = new Text(container, SWT.BORDER | SWT.SINGLE); textAlias.setData("GD_COMP_NAME", "U5500AuthenticationSignPackagePage_Alias_Text"); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; textAlias.setLayoutData(gd); textAlias.setText(""); textAlias.addModifyListener(modifyListener); // revision Label labelRevision = new Label(container, SWT.NULL); labelRevision.setText("Revision:"); textRevision = new Text(container, SWT.BORDER | SWT.SINGLE); textRevision.setData("GD_COMP_NAME", "U5500AuthenticationSignPackagePage_Revision_Text"); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; textRevision.setLayoutData(gd); textRevision.setText(""); textRevision.addModifyListener(modifyListener); // description Label labelDescription = new Label(container, SWT.NULL); labelDescription.setText("Description:"); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 4; textDescription = new Text(container, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); textDescription.setData("GD_COMP_NAME", "U5500AuthenticationSignPackagePage_Description_Text"); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 4; gd.heightHint = 100; textDescription.setLayoutData(gd); textDescription.setText(""); textDescription.addModifyListener(modifyListener); // auth cert Label labelAuthCert = new Label(container, SWT.NULL); labelAuthCert.setText("Authentication Certificate:"); textAuthCert = new Text(container, SWT.BORDER | SWT.SINGLE); textAuthCert.setData("GD_COMP_NAME", "U5500AuthenticationSignPackagePage_AuthCert_Text"); gd = new GridData(GridData.FILL_HORIZONTAL); // gd.horizontalSpan = 2; textAuthCert.setLayoutData(gd); textAuthCert.setText(""); textAuthCert.addModifyListener(modifyListener); buttonCreateCert = new Button(container, SWT.PUSH); buttonCreateCert.setText("Create..."); buttonCreateCert.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent pE) { String cert = U5500AuthenticationCertificateWizard.openWizard(); if (cert != null && !cert.trim().equals("")) { textAuthCert.setText(cert); } } }); buttonBrowseCert = new Button(container, SWT.PUSH); buttonBrowseCert.setData("GD_COMP_NAME", "U5500AuthenticationSignPackagePage_AuthCert_Button"); buttonBrowseCert.setText("Browse..."); buttonBrowseCert.addListener( SWT.Selection, new Listener() { public void handleEvent(Event event) { String cert = selectAuthCert(); if (cert != null && !cert.trim().equals("")) { textAuthCert.setText(cert); } } }); // output file Label labelOutputFile = new Label(container, SWT.NULL); labelOutputFile.setText("Output File:"); textOutputFile = new Text(container, SWT.BORDER | SWT.SINGLE); textOutputFile.setData("GD_COMP_NAME", "U5500AuthenticationSignPackagePage_OutputFile_Text"); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; textOutputFile.setLayoutData(gd); textOutputFile.setText(""); textOutputFile.addModifyListener(modifyListener); buttonOutputFile = new Button(container, SWT.PUSH); buttonOutputFile.setData( "GD_COMP_NAME", "U5500AuthenticationSignPackagePage_OutputFile_Button"); buttonOutputFile.setText("Browse..."); buttonOutputFile.addListener( SWT.Selection, new Listener() { public void handleEvent(Event event) { String outputFile = selectOutputFile(); if (outputFile != null && !outputFile.trim().equals("")) { textOutputFile.setText(outputFile); } } }); setControl(container); validate(); }
private void loadPhotos() { if (selectedPhotosFilesList == null) { selectedPhotosFilesList = new ArrayList<String>(); } else { selectedPhotosFilesList.clear(); } if (thumbnailWidgetList == null) { thumbnailWidgetList = new ArrayList<ThumbnailWidget>(); } else { thumbnailWidgetList.clear(); } ImagesGridView imagesGridView = (ImagesGridView) Activator.getView( PlatformUI.getWorkbench().getActiveWorkbenchWindow(), ImagesGridView.ID); Composite thumbnailGridComposite = imagesGridView.getThumbnailGridComposite(); for (Control control : thumbnailGridComposite.getChildren()) { control.dispose(); } int gridWidth = thumbnailGridComposite.getBounds().width; int numberOfColumns = gridWidth / 200 - 1; GridLayout thumbnailGridCompositeGL = new GridLayout(numberOfColumns, true); thumbnailGridComposite.setLayout(thumbnailGridCompositeGL); GridData thumbnailGridCompositeGD = new GridData(GridData.FILL_BOTH); thumbnailGridCompositeGD.horizontalSpan = 2; thumbnailGridComposite.setLayoutData(thumbnailGridCompositeGD); if (loadedPhotosList != null && loadedPhotosList.size() > 0) { // begin add photo composite, check and text fields for (ListIterator<String> selectedPhotosIterator = loadedPhotosList.listIterator(); selectedPhotosIterator.hasNext(); ) { String selectedPhotoFilePath = selectedPhotosIterator.next(); // check if the file has a valid imagesList final Image thumbnail; try { thumbnail = new Image(Display.getDefault(), selectedPhotoFilePath); } catch (SWTException ex) { selectedPhotosIterator.remove(); continue; } Composite imageParentComposite = new Composite(thumbnailGridComposite, SWT.BORDER); GridLayout imageParentCompositeGridLayout = new GridLayout(2, false); imageParentComposite.setLayout(imageParentCompositeGridLayout); GridData imageParentCompositeGridData = new GridData(); imageParentCompositeGridData.grabExcessHorizontalSpace = true; imageParentComposite.setLayoutData(imageParentCompositeGridData); final Composite imageComposite = new Composite(imageParentComposite, SWT.BORDER); GridData imageCompositeGridData = new GridData(175, 200); imageCompositeGridData.horizontalSpan = 2; imageComposite.setLayoutData(imageCompositeGridData); imageComposite.addMouseListener( new MouseListener() { @Override public void mouseUp(MouseEvent e) {} @Override public void mouseDown(MouseEvent e) {} @Override public void mouseDoubleClick(MouseEvent e) { String selectedPhotosFile = ((ThumbnailWidget) imageComposite.getData()).getSelectedPhotoFilePath(); Dialog dialog = new OriginalSizeImageDialog( Display.getDefault().getActiveShell(), new Image[] {new Image(Display.getDefault(), selectedPhotosFile)}); dialog.open(); } }); ResizeImageListener comp1Listener = new ResizeImageListener(thumbnail, imageComposite, true); imageComposite.addListener(SWT.Dispose, comp1Listener); imageComposite.addListener(SWT.Paint, comp1Listener); final Button checkBox = new Button(imageParentComposite, SWT.CHECK); Text imageDescriptionText = new Text(imageParentComposite, SWT.BORDER); GridData imageDescriptionTextGridData = new GridData(GridData.FILL_HORIZONTAL); imageDescriptionTextGridData.grabExcessHorizontalSpace = true; imageDescriptionText.setLayoutData(imageDescriptionTextGridData); ThumbnailWidget thumbnailWidget = new ThumbnailWidget(); thumbnailWidget.setImageParentComposite(imageParentComposite); thumbnailWidget.setImageComposite(imageComposite); thumbnailWidget.setImageDescriptionText(imageDescriptionText); thumbnailWidget.setImage(thumbnail); thumbnailWidget.setCheckBox(checkBox); thumbnailWidget.setSelectedPhotoFilePath(selectedPhotoFilePath); checkBox.setData(thumbnailWidget); imageDescriptionText.setData(thumbnailWidget); imageComposite.setData(thumbnailWidget); thumbnailWidgetList.add(thumbnailWidget); checkBox.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { String selectedPhotosFile = ((ThumbnailWidget) checkBox.getData()).getSelectedPhotoFilePath(); if (checkBox.getSelection()) { selectedPhotosFilesList.add(selectedPhotosFile); } else { selectedPhotosFilesList.remove(selectedPhotosFile); } } @Override public void widgetDefaultSelected(SelectionEvent e) {} }); } // end add photo composite, check and text fields ScrolledComposite thumbnailGridScrolledComposite = imagesGridView.getViewerScrolledComposite(); Point size = thumbnailGridComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT); thumbnailGridScrolledComposite.setMinSize(size); thumbnailGridScrolledComposite.setContent(thumbnailGridComposite); thumbnailGridScrolledComposite.layout(true); } // show image grid view try { PlatformUI.getWorkbench() .getActiveWorkbenchWindow() .getActivePage() .showView(ImagesGridView.ID); } catch (PartInitException e1) { e1.printStackTrace(); } }