org.apache.pivot.wtk.Component Java Examples

The following examples show how to use org.apache.pivot.wtk.Component. 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: TextInputDrop.java    From setupmaker with Apache License 2.0 6 votes vote down vote up
@Override
public DropAction drop(Component component, Manifest dragContent,
        int supportedDropActions, int x, int y, DropAction dropActions)
{
    DropAction dropAction = null;

    if (dragContent.containsText()) {
        try {
            ((TextInput) component).setText(dragContent.getText());
            dropAction = DropAction.COPY;
        } catch(IOException exception) {
            System.err.println(exception);
        }
    }

    dragExit(component);

    return dropAction;
}
 
Example #2
Source File: TextAreaDrop.java    From setupmaker with Apache License 2.0 6 votes vote down vote up
@Override
public DropAction drop(Component component, Manifest dragContent,
        int supportedDropActions, int x, int y, DropAction dropActions)
{
    DropAction dropAction = null;

    if (dragContent.containsText()) {
        try {
            TextArea textArea = (TextArea) component;
            textArea.setText(textArea.getText() + 
                    (textArea.getText().endsWith(" ")?"":" ") + dragContent.getText());
            dropAction = DropAction.COPY;
        } catch(IOException exception) {
            System.err.println(exception);
        }
    }

    dragExit(component);

    return dropAction;
}
 
Example #3
Source File: GeoTriplesWindow.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
@Override
public void configureMenuBar(Component component, MenuBar menuBar) {
    if (component instanceof TextInput) {
        TextInput textInput = (TextInput)component;
 
        updateActionState(textInput);
        Action.getNamedActions().get("paste").setEnabled(true);
 
        textInput.getTextInputContentListeners().add(textInputTextListener);
        textInput.getTextInputSelectionListeners().add(textInputSelectionListener);
    } else {
        Action.getNamedActions().get("cut").setEnabled(false);
        Action.getNamedActions().get("copy").setEnabled(false);
        Action.getNamedActions().get("paste").setEnabled(false);
    }
}
 
Example #4
Source File: GeoTriplesWindow.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
@Override
public void perform(Component source) {
	//remove table from list of tablesources , previously source table removed the object from mainTablePane in gui
	//so the size( list of tablessources) and the size(rows from gui) are not equal
	RowSequence rs=((TablePane)namespace.get("mainTablePane")).getRows();
	for(int i=0;i<rs.getLength();++i) //TODO ME,  na allaxtei afto, na mpei se ena row ena tablepain keno, kai se afto na paizei mpala , oxi se ola ta rows
	{ //giati an kapoios prosthesei ena row se afto to tablepane ti vapsame me afta ta 2 kai -2 :P
		if(rs.get(i) != sourceTables.get(i))
		{
			sourceTables.remove(i, 1);
			break;
		}
	}
	if((rs.getLength())!=sourceTables.getLength())
	{
		sourceTables.remove(sourceTables.getLength()-1, 1);
	}
		//sourceTables.remove((SourceTable)source);
}
 
Example #5
Source File: AddSourceTable.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
	
	selectSource.setAction(new Action() {
		
		@Override
		public void perform(Component source) {
			@SuppressWarnings({ "unchecked", "unused" })
			Sequence<TableName> mm=(Sequence<TableName>) listView.getSelectedItems();
			if( listView.getSelectedItems().getLength()==0)
			{
				return;
			}
			AddSourceTable.this.selectedItems=new ArrayList<TableName>();
			for(int i=0;i<mm.getLength();++i)
			{
				TableName selecteditem=mm.get(i);
				AddSourceTable.this.selectedItems.add(selecteditem);
			}
			
			close(true);
		}
	});
}
 
Example #6
Source File: MosaicPaneRefImpl.java    From Mosaic with Apache License 2.0 6 votes vote down vote up
private Position getClickQuadrant(Component c, int x, int y) {
	if(c == null) return null; //probably a divider
	
	Bounds b = c.getBounds();
	x -= b.x;
	y -= b.y;
	if(x < b.width / 4 && y > b.height / 3 && y < b.height - (b.height / 3)) {
		return Position.WEST;
	}else if(x > b.width - (b.width / 4) && y > b.height / 3 && y < b.height - (b.height / 3)) {
		return Position.EAST;
	}else if(y < b.height / 4 && x > b.width / 3 && x < b.width - (b.width / 3)) {
		return Position.NORTH;
	}else if(y > b.height - (b.height / 4) && x > b.width / 3 && x < b.width - (b.width / 3)) {
		return Position.SOUTH;
	}
	System.out.println("c = " + c + ", x = " + x + ", y = " + y + ",  c bounds = " + b);
	return null;
}
 
