org.eclipse.swt.widgets.Shell Java Examples

The following examples show how to use org.eclipse.swt.widgets.Shell. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClasspathModifierQueries.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Shows the UI to choose new classpath container classpath entries. See {@link IClasspathEntry#CPE_CONTAINER} for
 * details about container classpath entries.
 * The query returns the selected classpath entries or an empty array if the query has
 * been cancelled.
 *
 * @param shell The parent shell for the dialog, can be <code>null</code>
 * @return Returns the selected classpath container entries or an empty array if the query has
 * been cancelled by the user.
 */
public static IAddLibrariesQuery getDefaultLibrariesQuery(final Shell shell) {
    return new IAddLibrariesQuery() {

        public IClasspathEntry[] doQuery(final IJavaProject project, final IClasspathEntry[] entries) {
            final IClasspathEntry[][] selected= {null};
            Display.getDefault().syncExec(new Runnable() {
                public void run() {
                    Shell sh= shell != null ? shell : JavaPlugin.getActiveWorkbenchShell();
                    selected[0]= BuildPathDialogAccess.chooseContainerEntries(sh, project, entries);
                }
            });
            if(selected[0] == null)
                return new IClasspathEntry[0];
            return selected[0];
        }
    };
}
 
Example #2
Source File: HyperlinkBuilder.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public HyperlinkBuilder( Shell parentShell, boolean isIDE,
		boolean isRelativeToProjectRoot )
{
	super( parentShell, TITLE );
	this.isIDE = isIDE;
	this.isRelativeToProjectRoot = isRelativeToProjectRoot;

	// *********** try using a helper provider ****************
	IProjectFileServiceHelperProvider helperProvider = (IProjectFileServiceHelperProvider) ElementAdapterManager.getAdapter( this,
			IProjectFileServiceHelperProvider.class );

	if ( helperProvider != null )
	{
		projectFileServiceHelper = helperProvider.createHelper( );
	}
	else
	{
		projectFileServiceHelper = new DefaultProjectFileServiceHelper( );
	}
}
 
Example #3
Source File: RestoreDatabaseDialog.java    From Rel with Apache License 2.0 6 votes vote down vote up
/**
 * Create the dialog.
 * @param parent
 * @param style
 */
public RestoreDatabaseDialog(Shell parent) {
	super(parent, SWT.DIALOG_TRIM | SWT.RESIZE);
	setText("Create and Restore Database");
	
	newDatabaseDialog = new DirectoryDialog(parent);
	newDatabaseDialog.setText("Create Database");
	newDatabaseDialog.setMessage("Select a folder to hold a new database.");
	newDatabaseDialog.setFilterPath(System.getProperty("user.home"));

	restoreFileDialog = new FileDialog(Core.getShell(), SWT.OPEN);
	restoreFileDialog.setFilterPath(System.getProperty("user.home"));
	restoreFileDialog.setFilterExtensions(new String[] {"*.rel", "*.*"});
	restoreFileDialog.setFilterNames(new String[] {"Rel script", "All Files"});
	restoreFileDialog.setText("Load Backup");
}
 
Example #4
Source File: DialogClassificationConfiguration.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance
 * @param parent
 * @param config
 */
public DialogClassificationConfiguration(Shell parent,
                                         ARXClassificationConfiguration<?> config) {

    this.dialog = new PreferencesDialog(parent,
                                        Resources.getMessage("DialogClassificationConfiguration.0"), //$NON-NLS-1$
                                        Resources.getMessage("DialogClassificationConfiguration.1")); //$NON-NLS-1$
    
    this.config = config;

    if (config instanceof ClassificationConfigurationLogisticRegression) {
        createContentForLogisticRegression((ClassificationConfigurationLogisticRegression) config);
    } else if (config instanceof ClassificationConfigurationNaiveBayes) {
        createContentForNaiveBayes((ClassificationConfigurationNaiveBayes) config);
    } else if (config instanceof ClassificationConfigurationRandomForest) {
        createContentForRandomForest((ClassificationConfigurationRandomForest) config);
    } else {
        throw new IllegalArgumentException("Unknown classification configuration");
    }
}
 
Example #5
Source File: AddGetterSetterAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private int showQueryDialog(final String message, final String[] buttonLabels, int[] returnCodes) {
	final Shell shell= getShell();
	if (shell == null) {
		JavaPlugin.logErrorMessage("AddGetterSetterAction.showQueryDialog: No active shell found"); //$NON-NLS-1$
		return IRequestQuery.CANCEL;
	}
	final int[] result= { Window.CANCEL};
	shell.getDisplay().syncExec(new Runnable() {

		public void run() {
			String title= ActionMessages.AddGetterSetterAction_QueryDialog_title;
			MessageDialog dialog= new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, buttonLabels, 0);
			result[0]= dialog.open();
		}
	});
	int returnVal= result[0];
	return returnVal < 0 ? IRequestQuery.CANCEL : returnCodes[returnVal];
}
 
