Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Can't have a button labeled "Stop"?
Can't have a button labeled "Stop"? [message #777172] Mon, 09 January 2012 20:01 Go to next message
John Lussmyer is currently offline John Lussmyer
Messages: 96
Registered: December 2010
Member
I have a dialog with several buttons.
One of them has the text "Stop". Or I should stay I'd LIKE to have the button text be "Stop".
I can't.
If I set the button text to "Stop" - the button doesn't show up when the dialog is displayed.
If I change the text to something else, it does show up.

Huh?
Re: Can't have a button labeled "Stop"? [message #778035 is a reply to message #777172] Wed, 11 January 2012 05:26 Go to previous messageGo to next message
paul berzatti is currently offline paul berzatti
Messages: 3
Registered: January 2012
Junior Member
Strange!
I tested the creation of a 'Stop' button and it works fine.
Can you send me your code please?
Re: Can't have a button labeled "Stop"? [message #778261 is a reply to message #778035] Wed, 11 January 2012 21:56 Go to previous messageGo to next message
John Lussmyer is currently offline John Lussmyer
Messages: 96
Registered: December 2010
Member
This is in a jface dialog.
Whenever I set the button text to "Stop", it would never be displayed in the dialog.

		mcomposite_5 = new Composite(mcompImportStatus, SWT.NONE);
		mcomposite_5.setLayout(new FillLayout(SWT.VERTICAL));
		mcomposite_5.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
		mcomposite_5.setSize(43, 55);

		mbtnStop = new Button(mcomposite_5, SWT.NONE);
		mbtnStop.setEnabled(false);
		mbtnStop.setText("Stop Import");
		mbtnStop.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected( SelectionEvent e) {
				if (mImporter != null) {
					mImporter.stop();
				} else if (mFolderCreator != null) {
					mFolderCreator.stopCreating();
				}
				return;
			}
		});

Re: Can't have a button labeled "Stop"? [message #778318 is a reply to message #778261] Thu, 12 January 2012 06:23 Go to previous messageGo to next message
paul berzatti is currently offline paul berzatti
Messages: 3
Registered: January 2012
Junior Member
I tried your code and it works perfectly well.
Try adding the following line before setEnabled(false)

mbtnStop.setBounds(114, 205, 43, 55);

