Java Code Examples for org.eclipse.swt.SWT
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project acceleo-modules, under directory /psm-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.psm.gen.scala.editor/src-gen/com/github/sbegaudeau/acceleo/modules/psm/gen/scala/model/scala/presentation/.
Source file: ScalaEditor.java

/** * If there is more than one page in the multi-page editor part, this shows the tabs at the bottom. <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ protected void showTabs(){ if (getPageCount() > 1) { setPageText(0,getString("_UI_SelectionPage_label")); if (getContainer() instanceof CTabFolder) { ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT); Point point=getContainer().getSize(); getContainer().setSize(point.x,point.y - 6); } } }
Example 2
From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial.webapp.editor/src-gen/org/eclipse/acceleo/tutorial/webapp/presentation/.
Source file: WebappEditor.java

/** * If there is more than one page in the multi-page editor part, this shows the tabs at the bottom. <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ protected void showTabs(){ if (getPageCount() > 1) { setPageText(0,getString("_UI_SelectionPage_label")); if (getContainer() instanceof CTabFolder) { ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT); Point point=getContainer().getSize(); getContainer().setSize(point.x,point.y - 6); } } }
Example 3
From project acceleo-webapp-generator, under directory /plugins/org.obeonetwork.pim.gen.backbone.model.editor/src-gen/org/obeonetwork/pim/gen/backbone/model/backbone/presentation/.
Source file: BackboneEditor.java

/** * If there is more than one page in the multi-page editor part, this shows the tabs at the bottom. <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ protected void showTabs(){ if (getPageCount() > 1) { setPageText(0,getString("_UI_SelectionPage_label")); if (getContainer() instanceof CTabFolder) { ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT); Point point=getContainer().getSize(); getContainer().setSize(point.x,point.y - 6); } } }
Example 4
From project acceleo-webapp-generator, under directory /plugins/org.obeonetwork.pim.gen.bootstrap.model.editor/src-gen/org/obeonetwork/pim/gen/bootstrap/model/bootstrap/presentation/.
Source file: BootstrapEditor.java

/** * If there is more than one page in the multi-page editor part, this shows the tabs at the bottom. <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ protected void showTabs(){ if (getPageCount() > 1) { setPageText(0,getString("_UI_SelectionPage_label")); if (getContainer() instanceof CTabFolder) { ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT); Point point=getContainer().getSize(); getContainer().setSize(point.x,point.y - 6); } } }
Example 5
From project adt-cdt, under directory /com.android.ide.eclipse.adt.cdt/src/com/android/ide/eclipse/adt/cdt/internal/preferences/.
Source file: NDKPreferencePage.java

/** * Create contents of the preference page. * @param parent */ @Override public Control createContents(Composite parent){ Composite container=new Composite(parent,SWT.NULL); container.setLayout(new GridLayout(1,false)); Group grpNdkLocation=new Group(container,SWT.NONE); grpNdkLocation.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,false,1,1)); grpNdkLocation.setText("NDK Location"); grpNdkLocation.setLayout(new GridLayout(2,false)); text=new Text(grpNdkLocation,SWT.BORDER); text.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,false,1,1)); String ndkLoc=NDKManager.getNDKLocation(); if (ndkLoc != null) text.setText(ndkLoc); Button button=new Button(grpNdkLocation,SWT.NONE); button.addSelectionListener(new SelectionAdapter(){ @Override public void widgetSelected( SelectionEvent e){ String dir=new DirectoryDialog(NDKPreferencePage.this.getShell()).open(); if (dir != null) text.setText(dir); } } ); button.setText("Browse..."); return container; }
Example 6
From project Archimedes, under directory /br.org.archimedes.core/src/br/org/archimedes/gui/actions/.
Source file: LoadCommand.java

/** * Creates the error message box that will be show when the file cannot be loaded * @return The created message box */ protected MessageBox createErrorMessageBox(){ MessageBox error=new MessageBox(parent,SWT.OK | SWT.ICON_ERROR); error.setMessage(Messages.Load_InvalidFileTitle); error.setText(Messages.Load_InvalidFileText); return error; }
Example 7
From project Archimedes, under directory /br.org.archimedes.core/src/br/org/archimedes/gui/actions/.
Source file: LoadCommand.java