Example #6
Source File: BonitaContentProposalAdapter.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
void installListeners() {
    // Listeners on this popup's table and scroll bar
    proposalTable.addListener(SWT.FocusOut, this);
    final ScrollBar scrollbar = proposalTable.getVerticalBar();
    if (scrollbar != null) {
        scrollbar.addListener(SWT.Selection, this);
    }

    // Listeners on this popup's shell
    getShell().addListener(SWT.Deactivate, this);
    getShell().addListener(SWT.Close, this);

    // Listeners on the target control
    control.addListener(SWT.MouseDoubleClick, this);
    control.addListener(SWT.MouseDown, this);
    control.addListener(SWT.Dispose, this);
    control.addListener(SWT.FocusOut, this);
    // Listeners on the target control's shell
    final Shell controlShell = control.getShell();
    controlShell.addListener(SWT.Move, this);
    controlShell.addListener(SWT.Resize, this);

}
 
Example #7
Source File: ElexisEnvironmentLoginDialog.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public ElexisEnvironmentLoginDialog(Shell shell, String openidClientSecret, String keycloakUrl,
	String realmPublicKey){
	super(shell);
	
	logger = LoggerFactory.getLogger(getClass());
	
	oauthService = new ServiceBuilder(ElexisEnvironmentLoginContributor.OAUTH2_CLIENT_ID)
		.apiSecret(openidClientSecret).defaultScope("openid").callback(CALLBACK_URL)
		.build(KeycloakApi.instance(keycloakUrl, ElexisEnvironmentLoginContributor.REALM_ID));
	
	KeyFactory kf;
	try {
		kf = KeyFactory.getInstance("RSA");
		X509EncodedKeySpec keySpecX509 =
			new X509EncodedKeySpec(Base64.getDecoder().decode(realmPublicKey));
		RSAPublicKey publicKey = (RSAPublicKey) kf.generatePublic(keySpecX509);
		
		jwtParser = Jwts.parserBuilder().setSigningKey(publicKey).build();
	} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
		logger.error("Initialization error", e);
	}
	
}
 
Example #8
Source File: InformationPresenterHelpers.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public IInformationControl createInformationControl(Shell parent) {

    //            try { -- this would show the 'F2' for focus, but we don't actually handle that, so, don't use it.
    //                tooltipAffordanceString = EditorsUI.getTooltipAffordanceString();
    //            } catch (Throwable e) {
    //                //Not available on Eclipse 3.2
    //            }

    //Note: don't use the parent because when it's closed we don't want the parent to have focus (we want the original
    //widget that had focus to regain the focus).
    //            if (parent == null) {
    //                parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    //            }

    String tooltipAffordanceString = null;
    if (this.informationPresenterControlManager != null) {
        InformationPresenterControlManager m = this.informationPresenterControlManager.get();
        if (m != null) {
            tooltipAffordanceString = m.getTooltipAffordanceString();
        }
    }
    PyInformationControl tooltip = new PyInformationControl(null, tooltipAffordanceString, presenter);
    return tooltip;
}
 