Example #7
Source File: SourceTable.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public void setRemoveTableAction(final Action action)
{
	removeTable.setAction(new Action() {
		@Override
		public void perform(Component source) {
			SourceTable.this.getTablePane().getRows().remove(SourceTable.this);
			action.perform(null);
		}
	});
}
 
Example #8
Source File: TextInputDrop.java    From setupmaker with Apache License 2.0 5 votes vote down vote up
@Override
public DropAction dragEnter(Component component, Manifest dragContent,
        int supportedDropActions, DropAction userDropAction)
{
    DropAction dropAction = null;

    if (dragContent.containsText()
        && DropAction.COPY.isSelected(supportedDropActions)) {
        dropAction = DropAction.COPY;
    }

    return dropAction;
}
 
Example #9
Source File: TextAreaDrop.java    From setupmaker with Apache License 2.0 5 votes vote down vote up
@Override
public DropAction dragEnter(Component component, Manifest dragContent,
        int supportedDropActions, DropAction userDropAction)
{
    DropAction dropAction = null;

    if (dragContent.containsText()
        && DropAction.COPY.isSelected(supportedDropActions)) {
        dropAction = DropAction.COPY;
    }

    return dropAction;
}
 
Example #10
Source File: GeoTriplesWindow.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
@Override
public void cleanupMenuBar(Component component, MenuBar menuBar) {
    if (component instanceof TextInput) {
        TextInput textInput = (TextInput)component;
        textInput.getTextInputContentListeners().remove(textInputTextListener);
        textInput.getTextInputSelectionListeners().remove(textInputSelectionListener);
    }
}
 
Example #11
Source File: BrowseAction.java    From setupmaker with Apache License 2.0 5 votes vote down vote up
@Override
public void perform(Component component)
{
    if (rootDirectory != null && rootDirectory.exists())
    {
        if (rootDirectory.isDirectory())
            fileBrowserSheet.setRootDirectory(rootDirectory.getAbsoluteFile());
        else
        {
            fileBrowserSheet.setRootDirectory(rootDirectory.getParentFile().getAbsoluteFile());
            fileBrowserSheet.setSelectedFile(rootDirectory.getAbsoluteFile());
        }
    }
    fileBrowserSheet.open(component.getWindow());
}
 
Example #12
Source File: SourceTable.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
@Override
public void perform(Component source) {
	int selectedIndex = tableView.getFirstSelectedIndex();
	removeData(selectedIndex);
	if (selectedIndex == -1) {
		refreshDetail();
		symbolTextInput.requestFocus();
	}
}
 
Example #13
Source File: MosaicPaneRefImpl.java    From Mosaic with Apache License 2.0 5 votes vote down vote up
private void moveCursor(MosaicPane pane, Component source, int dir) {
	switch(dir) {
		case 37 : pane.getSurface().cursorLeft();break;
		case 38 : pane.getSurface().cursorUp();break;
		case 39 : pane.getSurface().cursorRight();break;
		case 40 : pane.getSurface().cursorDown();break;
	}
	Label l = (Label)clientMap.get(pane.getSurface().getCursor());
	System.out.println("component at cursor = " + l);
	pane.getSurface().requestMoveCancel(source);
	pane.getSurface().requestMoveBegin(l);
}
 
Example #14
Source File: NGDialog.java    From setupmaker with Apache License 2.0 5 votes vote down vote up
public NGDialog()
{
    AGroupAdd = new Action() {
        @Override public void perform(Component source)
        {
            if (inGroupName.getText().length() > 0)
                validated = true;
            NGDialog.this.close();
        } };
}
 
Example #15
Source File: ExpandTransition.java    From setupmaker with Apache License 2.0 5 votes vote down vote up
public ExpandTransition(Component component, int duration, int rate)
{
    super(duration, rate, false);
    
    this.component = component;
    initialWidth = component.getPreferredWidth();
}
 