/** * @return A dialog for the user to choose a file to open */ public FileDialog createFileDialog(){ FileDialog dialog=new FileDialog(parent,SWT.OPEN); List<String> filters=new LinkedList<String>(); for ( String extension : nativeLoader.getExtensionsArray()) { String filter="*." + extension; filters.add(filter); } String[] filtersArray=filters.toArray(new String[0]); dialog.setFilterExtensions(filtersArray); dialog.setText(Messages.Load_OpenDialog); return dialog; }
Example 8
From project Archimedes, under directory /br.org.archimedes.core/src/br/org/archimedes/gui/actions/.
Source file: SaveCommand.java

/** * Shows the save dialog until the user cancels it or the file is valid. * @return true if it finished successfully, false if it was canceled. */ protected File showDialog(){ File file=null; File chosenFile; FileDialog saveDialog=new FileDialog(shell,SWT.SAVE); saveDialog.setText(Messages.SaveAs_Title); String[] extensions=nativeLoader.getExtensionsArray(); saveDialog.setFilterExtensions(extensions); Workspace workspace=br.org.archimedes.Utils.getWorkspace(); String lastDirectory=workspace.getLastUsedDirectory().getAbsolutePath(); MessageBox errorDialog=new MessageBox(shell,SWT.OK | SWT.ICON_ERROR); errorDialog.setText(Messages.Save_ErrorTitle); errorDialog.setMessage(Messages.Save_ErrorText); boolean finished=false; while (!finished) { saveDialog.setFilterPath(lastDirectory); String rawFilePath=saveDialog.open(); String extension=getExtension(saveDialog.getFilterExtensions(),saveDialog.getFilterIndex()); String filePath=addExtensionIfNeeded(rawFilePath,extension); if (filePath != null) { chosenFile=new File(filePath); lastDirectory=chosenFile.getParent(); if ((!chosenFile.exists() && chosenFile.getParentFile().canWrite()) || (chosenFile.canWrite() && showOverwriteDialog() == SWT.YES)) { file=chosenFile; workspace.setLastUsedDirectory(chosenFile.getParentFile()); finished=true; } else { errorDialog.setMessage(buildLogMessage(chosenFile)); errorDialog.open(); } } else { finished=true; } } return file; }
Example 9
From project Archimedes, under directory /br.org.archimedes.core/src/br/org/archimedes/gui/actions/.
Source file: SaveCommand.java

/** * @param chosenFile The file chosen that caused the error * @return The log message to be shown */ private String buildLogMessage(File chosenFile){ String log=Messages.SaveCommand_ErrorLogEntry + LINE_BREAK; if (chosenFile.exists()) { log+=Messages.SaveCommand_FileExists + LINE_BREAK; if (chosenFile.canWrite()) { log+=Messages.SaveCommand_ParentWritable + LINE_BREAK; } } else { log+=Messages.SaveCommand_FileNotExist + LINE_BREAK; } if (chosenFile.getParentFile().canWrite()) { log+=Messages.SaveCommand_ParentWritable + LINE_BREAK; } else { log+=Messages.SaveCommand_ParentNotWritable + LINE_BREAK; } if (showOverwriteDialog() == SWT.YES) { log+=Messages.SaveCommand_Overwrite + LINE_BREAK; } return log; }
Example 10
From project Archimedes, under directory /br.org.archimedes.core/src/br/org/archimedes/gui/actions/.
Source file: SaveCommand.java

/** * Shows an overwrite dialog box * @return the user option */ private int showOverwriteDialog(){ if (System.getProperty("os.name").contains("Mac")) { return SWT.YES; } MessageBox dialogBox=new MessageBox(shell,SWT.YES | SWT.NO | SWT.ICON_QUESTION); dialogBox.setMessage(Messages.OverwriteQuestion); dialogBox.setText(Messages.OverwriteTitle); return dialogBox.open(); }
Example 11
From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/ui/.
Source file: AccountSelectionComposite.java

protected void createNoAccountLabel(){ noAccounts=new Label(this,SWT.None); noAccounts.setText("No AWS accounts have been configured yet."); GridData gd=new GridData(); gd.horizontalSpan=2; noAccounts.setLayoutData(gd); }
Example 12
From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/ui/.
Source file: AccountSelectionComposite.java