Try to maximize the dialog when the application is launched.
Let me know.
Re: Can't have a button labeled "Stop"? [message #778392 is a reply to message #778318] Thu, 12 January 2012 13:18 Go to previous message
John Lussmyer is currently offline John Lussmyer
Messages: 96
Registered: December 2010
Member
Doing the setBounds() didn't make any difference.
The other button in the Composite shows up just fine. (It's the 2nd control)
I noticed that it had a mbtnPause.setSize(43,25) call.
So I commented that out.
Now NEITHER button shows up.
Added the setSize() to the mbtnStop (only, didn't uncomment the other)
Now just the Stop button shows up.
uncommented the other, so both buttons have it.
Still, only the Stop button is being displayed.
Tried making the sizes larger or smaller. No change.

So, I removed the .setSize() call from both buttons, and changed the text of the mbtnStop to be "Stop Import".
Now both buttons show up just fine.

This is bizarre.

So, here is the entire "createDialogArea()" method.
	protected Control createDialogArea( Composite parent) {
		Composite container = (Composite) super.createDialogArea(parent);

		mtabFolder = new TabFolder(container, SWT.NONE);
		mtabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

		mtabMBox = new TabItem(mtabFolder, SWT.NONE);
		mtabMBox.setText("Mbox");
		mCurTab = mtabMBox;

		mcompMbox = new Composite(mtabFolder, SWT.NONE);
		mtabMBox.setControl(mcompMbox);
		mcompMbox.setLayout(new GridLayout(3, false));

		Label lblMboxPath = new Label(mcompMbox, SWT.NONE);
		lblMboxPath.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblMboxPath.setSize(60, 15);
		lblMboxPath.setText("mbox Path:");

		mtxtPath = new Text(mcompMbox, SWT.BORDER);
		mtxtPath.addFocusListener(new FocusAdapter() {
			@Override
			public void focusLost( FocusEvent e) {
				checkButtonState();
				return;
			}
		});
		mtxtPath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		mtxtPath.setSize(277, 21);

		Button btnBrowse = new Button(mcompMbox, SWT.NONE);
		btnBrowse.setSize(50, 25);
		btnBrowse.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected( SelectionEvent e) {
				Shell shell = new Shell(Display.getDefault(), SWT.APPLICATION_MODAL);
				FileDialog dialog = new FileDialog(shell);
				dialog.setText("Select mbox file");
				dialog.setFileName(mtxtPath.getText());
				String file = dialog.open();
				if (file != null) {
					mtxtPath.setText(file);
				}
				checkButtonState();
				return;
			}
		});
		btnBrowse.setText("Browse");

		Label lblTargetFolder = new Label(mcompMbox, SWT.NONE);
		lblTargetFolder.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblTargetFolder.setSize(73, 15);
		lblTargetFolder.setText("Target Folder:");

		mbuttonSelFolder = new Button(mcompMbox, SWT.NONE);
		mbuttonSelFolder.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected( SelectionEvent e) {
				try {
					FolderSelectDialog dialog = new FolderSelectDialog(getShell());
					dialog.open();
					mFolderID = dialog.getSelectedFolder();
					mbuttonSelFolder.setText((mFolderID == 0) ? "<select folder>" : getFolder(mFolderID).getName());
				} catch (RemoteException ex) {
					logger.error("Remote Exception", ex);
				} catch (FolderNotFoundException ex) {
					logger.error("Folder Not Found Exception", ex);
				}
				checkButtonState();
				return;
			}
		});
		mbuttonSelFolder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		mbuttonSelFolder.setText("<select folder>");
		new Label(mcompMbox, SWT.NONE);

		Label lblAccountIfNo = new Label(mcompMbox, SWT.NONE);
		lblAccountIfNo.setToolTipText("Accoun to use if Import is unable to guess an Account for a message.");
		lblAccountIfNo.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblAccountIfNo.setSize(147, 15);
		lblAccountIfNo.setText("Default Account:");

		mcmbAccounts = new Combo(mcompMbox, SWT.READ_ONLY);
		mcmbAccounts.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		mcmbAccounts.setSize(277, 23);
		mcmbAccounts.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected( SelectionEvent e) {
				int selid = mcmbAccounts.getSelectionIndex();
				if (selid != -1) {
					mAccountID = ((IAccount) mcmbAccounts.getData(mcmbAccounts.getItem(selid))).getID();
				} else {
					mAccountID = 0;
				}
				checkButtonState();
				return;
			}
		});
		new Label(mcompMbox, SWT.NONE);
		new Label(mcompMbox, SWT.NONE);

		mbtnMarkUnread = new Button(mcompMbox, SWT.CHECK);
		mbtnMarkUnread.setSize(157, 16);
		mbtnMarkUnread.setText("Mark messages as Unread");
		new Label(mcompMbox, SWT.NONE);

		mtabTB = new TabItem(mtabFolder, SWT.NONE);
		mtabTB.setText("Thunderbird");

		mcompTBird = new Composite(mtabFolder, SWT.NONE);
		mtabTB.setControl(mcompTBird);
		mcompTBird.setLayout(new GridLayout(3, false));

		mlabel_3 = new Label(mcompTBird, SWT.NONE);
		mlabel_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		mlabel_3.setText("Profile Directory:");

		mtextProfileDir = new Text(mcompTBird, SWT.BORDER);
		mtextProfileDir.addFocusListener(new FocusAdapter() {
			@Override
			public void focusLost( FocusEvent e) {
				checkButtonState();
				return;
			}
		});
		mtextProfileDir.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

		mbuttonProfileBrowse = new Button(mcompTBird, SWT.NONE);
		mbuttonProfileBrowse.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected( SelectionEvent e) {
				Shell shell = new Shell(Display.getDefault(), SWT.APPLICATION_MODAL);
				DirectoryDialog dialog = new DirectoryDialog(shell);
				dialog.setText("Select Thunderbird Profile Directory");
				String file = dialog.open();
				if (file != null) {
					mtextProfileDir.setText(file);
				}
				checkButtonState();
				return;
			}
		});
		mbuttonProfileBrowse.setText("Browse");
		new Label(mcompTBird, SWT.NONE);

		mbuttonTBFindAccts = new Button(mcompTBird, SWT.NONE);
		mbuttonTBFindAccts.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected( SelectionEvent e) {
				tbirdScan();
				checkButtonState();
				return;
			}
		});
		mbuttonTBFindAccts.setText("Find Accounts");
		new Label(mcompTBird, SWT.NONE);

		mlabel_4 = new Label(mcompTBird, SWT.NONE);
		mlabel_4.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		mlabel_4.setText("Accounts:");

		mcomposite_4 = new Composite(mcompTBird, SWT.NONE);
		mcomposite_4.setLayout(new FillLayout(SWT.VERTICAL));
		mcomposite_4.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 2));

		mtvTBAccounts = CheckboxTableViewer.newCheckList(mcomposite_4, SWT.BORDER | SWT.FULL_SELECTION);
		mtableTBAccounts = mtvTBAccounts.getTable();

		mtvTBFolders = CheckboxTableViewer.newCheckList(mcomposite_4, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
		mtableTBFolders = mtvTBFolders.getTable();
		mtvTBFolders.addCheckStateListener(new ICheckStateListener() {
			public void checkStateChanged( CheckStateChangedEvent event) {
				IStructuredSelection sel = (IStructuredSelection) mtvTBFolders.getSelection();
				Object[] elements = sel.toArray();
				for (int idx = 0; (idx < elements.length); idx++) {
					mtvTBFolders.setChecked(elements[idx], event.getChecked());
				}

				return;
			}
		});

		mlabel_5 = new Label(mcompTBird, SWT.NONE);
		mlabel_5.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		mlabel_5.setText("Folders:");
		new Label(mcompTBird, SWT.NONE);

		mcheckNoTrash = new Button(mcompTBird, SWT.CHECK);
		mcheckNoTrash.setSelection(true);
		mcheckNoTrash.setText("Don't Import TRASH folders");
		new Label(mcompTBird, SWT.NONE);

		mlabel_6 = new Label(mcompTBird, SWT.NONE);
		mlabel_6.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		mlabel_6.setText("Default Account:");

		mcomboTBDefAcct = new Combo(mcompTBird, SWT.READ_ONLY);
		mcomboTBDefAcct.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected( SelectionEvent e) {
				int selid = mcomboTBDefAcct.getSelectionIndex();
				if (selid != -1) {
					mAccountID = ((IAccount) mcomboTBDefAcct.getData(mcomboTBDefAcct.getItem(selid))).getID();
				} else {
					mAccountID = 0;
				}
				checkButtonState();
				return;
			}
		});
		mcomboTBDefAcct.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		new Label(mcompTBird, SWT.NONE);

		mcompImportStatus = new Composite(container, SWT.NONE);
		mcompImportStatus.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		mcompImportStatus.setLayout(new GridLayout(3, false));

		Label lblStatus = new Label(mcompImportStatus, SWT.NONE);
		lblStatus.setSize(35, 15);
		lblStatus.setText("Status:");

		mcomposite_1 = new Composite(mcompImportStatus, SWT.NONE);
		mcomposite_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		mcomposite_1.setSize(144, 55);
		mcomposite_1.setLayout(new GridLayout(3, false));

		mcomposite_2 = new Composite(mcomposite_1, SWT.NONE);
		mcomposite_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		mcomposite_2.setLayout(new GridLayout(1, false));

		mlabel = new Label(mcomposite_2, SWT.CENTER);
		mlabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		mlabel.setSize(36, 15);
		mlabel.setText("Count");

		mlblCount = new Label(mcomposite_2, SWT.RIGHT);
		mlblCount.setAlignment(SWT.CENTER);
		mlblCount.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		mlblCount.setSize(36, 15);
		mlblCount.setText("0");

		mcomposite_3 = new Composite(mcomposite_1, SWT.NONE);
		mcomposite_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		mcomposite_3.setLayout(new GridLayout(1, false));

		mlabel_1 = new Label(mcomposite_3, SWT.CENTER);
		mlabel_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		mlabel_1.setText("Size");

		lblSize = new Label(mcomposite_3, SWT.RIGHT);
		lblSize.setAlignment(SWT.CENTER);
		lblSize.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

		mcomposite = new Composite(mcomposite_1, SWT.NONE);
		mcomposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		mcomposite.setLayout(new GridLayout(1, false));

		mlabel_2 = new Label(mcomposite, SWT.CENTER);
		mlabel_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		mlabel_2.setText("% Done");

		mlblPctDon = new Label(mcomposite, SWT.RIGHT);
		mlblPctDon.setAlignment(SWT.CENTER);
		mlblPctDon.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		mlblPctDon.setText("0");

		mcomposite_5 = new Composite(mcompImportStatus, SWT.NONE);
		mcomposite_5.setLayout(new FillLayout(SWT.VERTICAL));
		mcomposite_5.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
		mcomposite_5.setSize(43, 55);

		mbtnStop = new Button(mcomposite_5, SWT.NONE);
		mbtnStop.setEnabled(false);
		//mbtnStop.setSize(43,25);
		mbtnStop.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected( SelectionEvent e) {
				if (mImporter != null) {
					mImporter.stop();
				} else if (mFolderCreator != null) {
					mFolderCreator.stopCreating();
				}
				return;
			}
		});
		mbtnStop.setText("Stop Import");

		mbtnPause = new Button(mcomposite_5, SWT.NONE);
		mbtnPause.setEnabled(false);
		//mbtnPause.setSize(43, 25);
		mbtnPause.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected( SelectionEvent e) {
				if (mImporter != null) {
					mImporter.pause(!mImporter.isPaused());
					mbtnPause.setText(mImporter.isPaused() ? "Resume" : "Pause");
				}
				return;
			}
		});
		mbtnPause.setText("Pause");

		mlblMsg = new Label(mcompImportStatus, SWT.NONE);
		mlblMsg.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
		mlblMsg.setSize(18, 15);

		mtabFolder.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected( SelectionEvent e) {
				logger.debug("Changed Tab");
				TabItem[] items = mtabFolder.getSelection();
				if ((items.length > 0) && (items[0] == mtabMBox)) {
					mCurTab = mtabMBox;
				} else {
					mCurTab = mtabTB;
				}

				checkButtonState();
				return;
			}
		});
		fillLists();
		return container;


Previous Topic:[SOLVED] ClassNotFoundException
Next Topic:Fix "Missing name Missing name" in forums
Goto Forum:
  


Current Time: Fri Jul 25 23:17:29 EDT 2014

Powered by FUDForum. Page generated in 0.02074 seconds