Example #9
Source File: LEDSnippet.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @param args
 */
public static void main(final String[] args) {
	final Display display = new Display();
	shell = new Shell(display);
	shell.setText("LED Snippet");
	shell.setLayout(new GridLayout(1, true));
	shell.setBackground(display.getSystemColor(SWT.COLOR_WHITE));

	createTopPart();
	createBottomPart();

	shell.pack();
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}

	display.dispose();

}
 
Example #10
Source File: DerbyServerUtils.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void startDerbyServer( IProject proj) throws CoreException {
	String args = CommonNames.START_DERBY_SERVER;
	String vmargs="";
	DerbyProperties dprop=new DerbyProperties(proj);
	//Starts the server as a Java app
	args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort();
	
	//Set Derby System Home from the Derby Properties
	if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
		vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
	}
	String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.START_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")";
	ILaunch launch = DerbyUtils.launch(proj, procName ,		
	CommonNames.DERBY_SERVER_CLASS, args, vmargs, CommonNames.START_DERBY_SERVER);
	IProcess ip=launch.getProcesses()[0];
	//set a name to be seen in the Console list
	ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
	
	// saves the mapping between (server) process and project
	//servers.put(launch.getProcesses()[0], proj);
	servers.put(ip, proj);
	// register a listener to listen, when this process is finished
	DebugPlugin.getDefault().addDebugEventListener(listener);
	//Add resource listener
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	
	workspace.addResourceChangeListener(rlistener);
	setRunning(proj, Boolean.TRUE);
	Shell shell = new Shell();
	MessageDialog.openInformation(
		shell,
		CommonNames.PLUGIN_NAME,
		Messages.D_NS_ATTEMPT_STARTED+dprop.getPort()+".");

}
 
Example #11
Source File: InspectAccountDialog.java    From offspring with MIT License 5 votes vote down vote up
/**
 * Static method that opens a new dialog or switches the existing dialog to
 * another account id. The dialog shows back and forward buttons to navigate
 * between accounts inspected.
 * 
 * @param accountId
 * @return
 */
public static void show(final Long accountId, final INxtService nxt,
    final IStylingEngine engine, final IUserService userService,
    final UISynchronize sync, final IContactsService contactsService) {

  sync.syncExec(new Runnable() {

    @Override
    public void run() {
      Shell shell = Display.getCurrent().getActiveShell();
      if (shell != null) {
        while (shell.getParent() != null) {
          shell = shell.getParent().getShell();
        }
      }
      if (INSTANCE == null) {
        INSTANCE = new InspectAccountDialog(shell, accountId, nxt, engine,
            userService, sync, contactsService);
        INSTANCE.history.add(accountId);
        INSTANCE.historyCursor = 0;
        INSTANCE.open();
      }
      else {
        INSTANCE.history.add(accountId);
        INSTANCE.historyCursor = INSTANCE.history.size() - 1;
        INSTANCE.setAccountId(accountId);
        INSTANCE.getShell().forceActive();
      }
    }
  });

}
 
Example #12
Source File: WorkbenchUtils.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static Shell getActivePartShell() {
      IWorkbenchPage activePage = WorkbenchUtils.getActivePage();
      if (activePage == null) {
      	return null;
      }
IWorkbenchPart activePart = activePage.getActivePart();
if (activePart == null) {
      	return null;
      }
IWorkbenchPartSite site = activePart.getSite();
if (site == null) {
      	return null;
      }
return site.getShell();
  }
 
Example #13
Source File: SWTUtil.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Centers the shell on the given monitor.
 *
 * @param shell
 * @param monitor
 */
public static void center(Shell shell, Monitor monitor) {
    Rectangle shellRect = shell.getBounds();
    Rectangle displayRect = monitor.getBounds();
    int x = (displayRect.width - shellRect.width) / 2;
    int y = (displayRect.height - shellRect.height) / 2;
    shell.setLocation(displayRect.x + x, displayRect.y + y);
}
 