Example #16
Source File: PathValidator.java    From setupmaker with Apache License 2.0 5 votes vote down vote up
public PathValidator(Component component, boolean required)
{
    assert component != null;
    this.component = component;
    this.tooltipText = component.getTooltipText();
    this.required = required;
}
 
Example #17
Source File: NameValidator.java    From setupmaker with Apache License 2.0 5 votes vote down vote up
public NameValidator(Component component, boolean required, boolean id)
{
    assert component != null;
    this.component = component;
    this.required = required;
    this.id = id;
}
 
Example #18
Source File: CollapseTransition.java    From setupmaker with Apache License 2.0 5 votes vote down vote up
public CollapseTransition(Component component, int duration, int rate)
{
    super(duration, rate, false);
    
    this.component = component;
    initialWidth = component.getPreferredWidth();
}
 
Example #19
Source File: VersionValidator.java    From setupmaker with Apache License 2.0 4 votes vote down vote up
public VersionValidator(Component component, boolean required)
{
    assert component != null;
    this.component = component;
    this.required = required;
}
 
Example #20
Source File: TextInputDrop.java    From setupmaker with Apache License 2.0 4 votes vote down vote up
@Override
public DropAction dragMove(Component component, Manifest dragContent,
        int supportedDropActions, int x, int y, DropAction dropActions)
{
    return (dragContent.containsText() ? DropAction.COPY : null);
}
 
Example #21
Source File: ScanFrame.java    From setupmaker with Apache License 2.0 4 votes vote down vote up
public ScanFrame() {// Constructor
    assert (singleton == null);
    singleton = this;
    
    // folder tree view context menu
    MHTreeView = new MenuHandler.Adapter() {
        @Override public boolean configureContextMenu(Component component, Menu menu, int x, int y)
        {
            final TreeNode node = (TreeNode) treeView.getSelectedNode();
            
            if (node != null) {
                Menu.Section menuSection = new Menu.Section();
                menu.getSections().add(menuSection);

                Menu.Item itemOpen = new Menu.Item(new ButtonData(IOFactory.imgFolder, "scan"));
                
                final File newDir = new File(inPath.getText(), node.getText());
                if (newDir.exists() && newDir.isDirectory()) {
                    itemOpen.getButtonPressListeners().add(new ButtonPressListener() {// scan selected folder
                        @Override public void buttonPressed(Button bt) {
                            Out.print(LOG_LEVEL.DEBUG, "Scan folder set to child folder: " + node.getText());
                            inPath.setText(newDir.getAbsolutePath());
                            ADirScan.perform(bt);
                        }
                    });
                }
                else itemOpen.setEnabled(false);

                menuSection.add(itemOpen);
            }
            return false;
        }
    };
    
    filter = new FilenameFilter() {// Checkbox packs filters
        @Override public boolean accept(File dir, String name)
        {
            try {
                if (inCustExpr.getText().length() > 0 && name.matches(inCustExpr.getText()))
                    return !cbCustExpr.isSelected();
                if (IOFactory.isFileType(name, FILE_TYPE.Archive))
                    return !cbZip.isSelected();
                if (IOFactory.isFileType(name, FILE_TYPE.Setup))
                    return !cbSetup.isSelected();
                if (IOFactory.isFileType(name, FILE_TYPE.Executable))
                    return !cbExe.isSelected();
                if (IOFactory.isFileType(name, FILE_TYPE.Image))
                    return !cbImg.isSelected();
                if (IOFactory.isFileType(name, FILE_TYPE.Video))
                    return !cbVid.isSelected();
                if (IOFactory.isFileType(name, FILE_TYPE.Sound))
                    return !cbSound.isSelected();
                if (IOFactory.isFileType(name, FILE_TYPE.Document))
                    return !cbDoc.isSelected();
                if (IOFactory.isFileType(name, FILE_TYPE.Custom))
                    return !cbCustTxt.isSelected();
                return true;
            }
            catch (PatternSyntaxException e) {
                cbCustExpr.setSelected(false);
                return true;
            }
        }
    };
    
    ADirScan = new Action() {// Directory Scan from Filters/mode Action
        @Override public void perform(Component source) {
            if (btSelect.isSelected()) btSelect.press(); // * bugfix: scan on enabled selection doesn't update packs list
            
            TaskDirScan scan = new TaskDirScan(singleton, inPath.getText(), facade.getTreeData(), filter,
                    (String) depthSpinner.getSelectedItem(), !cbDir.isSelected());
 
            int res = scan.execute();
            if (res == 0) {
                Out.print(LOG_LEVEL.DEBUG, "Scanned directory: " + inPath.getText());
                // Save directory to app config recent dirs
                appConfig.addRecentDir(new File(inPath.getText()));// add scanned dir to recent dirs
                recentFieldFill(recent_dirs, appConfig.getRecentDirs());// refresh recent dirs list display
                if (depthSpinner.getSelectedIndex() < 5)
                    treeView.expandAll();
                else treeView.collapseAll();
                inPath.requestFocus();
                setModified(true);// Modified Flag (*)
            }
            else if (res == 2) {// Error: Path doesn't exist
                Out.print(LOG_LEVEL.DEBUG, "Path error: " + inPath.getText());
                Alert.alert("This path doesn't exist! Please correct it.", ScanFrame.this.getWindow());
            }
            
        } };
}
 
