Java Code Examples for org.eclipse.swt.widgets.Control#dispose()

The following examples show how to use org.eclipse.swt.widgets.Control#dispose() . These examples are extracted from open source projects. 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
/**
 * 刷新过滤器设置组件
 */
private void refresh() {
	filterNameTxt.setText("");
	andBtn.setSelection(true);
	orBtn.setSelection(false);
	btnIsTagged.setSelection(false);
	btnQT.setSelection(false);
	btnPT.setSelection(false);
	if (btnIsRemoveFromSrc != null) {
		btnIsRemoveFromSrc.setSelection(false);
	}
	for (Control ctl : conditionList) {
		if (!ctl.isDisposed()) {
			ctl.dispose();
		}
	}
	conditionList.clear();
	new DynaComposite(dynaComp, SWT.NONE);
	scroll.setMinSize(dynaComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
	dynaComp.layout();

}
 
Example 2
/**
 * Sets the expanded state of the receiver.
 *
 * @param expanded
 *            the new expanded state
 *
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
 *                </ul>
 */
public void setExpanded(final boolean expanded) {
	if (parent == null) { return; }
	// checkWidget();
	this.expanded = expanded;
	if (onExpandBlock != null) {
		if (expanded) {
			onExpandBlock.run();
			setHeight(control.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
		} else {
			for (final Control c : control.getChildren()) {
				c.dispose();
			}
			if (control instanceof ScrolledComposite) {
				((ScrolledComposite) control).setContent(null);
			}
		}
	}
	parent.showItem(this);
}
 
Example 3
Source Project: nebula   File: CDateTime.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void disposePicker() {
	if (content != null) {
		if (picker != null) {
			picker.dispose();
			picker = null;
		}
		if (isDropDown()) {
			Control c = content;
			setContent(null);
			c.dispose();
			if (contentShell != null) {
				Display.getDefault().asyncExec(() -> {
					if (contentShell != null
							&& !contentShell.isDisposed()) {
						contentShell.dispose();
						contentShell = null;
					}
				});
			}
		}
	}
}
 
Example 4
/**
 *
 */
protected void refreshGrid() {
    if (gridPlaceHolder != null) {
        for (final Control child : gridPlaceHolder.getChildren()) {
            child.dispose();
        }
        createGrid(gridPlaceHolder);
        gridPlaceHolder.pack();
        gridPlaceHolder.layout(true);
        final Point size = gridPlaceHolder.getSize();
        size.x = size.x - 15;
        gridParentScrollable.setExpandHorizontal(true);
        gridParentScrollable.setExpandVertical(false);
        gridParentScrollable.setMinSize(size);
    }
}
 
Example 5
Source Project: ldparteditor   File: EditorTextDesign.java    License: MIT License 6 votes vote down vote up
public void reloadColours() {
    for (Control ctrl : toolItem_ColourBar.getChildren()) {
        if (!(ctrl instanceof ToolSeparator)) ctrl.dispose();
    }

    List<GColour> colours = WorkbenchManager.getUserSettingState().getUserPalette();

    final int size = colours.size();
    for (int i = 0; i < size; i++) {
        addColorButton(toolItem_ColourBar, colours.get(i), i);
    }

    {
        NButton btn_Palette = new NButton(toolItem_ColourBar, Cocoa.getStyle());
        this.btn_Palette[0] = btn_Palette;
        btn_Palette.setToolTipText(I18n.E3D_More);
        btn_Palette.setImage(ResourceManager.getImage("icon16_colours.png")); //$NON-NLS-1$
    }

    toolItem_ColourBar.getParent().layout();
    toolItem_ColourBar.layout();
    toolItem_ColourBar.redraw();
}
 
Example 6
/**
 * 销毁除了“过滤器列表控件”之外的其它控件
 */
private void disposeChild() {
	for (Control ctl : this.getChildren()) {
		if (!"filterName".equals(ctl.getData()) && ctl != null && !ctl.isDisposed()) {
			ctl.dispose();
		}
	}
}
 
Example 7
public void removeAllLines() {
int size = removes.size() ;
for(Button remove : removes){
	remove.dispose() ;
}
removes.clear();
for(Control control : controls){
	control.dispose() ;
}
controls.clear();

layoutComposite();
for(int i = 0 ; i< size ; i++)
	lineRemoved(i);	
}
 
Example 8
/**
 * Remove a filter from the header.
 *
 * @param filter
 *            the filter to remove
 */
public void removeFilter(ITmfFilter filter) {
    for (Control control : getChildren()) {
        if (filter.equals(control.getData())) {
            control.dispose();
            break;
        }
    }
    if (getChildren().length == 0) {
        fLayout.marginTop = 0;
        fLayout.marginBottom = 0;
    }
    getParent().layout(true, true);
}
 
Example 9
public void maximizeCoolbar() {
    for (final Control c : toolbarContainer.getChildren()) {
        c.dispose();
    }
    size = CoolbarSize.NORMAL;
    createToolbar(toolbarContainer, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage());
    toolbarContainer.getParent().layout(true, true);
}
 
Example 10
Source Project: pentaho-kettle   File: JobDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void showLogTypeOptions( int index ) {

    if ( index != previousLogTableIndex ) {

      getLogInfo( previousLogTableIndex );

      // clean the log options composite...
      //
      for ( Control control : wLogOptionsComposite.getChildren() ) {
        control.dispose();
      }

      previousLogTableIndex = index;

      LogTableInterface logTable = logTables.get( index );
      LogTableUserInterface logTableUserInterface = logTableUserInterfaces.get( index );

      if ( logTableUserInterface != null ) {
        logTableUserInterface.showLogTableOptions( wLogOptionsComposite, logTable );
      } else {
        if ( logTable instanceof JobLogTable ) {
          showJobLogTableOptions( (JobLogTable) logTable );
        } else if ( logTable instanceof ChannelLogTable ) {
          showChannelLogTableOptions( (ChannelLogTable) logTable );
        }
        if ( logTable instanceof JobEntryLogTable ) {
          showJobEntryLogTableOptions( (JobEntryLogTable) logTable );
        }
      }

      wLogOptionsComposite.layout( true, true );
      wLogComp.layout( true, true );
    }
  }
 
Example 11
Source Project: neoscada   File: PageManager.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void deactivateNode ()
{
    for ( final Control control : this.mainArea.getChildren () )
    {
        control.dispose ();
    }
    this.currentNode = null;
    this.currentPage = null;
}
 
Example 12
private void updateLegendArea() {
    for (Control c: fLegendArea.getChildren()) {
        c.dispose();
    }
    disposeLegendImages();
    if (fFullTraceHistogram.showTraces()) {
        Collection<ITmfTrace> traces = TmfTraceManager.getTraceSet(fTrace);
        fLegendImages = new Image[traces.size()];
        int traceIndex = 0;
        for (ITmfTrace trace : traces) {
            fLegendImages[traceIndex] = new Image(fLegendArea.getDisplay(), 16, 16);
            GC gc = new GC(fLegendImages[traceIndex]);
            gc.setBackground(fFullTraceHistogram.getTraceColor(traceIndex));
            gc.fillRectangle(0, 0, 15, 15);
            gc.setForeground(fLegendArea.getDisplay().getSystemColor(SWT.COLOR_BLACK));
            gc.drawRectangle(0, 0, 15, 15);
            gc.dispose();

            CLabel label = new CLabel(fLegendArea, SWT.NONE);
            label.setText(trace.getName());
            label.setImage(fLegendImages[traceIndex]);
            traceIndex++;
        }
    }
    fLegendArea.layout();
    fLegendArea.getParent().layout();
}
 
Example 13
Source Project: pentaho-kettle   File: DataGridDialog.java    License: Apache License 2.0 4 votes vote down vote up
private void addDataGrid( boolean refresh ) {

    if ( refresh ) {
      // retain changes made in the dialog...
      //
      getMetaInfo( dataGridMeta );
    }

    if ( refresh ) {
      // Retain the data edited in the dialog...
      //
      getDataInfo( dataGridMeta );

      // Clear out the data composite and redraw it completely...
      //
      for ( Control control : wDataComp.getChildren() ) {
        control.dispose();
      }
    }

    ColumnInfo[] columns = new ColumnInfo[dataGridMeta.getFieldName().length];
    for ( int i = 0; i < columns.length; i++ ) {
      columns[i] = new ColumnInfo( dataGridMeta.getFieldName()[i], ColumnInfo.COLUMN_TYPE_TEXT, false, false );
    }
    List<List<String>> lines = dataGridMeta.getDataLines();
    wData = new TableView( transMeta, wDataComp, SWT.NONE, columns, lines.size(), lsMod, props );
    wData.setSortable( false );

    for ( int i = 0; i < lines.size(); i++ ) {
      List<String> line = lines.get( i );
      TableItem item = wData.table.getItem( i );

      for ( int f = 0; f < line.size(); f++ ) {
        item.setText( f + 1, Const.NVL( line.get( f ), "" ) );
      }
    }

    wData.setRowNums();
    wData.optWidth( true );

    FormData fdData = new FormData();
    fdData.left = new FormAttachment( 0, 0 );
    fdData.top = new FormAttachment( 0, 0 );
    fdData.right = new FormAttachment( 100, 0 );
    fdData.bottom = new FormAttachment( 100, 0 );
    wData.setLayoutData( fdData );

    wTabFolder.layout( true, true );

    wFields.nrNonEmpty();
    wFields.setTableViewModifyListener( new TableModifyListener() );

    wFields.setContentListener( modifyEvent -> wFields.nrNonEmpty() );
  }
 
Example 14
Source Project: erflute   File: ListenerAppender.java    License: Apache License 2.0 4 votes vote down vote up
private static void setEditValue(Control control, TableItem tableItem, Point xy, EditableTable editableTable) {
    editableTable.setData(xy, control);
    if (editableTable.validate()) {
        control.dispose();
    }
}
 
Example 15
Source Project: nebula   File: Launcher.java    License: Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Dispose the content before a redraw
 */
private void disposePreviousContent() {
	for (final Control c : getChildren()) {
		c.dispose();
	}
}
 
Example 16
Source Project: xds-ide   File: SwtUtils.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public static void dispose(Control c) {
	if (null != c && !c.isDisposed()) {
		c.dispose();
	}
}
 
Example 17
/**
 * 编辑
 */
private void edit() {
	String[] filters = customFilterList.getSelection();
	if (filters.length > 0) {
		if (isChange()) {
			if (!MessageDialog.openConfirm(getShell(), "", Messages.getString("dialog.CustomFilterDialog.msg1"))) {
				return;
			}
		}
		String key = filters[0];
		filterNameTxt.setText(key);
		String link = XLFHandler.getCustomFilterAdditionMap().get(key);
		if (link.indexOf("and") != -1) {
			andBtn.setSelection(true);
			orBtn.setSelection(false);
		} else {
			andBtn.setSelection(false);
			orBtn.setSelection(true);
		}

		for (Control ctl : conditionList) {
			if (!ctl.isDisposed()) {
				ctl.dispose();
			}
		}
		conditionList.clear();
		ArrayList<String[]> tmpList = XLFHandler.getCustomFilterIndexMap().get(key);
		for (String[] tempIndex : tmpList) {
			String filterIndex = tempIndex[0];
			DynaComposite dyna = new DynaComposite(dynaComp, SWT.NONE);
			dyna.getFilterName().select(Integer.parseInt(filterIndex));
			dyna.getFilterName().notifyListeners(SWT.Selection, null);
			if ("0".equals(filterIndex) || "1".equals(filterIndex)) { // 关键字、批注
				dyna.getConditions().select(Integer.parseInt(tempIndex[1]));
				dyna.getValue().setText(tempIndex[2].replace("0x0020", " "));
				dyna.getValue().setForeground(black);
			} else if ("2".equals(filterIndex)) { // 属性
				dyna.getPropName().setText(tempIndex[1]);
				dyna.getPropValue().setText(tempIndex[2]);
				dyna.getPropName().setForeground(black);
				dyna.getPropValue().setForeground(black);
			}
		}
		scroll.setMinSize(dynaComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		dynaComp.layout();
	} else {
		MessageDialog.openInformation(getShell(), "", Messages.getString("dialog.CustomFilterDialog.msg4"));
	}
}
 
Example 18
Source Project: atdl4j   File: SWTStrategiesUI.java    License: MIT License 4 votes vote down vote up
public void removeAllStrategyPanels()
{
	// remove all strategy panels
	for ( Control control : strategiesPanel.getChildren() )
		control.dispose();
}
 
Example 19
private void removeAllChildrens(){
	for (Control c : getChildren()) {
		c.dispose();
		
	}
}
 
Example 20
Source Project: pentaho-kettle   File: TableView.java    License: Apache License 2.0 4 votes vote down vote up
private void edit( int rownr, int colnr, boolean selectText, char extra ) {
  selectionStart = -1;

  TableItem row = table.getItem( rownr );

  Control oldEditor = editor.getEditor();
  if ( oldEditor != null && !oldEditor.isDisposed() ) {
    try {
      oldEditor.dispose();
    } catch ( SWTException swte ) {
      // Eat "Widget Is Disposed Exception" : did you ever!!!
    }
  }

  activeTableItem = table.getItem( activeTableRow ); // just to make sure, clean
  // up afterwards.
  table.showItem( row );
  table.setSelection( new TableItem[]{ row } );

  if ( columns.length == 0 ) {
    return;
  }

  switch ( columns[colnr - 1].getType() ) {
    case ColumnInfo.COLUMN_TYPE_TEXT:
      isTextButton = false;
      editText( row, rownr, colnr, selectText, extra, columns[colnr - 1] );
      break;
    case ColumnInfo.COLUMN_TYPE_CCOMBO:
    case ColumnInfo.COLUMN_TYPE_FORMAT:
      editCombo( row, rownr, colnr );
      break;
    case ColumnInfo.COLUMN_TYPE_BUTTON:
      editButton( row, rownr, colnr );
      break;
    case ColumnInfo.COLUMN_TYPE_TEXT_BUTTON:
      if ( columns[colnr - 1].shouldRenderTextVarButton() ) {
        isTextButton = true;
      } else {
        isTextButton = false;
      }
      editText( row, rownr, colnr, selectText, extra, columns[colnr - 1] );
      break;
    default:
      break;
  }
}