Example #14
Source File: JobEntryDeleteFilesDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public JobEntryDeleteFilesDialog( Shell parent, JobEntryInterface jobEntryInt, Repository rep, JobMeta jobMeta ) {
  super( parent, jobEntryInt, rep, jobMeta );
  jobEntry = (JobEntryDeleteFiles) jobEntryInt;

  if ( this.jobEntry.getName() == null ) {
    this.jobEntry.setName( BaseMessages.getString( PKG, "JobDeleteFiles.Name.Default" ) );
  }
}
 
Example #15
Source File: ImportsAwareClipboardAction.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private Display getDisplay() {
	Shell shell = getShell();
	if (shell != null) {
		return shell.getDisplay();
	}
	return null;
}
 
Example #16
Source File: PipelineDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
public PipelineDialog( Shell parent, int style, PipelineMeta pipelineMeta ) {
  super( parent, style );
  this.props = PropsUi.getInstance();
  this.pipelineMeta = pipelineMeta;

  changed = false;
}
 
Example #17
Source File: DialogUtils.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public TwoChoiceDialog(Shell parentShell, String dialogTitle,
        Image dialogTitleImage, String dialogMessage,
        int dialogImageType, String[] dialogButtonLabels,
        int defaultIndex) {
    super(parentShell, dialogTitle, dialogTitleImage, dialogMessage,
            dialogImageType, dialogButtonLabels, defaultIndex);
    int style = SWT.NONE;
    style &= SWT.SHEET;
    setShellStyle(getShellStyle() | style);
}
 
Example #18
Source File: DumbUser.java    From http4e with Apache License 2.0 5 votes vote down vote up
/**
 * DumbMessageDialog constructor
 * 
 * @param parent the parent shell
 */
public DumbMessageDialog(Shell parent) {
  super(parent);

  // Create the image
  try {
    image = new Image(parent.getDisplay(), new FileInputStream(CoreImages.LOGO_DIALOG));
  } catch (FileNotFoundException e) {}

  // Set the default message
  message = "Are you sure you want to do something that dumb?";
}
 
Example #19
Source File: TSWizardDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
protected void configureShell(Shell newShell) {
	super.configureShell(newShell);
	// Register help listener on the shell
	newShell.addHelpListener(new HelpListener() {
		public void helpRequested(HelpEvent event) {
			// call perform help on the current page
			if (currentPage != null) {
				currentPage.performHelp();
			}
		}
	});
}
 
Example #20
Source File: AddResourcesToClientBundleDialog.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public AddResourcesToClientBundleDialog(Shell parent, IProject project,
    IType clientBundleType, IFile[] files) {
  super(parent);
  this.project = project;
  this.clientBundleType = clientBundleType;
  this.files = files;
  this.bundledResourcesBlock = new BundledResourcesSelectionBlock(
      "Bundled resources:", fieldAdapter);

  setTitle("Add Resources to ClientBundle");
  setHelpAvailable(false);
  setShellStyle(getShellStyle() | SWT.RESIZE);
}
 
Example #21
Source File: UIUtils.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Shows an error dialog that gives information on the given {@link Throwable}.
 *
 * This static method may be invoked at any point during startup as it does not rely on activators to be loaded.
 */