Example #22
Source File: TextAreaDrop.java    From setupmaker with Apache License 2.0 4 votes vote down vote up
@Override
public DropAction userDropActionChange(Component component, Manifest dragContent,
        int supportedDropActions, int x, int y, DropAction dropActions)
{
    return (dragContent.containsText() ? DropAction.COPY : null);
}
 
Example #23
Source File: SortDialog.java    From setupmaker with Apache License 2.0 4 votes vote down vote up
public SortDialog() {//Constructor
    APositioning = new Action() {//Move packs in priority
        @Override public void perform(Component source)
        {
            int oldIndex = tableView.getSelectedIndex();
            Pack P = null;
            if (oldIndex >= 0) P = packs.get(oldIndex);
            
            if (P!=null) {//If selected row
                int newIndex = -1;
                PushButton bt = (PushButton) source;
                
                if (bt.equals(btTop)) {//Top
                    newIndex = 0;
                    //Swap priorities
                    for(int i=0; i<P.getPriority()-1; i++)
                        packs.get(i).setPriority(i+1);
                }
                else if (bt.equals(btUp)) {//Up
                    if (oldIndex > 0)
                        newIndex = oldIndex - 1;
                    else newIndex = 0;
                    //Swap priorities
                    packs.get(newIndex).setPriority(oldIndex);
                }
                else if (bt.equals(btDown)) {//Down
                    if (oldIndex < packs.getLength()-1)
                        newIndex = oldIndex + 1;
                    else newIndex = packs.getLength()-1;
                    //Swap priorities
                    packs.get(newIndex).setPriority(oldIndex);
                }
                else if (bt.equals(btBottom)) {//Bottom
                    newIndex = packs.getLength()-1;
                    //Swap priorities
                    for(int i=packs.getLength()-1; i>P.getPriority()-1; i--)
                        packs.get(i).setPriority(i-1);
                }
                
                //Swap pack position with newIndex
                if (newIndex != oldIndex) {
                    P.setPriority(newIndex);
                    sort("priority");//Sort table by priority
                    //Out.print("PIVOT_SORT", "Pack: " + P.getName() + "- priority (" + (oldIndex) + ">" + (newIndex) + ")");
                    tableView.setSelectedIndex(newIndex);
                    tableView.requestFocus();//Focus on table view selected row
                }
            }
        }
    };
    
    ASortBy = new Action() {//Sort By radio buttons press event
        @Override public void perform(Component arg0)
        {
            if (rbName.isSelected()) {//Name
                sort("name");
            }
            else if (rbSize.isSelected()) {//Size
                sort("size");
            }
            else if (rbFileType.isSelected()) {//File Type
                sort("fileType");
            }
            else if (rbInstallType.isSelected()) {//Install Type
                sort("installType");
            }
            else if (rbGroup.isSelected()) {//Group
                sort("group");
            }
            else if (rbRequired.isSelected()) {//Required
                sort("required");
            }
            else if (rbCustom.isSelected()) {//Custom
                sort("priority");
            }
        }
    };
}
 