protected void createAccountConfigurationLink(){ Link link=new Link(this,SWT.NONE); link.setFont(this.getFont()); link.setText("<A>" + "Configure AWS accounts..." + "</A>"); link.addSelectionListener(new SelectionListener(){ public void widgetSelected( final SelectionEvent e){ PreferencesUtil.createPreferenceDialogOn(Display.getDefault().getActiveShell(),AwsAccountPreferencePage.ID,new String[]{AwsAccountPreferencePage.ID},null).open(); if (noAccounts != null && validAccountsConfigured()) { for ( Widget w : getChildren()) { w.dispose(); } noAccounts=null; createChildWidgets(); getShell().layout(true,true); } updateAccounts(); } public void widgetDefaultSelected( final SelectionEvent e){ widgetSelected(e); } } ); link.setLayoutData(new GridData(SWT.END,SWT.CENTER,false,false)); link.setEnabled(true); }
Example 13
From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/ui/.
Source file: AccountSelectionComposite.java

protected void createAccountSelectionCombo(){ Label selectAccount=new Label(this,SWT.None); selectAccount.setText("Select Account:"); this.accountSelection=new Combo(this,SWT.DROP_DOWN | SWT.READ_ONLY); accountSelection.addSelectionListener(new SelectionAdapter(){ @Override public void widgetSelected( SelectionEvent e){ for ( SelectionListener listener : listeners) { listener.widgetSelected(e); } } } ); }
Example 14
From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/ui/overview/.
Source file: FormsOverviewComposite.java

/** * Constructs a new AWS Toolkit for Eclipse overview composite, allocating all shared resources. This class is not intended to be have more than one instance instantiated at a time. * @param parent The parent composite in which to create the new overview page. */ public FormsOverviewComposite(Composite parent){ super(parent,SWT.NONE); setLayout(new FillLayout()); resources=new OverviewResources(); form=resources.getFormToolkit().createScrolledForm(this); TableWrapLayout tableWrapLayout=LayoutUtils.newSlimTableWrapLayout(1); tableWrapLayout.verticalSpacing=10; tableWrapLayout.horizontalSpacing=15; form.getBody().setLayout(tableWrapLayout); Composite headerComposite=new HeaderComposite(form.getBody(),resources); TableWrapData tableWrapData=new TableWrapData(TableWrapData.FILL_GRAB); headerComposite.setLayoutData(tableWrapData); Composite column=resources.getFormToolkit().createComposite(form.getBody()); TableWrapLayout leftHandColumnLayout=new TableWrapLayout(); leftHandColumnLayout.verticalSpacing=20; column.setLayout(leftHandColumnLayout); TableWrapData tableWrapData2=new TableWrapData(TableWrapData.FILL_GRAB); column.setLayoutData(tableWrapData2); createContributedOverviewSections(column); createResourcesSection(column).setLayoutData(new TableWrapData(TableWrapData.FILL)); }
Example 15
From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/ui/overview/.
Source file: FormsOverviewComposite.java

/** * Creates the Resources section, with links to general, external resources, in the specified parent composite. * @param parent The parent composite in which to create the new UI widgets. * @return The new composite containing the Resources section of theoverview page. */ private Composite createResourcesSection(Composite parent){ Toolkit overviewToolkit=new Toolkit(); overviewToolkit.setResources(resources); Section section=resources.getFormToolkit().createSection(parent,Section.CLIENT_INDENT | Section.TITLE_BAR | Section.TWISTIE| Section.EXPANDED); section.setText("Additional Resources"); section.setLayout(new FillLayout()); TableWrapData tableWrapData=new TableWrapData(TableWrapData.FILL,TableWrapData.FILL); tableWrapData.grabHorizontal=true; tableWrapData.grabVertical=true; section.setLayoutData(tableWrapData); Composite composite=new Composite(section,SWT.NONE); composite.setLayout(new TableWrapLayout()); section.setClient(composite); section.setFont(resources.getFont("module-header")); section.setForeground(resources.getColor("module-header")); section.setTitleBarForeground(resources.getColor("module-header")); composite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); overviewToolkit.newListItem(composite,"AWS Toolkit for Eclipse Homepage",AwsUrls.AWS_TOOLKIT_FOR_ECLIPSE_HOMEPAGE_URL,null); overviewToolkit.newListItem(composite,"AWS Java Development Forum",AwsUrls.JAVA_DEVELOPMENT_FORUM_URL,null); overviewToolkit.newListItem(composite,"Frequently Asked Questions",AwsUrls.AWS_TOOLKIT_FOR_ECLIPSE_FAQ_URL,null); overviewToolkit.newListItem(composite,"AWS Toolkit for Eclipse Source Code",AwsUrls.AWS_TOOLKIT_FOR_ECLIPSE_GITHUB_URL,null); overviewToolkit.newListItem(composite,"AWS Management Console",AwsUrls.AWS_MANAGEMENT_CONSOLE_URL,null); return composite; }