public static void showError(Throwable t) {
	int dialogW = 400;
	int dialogH = 300;

	Display display = new Display();
	Shell shell = new Shell(display);
	Rectangle bounds = display.getPrimaryMonitor().getBounds();
	shell.setLocation(bounds.width / 2 - dialogW / 2, bounds.height / 2 - dialogH / 2);
	shell.setText("Fatal Error with Dependency Injection.");
	shell.setSize(dialogW, dialogH);
	shell.setLayout(new FillLayout());

	Text text = new Text(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
	StringWriter sw = new StringWriter();
	PrintWriter pw = new PrintWriter(sw);
	t.printStackTrace(pw);
	String sStackTrace = sw.toString();
	text.setText(sStackTrace);

	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	display.dispose();
}
 
Example #22
Source File: HostPagePathSelectionDialog.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private HostPagePathSelectionDialog(Shell parent, IProject project) {
  super(parent, new HostPagePathLabelProvider(),
      new HostPagePathContentProvider());

  setTitle("Existing Folder Selection");
  setMessage("Choose a location for the HTML page");

  rootTreeItems = HostPagePathTreeItem.createRootItems(project);
  setInput(rootTreeItems);
  setComparator(new ViewerComparator());
}
 
Example #23
Source File: ActionPGPDecryptFilesDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
public ActionPGPDecryptFilesDialog( Shell parent, IAction action,
                                    WorkflowMeta workflowMeta ) {
  super( parent, action, workflowMeta );
  this.action = (ActionPGPDecryptFiles) action;

  if ( this.action.getName() == null ) {
    this.action.setName( BaseMessages.getString( PKG, "ActionPGPDecryptFiles.Name.Default" ) );
  }
}
 
Example #24
Source File: DialogOpenHierarchy.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * 
 *
 * @param parent
 * @param controller
 * @param file
 * @param data
 */
public DialogOpenHierarchy(final Shell parent,
                       final Controller controller,
                       final String file,
                       boolean data) {
    super(parent);
    this.file = file;
    this.data = data;
}
 
Example #25
Source File: CreateXMPPAccountWizardPage.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void performHelp() {
  Shell shell = new Shell(getShell());
  shell.setText("Saros XMPP Accounts");
  shell.setLayout(new GridLayout());
  shell.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

  Browser browser = new Browser(shell, SWT.NONE);
  browser.setUrl("https://www.saros-project.org/documentation/setup-xmpp.html");
  browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

  shell.open();
}
 
Example #26
Source File: OptionSettingDialog.java    From erflute with Apache License 2.0 5 votes vote down vote up
public OptionSettingDialog(Shell parentShell, DiagramSettings settings, ERDiagram diagram) {
    super(parentShell);

    this.diagram = diagram;
    this.settings = settings;
    this.tabWrapperList = new ArrayList<>();
}
 
Example #27
Source File: ActionSuccessDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
public ActionSuccessDialog( Shell parent, IAction action, WorkflowMeta workflowMeta ) {
  super( parent, action, workflowMeta );
  this.action = (ActionSuccess) action;
  if ( this.action.getName() == null ) {
    this.action.setName( BaseMessages.getString( PKG, "ActionSuccessDialog.Name.Default" ) );
  }
}
 
Example #28
Source File: ManageConnectorJarDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void configureShell(Shell newShell) {
	super.configureShell(newShell);
	if(title == null){
		newShell.setText(Messages.selectMissingJarTitle) ;
	}else{
		newShell.setText(title) ;
	}
}
 
Example #29
Source File: StepPerformanceSnapShotDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public StepPerformanceSnapShotDialog( Shell parent, String title,
  Map<String, List<StepPerformanceSnapShot>> stepPerformanceSnapShots, long timeDifference ) {
  super( parent );
  this.parent = parent;
  this.display = parent.getDisplay();
  this.props = PropsUI.getInstance();
  this.timeDifference = timeDifference;
  this.title = title;
  this.stepPerformanceSnapShots = stepPerformanceSnapShots;

  Set<String> stepsSet = stepPerformanceSnapShots.keySet();
  steps = stepsSet.toArray( new String[stepsSet.size()] );
  Arrays.sort( steps );
}
 
Example #30
Source File: SWTLayoutPositionTracker.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
public static void main(String[] args) {
	Display display = new Display();
	shell = new Shell(display);

	positiongLabel = new Label(shell, SWT.BORDER);
	
	int x= 60;
	int y=20;
	int width =400;
	int height=200;

	positiongLabel.setBounds(x, y, width, height);
	int toolbarSize = 30;

	shell.setBounds(200, 400, width+2*x , height + 2*y +toolbarSize);
	shell.open();
	
	
	
	shell.addMouseMoveListener(e -> showSize(e));
	positiongLabel.addMouseMoveListener(e -> showSize(e));
	
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}