Example #24
Source File: TextAreaDrop.java    From setupmaker with Apache License 2.0 4 votes vote down vote up
@Override
public DropAction dragMove(Component component, Manifest dragContent,
        int supportedDropActions, int x, int y, DropAction dropActions)
{
    return (dragContent.containsText() ? DropAction.COPY : null);
}
 
Example #25
Source File: BuildFrame.java    From setupmaker with Apache License 2.0 4 votes vote down vote up
public BuildFrame() {
    assert (singleton == null);
    singleton = this;
    
    // logger copy context menu
    menuHandler = new MenuHandler.Adapter() {
        @Override
        public boolean configureContextMenu(Component component, Menu menu, int x, int y)
        {
            Menu.Section menuSection = new Menu.Section();
            menu.getSections().add(menuSection);

            Menu.Item copy = new Menu.Item(new ButtonData(IOFactory.imgImport, "copy to clipboard"));
            copy.setAction(new Action() {
                @SuppressWarnings("unchecked")
                @Override public void perform(Component source) {
                    facade.copyToClipboard((Sequence<String>) logger.getSelectedItems()); // list of selected strings
                }
            });

            menuSection.add(copy);
            return false;
        }
    };
    
    // Open target folder in explorer
    AOpenFolder = new Action() {
        @Override public void perform(Component c)
        {
            String target = inTargetPath.getText();
            
            if (target.length() > 0) {
                try
                {
                    BuildFrame.this.facade.openFolder(target);
                }
                catch (IOException e)
                {
                    Out.print(LOG_LEVEL.ERR, "File Not Found: " + target);
                    e.printStackTrace();
                }
            }
        }
    };
}
 
Example #26
Source File: PositionSortAction.java    From setupmaker with Apache License 2.0 4 votes vote down vote up
@Override
public void perform(Component source)
{
    int oldIndex = tableView.getSelectedIndex();
    Pack P = null;
    if (oldIndex >= 0) P = packs.get(oldIndex);
    
    if (P!=null) {//If selected row
        int newIndex = -1;
        PushButton bt = (PushButton) source;
        
        if (bt.equals(btTop)) {//Top
            newIndex = 0;
            for(int i=0; i<P.getPriority(); i++)
                packs.get(i).setPriority(i+1);
        }
        else if (bt.equals(btUp)) {//Up
            if (oldIndex > 0)
                newIndex = oldIndex - 1;
            else newIndex = 0;
            packs.get(newIndex).setPriority(oldIndex);
        }
        else if (bt.equals(btDown)) {//Down
            if (oldIndex < packs.getLength()-1)
                newIndex = oldIndex + 1;
            else newIndex = packs.getLength()-1;
            packs.get(newIndex).setPriority(oldIndex);
        }
        else if (bt.equals(btBottom)) {//Bottom
            newIndex = packs.getLength()-1;
            for(int i=packs.getLength()-1; i>P.getPriority(); i--)
                packs.get(i).setPriority(i-1);
        }
        
        //Swap pack position with newIndex
        if (newIndex != oldIndex) {
            P.setPriority(newIndex);
            //Sort table by priority
            tableView.setSort("priority", SortDirection.ASCENDING);//Priority always sorted Ascending
            rbCustom.setSelected(true);//Select Custom radio button
            Out.print(LOG_LEVEL.DEBUG, "Pack: " + P.getName() + "- priority (" + (oldIndex) + ">" + (newIndex) + ")");
            tableView.setSelectedIndex(newIndex);
            tableView.requestFocus();//Focus on table view selected row
        }
    }
}
 
Example #27
Source File: ExpandTransition.java    From setupmaker with Apache License 2.0 4 votes vote down vote up
public Component getComponent() {
    return component;
}
 
Example #28
Source File: AppearTransition.java    From setupmaker with Apache License 2.0 4 votes vote down vote up
public AppearTransition(Component component, int duration, int rate) {
    super(duration, rate, false);
    this.component = component;
}
 
Example #29
Source File: AppearTransition.java    From setupmaker with Apache License 2.0 4 votes vote down vote up
public Component getComponent() {
    return component;
}
 
Example #30
Source File: TaskIzpackDebug.java    From setupmaker with Apache License 2.0 4 votes vote down vote up
public TaskIzpackDebug(String TargetPath, Component LOGGER, String appName) {
    compiler.setTarget(TargetPath);
    Out.setLogger(LOGGER);
    this.appName = appName;
}